@ev-ai/agent-hook 1.3.7 → 1.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -2,54 +2,55 @@
2
2
  import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
 
5
- var Ip=Object.create;var Si=Object.defineProperty;var Tp=Object.getOwnPropertyDescriptor;var Pp=Object.getOwnPropertyNames;var wp=Object.getPrototypeOf,Np=Object.prototype.hasOwnProperty;var ze=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var V=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var vp=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Pp(t))!Np.call(e,o)&&o!==n&&Si(e,o,{get:()=>t[o],enumerable:!(r=Tp(t,o))||r.enumerable});return e};var Ve=(e,t,n)=>(n=e!=null?Ip(wp(e)):{},vp(t||!e||!e.__esModule?Si(n,"default",{value:e,enumerable:!0}):n,e));var rr=V(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.MCP_MISSING_LAUNCH_SERIALIZED=Z.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;Z.foldMcpName=Oc;Z.buildMcpFamilyCanonicalKey=w_;Z.launchContainsCredentials=v_;Z.serializeMcpLaunchIdentity=Ic;Z.hashMcpLaunchIdentity=qt;Z.projectMcpMissingLaunchIdentity=H_;Z.projectMcpLaunchIdentity=U_;Z.maskMcpLaunchForDisplay=F_;Z.normalizeMcpToolNames=$_;var P_=ze("node:crypto");Z.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";Z.MCP_MISSING_LAUNCH_SERIALIZED=`${Z.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function $e(e){return e.toLocaleLowerCase("en-US")}function Oc(e){return $e(e)}function w_(e){return`interface:${Oc(e)}`}var bc=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),N_=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function It(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function v_(e){return e.kind==="url"?M_(e.url):e.kind==="command"?e.arguments.some(t=>N_.test(t)):!1}function M_(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(bc.has($e(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=$e(i.split("=",1)[0]??"");return bc.has(a)})}}function Ic(e){if(e.kind==="url")return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",It($e(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>$e(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",It($e(e.command)),String(t.length),...t.map(It)].join("|")}return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",It(e.installationRootExternalKey),It(e.sourcePath),It(e.nativeKey)].join("|")}function qt(e){return(0,P_.createHash)("sha256").update(e).digest("hex")}var L_=qt(Z.MCP_MISSING_LAUNCH_SERIALIZED);function H_(){return{kind:"unknown",arguments:[],serialized:Z.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:L_}}function U_(e){let t=Ic(e);return e.kind==="url"?{kind:"url",url:$e(e.url),arguments:[],serialized:t,contentHash:qt(t)}:e.kind==="command"?{kind:"command",command:$e(e.command),arguments:[...e.arguments].map(n=>$e(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:qt(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:qt(t)}}var D_=/^(https?:\/\/)([^/?#]*@)/i;function F_(e){return e.replace(D_,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}function $_(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 sr=V(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.PACKAGE_FIELD_MAX=void 0;Te.npxExecBin=Tc;Te.packageNameFromSpec=or;Te.pinnedPackageVersionFromSpec=Pc;Te.pinnedPackageVersionFromNpx=Y_;Te.npxPackageSpecs=wc;Te.PACKAGE_FIELD_MAX=128;var j_=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,B_=new Set(["-p","--package"]),K_=new Set(["-c","--call"]),G_=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),W_=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),z_=/^--no-/;function V_(e){return W_.has(e)||z_.test(e)}function Tc(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}var J_=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function or(e){if(e.length===0||e.length>Te.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return j_.test(n)?n:null}function Pc(e){let t=or(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return J_.test(n)?n:void 0}function Y_(e,t){for(let n of wc(e,t)){let r=Pc(n);if(r!==void 0)return r}}function wc(e,t){let n=Tc(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(K_.has(l))return[];if(B_.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||V_(l))){if(G_.has(l)){i+=1;continue}return[]}}return o.length>0?o.every(i=>or(i)!==null)?o:[]:s===null||or(s)===null?[]:[s]}});var Nc=V(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.McpPackageEcosystem=void 0;lt.resolveMcpPackageIdentity=ch;var X_=rr(),Ho=sr();lt.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var q_=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,Z_=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,Q_=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function eh(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}var th=new Set(["--from","--spec"]),nh=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"]),rh=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"]),oh=/^--no-/;function sh(e,t){let n=eh(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(th.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||rh.has(l)||oh.test(l))){if(nh.has(l)){i+=1;continue}return null}}return o??s}function ih(e){if(e.length===0||e.length>Ho.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!Z_.test(r)||!Q_.test(o)?null:{ecosystem:lt.McpPackageEcosystem.PYPI,packageName:r,version:o}}function ah(e){let t=(0,Ho.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return q_.test(n)?{ecosystem:lt.McpPackageEcosystem.NPM,packageName:t,version:n}:null}function ch(e){if(e?.kind!=="command"||(0,X_.launchContainsCredentials)(e))return;for(let n of(0,Ho.npxPackageSpecs)(e.command,e.arguments)){let r=ah(n);if(r!==null)return r}let t=sh(e.command,e.arguments);if(t!==null)return ih(t)??void 0}});var Dc=V(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.EMPTY_NPM_PUBLISHER=void 0;je.isNpmRegistryPublisher=lh;je.displayPublisherName=fh;je.classifyMcpProvenance=yh;var Lc=rr(),Uo=sr();je.EMPTY_NPM_PUBLISHER="npm:";var vc="npm:",uh=/^[A-Za-z0-9._-]+$/;function lh(e){return e.startsWith(vc)&&e!==je.EMPTY_NPM_PUBLISHER&&uh.test(e.slice(vc.length))}function fh(e){if(!(e==null||e===""||e===je.EMPTY_NPM_PUBLISHER))return e}function Mc(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 dh(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 Do(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}function ph(e){let t=Do(e),n=dh(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||Mc(t)||n!==void 0&&Mc(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}function mh(e){let t=Do(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}function gh(e){let t=Do(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}function Hc(e){let t={kind:"url",url:e};if((0,Lc.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||ph(n.hostname))return{origin:"UNKNOWN"};let r=mh(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:gh(n)}}catch{return{origin:"UNKNOWN"}}}var Uc="mcp-remote";function _h(e,t){if(e===Uc)return t.find(n=>/^https?:\/\//i.test(n))}function hh(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}function Sh(e,t,n){let r=_h(e,t);return r!==void 0?Hc(r):e===Uc?{origin:"UNKNOWN"}:hh(e,n)}function Eh(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 yh(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,Lc.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return Hc(t.url);let r=(0,Uo.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,Uo.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let s=Sh(o,t.arguments,e.publisherName),i=typeof e.packageName=="string"?(0,Uo.packageNameFromSpec)(e.packageName):null;return i!==null&&i===o&&s.packageName!==void 0?{...s,packageName:i,packageKey:i}:s}return Eh(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}});var $c=V(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.mcpServerToolSegmentForms=Fc;ir.mcpServerNameMatchesToolSegment=Rh;function Fc(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}function Rh(e,t){let n=t.toLowerCase();return Fc(e).some(r=>r.toLowerCase()===n)}});var jc=V(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.parseFrontmatterField=Ce.parseFrontmatterDescription=Ce.usableCatalogText=void 0;var Ch=/^(?:>|\|)[-+]?$/,Ah=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,xh=e=>{let t=e?.trim()??"";if(!(t.length===0||Ch.test(t)))return t};Ce.usableCatalogText=xh;var kh=e=>(0,Ce.parseFrontmatterField)(e,"description");Ce.parseFrontmatterDescription=kh;var bh=(e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return Ih(n[1],t)};Ce.parseFrontmatterField=bh;var Oh=e=>e.replace(/^["']|["']$/g,"");function Ih(e,t){let n=e.split(`
6
- `),r=`${t}:`,o=n.findIndex(p=>p===r||p.startsWith(`${r} `)||p.startsWith(`${r} `));if(o<0)return;let s=(n[o]??"").slice(r.length).trim(),i=Ah.exec(s);if(!i){let p=Oh(s).trim();return(0,Ce.usableCatalogText)(p)}let a=[];for(let p=o+1;p<n.length;p+=1){let g=n[p]??"";if(g.trim()===""){a.push("");continue}if(g.length===g.trimStart().length)break;a.push(g)}let c=a.reduce((p,g)=>g.trim()===""?p:Math.min(p,g.length-g.trimStart().length),Number.POSITIVE_INFINITY),l=[],u=i[1]?.trim();u&&l.push(u);for(let p of a)l.push(p.trim()===""?"":p.slice(c));for(;l.length>0&&l[l.length-1]==="";)l.pop();let f=s.startsWith(">")?l.join(`
5
+ var km=Object.create;var Fi=Object.defineProperty;var xm=Object.getOwnPropertyDescriptor;var Om=Object.getOwnPropertyNames;var Im=Object.getPrototypeOf,Tm=Object.prototype.hasOwnProperty;var Ze=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Pm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Om(t))!Tm.call(e,o)&&o!==n&&Fi(e,o,{get:()=>t[o],enumerable:!(r=xm(t,o))||r.enumerable});return e};var Qe=(e,t,n)=>(n=e!=null?km(Im(e)):{},Pm(t||!e||!e.__esModule?Fi(n,"default",{value:e,enumerable:!0}):n,e));var Sr=z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.MCP_MISSING_LAUNCH_SERIALIZED=Q.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;Q.foldMcpName=lu;Q.buildMcpFamilyCanonicalKey=Yh;Q.launchContainsCredentials=qh;Q.serializeMcpLaunchIdentity=fu;Q.hashMcpLaunchIdentity=an;Q.projectMcpMissingLaunchIdentity=eS;Q.projectMcpLaunchIdentity=tS;Q.maskMcpLaunchForDisplay=rS;Q.normalizeMcpToolNames=oS;var Jh=Ze("node:crypto");Q.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";Q.MCP_MISSING_LAUNCH_SERIALIZED=`${Q.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function Ve(e){return e.toLocaleLowerCase("en-US")}function lu(e){return Ve(e)}function Yh(e){return`interface:${lu(e)}`}var uu=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),Xh=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function Lt(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function qh(e){return e.kind==="url"?Zh(e.url):e.kind==="command"?e.arguments.some(t=>Xh.test(t)):!1}function Zh(e){try{let t=new URL(e);if(t.username.length>0||t.password.length>0)return!0;for(let n of t.searchParams.keys())if(uu.has(Ve(n)))return!0;return!1}catch{let t=e.split("://",2),n=t.length===2?t[1]:e,r=n.indexOf("@"),o=n.indexOf("/");if(r>0&&(o===-1||r<o))return!0;let s=e.split("?",2)[1];return s===void 0?!1:s.split("&").some(i=>{let a=Ve(i.split("=",1)[0]??"");return uu.has(a)})}}function fu(e){if(e.kind==="url")return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",Lt(Ve(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>Ve(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",Lt(Ve(e.command)),String(t.length),...t.map(Lt)].join("|")}return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",Lt(e.installationRootExternalKey),Lt(e.sourcePath),Lt(e.nativeKey)].join("|")}function an(e){return(0,Jh.createHash)("sha256").update(e).digest("hex")}var Qh=an(Q.MCP_MISSING_LAUNCH_SERIALIZED);function eS(){return{kind:"unknown",arguments:[],serialized:Q.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:Qh}}function tS(e){let t=fu(e);return e.kind==="url"?{kind:"url",url:Ve(e.url),arguments:[],serialized:t,contentHash:an(t)}:e.kind==="command"?{kind:"command",command:Ve(e.command),arguments:[...e.arguments].map(n=>Ve(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:an(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:an(t)}}var nS=/^(https?:\/\/)([^/?#]*@)/i;function rS(e){return e.replace(nS,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}function oS(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n.sort((r,o)=>r<o?-1:r>o?1:0),n}});var yr=z(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.PACKAGE_FIELD_MAX=void 0;we.npxExecBin=du;we.packageNameFromSpec=Er;we.pinnedPackageVersionFromSpec=pu;we.pinnedPackageVersionFromNpx=pS;we.npxPackageSpecs=mu;we.PACKAGE_FIELD_MAX=128;var sS=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,iS=new Set(["-p","--package"]),aS=new Set(["-c","--call"]),cS=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),uS=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),lS=/^--no-/;function fS(e){return uS.has(e)||lS.test(e)}function du(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}var dS=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function Er(e){if(e.length===0||e.length>we.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return sS.test(n)?n:null}function pu(e){let t=Er(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return dS.test(n)?n:void 0}function pS(e,t){for(let n of mu(e,t)){let r=pu(n);if(r!==void 0)return r}}function mu(e,t){let n=du(e);if(n===null)return[];let r=[...t];if(n==="npm"){let i=r[0]?.toLowerCase();if(i!=="exec"&&i!=="x")return[];r=r.slice(1)}let o=[],s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(aS.has(l))return[];if(iS.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&o.push(u),c===-1&&(i+=1);continue}if(!(c!==-1||fS(l))){if(cS.has(l)){i+=1;continue}return[]}}return o.length>0?o.every(i=>Er(i)!==null)?o:[]:s===null||Er(s)===null?[]:[s]}});var gu=z(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.McpPackageEcosystem=void 0;ht.resolveMcpPackageIdentity=xS;var mS=Sr(),qo=yr();ht.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var gS=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,_S=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,hS=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function SS(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}var ES=new Set(["--from","--spec"]),yS=new Set(["--python","-p","--with","--with-editable","--with-requirements","--index","--index-url","--default-index","--extra-index-url","--find-links","-f","--constraint","-c","--override","--refresh-package","--cache-dir","--directory","--project","--config-file","--color","--exclude-newer","--pip-args","--verbose-pip"]),RS=new Set(["-q","--quiet","-v","--verbose","-n","--native-tls","--offline","--isolated","--preview","--refresh","--reinstall","--upgrade","-U","--force","--system","--system-site-packages","--path","--managed-python","--progress"]),CS=/^--no-/;function AS(e,t){let n=SS(e);if(n===null)return null;let r=[...t];if(n==="uv"){if(r[0]?.toLowerCase()!=="tool"||r[1]?.toLowerCase()!=="run")return null;r=r.slice(2)}else if(n==="pipx"){if(r[0]?.toLowerCase()!=="run")return null;r=r.slice(1)}let o=null,s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(ES.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&(o=u),c===-1&&(i+=1);continue}if(!(c!==-1||RS.has(l)||CS.test(l))){if(yS.has(l)){i+=1;continue}return null}}return o??s}function bS(e){if(e.length===0||e.length>qo.PACKAGE_FIELD_MAX)return null;let t=e.includes("==")?"==":e.includes("@")?"@":null;if(t===null)return null;let n=e.indexOf(t),r=e.slice(0,n),o=e.slice(n+t.length);return!_S.test(r)||!hS.test(o)?null:{ecosystem:ht.McpPackageEcosystem.PYPI,packageName:r,version:o}}function kS(e){let t=(0,qo.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return gS.test(n)?{ecosystem:ht.McpPackageEcosystem.NPM,packageName:t,version:n}:null}function xS(e){if(e?.kind!=="command"||(0,mS.launchContainsCredentials)(e))return;for(let n of(0,qo.npxPackageSpecs)(e.command,e.arguments)){let r=kS(n);if(r!==null)return r}let t=AS(e.command,e.arguments);if(t!==null)return bS(t)??void 0}});var Ru=z(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.EMPTY_NPM_PUBLISHER=void 0;We.isNpmRegistryPublisher=IS;We.displayPublisherName=TS;We.classifyMcpProvenance=DS;var Su=Sr(),Zo=yr();We.EMPTY_NPM_PUBLISHER="npm:";var _u="npm:",OS=/^[A-Za-z0-9._-]+$/;function IS(e){return e.startsWith(_u)&&e!==We.EMPTY_NPM_PUBLISHER&&OS.test(e.slice(_u.length))}function TS(e){if(!(e==null||e===""||e===We.EMPTY_NPM_PUBLISHER))return e}function hu(e){let t=e.split(".").map(Number);return t.length!==4||t.some(n=>!Number.isInteger(n)||n<0||n>255)?!1:t[0]===0||t[0]===10||t[0]===127||t[0]===169&&t[1]===254||t[0]===172&&(t[1]??0)>=16&&(t[1]??0)<=31||t[0]===192&&t[1]===168}function PS(e){let t=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(e);if(t?.[1])return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(e);if(!n)return;let r=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16);return`${r>>8&255}.${r&255}.${o>>8&255}.${o&255}`}function Qo(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}function wS(e){let t=Qo(e),n=PS(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||hu(t)||n!==void 0&&hu(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}function NS(e){let t=Qo(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}function vS(e){let t=Qo(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}function Eu(e){let t={kind:"url",url:e};if((0,Su.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||wS(n.hostname))return{origin:"UNKNOWN"};let r=NS(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:vS(n)}}catch{return{origin:"UNKNOWN"}}}var yu="mcp-remote";function MS(e,t){if(e===yu)return t.find(n=>/^https?:\/\//i.test(n))}function LS(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}function HS(e,t,n){let r=MS(e,t);return r!==void 0?Eu(r):e===yu?{origin:"UNKNOWN"}:LS(e,n)}function US(e){let t=e.replaceAll("\\","/");return t.startsWith("~/")||t.startsWith("/")||/^[A-Za-z]:\//.test(t)?!1:t.startsWith("./")||t.startsWith("../")||t==="scripts"||t.startsWith("scripts/")}function DS(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,Su.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return Eu(t.url);let r=(0,Zo.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,Zo.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let s=HS(o,t.arguments,e.publisherName),i=typeof e.packageName=="string"?(0,Zo.packageNameFromSpec)(e.packageName):null;return i!==null&&i===o&&s.packageName!==void 0?{...s,packageName:i,packageKey:i}:s}return US(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}});var Au=z(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.mcpServerToolSegmentForms=Cu;Rr.mcpServerNameMatchesToolSegment=FS;function Cu(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}function FS(e,t){let n=t.toLowerCase();return Cu(e).some(r=>r.toLowerCase()===n)}});var bu=z(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.parseFrontmatterField=be.parseFrontmatterDescription=be.usableCatalogText=void 0;var $S=/^(?:>|\|)[-+]?$/,jS=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,BS=e=>{let t=e?.trim()??"";if(!(t.length===0||$S.test(t)))return t};be.usableCatalogText=BS;var KS=e=>(0,be.parseFrontmatterField)(e,"description");be.parseFrontmatterDescription=KS;var GS=(e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return WS(n[1],t)};be.parseFrontmatterField=GS;var VS=e=>e.replace(/^["']|["']$/g,"");function WS(e,t){let n=e.split(`
6
+ `),r=`${t}:`,o=n.findIndex(p=>p===r||p.startsWith(`${r} `)||p.startsWith(`${r} `));if(o<0)return;let s=(n[o]??"").slice(r.length).trim(),i=jS.exec(s);if(!i){let p=VS(s).trim();return(0,be.usableCatalogText)(p)}let a=[];for(let p=o+1;p<n.length;p+=1){let g=n[p]??"";if(g.trim()===""){a.push("");continue}if(g.length===g.trimStart().length)break;a.push(g)}let c=a.reduce((p,g)=>g.trim()===""?p:Math.min(p,g.length-g.trimStart().length),Number.POSITIVE_INFINITY),l=[],u=i[1]?.trim();u&&l.push(u);for(let p of a)l.push(p.trim()===""?"":p.slice(c));for(;l.length>0&&l[l.length-1]==="";)l.pop();let f=s.startsWith(">")?l.join(`
7
7
  `).split(/\n{2,}/).map(p=>p.split(`
8
8
  `).map(g=>g.trim()).filter(Boolean).join(" ")).filter(p=>p.length>0).join(`
9
9
 
10
10
  `):l.join(`
11
- `).trimEnd();return(0,Ce.usableCatalogText)(f)}});var Gc=V(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=Q.COMPONENT_INSPECTION_TEXT_MAX_BYTES=Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;Q.fitSnapshotInspectionTextBudget=Th;Q.capComponentTextBytes=Kc;Q.prepareComponentInspectionText=Ph;Q.redactComponentSource=Fo;Q.componentSourceContainsRedactableSecret=Uh;Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";Q.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;Q.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function Th(e){let t=0;return e.map(n=>{let r=n,o=r.skill?.inspectionText;if(o===void 0)return n;let s=Buffer.byteLength(o,"utf8");return t+s<=Q.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=s,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}function Kc(e,t){if(e==null||e.length===0)return;let n=Buffer.from(e,"utf8");if(n.byteLength<=t)return e;let r=new TextDecoder("utf-8",{fatal:!0});for(let o=t;o>0;o-=1)try{return r.decode(n.subarray(0,o))}catch{}}function Ph(e){if(!(e==null||e.length===0))return Kc(Fo(e),Q.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}var wh=[/\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],Nh=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,vh=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,Mh=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,Lh=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,Bc=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function Hh(e){let t=e.replace(vh,(n,r)=>`${r}${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(Mh,(n,r)=>`${r}${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(Nh,(n,r)=>`${r}${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of wh)t=t.replace(n,Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}function Fo(e){if(e.length===0)return e;let t=e.split(`
12
- `),n=!1;return t.map(o=>n?Bc.test(o)?(n=!1,o):o.trim().length===0?o:Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:Lh.test(o)&&!Bc.test(o)?(n=!0,o):Hh(o)).join(`
13
- `)}function Uh(e){return Fo(e)!==e}});var rt=V(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=Vh;y.installationRootExternalKey=Jh;y.normalizeRepositoryRelativePath=Wc;y.nativeKeyForSkillPath=Yh;y.nativeKeyForRulePath=Xh;y.nativeKeyForCommandPath=qh;y.serializeComponentIdentity=Vc;y.buildComponentReference=Qh;y.validateComponentReference=eS;var Dh=ze("node:crypto"),Fh=ze("node:path"),$h="cmp1_",jh=/^cmp1_[A-Za-z0-9_-]{43}$/,Bh=["/skills/","/skills-cursor/"],Kh=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,Gh=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,Wh=[".cursor",".claude",".codex"],zh={".claude.json":".claude",".agents":".codex"};y.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function Vh(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>Wh.includes(o));return n||(t.map(o=>zh[o]).find(o=>o!==void 0)??"unknown")}function Jh(e,t){return`runtime-install:${e}/${t}`}function ar(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function Wc(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=Fh.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return ar(n,"sourcePath")}function Yh(e){let t=e.replaceAll("\\","/");for(let n of Bh){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function zc(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 Xh(e){return zc(e,Kh,/\.(mdc|md|rules)$/i)}function qh(e){return zc(e,Gh,/\.(md|mdc|toml)$/i)}function Zh(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Vc(e){let t=[ar(e.installationRootExternalKey,"installationRootExternalKey"),ar(e.installableKind,"installableKind"),Wc(e.sourcePath),ar(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(Zh).join("|")}`,"utf8")}function Qh(e){let t=(0,Dh.createHash)("sha256").update(Vc(e)).digest("base64url");return`${$h}${t}`}function eS(e){return jh.test(e)}var Ae=rr();Object.defineProperty(y,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:function(){return Ae.buildMcpFamilyCanonicalKey}});Object.defineProperty(y,"foldMcpName",{enumerable:!0,get:function(){return Ae.foldMcpName}});Object.defineProperty(y,"hashMcpLaunchIdentity",{enumerable:!0,get:function(){return Ae.hashMcpLaunchIdentity}});Object.defineProperty(y,"launchContainsCredentials",{enumerable:!0,get:function(){return Ae.launchContainsCredentials}});Object.defineProperty(y,"maskMcpLaunchForDisplay",{enumerable:!0,get:function(){return Ae.maskMcpLaunchForDisplay}});Object.defineProperty(y,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:function(){return Ae.MCP_LAUNCH_IDENTITY_ALGORITHM}});Object.defineProperty(y,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:function(){return Ae.MCP_MISSING_LAUNCH_SERIALIZED}});Object.defineProperty(y,"normalizeMcpToolNames",{enumerable:!0,get:function(){return Ae.normalizeMcpToolNames}});Object.defineProperty(y,"projectMcpLaunchIdentity",{enumerable:!0,get:function(){return Ae.projectMcpLaunchIdentity}});Object.defineProperty(y,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:function(){return Ae.projectMcpMissingLaunchIdentity}});Object.defineProperty(y,"serializeMcpLaunchIdentity",{enumerable:!0,get:function(){return Ae.serializeMcpLaunchIdentity}});var Tt=sr();Object.defineProperty(y,"PACKAGE_FIELD_MAX",{enumerable:!0,get:function(){return Tt.PACKAGE_FIELD_MAX}});Object.defineProperty(y,"npxExecBin",{enumerable:!0,get:function(){return Tt.npxExecBin}});Object.defineProperty(y,"npxPackageSpecs",{enumerable:!0,get:function(){return Tt.npxPackageSpecs}});Object.defineProperty(y,"packageNameFromSpec",{enumerable:!0,get:function(){return Tt.packageNameFromSpec}});Object.defineProperty(y,"pinnedPackageVersionFromNpx",{enumerable:!0,get:function(){return Tt.pinnedPackageVersionFromNpx}});Object.defineProperty(y,"pinnedPackageVersionFromSpec",{enumerable:!0,get:function(){return Tt.pinnedPackageVersionFromSpec}});var Jc=Nc();Object.defineProperty(y,"McpPackageEcosystem",{enumerable:!0,get:function(){return Jc.McpPackageEcosystem}});Object.defineProperty(y,"resolveMcpPackageIdentity",{enumerable:!0,get:function(){return Jc.resolveMcpPackageIdentity}});var cr=Dc();Object.defineProperty(y,"classifyMcpProvenance",{enumerable:!0,get:function(){return cr.classifyMcpProvenance}});Object.defineProperty(y,"displayPublisherName",{enumerable:!0,get:function(){return cr.displayPublisherName}});Object.defineProperty(y,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:function(){return cr.EMPTY_NPM_PUBLISHER}});Object.defineProperty(y,"isNpmRegistryPublisher",{enumerable:!0,get:function(){return cr.isNpmRegistryPublisher}});var Yc=$c();Object.defineProperty(y,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:function(){return Yc.mcpServerNameMatchesToolSegment}});Object.defineProperty(y,"mcpServerToolSegmentForms",{enumerable:!0,get:function(){return Yc.mcpServerToolSegmentForms}});var $o=jc();Object.defineProperty(y,"parseFrontmatterDescription",{enumerable:!0,get:function(){return $o.parseFrontmatterDescription}});Object.defineProperty(y,"parseFrontmatterField",{enumerable:!0,get:function(){return $o.parseFrontmatterField}});Object.defineProperty(y,"usableCatalogText",{enumerable:!0,get:function(){return $o.usableCatalogText}});var nt=Gc();Object.defineProperty(y,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return nt.COMPONENT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:function(){return nt.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}});Object.defineProperty(y,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return nt.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"capComponentTextBytes",{enumerable:!0,get:function(){return nt.capComponentTextBytes}});Object.defineProperty(y,"componentSourceContainsRedactableSecret",{enumerable:!0,get:function(){return nt.componentSourceContainsRedactableSecret}});Object.defineProperty(y,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:function(){return nt.fitSnapshotInspectionTextBudget}});Object.defineProperty(y,"prepareComponentInspectionText",{enumerable:!0,get:function(){return nt.prepareComponentInspectionText}});Object.defineProperty(y,"redactComponentSource",{enumerable:!0,get:function(){return nt.redactComponentSource}})});var br=V(Ee=>{"use strict";Ee.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Ee.find=(e,t)=>e.nodes.find(n=>n.type===t);Ee.exceedsLimit=(e,t,n=1,r)=>r===!1||!Ee.isInteger(e)||!Ee.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Ee.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)};Ee.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Ee.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;Ee.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Ee.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Ee.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 Or=V((YI,kl)=>{"use strict";var xl=br();kl.exports=(e,t={})=>{let n=(r,o={})=>{let s=t.escapeInvalid&&xl.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a="";if(r.value)return(s||i)&&xl.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 Ol=V((XI,bl)=>{"use strict";bl.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var Hl=V((qI,Ll)=>{"use strict";var Il=Ol(),dt=(e,t,n)=>{if(Il(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(Il(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(dt.cache.hasOwnProperty(c))return dt.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=Ml(e)||Ml(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=Tl(S,Math.abs(l),f,r),l=f.a=0}return u>=0&&(p=Tl(l,u,f,r)),f.negatives=g,f.positives=p,f.result=Ay(g,p,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&p.length+g.length>1&&(f.result=`(?:${f.result})`),dt.cache[c]=f,f.result};function Ay(e,t,n){let r=Ss(e,t,"-",!1,n)||[],o=Ss(t,e,"",!1,n)||[],s=Ss(e,t,"-?",!0,n)||[];return r.concat(s).concat(o).join("|")}function xy(e,t){let n=1,r=1,o=wl(e,n),s=new Set([t]);for(;e<=o&&o<=t;)s.add(o),n+=1,o=wl(e,n);for(o=Nl(t+1,r)-1;e<o&&o<=t;)s.add(o),r+=1,o=Nl(t+1,r)-1;return s=[...s],s.sort(Oy),s}function ky(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=by(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+=Iy(c,l,n):i++}return i&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[i],digits:o}}function Tl(e,t,n,r){let o=xy(e,t),s=[],i=e,a;for(let c=0;c<o.length;c++){let l=o[c],u=ky(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+vl(a.count),i=l+1;continue}n.isPadded&&(d=Ty(l,n,r)),u.string=d+u.pattern+vl(u.count),s.push(u),i=l+1,a=u}return s}function Ss(e,t,n,r,o){let s=[];for(let i of e){let{string:a}=i;!r&&!Pl(t,"string",a)&&s.push(n+a),r&&Pl(t,"string",a)&&s.push(n+a)}return s}function by(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}function Oy(e,t){return e>t?1:t>e?-1:0}function Pl(e,t,n){return e.some(r=>r[t]===n)}function wl(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}function Nl(e,t){return e-e%Math.pow(10,t)}function vl(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}function Iy(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}function Ml(e){return/^-?(0+)\d/.test(e)}function Ty(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}}`}}dt.cache={};dt.clearCache=()=>dt.cache={};Ll.exports=dt});var Rs=V((ZI,Kl)=>{"use strict";var Py=ze("util"),Dl=Hl(),Ul=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),wy=e=>t=>e===!0?Number(t):String(t),Es=e=>typeof e=="number"||typeof e=="string"&&e!=="",cn=e=>Number.isInteger(+e),ys=e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},Ny=(e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,vy=(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},Tr=(e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},My=(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=>Tr(String(a),n)).join("|")),e.negatives.length&&(s=`-(${r}${e.negatives.map(a=>Tr(String(a),n)).join("|")})`),o&&s?i=`${o}|${s}`:i=o||s,t.wrap?`(${r}${i})`:i},Fl=(e,t,n,r)=>{if(n)return Dl(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let s=String.fromCharCode(t);return`[${o}-${s}]`},$l=(e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return Dl(e,t,n)},jl=(...e)=>new RangeError("Invalid range arguments: "+Py.inspect(...e)),Bl=(e,t,n)=>{if(n.strictRanges===!0)throw jl([e,t]);return[]},Ly=(e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},Hy=(e,t,n=1,r={})=>{let o=Number(e),s=Number(t);if(!Number.isInteger(o)||!Number.isInteger(s)){if(r.strictRanges===!0)throw jl([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=ys(a)||ys(c)||ys(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&Ny(e,t,r)===!1,p=r.transform||wy(f);if(r.toRegex&&n===1)return Fl(Tr(e,d),Tr(t,d),!0,r);let g={negatives:[],positives:[]},S=I=>g[I<0?"negatives":"positives"].push(Math.abs(I)),A=[],x=0;for(;i?o>=s:o<=s;)r.toRegex===!0&&n>1?S(o):A.push(vy(p(o,x),d,f)),o=i?o-n:o+n,x++;return r.toRegex===!0?n>1?My(g,r,d):$l(A,null,{wrap:!1,...r}):A},Uy=(e,t,n=1,r={})=>{if(!cn(e)&&e.length>1||!cn(t)&&t.length>1)return Bl(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 Fl(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?$l(u,null,{wrap:!1,options:r}):u},Ir=(e,t,n,r={})=>{if(t==null&&Es(e))return[e];if(!Es(e)||!Es(t))return Bl(e,t,r);if(typeof n=="function")return Ir(e,t,1,{transform:n});if(Ul(n))return Ir(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,cn(n)?cn(e)&&cn(t)?Hy(e,t,n,o):Uy(e,t,Math.max(Math.abs(n),1),o):n!=null&&!Ul(n)?Ly(n,o):Ir(e,t,1,n)};Kl.exports=Ir});var zl=V((QI,Wl)=>{"use strict";var Dy=Rs(),Gl=br(),Fy=(e,t={})=>{let n=(r,o={})=>{let s=Gl.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=Gl.reduce(r.nodes),d=Dy(...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)};Wl.exports=Fy});var Yl=V((eT,Jl)=>{"use strict";var $y=Rs(),Vl=Or(),wt=br(),pt=(e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?wt.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let s of o)r.push(pt(s,t,n));else for(let s of t)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?pt(o,s,n):o+s);return wt.flatten(r)},jy=(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(pt(a.pop(),Vl(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){a.push(pt(a.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let d=wt.reduce(o.nodes);if(wt.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=$y(...d,t);f.length===0&&(f=Vl(o,t)),a.push(pt(a.pop(),f)),o.nodes=[];return}let c=wt.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(pt(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(pt(l.pop(),f.value));continue}f.nodes&&r(f,o)}return l};return wt.flatten(r(e))};Jl.exports=jy});var ql=V((tT,Xl)=>{"use strict";Xl.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 nf=V((nT,tf)=>{"use strict";var By=Or(),{MAX_LENGTH:Zl,CHAR_BACKSLASH:Cs,CHAR_BACKTICK:Ky,CHAR_COMMA:Gy,CHAR_DOT:Wy,CHAR_LEFT_PARENTHESES:zy,CHAR_RIGHT_PARENTHESES:Vy,CHAR_LEFT_CURLY_BRACE:Jy,CHAR_RIGHT_CURLY_BRACE:Yy,CHAR_LEFT_SQUARE_BRACKET:Ql,CHAR_RIGHT_SQUARE_BRACKET:ef,CHAR_DOUBLE_QUOTE:Xy,CHAR_SINGLE_QUOTE:qy,CHAR_NO_BREAK_SPACE:Zy,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Qy}=ql(),eR=(e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Zl,n.maxLength):Zl;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===Qy||f===Zy)){if(f===Cs){g({type:"text",value:(t.keepEscaping?f:"")+p()});continue}if(f===ef){g({type:"text",value:"\\"+f});continue}if(f===Ql){c++;let S;for(;u<l&&(S=p());){if(f+=S,S===Ql){c++;continue}if(S===Cs){f+=p();continue}if(S===ef&&(c--,c===0))break}g({type:"text",value:f});continue}if(f===zy){i=g({type:"paren",nodes:[]}),s.push(i),g({type:"text",value:f});continue}if(f===Vy){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===Xy||f===qy||f===Ky){let S=f,A;for(t.keepQuotes!==!0&&(f="");u<l&&(A=p());){if(A===Cs){f+=A+p();continue}if(A===S){t.keepQuotes===!0&&(f+=A);break}f+=A}g({type:"text",value:f});continue}if(f===Jy){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===Yy){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===Gy&&d>0){if(i.ranges>0){i.ranges=0;let S=i.nodes.shift();i.nodes=[S,{type:"text",value:By(i)}]}g({type:"comma",value:f}),i.commas++;continue}if(f===Wy&&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(x=>{x.nodes||(x.type==="open"&&(x.isOpen=!0),x.type==="close"&&(x.isClose=!0),x.nodes||(x.type="text"),x.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};tf.exports=eR});var sf=V((rT,of)=>{"use strict";var rf=Or(),tR=zl(),nR=Yl(),rR=nf(),pe=(e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=pe.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(pe.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n};pe.parse=(e,t={})=>rR(e,t);pe.stringify=(e,t={})=>rf(typeof e=="string"?pe.parse(e,t):e,t);pe.compile=(e,t={})=>(typeof e=="string"&&(e=pe.parse(e,t)),tR(e,t));pe.expand=(e,t={})=>{typeof e=="string"&&(e=pe.parse(e,t));let n=nR(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};pe.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?pe.compile(e,t):pe.expand(e,t);of.exports=pe});var un=V((oT,ff)=>{"use strict";var oR=ze("path"),we="\\\\/",af=`[^${we}]`,sR=0,Ge="\\.",iR="\\+",aR="\\?",Pr="\\/",cR="(?=.)",cf="[^/]",As=`(?:${Pr}|$)`,uf=`(?:^|${Pr})`,xs=`${Ge}{1,2}${As}`,uR=`(?!${Ge})`,lR=`(?!${uf}${xs})`,fR=`(?!${Ge}{0,1}${As})`,dR=`(?!${xs})`,pR=`[^.${Pr}]`,mR=`${cf}*?`,lf={DOT_LITERAL:Ge,PLUS_LITERAL:iR,QMARK_LITERAL:aR,SLASH_LITERAL:Pr,ONE_CHAR:cR,QMARK:cf,END_ANCHOR:As,DOTS_SLASH:xs,NO_DOT:uR,NO_DOTS:lR,NO_DOT_SLASH:fR,NO_DOTS_SLASH:dR,QMARK_NO_DOT:pR,STAR:mR,START_ANCHOR:uf},gR={...lf,SLASH_LITERAL:`[${we}]`,QMARK:af,STAR:`${af}*?`,DOTS_SLASH:`${Ge}{1,2}(?:[${we}]|$)`,NO_DOT:`(?!${Ge})`,NO_DOTS:`(?!(?:^|[${we}])${Ge}{1,2}(?:[${we}]|$))`,NO_DOT_SLASH:`(?!${Ge}{0,1}(?:[${we}]|$))`,NO_DOTS_SLASH:`(?!${Ge}{1,2}(?:[${we}]|$))`,QMARK_NO_DOT:`[^.${we}]`,START_ANCHOR:`(?:^|[${we}])`,END_ANCHOR:`(?:[${we}]|$)`},_R={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};ff.exports={DEFAULT_MAX_EXTGLOB_RECURSION:sR,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:_R,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:oR.sep,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?gR:lf}}});var ln=V(ce=>{"use strict";var hR=ze("path"),SR=process.platform==="win32",{REGEX_BACKSLASH:ER,REGEX_REMOVE_BACKSLASH:yR,REGEX_SPECIAL_CHARS:RR,REGEX_SPECIAL_CHARS_GLOBAL:CR}=un();ce.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);ce.hasRegexChars=e=>RR.test(e);ce.isRegexChar=e=>e.length===1&&ce.hasRegexChars(e);ce.escapeRegex=e=>e.replace(CR,"\\$1");ce.toPosixSlashes=e=>e.replace(ER,"/");ce.removeBackslashes=e=>e.replace(yR,t=>t==="\\"?"":t);ce.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};ce.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:SR===!0||hR.sep==="\\";ce.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?ce.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};ce.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};ce.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${e})${o}`;return t.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var Ef=V((iT,Sf)=>{"use strict";var df=ln(),{CHAR_ASTERISK:ks,CHAR_AT:AR,CHAR_BACKWARD_SLASH:fn,CHAR_COMMA:xR,CHAR_DOT:bs,CHAR_EXCLAMATION_MARK:Os,CHAR_FORWARD_SLASH:hf,CHAR_LEFT_CURLY_BRACE:Is,CHAR_LEFT_PARENTHESES:Ts,CHAR_LEFT_SQUARE_BRACKET:kR,CHAR_PLUS:bR,CHAR_QUESTION_MARK:pf,CHAR_RIGHT_CURLY_BRACE:OR,CHAR_RIGHT_PARENTHESES:mf,CHAR_RIGHT_SQUARE_BRACKET:IR}=un(),gf=e=>e===hf||e===fn,_f=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},TR=(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,x=!1,I=!1,O=!1,v=!1,T=!1,K=0,D,b,w={value:"",depth:0,isGlob:!1},H=()=>l>=r,m=()=>c.charCodeAt(l+1),k=()=>(D=b,c.charCodeAt(++l));for(;l<r;){b=k();let ie;if(b===fn){I=w.backslashes=!0,b=k(),b===Is&&(x=!0);continue}if(x===!0||b===Is){for(K++;H()!==!0&&(b=k());){if(b===fn){I=w.backslashes=!0,k();continue}if(b===Is){K++;continue}if(x!==!0&&b===bs&&(b=k())===bs){if(f=w.isBrace=!0,g=w.isGlob=!0,T=!0,o===!0)continue;break}if(x!==!0&&b===xR){if(f=w.isBrace=!0,g=w.isGlob=!0,T=!0,o===!0)continue;break}if(b===OR&&(K--,K===0)){x=!1,f=w.isBrace=!0,T=!0;break}}if(o===!0)continue;break}if(b===hf){if(s.push(l),i.push(w),w={value:"",depth:0,isGlob:!1},T===!0)continue;if(D===bs&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(b===bR||b===AR||b===ks||b===pf||b===Os)===!0&&m()===Ts){if(g=w.isGlob=!0,S=w.isExtglob=!0,T=!0,b===Os&&l===u&&(v=!0),o===!0){for(;H()!==!0&&(b=k());){if(b===fn){I=w.backslashes=!0,b=k();continue}if(b===mf){g=w.isGlob=!0,T=!0;break}}continue}break}if(b===ks){if(D===ks&&(A=w.isGlobstar=!0),g=w.isGlob=!0,T=!0,o===!0)continue;break}if(b===pf){if(g=w.isGlob=!0,T=!0,o===!0)continue;break}if(b===kR){for(;H()!==!0&&(ie=k());){if(ie===fn){I=w.backslashes=!0,k();continue}if(ie===IR){p=w.isBracket=!0,g=w.isGlob=!0,T=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&b===Os&&l===u){O=w.negated=!0,u++;continue}if(n.noparen!==!0&&b===Ts){if(g=w.isGlob=!0,o===!0){for(;H()!==!0&&(b=k());){if(b===Ts){I=w.backslashes=!0,b=k();continue}if(b===mf){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,le="",_="";u>0&&(le=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&&gf(U.charCodeAt(U.length-1))&&(U=U.slice(0,-1)),n.unescape===!0&&(_&&(_=df.removeBackslashes(_)),U&&I===!0&&(U=df.removeBackslashes(U)));let h={prefix:le,input:e,start:u,base:U,glob:_,isBrace:f,isBracket:p,isGlob:g,isExtglob:S,isGlobstar:A,negated:O,negatedExtglob:v};if(n.tokens===!0&&(h.maxDepth=0,gf(b)||i.push(w),h.tokens=i),n.parts===!0||n.tokens===!0){let ie;for(let F=0;F<s.length;F++){let xe=ie?ie+1:u,ke=s[F],fe=e.slice(xe,ke);n.tokens&&(F===0&&u!==0?(i[F].isPrefix=!0,i[F].value=le):i[F].value=fe,_f(i[F]),h.maxDepth+=i[F].depth),(F!==0||fe!=="")&&a.push(fe),ie=ke}if(ie&&ie+1<e.length){let F=e.slice(ie+1);a.push(F),n.tokens&&(i[i.length-1].value=F,_f(i[i.length-1]),h.maxDepth+=i[i.length-1].depth)}h.slashes=s,h.parts=a}return h};Sf.exports=TR});var xf=V((aT,Af)=>{"use strict";var dn=un(),se=ln(),{MAX_LENGTH:wr,POSIX_REGEX_SOURCE:PR,REGEX_NON_SPECIAL_CHARS:wR,REGEX_SPECIAL_CHARS_BACKREF:NR,REPLACEMENTS:yf}=dn,vR=(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},Nt=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,Rf=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},MR=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},Cf=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(MR(t))return t.replace(/\\(.)/g,"$1")},LR=e=>{let t=e.map(Cf).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},Ps=(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}}}}},HR=e=>{let t=0,n=[];for(;t<e.length;){let o=Ps(e.slice(t),!1);if(!o||o.type!=="*")return;let s=Rf(o.body).map(a=>a.trim());if(s.length!==1)return;let i=Cf(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("")}]`}*`},UR=e=>{let t=0,n=e.trim(),r=Ps(n);for(;r;)t++,n=r.body.trim(),r=Ps(n);return t},DR=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:dn.DEFAULT_MAX_EXTGLOB_RECURSION,r=Rf(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||LR(r)))return{risky:!0};for(let o of r){let s=HR(o);if(s)return{risky:!0,safeOutput:s};if(UR(o)>n)return{risky:!0}}return{risky:!1}},ws=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=yf[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=dn.globChars(c),u=dn.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,SLASH_LITERAL:p,ONE_CHAR:g,DOTS_SLASH:S,NO_DOT:A,NO_DOT_SLASH:x,NO_DOTS_SLASH:I,QMARK:O,QMARK_NO_DOT:v,STAR:T,START_ANCHOR:K}=l,D=C=>`(${a}(?:(?!${K}${C.dot?S:d}).)*?)`,b=n.dot?"":A,w=n.dot?O:v,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=[],le=[],_=s,h,ie=()=>m.index===o-1,F=m.peek=(C=1)=>e[m.index+C],xe=m.advance=()=>e[++m.index]||"",ke=()=>e.slice(m.index+1),fe=(C="",Y=0)=>{m.consumed+=C,m.index+=Y},xn=C=>{m.output+=C.output!=null?C.output:C.value,fe(C.value)},bp=()=>{let C=1;for(;F()==="!"&&(F(2)!=="("||F(3)==="?");)xe(),m.start++,C++;return C%2===0?!1:(m.negated=!0,m.start++,!0)},kn=C=>{m[C]++,le.push(C)},We=C=>{m[C]--,le.pop()},N=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)&&xn(C),_&&_.type==="text"&&C.type==="text"){_.value+=C.value,_.output=(_.output||"")+C.value;return}C.prev=_,i.push(C),_=C},bn=(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 P=(n.capture?"(":"")+R.open;kn("parens"),N({type:C,value:Y,output:m.output?"":g}),N({type:"paren",extglob:!0,value:xe(),output:P}),k.push(R)},Op=C=>{let Y=e.slice(C.startIndex,m.index+1),R=e.slice(C.startIndex+2,m.index),P=DR(R,n);if((C.type==="plus"||C.type==="star")&&P.risky){let G=P.safeOutput?(C.output?"":g)+(n.capture?`(${P.safeOutput})`:P.safeOutput):void 0,be=i[C.tokensIndex];be.type="text",be.value=Y,be.output=G||se.escapeRegex(Y);for(let Oe=C.tokensIndex+1;Oe<i.length;Oe++)i[Oe].value="",i[Oe].output="",delete i[Oe].suffix;m.output=C.output+be.output,m.backtrack=!0,N({type:"paren",extglob:!0,value:h,output:""}),We("parens");return}let z=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(ke()))&&(z=C.close=`)$))${G}`),C.inner.includes("*")&&(oe=ke())&&/^\.[^\\/.]+$/.test(oe)){let be=ws(oe,{...t,fastpaths:!1}).output;z=C.close=`)${be})${G})`}C.prev.type==="bos"&&(m.negatedExtglob=!0)}N({type:"paren",extglob:!0,value:h,output:z}),We("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let C=!1,Y=e.replace(NR,(R,P,z,oe,G,be)=>oe==="\\"?(C=!0,R):oe==="?"?P?P+oe+(G?O.repeat(G.length):""):be===0?w+(G?O.repeat(G.length):""):O.repeat(z.length):oe==="."?d.repeat(z.length):oe==="*"?P?P+oe+(G?H:""):H:P?R:`\\${R}`);return C===!0&&(n.unescape===!0?Y=Y.replace(/\\/g,""):Y=Y.replace(/\\+/g,R=>R.length%2===0?"\\\\":R?"\\":"")),Y===e&&n.contains===!0?(m.output=e,m):(m.output=se.wrapOutput(Y,m,t),m)}for(;!ie();){if(h=xe(),h==="\0")continue;if(h==="\\"){let R=F();if(R==="/"&&n.bash!==!0||R==="."||R===";")continue;if(!R){h+="\\",N({type:"text",value:h});continue}let P=/^\\+/.exec(ke()),z=0;if(P&&P[0].length>2&&(z=P[0].length,m.index+=z,z%2!==0&&(h+="\\")),n.unescape===!0?h=xe():h+=xe(),m.brackets===0){N({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 P=_.value.lastIndexOf("["),z=_.value.slice(0,P),oe=_.value.slice(P+2),G=PR[oe];if(G){_.value=z+G,m.backtrack=!0,xe(),!s.output&&i.indexOf(_)===1&&(s.output=g);continue}}}(h==="["&&F()!==":"||h==="-"&&F()==="]")&&(h=`\\${h}`),h==="]"&&(_.value==="["||_.value==="[^")&&(h=`\\${h}`),n.posix===!0&&h==="!"&&_.value==="["&&(h="^"),_.value+=h,xn({value:h});continue}if(m.quotes===1&&h!=='"'){h=se.escapeRegex(h),_.value+=h,xn({value:h});continue}if(h==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===!0&&N({type:"text",value:h});continue}if(h==="("){kn("parens"),N({type:"paren",value:h});continue}if(h===")"){if(m.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Nt("opening","("));let R=k[k.length-1];if(R&&m.parens===R.parens+1){Op(k.pop());continue}N({type:"paren",value:h,output:m.parens?")":"\\)"}),We("parens");continue}if(h==="["){if(n.nobracket===!0||!ke().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Nt("closing","]"));h=`\\${h}`}else kn("brackets");N({type:"bracket",value:h});continue}if(h==="]"){if(n.nobracket===!0||_&&_.type==="bracket"&&_.value.length===1){N({type:"text",value:h,output:`\\${h}`});continue}if(m.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Nt("opening","["));N({type:"text",value:h,output:`\\${h}`});continue}We("brackets");let R=_.value.slice(1);if(_.posix!==!0&&R[0]==="^"&&!R.includes("/")&&(h=`/${h}`),_.value+=h,xn({value:h}),n.literalBrackets===!1||se.hasRegexChars(R))continue;let P=se.escapeRegex(_.value);if(m.output=m.output.slice(0,-_.value.length),n.literalBrackets===!0){m.output+=P,_.value=P;continue}_.value=`(${a}${P}|${_.value})`,m.output+=_.value;continue}if(h==="{"&&n.nobrace!==!0){kn("braces");let R={type:"brace",value:h,output:"(",outputIndex:m.output.length,tokensIndex:m.tokens.length};U.push(R),N(R);continue}if(h==="}"){let R=U[U.length-1];if(n.nobrace===!0||!R){N({type:"text",value:h,output:h});continue}let P=")";if(R.dots===!0){let z=i.slice(),oe=[];for(let G=z.length-1;G>=0&&(i.pop(),z[G].type!=="brace");G--)z[G].type!=="dots"&&oe.unshift(z[G].value);P=vR(oe,n),m.backtrack=!0}if(R.comma!==!0&&R.dots!==!0){let z=m.output.slice(0,R.outputIndex),oe=m.tokens.slice(R.tokensIndex);R.value=R.output="\\{",h=P="\\}",m.output=z;for(let G of oe)m.output+=G.output||G.value}N({type:"brace",value:h,output:P}),We("braces"),U.pop();continue}if(h==="|"){k.length>0&&k[k.length-1].conditions++,N({type:"text",value:h});continue}if(h===","){let R=h,P=U[U.length-1];P&&le[le.length-1]==="braces"&&(P.comma=!0,R="|"),N({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}N({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"){N({type:"text",value:h,output:d});continue}N({type:"dot",value:h,output:d});continue}if(h==="?"){if(!(_&&_.value==="(")&&n.noextglob!==!0&&F()==="("&&F(2)!=="?"){bn("qmark",h);continue}if(_&&_.type==="paren"){let P=F(),z=h;if(P==="<"&&!se.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(_.value==="("&&!/[!=<:]/.test(P)||P==="<"&&!/<([!=]|\w+>)/.test(ke()))&&(z=`\\${h}`),N({type:"text",value:h,output:z});continue}if(n.dot!==!0&&(_.type==="slash"||_.type==="bos")){N({type:"qmark",value:h,output:v});continue}N({type:"qmark",value:h,output:O});continue}if(h==="!"){if(n.noextglob!==!0&&F()==="("&&(F(2)!=="?"||!/[!=<:]/.test(F(3)))){bn("negate",h);continue}if(n.nonegate!==!0&&m.index===0){bp();continue}}if(h==="+"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){bn("plus",h);continue}if(_&&_.value==="("||n.regex===!1){N({type:"plus",value:h,output:f});continue}if(_&&(_.type==="bracket"||_.type==="paren"||_.type==="brace")||m.parens>0){N({type:"plus",value:h});continue}N({type:"plus",value:f});continue}if(h==="@"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){N({type:"at",extglob:!0,value:h,output:""});continue}N({type:"text",value:h});continue}if(h!=="*"){(h==="$"||h==="^")&&(h=`\\${h}`);let R=wR.exec(ke());R&&(h+=R[0],m.index+=R[0].length),N({type:"text",value:h});continue}if(_&&(_.type==="globstar"||_.star===!0)){_.type="star",_.star=!0,_.value+=h,_.output=H,m.backtrack=!0,m.globstar=!0,fe(h);continue}let C=ke();if(n.noextglob!==!0&&/^\([^?]/.test(C)){bn("star",h);continue}if(_.type==="star"){if(n.noglobstar===!0){fe(h);continue}let R=_.prev,P=R.prev,z=R.type==="slash"||R.type==="bos",oe=P&&(P.type==="star"||P.type==="globstar");if(n.bash===!0&&(!z||C[0]&&C[0]!=="/")){N({type:"star",value:h,output:""});continue}let G=m.braces>0&&(R.type==="comma"||R.type==="brace"),be=k.length&&(R.type==="pipe"||R.type==="paren");if(!z&&R.type!=="paren"&&!G&&!be){N({type:"star",value:h,output:""});continue}for(;C.slice(0,3)==="/**";){let Oe=e[m.index+4];if(Oe&&Oe!=="/")break;C=C.slice(3),fe("/**",3)}if(R.type==="bos"&&ie()){_.type="globstar",_.value+=h,_.output=D(n),m.output=_.output,m.globstar=!0,fe(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,fe(h);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&C[0]==="/"){let Oe=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}${Oe})`,_.value+=h,m.output+=R.output+_.output,m.globstar=!0,fe(h+xe()),N({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,fe(h+xe()),N({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,fe(h);continue}let Y={type:"star",value:h,output:H};if(n.bash===!0){Y.output=".*?",(_.type==="bos"||_.type==="slash")&&(Y.output=b+Y.output),N(Y);continue}if(_&&(_.type==="bracket"||_.type==="paren")&&n.regex===!0){Y.output=h,N(Y);continue}(m.index===m.start||_.type==="slash"||_.type==="dot")&&(_.type==="dot"?(m.output+=x,_.output+=x):n.dot===!0?(m.output+=I,_.output+=I):(m.output+=b,_.output+=b),F()!=="*"&&(m.output+=g,_.output+=g)),N(Y)}for(;m.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Nt("closing","]"));m.output=se.escapeLast(m.output,"["),We("brackets")}for(;m.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Nt("closing",")"));m.output=se.escapeLast(m.output,"("),We("parens")}for(;m.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Nt("closing","}"));m.output=se.escapeLast(m.output,"{"),We("braces")}if(n.strictSlashes!==!0&&(_.type==="star"||_.type==="bracket")&&N({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};ws.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=yf[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}=dn.globChars(s),S=n.dot?d:u,A=n.dot?f:u,x=n.capture?"":"?:",I={negated:!1,prefix:""},O=n.bash===!0?".*?":p;n.capture&&(O=`(${O})`);let v=b=>b.noglobstar===!0?O:`(${x}(?:(?!${g}${b.dot?l:i}).)*?)`,T=b=>{switch(b){case"*":return`${S}${c}${O}`;case".*":return`${i}${c}${O}`;case"*.*":return`${S}${O}${i}${c}${O}`;case"*/*":return`${S}${O}${a}${c}${A}${O}`;case"**":return S+v(n);case"**/*":return`(?:${S}${v(n)}${a})?${A}${c}${O}`;case"**/*.*":return`(?:${S}${v(n)}${a})?${A}${O}${i}${c}${O}`;case"**/.*":return`(?:${S}${v(n)}${a})?${i}${c}${O}`;default:{let w=/^(.*?)\.(\w+)$/.exec(b);if(!w)return;let H=T(w[1]);return H?H+i+w[2]:void 0}}},K=se.removePrefix(e,I),D=T(K);return D&&n.strictSlashes!==!0&&(D+=`${a}?`),D};Af.exports=ws});var bf=V((cT,kf)=>{"use strict";var FR=ze("path"),$R=Ef(),Ns=xf(),vs=ln(),jR=un(),BR=e=>e&&typeof e=="object"&&!Array.isArray(e),ee=(e,t,n=!1)=>{if(Array.isArray(e)){let u=e.map(f=>ee(f,t,n));return f=>{for(let p of u){let g=p(f);if(g)return g}return!1}}let r=BR(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=t||{},s=vs.isWindows(t),i=r?ee.compileRe(e,t):ee.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=ee(o.ignore,u,n)}let l=(u,d=!1)=>{let{isMatch:f,match:p,output:g}=ee.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};ee.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?vs.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=ee.matchBase(e,t,n,o):a=t.exec(c)),{isMatch:!!a,match:a,output:c}};ee.matchBase=(e,t,n,r=vs.isWindows(n))=>(t instanceof RegExp?t:ee.makeRe(t,n)).test(FR.basename(e));ee.isMatch=(e,t,n)=>ee(t,n)(e);ee.parse=(e,t)=>Array.isArray(e)?e.map(n=>ee.parse(n,t)):Ns(e,{...t,fastpaths:!1});ee.scan=(e,t)=>$R(e,t);ee.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=ee.toRegex(a,t);return r===!0&&(c.state=e),c};ee.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=Ns.fastpaths(e,t)),o.output||(o=Ns(e,t)),ee.compileRe(o,t,n,r)};ee.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/$^/}};ee.constants=jR;kf.exports=ee});var If=V((uT,Of)=>{"use strict";Of.exports=bf()});var Mf=V((lT,vf)=>{"use strict";var Pf=ze("util"),wf=sf(),Ne=If(),Ms=ln(),Tf=e=>e===""||e==="./",Nf=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=Ne(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)=>Ne(e,t);J.isMatch=(e,t,n)=>Ne(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: "${Pf.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>J.contains(e,r,n));if(typeof t=="string"){if(Tf(e)||Tf(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(!Ms.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=Ne(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=Ne(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: "${Pf.inspect(e)}"`);return[].concat(t).every(r=>Ne(r,n)(e))};J.capture=(e,t,n)=>{let r=Ms.isWindows(n),s=Ne.makeRe(String(e),{...n,capture:!0}).exec(r?Ms.toPosixSlashes(t):t);if(s)return s.slice(1).map(i=>i===void 0?"":i)};J.makeRe=(...e)=>Ne.makeRe(...e);J.scan=(...e)=>Ne.scan(...e);J.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of wf(String(r),t))n.push(Ne.parse(o,t));return n};J.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!Nf(e)?[e]:wf(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=Nf;vf.exports=J});import{realpathSync as Gx}from"node:fs";import{resolve as Wx}from"node:path";import{fileURLToPath as zx,pathToFileURL as Vx}from"node:url";import{createHash as Qp}from"node:crypto";import{homedir as em}from"node:os";import{dirname as yk,join as tm,parse as Rk,resolve as Ck}from"node:path";var Ei="EV_AI_LAUNCHER_VERSION";var yi="EV_AI_HOOK_SOURCE",Ri="EV_AI_HOOK_FALLBACK_REASON",Ci="EV_AI_LAUNCHER_SCOPE",Xr="EV_AI_LAUNCHER_READY_FD";var Ai="--defer-user-spec",On="--cap",$t="--slot";var xi=Buffer.from([1]);var qx=1024*1024,Zx=4*1024*1024,Qx=64*1024,ek=64*1024,tk=64*1024;var qr=4096,nk=4*1024*1024;import{join as Pi}from"node:path";import{open as ki,mkdir as Mp,readFile as Lp,readdir as Hp,rename as Up,stat as Dp,rmdir as Fp,unlink as $p,utimes as jp}from"node:fs/promises";var In=new WeakMap;function Oi(e){if(e&&typeof e=="object"&&"code"in e)return e}function yt(e){return Oi(e)?.code==="ENOENT"}function jt(e){return Oi(e)?.code==="EEXIST"}async function Ii(e,t){try{return await e.readdir(t)}catch(n){if(yt(n))return[];throw n}}function Ti(){return{async open(e,t){let n=await ki(e,t),r={path:e};return In.set(r,n),r},async write(e,t){let n=bi(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await bi(e).sync()},async close(e){let t=In.get(e);In.delete(e),t&&await t.close()},rename:Up,async readdir(e){return Hp(e)},readFile:Lp,async stat(e){let t=await Dp(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await Mp(e,t)},unlink:$p,rmdir:Fp,utimes:jp,async fsyncDir(e){if(process.platform==="win32")return;let t=await ki(e,"r");try{await t.sync()}finally{await t.close()}}}}function bi(e){let t=In.get(e);if(!t)throw new Error("closed");return t}var wi=4,Ni=10;function Tn(e=process.platform){return e==="win32"?wi:Ni}var Pn=6e4,Bt=2e3,vi="slots",Zr=64;function Mi(e){return Pi(e,".ev-ai","agent-hook",vi)}function wn(e,t){return Pi(e,`slot-${t}`)}function Nn(e,t){return`${e}
11
+ `).trimEnd();return(0,be.usableCatalogText)(f)}});var Ou=z(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=ee.COMPONENT_INSPECTION_TEXT_MAX_BYTES=ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;ee.fitSnapshotInspectionTextBudget=zS;ee.capComponentTextBytes=xu;ee.prepareComponentInspectionText=JS;ee.redactComponentSource=es;ee.componentSourceContainsRedactableSecret=tE;ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";ee.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;ee.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function zS(e){let t=0;return e.map(n=>{let r=n,o=r.skill?.inspectionText;if(o===void 0)return n;let s=Buffer.byteLength(o,"utf8");return t+s<=ee.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=s,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}function xu(e,t){if(e==null||e.length===0)return;let n=Buffer.from(e,"utf8");if(n.byteLength<=t)return e;let r=new TextDecoder("utf-8",{fatal:!0});for(let o=t;o>0;o-=1)try{return r.decode(n.subarray(0,o))}catch{}}function JS(e){if(!(e==null||e.length===0))return xu(es(e),ee.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}var YS=[/\bsk-(?:proj-)?[A-Za-z0-9_-]{16,}/g,/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g,/\bgithub_pat_[A-Za-z0-9_]{20,}/g,/\bxox[baprs]-[A-Za-z0-9-]{10,}/g,/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,/\bAIza[0-9A-Za-z_-]{35}\b/g,/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g],XS=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,qS=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,ZS=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,QS=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,ku=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function eE(e){let t=e.replace(qS,(n,r)=>`${r}${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(ZS,(n,r)=>`${r}${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(XS,(n,r)=>`${r}${ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of YS)t=t.replace(n,ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}function es(e){if(e.length===0)return e;let t=e.split(`
12
+ `),n=!1;return t.map(o=>n?ku.test(o)?(n=!1,o):o.trim().length===0?o:ee.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:QS.test(o)&&!ku.test(o)?(n=!0,o):eE(o)).join(`
13
+ `)}function tE(e){return es(e)!==e}});var lt=z(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.redactComponentSource=y.prepareComponentInspectionText=y.fitSnapshotInspectionTextBudget=y.componentSourceContainsRedactableSecret=y.capComponentTextBytes=y.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=y.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=y.COMPONENT_INSPECTION_TEXT_MAX_BYTES=y.usableCatalogText=y.parseFrontmatterField=y.parseFrontmatterDescription=y.mcpServerToolSegmentForms=y.mcpServerNameMatchesToolSegment=y.isNpmRegistryPublisher=y.EMPTY_NPM_PUBLISHER=y.displayPublisherName=y.classifyMcpProvenance=y.resolveMcpPackageIdentity=y.McpPackageEcosystem=y.pinnedPackageVersionFromSpec=y.pinnedPackageVersionFromNpx=y.packageNameFromSpec=y.npxPackageSpecs=y.npxExecBin=y.PACKAGE_FIELD_MAX=y.serializeMcpLaunchIdentity=y.projectMcpMissingLaunchIdentity=y.projectMcpLaunchIdentity=y.normalizeMcpToolNames=y.MCP_MISSING_LAUNCH_SERIALIZED=y.MCP_LAUNCH_IDENTITY_ALGORITHM=y.maskMcpLaunchForDisplay=y.launchContainsCredentials=y.hashMcpLaunchIdentity=y.foldMcpName=y.buildMcpFamilyCanonicalKey=y.ComponentKind=void 0;y.userConfigRootFromPath=fE;y.installationRootExternalKey=dE;y.normalizeRepositoryRelativePath=Iu;y.nativeKeyForSkillPath=pE;y.nativeKeyForRulePath=mE;y.nativeKeyForCommandPath=gE;y.serializeComponentIdentity=Pu;y.buildComponentReference=hE;y.validateComponentReference=SE;var nE=Ze("node:crypto"),rE=Ze("node:path"),oE="cmp1_",sE=/^cmp1_[A-Za-z0-9_-]{43}$/,iE=["/skills/","/skills-cursor/"],aE=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,cE=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,uE=[".cursor",".claude",".codex"],lE={".claude.json":".claude",".agents":".codex"};y.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function fE(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>uE.includes(o));return n||(t.map(o=>lE[o]).find(o=>o!==void 0)??"unknown")}function dE(e,t){return`runtime-install:${e}/${t}`}function Cr(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function Iu(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=rE.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Cr(n,"sourcePath")}function pE(e){let t=e.replaceAll("\\","/");for(let n of iE){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function Tu(e,t,n){let r=e.replaceAll("\\","/"),s=t.exec(r)?.[1];if(!s||s.split("/").includes(".."))return null;let i=s.replace(n,"");return i.length>0?i:null}function mE(e){return Tu(e,aE,/\.(mdc|md|rules)$/i)}function gE(e){return Tu(e,cE,/\.(md|mdc|toml)$/i)}function _E(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Pu(e){let t=[Cr(e.installationRootExternalKey,"installationRootExternalKey"),Cr(e.installableKind,"installableKind"),Iu(e.sourcePath),Cr(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(_E).join("|")}`,"utf8")}function hE(e){let t=(0,nE.createHash)("sha256").update(Pu(e)).digest("base64url");return`${oE}${t}`}function SE(e){return sE.test(e)}var ke=Sr();Object.defineProperty(y,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:function(){return ke.buildMcpFamilyCanonicalKey}});Object.defineProperty(y,"foldMcpName",{enumerable:!0,get:function(){return ke.foldMcpName}});Object.defineProperty(y,"hashMcpLaunchIdentity",{enumerable:!0,get:function(){return ke.hashMcpLaunchIdentity}});Object.defineProperty(y,"launchContainsCredentials",{enumerable:!0,get:function(){return ke.launchContainsCredentials}});Object.defineProperty(y,"maskMcpLaunchForDisplay",{enumerable:!0,get:function(){return ke.maskMcpLaunchForDisplay}});Object.defineProperty(y,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:function(){return ke.MCP_LAUNCH_IDENTITY_ALGORITHM}});Object.defineProperty(y,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:function(){return ke.MCP_MISSING_LAUNCH_SERIALIZED}});Object.defineProperty(y,"normalizeMcpToolNames",{enumerable:!0,get:function(){return ke.normalizeMcpToolNames}});Object.defineProperty(y,"projectMcpLaunchIdentity",{enumerable:!0,get:function(){return ke.projectMcpLaunchIdentity}});Object.defineProperty(y,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:function(){return ke.projectMcpMissingLaunchIdentity}});Object.defineProperty(y,"serializeMcpLaunchIdentity",{enumerable:!0,get:function(){return ke.serializeMcpLaunchIdentity}});var Ht=yr();Object.defineProperty(y,"PACKAGE_FIELD_MAX",{enumerable:!0,get:function(){return Ht.PACKAGE_FIELD_MAX}});Object.defineProperty(y,"npxExecBin",{enumerable:!0,get:function(){return Ht.npxExecBin}});Object.defineProperty(y,"npxPackageSpecs",{enumerable:!0,get:function(){return Ht.npxPackageSpecs}});Object.defineProperty(y,"packageNameFromSpec",{enumerable:!0,get:function(){return Ht.packageNameFromSpec}});Object.defineProperty(y,"pinnedPackageVersionFromNpx",{enumerable:!0,get:function(){return Ht.pinnedPackageVersionFromNpx}});Object.defineProperty(y,"pinnedPackageVersionFromSpec",{enumerable:!0,get:function(){return Ht.pinnedPackageVersionFromSpec}});var wu=gu();Object.defineProperty(y,"McpPackageEcosystem",{enumerable:!0,get:function(){return wu.McpPackageEcosystem}});Object.defineProperty(y,"resolveMcpPackageIdentity",{enumerable:!0,get:function(){return wu.resolveMcpPackageIdentity}});var Ar=Ru();Object.defineProperty(y,"classifyMcpProvenance",{enumerable:!0,get:function(){return Ar.classifyMcpProvenance}});Object.defineProperty(y,"displayPublisherName",{enumerable:!0,get:function(){return Ar.displayPublisherName}});Object.defineProperty(y,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:function(){return Ar.EMPTY_NPM_PUBLISHER}});Object.defineProperty(y,"isNpmRegistryPublisher",{enumerable:!0,get:function(){return Ar.isNpmRegistryPublisher}});var Nu=Au();Object.defineProperty(y,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:function(){return Nu.mcpServerNameMatchesToolSegment}});Object.defineProperty(y,"mcpServerToolSegmentForms",{enumerable:!0,get:function(){return Nu.mcpServerToolSegmentForms}});var ts=bu();Object.defineProperty(y,"parseFrontmatterDescription",{enumerable:!0,get:function(){return ts.parseFrontmatterDescription}});Object.defineProperty(y,"parseFrontmatterField",{enumerable:!0,get:function(){return ts.parseFrontmatterField}});Object.defineProperty(y,"usableCatalogText",{enumerable:!0,get:function(){return ts.usableCatalogText}});var ut=Ou();Object.defineProperty(y,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return ut.COMPONENT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:function(){return ut.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}});Object.defineProperty(y,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return ut.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"capComponentTextBytes",{enumerable:!0,get:function(){return ut.capComponentTextBytes}});Object.defineProperty(y,"componentSourceContainsRedactableSecret",{enumerable:!0,get:function(){return ut.componentSourceContainsRedactableSecret}});Object.defineProperty(y,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:function(){return ut.fitSnapshotInspectionTextBudget}});Object.defineProperty(y,"prepareComponentInspectionText",{enumerable:!0,get:function(){return ut.prepareComponentInspectionText}});Object.defineProperty(y,"redactComponentSource",{enumerable:!0,get:function(){return ut.redactComponentSource}})});var Gr=z(Ce=>{"use strict";Ce.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Ce.find=(e,t)=>e.nodes.find(n=>n.type===t);Ce.exceedsLimit=(e,t,n=1,r)=>r===!1||!Ce.isInteger(e)||!Ce.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Ce.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||r.type==="open"||r.type==="close")&&r.escaped!==!0&&(r.value="\\"+r.value,r.escaped=!0)};Ce.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Ce.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;Ce.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Ce.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Ce.flatten=(...e)=>{let t=[],n=r=>{for(let o=0;o<r.length;o++){let s=r[o];if(Array.isArray(s)){n(s);continue}s!==void 0&&t.push(s)}return t};return n(e),t}});var Vr=z((ZP,Ef)=>{"use strict";var Sf=Gr();Ef.exports=(e,t={})=>{let n=(r,o={})=>{let s=t.escapeInvalid&&Sf.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a="";if(r.value)return(s||i)&&Sf.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let c of r.nodes)a+=n(c);return a};return n(e)}});var Rf=z((QP,yf)=>{"use strict";yf.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var Pf=z((ew,Tf)=>{"use strict";var Cf=Rf(),Et=(e,t,n)=>{if(Cf(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(Cf(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let o=String(r.relaxZeros),s=String(r.shorthand),i=String(r.capture),a=String(r.wrap),c=e+":"+t+"="+o+s+i+a;if(Et.cache.hasOwnProperty(c))return Et.cache[c].result;let l=Math.min(e,t),u=Math.max(e,t);if(Math.abs(l-u)===1){let S=e+"|"+t;return r.capture?`(${S})`:r.wrap===!1?S:`(?:${S})`}let d=If(e)||If(t),f={min:e,max:t,a:l,b:u},p=[],g=[];if(d&&(f.isPadded=d,f.maxLen=String(f.max).length),l<0){let S=u<0?Math.abs(u):1;g=Af(S,Math.abs(l),f,r),l=f.a=0}return u>=0&&(p=Af(l,u,f,r)),f.negatives=g,f.positives=p,f.result=nC(g,p,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&p.length+g.length>1&&(f.result=`(?:${f.result})`),Et.cache[c]=f,f.result};function nC(e,t,n){let r=Ds(e,t,"-",!1,n)||[],o=Ds(t,e,"",!1,n)||[],s=Ds(e,t,"-?",!0,n)||[];return r.concat(s).concat(o).join("|")}function rC(e,t){let n=1,r=1,o=kf(e,n),s=new Set([t]);for(;e<=o&&o<=t;)s.add(o),n+=1,o=kf(e,n);for(o=xf(t+1,r)-1;e<o&&o<=t;)s.add(o),r+=1,o=xf(t+1,r)-1;return s=[...s],s.sort(iC),s}function oC(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=sC(e,t),o=r.length,s="",i=0;for(let a=0;a<o;a++){let[c,l]=r[a];c===l?s+=c:c!=="0"||l!=="9"?s+=aC(c,l,n):i++}return i&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[i],digits:o}}function Af(e,t,n,r){let o=rC(e,t),s=[],i=e,a;for(let c=0;c<o.length;c++){let l=o[c],u=oC(String(i),String(l),r),d="";if(!n.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+Of(a.count),i=l+1;continue}n.isPadded&&(d=cC(l,n,r)),u.string=d+u.pattern+Of(u.count),s.push(u),i=l+1,a=u}return s}function Ds(e,t,n,r,o){let s=[];for(let i of e){let{string:a}=i;!r&&!bf(t,"string",a)&&s.push(n+a),r&&bf(t,"string",a)&&s.push(n+a)}return s}function sC(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}function iC(e,t){return e>t?1:t>e?-1:0}function bf(e,t,n){return e.some(r=>r[t]===n)}function kf(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}function xf(e,t){return e-e%Math.pow(10,t)}function Of(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}function aC(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}function If(e){return/^-?(0+)\d/.test(e)}function cC(e,t,n){if(!t.isPadded)return e;let r=Math.abs(t.maxLen-String(e).length),o=n.relaxZeros!==!1;switch(r){case 0:return"";case 1:return o?"0?":"0";case 2:return o?"0{0,2}":"00";default:return o?`0{0,${r}}`:`0{${r}}`}}Et.cache={};Et.clearCache=()=>Et.cache={};Tf.exports=Et});var js=z((tw,Uf)=>{"use strict";var uC=Ze("util"),Nf=Pf(),wf=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),lC=e=>t=>e===!0?Number(t):String(t),Fs=e=>typeof e=="number"||typeof e=="string"&&e!=="",En=e=>Number.isInteger(+e),$s=e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},fC=(e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,dC=(e,t,n)=>{if(t>0){let r=e[0]==="-"?"-":"";r&&(e=e.slice(1)),e=r+e.padStart(r?t-1:t,"0")}return n===!1?String(e):e},zr=(e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},pC=(e,t,n)=>{e.negatives.sort((a,c)=>a<c?-1:a>c?1:0),e.positives.sort((a,c)=>a<c?-1:a>c?1:0);let r=t.capture?"":"?:",o="",s="",i;return e.positives.length&&(o=e.positives.map(a=>zr(String(a),n)).join("|")),e.negatives.length&&(s=`-(${r}${e.negatives.map(a=>zr(String(a),n)).join("|")})`),o&&s?i=`${o}|${s}`:i=o||s,t.wrap?`(${r}${i})`:i},vf=(e,t,n,r)=>{if(n)return Nf(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let s=String.fromCharCode(t);return`[${o}-${s}]`},Mf=(e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return Nf(e,t,n)},Lf=(...e)=>new RangeError("Invalid range arguments: "+uC.inspect(...e)),Hf=(e,t,n)=>{if(n.strictRanges===!0)throw Lf([e,t]);return[]},mC=(e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},gC=(e,t,n=1,r={})=>{let o=Number(e),s=Number(t);if(!Number.isInteger(o)||!Number.isInteger(s)){if(r.strictRanges===!0)throw Lf([e,t]);return[]}o===0&&(o=0),s===0&&(s=0);let i=o>s,a=String(e),c=String(t),l=String(n);n=Math.max(Math.abs(n),1);let u=$s(a)||$s(c)||$s(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&fC(e,t,r)===!1,p=r.transform||lC(f);if(r.toRegex&&n===1)return vf(zr(e,d),zr(t,d),!0,r);let g={negatives:[],positives:[]},S=I=>g[I<0?"negatives":"positives"].push(Math.abs(I)),A=[],b=0;for(;i?o>=s:o<=s;)r.toRegex===!0&&n>1?S(o):A.push(dC(p(o,b),d,f)),o=i?o-n:o+n,b++;return r.toRegex===!0?n>1?pC(g,r,d):Mf(A,null,{wrap:!1,...r}):A},_C=(e,t,n=1,r={})=>{if(!En(e)&&e.length>1||!En(t)&&t.length>1)return Hf(e,t,r);let o=r.transform||(f=>String.fromCharCode(f)),s=`${e}`.charCodeAt(0),i=`${t}`.charCodeAt(0),a=s>i,c=Math.min(s,i),l=Math.max(s,i);if(r.toRegex&&n===1)return vf(c,l,!1,r);let u=[],d=0;for(;a?s>=i:s<=i;)u.push(o(s,d)),s=a?s-n:s+n,d++;return r.toRegex===!0?Mf(u,null,{wrap:!1,options:r}):u},Wr=(e,t,n,r={})=>{if(t==null&&Fs(e))return[e];if(!Fs(e)||!Fs(t))return Hf(e,t,r);if(typeof n=="function")return Wr(e,t,1,{transform:n});if(wf(n))return Wr(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,En(n)?En(e)&&En(t)?gC(e,t,n,o):_C(e,t,Math.max(Math.abs(n),1),o):n!=null&&!wf(n)?mC(n,o):Wr(e,t,1,n)};Uf.exports=Wr});var $f=z((nw,Ff)=>{"use strict";var hC=js(),Df=Gr(),SC=(e,t={})=>{let n=(r,o={})=>{let s=Df.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a=s===!0||i===!0,c=t.escapeInvalid===!0?"\\":"",l="";if(r.isOpen===!0)return c+r.value;if(r.isClose===!0)return console.log("node.isClose",c,r.value),c+r.value;if(r.type==="open")return a?c+r.value:"(";if(r.type==="close")return a?c+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":a?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let u=Df.reduce(r.nodes),d=hC(...u,{...t,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(r.nodes)for(let u of r.nodes)l+=n(u,r);return l};return n(e)};Ff.exports=SC});var Kf=z((rw,Bf)=>{"use strict";var EC=js(),jf=Vr(),Dt=Gr(),yt=(e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?Dt.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let s of o)r.push(yt(s,t,n));else for(let s of t)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?yt(o,s,n):o+s);return Dt.flatten(r)},yC=(e,t={})=>{let n=t.rangeLimit===void 0?1e3:t.rangeLimit,r=(o,s={})=>{o.queue=[];let i=s,a=s.queue;for(;i.type!=="brace"&&i.type!=="root"&&i.parent;)i=i.parent,a=i.queue;if(o.invalid||o.dollar){a.push(yt(a.pop(),jf(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){a.push(yt(a.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let d=Dt.reduce(o.nodes);if(Dt.exceedsLimit(...d,t.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=EC(...d,t);f.length===0&&(f=jf(o,t)),a.push(yt(a.pop(),f)),o.nodes=[];return}let c=Dt.encloseBrace(o),l=o.queue,u=o;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let d=0;d<o.nodes.length;d++){let f=o.nodes[d];if(f.type==="comma"&&o.type==="brace"){d===1&&l.push(""),l.push("");continue}if(f.type==="close"){a.push(yt(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(yt(l.pop(),f.value));continue}f.nodes&&r(f,o)}return l};return Dt.flatten(r(e))};Bf.exports=yC});var Vf=z((ow,Gf)=>{"use strict";Gf.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
14
+ `,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Xf=z((sw,Yf)=>{"use strict";var RC=Vr(),{MAX_LENGTH:Wf,CHAR_BACKSLASH:Bs,CHAR_BACKTICK:CC,CHAR_COMMA:AC,CHAR_DOT:bC,CHAR_LEFT_PARENTHESES:kC,CHAR_RIGHT_PARENTHESES:xC,CHAR_LEFT_CURLY_BRACE:OC,CHAR_RIGHT_CURLY_BRACE:IC,CHAR_LEFT_SQUARE_BRACKET:zf,CHAR_RIGHT_SQUARE_BRACKET:Jf,CHAR_DOUBLE_QUOTE:TC,CHAR_SINGLE_QUOTE:PC,CHAR_NO_BREAK_SPACE:wC,CHAR_ZERO_WIDTH_NOBREAK_SPACE:NC}=Vf(),vC=(e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Wf,n.maxLength):Wf;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},s=[o],i=o,a=o,c=0,l=e.length,u=0,d=0,f,p=()=>e[u++],g=S=>{if(S.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&S.type==="text"){a.value+=S.value;return}return i.nodes.push(S),S.parent=i,S.prev=a,a=S,S};for(g({type:"bos"});u<l;)if(i=s[s.length-1],f=p(),!(f===NC||f===wC)){if(f===Bs){g({type:"text",value:(t.keepEscaping?f:"")+p()});continue}if(f===Jf){g({type:"text",value:"\\"+f});continue}if(f===zf){c++;let S;for(;u<l&&(S=p());){if(f+=S,S===zf){c++;continue}if(S===Bs){f+=p();continue}if(S===Jf&&(c--,c===0))break}g({type:"text",value:f});continue}if(f===kC){i=g({type:"paren",nodes:[]}),s.push(i),g({type:"text",value:f});continue}if(f===xC){if(i.type!=="paren"){g({type:"text",value:f});continue}i=s.pop(),g({type:"text",value:f}),i=s[s.length-1];continue}if(f===TC||f===PC||f===CC){let S=f,A;for(t.keepQuotes!==!0&&(f="");u<l&&(A=p());){if(A===Bs){f+=A+p();continue}if(A===S){t.keepQuotes===!0&&(f+=A);break}f+=A}g({type:"text",value:f});continue}if(f===OC){d++;let A={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||i.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};i=g(A),s.push(i),g({type:"open",value:f});continue}if(f===IC){if(i.type!=="brace"){g({type:"text",value:f});continue}let S="close";i=s.pop(),i.close=!0,g({type:S,value:f}),d--,i=s[s.length-1];continue}if(f===AC&&d>0){if(i.ranges>0){i.ranges=0;let S=i.nodes.shift();i.nodes=[S,{type:"text",value:RC(i)}]}g({type:"comma",value:f}),i.commas++;continue}if(f===bC&&d>0&&i.commas===0){let S=i.nodes;if(d===0||S.length===0){g({type:"text",value:f});continue}if(a.type==="dot"){if(i.range=[],a.value+=f,a.type="range",i.nodes.length!==3&&i.nodes.length!==5){i.invalid=!0,i.ranges=0,a.type="text";continue}i.ranges++,i.args=[];continue}if(a.type==="range"){S.pop();let A=S[S.length-1];A.value+=a.value+f,a=A,i.ranges--;continue}g({type:"dot",value:f});continue}g({type:"text",value:f})}do if(i=s.pop(),i.type!=="root"){i.nodes.forEach(b=>{b.nodes||(b.type==="open"&&(b.isOpen=!0),b.type==="close"&&(b.isClose=!0),b.nodes||(b.type="text"),b.invalid=!0)});let S=s[s.length-1],A=S.nodes.indexOf(i);S.nodes.splice(A,1,...i.nodes)}while(s.length>0);return g({type:"eos"}),o};Yf.exports=vC});var Qf=z((iw,Zf)=>{"use strict";var qf=Vr(),MC=$f(),LC=Kf(),HC=Xf(),he=(e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=he.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(he.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n};he.parse=(e,t={})=>HC(e,t);he.stringify=(e,t={})=>qf(typeof e=="string"?he.parse(e,t):e,t);he.compile=(e,t={})=>(typeof e=="string"&&(e=he.parse(e,t)),MC(e,t));he.expand=(e,t={})=>{typeof e=="string"&&(e=he.parse(e,t));let n=LC(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};he.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?he.compile(e,t):he.expand(e,t);Zf.exports=he});var yn=z((aw,od)=>{"use strict";var UC=Ze("path"),Me="\\\\/",ed=`[^${Me}]`,DC=0,Xe="\\.",FC="\\+",$C="\\?",Jr="\\/",jC="(?=.)",td="[^/]",Ks=`(?:${Jr}|$)`,nd=`(?:^|${Jr})`,Gs=`${Xe}{1,2}${Ks}`,BC=`(?!${Xe})`,KC=`(?!${nd}${Gs})`,GC=`(?!${Xe}{0,1}${Ks})`,VC=`(?!${Gs})`,WC=`[^.${Jr}]`,zC=`${td}*?`,rd={DOT_LITERAL:Xe,PLUS_LITERAL:FC,QMARK_LITERAL:$C,SLASH_LITERAL:Jr,ONE_CHAR:jC,QMARK:td,END_ANCHOR:Ks,DOTS_SLASH:Gs,NO_DOT:BC,NO_DOTS:KC,NO_DOT_SLASH:GC,NO_DOTS_SLASH:VC,QMARK_NO_DOT:WC,STAR:zC,START_ANCHOR:nd},JC={...rd,SLASH_LITERAL:`[${Me}]`,QMARK:ed,STAR:`${ed}*?`,DOTS_SLASH:`${Xe}{1,2}(?:[${Me}]|$)`,NO_DOT:`(?!${Xe})`,NO_DOTS:`(?!(?:^|[${Me}])${Xe}{1,2}(?:[${Me}]|$))`,NO_DOT_SLASH:`(?!${Xe}{0,1}(?:[${Me}]|$))`,NO_DOTS_SLASH:`(?!${Xe}{1,2}(?:[${Me}]|$))`,QMARK_NO_DOT:`[^.${Me}]`,START_ANCHOR:`(?:^|[${Me}])`,END_ANCHOR:`(?:[${Me}]|$)`},YC={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};od.exports={DEFAULT_MAX_EXTGLOB_RECURSION:DC,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:YC,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:UC.sep,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?JC:rd}}});var Rn=z(le=>{"use strict";var XC=Ze("path"),qC=process.platform==="win32",{REGEX_BACKSLASH:ZC,REGEX_REMOVE_BACKSLASH:QC,REGEX_SPECIAL_CHARS:eA,REGEX_SPECIAL_CHARS_GLOBAL:tA}=yn();le.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);le.hasRegexChars=e=>eA.test(e);le.isRegexChar=e=>e.length===1&&le.hasRegexChars(e);le.escapeRegex=e=>e.replace(tA,"\\$1");le.toPosixSlashes=e=>e.replace(ZC,"/");le.removeBackslashes=e=>e.replace(QC,t=>t==="\\"?"":t);le.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};le.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:qC===!0||XC.sep==="\\";le.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?le.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};le.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};le.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${e})${o}`;return t.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var dd=z((uw,fd)=>{"use strict";var sd=Rn(),{CHAR_ASTERISK:Vs,CHAR_AT:nA,CHAR_BACKWARD_SLASH:Cn,CHAR_COMMA:rA,CHAR_DOT:Ws,CHAR_EXCLAMATION_MARK:zs,CHAR_FORWARD_SLASH:ld,CHAR_LEFT_CURLY_BRACE:Js,CHAR_LEFT_PARENTHESES:Ys,CHAR_LEFT_SQUARE_BRACKET:oA,CHAR_PLUS:sA,CHAR_QUESTION_MARK:id,CHAR_RIGHT_CURLY_BRACE:iA,CHAR_RIGHT_PARENTHESES:ad,CHAR_RIGHT_SQUARE_BRACKET:aA}=yn(),cd=e=>e===ld||e===Cn,ud=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},cA=(e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,s=[],i=[],a=[],c=e,l=-1,u=0,d=0,f=!1,p=!1,g=!1,S=!1,A=!1,b=!1,I=!1,P=!1,T=!1,O=!1,K=0,D,x,N={value:"",depth:0,isGlob:!1},H=()=>l>=r,m=()=>c.charCodeAt(l+1),k=()=>(D=x,c.charCodeAt(++l));for(;l<r;){x=k();let ie;if(x===Cn){I=N.backslashes=!0,x=k(),x===Js&&(b=!0);continue}if(b===!0||x===Js){for(K++;H()!==!0&&(x=k());){if(x===Cn){I=N.backslashes=!0,k();continue}if(x===Js){K++;continue}if(b!==!0&&x===Ws&&(x=k())===Ws){if(f=N.isBrace=!0,g=N.isGlob=!0,O=!0,o===!0)continue;break}if(b!==!0&&x===rA){if(f=N.isBrace=!0,g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===iA&&(K--,K===0)){b=!1,f=N.isBrace=!0,O=!0;break}}if(o===!0)continue;break}if(x===ld){if(s.push(l),i.push(N),N={value:"",depth:0,isGlob:!1},O===!0)continue;if(D===Ws&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(x===sA||x===nA||x===Vs||x===id||x===zs)===!0&&m()===Ys){if(g=N.isGlob=!0,S=N.isExtglob=!0,O=!0,x===zs&&l===u&&(T=!0),o===!0){for(;H()!==!0&&(x=k());){if(x===Cn){I=N.backslashes=!0,x=k();continue}if(x===ad){g=N.isGlob=!0,O=!0;break}}continue}break}if(x===Vs){if(D===Vs&&(A=N.isGlobstar=!0),g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===id){if(g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===oA){for(;H()!==!0&&(ie=k());){if(ie===Cn){I=N.backslashes=!0,k();continue}if(ie===aA){p=N.isBracket=!0,g=N.isGlob=!0,O=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&x===zs&&l===u){P=N.negated=!0,u++;continue}if(n.noparen!==!0&&x===Ys){if(g=N.isGlob=!0,o===!0){for(;H()!==!0&&(x=k());){if(x===Ys){I=N.backslashes=!0,x=k();continue}if(x===ad){O=!0;break}}continue}break}if(g===!0){if(O=!0,o===!0)continue;break}}n.noext===!0&&(S=!1,g=!1);let U=c,de="",_="";u>0&&(de=c.slice(0,u),c=c.slice(u),d-=u),U&&g===!0&&d>0?(U=c.slice(0,d),_=c.slice(d)):g===!0?(U="",_=c):U=c,U&&U!==""&&U!=="/"&&U!==c&&cd(U.charCodeAt(U.length-1))&&(U=U.slice(0,-1)),n.unescape===!0&&(_&&(_=sd.removeBackslashes(_)),U&&I===!0&&(U=sd.removeBackslashes(U)));let h={prefix:de,input:e,start:u,base:U,glob:_,isBrace:f,isBracket:p,isGlob:g,isExtglob:S,isGlobstar:A,negated:P,negatedExtglob:T};if(n.tokens===!0&&(h.maxDepth=0,cd(x)||i.push(N),h.tokens=i),n.parts===!0||n.tokens===!0){let ie;for(let F=0;F<s.length;F++){let xe=ie?ie+1:u,Oe=s[F],pe=e.slice(xe,Oe);n.tokens&&(F===0&&u!==0?(i[F].isPrefix=!0,i[F].value=de):i[F].value=pe,ud(i[F]),h.maxDepth+=i[F].depth),(F!==0||pe!=="")&&a.push(pe),ie=Oe}if(ie&&ie+1<e.length){let F=e.slice(ie+1);a.push(F),n.tokens&&(i[i.length-1].value=F,ud(i[i.length-1]),h.maxDepth+=i[i.length-1].depth)}h.slashes=s,h.parts=a}return h};fd.exports=cA});var hd=z((lw,_d)=>{"use strict";var An=yn(),se=Rn(),{MAX_LENGTH:Yr,POSIX_REGEX_SOURCE:uA,REGEX_NON_SPECIAL_CHARS:lA,REGEX_SPECIAL_CHARS_BACKREF:fA,REPLACEMENTS:pd}=An,dA=(e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(o=>se.escapeRegex(o)).join("..")}return n},Ft=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,md=e=>{let t=[],n=0,r=0,o=0,s="",i=!1;for(let a of e){if(i===!0){s+=a,i=!1;continue}if(a==="\\"){s+=a,i=!0;continue}if(a==='"'){o=o===1?0:1,s+=a;continue}if(o===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){t.push(s),s="";continue}}}s+=a}return t.push(s),t},pA=e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n==="\\"){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},gd=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(pA(t))return t.replace(/\\(.)/g,"$1")},mA=e=>{let t=e.map(gd).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],s=t[r],i=o[0];if(!(!i||o!==i.repeat(o.length)||s!==i.repeat(s.length))&&(o===s||o.startsWith(s)||s.startsWith(o)))return!0}return!1},Xs=(e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,o=0,s=!1;for(let i=1;i<e.length;i++){let a=e[i];if(s===!0){s=!1;continue}if(a==="\\"){s=!0;continue}if(a==='"'){o=o===1?0:1;continue}if(o!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return t===!0&&i!==e.length-1?void 0:{type:e[0],body:e.slice(2,i),end:i}}}}},gA=e=>{let t=0,n=[];for(;t<e.length;){let o=Xs(e.slice(t),!1);if(!o||o.type!=="*")return;let s=md(o.body).map(a=>a.trim());if(s.length!==1)return;let i=gd(s[0]);if(!i||i.length!==1)return;n.push(i),t+=o.end+1}return n.length<1?void 0:`${n.length===1?se.escapeRegex(n[0]):`[${n.map(o=>se.escapeRegex(o)).join("")}]`}*`},_A=e=>{let t=0,n=e.trim(),r=Xs(n);for(;r;)t++,n=r.body.trim(),r=Xs(n);return t},hA=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:An.DEFAULT_MAX_EXTGLOB_RECURSION,r=md(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||mA(r)))return{risky:!0};for(let o of r){let s=gA(o);if(s)return{risky:!0,safeOutput:s};if(_A(o)>n)return{risky:!0}}return{risky:!1}},qs=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=pd[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(Yr,n.maxLength):Yr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},i=[s],a=n.capture?"":"?:",c=se.isWindows(t),l=An.globChars(c),u=An.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,SLASH_LITERAL:p,ONE_CHAR:g,DOTS_SLASH:S,NO_DOT:A,NO_DOT_SLASH:b,NO_DOTS_SLASH:I,QMARK:P,QMARK_NO_DOT:T,STAR:O,START_ANCHOR:K}=l,D=C=>`(${a}(?:(?!${K}${C.dot?S:d}).)*?)`,x=n.dot?"":A,N=n.dot?P:T,H=n.bash===!0?D(n):O;n.capture&&(H=`(${H})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let m={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:i};e=se.removePrefix(e,m),o=e.length;let k=[],U=[],de=[],_=s,h,ie=()=>m.index===o-1,F=m.peek=(C=1)=>e[m.index+C],xe=m.advance=()=>e[++m.index]||"",Oe=()=>e.slice(m.index+1),pe=(C="",Y=0)=>{m.consumed+=C,m.index+=Y},Hn=C=>{m.output+=C.output!=null?C.output:C.value,pe(C.value)},Am=()=>{let C=1;for(;F()==="!"&&(F(2)!=="("||F(3)==="?");)xe(),m.start++,C++;return C%2===0?!1:(m.negated=!0,m.start++,!0)},Un=C=>{m[C]++,de.push(C)},qe=C=>{m[C]--,de.pop()},v=C=>{if(_.type==="globstar"){let Y=m.braces>0&&(C.type==="comma"||C.type==="brace"),R=C.extglob===!0||k.length&&(C.type==="pipe"||C.type==="paren");C.type!=="slash"&&C.type!=="paren"&&!Y&&!R&&(m.output=m.output.slice(0,-_.output.length),_.type="star",_.value="*",_.output=H,m.output+=_.output)}if(k.length&&C.type!=="paren"&&(k[k.length-1].inner+=C.value),(C.value||C.output)&&Hn(C),_&&_.type==="text"&&C.type==="text"){_.value+=C.value,_.output=(_.output||"")+C.value;return}C.prev=_,i.push(C),_=C},Dn=(C,Y)=>{let R={...u[Y],conditions:1,inner:""};R.prev=_,R.parens=m.parens,R.output=m.output,R.startIndex=m.index,R.tokensIndex=i.length;let w=(n.capture?"(":"")+R.open;Un("parens"),v({type:C,value:Y,output:m.output?"":g}),v({type:"paren",extglob:!0,value:xe(),output:w}),k.push(R)},bm=C=>{let Y=e.slice(C.startIndex,m.index+1),R=e.slice(C.startIndex+2,m.index),w=hA(R,n);if((C.type==="plus"||C.type==="star")&&w.risky){let G=w.safeOutput?(C.output?"":g)+(n.capture?`(${w.safeOutput})`:w.safeOutput):void 0,Ie=i[C.tokensIndex];Ie.type="text",Ie.value=Y,Ie.output=G||se.escapeRegex(Y);for(let Te=C.tokensIndex+1;Te<i.length;Te++)i[Te].value="",i[Te].output="",delete i[Te].suffix;m.output=C.output+Ie.output,m.backtrack=!0,v({type:"paren",extglob:!0,value:h,output:""}),qe("parens");return}let W=C.close+(n.capture?")":""),oe;if(C.type==="negate"){let G=H;if(C.inner&&C.inner.length>1&&C.inner.includes("/")&&(G=D(n)),(G!==H||ie()||/^\)+$/.test(Oe()))&&(W=C.close=`)$))${G}`),C.inner.includes("*")&&(oe=Oe())&&/^\.[^\\/.]+$/.test(oe)){let Ie=qs(oe,{...t,fastpaths:!1}).output;W=C.close=`)${Ie})${G})`}C.prev.type==="bos"&&(m.negatedExtglob=!0)}v({type:"paren",extglob:!0,value:h,output:W}),qe("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let C=!1,Y=e.replace(fA,(R,w,W,oe,G,Ie)=>oe==="\\"?(C=!0,R):oe==="?"?w?w+oe+(G?P.repeat(G.length):""):Ie===0?N+(G?P.repeat(G.length):""):P.repeat(W.length):oe==="."?d.repeat(W.length):oe==="*"?w?w+oe+(G?H:""):H:w?R:`\\${R}`);return C===!0&&(n.unescape===!0?Y=Y.replace(/\\/g,""):Y=Y.replace(/\\+/g,R=>R.length%2===0?"\\\\":R?"\\":"")),Y===e&&n.contains===!0?(m.output=e,m):(m.output=se.wrapOutput(Y,m,t),m)}for(;!ie();){if(h=xe(),h==="\0")continue;if(h==="\\"){let R=F();if(R==="/"&&n.bash!==!0||R==="."||R===";")continue;if(!R){h+="\\",v({type:"text",value:h});continue}let w=/^\\+/.exec(Oe()),W=0;if(w&&w[0].length>2&&(W=w[0].length,m.index+=W,W%2!==0&&(h+="\\")),n.unescape===!0?h=xe():h+=xe(),m.brackets===0){v({type:"text",value:h});continue}}if(m.brackets>0&&(h!=="]"||_.value==="["||_.value==="[^")){if(n.posix!==!1&&h===":"){let R=_.value.slice(1);if(R.includes("[")&&(_.posix=!0,R.includes(":"))){let w=_.value.lastIndexOf("["),W=_.value.slice(0,w),oe=_.value.slice(w+2),G=uA[oe];if(G){_.value=W+G,m.backtrack=!0,xe(),!s.output&&i.indexOf(_)===1&&(s.output=g);continue}}}(h==="["&&F()!==":"||h==="-"&&F()==="]")&&(h=`\\${h}`),h==="]"&&(_.value==="["||_.value==="[^")&&(h=`\\${h}`),n.posix===!0&&h==="!"&&_.value==="["&&(h="^"),_.value+=h,Hn({value:h});continue}if(m.quotes===1&&h!=='"'){h=se.escapeRegex(h),_.value+=h,Hn({value:h});continue}if(h==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===!0&&v({type:"text",value:h});continue}if(h==="("){Un("parens"),v({type:"paren",value:h});continue}if(h===")"){if(m.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Ft("opening","("));let R=k[k.length-1];if(R&&m.parens===R.parens+1){bm(k.pop());continue}v({type:"paren",value:h,output:m.parens?")":"\\)"}),qe("parens");continue}if(h==="["){if(n.nobracket===!0||!Oe().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Ft("closing","]"));h=`\\${h}`}else Un("brackets");v({type:"bracket",value:h});continue}if(h==="]"){if(n.nobracket===!0||_&&_.type==="bracket"&&_.value.length===1){v({type:"text",value:h,output:`\\${h}`});continue}if(m.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Ft("opening","["));v({type:"text",value:h,output:`\\${h}`});continue}qe("brackets");let R=_.value.slice(1);if(_.posix!==!0&&R[0]==="^"&&!R.includes("/")&&(h=`/${h}`),_.value+=h,Hn({value:h}),n.literalBrackets===!1||se.hasRegexChars(R))continue;let w=se.escapeRegex(_.value);if(m.output=m.output.slice(0,-_.value.length),n.literalBrackets===!0){m.output+=w,_.value=w;continue}_.value=`(${a}${w}|${_.value})`,m.output+=_.value;continue}if(h==="{"&&n.nobrace!==!0){Un("braces");let R={type:"brace",value:h,output:"(",outputIndex:m.output.length,tokensIndex:m.tokens.length};U.push(R),v(R);continue}if(h==="}"){let R=U[U.length-1];if(n.nobrace===!0||!R){v({type:"text",value:h,output:h});continue}let w=")";if(R.dots===!0){let W=i.slice(),oe=[];for(let G=W.length-1;G>=0&&(i.pop(),W[G].type!=="brace");G--)W[G].type!=="dots"&&oe.unshift(W[G].value);w=dA(oe,n),m.backtrack=!0}if(R.comma!==!0&&R.dots!==!0){let W=m.output.slice(0,R.outputIndex),oe=m.tokens.slice(R.tokensIndex);R.value=R.output="\\{",h=w="\\}",m.output=W;for(let G of oe)m.output+=G.output||G.value}v({type:"brace",value:h,output:w}),qe("braces"),U.pop();continue}if(h==="|"){k.length>0&&k[k.length-1].conditions++,v({type:"text",value:h});continue}if(h===","){let R=h,w=U[U.length-1];w&&de[de.length-1]==="braces"&&(w.comma=!0,R="|"),v({type:"comma",value:h,output:R});continue}if(h==="/"){if(_.type==="dot"&&m.index===m.start+1){m.start=m.index+1,m.consumed="",m.output="",i.pop(),_=s;continue}v({type:"slash",value:h,output:p});continue}if(h==="."){if(m.braces>0&&_.type==="dot"){_.value==="."&&(_.output=d);let R=U[U.length-1];_.type="dots",_.output+=h,_.value+=h,R.dots=!0;continue}if(m.braces+m.parens===0&&_.type!=="bos"&&_.type!=="slash"){v({type:"text",value:h,output:d});continue}v({type:"dot",value:h,output:d});continue}if(h==="?"){if(!(_&&_.value==="(")&&n.noextglob!==!0&&F()==="("&&F(2)!=="?"){Dn("qmark",h);continue}if(_&&_.type==="paren"){let w=F(),W=h;if(w==="<"&&!se.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(_.value==="("&&!/[!=<:]/.test(w)||w==="<"&&!/<([!=]|\w+>)/.test(Oe()))&&(W=`\\${h}`),v({type:"text",value:h,output:W});continue}if(n.dot!==!0&&(_.type==="slash"||_.type==="bos")){v({type:"qmark",value:h,output:T});continue}v({type:"qmark",value:h,output:P});continue}if(h==="!"){if(n.noextglob!==!0&&F()==="("&&(F(2)!=="?"||!/[!=<:]/.test(F(3)))){Dn("negate",h);continue}if(n.nonegate!==!0&&m.index===0){Am();continue}}if(h==="+"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){Dn("plus",h);continue}if(_&&_.value==="("||n.regex===!1){v({type:"plus",value:h,output:f});continue}if(_&&(_.type==="bracket"||_.type==="paren"||_.type==="brace")||m.parens>0){v({type:"plus",value:h});continue}v({type:"plus",value:f});continue}if(h==="@"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){v({type:"at",extglob:!0,value:h,output:""});continue}v({type:"text",value:h});continue}if(h!=="*"){(h==="$"||h==="^")&&(h=`\\${h}`);let R=lA.exec(Oe());R&&(h+=R[0],m.index+=R[0].length),v({type:"text",value:h});continue}if(_&&(_.type==="globstar"||_.star===!0)){_.type="star",_.star=!0,_.value+=h,_.output=H,m.backtrack=!0,m.globstar=!0,pe(h);continue}let C=Oe();if(n.noextglob!==!0&&/^\([^?]/.test(C)){Dn("star",h);continue}if(_.type==="star"){if(n.noglobstar===!0){pe(h);continue}let R=_.prev,w=R.prev,W=R.type==="slash"||R.type==="bos",oe=w&&(w.type==="star"||w.type==="globstar");if(n.bash===!0&&(!W||C[0]&&C[0]!=="/")){v({type:"star",value:h,output:""});continue}let G=m.braces>0&&(R.type==="comma"||R.type==="brace"),Ie=k.length&&(R.type==="pipe"||R.type==="paren");if(!W&&R.type!=="paren"&&!G&&!Ie){v({type:"star",value:h,output:""});continue}for(;C.slice(0,3)==="/**";){let Te=e[m.index+4];if(Te&&Te!=="/")break;C=C.slice(3),pe("/**",3)}if(R.type==="bos"&&ie()){_.type="globstar",_.value+=h,_.output=D(n),m.output=_.output,m.globstar=!0,pe(h);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&!oe&&ie()){m.output=m.output.slice(0,-(R.output+_.output).length),R.output=`(?:${R.output}`,_.type="globstar",_.output=D(n)+(n.strictSlashes?")":"|$)"),_.value+=h,m.globstar=!0,m.output+=R.output+_.output,pe(h);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&C[0]==="/"){let Te=C[1]!==void 0?"|$":"";m.output=m.output.slice(0,-(R.output+_.output).length),R.output=`(?:${R.output}`,_.type="globstar",_.output=`${D(n)}${p}|${p}${Te})`,_.value+=h,m.output+=R.output+_.output,m.globstar=!0,pe(h+xe()),v({type:"slash",value:"/",output:""});continue}if(R.type==="bos"&&C[0]==="/"){_.type="globstar",_.value+=h,_.output=`(?:^|${p}|${D(n)}${p})`,m.output=_.output,m.globstar=!0,pe(h+xe()),v({type:"slash",value:"/",output:""});continue}m.output=m.output.slice(0,-_.output.length),_.type="globstar",_.output=D(n),_.value+=h,m.output+=_.output,m.globstar=!0,pe(h);continue}let Y={type:"star",value:h,output:H};if(n.bash===!0){Y.output=".*?",(_.type==="bos"||_.type==="slash")&&(Y.output=x+Y.output),v(Y);continue}if(_&&(_.type==="bracket"||_.type==="paren")&&n.regex===!0){Y.output=h,v(Y);continue}(m.index===m.start||_.type==="slash"||_.type==="dot")&&(_.type==="dot"?(m.output+=b,_.output+=b):n.dot===!0?(m.output+=I,_.output+=I):(m.output+=x,_.output+=x),F()!=="*"&&(m.output+=g,_.output+=g)),v(Y)}for(;m.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ft("closing","]"));m.output=se.escapeLast(m.output,"["),qe("brackets")}for(;m.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ft("closing",")"));m.output=se.escapeLast(m.output,"("),qe("parens")}for(;m.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ft("closing","}"));m.output=se.escapeLast(m.output,"{"),qe("braces")}if(n.strictSlashes!==!0&&(_.type==="star"||_.type==="bracket")&&v({type:"maybe_slash",value:"",output:`${p}?`}),m.backtrack===!0){m.output="";for(let C of m.tokens)m.output+=C.output!=null?C.output:C.value,C.suffix&&(m.output+=C.suffix)}return m};qs.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(Yr,n.maxLength):Yr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=pd[e]||e;let s=se.isWindows(t),{DOT_LITERAL:i,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:f,STAR:p,START_ANCHOR:g}=An.globChars(s),S=n.dot?d:u,A=n.dot?f:u,b=n.capture?"":"?:",I={negated:!1,prefix:""},P=n.bash===!0?".*?":p;n.capture&&(P=`(${P})`);let T=x=>x.noglobstar===!0?P:`(${b}(?:(?!${g}${x.dot?l:i}).)*?)`,O=x=>{switch(x){case"*":return`${S}${c}${P}`;case".*":return`${i}${c}${P}`;case"*.*":return`${S}${P}${i}${c}${P}`;case"*/*":return`${S}${P}${a}${c}${A}${P}`;case"**":return S+T(n);case"**/*":return`(?:${S}${T(n)}${a})?${A}${c}${P}`;case"**/*.*":return`(?:${S}${T(n)}${a})?${A}${P}${i}${c}${P}`;case"**/.*":return`(?:${S}${T(n)}${a})?${i}${c}${P}`;default:{let N=/^(.*?)\.(\w+)$/.exec(x);if(!N)return;let H=O(N[1]);return H?H+i+N[2]:void 0}}},K=se.removePrefix(e,I),D=O(K);return D&&n.strictSlashes!==!0&&(D+=`${a}?`),D};_d.exports=qs});var Ed=z((fw,Sd)=>{"use strict";var SA=Ze("path"),EA=dd(),Zs=hd(),Qs=Rn(),yA=yn(),RA=e=>e&&typeof e=="object"&&!Array.isArray(e),te=(e,t,n=!1)=>{if(Array.isArray(e)){let u=e.map(f=>te(f,t,n));return f=>{for(let p of u){let g=p(f);if(g)return g}return!1}}let r=RA(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=t||{},s=Qs.isWindows(t),i=r?te.compileRe(e,t):te.makeRe(e,t,!1,!0),a=i.state;delete i.state;let c=()=>!1;if(o.ignore){let u={...t,ignore:null,onMatch:null,onResult:null};c=te(o.ignore,u,n)}let l=(u,d=!1)=>{let{isMatch:f,match:p,output:g}=te.test(u,i,t,{glob:e,posix:s}),S={glob:e,state:a,regex:i,posix:s,input:u,output:g,match:p,isMatch:f};return typeof o.onResult=="function"&&o.onResult(S),f===!1?(S.isMatch=!1,d?S:!1):c(u)?(typeof o.onIgnore=="function"&&o.onIgnore(S),S.isMatch=!1,d?S:!1):(typeof o.onMatch=="function"&&o.onMatch(S),d?S:!0)};return n&&(l.state=a),l};te.test=(e,t,n,{glob:r,posix:o}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let s=n||{},i=s.format||(o?Qs.toPosixSlashes:null),a=e===r,c=a&&i?i(e):e;return a===!1&&(c=i?i(e):e,a=c===r),(a===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?a=te.matchBase(e,t,n,o):a=t.exec(c)),{isMatch:!!a,match:a,output:c}};te.matchBase=(e,t,n,r=Qs.isWindows(n))=>(t instanceof RegExp?t:te.makeRe(t,n)).test(SA.basename(e));te.isMatch=(e,t,n)=>te(t,n)(e);te.parse=(e,t)=>Array.isArray(e)?e.map(n=>te.parse(n,t)):Zs(e,{...t,fastpaths:!1});te.scan=(e,t)=>EA(e,t);te.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},s=o.contains?"":"^",i=o.contains?"":"$",a=`${s}(?:${e.output})${i}`;e&&e.negated===!0&&(a=`^(?!${a}).*$`);let c=te.toRegex(a,t);return r===!0&&(c.state=e),c};te.makeRe=(e,t={},n=!1,r=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(o.output=Zs.fastpaths(e,t)),o.output||(o=Zs(e,t)),te.compileRe(o,t,n,r)};te.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===!0)throw n;return/$^/}};te.constants=yA;Sd.exports=te});var Rd=z((dw,yd)=>{"use strict";yd.exports=Ed()});var Od=z((pw,xd)=>{"use strict";var Ad=Ze("util"),bd=Qf(),Le=Rd(),ei=Rn(),Cd=e=>e===""||e==="./",kd=e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},J=(e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,s=new Set,i=0,a=u=>{s.add(u.output),n&&n.onResult&&n.onResult(u)};for(let u=0;u<t.length;u++){let d=Le(String(t[u]),{...n,onResult:a},!0),f=d.state.negated||d.state.negatedExtglob;f&&i++;for(let p of e){let g=d(p,!0);(f?!g.isMatch:g.isMatch)&&(f?r.add(g.output):(r.delete(g.output),o.add(g.output)))}}let l=(i===t.length?[...s]:[...o]).filter(u=>!r.has(u));if(n&&l.length===0){if(n.failglob===!0)throw new Error(`No matches found for "${t.join(", ")}"`);if(n.nonull===!0||n.nullglob===!0)return n.unescape?t.map(u=>u.replace(/\\/g,"")):t}return l};J.match=J;J.matcher=(e,t)=>Le(e,t);J.isMatch=(e,t,n)=>Le(t,n)(e);J.any=J.isMatch;J.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],s=a=>{n.onResult&&n.onResult(a),o.push(a.output)},i=new Set(J(e,t,{...n,onResult:s}));for(let a of o)i.has(a)||r.add(a);return[...r]};J.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Ad.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>J.contains(e,r,n));if(typeof t=="string"){if(Cd(e)||Cd(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return J.isMatch(e,t,{...n,contains:!0})};J.matchKeys=(e,t,n)=>{if(!ei.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=J(Object.keys(e),t,n),o={};for(let s of r)o[s]=e[s];return o};J.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Le(String(o),n);if(r.some(i=>s(i)))return!0}return!1};J.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Le(String(o),n);if(!r.every(i=>s(i)))return!1}return!0};J.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Ad.inspect(e)}"`);return[].concat(t).every(r=>Le(r,n)(e))};J.capture=(e,t,n)=>{let r=ei.isWindows(n),s=Le.makeRe(String(e),{...n,capture:!0}).exec(r?ei.toPosixSlashes(t):t);if(s)return s.slice(1).map(i=>i===void 0?"":i)};J.makeRe=(...e)=>Le.makeRe(...e);J.scan=(...e)=>Le.scan(...e);J.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of bd(String(r),t))n.push(Le.parse(o,t));return n};J.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!kd(e)?[e]:bd(e,t)};J.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return J.braces(e,{...t,expand:!0})};J.hasBraces=kd;xd.exports=J});import{realpathSync as xx}from"node:fs";import{resolve as Ox}from"node:path";import{fileURLToPath as Ix,pathToFileURL as Tx}from"node:url";import{createHash as qm}from"node:crypto";import{homedir as Zm}from"node:os";import{dirname as rO,join as Qm,parse as oO,resolve as sO}from"node:path";var $i="EV_AI_LAUNCHER_VERSION";var ji="EV_AI_HOOK_SOURCE",Bi="EV_AI_HOOK_FALLBACK_REASON",Ki="EV_AI_LAUNCHER_SCOPE",mo="EV_AI_LAUNCHER_READY_FD";var Gi="--defer-user-spec",Fn="--cap",zt="--slot";var Vi=Buffer.from([1]);var vx=1024*1024,Mx=4*1024*1024,Lx=64*1024,Hx=64*1024,Ux=64*1024;var go=4096,Dx=4*1024*1024;import{join as qi}from"node:path";import{open as Wi,mkdir as wm,readFile as Nm,readdir as vm,rename as Mm,stat as Lm,rmdir as Hm,unlink as Um,utimes as Dm}from"node:fs/promises";var $n=new WeakMap;function Ji(e){if(e&&typeof e=="object"&&"code"in e)return e}function Ot(e){return Ji(e)?.code==="ENOENT"}function Jt(e){return Ji(e)?.code==="EEXIST"}async function Yi(e,t){try{return await e.readdir(t)}catch(n){if(Ot(n))return[];throw n}}function Xi(){return{async open(e,t){let n=await Wi(e,t),r={path:e};return $n.set(r,n),r},async write(e,t){let n=zi(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await zi(e).sync()},async close(e){let t=$n.get(e);$n.delete(e),t&&await t.close()},rename:Mm,async readdir(e){return vm(e)},readFile:Nm,async stat(e){let t=await Lm(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await wm(e,t)},unlink:Um,rmdir:Hm,utimes:Dm,async fsyncDir(e){if(process.platform==="win32")return;let t=await Wi(e,"r");try{await t.sync()}finally{await t.close()}}}}function zi(e){let t=$n.get(e);if(!t)throw new Error("closed");return t}var Zi=4,Qi=10;function jn(e=process.platform){return e==="win32"?Zi:Qi}var Bn=6e4,Yt=2e3,ea="slots",_o=64;function ta(e){return qi(e,".ev-ai","agent-hook",ea)}function Kn(e,t){return qi(e,`slot-${t}`)}function Gn(e,t){return`${e}
15
15
  ${t}
16
- `}function Qr(e){let t=e===void 0?null:/^(\d+):(\d+)$/.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&Number.isSafeInteger(r)?{index:n,acquiredAtMs:r}:void 0}function Li(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}var Bp=/^(\d+)\n(\d+)\n$/;function Kp(e){let t=Bp.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&n>0&&Number.isSafeInteger(r)?{pid:n,acquiredAtMs:r}:void 0}function Hi(e,t,n){let r=Kp(e);if(!r)return Math.abs(n-t)<Bt;let o=n-r.acquiredAtMs;return o<-Bt||o>=Pn?!1:Li(r.pid)}import{createHash as Gp,randomBytes as Wp}from"node:crypto";import{existsSync as eo,mkdirSync as zp,readdirSync as Vp,readFileSync as Jp,renameSync as Ui,statSync as ji,unlinkSync as Di,writeFileSync as Yp}from"node:fs";import{basename as Xp,dirname as Fi,join as Bi,relative as qp}from"node:path";function E(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
17
- `)}function Kt(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}function Gt(e){return Gp("sha256").update(e).digest("hex").slice(0,32)}function me(e,t){zp(Fi(e),{recursive:!0});let n=Bi(Fi(e),`.${Xp(e)}.${process.pid}.${Wp(4).toString("hex")}.tmp`);try{Yp(n,t,"utf8");try{Ui(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){Di(e),Ui(n,e);return}throw r}}catch(r){try{Di(n)}catch{}throw r}}function vn(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}function to(){process.stdout.write('{"continue":true}')}function M(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function Wt(){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 Mn(e){return new Promise(t=>{let n="",r=!1,o=i=>{r||(r=!0,clearTimeout(s),t(i||"{}"))},s=setTimeout(()=>{o(n)},e);if(process.stdin.isTTY){o("{}");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",i=>{n+=i}),process.stdin.on("end",()=>{o(n)}),process.stdin.on("error",()=>{o(n)}),process.stdin.resume()})}async function ye(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 te(e,t,n=3e3,r={}){let o=await ye(e,t,n,r);return o.ok?o.stdout:""}async function no(e=process.cwd()){let t=await ye("git",["rev-parse","--show-toplevel"],2e3,{cwd:e});if(t.ok&&t.stdout)return{root:t.stdout,inGitRepo:!0};if(M("EV_AI_HOOK_DEBUG")){let r=t.ok?"empty stdout":t.spawnFailed?"spawn failed":`exit ${String(t.code??"unknown")}`;E(`DEBUG: git rev-parse --show-toplevel failed (${r}) cwd=${e}`)}let n=M("CURSOR_PROJECT_DIR")??M("CLAUDE_PROJECT_DIR");if(n&&eo(n)){let r=await ye("git",["rev-parse","--show-toplevel"],2e3,{cwd:n});return r.ok&&r.stdout?{root:r.stdout,inGitRepo:!0}:{root:n,inGitRepo:!1}}return{root:e,inGitRepo:!1}}async function Le(e=process.cwd()){return(await no(e)).root}function ge(e,t){try{return JSON.parse(e)}catch{return t}}var $i=new Map;function Ln(e){return e.charCodeAt(0)===65279?e.slice(1):e}function Zp(e){let t;try{t=Jp(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Ln(t))}}catch{return{ok:!1,reason:"parse"}}}function Ki(e){let t=$i.get(e);if(t!==void 0)return t;let n=Zp(e);return $i.set(e,n),n}function Gi(e){return Ki(e)}function ne(e,t){let n=Ki(e);return n.ok?n.value:t}function it(e){return typeof e=="string"?e:""}function He(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=He(e,t);return typeof n=="string"?n:""}var Je=500;function Wi(e,t=2){if(!eo(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,i)=>{if(i>t||r)return;let a;try{a=Vp(s,{withFileTypes:!0})}catch{return}for(let c of a){if(r)return;let l=Bi(s,c.name);if(c.isDirectory()){o(l,i+1);continue}if(c.isFile()){try{n.push({name:qp(e,l),size:ji(l).size})}catch{continue}if(n.length>=Je){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function ro(e){return eo(e)?{present:!0,size:ji(e).size}:{present:!1,size:0}}var Ji="https://hooks.ev-ai.ai",Hn=".claude/ev-ai-runtime-report.json",Yi="config.json",nm="max_concurrent_hooks",bk=1024*1024,rm=new Set(["localhost","127.0.0.1","[::1]","::1"]),om=["claude","cursor","codex"],Un=[Hn,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],oo=/^[A-Za-z0-9._~-]+$/;function Dn(e){return e!==void 0&&om.includes(e)}function Xi(e){if(!e||typeof e!="object")return;let t=e[nm];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}function zi(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function Rt(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function so(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=Rt(e,c);t=u.value,c=u.next;continue}if(l.startsWith("--runner=")){t=l.slice(9);continue}if(l==="--url"){let u=Rt(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=Rt(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=Rt(e,c);u.value&&(s=u.value),c=u.next;continue}if(l.startsWith("--base-url=")){s=l.slice(11);continue}if(l===On){let u=Rt(e,c);i=zi(u.value)??i,c=u.next;continue}if(l.startsWith(`${On}=`)){i=zi(l.slice(On.length+1))??i;continue}if(l===$t){let u=Rt(e,c);a=Qr(u.value)??a,c=u.next;continue}if(l.startsWith(`${$t}=`)){a=Qr(l.slice($t.length+1))??a;continue}l!==Ai&&!l.startsWith("-")&&n===void 0&&(n=l)}}return{runner:Dn(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s,...i!==void 0?{cap:i}:{},...a!==void 0?{slot:a}:{}}}function Fn(e,t=Ji){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function zt(e=em()){return tm(e,".ev-ai",Yi)}function qi(e,t){return{...e,...t}}function Vi(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 $n(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?rm.has(t.hostname):!1}catch{return!1}}function io(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 at(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!$n(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=io(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!oo.test(n))return`org token must match ${oo.source} (got: ${n})`;if(Vi(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(Vi(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function Ct(e){return new URL(e).toString()}function ao(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?Fn(n):""}function jn(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 Zi(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=Fn(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=at(n);return r?{problem:r}:{url:Ct(n)}}var co="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL";function Qi(e){let t=e[co]?.trim();if(!t)return{};let n=at(t);return n?{problem:n}:{url:Ct(t)}}function Vt(e){if(at(e))return;let t;try{t=new URL(e)}catch{return}let n=io(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 Qp("sha256").update(i).digest("hex").slice(0,32)}var Ye=2,ea="node_modules/@ev-ai/agent-hook/dist/hook.mjs",_e="ev-ai-agent-hook";function sm(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}function Bn(e){let t=sm(e);return t===_e||t===`${_e}.exe`}var ta="https://cdn.ev-ai.ai/agent-hook";var uo=`current/${_e}`,lo=`.ev-ai/agent-hook/${_e}`,na=5e3,ra=5e3,fo=3e3;var Kn=3e3,oa=1500,sa=4*1024,po=256*1024,im=4*1024,ia=32*1024,Ue="1.3.7",Gn=`@ev-ai/agent-hook@${Ue}`,aa="ev-ai runtime report";var ca={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{chmodSync as za,cpSync as Va,existsSync as Xe,mkdirSync as Oo,readFileSync as hg,rmSync as Zn,symlinkSync as Sg,writeFileSync as Eg}from"node:fs";import{homedir as De}from"node:os";import{dirname as Io,isAbsolute as yg,join as W,relative as Ja,resolve as Ga,sep as Rg}from"node:path";import{fileURLToPath as Cg}from"node:url";import{existsSync as am,readdirSync as ua}from"node:fs";import{homedir as Wn}from"node:os";import{join as ae}from"node:path";function la(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return ae(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}function mo(e=process.platform){let t=la(e),n=[ae(t,"managed-settings.json")],r=ae(t,"managed-settings.d");try{if(!am(r))return n;let o=ua(r).filter(s=>s.endsWith(".json")&&!s.startsWith(".")).sort().map(s=>ae(r,s));n.push(...o)}catch{}return n}function go(e=process.platform,t=Wn()){return{serverManaged:ae(t,".claude","remote-settings.json"),fileBased:mo(e)}}function cm(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return ae(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}function um(e=process.platform,t=Wn()){let n=[ae(cm(e),"hooks.json")],r=ae(t,".cursor","managed");try{for(let o of ua(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(ae(r,o.name,"hooks.json"))}catch{}return n}function lm(e=process.platform,t=Wn()){let n=e==="win32"?ae(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[ae(n,"requirements.toml")];return e!=="win32"&&r.push(ae(n,"managed_config.toml")),r.push(ae(t,".codex","managed_config.toml"),ae(n,"config.toml")),r}function zn(e,t=process.platform,n=Wn()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=go(t,n);return[r,...o]}case"cursor":return um(t,n);default:return lm(t,n)}}import{createHash as Ra,randomBytes as bm}from"node:crypto";import{existsSync as Ca,mkdirSync as ho,readFileSync as Aa,unlinkSync as xa,writeFileSync as ka}from"node:fs";import{homedir as So}from"node:os";import{dirname as Jn,join as Eo,resolve as Om}from"node:path";var fm=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),dm=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function de(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||dm.has(n)||r.includes("[bot]")||fm.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 pm,readFileSync as mm}from"node:fs";import{hostname as fa,userInfo as gm}from"node:os";function At(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 At(X("CURSOR_SANDBOX",e))}var _m=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function hm(e){return _m.some(t=>!!X(t,e))}function Sm(e){if(X("KUBERNETES_SERVICE_HOST",e)||At(X("REMOTE_CONTAINERS",e))||At(X("DEVCONTAINER",e)))return!0;try{if(pm("/.dockerenv")||mm("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function pa(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!X(t,e))}function Em(e,t=process.platform){return pa(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!X(n,e)):!1}function ym(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function Rm(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 Cm(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Am(X("CURSOR_VERSION",n))}function Am(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function _o(e){if(ym(e.sessionId))return!0;let t=e.hostname??fa(),n=e.osUser??ga(e.env);return Cm(t,n,e.env)}function xm(e){return At(X("CURSOR_AGENT",e.env))?!0:_o(e)}function km(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))||pa(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!X(t,e))||X("SESSIONNAME",e))}function Jt(e={}){let t=e.env;if(X("GITHUB_ACTIONS",t))return"github_actions";if(At(X("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!Em(t,n)&&xm(e)&&(At(X("CURSOR_AGENT",t))||Rm(n)))return"cursor_cloud";if(X("CODESPACES",t)||X("CODESPACE_NAME",t))return"codespaces";if(X("GITLAB_CI",t))return"gitlab_ci";if(hm(t))return"managed";let r=X("CI",t);return r&&r!=="false"&&r!=="0"?"managed":Sm(t)?"container":km(t)?"interactive":"unknown"}async function ma(){return await te("systemd-detect-virt",[],1e3)}function ga(e=process.env,t=gm){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""}}async function _a(){let e=process.platform==="darwin"?"Darwin":process.platform==="win32"?"Windows_NT":"Linux",t="";if(process.platform==="darwin")t=await te("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:s}=await import("node:fs"),i=s("/etc/os-release","utf8"),a=i.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],c=i.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];t=a??c??""}catch{t=await te("lsb_release",["-sd"],1e3).then(s=>s.replace(/^"|"$/g,""))}t||(t=await te("uname",["-r"],1e3))}else t=await te("ver",[],1e3);let n=ga(),r=(process.env.SHELL??"").split(/[/\\]/).pop()??"",o="";try{o=await te("tty",[],500),o.includes("not a tty")&&(o="")}catch{o=""}return{os:e,os_version:t||null,user:n||null,shell:r||null,tty:o||null}}function Vn(){return fa()}var Im="installation.json",Tm="cloud-bootstrap.lock",Pm=6e4;function ba(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function Re(e=So()){return Eo(e,".ev-ai","agent-hook")}function wm(e=So()){return Eo(Re(e),Im)}function Oa(e){return Eo(Jn(e),Tm)}function Ia(){return bm(8).toString("hex")}function xt(e){return Ra("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 Ta(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function Nm(e=process.env){let t=$(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!Ta(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 Pa(e,t){return e&&Ta(e)?e:(e&&E(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),Nm(t))}function vm(e){return/^[0-9a-f]{16}$/.test(e)}function Mm(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 xt(`github_actions|${t}|${n}`)}if($(e.CODESPACES)||$(e.CODESPACE_NAME)){let t=$(e.CODESPACE_NAME);if(t)return xt(`codespaces|${t}`);let n=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),r=$(e.GITHUB_USER)??$(e.GITHUB_ACTOR);if(n&&r)return xt(`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 xt(`gitlab|${t}|${n}`)}return null}var Lm="cursoragent@cursor.com";function Hm(e){let t=$(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===Lm?null:t}function Um(e,t){return $(e.CURSOR_PROJECT_DIR)??$(e.CLAUDE_PROJECT_DIR)??t}function Dm(e){return Kt(e).replace(/\.git$/i,"").toLowerCase()}async function Fm(e){let t=await te("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?Dm(t):e}async function $m(e){let t=$(await te("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!de(null,t))return t;let n=$(await te("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!de(null,n)?n:null}function jm(e,t){let n=Um(e,t);return n?xt(`cursor_cloud|${n}|${Hm(e)??""}`):null}async function Bm(e,t){let n=$(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await Fm(n),o=await $m(n);return xt(`claude_remote|${r}|${o??""}`)}function ha(e,t){let n=Pa(e,t);if(n)return n;let r=Mm(t);return r||Ia()}async function Km(e){let n=await te("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||Om(e);return Ra("sha256").update(n).digest("hex").slice(0,16)}function Gm(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 Wm(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=Gm(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 ct(e){if(Ca(e))try{return Wm(Aa(e,"utf8"))}catch{}}function yo(e){return ct(e)}function wa(e,t,n){let r=ct(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{me(e,`${JSON.stringify(o,null,2)}
18
- `)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: operator identity cache write failed open: ${i}`)}}function Na(e,t=Date.now()){if(!e)return!0;if(ct(e)?.operator_identity_hash)return!1;let n=Oa(e);try{if(Ca(n)){let r=Number.NaN;try{r=Number(Aa(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<Pm)return!1;try{xa(n)}catch{}}}catch{}try{return ho(Jn(n),{recursive:!0}),ka(n,`${t}
19
- `,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(Ha(r))return!1;let o=r instanceof Error?r.message:String(r);return E(`WARN: cloud bootstrap claim failed open: ${o}`),!0}}function va(e){if(e)try{xa(Oa(e))}catch{}}function Ma(e,t){let r=ct(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}function La(e,t,n){if(!n)return;let r=ct(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{me(e,`${JSON.stringify(o,null,2)}
20
- `)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: platform_agent_id cache write failed open: ${i}`)}}function Ha(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}function zm(e,t){ho(Jn(e),{recursive:!0}),ka(e,`${JSON.stringify(t,null,2)}
21
- `,{encoding:"utf8",flag:"wx"})}function Sa(e,t){try{return zm(e,t),t}catch(n){if(!Ha(n))throw n;return ct(e)}}function Ea(e,t){ho(Jn(e),{recursive:!0}),me(e,`${JSON.stringify(t,null,2)}
22
- `)}function ya(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}async function Yn(e,t={}){let n=t.home??So(),r=t.env??process.env,o=await Km(e),s=wm(n),i={sessionId:t.sessionId,hostname:$(r.HOSTNAME)??void 0,osUser:$(r.USER)??$(r.LOGNAME)??$(r.USERNAME)??void 0,env:r},a=Jt(i),c=Pa(t.overrideId,r),l=a==="cursor_cloud"&&_o(i)?jm(r,e):a==="claude_remote"?await Bm(r,e):null,u=ct(s);if(u){let S=u;if(c&&c===u.installation_id&&u.pinned!==!0&&(S={...u,pinned:!0},Ea(s,S)),!!l&&l!==S.installation_id&&!c&&S.pinned!==!0&&vm(S.installation_id)&&l){let x={installation_id:l,...S.platform_agent_ids?{platform_agent_ids:S.platform_agent_ids}:{}};return Ea(s,x),{installationId:l,storePath:s,repoKey:o}}return{installationId:S.installation_id,storePath:s,repoKey:o}}let d=c??l??ha(void 0,r),f=Sa(s,ya(d,c));if(f)return{installationId:f.installation_id,storePath:s,repoKey:o};let p=c??l??ha(void 0,r),g=Sa(s,ya(p===d?Ia():p,c));if(g)return{installationId:g.installation_id,storePath:s,repoKey:o};throw new Error(`Failed to create installation record at ${s}`)}import{existsSync as Ao,readFileSync as og}from"node:fs";import{dirname as sg,isAbsolute as ig,join as ag,relative as cg}from"node:path";import{readFileSync as Vm,statSync as Jm}from"node:fs";import{homedir as Ro}from"node:os";import{join as Ym}from"node:path";var Xm="hook-config.json",qm=10080*60*1e3,Zm=1440*60*1e3,Qm=2048,eg=1024*1024;function kt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ua(e=Ro()){return Ym(Re(e),Xm)}function Da(e){let t=Ua(e);try{let n=Jm(t);if(!n.isFile()||n.size>eg)return;let r=JSON.parse(Vm(t,"utf8"));return kt(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}function tg(e){let t={};return typeof e.collect_prompt=="boolean"&&(t.collect_prompt=e.collect_prompt),t}function Xn(e,t=Ro(),n=Date.now()){if(!e)return;let r=Vt(e);if(!r)return;let o=Da(t),s=o?o[r]:void 0;if(!kt(s)||!kt(s.config))return;let i=s.fetched_at_ms;if(!(typeof i!="number"||n-i>qm))return tg(s.config)}function ng(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!kt(n)||!kt(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>Qm))return n.hook_config}function rg(e,t,n,r){let o={...e},s=o[t];if(Object.keys(n).length===0)return s===void 0?void 0:(delete o[t],o);if(!(kt(s)&&JSON.stringify(s.config)===JSON.stringify(n)&&typeof s.fetched_at_ms=="number"&&s.fetched_at_ms<=r&&r-s.fetched_at_ms<Zm))return o[t]={config:n,fetched_at_ms:r},o}function Fa(e,t,n=Ro(),r=Date.now()){let o=ng(e),s=t?Vt(t):void 0;if(o===void 0||!s)return"skipped";try{let i=Da(n);if(i===void 0)return"skipped";let a=rg(i??{},s,o,r);return a?(me(Ua(n),`${JSON.stringify(a,null,2)}
23
- `),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(i){let a=i instanceof Error?i.message:String(i);return E(`WARN: hook config write failed open: ${a}`),"failed"}}function $a(e){for(let t of Un){let n=ag(e,t);if(Ao(n))return n}}async function ug(e=process.cwd(),t){let n=t??await Le(e);return $a(n)??$a(e)}async function lg(e,t){let n=t??await Le(sg(e)),r=cg(n,e);if(r.startsWith("..")||ig(r))return!1;let o=await ye("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(E(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}function Co(e){let t=og(e,"utf8");return ge(Ln(t),{})}function fg(){return{schema_version:Ye,mcp_servers:[]}}function dg(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(E(`WARN: ignoring capture_hook_input=full in git-tracked manifest ${t}; use EV_AI_HOOK_CAPTURE_FULL_INPUT=1 or an untracked operator manifest`),delete e.capture_hook_input),e.debug===!0&&r.has("debug")&&(E(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}function pg(){let e=Qi(process.env);return e.problem&&E(`WARN: ignoring ${co}: ${e.problem}`),e.url??""}async function ja(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await no(e),o=M("EV_AI_HOOK_MANIFEST"),s=o&&Ao(o)?o:void 0,i=s?void 0:Ao(zt())?zt():void 0,a=s?void 0:await ug(e,n),c=i?Co(i):void 0,l=a?Co(a):void 0,u,d,f,p=new Set;if(s){u=Co(s),d=s,f=s;for(let O of Object.keys(u))p.add(O)}else if(c&&l){u=qi(l,c),d=i,f=a;for(let O of Object.keys(l))O in c||p.add(O)}else if(c)u=c,d=i;else if(l){u=l,d=a,f=a;for(let O of Object.keys(l))p.add(O)}else u=fg();delete u.installation_id;let g=f?await lg(f,n):!1;dg(u,f,g,p);let{installationId:S,storePath:A,repoKey:x}=await Yn(n,{sessionId:t.sessionId}),I=ao(u)||pg();return{manifestPath:d??A,manifest:u,installationId:S,installationStorePath:A,repoKey:x,collectorUrl:I,hookConfig:Xn(I),platformAgentId:u.platform_agent_id??"",gitRoot:n,inGitRepo:r}}function Ba(e){return{schema_version:Ye,...e?{collector_url:e}:{},mcp_servers:[]}}var mg=["darwin-arm64","darwin-x64","linux-arm64","linux-x64","windows-x64","windows-arm64"];function gg(e){return e==="windows-x64"||e==="windows-arm64"}function xo(e=process.platform,t=process.arch){if(e==="darwin")return t==="arm64"?"darwin-arm64":t==="x64"?"darwin-x64":void 0;if(e==="linux")return t==="arm64"?"linux-arm64":t==="x64"?"linux-x64":void 0;if(e==="win32")return t==="x64"?"windows-x64":t==="arm64"?"windows-arm64":void 0}function Ka(e=process.platform,t=process.arch){let n=xo(e,t);if(!n)throw new Error(`Unsupported platform ${e}-${t}. Supported: ${mg.join(", ")}.`);return n}function _g(e){return gg(e)?`${_e}.exe`:_e}function ko(e){return`compile-out/bin/${e}/${_g(e)}`}function Ag(e,t){let n=e.collectorUrl?.trim();if(!n)throw new Error(`${t} requires --url <https://hooks.ev-ai.ai/{orgToken}/hook>`);let r=at(n);if(r)throw new Error(`collector URL rejected: ${r}`);return Ct(n)}function xg(e){let t=e.collectorUrl?.trim();if(!t)return;let n=at(t);if(n)throw new Error(`collector URL rejected: ${n}`);return Ct(t)}function kg(e){return Ag(e,"install")}function Ya(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url")}return t}function Xa(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url");if(r==="--update")throw new Error("--update was removed; use the `update` command instead of `install --update`");if(r==="--delivery"){let o=e[n+1];(o==="npx"||o==="binary"||o==="local")&&(t.delivery=o,n+=1);continue}if(r==="--force"){t.force=!0;continue}if(r==="--no-claude"){t.skipClaude=!0;continue}if(r==="--no-cursor"){t.skipCursor=!0;continue}if(r==="--no-codex"){t.skipCodex=!0;continue}}return t}function qa(e=process.execPath){return Za(e)?"binary":"npx"}function bg(){return W(De(),".ev-ai","agent-hook")}function Og(e=De()){return W(e,".ev-ai","agent-hook",uo)}function Ig(){let e=Io(Cg(import.meta.url)),t=W(e,"hook.mjs");return Xe(t)?t:W(e,"..","dist","hook.mjs")}function Za(e=process.execPath){return Bn(e)}function Qa(e,t){let n=Ja(Ga(e),Ga(t));return!n.startsWith("..")&&!yg(n)}function Qn(e){return e.split(Rg).join("/")}function Tg(e){return`node "$(git rev-parse --show-toplevel)/${Qn(e)}"`}function Pg(e){return`"$(git rev-parse --show-toplevel)/${Qn(e)}"`}function wg(e){return W(e,lo)}function ec(e,t){let n=wg(e);Oo(Io(n),{recursive:!0}),Va(t,n,{force:!0});try{za(n,493)}catch{}return n}function Ng(e){let t=W(bg(),"current");try{Zn(t,{recursive:!0,force:!0})}catch{}Sg(e,t,process.platform==="win32"?"junction":"dir")}function tc(e,t=Ue,n=De()){let r=W(n,".ev-ai","agent-hook",t),o=W(r,_e);Oo(r,{recursive:!0}),Va(e,o,{force:!0});try{za(o,493)}catch{}return Ng(r),W(n,".ev-ai","agent-hook",uo)}function nc(e){let t=xo();if(!t)return;let n=[W(e,ko(t)),W(e,"packages","agent-hook",ko(t))];for(let r of n)if(Xe(r)&&Qa(e,r))return r}function vg(e=De()){let t=Og(e);return Xe(t)?t:void 0}function Mg(e,t=De()){let n=vg(t);return n||(Za()?tc(process.execPath,Ue,t):nc(e))}function Lg(e,t=De()){let n=nc(e);if(!n)throw new Error(`update requires a locally compiled binary \u2014 run this package\u2019s build:hook-binary script first.
24
- To install a released binary instead: curl -fsSL https://cdn.ev-ai.ai/agent-hook/install.sh | sh`);let r=tc(n,Ue,t),o=ec(e,n);return{sourcePath:n,projectPath:o,globalPath:r}}function Wa(e){let t=[W(e,"packages","agent-hook","dist","hook.mjs"),W(e,ea)],n=Ig();Xe(n)&&Qa(e,n)&&t.unshift(n);for(let r of t){if(!Xe(r))continue;let o=Qn(Ja(e,r));return{command:Tg(o),hookPath:o,strategy:"dev_mjs"}}}function Hg(e){return e==="SessionStart"||e==="sessionStart"}function Ug(e){return e.replace(/\s+--prefer-offline\b/g,"")}function qn(e,t){return Hg(e)?Ug(t):t}function Dg(e=Gn){return`npx -y --prefer-offline ${e}`}function Fg(e,t=De(),n=qa()){if(n==="npx")return{command:Dg(),hookPath:Gn,strategy:"npx"};if(n==="local"){let s=Wa(e);if(s)return s;throw new Error("local delivery requires packages/agent-hook/dist/hook.mjs (or node_modules/@ev-ai/agent-hook/dist/hook.mjs) under the git root \u2014 run yarn workspace @ev-ai/agent-hook build first")}let r=Mg(e,t);if(r){ec(e,r);let s=Qn(lo);return{command:Pg(s),hookPath:s,strategy:"project_binary"}}let o=Wa(e);if(o)return o;throw new Error(`ev-ai-agent-hook binary not found. Install from CDN:
25
- curl -fsSL ${ta}/install.sh | sh
16
+ `}function ho(e){let t=e===void 0?null:/^(\d+):(\d+)$/.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&Number.isSafeInteger(r)?{index:n,acquiredAtMs:r}:void 0}function na(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}var Fm=/^(\d+)\n(\d+)\n$/;function $m(e){let t=Fm.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&n>0&&Number.isSafeInteger(r)?{pid:n,acquiredAtMs:r}:void 0}function ra(e,t,n){let r=$m(e);if(!r)return Math.abs(n-t)<Yt;let o=n-r.acquiredAtMs;return o<-Yt||o>=Bn?!1:na(r.pid)}import{createHash as jm,randomBytes as Bm}from"node:crypto";import{existsSync as Vn,mkdirSync as Km,readdirSync as Gm,readFileSync as Vm,renameSync as oa,statSync as ca,unlinkSync as sa,writeFileSync as Wm}from"node:fs";import{homedir as ua}from"node:os";import{basename as zm,dirname as ia,isAbsolute as Jm,join as la,relative as fa,resolve as De,sep as Ym}from"node:path";function E(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
17
+ `)}function Xt(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}function qt(e){return jm("sha256").update(e).digest("hex").slice(0,32)}function ce(e,t){Km(ia(e),{recursive:!0});let n=la(ia(e),`.${zm(e)}.${process.pid}.${Bm(4).toString("hex")}.tmp`);try{Wm(n,t,"utf8");try{oa(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){sa(e),oa(n,e);return}throw r}}catch(r){try{sa(n)}catch{}throw r}}function Wn(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}var da;function Eo(){(da?.stdout??process.stdout).write('{"continue":true}')}var Zt=new Set(["on","1","true"]),pa=new Set(["off","0","false"]);function M(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function Qt(){return new Promise(e=>{let t="";if(process.stdin.isTTY){e("");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",n=>{t+=n}),process.stdin.on("end",()=>{e(t)}),process.stdin.on("error",()=>{e(t)}),process.stdin.resume()})}async function zn(e){let t=da?.stdin??process.stdin;return new Promise(n=>{let r="",o=!1,s=a=>{o||(o=!0,clearTimeout(i),n(a||"{}"))},i=setTimeout(()=>{s(r)},e);if(t.isTTY){s("{}");return}t.setEncoding("utf8"),t.on("data",a=>{r+=a}),t.on("end",()=>{s(r)}),t.on("error",()=>{s(r)}),t.resume()})}async function Ae(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:s}=await import("node:util"),i=s(o);try{let{stdout:a}=await i(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:a.trim()}}catch(a){let c=a,l=typeof c.code=="number"?c.code:typeof c.status=="number"?c.status:void 0;return{ok:!1,code:l,spawnFailed:l===void 0}}}async function ne(e,t,n=3e3,r={}){let o=await Ae(e,t,n,r);return o.ok?o.stdout:""}function So(e,t){let n=De(e),r=De(t),o=fa(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${Ym}`)||Jm(o)?!1:De(r,o)===n}function ma(e,t,n=ua()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return De(e);let o=De(r),s=De(e);if(So(s,o))return s;let i=t.CURSOR_PLUGIN_ROOT?.trim();return So(s,De(n,".cursor"))||i!==void 0&&i.length>0&&So(s,De(i))?o:s}async function yo(e=process.cwd(),t=process.env,n=ua()){let r=ma(e,t,n),o=r!==De(e)&&Vn(r)?r:e,s=await Ae("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(s.ok&&s.stdout)return{root:s.stdout,inGitRepo:!0};if(M("EV_AI_HOOK_DEBUG")){let a=s.ok?"empty stdout":s.spawnFailed?"spawn failed":`exit ${String(s.code??"unknown")}`;E(`DEBUG: git rev-parse --show-toplevel failed (${a}) cwd=${e}`)}let i=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||M("CURSOR_PROJECT_DIR")||M("CLAUDE_PROJECT_DIR");if(i&&Vn(i)){let a=await Ae("git",["rev-parse","--show-toplevel"],2e3,{cwd:i});return a.ok&&a.stdout?{root:a.stdout,inGitRepo:!0}:{root:i,inGitRepo:!1}}return{root:e,inGitRepo:!1}}async function Fe(e=process.cwd()){return(await yo(e)).root}function Se(e,t){try{return JSON.parse(e)}catch{return t}}var aa=new Map;function Jn(e){return e.charCodeAt(0)===65279?e.slice(1):e}function Xm(e){let t;try{t=Vm(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Jn(t))}}catch{return{ok:!1,reason:"parse"}}}function ga(e){let t=aa.get(e);if(t!==void 0)return t;let n=Xm(e);return aa.set(e,n),n}function _a(e){return ga(e)}function q(e,t){let n=ga(e);return n.ok?n.value:t}function pt(e){return typeof e=="string"?e:""}function $e(e,t){let n=e[t];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(!t.includes("."))return;let r=t.split("."),o=e;for(let s of r){if(o===null||typeof o!="object"||Array.isArray(o))return;o=o[s]}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o}function L(e,t){let n=$e(e,t);return typeof n=="string"?n:""}var et=500;function ha(e,t=2){if(!Vn(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,i)=>{if(i>t||r)return;let a;try{a=Gm(s,{withFileTypes:!0})}catch{return}for(let c of a){if(r)return;let l=la(s,c.name);if(c.isDirectory()){o(l,i+1);continue}if(c.isFile()){try{n.push({name:fa(e,l),size:ca(l).size})}catch{continue}if(n.length>=et){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function Ro(e){return Vn(e)?{present:!0,size:ca(e).size}:{present:!1,size:0}}var Ca="https://hooks.ev-ai.ai",Yn=".claude/ev-ai-runtime-report.json",Aa="config.json",eg="max_concurrent_hooks",uO=1024*1024,tg=new Set(["localhost","127.0.0.1","[::1]","::1"]),ng=["claude","cursor","codex"],Xn=[Yn,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Co=/^[A-Za-z0-9._~-]+$/;function qn(e){return e!==void 0&&ng.includes(e)}function ba(e){if(!e||typeof e!="object")return;let t=e[eg];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}function Sa(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function It(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function Zn(e){let t,n,r,o,s,i,a;for(let c=0;c<e.length;c++){let l=e[c];if(l!==void 0){if(l==="--runner"){let u=It(e,c);t=u.value,c=u.next;continue}if(l.startsWith("--runner=")){t=l.slice(9);continue}if(l==="--url"){let u=It(e,c);u.value&&(r=u.value),c=u.next;continue}if(l.startsWith("--url=")){r=l.slice(6);continue}if(l==="--token"){let u=It(e,c);u.value&&(o=u.value),c=u.next;continue}if(l.startsWith("--token=")){o=l.slice(8);continue}if(l==="--base-url"){let u=It(e,c);u.value&&(s=u.value),c=u.next;continue}if(l.startsWith("--base-url=")){s=l.slice(11);continue}if(l===Fn){let u=It(e,c);i=Sa(u.value)??i,c=u.next;continue}if(l.startsWith(`${Fn}=`)){i=Sa(l.slice(Fn.length+1))??i;continue}if(l===zt){let u=It(e,c);a=ho(u.value)??a,c=u.next;continue}if(l.startsWith(`${zt}=`)){a=ho(l.slice(zt.length+1))??a;continue}l!==Gi&&!l.startsWith("-")&&n===void 0&&(n=l)}}return{runner:qn(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s,...i!==void 0?{cap:i}:{},...a!==void 0?{slot:a}:{}}}function Qn(e,t=Ca){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function mt(e=Zm()){return Qm(e,".ev-ai",Aa)}function ka(e,t){return{...e,...t}}function Ea(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===127||n===39)return!0}return!1}function er(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?tg.has(t.hostname):!1}catch{return!1}}function Ao(e){try{let n=new URL(e).pathname.split("/").filter(r=>r.length>0);if(n.length>=2&&n[n.length-1]==="hook"){let r=n[n.length-2];return r&&r.length>0?r:void 0}return}catch{return}}function je(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!er(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Ao(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Co.test(n))return`org token must match ${Co.source} (got: ${n})`;if(Ea(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(Ea(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function tt(e){return new URL(e).toString()}function xa(e){if(e.collector_url)return e.collector_url;let t=e.repo_ingest_token,n=typeof t=="string"?t.trim():void 0;return n?Qn(n):""}function Tt(e){try{let t=new URL(e),n=t.pathname.split("/").filter(r=>r.length>0);return n.length>=2&&n[n.length-1]==="hook"&&(n[n.length-2]="***",t.pathname=`/${n.join("/")}`),t.toString()}catch{return"<invalid-url>"}}function Oa(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=Qn(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=je(n);return r?{problem:r}:{url:tt(n)}}var rg="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",og="COLLECTOR_URL",ya="collector_url_override",sg=[rg,og];function ig(e){let t;for(let n of sg){let r=e[n]?.trim();if(!r)continue;let o=je(r);if(o){t??={problem:o,envName:n};continue}return{url:tt(r),envName:n}}return t??{}}function Ra(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=je(t);return n?{problem:n}:{url:tt(t)}}function Ia(e){let t=[],n=Ra(e.homeConfig?.[ya]);if(n.problem&&t.push({label:ya,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=Oa(Zn(e.argv));if(r.problem&&t.push({label:"--url/--token",problem:r.problem}),r.url)return{url:r.url,source:"argv",warnings:t};let o=ig(e.env);if(o.problem&&o.envName&&t.push({label:o.envName,problem:o.problem}),o.url)return{url:o.url,source:"plugin_option",warnings:t};let s=Ra(e.homeConfig?.collector_url);if(s.problem&&t.push({label:"collector_url",problem:s.problem}),s.url)return{url:s.url,source:"home_config",warnings:t};let i=e.homeConfig?.repo_ingest_token,a=typeof i=="string"&&i.trim()?{...e.manifest,repo_ingest_token:i}:e.manifest,c=a?xa(a):"";if(c){let l=je(c);if(l)t.push({label:"manifest collector_url",problem:l});else return{url:tt(c),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}function en(e){if(je(e))return;let t;try{t=new URL(e)}catch{return}let n=Ao(e);if(!n)return;let o=t.pathname.split("/").filter(a=>a.length>0).slice(0,-2),s=o.length>0?`/${o.join("/")}`:"",i=`${t.origin}${s}/${n}`;return qm("sha256").update(i).digest("hex").slice(0,32)}var nt=2,Ta="node_modules/@ev-ai/agent-hook/dist/hook.mjs",Ee="ev-ai-agent-hook";function ag(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}function tr(e){let t=ag(e);return t===Ee||t===`${Ee}.exe`}var Pa="https://cdn.ev-ai.ai/agent-hook";var bo=`current/${Ee}`,ko=`.ev-ai/agent-hook/${Ee}`,wa=5e3,Na=5e3,xo=3e3;var nr=3e3,va=1500,Ma=4*1024,Oo=256*1024,cg=4*1024,La=32*1024,Be="1.3.9",rr=`@ev-ai/agent-hook@${Be}`,Ha="ev-ai runtime report";var Ua={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{chmodSync as Tc,cpSync as Pc,existsSync as rt,mkdirSync as Bo,readFileSync as L_,rmSync as pr,symlinkSync as H_,writeFileSync as U_}from"node:fs";import{homedir as Ke}from"node:os";import{dirname as Ko,isAbsolute as D_,join as V,relative as wc,resolve as Oc,sep as F_}from"node:path";import{fileURLToPath as $_}from"node:url";import{existsSync as ug,readdirSync as Da}from"node:fs";import{homedir as or}from"node:os";import{join as ue}from"node:path";function Fa(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return ue(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}function Io(e=process.platform){let t=Fa(e),n=[ue(t,"managed-settings.json")],r=ue(t,"managed-settings.d");try{if(!ug(r))return n;let o=Da(r).filter(s=>s.endsWith(".json")&&!s.startsWith(".")).sort().map(s=>ue(r,s));n.push(...o)}catch{}return n}function tn(e=process.platform,t=or()){return{serverManaged:ue(t,".claude","remote-settings.json"),fileBased:Io(e)}}function lg(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return ue(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}function fg(e=process.platform,t=or()){let n=[ue(lg(e),"hooks.json")],r=ue(t,".cursor","managed");try{for(let o of Da(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(ue(r,o.name,"hooks.json"))}catch{}return n}function dg(e=process.platform,t=or()){let n=e==="win32"?ue(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[ue(n,"requirements.toml")];return e!=="win32"&&r.push(ue(n,"managed_config.toml")),r.push(ue(t,".codex","managed_config.toml"),ue(n,"config.toml")),r}function sr(e,t=process.platform,n=or()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=tn(t,n);return[r,...o]}case"cursor":return fg(t,n);default:return dg(t,n)}}import{createHash as Za,randomBytes as Lg}from"node:crypto";import{existsSync as Qa,mkdirSync as wo,readFileSync as ec,unlinkSync as tc,writeFileSync as nc}from"node:fs";import{homedir as No}from"node:os";import{dirname as cr,join as vo,resolve as Hg}from"node:path";var pg=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),mg=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function me(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||mg.has(n)||r.includes("[bot]")||pg.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),s=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(s.endsWith("bot")||s.includes("[bot]"))return!0}return!1}import{existsSync as hg,readFileSync as Sg}from"node:fs";import{hostname as Ba,release as Eg,userInfo as yg,version as Rg}from"node:os";import*as ae from"node:os";import{performance as To}from"node:perf_hooks";var gg=1024*1024,_g=128;function ir(e){return Math.round(e/gg)}function nn(e,t){let n=10**t;return Math.round(e*n)/n}function $a(e=process.platform){try{let t=To.now(),n={},r=0,o=0,s=e!=="win32";for(let{times:c}of ae.cpus())r+=c.user+c.nice+c.sys+(s?c.irq:0),o+=c.idle;if(r+o>0&&(n.cpu_busy_ms=Math.round(r),n.cpu_idle_ms=Math.round(o)),n.uptime_s=Math.round(ae.uptime()),n.mem_free_mb=ir(ae.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=ir(process.availableMemory())),e!=="win32"){let[c,l,u]=ae.loadavg();n.load_1m=nn(c??0,2),n.load_5m=nn(l??0,2),n.load_15m=nn(u??0,2)}let i=process.resourceUsage();n.proc_cpu_user_ms=Math.round(i.userCPUTime/1e3),n.proc_cpu_sys_ms=Math.round(i.systemCPUTime/1e3),n.proc_max_rss_mb=Math.round(i.maxRSS/1024),n.proc_page_faults=i.majorPageFault,e!=="win32"&&(n.proc_invol_ctx=i.involuntaryContextSwitches);let a=To.nodeTiming?.bootstrapComplete;return typeof a=="number"&&a>0&&(n.node_boot_ms=nn(a,1)),n.sample_us=Math.round((To.now()-t)*1e3),n}catch{return}}function ja(){try{let e=ae.cpus(),t={},n=typeof ae.availableParallelism=="function"?ae.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,_g);r&&(t.cpu_model=r);let o=ae.totalmem();t.mem_total_mb=ir(o);let s=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof s=="number"&&s>0&&s<o&&(t.mem_limit_mb=ir(s)),t.uptime_h=nn(ae.uptime()/3600,1),t}catch{return{}}}function Pt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function Ka(e=process.env){return Pt(X("CURSOR_SANDBOX",e))}var Cg=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function Ag(e){return Cg.some(t=>!!X(t,e))}function bg(e){if(X("KUBERNETES_SERVICE_HOST",e)||Pt(X("REMOTE_CONTAINERS",e))||Pt(X("DEVCONTAINER",e)))return!0;try{if(hg("/.dockerenv")||Sg("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function Ga(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!X(t,e))}function kg(e,t=process.platform){return Ga(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!X(n,e)):!1}function xg(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function Og(e){return e==="linux"}function X(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return M(e)}function Ig(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Tg(X("CURSOR_VERSION",n))}function Tg(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function Po(e){if(xg(e.sessionId))return!0;let t=e.hostname??Ba(),n=e.osUser??Wa(e.env);return Ig(t,n,e.env)}function Pg(e){return Pt(X("CURSOR_AGENT",e.env))?!0:Po(e)}function wg(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(X("TERM",e)??X("TERM_PROGRAM",e))||(X("SSH_TTY",e)??X("SSH_CONNECTION",e))||(X("__CFBundleIdentifier",e)??X("XPC_SERVICE_NAME",e))||Ga(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!X(t,e))||X("SESSIONNAME",e))}function rn(e={}){let t=e.env;if(X("GITHUB_ACTIONS",t))return"github_actions";if(Pt(X("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!kg(t,n)&&Pg(e)&&(Pt(X("CURSOR_AGENT",t))||Og(n)))return"cursor_cloud";if(X("CODESPACES",t)||X("CODESPACE_NAME",t))return"codespaces";if(X("GITLAB_CI",t))return"gitlab_ci";if(Ag(t))return"managed";let r=X("CI",t);return r&&r!=="false"&&r!=="0"?"managed":bg(t)?"container":wg(t)?"interactive":"unknown"}async function Va(){return await ne("systemd-detect-virt",[],1e3)}function Wa(e=process.env,t=yg){for(let n of["USER","LOGNAME","USERNAME"]){let r=e[n];if(typeof r=="string"){let o=r.trim();if(o.length>0)return o}}try{return t().username??""}catch{return""}}var Ng=32;function vg(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,Ng);return t.length>0?t:null}function Mg(){try{return[Rg(),Eg()].filter(Boolean).join(" ").trim()}catch{return""}}async function za(e=!1){let t=vg(process.platform),n="";if(process.platform==="darwin")n=await ne("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:i}=await import("node:fs"),a=i("/etc/os-release","utf8"),c=a.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],l=a.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];n=c??l??""}catch{n=await ne("lsb_release",["-sd"],1e3).then(i=>i.replace(/^"|"$/g,""))}n||(n=await ne("uname",["-r"],1e3))}else process.platform==="win32"?n=Mg():n=await ne("ver",[],1e3);let r=Wa(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",s="";try{s=await ne("tty",[],500),s.includes("not a tty")&&(s="")}catch{s=""}return{os:t,os_version:n||null,user:r||null,shell:o||null,tty:s||null,...e?ja():{}}}function ar(){return Ba()}var Ug="installation.json",Dg="cloud-bootstrap.lock",Fg=6e4;function rc(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function ge(e=No()){return vo(e,".ev-ai","agent-hook")}function $g(e=No()){return vo(ge(e),Ug)}function oc(e){return vo(cr(e),Dg)}function sc(){return Lg(8).toString("hex")}function wt(e){return Za("sha256").update(e).digest("hex").slice(0,16)}function $(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function ic(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function jg(e=process.env){let t=$(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!ic(t)){E(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}function ac(e,t){return e&&ic(e)?e:(e&&E(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),jg(t))}function Bg(e){return/^[0-9a-f]{16}$/.test(e)}function Kg(e=process.env){if($(e.GITHUB_ACTIONS)){let t=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),n=$(e.GITHUB_ACTOR)??$(e.GITHUB_TRIGGERING_ACTOR)??$(e.GITHUB_USER);if(t&&n)return wt(`github_actions|${t}|${n}`)}if($(e.CODESPACES)||$(e.CODESPACE_NAME)){let t=$(e.CODESPACE_NAME);if(t)return wt(`codespaces|${t}`);let n=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),r=$(e.GITHUB_USER)??$(e.GITHUB_ACTOR);if(n&&r)return wt(`codespaces|${n}|${r}`)}if($(e.GITLAB_CI)){let t=$(e.CI_PROJECT_ID)??$(e.CI_PROJECT_PATH),n=$(e.GITLAB_USER_LOGIN)??$(e.GITLAB_USER_EMAIL)??$(e.GITLAB_USER_NAME);if(t&&n)return wt(`gitlab|${t}|${n}`)}return null}var Gg="cursoragent@cursor.com";function Vg(e){let t=$(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===Gg?null:t}function Wg(e,t){return $(e.CURSOR_PROJECT_DIR)??$(e.CLAUDE_PROJECT_DIR)??t}function zg(e){return Xt(e).replace(/\.git$/i,"").toLowerCase()}async function Jg(e){let t=await ne("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?zg(t):e}async function Yg(e){let t=$(await ne("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!me(null,t))return t;let n=$(await ne("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!me(null,n)?n:null}function Xg(e,t){let n=Wg(e,t);return n?wt(`cursor_cloud|${n}|${Vg(e)??""}`):null}async function qg(e,t){let n=$(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await Jg(n),o=await Yg(n);return wt(`claude_remote|${r}|${o??""}`)}function Ja(e,t){let n=ac(e,t);if(n)return n;let r=Kg(t);return r||sc()}async function Zg(e){let n=await ne("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||Hg(e);return Za("sha256").update(n).digest("hex").slice(0,16)}function Qg(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&r.length>0&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function e_(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=Qg(t.platform_agent_ids);return{installation_id:t.installation_id,...t.pinned===!0?{pinned:!0}:{},...n?{platform_agent_ids:n}:{},...typeof t.operator_identity_hash=="string"?{operator_identity_hash:t.operator_identity_hash}:{},...typeof t.operator_identity_sent_at=="string"?{operator_identity_sent_at:t.operator_identity_sent_at}:{}}}catch{return}}function gt(e){if(Qa(e))try{return e_(ec(e,"utf8"))}catch{}}function Mo(e){return gt(e)}function cc(e,t,n){let r=gt(e);if(!r||r.operator_identity_hash===t&&r.operator_identity_sent_at===n)return;let o={...r,operator_identity_hash:t,operator_identity_sent_at:n};try{ce(e,`${JSON.stringify(o,null,2)}
18
+ `)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: operator identity cache write failed open: ${i}`)}}function uc(e,t=Date.now()){if(!e)return!0;if(gt(e)?.operator_identity_hash)return!1;let n=oc(e);try{if(Qa(n)){let r=Number.NaN;try{r=Number(ec(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<Fg)return!1;try{tc(n)}catch{}}}catch{}try{return wo(cr(n),{recursive:!0}),nc(n,`${t}
19
+ `,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(pc(r))return!1;let o=r instanceof Error?r.message:String(r);return E(`WARN: cloud bootstrap claim failed open: ${o}`),!0}}function lc(e){if(e)try{tc(oc(e))}catch{}}function fc(e,t){let r=gt(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}function dc(e,t,n){if(!n)return;let r=gt(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={installation_id:r.installation_id,platform_agent_ids:{...r.platform_agent_ids,[t]:n},...r.operator_identity_hash?{operator_identity_hash:r.operator_identity_hash}:{},...r.operator_identity_sent_at?{operator_identity_sent_at:r.operator_identity_sent_at}:{}};try{ce(e,`${JSON.stringify(o,null,2)}
20
+ `)}catch(s){let i=s instanceof Error?s.message:String(s);E(`WARN: platform_agent_id cache write failed open: ${i}`)}}function pc(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}function t_(e,t){wo(cr(e),{recursive:!0}),nc(e,`${JSON.stringify(t,null,2)}
21
+ `,{encoding:"utf8",flag:"wx"})}function Ya(e,t){try{return t_(e,t),t}catch(n){if(!pc(n))throw n;return gt(e)}}function Xa(e,t){wo(cr(e),{recursive:!0}),ce(e,`${JSON.stringify(t,null,2)}
22
+ `)}function qa(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}async function ur(e,t={}){let n=t.home??No(),r=t.env??process.env,o=await Zg(e),s=$g(n),i={sessionId:t.sessionId,hostname:$(r.HOSTNAME)??void 0,osUser:$(r.USER)??$(r.LOGNAME)??$(r.USERNAME)??void 0,env:r},a=rn(i),c=ac(t.overrideId,r),l=a==="cursor_cloud"&&Po(i)?Xg(r,e):a==="claude_remote"?await qg(r,e):null,u=gt(s);if(u){let S=u;if(c&&c===u.installation_id&&u.pinned!==!0&&(S={...u,pinned:!0},Xa(s,S)),!!l&&l!==S.installation_id&&!c&&S.pinned!==!0&&Bg(S.installation_id)&&l){let b={installation_id:l,...S.platform_agent_ids?{platform_agent_ids:S.platform_agent_ids}:{}};return Xa(s,b),{installationId:l,storePath:s,repoKey:o}}return{installationId:S.installation_id,storePath:s,repoKey:o}}let d=c??l??Ja(void 0,r),f=Ya(s,qa(d,c));if(f)return{installationId:f.installation_id,storePath:s,repoKey:o};let p=c??l??Ja(void 0,r),g=Ya(s,qa(p===d?sc():p,c));if(g)return{installationId:g.installation_id,storePath:s,repoKey:o};throw new Error(`Failed to create installation record at ${s}`)}import{existsSync as Do,readFileSync as R_}from"node:fs";import{dirname as C_,isAbsolute as A_,join as b_,relative as k_}from"node:path";import{readFileSync as n_,statSync as r_}from"node:fs";import{homedir as Lo}from"node:os";import{join as o_}from"node:path";var s_="hook-config.json",i_=1440*60*1e3,a_=2048,c_=1024*1024;function Nt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mc(e=Lo()){return o_(ge(e),s_)}function gc(e){let t=mc(e);try{let n=r_(t);if(!n.isFile()||n.size>c_)return;let r=JSON.parse(n_(t,"utf8"));return Nt(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}function u_(e){let t={};return typeof e.collect_prompt=="boolean"&&(t.collect_prompt=e.collect_prompt),typeof e.collect_telemetry=="boolean"&&(t.collect_telemetry=e.collect_telemetry),t}function _c(e,t=Lo()){if(!e)return;let n=en(e);if(!n)return;let r=gc(t),o=r?r[n]:void 0;if(!(!Nt(o)||!Nt(o.config)))return u_(o.config)}function l_(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!Nt(n)||!Nt(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>a_))return n.hook_config}function f_(e,t,n,r){let o={...e},s=o[t];if(Object.keys(n).length===0)return s===void 0?void 0:(delete o[t],o);if(!(Nt(s)&&JSON.stringify(s.config)===JSON.stringify(n)&&typeof s.fetched_at_ms=="number"&&s.fetched_at_ms<=r&&r-s.fetched_at_ms<i_))return o[t]={config:n,fetched_at_ms:r},o}function hc(e,t,n=Lo(),r=Date.now()){let o=l_(e),s=t?en(t):void 0;if(o===void 0||!s)return"skipped";try{let i=gc(n);if(i===void 0)return"skipped";let a=f_(i??{},s,o,r);return a?(ce(mc(n),`${JSON.stringify(a,null,2)}
23
+ `),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(i){let a=i instanceof Error?i.message:String(i);return E(`WARN: hook config write failed open: ${a}`),"failed"}}var d_="EV_AI_HOOK_TELEMETRY";function Sc(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}function Ec(e,t,n=process.env){let r=n[d_]?.trim().toLowerCase();return r&&Zt.has(r)?{enabled:!0,source:"env"}:r&&pa.has(r)?{enabled:!1,source:"env"}:e!==void 0?{enabled:e,source:"local_config"}:t?.collect_telemetry!==void 0?{enabled:t.collect_telemetry,source:"org_config"}:{enabled:!0,source:"default"}}import{appendFileSync as p_,mkdirSync as m_,readFileSync as g_}from"node:fs";import{homedir as yc}from"node:os";import{dirname as __,join as Rc}from"node:path";var h_="hooks-debug.log",Cc={info(){},error(){}},lr=Cc;function S_(e=yc()){return Rc(e,".ev-ai",h_)}function E_(e=yc()){try{let t=JSON.parse(g_(Rc(e,".ev-ai","config.json"),"utf8"));return t!==null&&typeof t=="object"&&!Array.isArray(t)&&t.debug===!0}catch{return!1}}function Ho(e,t=!1){return e.includes("--debug")||t}function y_(e){return e.replace(/[\r\n]/g," ")}function fr(e=process.argv,t=S_(),n=E_()){if(!Ho(e,n)){lr=Cc;return}let r=(o,s)=>{try{m_(__(t),{recursive:!0}),p_(t,`${new Date().toISOString()} ${o} ${y_(s)}
24
+ `,"utf8")}catch{}};lr={info(o){r("info",o)},error(o){r("error",o)}}}var _e={info(e){lr.info(e)},error(e){lr.error(e)}};function Ac(e){for(let t of Xn){let n=b_(e,t);if(Do(n))return n}}async function x_(e=process.cwd(),t){let n=t??await Fe(e);return Ac(n)??Ac(e)}async function O_(e,t){let n=t??await Fe(C_(e)),r=k_(n,e);if(r.startsWith("..")||A_(r))return!1;let o=await Ae("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(E(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}function Uo(e){let t=R_(e,"utf8");return Se(Jn(t),{})}function I_(){return{schema_version:nt,mcp_servers:[]}}function T_(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(E(`WARN: ignoring capture_hook_input=full in git-tracked manifest ${t}; use EV_AI_HOOK_CAPTURE_FULL_INPUT=1 or an untracked operator manifest`),delete e.capture_hook_input),e.debug===!0&&r.has("debug")&&(E(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}function P_(e){let t=Ia({argv:e.argv,env:process.env,homeConfig:e.homeConfig,manifest:e.manifest,manifestSource:e.manifestSource});for(let r of t.warnings)E(`WARN: ignoring ${r.label}: ${r.problem}`),_e.error(`collector ${r.label} ignored: ${r.problem}`);let n=t.url??"";return _e.info(`collector source=${t.source} url=${n?Tt(n):"(none)"}`),n}function w_(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}async function bc(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await yo(e),o=M("EV_AI_HOOK_MANIFEST"),s=o&&Do(o)?o:void 0,i=s?void 0:Do(mt())?mt():void 0,a=s?void 0:await x_(e,n),c=i?Uo(i):void 0,l=a?Uo(a):void 0,u=Sc(s?q(mt(),{}):c),d,f,p,g=new Set;if(s){d=Uo(s),f=s,p=s;for(let O of Object.keys(d))g.add(O)}else if(c&&l){d=ka(l,c),f=i,p=a;for(let O of Object.keys(l))O in c||g.add(O)}else if(c)d=c,f=i;else if(l){d=l,f=a,p=a;for(let O of Object.keys(l))g.add(O)}else d=I_();delete d.installation_id;let S=p?await O_(p,n):!1;T_(d,p,S,g);let{installationId:A,storePath:b,repoKey:I}=await ur(n,{sessionId:t.sessionId}),P=c??w_(q(mt(),null)),T=P_({argv:t.argv??process.argv,homeConfig:P,manifest:s?d:l,manifestSource:s?"manifest_override":"manifest"});return{manifestPath:f??b,manifest:d,installationId:A,installationStorePath:b,repoKey:I,collectorUrl:T,hookConfig:_c(T),...u!==void 0?{localTelemetry:u}:{},platformAgentId:d.platform_agent_id??"",gitRoot:n,inGitRepo:r}}function kc(e){return{schema_version:nt,...e?{collector_url:e}:{},mcp_servers:[]}}var N_=["darwin-arm64","darwin-x64","linux-arm64","linux-x64","windows-x64","windows-arm64"];function v_(e){return e==="windows-x64"||e==="windows-arm64"}function Fo(e=process.platform,t=process.arch){if(e==="darwin")return t==="arm64"?"darwin-arm64":t==="x64"?"darwin-x64":void 0;if(e==="linux")return t==="arm64"?"linux-arm64":t==="x64"?"linux-x64":void 0;if(e==="win32")return t==="x64"?"windows-x64":t==="arm64"?"windows-arm64":void 0}function xc(e=process.platform,t=process.arch){let n=Fo(e,t);if(!n)throw new Error(`Unsupported platform ${e}-${t}. Supported: ${N_.join(", ")}.`);return n}function M_(e){return v_(e)?`${Ee}.exe`:Ee}function $o(e){return`compile-out/bin/${e}/${M_(e)}`}function j_(e,t){let n=e.collectorUrl?.trim();if(!n)throw new Error(`${t} requires --url <https://hooks.ev-ai.ai/{orgToken}/hook>`);let r=je(n);if(r)throw new Error(`collector URL rejected: ${r}`);return tt(n)}function B_(e){let t=e.collectorUrl?.trim();if(!t)return;let n=je(t);if(n)throw new Error(`collector URL rejected: ${n}`);return tt(t)}function K_(e){return j_(e,"install")}function Nc(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url")}return t}function vc(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url");if(r==="--update")throw new Error("--update was removed; use the `update` command instead of `install --update`");if(r==="--delivery"){let o=e[n+1];(o==="npx"||o==="binary"||o==="local")&&(t.delivery=o,n+=1);continue}if(r==="--force"){t.force=!0;continue}if(r==="--no-claude"){t.skipClaude=!0;continue}if(r==="--no-cursor"){t.skipCursor=!0;continue}if(r==="--no-codex"){t.skipCodex=!0;continue}}return t}function Mc(e=process.execPath){return Lc(e)?"binary":"npx"}function G_(){return V(Ke(),".ev-ai","agent-hook")}function V_(e=Ke()){return V(e,".ev-ai","agent-hook",bo)}function W_(){let e=Ko($_(import.meta.url)),t=V(e,"hook.mjs");return rt(t)?t:V(e,"..","dist","hook.mjs")}function Lc(e=process.execPath){return tr(e)}function Hc(e,t){let n=wc(Oc(e),Oc(t));return!n.startsWith("..")&&!D_(n)}function mr(e){return e.split(F_).join("/")}function z_(e){return`node "$(git rev-parse --show-toplevel)/${mr(e)}"`}function J_(e){return`"$(git rev-parse --show-toplevel)/${mr(e)}"`}function Y_(e){return V(e,ko)}function Uc(e,t){let n=Y_(e);Bo(Ko(n),{recursive:!0}),Pc(t,n,{force:!0});try{Tc(n,493)}catch{}return n}function X_(e){let t=V(G_(),"current");try{pr(t,{recursive:!0,force:!0})}catch{}H_(e,t,process.platform==="win32"?"junction":"dir")}function Dc(e,t=Be,n=Ke()){let r=V(n,".ev-ai","agent-hook",t),o=V(r,Ee);Bo(r,{recursive:!0}),Pc(e,o,{force:!0});try{Tc(o,493)}catch{}return X_(r),V(n,".ev-ai","agent-hook",bo)}function Fc(e){let t=Fo();if(!t)return;let n=[V(e,$o(t)),V(e,"packages","agent-hook",$o(t))];for(let r of n)if(rt(r)&&Hc(e,r))return r}function q_(e=Ke()){let t=V_(e);return rt(t)?t:void 0}function Z_(e,t=Ke()){let n=q_(t);return n||(Lc()?Dc(process.execPath,Be,t):Fc(e))}function Q_(e,t=Ke()){let n=Fc(e);if(!n)throw new Error(`update requires a locally compiled binary \u2014 run this package\u2019s build:hook-binary script first.
25
+ To install a released binary instead: curl -fsSL https://cdn.ev-ai.ai/agent-hook/install.sh | sh`);let r=Dc(n,Be,t),o=Uc(e,n);return{sourcePath:n,projectPath:o,globalPath:r}}function Ic(e){let t=[V(e,"packages","agent-hook","dist","hook.mjs"),V(e,Ta)],n=W_();rt(n)&&Hc(e,n)&&t.unshift(n);for(let r of t){if(!rt(r))continue;let o=mr(wc(e,r));return{command:z_(o),hookPath:o,strategy:"dev_mjs"}}}function eh(e){return e==="SessionStart"||e==="sessionStart"}function th(e){return e.replace(/\s+--prefer-offline\b/g,"")}function dr(e,t){return eh(e)?th(t):t}function nh(e=rr){return`npx -y --prefer-offline ${e}`}function rh(e,t=Ke(),n=Mc()){if(n==="npx")return{command:nh(),hookPath:rr,strategy:"npx"};if(n==="local"){let s=Ic(e);if(s)return s;throw new Error("local delivery requires packages/agent-hook/dist/hook.mjs (or node_modules/@ev-ai/agent-hook/dist/hook.mjs) under the git root \u2014 run yarn workspace @ev-ai/agent-hook build first")}let r=Z_(e,t);if(r){Uc(e,r);let s=mr(ko);return{command:J_(s),hookPath:s,strategy:"project_binary"}}let o=Ic(e);if(o)return o;throw new Error(`ev-ai-agent-hook binary not found. Install from CDN:
26
+ curl -fsSL ${Pa}/install.sh | sh
26
27
  Or use npx delivery:
27
- npx ${Gn} install`)}function rc(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(_e)||/(?:^|[\s/"'])ev-ai-agent-hook(?:$|[\s"'])/.test(e)}function To(e,t){return`${e.replace(/\s+--runner(?:=|\s+)\S+/g,"").trimEnd()} --runner ${t}`}function qe(e,t){Oo(Io(e),{recursive:!0}),Eg(e,`${JSON.stringify(t,null,2)}
28
- `,"utf8")}function Fe(e){if(Xe(e))try{return JSON.parse(hg(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}function $g(e,t){let n=Ba(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 jg(e){return(e.schema_version??Ye)===Ye&&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 oc(e,t){let n=W(e,Hn),r=Fe(n),o=$g(r,t);return t.collectorUrl!==void 0||Xe(n)||!jg(o)?(qe(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}function bo(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 Bg(e){if(bo(process.env))return!0;let t=De();return[...mo(),W(t,".claude","settings.json"),W(t,".claude","remote-settings.json"),W(e,".claude","settings.json"),W(e,".claude","settings.local.json")].some(r=>{try{let o=Fe(r);return o?bo(o.env):!1}catch{return!1}})}function Kg(e){try{let t=Fe(W(e,".claude","settings.json"));return t?bo(t.env):!1}catch{return!1}}function sc(e){return Array.isArray(e)?e:[]}function er(e){let t=[],n=r=>!!r&&typeof r=="object"&&rc(r.command);for(let r of sc(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 ic(e,t){return[...er(e),...t]}function Po(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!rc(t.command)):[]}function Gg(e,t){return[...Po(e),{command:t}]}function Wg(e){return typeof e=="string"?[e]:e}function zg(e){let t=(n="")=>({hooks:Wg(e).map(r=>({type:"command",command:qn(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 Vg(e){let t=typeof e=="string"?{command:e}:e,n=(r="")=>({hooks:[{type:"command",command:qn(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:qn(r,t.commandWindows)},statusMessage:aa}]});return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}var Jg=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],Yg=["afterShellExecution","afterFileEdit"];function Xg(e,t=Yg){let n={...e};for(let r of t){if(!(r in n))continue;let o=Po(n[r]);o.length===0?delete n[r]:n[r]=o}return n}function qg(e,t,n={}){let r=W(e,".claude/settings.json"),o=To(t,"claude"),s=Fe(r)??{};if(Bg(e)&&!n.force){if(s.hooks&&typeof s.hooks=="object"){let u={...s.hooks};for(let d of Object.keys(u))u[d]=er(u[d]),sc(u[d]).length===0&&delete u[d];Object.keys(u).length===0?delete s.hooks:s.hooks=u,qe(r,s)}return!1}let a=s.hooks&&typeof s.hooks=="object"?s.hooks:{},c=zg(o),l={...a};for(let[u,d]of Object.entries(c))l[u]=ic(a[u],d);return s.hooks=l,qe(r,s),!0}function Zg(e,t){let n=W(e,".cursor/hooks.json"),r=To(t,"cursor"),o=Fe(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=Xg({...s});for(let a of Jg)i[a]=Gg(i[a],qn(a,r));qe(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:i})}function Qg(e,t){let n=W(e,".codex/hooks.json"),r=To(t,"codex"),o=Fe(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=Vg(r),a={...s};for(let[c,l]of Object.entries(i))a[c]=ic(s[c],l);qe(n,{...o,hooks:a})}function e_(e){let t=W(e,".claude/settings.json"),n=Fe(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=er(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,qe(t,n),E(`Removed ev-ai hooks from ${t}`))}function t_(e){let t=W(e,".cursor/hooks.json"),n=Fe(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=Po(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){Zn(t,{force:!0}),E(`Removed ${t}`);return}qe(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function n_(e){let t=W(e,".codex/hooks.json"),n=Fe(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=er(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){Zn(t,{force:!0}),E(`Removed ${t}`);return}qe(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function wo(e=process.platform,t=process.arch,n={}){if(e==="win32")throw new Error("Windows install is not supported yet. Use macOS/Linux, or wait for phase-2 native commands.");(n.requireBinaryArch??!0)&&Ka(e,t)}async function ac(e={}){let t=kg(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??qa();wo(process.platform,process.arch,{requireBinaryArch:s==="binary"});let i=e.cwd??process.cwd(),a=await Le(i),{command:c,hookPath:l,strategy:u}=Fg(a,De(),s),{installationId:d,storePath:f}=await Yn(a,{overrideId:e.installationId}),{manifestPath:p,wrote:g}=oc(a,e),S=[];return n?E("Skipped Claude hook \u2014 --no-claude"):qg(a,c,{force:e.force})?(S.push("Claude"),e.force&&Kg(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"):(Zg(a,c),S.push("Cursor")),o?E("Skipped Codex hook \u2014 --no-codex"):(Qg(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 cc(e=process.cwd()){wo(process.platform,process.arch,{requireBinaryArch:!0});let t=await Le(e),{projectPath:n,globalPath:r}=Lg(t);E(`Refreshed ${r}`),E(`Refreshed ${n}`),E("Hook configs and shared manifest left unchanged")}async function uc(e={}){let t=xg(e);e.collectorUrl=t,wo(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await Le(n),{manifestPath:o,wrote:s}=oc(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 lc(e){for(let t of[()=>e_(e),()=>t_(e),()=>n_(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 Le(e);return lc(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 dc(e=process.cwd()){let t=await Le(e);lc(t);for(let n of Un){let r=W(t,n);if(Xe(r))try{Zn(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 wS,mkdirSync as NS,readdirSync as vS,readFileSync as MS,unlinkSync as _u,writeFileSync as LS}from"node:fs";import{homedir as hu}from"node:os";import{join as zo}from"node:path";import{existsSync as p_}from"node:fs";import{existsSync as r_}from"node:fs";import{homedir as mc}from"node:os";import{join as o_}from"node:path";function gc(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}var s_={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 pc(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}function i_(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:pc(n.mcpJson,t.mcpJson),mcpToml:pc(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}function _c(e){return Object.fromEntries(Object.entries(s_).map(([t,n])=>[t,i_(n,n[e])]))}var bt=_c("homeOnly"),Qe=_c("projectOnly");function a_(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}function c_(e,t){return a_(e).some(n=>r_(o_(t,n)))}function hc(e,t){for(let n of e)if(c_(n,t))return!0;return!1}function Ze(e){return[...new Set(e)]}function et(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:Ze(t),subagents:Ze(n),commands:Ze(r),rules:Ze(o),memory:Ze(s),settings:Ze(i),mcp:Ze(a)}}function u_(e,t=mc(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...zn(o.managed,n,t));return Ze(r)}var tt=et(Object.values(bt));function Sc(e=mc(),t=process.platform){return u_(Object.values(bt),e,t)}import{existsSync as l_}from"node:fs";import{resolve as No}from"node:path";function he(e){return No(e).replaceAll("\\","/").replace(/\/$/,"")}function ut(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 tr(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 f_=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function Yt(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!f_.test(t)?null:t}function Ot(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let s=he(o);n.has(s)||(n.add(s),r.push(s))}return r}function d_(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}function Ie(e,t,n,r=l_){for(let o of e)for(let s of t){let i=he(No(o,s)),a=No(o,s,n).replaceAll("\\","/");if(d_(i,a)&&r(a))return a}return null}var yc=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Rc=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,m_=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,Ec=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"]),g_=/^[a-z][a-z0-9-]{1,63}$/,__=[".cursor/skills",".claude/skills",".agents/skills"],h_=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],S_=ut(__,et(Object.values(Qe)).skills),E_=ut(h_,et(Object.values(bt)).skills),y_=new Set(["read","read_file","view"]),R_=new Set(["bash","shell","zsh"]);function vo(e){let t=e.replace(/\\/g,"/");return yc.exec(t)?.[1]??null}function C_(e){let t=e.replace(/\\/g,"/"),r=Rc.exec(t)?.[1];return r?r.toLowerCase():null}function A_(e){return vo(e)??C_(e)}function x_(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 nr(e){return typeof e=="string"?nr(ge(e,null)):!e||typeof e!="object"?null:x_(e)}function Cc(e){if(typeof e=="string")return Cc(ge(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}function Mo(e){let t=Cc(e.tool_input);if(t)return t;let n=it(e.command);return n.length>0?n:null}function k_(e){let t=e.replace(/\\/g,"/"),n=yc.exec(t);if(n?.[1])return n[1];let o=Rc.exec(t)?.[1];return o?o.toLowerCase():null}function b_(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function Lo(e){let t=nr(e.tool_input)??it(e.file_path);return t.length>0?t:null}function Xt(e,t,n){let r=b_(e).toLowerCase();if(y_.has(r)){let o=Lo(e);return o?t(o):null}if(R_.has(r)){let o=Mo(e);return o?n(o):null}return null}function Ac(e){return Xt(e,A_,k_)}function O_(e){let t=new Set,n=[];for(let r of e.matchAll(m_)){let o=r[1]?.toLowerCase();!o||t.has(o)||I_(o)||(t.add(o),n.push(o))}return n}function I_(e){let t=e.split("/")[0];return Ec.has(e)||t!==void 0&&Ec.has(t)}function xc(e){let t=e.skillId.toLowerCase();if(!g_.test(t))return null;let n=e.exists??p_,r=`${t}/SKILL.md`,o=Ie(Ot(e.launchCwd,e.gitRoot),S_,r,n);return o!==null?o:e.home?Ie([he(e.home)],E_,r,n):null}function T_(e){return it(e.prompt)}function kc(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=T_(e);return n?O_(n):[]}var jo=Ve(rt(),1);import{existsSync as nS}from"node:fs";var ft={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function Zt(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function tS(e){if(!e)return"";let t=Kt(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return Zt(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return Zt(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?Zt(o[1]):Zt(t)}async function ur(e=process.cwd()){let t=await ye("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([ye("git",["remote","get-url","origin"],2e3,{cwd:e}),ye("git",["branch","--show-current"],2e3,{cwd:e}),ye("git",["rev-parse","HEAD"],2e3,{cwd:e}),ye("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Kt(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 Xc(e,t,n,r=process.cwd(),o,s,i){if(t)return t;let a=ft[n];if(!a)return"";let c=ba(n,e.scope_path,i);if(s){let g=Ma(s,c);if(g)return g}let l=o??await ur(r),u=l?.remote?tS(l.remote):"";if(u||(u=Zt(process.env.GITHUB_REPOSITORY??"")),!u)return"";let d=e.scope_path??"",f=d?`${d}/`:"",p=`${u}:${f}${a}`;return s&&La(s,c,p),p}var rS=[".cursor/rules",".claude/rules",".codex/rules"],oS=et(Object.values(Qe)).rules;function sS(e){return ut(tr(e?ft[e]:void 0,rS),oS)}var iS=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function qc(e){let t=Yt(e.relativePath);if(!t)return null;let n=e.exists??nS,r=Ot(e.launchCwd,e.gitRoot),o=sS(e.runnerPlatform),s=Ie(r,o,t,n);if(s!==null)return s;if(!t.includes("/")){let i=Ie(r,["."],t,n);if(i!==null)return i}return e.home?Ie([he(e.home)],o,t,n):null}function aS(e){let t=e.replace(/\\/g,"/"),r=iS.exec(t)?.[1];return r?(0,jo.nativeKeyForRulePath)(r):null}function Zc(e){return Xt(e,jo.nativeKeyForRulePath,aS)}function Qc(e){return e.replace(/\.(mdc|md|rules)$/i,"")}function eu(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=Yt(i);!a||n.has(a)||(n.add(a),r.push(a))}return r}var Bo=Ve(rt(),1);import{existsSync as cS}from"node:fs";var uS=[".cursor/commands",".claude/commands",".codex/prompts"],lS=et(Object.values(Qe)).commands;function fS(e){return ut(tr(e?ft[e]:void 0,uS),lS)}var dS=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function tu(e){let t=Yt(e.commandId);if(!t)return null;let n=e.exists??cS,r=`${t}.md`,o=fS(e.runnerPlatform),s=Ie(Ot(e.launchCwd,e.gitRoot),o,r,n);return s!==null?s:e.home?Ie([he(e.home)],o,r,n):null}function pS(e){let t=e.replace(/\\/g,"/"),r=dS.exec(t)?.[1];return r?(0,Bo.nativeKeyForCommandPath)(r):null}function nu(e){return Xt(e,Bo.nativeKeyForCommandPath,pS)}var lr=Ve(rt(),1);function ru(e){let t=Zi(e);if(t.problem){E(`WARN: ignoring --url/--token collector override: ${t.problem}`);return}return t.url}function ou(e,t){if(L(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function mS(){return!!(M("CURSOR_VERSION")??M("CURSOR_PROJECT_DIR"))}function su(e,t,n){return e!=="claude"&&e!=="codex"?!1:ou(t,n)?!0:mS()}var gS=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function Qt(e,t,n,r){return ou(e,t)?"cursor":Dn(r)?r:Dn(n)?n:L(e,"turn_id")?"codex":L(e,"session_id")||gS.has(t.toLowerCase())?"claude":"unknown"}function fr(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function _S(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 iu(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}function au(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}function cu(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function en(e){return L(e,"session_id")||L(e,"conversation_id")}function Ko(e){return L(e,"prompt.id")||L(e,"prompt_id")||L(e,"generation_id")||L(e,"turn_id")}function Go(e){return L(e,"hook_event_name")||L(e,"event")}function uu(e,t,n){let r=en(e),o=Ko(e),s=Go(e),i=L(e,"source"),a=Qt(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:i,runnerPlatform:a}}var hS=["session_start","session_end","tool_invoked","skill_invoked"];function SS(e){return hS.includes(e)}function Wo(e,t){return e&&SS(e)?e:_S(t.toLowerCase())}var ES={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function dr(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function lu(e,t=""){let n=L(e,"tool_name")||L(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!dr(n)&&(n=`MCP:${n}`):n=ES[r]??null;let o=e.tool_input,i=(o&&typeof o=="object"?it(o.skill)||it(o.skill_name):"")||L(e,"skill_name")||null,a=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;i??=Ac(a);let c=Zc(a),l=nu(a);return{toolName:n,skillName:i,ruleName:c,commandName:l}}var yS=/^[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&&yS.test(n))return n}return null}function du(e){let t=He(e,"duration_ms");if(typeof t=="number")return t;let n=He(e,"duration");return typeof n=="number"?n:null}var RS="error",CS="interrupted",AS="permission_denied",xS=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function tn(e){return xS.test(e)?e:null}function kS(e){for(let t of["failure_type","error_type"]){let n=tn(L(e,t));if(n)return n}return null}function pu(e,t){return He(e,"is_interrupt")===!0?CS:t.toLowerCase()==="permissiondenied"?AS:kS(e)??RS}function mu(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}function bS(e,t){return mu(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}function OS(e,t){return mu(t,n=>(0,lr.mcpServerNameMatchesToolSegment)(n,e))}function IS(e,t){let n=null,r=0;for(let s of t)if(s)for(let i of(0,lr.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:OS(o[1],t)??o[1],mcpTool:o[2]}}function TS(e,t){if(/^mcp__/i.test(e))return IS(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:bS(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}function PS(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}function gu(e,t=[],n=""){let r=e?TS(e,t):{mcpServer:null,mcpTool:null},o=tn(n.trim());if(!o)return r;let s=r.mcpTool;return!s&&e&&!dr(e)&&(s=e),s&&(s=PS(s,o)),{mcpServer:o,mcpTool:s}}var Su=3e4,HS="claims",US=!0,DS=100,FS=new Set(["sessionstart","sessionend","stopfailure"]),$S=["tool_name","tool","command","file_path","url"];function jS(e=hu()){return zo(Re(e),HS)}function Eu(e,t){try{let n=MS(e,"utf8").split(`
29
- `,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}function BS(e){let t=[];for(let n of $S){let r=L(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":Gt(t.join("\0"))}function KS(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),s=e.subagentId?.trim()??"",i=e.callFingerprint?.trim()??"",a=!!(o||r||s),c=FS.has(n);if(!a&&!c)return;let l=e.runnerPlatform.trim()||"unknown";return Gt(`${l}|${t}|${n}|${r}|${o}|${i}|${s}`)}function GS(e,t=Date.now()){let n;try{n=vS(e)}catch{return}let r=0;for(let o of n){if(r>=DS)break;r+=1;let s=zo(e,o),i=Eu(s,t);if(!(!Number.isFinite(i)||i<Su))try{_u(s)}catch{}}}function WS(e,t,n=Date.now()){let r=zo(t,e);try{if(wS(r)){let o=Eu(r,n);if(Number.isFinite(o)&&o>=0&&o<Su)return!1;try{_u(r)}catch{}}}catch{}try{NS(t,{recursive:!0}),LS(r,`${n}
30
- `,{encoding:"utf8",flag:"wx"})}catch(o){if(jt(o))return!1;let s=o instanceof Error?o.message:String(o);return E(`WARN: event claim failed open: ${s}`),!0}return GS(t,n),!0}function zS(e,t,n){let r=en(e),o=Ko(e),s=L(e,"tool_use_id"),i=L(e,"subagent_id")||L(e,"agent_id"),a=Qt(e,t,void 0,n),c=BS(e);return{runnerPlatform:a,sessionId:r,runnerEvent:t,turnId:o,toolUseId:s,subagentId:i,callFingerprint:c}}function yu(e,t,n,r=hu(),o=Date.now()){if(!US)return!0;let s=KS(zS(e,t,n));if(!s)return!0;let i=WS(s,jS(r),o);return!i&&M("EV_AI_HOOK_DEBUG")&&E(`DEBUG: duplicate hook event suppressed (claim ${s.slice(0,8)}\u2026)`),i}import{mkdirSync as VS,readFileSync as Vo,statSync as xu,unlinkSync as ku,writeFileSync as Jo}from"node:fs";import{homedir as bu}from"node:os";function Ou(e){return e==="session_start"||e==="session_end"}var pr=new Set,Ru=!1;function Yo(e=bu()){return Mi(e)}function Xo(e,t=bu(),n=process.platform){if(e!==void 0)return e>0?e:Tn(n);let r=ne(zt(t),{});return Xi(r)??Tn(n)}function nn(e){return Nn(e.pid,e.acquiredAtMs)}function Iu(e){try{let t=xu(e);return t.isFile()&&t.size<=Zr?Vo(e,"utf8"):void 0}catch{return}}function qo(e,t=Yo()){if(!e)return;let n=wn(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=Iu(n);if(o===nn(r))return mr(r);if(o===Nn(process.ppid,e.acquiredAtMs))try{return Jo(n,nn(r),{encoding:"utf8",mode:384}),mr(r)}catch{return}}function Tu(e,t){if(e.path){pr.delete(e);try{Iu(e.path)===nn(e)&&Jo(e.path,Nn(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}function Pu(e,t=Date.now()){let n,r;try{let o=xu(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=Zr?Vo(e,"utf8"):""}catch{return!1}return Hi(n,r,t)}function wu(e,t=Yo(),n=Date.now){for(let r=0;r<e;r+=1)if(!Pu(wn(t,r),n()))return!0;return e<=0}function Nu(e){return{pid:process.pid,acquiredAtMs:e}}function Cu(e,t){let n=e instanceof Error?e.message:String(e);return E(`WARN: hook process slot failed open: ${n}`),Nu(t)}function mr(e){return pr.add(e),Ru||(Ru=!0,process.once("exit",()=>{for(let t of[...pr])gr(t)})),e}function Au(e){try{return Jo(e.path,nn(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(jt(t))return!1;throw t}}function vu(e,t=Yo(),n=Date.now){if(e<=0)return Nu(n());try{VS(t,{recursive:!0})}catch(s){return Cu(s,n())}let r,o=0;for(let s=0;s<e;s+=1)try{let i={path:wn(t,s),pid:process.pid,acquiredAtMs:n()};if(Au(i))return mr(i);if(Pu(i.path,n())){o+=1;continue}try{ku(i.path)}catch(a){if(!yt(a))throw a}if(i.acquiredAtMs=n(),Au(i))return mr(i);o+=1}catch(i){r??=i}return r===void 0||o>0?null:Cu(r,n())}function gr(e,t=Date.now()){if(pr.delete(e),!(!e.path||t-e.acquiredAtMs>=Pn-Bt))try{Vo(e.path,"utf8")===nn(e)&&ku(e.path)}catch{}}function Zo(e){M("EV_AI_HOOK_DEBUG")&&E(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}import{closeSync as JS,writeSync as YS}from"node:fs";function Mu(e=process.env){let t=e[Xr];if(delete e[Xr],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{YS(n,xi)}catch{}try{JS(n)}catch{}}}function Qo(e=process.env){let t=e[Ei];if(t)return{launcherVersion:t,hookSource:e[yi]??"",fallbackReason:e[Ri],launcherScope:e[Ci]}}function Lu(e,t){return(e?Vt(e):void 0)===t}import{realpathSync as ux}from"node:fs";import{homedir as lx}from"node:os";var B=Ve(rt(),1);import{existsSync as XS,readFileSync as qS}from"node:fs";import{homedir as Hu}from"node:os";import{join as ZS}from"node:path";var QS="cloud-cache.json",eE=1440*60*1e3,tE=900*1e3;function nE(e=Hu()){return ZS(Re(e),QS)}function rE(e){if(!XS(e))return;let t=ge(qS(e,"utf8"),{});if(!(typeof t.context!="string"||typeof t.probed_at!="number"||t.result!==null&&t.result!==void 0&&typeof t.result!="object"))return{context:t.context,probed_at:t.probed_at,result:t.result??null}}function oE(e,t){try{me(e,`${JSON.stringify(t)}
31
- `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: cloud cache write failed open: ${r}`)}}function sE(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?tE:eE;return n-e.probed_at<r}async function iE(e){let t=await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"60"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=(await t.text()).trim();if(!n)return;let r={"X-aws-ec2-metadata-token":n},[o,s]=await Promise.all([fetch("http://169.254.169.254/latest/meta-data/placement/region",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{}),fetch("http://169.254.169.254/latest/meta-data/instance-id",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{})]);if(!o?.ok&&!s?.ok)return;let i=o?.ok?(await o.text()).trim():"",a=s?.ok?(await s.text()).trim():"";if(!(!i&&!a))return{provider:"aws",region:i,instance_id:a}}async function aE(e){let t=await fetch("http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true",{headers:{"Metadata-Flavor":"Google"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=typeof n.zone=="string"?n.zone.split("/").pop()??"":"",o=n.id===void 0?"":String(n.id);if(!(!r&&!o))return{provider:"gcp",region:r,instance_id:o}}async function cE(e){let t=await fetch("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{headers:{Metadata:"true"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=n.compute?.location??"",o=n.compute?.vmId??"";if(!(!r&&!o))return{provider:"azure",region:r,instance_id:o}}async function uE(e){let t=await Promise.allSettled([iE(e),aE(e),cE(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}async function Uu(e,t){if(e==="interactive")return null;let n=t?.home??Hu(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),s=nE(n),i=rE(s);if(sE(i,e,o))return i.result;let a=await uE(r);return oE(s,{context:e,probed_at:o,result:a}),a}var ju=Ve(rt(),1);import{existsSync as Fu}from"node:fs";import{homedir as $u}from"node:os";import{join as rn,resolve as es,sep as Du}from"node:path";function _r(e,t,n){if(!Fu(e))return;let r=ne(e,{});for(let[o,s]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:s})}function lE(e,t,n){if(!Fu(e))return;let r=ne(e,{}),o=es(t),s=null;for(let a of Object.keys(r.projects??{})){let c=es(a);(o===c||o.startsWith(c.endsWith(Du)?c:c+Du))&&(s===null||c.length>es(s).length)&&(s=a)}if(s===null)return;let i=r.projects?.[s]?.mcpServers??{};for(let[a,c]of Object.entries(i))n.set(a,{declared:{name:a,source:"claude_json_project",sourcePath:".claude.json",scope:"user"},config:c})}function Bu(e,t,n,r){let o=new Map;for(let s of e.mcp_servers??[])s.name&&o.set(s.name,{declared:{name:s.name,source:"manifest"}});return n==="claude"?(_r(rn(r,".claude.json"),{source:"claude_json_user"},o),lE(rn(r,".claude.json"),t,o)):n==="cursor"&&_r(rn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),_r(rn(t,".mcp.json"),{source:"mcp_json"},o),_r(rn(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}async function ts(e,t=process.cwd(),n="claude",r=$u()){return[...Bu(e,t,n,r).values()].map(o=>o.declared)}function Ku(e,t,n=process.cwd(),r="claude",o=$u()){let s=Bu(t,n,r,o),i=s.get(e);if(i!==void 0)return i.config??null;for(let[a,c]of s)if((0,ju.mcpServerNameMatchesToolSegment)(a,e))return c.config??null;return null}var fE=["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"],dE=["CURSOR_PROJECT_DIR"],pE=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function mE(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)pE.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}function Gu(e=process.env){let t=fE.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:mE(e[r]??"")}:{name:r,present:!1}),n=dE.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}import{homedir as GE}from"node:os";import{homedir as Wu}from"node:os";import{join as gE}from"node:path";function _E(e=Wu()){return gE(e,".claude.json")}function hr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function zu(e=Wu()){let n=ne(_E(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=hr(n.emailAddress),o=hr(n.fullName)??hr(n.displayName),s=hr(n.accountUuid),i=r??s;return!i||de(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:i,identity_source:"claude_oauth"}}import{homedir as Yu}from"node:os";import{join as Vu}from"node:path";var hE="https://api.openai.com/auth";function Pt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Xu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function SE(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 Xu(r)}catch{return null}}function Ju(e,t,n){return Pt(e[n])??Pt(t?.[n])}function EE(e=process.env,t=Yu()){let n=Pt(e.CODEX_HOME)??Vu(t,".codex");return Vu(n,"auth.json")}function qu(e=process.env,t=Yu()){let n=ne(EE(e,t),{}),r=Pt(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&Pt(n.OPENAI_API_KEY))return null;let o=Pt(n.tokens?.id_token);if(!o)return null;let s=SE(o);if(!s)return null;let i=Xu(s[hE]),a=Ju(s,i,"name"),c=Ju(s,i,"email");return!c||de(a,c)?null:{git_user_name:null,git_user_email:null,platform_login:c,identity_source:"codex_oauth"}}import{homedir as yr}from"node:os";import{join as Be}from"node:path";import{join as yE}from"node:path";var RE="cursor-ide-identity.json",CE=840*60*1e3;function Qu(e){return yE(Re(e),RE)}function Zu(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function el(e){let t=ne(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:Zu(t.email),auth_id:Zu(t.auth_id)}}function tl(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<CE}function nl(e,t){try{me(e,`${JSON.stringify(t)}
32
- `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: cursor IDE identity cache write failed open: ${r}`)}}import{execFileSync as AE}from"node:child_process";import{existsSync as xE}from"node:fs";import{createRequire as kE}from"node:module";import{pathToFileURL as bE}from"node:url";var ol=kE(import.meta.url),Sr=`
28
+ npx ${rr} install`)}function $c(e){return typeof e!="string"?!1:e.includes("@ev-ai/agent-hook")||e.includes("agent-hook/dist/hook")||e.includes(".ev-ai/agent-hook")||e.includes(Ee)||/(?:^|[\s/"'])ev-ai-agent-hook(?:$|[\s"'])/.test(e)}function Go(e,t){return`${e.replace(/\s+--runner(?:=|\s+)\S+/g,"").trimEnd()} --runner ${t}`}function ot(e,t){Bo(Ko(e),{recursive:!0}),U_(e,`${JSON.stringify(t,null,2)}
29
+ `,"utf8")}function Ge(e){if(rt(e))try{return JSON.parse(L_(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}function oh(e,t){let n=kc(t.collectorUrl),r={...e,schema_version:e?.schema_version??n.schema_version};return t.collectorUrl!==void 0?r.collector_url=t.collectorUrl:r.collector_url=e?.collector_url??n.collector_url,delete r.repo_ingest_token,delete r.installation_id,r.mcp_servers??=n.mcp_servers,r}function sh(e){return(e.schema_version??nt)===nt&&e.collector_url===void 0&&(e.mcp_servers?.length??0)===0&&e.platform_agent_id===void 0&&e.capture_hook_input===void 0&&e.debug===void 0&&e.repo_ingest_token===void 0}function jc(e,t){let n=V(e,Yn),r=Ge(n),o=oh(r,t);return t.collectorUrl!==void 0||rt(n)||!sh(o)?(ot(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}function jo(e){if(e===null||typeof e!="object")return!1;let t=e,n=String(t.CLAUDE_CODE_ENABLE_TELEMETRY??"").toLowerCase();return n==="1"||n==="true"?!0:Object.keys(t).some(r=>r.startsWith("OTEL_"))}function ih(e){if(jo(process.env))return!0;let t=Ke();return[...Io(),V(t,".claude","settings.json"),V(t,".claude","remote-settings.json"),V(e,".claude","settings.json"),V(e,".claude","settings.local.json")].some(r=>{try{let o=Ge(r);return o?jo(o.env):!1}catch{return!1}})}function ah(e){try{let t=Ge(V(e,".claude","settings.json"));return t?jo(t.env):!1}catch{return!1}}function Bc(e){return Array.isArray(e)?e:[]}function gr(e){let t=[],n=r=>!!r&&typeof r=="object"&&$c(r.command);for(let r of Bc(e)){if(!r||typeof r!="object"){t.push(r);continue}let o=Array.isArray(r.hooks)?r.hooks:[],s=o.filter(i=>!n(i));if(!(s.length===0&&o.some(n))){if(s.length!==o.length){t.push({...r,hooks:s});continue}t.push(r)}}return t}function Kc(e,t){return[...gr(e),...t]}function Vo(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!$c(t.command)):[]}function ch(e,t){return[...Vo(e),{command:t}]}function uh(e){return typeof e=="string"?[e]:e}function lh(e){let t=(n="")=>({hooks:uh(e).map(r=>({type:"command",command:dr(n,r)}))});return{SessionStart:[t("SessionStart")],UserPromptExpansion:[t()],UserPromptSubmit:[t()],PreToolUse:[t()],PostToolUse:[t()],PostToolUseFailure:[t()],PermissionDenied:[t()],Stop:[t()],StopFailure:[t()],SessionEnd:[t()],SubagentStart:[t()],SubagentStop:[t()]}}function fh(e){let t=typeof e=="string"?{command:e}:e,n=(r="")=>({hooks:[{type:"command",command:dr(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:dr(r,t.commandWindows)},statusMessage:Ha}]});return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}var dh=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],ph=["afterShellExecution","afterFileEdit"];function mh(e,t=ph){let n={...e};for(let r of t){if(!(r in n))continue;let o=Vo(n[r]);o.length===0?delete n[r]:n[r]=o}return n}function gh(e,t,n={}){let r=V(e,".claude/settings.json"),o=Go(t,"claude"),s=Ge(r)??{};if(ih(e)&&!n.force){if(s.hooks&&typeof s.hooks=="object"){let u={...s.hooks};for(let d of Object.keys(u))u[d]=gr(u[d]),Bc(u[d]).length===0&&delete u[d];Object.keys(u).length===0?delete s.hooks:s.hooks=u,ot(r,s)}return!1}let a=s.hooks&&typeof s.hooks=="object"?s.hooks:{},c=lh(o),l={...a};for(let[u,d]of Object.entries(c))l[u]=Kc(a[u],d);return s.hooks=l,ot(r,s),!0}function _h(e,t){let n=V(e,".cursor/hooks.json"),r=Go(t,"cursor"),o=Ge(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=mh({...s});for(let a of dh)i[a]=ch(i[a],dr(a,r));ot(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:i})}function hh(e,t){let n=V(e,".codex/hooks.json"),r=Go(t,"codex"),o=Ge(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=fh(r),a={...s};for(let[c,l]of Object.entries(i))a[c]=Kc(s[c],l);ot(n,{...o,hooks:a})}function Sh(e){let t=V(e,".claude/settings.json"),n=Ge(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1;for(let s of Object.keys(r)){let i=r[s],a=gr(i);JSON.stringify(i)!==JSON.stringify(a)&&(o=!0),a.length===0?delete r[s]:r[s]=a}o&&(Object.keys(r).length===0?delete n.hooks:n.hooks=r,ot(t,n),E(`Removed ev-ai hooks from ${t}`))}function Eh(e){let t=V(e,".cursor/hooks.json"),n=Ge(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=Vo(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks"&&a!=="version").length===0){pr(t,{force:!0}),E(`Removed ${t}`);return}ot(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function yh(e){let t=V(e,".codex/hooks.json"),n=Ge(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=gr(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks").length===0){pr(t,{force:!0}),E(`Removed ${t}`);return}ot(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function Wo(e=process.platform,t=process.arch,n={}){if(e==="win32")throw new Error("Windows install is not supported yet. Use macOS/Linux, or wait for phase-2 native commands.");(n.requireBinaryArch??!0)&&xc(e,t)}async function Gc(e={}){let t=K_(e);e.collectorUrl=t;let n=e.skipClaude===!0,r=e.skipCursor===!0,o=e.skipCodex===!0;if(n&&r&&o)throw new Error("at least one runner must be wired; refuse --no-claude --no-cursor --no-codex together");let s=e.delivery??Mc();Wo(process.platform,process.arch,{requireBinaryArch:s==="binary"});let i=e.cwd??process.cwd(),a=await Fe(i),{command:c,hookPath:l,strategy:u}=rh(a,Ke(),s),{installationId:d,storePath:f}=await ur(a,{overrideId:e.installationId}),{manifestPath:p,wrote:g}=jc(a,e),S=[];return n?E("Skipped Claude hook \u2014 --no-claude"):gh(a,c,{force:e.force})?(S.push("Claude"),e.force&&ah(a)&&E("Forced Claude hook despite project native OTEL \u2014 expect duplicate session/tool events")):E("Skipped Claude hook \u2014 native OTEL telemetry already enabled (avoids duplicate events); pass --force to wire anyway"),r?E("Skipped Cursor hook \u2014 --no-cursor"):(_h(a,c),S.push("Cursor")),o?E("Skipped Codex hook \u2014 --no-codex"):(hh(a,c),S.push("Codex")),E(`Installed hook (${u}) at ${l}`),E(`Installation identity ${d} at ${f}`),g&&p?E(`Shared manifest written to ${p}`):E("Using package default collector config (no shared manifest file needed)"),E(S.length>0?`Wired ${S.join(", ")} hooks in ${a} (commands include --runner)`:`No runner hooks wired in ${a} (Claude skipped by OTEL; Cursor/Codex excluded via flags)`),u==="npx"?E("Hook commands use npx and may be committed; teammates need Node on PATH only (no install step, no env vars when collector_url is in the shared manifest)."):u==="project_binary"?E("Hook commands are git-root-relative and may be committed; each collaborator runs install once to populate .ev-ai/agent-hook/ (gitignored)."):u==="dev_mjs"&&E("Hook commands use node + monorepo packages/agent-hook/dist/hook.mjs (local delivery; rebuild with yarn workspace @ev-ai/agent-hook build)."),g&&p&&e.collectorUrl&&E("Shared manifest includes collector_url \u2014 commit it with hook configs so teammates post without env vars."),{gitRoot:a,hookPath:l,manifestPath:p,installationStorePath:f,strategy:u}}async function Vc(e=process.cwd()){Wo(process.platform,process.arch,{requireBinaryArch:!0});let t=await Fe(e),{projectPath:n,globalPath:r}=Q_(t);E(`Refreshed ${r}`),E(`Refreshed ${n}`),E("Hook configs and shared manifest left unchanged")}async function Wc(e={}){let t=B_(e);e.collectorUrl=t,Wo(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await Fe(n),{manifestPath:o,wrote:s}=jc(r,e);if(t!==void 0&&(!o||!s))throw new Error("configure failed to write shared collector manifest");return s&&o?E(`Wrote ${o}`):t===void 0&&E("No --url given and no shared manifest yet \u2014 pass --url <\u2026/{orgToken}/hook> to write collector destination."),E("Manifest only \u2014 enable ev-ai marketplace plugins. Do not also run file-wiring install for the same events."),{gitRoot:r,manifestPath:o}}function zc(e){for(let t of[()=>Sh(e),()=>Eh(e),()=>yh(e)])try{t()}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: strip skipped a hook file: ${r}`)}}async function Jc(e=process.cwd()){let t=await Fe(e);return zc(t),E("Stripped ev-ai file-wired hooks; shared collector manifest left in place."),E("Next: enable ev-ai marketplace plugins, then restart runners."),{gitRoot:t}}async function Yc(e=process.cwd()){let t=await Fe(e);zc(t);for(let n of Xn){let r=V(t,n);if(rt(r))try{pr(r,{force:!0}),E(`Removed ${r}`)}catch(o){let s=o instanceof Error?o.message:String(o);E(`WARN: uninstall could not remove ${r}: ${s}`)}}}import{existsSync as YE,mkdirSync as XE,readdirSync as qE,readFileSync as ZE,unlinkSync as Zu,writeFileSync as QE}from"node:fs";import{homedir as Qu}from"node:os";import{join as as}from"node:path";import{existsSync as wh}from"node:fs";import{existsSync as Rh}from"node:fs";import{homedir as qc}from"node:os";import{join as Ch}from"node:path";function Zc(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}var Ah={claude:{shared:{skillRoots:[".claude/skills"],dirs:[{dir:".claude/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".claude/commands",kind:"COMMAND",extensions:[".md"]},{dir:".claude/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["CLAUDE.md"],["CLAUDE.local.md"],[".claude/CLAUDE.md"]],settings:[".claude/settings.json",".claude/settings.local.json",".claude/hooks.json"]},homeOnly:{mcpJson:[".claude.json"],plugins:"claude",managed:"claude"},projectOnly:{mcpJson:[".mcp.json","mcp.json"]}},cursor:{shared:{skillRoots:[".cursor/skills"],dirs:[{dir:".cursor/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".cursor/commands",kind:"COMMAND",extensions:[".md"]},{dir:".cursor/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["AGENTS.md"]],settings:[".cursor/hooks.json",".cursor/sandbox.json",".cursor/permissions.json"],mcpJson:[".cursor/mcp.json"]},homeOnly:{skillRoots:[".cursor/skills-cursor"],memory:[[".cursor/AGENTS.md"]],settings:[".cursor/cli-config.json"],plugins:"cursor",managed:"cursor"},projectOnly:{skillRoots:[".agents/skills"],settings:[".cursor/cli.json"]}},codex:{shared:{skillRoots:[".agents/skills",".codex/skills"],dirs:[{dir:".codex/agents",kind:"SUBAGENT",extensions:[".toml",".md"]},{dir:".codex/prompts",kind:"COMMAND",extensions:[".md"]},{dir:".codex/rules",kind:"RULE",extensions:[".md",".rules"]}],memory:[["AGENTS.override.md","AGENTS.md"]],settings:[".codex/hooks.json",".codex/config.toml"],mcpToml:[".codex/config.toml"]},homeOnly:{memory:[[".codex/AGENTS.override.md",".codex/AGENTS.md"]],managed:"codex"}}};function Xc(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}function bh(e,t={}){let{shared:n}=e;return{skillRoots:[...n.skillRoots,...t.skillRoots??[]],dirs:n.dirs,memory:[...n.memory,...t.memory??[]],settings:[...n.settings,...t.settings??[]],mcpJson:Xc(n.mcpJson,t.mcpJson),mcpToml:Xc(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}function Qc(e){return Object.fromEntries(Object.entries(Ah).map(([t,n])=>[t,bh(n,n[e])]))}var vt=Qc("homeOnly"),it=Qc("projectOnly");function kh(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}function xh(e,t){return kh(e).some(n=>Rh(Ch(t,n)))}function eu(e,t){for(let n of e)if(xh(n,t))return!0;return!1}function st(e){return[...new Set(e)]}function at(e){let t=[],n=[],r=[],o=[],s=[],i=[],a=[];for(let c of e){t.push(...c.skillRoots);for(let l of c.dirs)l.kind==="SUBAGENT"?n.push(l.dir):l.kind==="COMMAND"?r.push(l.dir):o.push(l.dir);s.push(...c.memory.flat()),i.push(...c.settings),a.push(...c.mcpJson??[],...c.mcpToml??[])}return{skills:st(t),subagents:st(n),commands:st(r),rules:st(o),memory:st(s),settings:st(i),mcp:st(a)}}function Oh(e,t=qc(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...sr(o.managed,n,t));return st(r)}var ct=at(Object.values(vt));function tu(e=qc(),t=process.platform){return Oh(Object.values(vt),e,t)}import{existsSync as Ih}from"node:fs";import{resolve as zo}from"node:path";function ye(e){return zo(e).replaceAll("\\","/").replace(/\/$/,"")}function _t(e,t){let n=new Set(t),r=[];for(let o of e)n.delete(o)&&r.push(o);for(let o of[...n].sort())r.push(o);return r}function _r(e,t){if(!e)return t;let n=`${e}/`,r=[],o=[];for(let s of t)s===e||s.startsWith(n)?r.push(s):o.push(s);return r.length===0?t:[...r,...o]}var Th=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function on(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!Th.test(t)?null:t}function Mt(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let s=ye(o);n.has(s)||(n.add(s),r.push(s))}return r}function Ph(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}function Pe(e,t,n,r=Ih){for(let o of e)for(let s of t){let i=ye(zo(o,s)),a=zo(o,s,n).replaceAll("\\","/");if(Ph(i,a)&&r(a))return a}return null}var ru=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,ou=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,Nh=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,nu=new Set(["applications","app","bin","boot","data","dev","etc","home","lib","media","mnt","node_modules","opt","pkg","private","proc","projects","repos","run","sbin","src","srv","sys","tmp","usr","users","var","volumes","workspace","workspaces"]),vh=/^[a-z][a-z0-9-]{1,63}$/,Mh=[".cursor/skills",".claude/skills",".agents/skills"],Lh=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],Hh=_t(Mh,at(Object.values(it)).skills),Uh=_t(Lh,at(Object.values(vt)).skills),Dh=new Set(["read","read_file","view"]),Fh=new Set(["bash","shell","zsh"]);function Jo(e){let t=e.replace(/\\/g,"/");return ru.exec(t)?.[1]??null}function $h(e){let t=e.replace(/\\/g,"/"),r=ou.exec(t)?.[1];return r?r.toLowerCase():null}function jh(e){return Jo(e)??$h(e)}function Bh(e){for(let t of["path","file_path","target_file"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}return null}function hr(e){return typeof e=="string"?hr(Se(e,null)):!e||typeof e!="object"?null:Bh(e)}function su(e){if(typeof e=="string")return su(Se(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}function Yo(e){let t=su(e.tool_input);if(t)return t;let n=pt(e.command);return n.length>0?n:null}function Kh(e){let t=e.replace(/\\/g,"/"),n=ru.exec(t);if(n?.[1])return n[1];let o=ou.exec(t)?.[1];return o?o.toLowerCase():null}function Gh(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function Xo(e){let t=hr(e.tool_input)??pt(e.file_path);return t.length>0?t:null}function sn(e,t,n){let r=Gh(e).toLowerCase();if(Dh.has(r)){let o=Xo(e);return o?t(o):null}if(Fh.has(r)){let o=Yo(e);return o?n(o):null}return null}function iu(e){return sn(e,jh,Kh)}function Vh(e){let t=new Set,n=[];for(let r of e.matchAll(Nh)){let o=r[1]?.toLowerCase();!o||t.has(o)||Wh(o)||(t.add(o),n.push(o))}return n}function Wh(e){let t=e.split("/")[0];return nu.has(e)||t!==void 0&&nu.has(t)}function au(e){let t=e.skillId.toLowerCase();if(!vh.test(t))return null;let n=e.exists??wh,r=`${t}/SKILL.md`,o=Pe(Mt(e.launchCwd,e.gitRoot),Hh,r,n);return o!==null?o:e.home?Pe([ye(e.home)],Uh,r,n):null}function zh(e){return pt(e.prompt)}function cu(e){let t=L(e,"command_name");if(t){let r=L(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=zh(e);return n?Vh(n):[]}var ns=Qe(lt(),1);import{existsSync as yE}from"node:fs";var St={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function cn(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function EE(e){if(!e)return"";let t=Xt(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return cn(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return cn(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?cn(o[1]):cn(t)}async function br(e=process.cwd()){let t=await Ae("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,s]=await Promise.all([Ae("git",["remote","get-url","origin"],2e3,{cwd:e}),Ae("git",["branch","--show-current"],2e3,{cwd:e}),Ae("git",["rev-parse","HEAD"],2e3,{cwd:e}),Ae("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Xt(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:s.ok?s.stdout.length>0:null}}async function vu(e,t,n,r=process.cwd(),o,s,i){if(t)return t;let a=St[n];if(!a)return"";let c=rc(n,e.scope_path,i);if(s){let g=fc(s,c);if(g)return g}let l=o??await br(r),u=l?.remote?EE(l.remote):"";if(u||(u=cn(process.env.GITHUB_REPOSITORY??"")),!u)return"";let d=e.scope_path??"",f=d?`${d}/`:"",p=`${u}:${f}${a}`;return s&&dc(s,c,p),p}var RE=[".cursor/rules",".claude/rules",".codex/rules"],CE=at(Object.values(it)).rules;function AE(e){return _t(_r(e?St[e]:void 0,RE),CE)}var bE=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function Mu(e){let t=on(e.relativePath);if(!t)return null;let n=e.exists??yE,r=Mt(e.launchCwd,e.gitRoot),o=AE(e.runnerPlatform),s=Pe(r,o,t,n);if(s!==null)return s;if(!t.includes("/")){let i=Pe(r,["."],t,n);if(i!==null)return i}return e.home?Pe([ye(e.home)],o,t,n):null}function kE(e){let t=e.replace(/\\/g,"/"),r=bE.exec(t)?.[1];return r?(0,ns.nativeKeyForRulePath)(r):null}function Lu(e){return sn(e,ns.nativeKeyForRulePath,kE)}function Hu(e){return e.replace(/\.(mdc|md|rules)$/i,"")}function Uu(e){let t=e.attachments;if(!Array.isArray(t))return[];let n=new Set,r=[];for(let o of t){if(!o||typeof o!="object"||Array.isArray(o))continue;let s=o;if(s.type!=="rule")continue;let i=typeof s.file_path=="string"?s.file_path:"",a=on(i);!a||n.has(a)||(n.add(a),r.push(a))}return r}var rs=Qe(lt(),1);import{existsSync as xE}from"node:fs";var OE=[".cursor/commands",".claude/commands",".codex/prompts"],IE=at(Object.values(it)).commands;function TE(e){return _t(_r(e?St[e]:void 0,OE),IE)}var PE=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function Du(e){let t=on(e.commandId);if(!t)return null;let n=e.exists??xE,r=`${t}.md`,o=TE(e.runnerPlatform),s=Pe(Mt(e.launchCwd,e.gitRoot),o,r,n);return s!==null?s:e.home?Pe([ye(e.home)],o,r,n):null}function wE(e){let t=e.replace(/\\/g,"/"),r=PE.exec(t)?.[1];return r?(0,rs.nativeKeyForCommandPath)(r):null}function Fu(e){return sn(e,rs.nativeKeyForCommandPath,wE)}var kr=Qe(lt(),1);function $u(e,t){if(L(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function NE(){return!!(M("CURSOR_VERSION")??M("CURSOR_PROJECT_DIR"))}function ju(e,t,n){return e!=="claude"&&e!=="codex"?!1:$u(t,n)?!0:NE()}var vE=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function un(e,t,n,r){return $u(e,t)?"cursor":qn(r)?r:qn(n)?n:L(e,"turn_id")?"codex":L(e,"session_id")||vE.has(t.toLowerCase())?"claude":"unknown"}function xr(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function ME(e){switch(e){case"sessionstart":return"session_start";case"stop":case"sessionend":case"stopfailure":return"session_end";case"pretooluse":case"posttooluse":case"posttoolusefailure":case"permissiondenied":case"beforemcpexecution":case"beforeshellexecution":case"aftershellexecution":case"beforereadfile":case"afterfileedit":case"subagentstart":case"subagentstop":return"tool_invoked";case"beforesubmitprompt":case"userpromptexpansion":case"userpromptsubmit":return"skill_invoked";default:return""}}function Bu(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}function Ku(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}function Gu(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function ln(e){return L(e,"session_id")||L(e,"conversation_id")}function os(e){return L(e,"prompt.id")||L(e,"prompt_id")||L(e,"generation_id")||L(e,"turn_id")}function ss(e){return L(e,"hook_event_name")||L(e,"event")}function Vu(e,t,n){let r=ln(e),o=os(e),s=ss(e),i=L(e,"source"),a=un(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:i,runnerPlatform:a}}var LE=["session_start","session_end","tool_invoked","skill_invoked"];function HE(e){return LE.includes(e)}function is(e,t){return e&&HE(e)?e:ME(t.toLowerCase())}var UE={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function Or(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function Wu(e,t=""){let n=L(e,"tool_name")||L(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!Or(n)&&(n=`MCP:${n}`):n=UE[r]??null;let o=e.tool_input,i=(o&&typeof o=="object"?pt(o.skill)||pt(o.skill_name):"")||L(e,"skill_name")||null,a=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;i??=iu(a);let c=Lu(a),l=Fu(a);return{toolName:n,skillName:i,ruleName:c,commandName:l}}var DE=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function zu(e){for(let t of["subagent_type","agent_type"]){let n=L(e,t);if(n&&DE.test(n))return n}return null}function Ju(e){let t=$e(e,"duration_ms");if(typeof t=="number")return t;let n=$e(e,"duration");return typeof n=="number"?n:null}var FE="error",$E="interrupted",jE="permission_denied",BE=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function fn(e){return BE.test(e)?e:null}function KE(e){for(let t of["failure_type","error_type"]){let n=fn(L(e,t));if(n)return n}return null}function Yu(e,t){return $e(e,"is_interrupt")===!0?$E:t.toLowerCase()==="permissiondenied"?jE:KE(e)??FE}function Xu(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}function GE(e,t){return Xu(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}function VE(e,t){return Xu(t,n=>(0,kr.mcpServerNameMatchesToolSegment)(n,e))}function WE(e,t){let n=null,r=0;for(let s of t)if(s)for(let i of(0,kr.mcpServerToolSegmentForms)(s)){let a=`${i}__`;e.length>a.length&&e.slice(0,a.length).toLowerCase()===a.toLowerCase()&&i.length>r&&(n={mcpServer:s,mcpTool:e.slice(a.length)},r=i.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:VE(o[1],t)??o[1],mcpTool:o[2]}}function zE(e,t){if(/^mcp__/i.test(e))return WE(e.slice(5),t);if(/^MCP:/i.test(e)){let n=e.slice(4);if(!n)return{mcpServer:null,mcpTool:null};let r=n.indexOf(":");if(r>0)return{mcpServer:n.slice(0,r),mcpTool:n.slice(r+1)||null};let o=n.indexOf("__");return o>0?{mcpServer:n.slice(0,o),mcpTool:n.slice(o+2)||null}:{mcpServer:GE(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}function JE(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}function qu(e,t=[],n=""){let r=e?zE(e,t):{mcpServer:null,mcpTool:null},o=fn(n.trim());if(!o)return r;let s=r.mcpTool;return!s&&e&&!Or(e)&&(s=e),s&&(s=JE(s,o)),{mcpServer:o,mcpTool:s}}var el=3e4,ey="claims",ty=!0,ny=100,ry=new Set(["sessionstart","sessionend","stopfailure"]),oy=["tool_name","tool","command","file_path","url"];function sy(e=Qu()){return as(ge(e),ey)}function tl(e,t){try{let n=ZE(e,"utf8").split(`
30
+ `,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}function iy(e){let t=[];for(let n of oy){let r=L(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":qt(t.join("\0"))}function ay(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),s=e.subagentId?.trim()??"",i=e.callFingerprint?.trim()??"",a=!!(o||r||s),c=ry.has(n);if(!a&&!c)return;let l=e.runnerPlatform.trim()||"unknown";return qt(`${l}|${t}|${n}|${r}|${o}|${i}|${s}`)}function cy(e,t=Date.now()){let n;try{n=qE(e)}catch{return}let r=0;for(let o of n){if(r>=ny)break;r+=1;let s=as(e,o),i=tl(s,t);if(!(!Number.isFinite(i)||i<el))try{Zu(s)}catch{}}}function uy(e,t,n=Date.now()){let r=as(t,e);try{if(YE(r)){let o=tl(r,n);if(Number.isFinite(o)&&o>=0&&o<el)return!1;try{Zu(r)}catch{}}}catch{}try{XE(t,{recursive:!0}),QE(r,`${n}
31
+ `,{encoding:"utf8",flag:"wx"})}catch(o){if(Jt(o))return!1;let s=o instanceof Error?o.message:String(o);return E(`WARN: event claim failed open: ${s}`),!0}return cy(t,n),!0}function ly(e,t,n){let r=ln(e),o=os(e),s=L(e,"tool_use_id"),i=L(e,"subagent_id")||L(e,"agent_id"),a=un(e,t,void 0,n),c=iy(e);return{runnerPlatform:a,sessionId:r,runnerEvent:t,turnId:o,toolUseId:s,subagentId:i,callFingerprint:c}}function nl(e,t,n,r=Qu(),o=Date.now()){if(!ty)return!0;let s=ay(ly(e,t,n));if(!s)return!0;let i=uy(s,sy(r),o);return!i&&M("EV_AI_HOOK_DEBUG")&&E(`DEBUG: duplicate hook event suppressed (claim ${s.slice(0,8)}\u2026)`),i}import{mkdirSync as fy,readFileSync as cs,statSync as il,unlinkSync as al,writeFileSync as us}from"node:fs";import{homedir as cl}from"node:os";function ul(e){return e==="session_start"||e==="session_end"}var Ir=new Set,rl=!1;function ls(e=cl()){return ta(e)}function fs(e,t=cl(),n=process.platform){if(e!==void 0)return e>0?e:jn(n);let r=q(mt(t),{});return ba(r)??jn(n)}function dn(e){return Gn(e.pid,e.acquiredAtMs)}function ll(e){try{let t=il(e);return t.isFile()&&t.size<=_o?cs(e,"utf8"):void 0}catch{return}}function ds(e,t=ls()){if(!e)return;let n=Kn(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=ll(n);if(o===dn(r))return Tr(r);if(o===Gn(process.ppid,e.acquiredAtMs))try{return us(n,dn(r),{encoding:"utf8",mode:384}),Tr(r)}catch{return}}function fl(e,t){if(e.path){Ir.delete(e);try{ll(e.path)===dn(e)&&us(e.path,Gn(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}function dl(e,t=Date.now()){let n,r;try{let o=il(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=_o?cs(e,"utf8"):""}catch{return!1}return ra(n,r,t)}function pl(e,t=ls(),n=Date.now){for(let r=0;r<e;r+=1)if(!dl(Kn(t,r),n()))return!0;return e<=0}function ml(e){return{pid:process.pid,acquiredAtMs:e}}function ol(e,t){let n=e instanceof Error?e.message:String(e);return E(`WARN: hook process slot failed open: ${n}`),ml(t)}function Tr(e){return Ir.add(e),rl||(rl=!0,process.once("exit",()=>{for(let t of[...Ir])Pr(t)})),e}function sl(e){try{return us(e.path,dn(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(Jt(t))return!1;throw t}}function gl(e,t=ls(),n=Date.now){if(e<=0)return ml(n());try{fy(t,{recursive:!0})}catch(s){return ol(s,n())}let r,o=0;for(let s=0;s<e;s+=1)try{let i={path:Kn(t,s),pid:process.pid,acquiredAtMs:n()};if(sl(i))return Tr(i);if(dl(i.path,n())){o+=1;continue}try{al(i.path)}catch(a){if(!Ot(a))throw a}if(i.acquiredAtMs=n(),sl(i))return Tr(i);o+=1}catch(i){r??=i}return r===void 0||o>0?null:ol(r,n())}function Pr(e,t=Date.now()){if(Ir.delete(e),!(!e.path||t-e.acquiredAtMs>=Bn-Yt))try{cs(e.path,"utf8")===dn(e)&&al(e.path)}catch{}}function ps(e){M("EV_AI_HOOK_DEBUG")&&E(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}import{closeSync as dy,writeSync as py}from"node:fs";function _l(e=process.env){let t=e[mo];if(delete e[mo],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{py(n,Vi)}catch{}try{dy(n)}catch{}}}function ms(e=process.env){let t=e[$i];if(t)return{launcherVersion:t,hookSource:e[ji]??"",fallbackReason:e[Bi],launcherScope:e[Ki]}}function hl(e,t){return(e?en(e):void 0)===t}import{readFileSync as hy,statSync as Sy}from"node:fs";import{homedir as Ey}from"node:os";import{join as yy}from"node:path";var yl="EV_AI_PERF_L",gs="EV_AI_PERF_H",my="EV_AI_HOOK_PERF";var gy=/^[a-z][a-z0-9_]{0,23}$/;var wr={origin:0,marks:{},values:{}},Nr=!1;function Rl(e=process.env){Nr=e[my]!=="0",wr.origin=performance.timeOrigin}function pn(){return Nr}function ze(e,t=performance.now()){Nr&&(wr.marks[e]=t)}function Cl(){return wr}function Al(e){return Math.round(e*10)/10}function Sl(e){return Object.entries(e).map(([t,n])=>`${t}=${Al(n)}`).join(",")}function _y(e){return`${Al(e.origin)}|${Sl(e.marks)}|${Sl(e.values)}`}function El(e,t){if(!e)return!0;for(let n of e.split(",")){let r=n.indexOf("="),o=n.slice(0,r),s=Number(n.slice(r+1));if(r<1||!gy.test(o)||!(s>=0&&s<=36e5))return!1;t[o]=s}return Object.keys(t).length<=32}function _s(e){if(!e||e.length>1024)return;let[t,n,r,...o]=e.split("|"),s=Number(t);if(o.length>0||!Number.isFinite(s)||s<=0)return;let i={origin:s,marks:{},values:{}};if(!(!El(n,i.marks)||!El(r,i.values)))return i}function bl(){return Nr?_y(wr):void 0}var Ry="perf-prev.json",Cy=512,Ay=1440*60*1e3,by=12e4,ky=50,mn={},kl=!1;function Ss(e){return Math.round(e*10)/10}function Ne(e,t){if(!pn())return t();let n=performance.now();return t().finally(()=>{mn[e]=Ss(performance.now()-n)})}function xy(){for(let e of Object.keys(mn))delete mn[e]}function Ol(){if(!pn())return;let e=bl();e&&(process.env[gs]=e)}function xl(e,t){if(!e)return;let n=t-e.origin;return n>=-ky&&n<=by?e:void 0}function Oy(e){if(e===null||typeof e!="object")return!1;let t=e;return typeof t.at=="number"&&Number.isFinite(t.at)&&typeof t.post_ms=="number"&&Number.isFinite(t.post_ms)&&t.post_ms>=0}function Il(e=Ey()){return yy(ge(e),Ry)}function Iy(e,t){if(!kl){kl=!0;try{let n=Il(t);if(Sy(n).size>Cy)return;let r=JSON.parse(hy(n,"utf8"));return!Oy(r)||e-r.at>Ay?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}function Es(e,t){if(!pn())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{ce(Il(t),JSON.stringify(n))}catch{}}function hs(e,t,n,r,o=n.marks){let s=Math.max(0,n.origin-r);e[t]=Ss(s);for(let[i,a]of Object.entries(o))e[i]=Ss(s+a)}function Tl(e,t=process.env,n,r=!1){let o=r?$a():void 0;if(!pn())return o?{sys:o}:void 0;let s=Cl(),i="w0"in s.marks?"w":"h",a=i==="w"?xl(_s(t[gs]),s.origin):void 0,c=xl(_s(t[yl]),(a??s).origin),l=c?"l":a?"h":i,u=(c??a??s).origin,d={};c&&hs(d,"l",c,u),a&&hs(d,"h",a,u),hs(d,i,s,u,{...s.marks,...e});let f={base:l,t:d};i==="w"&&a&&d.h3!==void 0&&(f.ack_ms=d.h3),c?.values.bootstrap===1&&(f.bootstrap=!0),Object.keys(mn).length>0&&(f.spans={...mn},xy());let p=Iy(Date.now(),n);return p&&(f.prev=p),o&&(f.sys=o),f}import{realpathSync as Vk}from"node:fs";import{homedir as Wk}from"node:os";var B=Qe(lt(),1);import{existsSync as Ty,readFileSync as Py}from"node:fs";import{homedir as Pl}from"node:os";import{join as wy}from"node:path";var Ny="cloud-cache.json",vy=1440*60*1e3,My=900*1e3;function Ly(e=Pl()){return wy(ge(e),Ny)}function Hy(e){if(!Ty(e))return;let t=Se(Py(e,"utf8"),{});if(!(typeof t.context!="string"||typeof t.probed_at!="number"||t.result!==null&&t.result!==void 0&&typeof t.result!="object"))return{context:t.context,probed_at:t.probed_at,result:t.result??null}}function Uy(e,t){try{ce(e,`${JSON.stringify(t)}
32
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: cloud cache write failed open: ${r}`)}}function Dy(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?My:vy;return n-e.probed_at<r}async function Fy(e){let t=await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"60"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=(await t.text()).trim();if(!n)return;let r={"X-aws-ec2-metadata-token":n},[o,s]=await Promise.all([fetch("http://169.254.169.254/latest/meta-data/placement/region",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{}),fetch("http://169.254.169.254/latest/meta-data/instance-id",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{})]);if(!o?.ok&&!s?.ok)return;let i=o?.ok?(await o.text()).trim():"",a=s?.ok?(await s.text()).trim():"";if(!(!i&&!a))return{provider:"aws",region:i,instance_id:a}}async function $y(e){let t=await fetch("http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true",{headers:{"Metadata-Flavor":"Google"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=typeof n.zone=="string"?n.zone.split("/").pop()??"":"",o=n.id===void 0?"":String(n.id);if(!(!r&&!o))return{provider:"gcp",region:r,instance_id:o}}async function jy(e){let t=await fetch("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{headers:{Metadata:"true"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=n.compute?.location??"",o=n.compute?.vmId??"";if(!(!r&&!o))return{provider:"azure",region:r,instance_id:o}}async function By(e){let t=await Promise.allSettled([Fy(e),$y(e),jy(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}async function wl(e,t){if(e==="interactive")return null;let n=t?.home??Pl(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),s=Ly(n),i=Hy(s);if(Dy(i,e,o))return i.result;let a=await By(r);return Uy(s,{context:e,probed_at:o,result:a}),a}var Ll=Qe(lt(),1);import{existsSync as vl}from"node:fs";import{homedir as Ml}from"node:os";import{join as gn,resolve as ys,sep as Nl}from"node:path";function vr(e,t,n){if(!vl(e))return;let r=q(e,{});for(let[o,s]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:s})}function Ky(e,t,n){if(!vl(e))return;let r=q(e,{}),o=ys(t),s=null;for(let a of Object.keys(r.projects??{})){let c=ys(a);(o===c||o.startsWith(c.endsWith(Nl)?c:c+Nl))&&(s===null||c.length>ys(s).length)&&(s=a)}if(s===null)return;let i=r.projects?.[s]?.mcpServers??{};for(let[a,c]of Object.entries(i))n.set(a,{declared:{name:a,source:"claude_json_project",sourcePath:".claude.json",scope:"user"},config:c})}function Hl(e,t,n,r){let o=new Map;for(let s of e.mcp_servers??[])s.name&&o.set(s.name,{declared:{name:s.name,source:"manifest"}});return n==="claude"?(vr(gn(r,".claude.json"),{source:"claude_json_user"},o),Ky(gn(r,".claude.json"),t,o)):n==="cursor"&&vr(gn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),vr(gn(t,".mcp.json"),{source:"mcp_json"},o),vr(gn(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}async function Rs(e,t=process.cwd(),n="claude",r=Ml()){return[...Hl(e,t,n,r).values()].map(o=>o.declared)}function Ul(e,t,n=process.cwd(),r="claude",o=Ml()){let s=Hl(t,n,r,o),i=s.get(e);if(i!==void 0)return i.config??null;for(let[a,c]of s)if((0,Ll.mcpServerNameMatchesToolSegment)(a,e))return c.config??null;return null}var Gy=["CI","GITHUB_ACTIONS","GITLAB_CI","CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER","KUBERNETES_SERVICE_HOST","REMOTE_CONTAINERS","DEVCONTAINER","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID","GITHUB_REF","GITHUB_SHA","GITHUB_RUN_ID","GITHUB_WORKFLOW","GITHUB_ACTOR","GITHUB_TRIGGERING_ACTOR","GITHUB_ACTOR_ID","GITHUB_USER","GITLAB_USER_LOGIN","GITLAB_USER_NAME","GITLAB_USER_EMAIL","BUILD_REQUESTEDFOR","BUILD_REQUESTEDFOREMAIL","BUILD_REQUESTEDFORID","BUILDKITE_BUILD_CREATOR","BUILDKITE_BUILD_CREATOR_EMAIL","BUILD_USER","BUILD_USER_ID","BUILD_USER_EMAIL","CHANGE_AUTHOR","CHANGE_AUTHOR_EMAIL","CIRCLE_USERNAME","CODEBUILD_INITIATOR","DRONE_COMMIT_AUTHOR","DRONE_COMMIT_AUTHOR_NAME","DRONE_COMMIT_AUTHOR_EMAIL","EV_AI_HOOK_OPERATOR_NAME","EV_AI_HOOK_OPERATOR_EMAIL","EV_AI_HOOK_OPERATOR_LOGIN","GIT_AUTHOR_NAME","GIT_AUTHOR_EMAIL","GIT_COMMITTER_NAME","GIT_COMMITTER_EMAIL","EMAIL","RUNNER_OS","RUNNER_ARCH","NODE_ENV","TERM_PROGRAM","CLAUDE_CODE_REMOTE","CLAUDE_CODE_REMOTE_SESSION_ID","CURSOR_AGENT","CURSOR_VERSION","CURSOR_CODE_REMOTE","CURSOR_USER_EMAIL","CODESPACES","CODESPACE_NAME","ANTHROPIC_BASE_URL","OPENAI_BASE_URL","OPENAI_API_BASE","AZURE_OPENAI_ENDPOINT","GOOGLE_GEMINI_BASE_URL","GEMINI_API_BASE","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX"],Vy=["CURSOR_PROJECT_DIR"],Wy=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function zy(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)Wy.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}function Dl(e=process.env){let t=Gy.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:zy(e[r]??"")}:{name:r,present:!1}),n=Vy.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}import{homedir as AR}from"node:os";import{homedir as Fl}from"node:os";import{join as Jy}from"node:path";function Yy(e=Fl()){return Jy(e,".claude.json")}function Mr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function $l(e=Fl()){let n=q(Yy(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=Mr(n.emailAddress),o=Mr(n.fullName)??Mr(n.displayName),s=Mr(n.accountUuid),i=r??s;return!i||me(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:i,identity_source:"claude_oauth"}}import{homedir as Kl}from"node:os";import{join as jl}from"node:path";var Xy="https://api.openai.com/auth";function Ut(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Gl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function qy(e){let t=e.split(".");if(t.length!==3||t.some(r=>r.length===0))return null;let n=t[1];if(!n)return null;try{let r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"));return Gl(r)}catch{return null}}function Bl(e,t,n){return Ut(e[n])??Ut(t?.[n])}function Zy(e=process.env,t=Kl()){let n=Ut(e.CODEX_HOME)??jl(t,".codex");return jl(n,"auth.json")}function Vl(e=process.env,t=Kl()){let n=q(Zy(e,t),{}),r=Ut(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&Ut(n.OPENAI_API_KEY))return null;let o=Ut(n.tokens?.id_token);if(!o)return null;let s=qy(o);if(!s)return null;let i=Gl(s[Xy]),a=Bl(s,i,"name"),c=Bl(s,i,"email");return!c||me(a,c)?null:{git_user_name:null,git_user_email:null,platform_login:c,identity_source:"codex_oauth"}}import{homedir as Ur}from"node:os";import{join as Je}from"node:path";import{join as Qy}from"node:path";var eR="cursor-ide-identity.json",tR=840*60*1e3;function zl(e){return Qy(ge(e),eR)}function Wl(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Jl(e){let t=q(e,{}),n=t.read_at_ms,r=t.db_path;if(!(typeof n!="number"||!Number.isFinite(n)||typeof r!="string"))return{read_at_ms:n,db_path:r,email:Wl(t.email),auth_id:Wl(t.auth_id)}}function Yl(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<tR}function Xl(e,t){try{ce(e,`${JSON.stringify(t)}
33
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: cursor IDE identity cache write failed open: ${r}`)}}import{execFileSync as nR}from"node:child_process";import{existsSync as rR}from"node:fs";import{createRequire as oR}from"node:module";import{pathToFileURL as sR}from"node:url";var Zl=oR(import.meta.url),Lr=`
33
34
  SELECT key, value
34
35
  FROM ItemTable
35
36
  WHERE key LIKE 'cursorAuth/%'
36
37
  AND key NOT LIKE '%Token%'
37
38
  AND key NOT LIKE '%token%'
38
39
  ORDER BY key
39
- `.trim(),ns=new Map;function rl(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:null}if(e instanceof Uint8Array){let t=Buffer.from(e).toString("utf8").trim();return t.length>0?t:null}return null}function sl(e){return e.toLowerCase().includes("token")}function il(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=rl(r.key),s=rl(r.value);o&&s&&!sl(o)&&t.set(o,s)}return t}function OE(e){let t=bE(e);return t.search="mode=ro&immutable=1",t.href}function IE(e){try{let t=ol("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(Sr)??n.prepare(Sr);return il(r.all?.())}finally{n.close?.()}}catch{return null}}function TE(e){let t=process.emitWarning.bind(process);process.emitWarning=((n,...r)=>{(typeof n=="string"?n:n instanceof Error?n.message:"").includes("SQLite is an experimental feature")||t(n,...r)});try{return e()}finally{process.emitWarning=t}}function PE(e){try{return TE(()=>{let t=ol("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return il(n.prepare(Sr).all?.())}finally{n.close?.()}})}catch{return null}}function wE(e){let t=new Map;for(let n of e.split(`
40
- `)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let s=r.slice(0,o).trim(),i=r.slice(o+1).trim();s&&i&&!sl(s)&&t.set(s,i)}return t}function NE(e){try{let t=AE("sqlite3",["-noheader","-batch","-separator"," ",e,Sr],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return wE(t)}catch{return null}}function al(e){let t=ns.get(e);if(t)return t;if(!xE(e)){let o=new Map;return ns.set(e,o),o}let n=OE(e),r=IE(n)??NE(n)??PE(n)??new Map;return ns.set(e,r),r}var vE="cursorAuth/cachedEmail",ME="cursorAuth/stripeMembershipAuthId";function Er(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function LE(e=yr(),t=process.platform,n=process.env){let r=Er(n.VSCODE_PORTABLE);if(r)return Be(r,"user-data");let o=Er(n.VSCODE_APPDATA);if(o)return Be(o,"Cursor");switch(t){case"darwin":return Be(e,"Library","Application Support","Cursor");case"win32":return Be(Er(n.APPDATA)??Be(e,"AppData","Roaming"),"Cursor");default:return Be(Er(n.XDG_CONFIG_HOME)??Be(e,".config"),"Cursor")}}function HE(e=yr()){return Be(e,".cursor","cli-config.json")}function UE(e=yr(),t=process.platform,n=process.env){return Be(LE(e,t,n),"User","globalStorage","state.vscdb")}function on(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function DE(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):on(e.userId)}function FE(e){return on(e.email)??on(e.authId)??DE(e)}function rs(e){let t=on(e.email),n=on(e.displayName),r=FE(e);return!r||de(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}function $E(e){let n=ne(HE(e),{}).authInfo;return!n||typeof n!="object"?null:rs(n)}function jE(e,t,n){let r=UE(e,process.platform,t),o=Qu(e),s=el(o);if(tl(s,r,n))return rs({email:s?.email,authId:s?.auth_id});let i=al(r),a=i.get(vE)??null,c=i.get(ME)??null;return nl(o,{read_at_ms:n,db_path:r,email:a,auth_id:c}),rs({email:a,authId:c})}function cl(e=yr(),t=process.env,n=Date.now()){return $E(e)??jE(e,t,n)}import{createHash as BE}from"node:crypto";import{resolve as KE}from"node:path";function q(e){return BE("sha256").update(e).digest("hex").slice(0,16)}function os(e){return q(KE(e))}function Se(e,t){return`${e}\0${t}`}function ul(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}function sn(e){let n=[...e].sort((r,o)=>{let s=r.path.localeCompare(o.path);return s!==0?s:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
41
- `);return q(n)}function WE(e,t,n="git_config",r=null){return q(`${e??""}|${t??""}|${r??""}|${n}`)}function zE(e){let t=null,n=null;for(let r of e.split(`
42
- `)){let o=r.trim();if(!o)continue;let s=o.indexOf(" ");if(s<=0)continue;let i=o.slice(0,s).toLowerCase(),a=o.slice(s+1).trim();a&&(i==="user.name"?t=a:i==="user.email"&&(n=a))}return{git_user_name:t,git_user_email:n,platform_login:null}}async function VE(e,t=te){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return zE(n)}function JE(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 Ke(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 YE(e=process.env){let t=j(e.EV_AI_HOOK_OPERATOR_EMAIL),n=j(e.EV_AI_HOOK_OPERATOR_LOGIN),r=Ke(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=Ke(o,null,"github",o);if(s)return s;let i=j(e.GITLAB_USER_LOGIN),a=j(e.GITLAB_USER_EMAIL),c=Ke(j(e.GITLAB_USER_NAME)??i,a,"gitlab",a??i);if(c)return c;let l=j(e.BUILD_REQUESTEDFOREMAIL),u=Ke(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=Ke(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=Ke(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=Ke(S,null,"circleci",S);if(A)return A;let x=j(e.CODEBUILD_INITIATOR),I=Ke(x,null,"codebuild",x);if(I)return I;let O=j(e.DRONE_COMMIT_AUTHOR_EMAIL),v=j(e.DRONE_COMMIT_AUTHOR),T=Ke(v??j(e.DRONE_COMMIT_AUTHOR_NAME),O,"drone",O??v);if(T)return T;if(ll(e.CLAUDE_CODE_REMOTE)||ll(e.CURSOR_AGENT)){let K=j(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:K&&!de(null,K)?K:null,identity_source:"cloud"}}return null}function ss(e){return!!((e.git_user_name??e.git_user_email)&&!de(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 ll(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function XE(e,t,n){return e==="claude"?zu(t):e==="cursor"?cl(t,n):e==="codex"?qu(n,t):null}async function is(e,t=te,n=process.env,r={}){let o=await VE(e,t),s=JE(n),i=ss(o)?o:s&&ss(s)?s:null,a=XE(r.runnerPlatform,r.home??GE(),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=YE(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:ss(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 as(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??te,s=e.env??process.env,i=await is(t,o,s,{runnerPlatform:e.runnerPlatform,home:e.home}),a=WE(i.git_user_name,i.git_user_email,i.identity_source,i.platform_login),l=(n?yo(n):void 0)?.operator_identity_hash;if(!(r||l!==void 0&&l!==a||!l))return{commit:()=>{}};let p=n;return{operator:i,commit:()=>{p&&wa(p,a,vn())}}}function cs(e){return e?!yo(e)?.operator_identity_hash:!0}function fl(e){return!0}import{existsSync as fA,readFileSync as dA}from"node:fs";import{homedir as Ud}from"node:os";import{join as Ht,resolve as pA}from"node:path";import{basename as rA,join as Lt}from"node:path";import{dirname as Cl,resolve as xr}from"node:path";import{existsSync as qE}from"node:fs";import{homedir as ml}from"node:os";import{relative as gl,resolve as Pe,sep as ot}from"node:path";var ZE=["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"],QE=["prompt","tool_input","tool_response","last_assistant_message","command"],ey=new Set;function ty(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return ey}}var _l=new Set(["on","1","true"]);function ps(e){let t=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?_l.has(t.toLowerCase()):e?.collect_prompt===!0}function Rr(e,t){let n=hl(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!==""?_l.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}function hl(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 ny(e){let t={};for(let n of ZE){let r=He(e,n);r!==void 0&&(t[n]=r)}return t}function Cr(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Pe(e),r=Pe(t),o=gl(r,n);return!o||o==="."?".":o.startsWith(`..${ot}`)||o===".."||Pe(r,o)!==n?null:o.split(ot).join("/")}function Sl(e,t){let n=gl(Pe(t),Pe(e)).split(ot).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}function El(e){return typeof e!="string"||e.length===0?null:Pe(e).split(ot).join("/")}function ry(){let e=M("CURSOR_PROJECT_DIR");if(!e)return null;let t=Pe(e);return qE(t)?t.split(ot).join("/"):null}function ls(e,t){return Cr(e,t)!==null}function oy(e,t){let n=Pe(t??ml(),".cursor").split(ot).join("/");return ls(e,n)}function sy(e,t,n){return t!==null&&ls(e,t)?!0:t!==null&&oy(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&ls(e,n.gitRoot)?!0:t===null}function yl(e,t){let n=El(e.cwd);if(n!==null)return n;let r=Pe(process.cwd()).split(ot).join("/"),o=ry();return sy(r,o,t)?r:o??r}function ms(e,t={}){return yl(e,t)}function gs(e,t=ml()){let n=Pe(t).split(ot).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function dl(e,t,n){let r=El(n.launchCwd)??yl(t,n);e.cwd=gs(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?Cr(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}var Rl="\u2026[truncated]\u2026",fs=Buffer.byteLength(Rl,"utf8"),iy=8;function an(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function pl(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}function ay(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 cy(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=fs)return pl(e,t);let r=t-fs,o=Math.ceil(r/2),s=Math.floor(r/2);return`${pl(e,o)}${Rl}${ay(e,s)}`}function ds(e,t,n){if(typeof e=="string"){n.push({path:t,value:e,bytes:Buffer.byteLength(e,"utf8")});return}if(Array.isArray(e)){e.forEach((r,o)=>{ds(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||ds(o,[...t,r],n)}function uy(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 ly=256;function fy(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 dy(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let s=an(e);if(s<=t)return;let i=[];ds(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=fy(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&&uy(e,u.path,cy(u.value,r))}}function py(e,t){let n=Math.max(0,t-ly),r=Object.keys(e).filter(s=>!s.startsWith("_")).map(s=>({key:s,bytes:an(e[s])})).sort((s,i)=>i.bytes-s.bytes),o=[];for(let{key:s}of r){if(an(e)<=n)break;delete e[s],o.push(s)}o.length>0&&(e._dropped_keys=o.slice(0,10))}function us(e,t){let n=an(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,dy(r,t,fs+iy),an(r)>t&&py(r,t),r}function my(e,t,n){if(!(n.promptCapture??ps()))return;let r=ty(n.runnerEvent);for(let o of QE){if(r.has(o))continue;let s=t[o];s!==void 0&&(e[o]=s)}}function Ar(e,t,n={}){let r=hl(t);if(r==="full"){let s={...e};return delete s.cwd,delete s.transcript_path,dl(s,e,n),us(s,po)}let o=ny(e);return dl(o,e,n),r==="content"?(my(o,e,n),us(o,po)):us(o,sa)}function gy(e){return typeof e=="string"&&e.length>0}function _s(e){let t=xr(e.home),n=xr(e.launchCwd),r=e.gitRoot?xr(e.gitRoot):null,o=new Set,s=[],i=null;e.inGitRepo&&gy(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&&Cr(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&c){let l=Cl(r);for(;;){let u=xr(l);if(u===t)break;let d=Cl(u);if(d===u)break;if(e.hasProjectSpec(u)){s.push({scope:"parent",dir:u}),a=Sl(u,n);break}l=d}}return{anchors:s,parentRel:a}}import{existsSync as Al,readdirSync as _y,realpathSync as hy}from"node:fs";import{basename as Sy,dirname as Ey,relative as yy,resolve as Ry,sep as Cy}from"node:path";var hs=400,kr=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??Je}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=Ry(t).split(Cy).join("/");return gs(r,this.home)}let n=yy(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${q(Ey(t))}/${Sy(t)}`:n}claimFile(t){try{let n=hy(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(!Al(t))return[];try{return _y(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(Al(t))return ne(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 Ls,readFileSync as WR,statSync as zR}from"node:fs";import{basename as Ff,join as mt,relative as Hs}from"node:path";var Lf=Ve(Mf());var KR=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],Hf=KR.map(e=>Lf.default.matcher(e,{dot:!0}));function GR(e){return e===""?!1:Hf.some(t=>t(`${e}/`))}function Uf(e,t){if(t==="")return!1;if(e==="")return GR(t);let n=e.replace(/\/+$/,"");return Hf.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}var Us=100*1024,VR=4;function JR(e){return e.length<=Us?e:`${e.slice(0,Us-1)}\u2026`}function YR(e){try{let t=WR(e),n=t.toString("utf8");return{hash:q(t),length:t.length,text:JR(n)}}catch{return null}}var Df={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function XR(e){return e in Df?Df[e]:"UNSPECIFIED"}function vt(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=YR(t.absolutePath);if(!n)return!1;let r=t.name??Ff(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=XR(t.kind);return s&&(o.trigger=s),t.attributes&&(o.attributes=t.attributes),e.push(o)}function qR(e,t,n){let r=Hs(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?Ff(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function gt(e,t){let{dir:n,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c}=t;Ds(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c})}function Ds(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u}=t;if(!(o>VR))for(let d of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(d.isDirectory()&&Uf(n.replace(/\\/g,"/"),Hs(n,mt(r,d.name)).replace(/\\/g,"/"))||d.isDirectory()&&u?.includes(mt(r,d.name)))continue;if(c){if(!d.isDirectory())continue;let g=mt(r,d.name,c);if(Ls(g)){let S=Hs(n,mt(r,d.name)).replace(/\\/g,"/");vt(e,{absolutePath:g,kind:s,origin:i,enabled:a,name:S||d.name});continue}Ds(e,{walkRoot:n,currentDir:mt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(d.isDirectory()){Ds(e,{walkRoot:n,currentDir:mt(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=mt(r,d.name);vt(e,{absolutePath:p,kind:s,origin:i,enabled:a,name:qR(n,p,!0)})}}function $f(e){for(let t of e)if(Ls(t))try{if(zR(t).size>0)return t}catch{continue}return e.find(t=>Ls(t))}import{existsSync as OC,readFileSync as IC}from"node:fs";var Nr=Ve(rt(),1);var ZR="<omitted>",QR=["package_name","package_spec","package_version","package_version_source"],jf=100,Bf=120,vr=[{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"}],Kf=new Set(vr.map(e=>e.attr)),eC=["enabled","disabled"],tC=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],nC=new Set(["type","command","url","args","env","envVars","headers",...eC,...tC,...vr.map(e=>e.raw)]),rC=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",...QR,...Kf,...[...Kf].map(e=>`${e}_truncated`)]);function Gf(e,t){for(let n of t)nC.has(n)||rC.has(n)||(e[n]=ZR)}var oC=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,sC=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,iC=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,aC=/^bearer(?:\s+|$)/i;function Mr(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Wf(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Fs(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=Mr(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function _t(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function cC(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,Nr.launchContainsCredentials)({kind:"url",url:e})||(0,Nr.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=mn([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,Nr.launchContainsCredentials)({kind:"url",url:r}):!0)}function zf(e,t,n){cC(t,n)&&(e.launch_had_credentials=!0)}function uC(e){return iC.test(e)||aC.test(e)?"<redacted>":e.includes("://")?_t(e):e}function Vf(e){if(/^https?:\/\//i.test(e))return _t(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Vf(e.slice(t+1))}`:uC(e)}function lC(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return oC.test(t)||sC.test(t)}function mn(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(lC(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Vf(r))}return t}function fC(e){let t=Wf(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Bf?r.slice(0,Bf):r))].sort();if(n.length!==0)return n.length>jf?{names:n.slice(0,jf),truncated:!0}:{names:n,truncated:!1}}function dC(e){let t=Mr(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 Jf(e,t){let n=new Set;for(let{raw:r,attr:o}of vr){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=fC(s);i&&(e[o]=i.names,i.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function Yf(e,t){let n=Mr(e),r={transport:t};if(!n)return r;Gf(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=Wf(n.args);a&&(r.command_or_url=_t(a));let l=mn(c);l.length>0&&(r.args=l),zf(r,a,c);let u=dC(n.env_http_headers),d=[...new Set([...Fs(n.env),...Fs(n.envVars),...Fs(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),Jf(r,n),r}function Xf(e){let t=Mr(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function Bs(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 Mt(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function pn(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 js(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function $s(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=Mt(n[1]);return r.length>0?r:void 0}function pC(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],Mt(c[2]??"")])}},o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let s=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
43
- ${e}`);return s?.[1]&&r(s[1]),n}function qf(e){return js(e,"enabled")===!1?!1:js(e,"disabled")!==!0}function mC(e,t){let n={};for(let{raw:r,attr:o}of vr){if(o==="auto_approve"){let i=js(t,r);if(i!==void 0){n[r]=i;continue}}let s=pn(t,r);s.length>0&&(n[r]=s)}Jf(e,n)}var gC=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,_C=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function hC(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
44
- `)){let s=gC.exec(o);s?.[1]&&t.add(s[1])}for(let o of e.matchAll(_C))o[1]&&t.add(o[1]);return[...t]}function Zf(e,t){let n={transport:t};Gf(n,hC(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),s=r?Mt(r[1]??""):void 0,i=o?Mt(o[1]??""):void 0,a=s!==void 0&&s.length>0?s:i,c=pn(e,"args");a&&(n.command_or_url=_t(a));let l=mn(c);l.length>0&&(n.args=l),zf(n,a,c);let u=new Set;for(let x of e.split(`
45
- `)){let I=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(x);I?.[1]&&u.add(I[1])}let d=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(d?.[1])for(let x of d[1].split(",")){let I=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(x);I?.[1]&&u.add(I[1])}let f=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
46
- ${e}`);if(f?.[1])for(let x of f[1].split(`
47
- `)){let I=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(x);I?.[1]&&u.add(I[1])}for(let x of pn(e,"env_vars"))u.add(x);let p=pC(e,"env_http_headers");for(let[,x]of p)x.length>0&&u.add(x);let g=$s(e,"bearer_token_env_var");g&&(u.add(g),n.bearer_token_env_var=g),u.size>0&&(n.env_var_names=[...u].sort()),p.length>0&&(n.env_http_header_names=[...new Set(p.map(([x])=>x))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let S=$s(e,"auth");S&&(n.auth=S);let A=$s(e,"default_tools_approval_mode");return A&&(n.default_tools_approval_mode=A),mC(n,e),n}var ve=Ve(rt(),1);import{createHash as RC}from"node:crypto";import{join as gn}from"node:path";var SC=300,EC=256;function Qf(e,t){if(!t)return e;let n=[...new Set([t,t.replace(/\\/g,"/")])].filter(o=>o.length>1),r=e;for(let o of n)r=r.split(o).join("~");return r}function Lr(e){let t=[],n="",r=null;for(let o of e){if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(/\s/.test(o)){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}function ed(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function yC(e){return ed(e,SC)}function td(e,t){let n=Qf(e.trim(),t),r=Lr(n);if(r.length===0)return"";let[o,...s]=r,i=_t(o),a=mn(s);return yC([i,...a].join(" "))}function nd(e,t){if(typeof e!="string")return null;let n=Qf(e.trim(),t),r=Lr(n)[0];if(!r)return null;let o=_t(r);return o.length===0?null:ed(o,EC)}function CC(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,ve.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}function AC(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
48
- `);return RC("sha512").update(t).digest("hex").slice(0,16)}function xC(e){let t=process.platform==="win32"?gn(M("LOCALAPPDATA")??e,"npm-cache"):gn(e,".npm"),n=M("npm_config_cache")??M("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}function rd(e){return typeof e=="string"&&e.length>0&&e.length<=ve.PACKAGE_FIELD_MAX?e:null}function kC(e,t,n){let r=AC(e);for(let o of xC(n)){let s=gn(o,"_npx",r),i=ne(gn(s,"node_modules",...t.split("/"),"package.json"),{}),a=rd(i.version);if(a!==null)return a;let c=ne(gn(s,"package-lock.json"),{}),l=rd(c.packages?.[`node_modules/${t}`]?.version);if(l!==null)return l}return null}function bC(e){return e.length<=ve.PACKAGE_FIELD_MAX?e:`${e.slice(0,ve.PACKAGE_FIELD_MAX-1)}\u2026`}function Ks(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,ve.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let s=(0,ve.packageNameFromSpec)(o);return s===null?null:{package_name:s,package_spec:bC(o),...CC(o,kC(r,s,n))}}function od(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=Lr(e.trim());return n===void 0?null:Ks(n,r,t)}function Hr(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 Ks(typeof n.command=="string"?n.command:null,r,t)}function sd(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:Ks(Mt(n[1]??""),pn(e,"args"),t)}function TC(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 id(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=TC(a),l=Yf(a,c);Object.assign(l,Hr(a,e.home)??{});let u=Xf(a);e.push({kind:"MCP_SERVER",name:i,path:s,content_hash:Bs(i,l,u),origin:n,enabled:u,attributes:l})}}function ad(e,t,n){if(!OC(t)||!e.claimFile(t))return;let r;try{r=IC(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=Zf(u,d);Object.assign(f,sd(u,e.home)??{});let p=qf(u);e.push({kind:"MCP_SERVER",name:a,path:o,content_hash:Bs(a,f,p),origin:n,enabled:p,attributes:f})}}import{existsSync as NC,readdirSync as vC}from"node:fs";import{join as ue}from"node:path";function PC(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 wC(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 Gs(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 wC(c)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??c.powershell??"",d=PC({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:td(u,e.home)}:{}}})}}}function Ws(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||Gs(e,t,r.hooks,n)}var cd=50;function _n(e,t,n,r){if(!NC(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(cd,()=>{gt(e,{dir:ue(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),gt(e,{dir:ue(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),gt(e,{dir:ue(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});Ws(e,ue(t,"hooks","hooks.json"),n),Ws(e,ue(t,"hooks.json"),n);let i=e.components.length-o,a=s>=cd;return{componentCount:i,expandTruncated:a}}function hn(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 ud(e){let t=ue(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},s=e.readJson(ue(e.home,".claude/settings.json"),{})?.enabledPlugins??{},i=e.componentPath(t);for(let[a,c]of Object.entries(r)){if(e.truncated)return;let l=Array.isArray(c)?c:[c],u=l[0]??{},d=s[a]===!0,f=a.includes("@")?a.split("@").slice(1).join("@"):"",p=typeof u.version=="string"?u.version:"",g=typeof u.scope=="string"?u.scope:"user",S=`plugin:${a}`,A=0,x=!1;for(let I of l)if(typeof I.installPath=="string"&&I.installPath.length>0){let O=_n(e,I.installPath,S,d);A+=O.componentCount,x=x||O.expandTruncated}hn(e,{pluginKey:a,rowPath:i,enabled:d,scope:g,version:p||void 0,marketplace:f||void 0,componentCount:A,expandTruncated:x,contentHash:q(`${a}|${p}|${g}|${d}|${A}`)})}}function MC(e){let t=e,n="";try{let r=vC(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=ue(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),s=o[o.length-1];s&&(t=ue(e,s),n=s)}}catch{}return{installPath:t,version:n}}var LC=/^\d+$/;function HC(e){let t=e.filter(n=>!LC.test(n.pluginId));return t.length>0?t:e}function ld(e){let t=[{base:ue(e.home,".cursor/plugins/local"),scope:"local"},{base:ue(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=ue(n,o.name),l=`plugin:${a}`,{componentCount:u,expandTruncated:d}=_n(e,c,l,!0);hn(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(ue(n,s))){if(!a.isDirectory())continue;let c=ue(n,s,a.name),{installPath:l,version:u}=MC(c);i.push({pluginId:a.name,installPath:l,version:u})}for(let a of HC(i)){if(e.truncated)break;let c=`${a.pluginId}@${s}`,l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=_n(e,a.installPath,l,!0);hn(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 FC}from"node:fs";var UC=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,zs="<path>",DC=new RegExp(`${zs}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function Ur(e){let t=e.replace(UC,zs).replace(DC,zs);return t.length>200?`${t.slice(0,200)}...`:t}var fd=200,dd=200,Vs=16*1024,pd=6,$C=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),jC=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),BC=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),KC=new Set(["permissions"]),GC={claude:$C,cursor_sandbox:jC,cursor_permissions:BC,cursor_cli:KC},WC=new Set(["allow","deny","ask"]);function st(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Dr(e){return e.replace(/\\/g,"/")}function Js(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Js(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${Js(t[r])}`).join(",")}}`}function zC(e){return q(`${Js(e)}|settings1`)}function Sd(e){let t=Dr(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 Ed(e,t){if(e!=="claude")return{};let n=Dr(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 yd(e){let t=Dr(e).replace(/\/+$/,"");return t.length<=1?"":t}function Rd(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}function VC(e,t){let n=Dr(e);if(n==="~"||n.startsWith("~/"))return n;let r=yd(t);if(!r)return n;let o=n.slice(0,r.length);if(!(Rd(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let i=n.slice(r.length);return i===""?"~":i.startsWith("/")?`~${i}`:n}var md=new Map;function JC(e){let t=md.get(e);if(t!==void 0)return t;let n=yd(e),r=null;if(n){let o=n.split("/").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,Rd(e)?"gi":"g")}return md.set(e,r),r}function YC(e,t){let n=JC(t);return n?e.replace(n,"~"):e}function gd(e,t){return e.length<=dd?e:(t.truncated=!0,e.slice(0,dd))}function Cd(e,t){return e.length<=fd?e:(t.truncated=!0,e.slice(0,fd))}function re(e,t,n,r){if(typeof e=="string"){if(t==="path")return gd(VC(e,n),r);let o=t==="rule"?Ur(e):e;return gd(YC(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=Cd(e,r),s=[];for(let i of o){let a=re(i,t,n,r);a!==void 0&&s.push(a)}return s}if(st(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 _d(e,t,n){if(!st(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i="plain";WC.has(o)?i="rule":o==="additionalDirectories"&&(i="path");let a=re(s,i,t,n);a!==void 0&&(r[o]=a)}return r}function XC(e,t,n){if(!st(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=Cd(s,n);r[o]=a.map(c=>{if(!st(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 qC(e,t,n){if(!st(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 ZC(e,t,n){if(!st(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=qC(s,t,n):o==="credentials"?i=XC(s,t,n):i=re(s,"plain",t,n),i!==void 0&&(r[o]=i)}return r}function QC(e,t,n,r,o){return n==="claude"?e==="permissions"?_d(t,r,o):e==="sandbox"?ZC(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"?_d(t,r,o):re(t,"plain",r,o)}function Sn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Ys(e,t){return e?`${e}.${t}`:t}function Xs(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>=pd?(e.splice(o,1),r.add(n)):Xs(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>=pd?(delete e[o],r.add(Ys(n,o))):Xs(s,t+1,Ys(n,o),r))}function Ad(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:Sn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))Ad(o,Ys(t,r),n)}function eA(e,t,n){let r=Sn(e);if(r<=Vs)return;t.truncated=!0;let o=[];for(Ad(e,"",o);r>Vs;){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=Sn(i)+(s.items.length>0?1:0);s.bytes-=a,r-=a,n.add(s.path)}for(;Sn(e)>Vs;){let s,i=-1;for(let[a,c]of Object.entries(e)){let l=Sn(c);l>i&&(s=a,i=l)}if(s===void 0)break;delete e[s],n.add(s)}}function tA(e,t,n){let r=GC[t],o={truncated:!1},s={},i=[];for(let c of Object.keys(e)){if(!r.has(c)){i.push(c);continue}let l=QC(c,e[c],t,n,o);l!==void 0&&(s[c]=l)}i.sort();let a=new Set;return Xs(s,1,"",a),a.size>0&&(o.truncated=!0),eA(s,o,a),{settings:s,keys_omitted:i,truncated:o.truncated,trimmed_paths:[...a].sort()}}function hd(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:zC(t.attributes),attributes:t.attributes};e.push(n)}function qs(e,t,n,r){if(!e.claimFile(t)||!FC(t))return;let o=Gi(t);if(!o.ok||!st(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),hd(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}return}let s=o.value,i=s.hooks;if(st(i)&&Gs(e,t,i,n),!r.profile)return;let a=tA(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),hd(e,{kind:r.kind,absPath:t,origin:n,attributes:c})}import{existsSync as nA}from"node:fs";import{join as Me}from"node:path";var xd=".claude/skills/synced",kd=".claude/plugins/synced";function bd(e){return[Me(e,xd),Me(e,kd)]}function Fr(e){return typeof e=="string"&&e.length>0?e:void 0}function Od(e){let t=Me(e.home,xd);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Me(t,n.name),o=e.readJson(Me(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=Me(r,i.name,"SKILL.md");if(!i.isDirectory()||!nA(a))continue;let c=s.get(i.name),l=Fr(c?.source),u=Fr(c?.creatorType);vt(e,{absolutePath:a,kind:"SKILL",origin:"user",enabled:!0,name:i.name,attributes:{scope:"synced",...l?{source:l}:{},...u?{creator_type:u}:{}}})}}}function Id(e){let t=Me(e.home,kd);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Me(t,n.name),o=e.readJson(Me(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=Fr(a?.marketplaceName),l=Fr(a?.version),u=c?`${i.name}@${c}`:i.name,d=Me(r,i.name),{componentCount:f,expandTruncated:p}=_n(e,d,`plugin:${u}`,!0);hn(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 oA(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:s}=t;for(let i of n.skillRoots)gt(e,{dir:Lt(r,i),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:bd(e.home)});for(let i of n.dirs)gt(e,{dir:Lt(r,i.dir),kind:i.kind,origin:o,enabled:!0,extensions:i.extensions});for(let i of n.memory){let a=$f(i.map(c=>Lt(r,c)));a&&vt(e,{absolutePath:a,kind:"MEMORY",origin:o,enabled:!0,name:rA(a)})}for(let i of gc(n))qs(e,Lt(r,i),o,{kind:"SETTINGS",profile:Sd(i)});for(let i of n.mcpJson??[])id(e,Lt(r,i),o);for(let i of n.mcpToml??[])ad(e,Lt(r,i),o);if(s){if(n.managed){for(let i of zn(n.managed,process.platform,e.home))if(i.toLowerCase().endsWith(".json")){let a=Ed(n.managed,i);qs(e,i,o,{kind:"MANAGED_SETTINGS",...a})}}n.plugins==="claude"?(ud(e),Id(e),Od(e)):n.plugins==="cursor"&&ld(e)}}function Td(e,t){try{let n=new kr(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)oA(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 Zs(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let c=Td(t,{layouts:Object.values(bt),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:Je,scopeRef:""});c&&(r.user=c)}let s=n.inGitRepo===!0,i=null,a=n.launchCwd;if(a!==void 0){let c=Object.values(Qe),l=_s({launchCwd:a,gitRoot:n.gitRoot,inGitRepo:s,remote:n.remote,home:t,hasProjectSpec:u=>hc(c,u)});i=l.parentRel;for(let u of l.anchors){let d=os(u.dir);if(o!==void 0&&!o(u.scope,d))continue;let f=Td(t,{layouts:c,levelDir:u.dir,origin:u.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:hs,scopeRef:d});f&&(r[u.scope]=f)}r.parent||(i=null)}return{scopes:r,parentRel:i,cwdInGitRepo:s}}function Qs(e,t,n={}){let r=n.truncated===!0,o=sn(e),s=new Set(e.map(u=>Se(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=Se(u.path,u.name);c[d]!==u.content_hash&&a.push(u)}let l=[];if(!r){for(let u of Object.keys(c))if(!s.has(u)){let d=ul(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 wd=2*1024*1024,sA=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function ei(e,t,n){let r=new Set(t.map(s=>Se(s.path,s.name))),o=[];for(let s of e)s.text!==void 0&&(n.has(s.content_hash)||r.has(Se(s.path,s.name))||o.push(s));return o}function ti(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 Pd(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Nd(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function ni(e,t=wd){let n=[],r=[];for(let u of e)sA.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=Pd(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=Nd(u),g=Pd(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 ri(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:Nd(n))}var iA=["user","cwd","repo","parent"];function oi(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,s=[];for(let v of iA){let T=t.scopes[v];if(!T)continue;let K=n(v,T.scopeRef),D=K.components,b=Qs(T.components,D,{forceFull:D===void 0,truncated:T.truncated}),w=new Set(K.textHashes),H=ei(T.components,b.upserts,w),m=ri([...b.upserts,...H],w);s.push({scope:v,walk:T,delta:b,outgoing:m,outgoingKeys:new Set(m.map(k=>Se(k.path,k.name))),deliveredTextHashes:w,cachedComponents:D})}let i=s.flatMap(v=>v.outgoing),a=ni(i,o),c=new Set(a.components.map(v=>Se(v.path,v.name))),l=[],u=[],d=[],f=[],p=[],g=[],S=[];for(let v of s){let{scope:T,walk:K,delta:D}=v;g.push(...K.components),l.push(T);let b=a.components.filter(k=>v.outgoingKeys.has(Se(k.path,k.name))),w=[...v.outgoingKeys].some(k=>!c.has(k)),H=D.truncated||w;H?d.push(T):D.full&&u.push(T),f.push(...b),!D.full&&!H&&p.push(...D.removed);let m=D.full?{}:{...v.cachedComponents??{}};if(!H)for(let k of D.removed)delete m[Se(k.path,k.name)];for(let k of b)m[Se(k.path,k.name)]=k.content_hash;S.push({scope:T,scopeRef:K.scopeRef,components:m,textHashes:ti(v.deliveredTextHashes,b.filter(k=>k.text!==void 0).map(k=>k.content_hash),K.components),collectedAtMs:r,included:b.length>0||D.removed.length>0&&!H||D.full})}let A={user_spec_hash:sn(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 x=t.scopes.cwd;x&&(A.user_spec_cwd_scope_ref=x.scopeRef);let I=t.scopes.repo;I&&(A.user_spec_repo_scope_ref=I.scopeRef);let O=t.scopes.parent;return O&&(A.user_spec_parent_scope_ref=O.scopeRef,t.parentRel&&(A.user_spec_parent_rel=t.parentRel)),{fields:A,scopes:S}}var $r={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function si(e){return e==="cwd"||e==="repo"||e==="parent"}function En(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ii(e){return!En(e)||!En(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 vd(e){return aA(e)}function Md(e){return cA(e)}function Ld(e){return uA(e)}function aA(e){if(!En(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function cA(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Hd(e,t){if(!En(e))return;let n=e[t];return ii(n)?n:void 0}function uA(e){if(!En(e))return{};let t={};for(let[n,r]of Object.entries(e))ii(r)&&(t[n]=r);return t}function ai(e,t=20){let n=[];for(let[r,o]of Object.entries(e))ii(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 mA=["allow","deny","ask"];function Br(e){let t=ne(e,{}),n=[];for(let r of mA)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:Ur(o),mode:r});return{model:t.model??"",permissionKeys:n}}function gA(e){let{serverManaged:t,fileBased:n}=go(process.platform,e),r=Br(t);if(r.model||r.permissionKeys.length>0)return r;let o="",s=[];for(let i of n){let a=Br(i);a.model&&(o=a.model),s.push(...a.permissionKeys)}return{model:o,permissionKeys:s}}function _A(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 hA=10,SA="self-config-cache.json",Dd=4;function Ut(){return M("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function EA(){return M("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}var yA={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function RA(e,t=te){let n=yA[e];if(!n||n.length===0)return null;let r=async o=>{let s=n[o];if(s===void 0)return null;let a=((await t(s,["--version"],2e3)).split(`
49
- `)[0]??"").trim();return a||r(o+1)};return r(0)}function CA(e=Ud()){return Ht(e,".ev-ai","agent-hook",SA)}function AA(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
50
- `);return q(n)}function jr(e,t,n=!1){let r=AA(e),o=e.length;return t===r?n?{hash:r,count:o,truncated:n}:{hash:r,count:o}:n?{hash:r,count:o,entries:e,truncated:n}:{hash:r,count:o,entries:e}}function ci(e,t,n=[]){let r=0,o=!1,s=new Set;for(let i of[...t.map(a=>Ht(e,a)),...n]){let a=pA(i);if(s.has(a))continue;s.add(a);let c=ro(i);c.present&&(o=!0,r+=c.size)}return o?{present:!0,size:r}:{present:!1,size:0}}function xA(e){return fA(e)?ge(dA(e,"utf8"),{}):{}}function kA(e,t){try{me(e,`${JSON.stringify(t)}
51
- `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: self-config cache write failed open: ${r}`)}}function bA(e,t,n){if(t==="user")return{components:vd(e.user_spec_components),textHashes:Md(e.user_spec_text_hashes)};if(!si(t))return{components:void 0,textHashes:[]};let r=Hd(e[$r[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}function OA(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=Dd,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(!si(s.scope))continue;let i=$r[s.scope],a=Ld(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]=ai(a)}}return o}async function Fd(e,t=process.cwd(),n=Ud(),r={}){let o=e==="claude",s=r.gitRoot??t,i=await RA(e),a="",c=[];if(o){let H=gA(n),m=Br(Ht(n,".claude/settings.json")),k=Br(Ht(t,".claude/settings.local.json"));a=H.model||k.model||m.model,c=_A([...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 le=Wi(Ht(n,U));if(m=m.concat(le.entries),k=k||le.truncated,m.length>=Je){m=m.slice(0,Je),k=!0;break}}return{entries:m,truncated:k}},d=CA(n),f=xA(d),p=f[e]??{},g=(p.send_count??0)+1,S=g>0&&g%hA===0,A=H=>S?void 0:p[H],x=u(tt.skills),I=u(tt.subagents),O=u(tt.commands),v=u(tt.rules),T={skills:jr(x.entries,A("skills"),x.truncated),subagents:jr(I.entries,A("subagents"),I.truncated),commands:jr(O.entries,A("commands"),O.truncated),rules:jr(v.entries,A("rules"),v.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:ci(n,tt.memory),settings:ci(n,tt.settings,Sc(n)),mcp:ci(n,tt.mcp)},local_settings:o?ro(Ht(t,".claude/settings.local.json")):l},D=null,b=r.nowMs??Date.now();if(!Ut()){let H=p.user_spec_layout_version!==Dd,m=Zs(e,n,{launchCwd:EA()?void 0:r.launchCwd,gitRoot:s,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(m.scopes).length>0){let k=oi({collected:m,cacheFor:(U,le)=>H?{components:void 0,textHashes:[]}:bA(p,U,le),nowMs:b});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 w=OA(p,T,g,D);return{config:K,commit:()=>{f[e]=w,kA(d,f)}}}import{homedir as WA}from"node:os";import{join as Bd}from"node:path";function ht(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{join as Kr}from"node:path";function IA(e){return Kr(e,".ev-ai","agent-hook","js","signed-v1")}function TA(e){return Kr(IA(e),"scopes")}function $d(e,t){return Kr(TA(e),t)}function jd(e){return Kr(e,"attempts")}function ui(e){return String(e).padStart(10,"0")}var PA=/^(\d{10})$/,wA=/^(\d{10})\.done$/,NA=/^[0-9a-f]{128}$/,vA=64;async function zd(e,t,n=!1){let r=jd(t),o=await Ii(e,r),s=new Map,i=new Map,a=Kd(o,PA),c=Kd(o,wA),l=async f=>{let p=await Wd(e,Bd(r,MA(f)));return p&&s.set(f,{record:HA(p.value),mtimeMs:p.mtimeMs}),p!==void 0},u=async f=>{let p=UA((await Wd(e,Bd(r,LA(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([Gd(a,l),Gd(c,u)]);let d=yn(s);return d<yn(i)&&c.includes(d)&&await u(d),{claims:s,dones:i}}function Kd(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}async function Gd(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}function yn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}function Vd(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 MA(e){return ui(e)}function LA(e){return`${ui(e)}.done`}async function Wd(e,t){let n;try{n=await e.stat(t)}catch(o){if(yt(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>qr)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>qr?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}function HA(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}function UA(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=DA(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n}}function DA(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"&&NA.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&FA(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}function FA(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==vA||t.toString("base64")!==e))return t.toString("hex")}function KA(e){return e==="bootstrap"?3e3:6e4}function GA(e,t){let n=yn(e.claims);if(n===0)return;let r=yn(e.dones),o=e.claims.get(n),s=e.dones.get(n);if(o&&!s){let a=Vd(o),c=o.record==="empty"?void 0:o.record.owner,l=KA(c)+3e4;if(t-a>l)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:Jd(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:Jd(i.selection)}}async function Yd(e,t,n){try{let r=await zd(Ti(),$d(e,t),!0);return GA(r,n)}catch{return}}function Jd(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}function zA(e=process.env){if(Object.values(ca).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===_e?"npx":null}async function Xd(e=WA()){let t=Qo()?.launcherScope;if(!t)return{};let n=await Yd(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}function Dt(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:Ye,event:e,timestamp:vn(),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:Ue,hook_delivery:zA(),host_arch:process.arch,node_version:process.version,policy_version:null,policy_capabilities:[],...n.promptCaptureSource!==void 0?{prompt_capture_source:n.promptCaptureSource}:{},correlation:r,payload:t},s=Qo();return s&&(o.launcher_version=s.launcherVersion,o.hook_source=s.hookSource,o.hook_fallback_reason=s.fallbackReason??null,o.launcher_scope_match=Lu(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 qd}from"node:fs";import{spawn as Zd}from"node:child_process";import{fileURLToPath as JA}from"node:url";import{gzipSync as VA}from"node:zlib";function li(e){return M("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<ia?{body:e}:{body:VA(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}function Gr(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}function fi(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}var Rn="__post",Wr="__work";async function YA(e,t,n={}){if(Ut())return e;let r=await is(n.gitRoot??process.cwd(),te,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}}}function XA(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})}function Qd(e){switch(e){case"session_start":return na;case"session_end":return ra;case"tool_invoked":case"skill_invoked":return fo;default:return fo}}function qA(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
52
- ${n}`}function ep(e,t=[],n=process.execPath,r=import.meta.url,o=qd){if(Bn(n))return{command:n,args:[e,...t]};let s=JA(r);return o(s)?{command:n,args:[s,e,...t]}:{command:n,args:[e,...t]}}function ZA(e=process.execPath,t=import.meta.url,n=qd){return ep(Rn,[],e,t,n)}function QA(e){let t=e.indexOf(`
53
- `);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}async function tp(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();Fa(n,t)}catch{}}async function zr(e,t=fetch){let n=await e(),r=QA(n);if(!r)return;let{meta:o,body:s}=r,i=li(s),a=Gr(i.contentEncoding);try{let c=await t(o.url,{method:"POST",headers:a,body:i.body,signal:AbortSignal.timeout(Number(o.timeoutMs))});await tp(c,o.url)}catch{}}async function ex(e,t,n,r=fetch){let o=Qd(e),s=li(t),i=Gr(s.contentEncoding),a=fi(s.body);E(`POST event=${e} url=${jn(n)} size=${a} encoding=${s.contentEncoding??"identity"} platform=${process.platform}`);let c=Date.now();try{let l=await r(n,{method:"POST",headers:i,body:s.body,signal:AbortSignal.timeout(o)});if(!l.ok&&s.contentEncoding==="gzip"&&(l.status===400||l.status===415)){try{await l.text()}catch{}E(`POST gzip rejected http=${l.status} \u2014 retrying uncompressed`),l=await r(n,{method:"POST",headers:Gr(),body:t,signal:AbortSignal.timeout(o)})}let u=Date.now()-c;if(l.ok)return E(`POST outcome=ok elapsed_ms=${u} http=${l.status}`),await tp(l,n),!0;let d=(await l.text()).slice(0,200).replace(/[\n\r]/g,"");return E(`POST outcome=fail elapsed_ms=${u} http=${l.status} body=${d}`),!1}catch(l){let u=Date.now()-c,d=l instanceof Error?l.message:String(l);return E(`POST outcome=fail elapsed_ms=${u} http=000 body=${d}`),!1}}async function np(e,t,n,r,o){try{let s=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});s.on("error",()=>{}),s.stdin.on("error",()=>{});let i=!1;return await new Promise(a=>{let c=setTimeout(()=>{if(!i){E(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`);try{s.stdin.destroy()}catch{}}a()},oa),l=()=>{i=!0,clearTimeout(c),a()};s.stdin.end(n,()=>l()),s.stdin.once("error",()=>l())}),s.unref(),s}catch(s){let i=s instanceof Error?s.message:String(s);return E(`WARN: ${o} spawn failed open: ${i}`),null}}async function tx(e,t,n,r=Zd,o=ZA){let s=Qd(e),i=qA(n,s,t),{command:a,args:c}=o();return np(a,c,i,r,"detached post")}async function rp(e,t,n=Zd,r=ep){let{command:o,args:s}=r(Wr,t);return np(o,s,e,n,"detached work")}async function Ft(e,t,n,r,o,s,i){if(!o)return E("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),!1;if(!$n(o))return E(`WARN: collector URL blocked (https required): ${jn(o)}`),!1;let a=await YA(t,n.runnerPlatform,i),c=r(e,a,{...n,collectorUrl:o});s!==void 0&&(c.build_ms=Math.max(0,Date.now()-s));let l=JSON.stringify(c),u=`${l}
54
- `,d=M("EV_AI_HOOK_DEBUG");d==="full"?E(`DEBUG envelope=${l}`):d==="1"&&E(`DEBUG summary=${XA(c,fi(u))}`);let f=process.argv.includes(Wr),p=M("EV_AI_HOOK_SYNC")==="1";return fr(n.runnerEvent,n.runnerPlatform)||f||p?ex(e,u,o):(await tx(e,u,o),!1)}import{createReadStream as nx}from"node:fs";import{stat as rx}from"node:fs/promises";import{basename as ox,resolve as sx}from"node:path";import{createInterface as ix}from"node:readline";var ax=1024*1024;function cx(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&ox(t).endsWith(".jsonl")}async function op(e){if(!e||!cx(e))return null;try{let t=sx(e),n=await rx(t);if(!n.isFile())return null;let r=Math.max(0,n.size-ax),o=[],s=ix({input:nx(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 Vr(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:Rr(e.manifest.manifest,e.manifest.hookConfig)}}function An(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}function pi(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:ps(e.manifest.hookConfig)}}async function ap(e){let t=Date.now();await yx(e);let{gitRoot:n}=e.manifest;await gi(e,n);let r=pi(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:Ar(e.hookInput,e.manifest.manifest,r),envelopeFields:Vr(e),launchCwd:ms(e.hookInput,r),home:lx()}}function sp(e){try{return he(ux(e))}catch{return null}}function cp(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function ip(e,t){let n=e.replaceAll("\\","/");if(!cp(n))return null;let r=he(e),o=he(t),s=sp(e)??r,i=sp(t)??o;return s.startsWith(`${i}/`)?s.slice(i.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}function up(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),s=ip(e,t)??(cp(r)?null:r),i=ip(e,n);return{repositorySourcePath:s,userSourcePath:i}}function di(e,t,n,r,o){return lp(e,up(n,t.gitRoot,t.home),r,o)}function lp(e,{repositorySourcePath:t,userSourcePath:n},r,o){let s=t??n,i=s===null?null:o(s),a=i!==null&&s!==null?fx({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 fx(e){try{let t=e.inRepository?mx(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 fp(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 mi(e,t,n){return Ft("tool_invoked",{...n,...fp(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,Dt,e.manifest.collectorUrl,t.buildStartedAtMs,An(e,t.home))}function dx(e){return au(e.runnerEvent,e.runnerPlatform)?[]:kc(e.hookInput)}function px(e,t){return mi(e,t,{})}var dp=new Set([...Object.values(ft),".github"]);function mx(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=>dp.has(i));return s<0?null:`${r}:${o.slice(0,s+1).join("/")}`}var pp=".codex/config.toml",gx=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",pp]]);function _x(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?gx.get(c.source):o==="codex"?pp: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||!dp.has(g)))try{return(0,B.buildComponentReference)({installationRootExternalKey:n,installableKind:B.ComponentKind.INTERFACE,sourcePath:p,nativeKey:t})}catch{return}}function hx(...e){for(let t of e)if(t)return t;return null}function Et(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 Sx(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 Ex(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var St=new Set,Cn=null;async function yx(e){if(Ut())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(St.has(t))return;if(!cs(n)){St.add(t);return}let r=Jt({sessionId:e.sessionId,hostname:Vn()});if(fl(r)){if(Cn){await Cn;return}Cn=(async()=>{if(St.has(t)||!cs(n)){St.add(t);return}if(!Na(n)){St.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:i}=e.manifest,a=String(e.runnerPlatform),{operatorResolved:c,fields:l}=await mp(e,r,ur(i),as({gitRoot:i,installationStorePath:n,forceResend:!1,runnerPlatform:a})),u={...l,self_config:Ex(a,c.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await Ft("session_start",u,Vr(e),Dt,e.manifest.collectorUrl,s,An(e)),o&&(c.commit(),St.add(t))}finally{va(n)}})().finally(()=>{Cn=null}),await Cn}}async function gi(e,t,n){try{e.platformAgentId=await Xc(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 mp(e,t,n,r){let[o,s,i,a,c]=await Promise.allSettled([n,ma(),Uu(t),_a(),r]),l=Et(o,null,"gitSnapshot"),u=Et(s,"","detectVirt"),d=Et(i,null,"probeCloud"),f=Et(a,{},"hostEnv"),p=Et(c,{commit:()=>{}},"resolveOperatorForSend");return await gi(e,e.manifest.gitRoot,l),{operatorResolved:p,fields:{identity:{host:Vn(),context:t,virt:u||null,cloud:d,git:l},host_env:f,env_vars:Gu()}}}async function Rx(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=Jt({sessionId:e.sessionId,hostname:Vn()}),o=String(e.runnerPlatform),s=pi(e),i=ms(e.hookInput,s),a=ur(n),c=Xd().catch(()=>({})),l=Ut()?Promise.resolve({commit:()=>{}}):as({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o}),u=mp(e,r,a,l),[d,f]=await Promise.allSettled([ts(e.manifest.manifest,n,o),a.catch(()=>null).then(K=>Fd(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=Et(d,[],"mcpDeclared"),A=Et(f,Sx(o),"selfConfig"),x=A.config,I=L(e.hookInput,"model");I&&(x.model=I);let O={...g,mcp:{declared:S},self_config:x,run_meta:{trigger:e.hookSource||"startup"},hook_input:Ar(e.hookInput,e.manifest.manifest,{...s,launchCwd:i})},v=await c;await Ft("session_start",O,{...Vr(e),...v},Dt,e.manifest.collectorUrl,t,An(e))&&(A.commit(),p.commit(),St.add(e.manifest.installationId))}async function Cx(e){let t=Date.now(),[,n]=await Promise.all([gi(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?op(L(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=hx(L(e.hookInput,"status"),L(e.hookInput,"stop_reason"),L(e.hookInput,"reason"),tn(L(e.hookInput,"error")),r==="stop"?He(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),s=Ar(e.hookInput,e.manifest.manifest,pi(e));n&&(s.model=n),r!=="stopfailure"&&Rr(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&s.last_assistant_message===void 0&&(s.last_assistant_message=""),await Ft("session_end",{status:o,...n?{model:n}:{},hook_input:s},Vr(e),Dt,e.manifest.collectorUrl,t,An(e))}async function Ax(e){let t=dx(e),n=eu(e.hookInput),r=iu(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&Rr(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let s=await ap(e);await Promise.all([o?px(e,s):void 0,t.length===0?void 0:xx(e,s,t),n.length===0?void 0:kx(e,s,n)])}function gp(e,t,n,r){let o=r??xc({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),s=di(e,t,o,B.ComponentKind.SKILL,B.nativeKeyForSkillPath);if(s.sourcePath!==null&&vo(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=di(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 xx(e,t,n){let r=nr(e.hookInput.tool_input);return Promise.all(n.map(o=>{let s=gp(e,t,o,r);return mi(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 kx(e,t,n){return Promise.all(n.map(r=>{let o=qc({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),s=di(e,t,o,B.ComponentKind.RULE,B.nativeKeyForRulePath),i=s.nativeKey??Qc(r);return mi(e,t,{tool_name:"Rule",rule_name:i,...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}var bx=[{kind:B.ComponentKind.SKILL,nativeKeyFn:B.nativeKeyForSkillPath},{kind:B.ComponentKind.RULE,nativeKeyFn:B.nativeKeyForRulePath},{kind:B.ComponentKind.COMMAND,nativeKeyFn:B.nativeKeyForCommandPath}];function Ox(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Lo(e.hookInput);if(r===null)return n.skillName===null?{}:gp(e,t,n.skillName,null);let o=up(r,t.gitRoot,t.home);for(let s of bx){let i=lp(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 Ix=/mcp/i;function Tx(e,t,n,r){let o=Ix.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let s=o?od(t,n):Hr(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 Px(e){let t=await ap(e),n=lu(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,s=Mo(e.hookInput),i=nd(s,t.home),a=du(e.hookInput),c=cu(e.runnerEvent),l=c===!1?pu(e.hookInput,e.runnerEvent):null,u=tn(L(e.hookInput,"mcp_server_name")),d=u!==null||r!==null&&dr(r)?await ts(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(()=>[]):[],{mcpServer:f,mcpTool:p}=gu(r,d.map(K=>K.name),u??""),g=_x(r,f,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),d,u),S=g===void 0?Ox(e,t,n):{},A=f===null?null:Ku(f,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),x=Tx(e,s,t.home,{hasMcpIdentity:!!f||!!p,declaredConfig:A}),I=g??S.componentReference,O=S.ruleName??n.ruleName,v=S.commandName??n.commandName,T=fu(e.hookInput);await Ft("tool_invoked",{tool_name:r,skill_name:o,...O?{rule_name:O}:{},...v?{command_name:v}:{},success:c,duration_ms:a,...i?{executable:i}:{},...l?{failure_reason:l}:{},...f?{mcp_server:f}:{},...p?{mcp_tool:p}:{},...x,...I?{component_reference:I}:{},...T?{subagent_type:T}:{},...fp(e),hook_input:t.hookInput},t.envelopeFields,Dt,e.manifest.collectorUrl,t.buildStartedAtMs,An(e,t.home))}async function _p(e){switch(e.internalEvent){case"session_start":await Rx(e);return;case"session_end":await Cx(e);return;case"skill_invoked":await Ax(e);return;case"tool_invoked":await Px(e);return;default:return}}import{mkdirSync as wx,readdirSync as Nx,readFileSync as vx,statSync as hp,unlinkSync as Mx,writeFileSync as Lx}from"node:fs";import{homedir as Jr}from"node:os";import{join as _i}from"node:path";var Hx="turns",Sp=1440*60*1e3,Ux=100,Dx=new Set(["stop","stopfailure","sessionend"]);function hi(e=Jr()){return _i(Re(e),Hx)}function Ep(e,t){return _i(e,Gt(t))}function Fx(e,t=Date.now()){let n;try{n=Nx(e)}catch{return}let r=0;for(let o of n){if(r>=Ux)return;r+=1;try{let s=_i(e,o);t-hp(s).mtimeMs>Sp&&Mx(s)}catch{}}}function $x(e,t,n=Jr()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let s=hi(n);wx(s,{recursive:!0}),Lx(Ep(s,r),o,"utf8")}catch{}}function jx(e,t=Jr()){let n=e.trim();if(!n)return"";try{let r=Ep(hi(t),n);return Date.now()-hp(r).mtimeMs>Sp?"":vx(r,"utf8").trim()}catch{return""}}function yp(e,t,n,r=Jr()){let o=t.trim(),s=Dx.has(n.trim().toLowerCase());return s&&Fx(hi(r)),o?($x(e,o,r),o):s?jx(e,r):""}async function Bx(e,t,n,r){let o=t??await Mn(Kn),s=ge(o,{}),i=await ja(process.cwd(),{sessionId:en(s)});if(!i)return;r&&(i.collectorUrl=r,i.hookConfig=Xn(r));let a=uu(s,i.manifest.platform,n),c=Wo(e,a.runnerEvent);if(!c){E(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`);return}let l={hookInput:s,sessionId:a.sessionId,turnId:yp(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await _p(l)}function Kx(e,t=!1){if(M("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,s=Qt(r,o,void 0,n.runner);return fr(o,s)?!0:t}function Rp(e,t){let n=so(e),r=ge(t,{}),o=n.event??Go(r);return da()||su(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}function Ap(e){return Ou(Wo(e.parsed.event,e.runnerEvent))}async function Cp(e,t,n){let{parsed:r}=e,o=n??qo(r.slot);if(!o&&!Ap(e)){let s=Xo(r.cap),i=vu(s);if(!i){Zo(s);return}o=i}try{await Bx(r.event,t,r.runner,ru(r))}finally{o&&gr(o)}}async function xp(e=process.argv.slice(2)){if(Mu(),M("EV_AI_HOOK_JUDGE")==="1"){try{await Mn(Kn)}catch{}return to(),0}if(e[0]===Rn){try{await zr(Wt)}catch{}return 0}if(e[0]===Wr){try{let n=await Wt(),r=Rp(e.slice(1),n);if(!r)return 0;await Cp(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 Mn(Kn),r=Rp(e,n);if(!r)return 0;let{parsed:o,hookInput:s,runnerEvent:i}=r;if(t=qo(o.slot),!yu(s,i,o.runner))return 0;if(Kx(r))await Cp(r,n,t);else{let a=t||Ap(r)?void 0:Xo(o.cap);if(a===void 0||wu(a)){let c=await rp(n,e);t&&c?.pid!==void 0&&Tu(t,c.pid)}else Zo(a)}}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: hook failed open: ${r}`)}finally{t&&gr(t),to()}return 0}function Yr(){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 kp(e){return e.includes("--help")||e.includes("-h")}async function Jx(e=process.argv.slice(2)){let[t,...n]=e;if(t===Rn){try{await zr(Wt)}catch{}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${Ue}
55
- `),0):t==="configure"?kp(n)?(Yr(),0):(await uc(Ya(n)),0):t==="install"?kp(n)?(Yr(),0):(await ac(Xa(n)),0):t==="migrate-to-plugin"?(await fc(),0):t==="update"?(await cc(),0):t==="uninstall"?(await dc(),0):t==="help"||t==="--help"||t==="-h"?(Yr(),0):t===void 0?(Yr(),1):xp(e)}function Yx(e,t,n=Gx){if(!t)return!1;try{return e===Vx(Wx(t)).href?!0:n(zx(e))===n(t)}catch{return!1}}Yx(import.meta.url,process.argv[1])&&process.env.VITEST===void 0&&Jx().then(e=>{process.exit(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);E(t),process.exit(1)});export{Yx as isCliEntrypoint,Jx as main};
40
+ `.trim(),Cs=new Map;function ql(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:null}if(e instanceof Uint8Array){let t=Buffer.from(e).toString("utf8").trim();return t.length>0?t:null}return null}function Ql(e){return e.toLowerCase().includes("token")}function ef(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=ql(r.key),s=ql(r.value);o&&s&&!Ql(o)&&t.set(o,s)}return t}function iR(e){let t=sR(e);return t.search="mode=ro&immutable=1",t.href}function aR(e){try{let t=Zl("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(Lr)??n.prepare(Lr);return ef(r.all?.())}finally{n.close?.()}}catch{return null}}function cR(e){let t=process.emitWarning.bind(process);process.emitWarning=((n,...r)=>{(typeof n=="string"?n:n instanceof Error?n.message:"").includes("SQLite is an experimental feature")||t(n,...r)});try{return e()}finally{process.emitWarning=t}}function uR(e){try{return cR(()=>{let t=Zl("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return ef(n.prepare(Lr).all?.())}finally{n.close?.()}})}catch{return null}}function lR(e){let t=new Map;for(let n of e.split(`
41
+ `)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let s=r.slice(0,o).trim(),i=r.slice(o+1).trim();s&&i&&!Ql(s)&&t.set(s,i)}return t}function fR(e){try{let t=nR("sqlite3",["-noheader","-batch","-separator"," ",e,Lr],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return lR(t)}catch{return null}}function tf(e){let t=Cs.get(e);if(t)return t;if(!rR(e)){let o=new Map;return Cs.set(e,o),o}let n=iR(e),r=aR(n)??fR(n)??uR(n)??new Map;return Cs.set(e,r),r}var dR="cursorAuth/cachedEmail",pR="cursorAuth/stripeMembershipAuthId";function Hr(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function mR(e=Ur(),t=process.platform,n=process.env){let r=Hr(n.VSCODE_PORTABLE);if(r)return Je(r,"user-data");let o=Hr(n.VSCODE_APPDATA);if(o)return Je(o,"Cursor");switch(t){case"darwin":return Je(e,"Library","Application Support","Cursor");case"win32":return Je(Hr(n.APPDATA)??Je(e,"AppData","Roaming"),"Cursor");default:return Je(Hr(n.XDG_CONFIG_HOME)??Je(e,".config"),"Cursor")}}function gR(e=Ur()){return Je(e,".cursor","cli-config.json")}function _R(e=Ur(),t=process.platform,n=process.env){return Je(mR(e,t,n),"User","globalStorage","state.vscdb")}function _n(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function hR(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):_n(e.userId)}function SR(e){return _n(e.email)??_n(e.authId)??hR(e)}function As(e){let t=_n(e.email),n=_n(e.displayName),r=SR(e);return!r||me(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}function ER(e){let n=q(gR(e),{}).authInfo;return!n||typeof n!="object"?null:As(n)}function yR(e,t,n){let r=_R(e,process.platform,t),o=zl(e),s=Jl(o);if(Yl(s,r,n))return As({email:s?.email,authId:s?.auth_id});let i=tf(r),a=i.get(dR)??null,c=i.get(pR)??null;return Xl(o,{read_at_ms:n,db_path:r,email:a,auth_id:c}),As({email:a,authId:c})}function nf(e=Ur(),t=process.env,n=Date.now()){return ER(e)??yR(e,t,n)}import{createHash as RR}from"node:crypto";import{resolve as CR}from"node:path";function Z(e){return RR("sha256").update(e).digest("hex").slice(0,16)}function bs(e){return Z(CR(e))}function Re(e,t){return`${e}\0${t}`}function Dr(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}function rf(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}function hn(e){let n=[...e].sort((r,o)=>{let s=r.path.localeCompare(o.path);return s!==0?s:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
42
+ `);return Z(n)}function bR(e,t,n="git_config",r=null){return Z(`${e??""}|${t??""}|${r??""}|${n}`)}function kR(e){let t=null,n=null;for(let r of e.split(`
43
+ `)){let o=r.trim();if(!o)continue;let s=o.indexOf(" ");if(s<=0)continue;let i=o.slice(0,s).toLowerCase(),a=o.slice(s+1).trim();a&&(i==="user.name"?t=a:i==="user.email"&&(n=a))}return{git_user_name:t,git_user_email:n,platform_login:null}}async function xR(e,t=ne){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return kR(n)}function OR(e=process.env){let t=j(e.GIT_AUTHOR_NAME),n=j(e.GIT_AUTHOR_EMAIL);if(t||n)return{git_user_name:t,git_user_email:n,platform_login:null,identity_source:"git_env"};let r=j(e.GIT_COMMITTER_NAME),o=j(e.GIT_COMMITTER_EMAIL);if(r||o)return{git_user_name:r,git_user_email:o,platform_login:null,identity_source:"git_env"};let s=j(e.EMAIL);return s?{git_user_name:null,git_user_email:s,platform_login:null,identity_source:"git_env"}:null}function Ye(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}function IR(e=process.env){let t=j(e.EV_AI_HOOK_OPERATOR_EMAIL),n=j(e.EV_AI_HOOK_OPERATOR_LOGIN),r=Ye(j(e.EV_AI_HOOK_OPERATOR_NAME),t,"configured",t??n);if(r)return r;let o=j(e.GITHUB_ACTOR)??j(e.GITHUB_TRIGGERING_ACTOR)??j(e.GITHUB_USER),s=Ye(o,null,"github",o);if(s)return s;let i=j(e.GITLAB_USER_LOGIN),a=j(e.GITLAB_USER_EMAIL),c=Ye(j(e.GITLAB_USER_NAME)??i,a,"gitlab",a??i);if(c)return c;let l=j(e.BUILD_REQUESTEDFOREMAIL),u=Ye(j(e.BUILD_REQUESTEDFOR),l,"azure_devops",l??j(e.BUILD_REQUESTEDFORID));if(u)return u;let d=j(e.BUILDKITE_BUILD_CREATOR_EMAIL),f=Ye(j(e.BUILDKITE_BUILD_CREATOR),d,"buildkite",d);if(f)return f;let p=j(e.BUILD_USER_EMAIL)??j(e.CHANGE_AUTHOR_EMAIL),g=Ye(j(e.BUILD_USER)??j(e.CHANGE_AUTHOR),p,"jenkins",p??j(e.BUILD_USER_ID));if(g)return g;let S=j(e.CIRCLE_USERNAME),A=Ye(S,null,"circleci",S);if(A)return A;let b=j(e.CODEBUILD_INITIATOR),I=Ye(b,null,"codebuild",b);if(I)return I;let P=j(e.DRONE_COMMIT_AUTHOR_EMAIL),T=j(e.DRONE_COMMIT_AUTHOR),O=Ye(T??j(e.DRONE_COMMIT_AUTHOR_NAME),P,"drone",P??T);if(O)return O;if(of(e.CLAUDE_CODE_REMOTE)||of(e.CURSOR_AGENT)){let K=j(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:K&&!me(null,K)?K:null,identity_source:"cloud"}}return null}function ks(e){return!!((e.git_user_name??e.git_user_email)&&!me(e.git_user_name,e.git_user_email))}function j(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function of(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function TR(e,t,n){return e==="claude"?$l(t):e==="cursor"?nf(t,n):e==="codex"?Vl(n,t):null}async function xs(e,t=ne,n=process.env,r={}){let o=await xR(e,t),s=OR(n),i=ks(o)?o:s&&ks(s)?s:null,a=TR(r.runnerPlatform,r.home??AR(),n);if(a)return{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:a.platform_login,identity_source:a.identity_source};let c=IR(n);return c?.platform_login?{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:c.platform_login,identity_source:c.identity_source}:i?{...i,platform_login:null,identity_source:ks(o)?"git_config":"git_env"}:c||(o.git_user_name||o.git_user_email?{...o,identity_source:"git_config"}:s||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}async function Os(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??ne,s=e.env??process.env,i=await xs(t,o,s,{runnerPlatform:e.runnerPlatform,home:e.home}),a=bR(i.git_user_name,i.git_user_email,i.identity_source,i.platform_login),l=(n?Mo(n):void 0)?.operator_identity_hash;if(!(r||l!==void 0&&l!==a||!l))return{commit:()=>{}};let p=n;return{operator:i,commit:()=>{p&&cc(p,a,Wn())}}}function Is(e){return e?!Mo(e)?.operator_identity_hash:!0}function sf(e){return!0}import{existsSync as Vb,readFileSync as Wb}from"node:fs";import{homedir as Pp}from"node:os";import{join as Kt,resolve as zb}from"node:path";import{basename as Ub,join as Bt}from"node:path";import{dirname as _f,resolve as Br}from"node:path";import{existsSync as PR}from"node:fs";import{homedir as uf}from"node:os";import{relative as lf,resolve as ve,sep as ft}from"node:path";var wR=["session_id","conversation_id","turn_id","generation_id","prompt.id","prompt_id","hook_event_name","event","source","status","stop_reason","reason","tool_name","tool","tool_use_id","skill_name","command_name","expansion_type","command_source","permission_mode","model","model_id","agent_id","agent_type","subagent_id","subagent_type","subagent_model","is_parallel_worker","effort","effort.level","duration_ms","duration","sandbox","failure_type","is_interrupt"],NR=["prompt","tool_input","tool_response","last_assistant_message","command"],vR=new Set;function MR(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return vR}}function vs(e){let t=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Zt.has(t.toLowerCase()):e?.collect_prompt===!0}function Fr(e,t){let n=ff(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?Zt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}function ff(e){return M("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||Ho(process.argv,e.debug===!0)||M("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}function LR(e){let t={};for(let n of wR){let r=$e(e,n);r!==void 0&&(t[n]=r)}return t}function $r(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=ve(e),r=ve(t),o=lf(r,n);return!o||o==="."?".":o.startsWith(`..${ft}`)||o===".."||ve(r,o)!==n?null:o.split(ft).join("/")}function df(e,t){let n=lf(ve(t),ve(e)).split(ft).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}function pf(e){return typeof e!="string"||e.length===0?null:ve(e).split(ft).join("/")}function HR(){let e=M("CURSOR_PROJECT_DIR");if(!e)return null;let t=ve(e);return PR(t)?t.split(ft).join("/"):null}function Ps(e,t){return $r(e,t)!==null}function UR(e,t){let n=ve(t??uf(),".cursor").split(ft).join("/");return Ps(e,n)}function DR(e,t,n){return t!==null&&Ps(e,t)?!0:t!==null&&UR(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&Ps(e,n.gitRoot)?!0:t===null}function mf(e,t){let n=pf(e.cwd);if(n!==null)return n;let r=ve(process.cwd()).split(ft).join("/"),o=HR();return DR(r,o,t)?r:o??r}function Ms(e,t={}){return mf(e,t)}function Ls(e,t=uf()){let n=ve(t).split(ft).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function af(e,t,n){let r=pf(n.launchCwd)??mf(t,n);e.cwd=Ls(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?$r(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}var gf="\u2026[truncated]\u2026",ws=Buffer.byteLength(gf,"utf8"),FR=8;function Sn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function cf(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}function $R(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}function jR(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=ws)return cf(e,t);let r=t-ws,o=Math.ceil(r/2),s=Math.floor(r/2);return`${cf(e,o)}${gf}${$R(e,s)}`}function Ns(e,t,n){if(typeof e=="string"){n.push({path:t,value:e,bytes:Buffer.byteLength(e,"utf8")});return}if(Array.isArray(e)){e.forEach((r,o)=>{Ns(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Ns(o,[...t,r],n)}function BR(e,t,n){let r=e;for(let s=0;s<t.length-1;s++){let i=t[s];if(i===void 0)return;r=(Array.isArray(r),r[i])}let o=t[t.length-1];if(!(o===void 0||r===null||typeof r!="object")){if(Array.isArray(r)){r[o]=n;return}r[o]=n}}var KR=256;function GR(e,t,n){let r=n,o=Math.max(n,e[0]?.bytes??n);for(;r<o;){let s=Math.ceil((r+o)/2),i=0;for(let a of e)a.bytes>s&&(i+=a.bytes-s);i>=t?r=s:o=s-1}return r}function VR(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let s=Sn(e);if(s<=t)return;let i=[];Ns(e,[],i),i.sort((u,d)=>d.bytes-u.bytes);let a=i.filter(u=>u.bytes>n);if(a.length===0)return;let c=GR(a,s-t,n),l=Math.max(n,Math.min(c,r-1));if(l>=r)return;r=l;for(let u of a)u.bytes>r&&BR(e,u.path,jR(u.value,r))}}function WR(e,t){let n=Math.max(0,t-KR),r=Object.keys(e).filter(s=>!s.startsWith("_")).map(s=>({key:s,bytes:Sn(e[s])})).sort((s,i)=>i.bytes-s.bytes),o=[];for(let{key:s}of r){if(Sn(e)<=n)break;delete e[s],o.push(s)}o.length>0&&(e._dropped_keys=o.slice(0,10))}function Ts(e,t){let n=Sn(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,VR(r,t,ws+FR),Sn(r)>t&&WR(r,t),r}function zR(e,t,n){if(!(n.promptCapture??vs()))return;let r=MR(n.runnerEvent);for(let o of NR){if(r.has(o))continue;let s=t[o];s!==void 0&&(e[o]=s)}}function jr(e,t,n={}){let r=ff(t);if(r==="full"){let s={...e};return delete s.cwd,delete s.transcript_path,af(s,e,n),Ts(s,Oo)}let o=LR(e);return af(o,e,n),r==="content"?(zR(o,e,n),Ts(o,Oo)):Ts(o,Ma)}function JR(e){return typeof e=="string"&&e.length>0}function Hs(e){let t=Br(e.home),n=Br(e.launchCwd),r=e.gitRoot?Br(e.gitRoot):null,o=new Set,s=[],i=null;e.inGitRepo&&JR(e.remote)&&r!==null&&r!==t&&(i=r,o.add(r)),n!==t&&!o.has(n)&&(s.push({scope:"cwd",dir:n}),o.add(n)),i!==null&&s.push({scope:"repo",dir:i});let a=null,c=r!==null&&$r(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&c){let l=_f(r);for(;;){let u=Br(l);if(u===t)break;let d=_f(u);if(d===u)break;if(e.hasProjectSpec(u)){s.push({scope:"parent",dir:u}),a=df(u,n);break}l=d}}return{anchors:s,parentRel:a}}import{existsSync as hf,readdirSync as YR,realpathSync as XR}from"node:fs";import{basename as qR,dirname as ZR,relative as QR,resolve as eC,sep as tC}from"node:path";var Us=400,Kr=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??et}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=eC(t).split(tC).join("/");return Ls(r,this.home)}let n=QR(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${Z(ZR(t))}/${qR(t)}`:n}claimFile(t){try{let n=XR(t);return this.seenRealpaths.has(n)?!1:(this.seenRealpaths.add(n),!0)}catch{return this.seenRealpaths.has(t)?!1:(this.seenRealpaths.add(t),!0)}}get atGlobalCap(){return this.truncated||this.components.length>=this.maxEntries}get pluginBudgetSpent(){return this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0}readEntries(t){if(!hf(t))return[];try{return YR(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(hf(t))return q(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),s=t-(this.pluginExpandRemaining??0);return{result:o,expanded:s}}finally{this.pluginExpandRemaining=r}}};import{existsSync as ti,readFileSync as bA,statSync as kA}from"node:fs";import{basename as Nd,join as Rt,relative as ni}from"node:path";var Id=Qe(Od());var CA=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],Td=CA.map(e=>Id.default.matcher(e,{dot:!0}));function AA(e){return e===""?!1:Td.some(t=>t(`${e}/`))}function Pd(e,t){if(t==="")return!1;if(e==="")return AA(t);let n=e.replace(/\/+$/,"");return Td.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}var ri=100*1024,xA=4;function OA(e){return e.length<=ri?e:`${e.slice(0,ri-1)}\u2026`}function IA(e){try{let t=bA(e),n=t.toString("utf8");return{hash:Z(t),length:t.length,text:OA(n)}}catch{return null}}var wd={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function TA(e){return e in wd?wd[e]:"UNSPECIFIED"}function $t(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=IA(t.absolutePath);if(!n)return!1;let r=t.name??Nd(t.absolutePath).replace(/\.(md|mdc|toml)$/i,""),o={kind:t.kind,name:r,path:e.componentPath(t.absolutePath),text:n.text,content_hash:n.hash,content_length:n.length,origin:t.origin,enabled:t.enabled},s=TA(t.kind);return s&&(o.trigger=s),t.attributes&&(o.attributes=t.attributes),e.push(o)}function PA(e,t,n){let r=ni(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?Nd(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function Ct(e,t){let{dir:n,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c}=t;oi(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c})}function oi(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u}=t;if(!(o>xA))for(let d of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(d.isDirectory()&&Pd(n.replace(/\\/g,"/"),ni(n,Rt(r,d.name)).replace(/\\/g,"/"))||d.isDirectory()&&u?.includes(Rt(r,d.name)))continue;if(c){if(!d.isDirectory())continue;let g=Rt(r,d.name,c);if(ti(g)){let S=ni(n,Rt(r,d.name)).replace(/\\/g,"/");$t(e,{absolutePath:g,kind:s,origin:i,enabled:a,name:S||d.name});continue}oi(e,{walkRoot:n,currentDir:Rt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(d.isDirectory()){oi(e,{walkRoot:n,currentDir:Rt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(!d.isFile()||!l)continue;let f=d.name.toLowerCase();if(!l.some(g=>f.endsWith(g)))continue;let p=Rt(r,d.name);$t(e,{absolutePath:p,kind:s,origin:i,enabled:a,name:PA(n,p,!0)})}}function vd(e){for(let t of e)if(ti(t))try{if(kA(t).size>0)return t}catch{continue}return e.find(t=>ti(t))}import{existsSync as ib,readFileSync as ab}from"node:fs";var Xr=Qe(lt(),1);var wA="<omitted>",NA=["package_name","package_spec","package_version","package_version_source"],Md=100,Ld=120,qr=[{raw:"tools",attr:"tools"},{raw:"autoApprove",attr:"auto_approve"},{raw:"auto_approve",attr:"auto_approve"},{raw:"alwaysAllow",attr:"always_allow"},{raw:"always_allow",attr:"always_allow"},{raw:"enabledTools",attr:"enabled_tools"},{raw:"enabled_tools",attr:"enabled_tools"},{raw:"disabledTools",attr:"disabled_tools"},{raw:"disabled_tools",attr:"disabled_tools"}],Hd=new Set(qr.map(e=>e.attr)),vA=["enabled","disabled"],MA=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],LA=new Set(["type","command","url","args","env","envVars","headers",...vA,...MA,...qr.map(e=>e.raw)]),HA=new Set(["transport","command_or_url","args","env_var_names","headers_present","auth","bearer_token_env_var","default_tools_approval_mode","env_http_header_names",...NA,...Hd,...[...Hd].map(e=>`${e}_truncated`)]);function Ud(e,t){for(let n of t)LA.has(n)||HA.has(n)||(e[n]=wA)}var UA=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,DA=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,FA=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,$A=/^bearer(?:\s+|$)/i;function Zr(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Dd(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function si(e){if(Array.isArray(e)){let n=[];for(let r of e){if(typeof r!="string"||r.length===0)continue;let o=r.split("=",1)[0]?.trim();o&&n.push(o)}return n}let t=Zr(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function At(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function jA(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,Xr.launchContainsCredentials)({kind:"url",url:e})||(0,Xr.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=kn([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,Xr.launchContainsCredentials)({kind:"url",url:r}):!0)}function Fd(e,t,n){jA(t,n)&&(e.launch_had_credentials=!0)}function BA(e){return FA.test(e)||$A.test(e)?"<redacted>":e.includes("://")?At(e):e}function $d(e){if(/^https?:\/\//i.test(e))return At(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${$d(e.slice(t+1))}`:BA(e)}function KA(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return UA.test(t)||DA.test(t)}function kn(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(KA(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push($d(r))}return t}function GA(e){let t=Dd(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Ld?r.slice(0,Ld):r))].sort();if(n.length!==0)return n.length>Md?{names:n.slice(0,Md),truncated:!0}:{names:n,truncated:!1}}function VA(e){let t=Zr(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,s]of Object.entries(t))o.length>0&&n.push(o),typeof s=="string"&&s.length>0&&r.push(s);return{headers:n,envVars:r}}function jd(e,t){let n=new Set;for(let{raw:r,attr:o}of qr){if(n.has(o)||!(r in t))continue;let s=t[r];if(o==="auto_approve"&&typeof s=="boolean"){e.auto_approve=s,n.add(o);continue}let i=GA(s);i&&(e[o]=i.names,i.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function Bd(e,t){let n=Zr(e),r={transport:t};if(!n)return r;Ud(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,s=typeof n.url=="string"?n.url:void 0,i=typeof n.serverUrl=="string"?n.serverUrl:void 0,a=o??s??i,c=Dd(n.args);a&&(r.command_or_url=At(a));let l=kn(c);l.length>0&&(r.args=l),Fd(r,a,c);let u=VA(n.env_http_headers),d=[...new Set([...si(n.env),...si(n.envVars),...si(n.env_vars),...u.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();d.length>0&&(r.env_var_names=d),u.headers.length>0&&(r.env_http_header_names=[...new Set(u.headers)].sort());for(let S of["headers","http_headers","env_http_headers"])if(n[S]!==void 0&&n[S]!==null){r.headers_present=!0;break}let f=typeof n.auth=="string"?n.auth:void 0;f&&(r.auth=f);let p=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;p&&(r.bearer_token_env_var=p);let g=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return g&&(r.default_tools_approval_mode=g),jd(r,n),r}function Kd(e){let t=Zr(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function ci(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return Z(JSON.stringify({name:e,attributes:r,enabled:n}))}function jt(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function bn(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*\\[([^\\]]*)\\]`,"m").exec(e);return n?.[1]?[...n[1].matchAll(/"([^"]*)"|'([^']*)'/g)].map(r=>r[1]??r[2]??"").filter(r=>r.length>0):[]}function ai(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function ii(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=jt(n[1]);return r.length>0?r:void 0}function WA(e,t){let n=[],r=i=>{for(let a of i.split(/[,\n]/)){let c=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(a);c?.[1]&&n.push([c[1],jt(c[2]??"")])}},o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let s=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
44
+ ${e}`);return s?.[1]&&r(s[1]),n}function Gd(e){return ai(e,"enabled")===!1?!1:ai(e,"disabled")!==!0}function zA(e,t){let n={};for(let{raw:r,attr:o}of qr){if(o==="auto_approve"){let i=ai(t,r);if(i!==void 0){n[r]=i;continue}}let s=bn(t,r);s.length>0&&(n[r]=s)}jd(e,n)}var JA=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,YA=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function XA(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
45
+ `)){let s=JA.exec(o);s?.[1]&&t.add(s[1])}for(let o of e.matchAll(YA))o[1]&&t.add(o[1]);return[...t]}function Vd(e,t){let n={transport:t};Ud(n,XA(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),s=r?jt(r[1]??""):void 0,i=o?jt(o[1]??""):void 0,a=s!==void 0&&s.length>0?s:i,c=bn(e,"args");a&&(n.command_or_url=At(a));let l=kn(c);l.length>0&&(n.args=l),Fd(n,a,c);let u=new Set;for(let b of e.split(`
46
+ `)){let I=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);I?.[1]&&u.add(I[1])}let d=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(d?.[1])for(let b of d[1].split(",")){let I=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);I?.[1]&&u.add(I[1])}let f=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
47
+ ${e}`);if(f?.[1])for(let b of f[1].split(`
48
+ `)){let I=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);I?.[1]&&u.add(I[1])}for(let b of bn(e,"env_vars"))u.add(b);let p=WA(e,"env_http_headers");for(let[,b]of p)b.length>0&&u.add(b);let g=ii(e,"bearer_token_env_var");g&&(u.add(g),n.bearer_token_env_var=g),u.size>0&&(n.env_var_names=[...u].sort()),p.length>0&&(n.env_http_header_names=[...new Set(p.map(([b])=>b))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let S=ii(e,"auth");S&&(n.auth=S);let A=ii(e,"default_tools_approval_mode");return A&&(n.default_tools_approval_mode=A),zA(n,e),n}var He=Qe(lt(),1);import{createHash as eb}from"node:crypto";import{join as xn}from"node:path";var qA=300,ZA=256;function Wd(e,t){if(!t)return e;let n=[...new Set([t,t.replace(/\\/g,"/")])].filter(o=>o.length>1),r=e;for(let o of n)r=r.split(o).join("~");return r}function Qr(e){let t=[],n="",r=null;for(let o of e){if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(/\s/.test(o)){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}function zd(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function QA(e){return zd(e,qA)}function Jd(e,t){let n=Wd(e.trim(),t),r=Qr(n);if(r.length===0)return"";let[o,...s]=r,i=At(o),a=kn(s);return QA([i,...a].join(" "))}function Yd(e,t){if(typeof e!="string")return null;let n=Wd(e.trim(),t),r=Qr(n)[0];if(!r)return null;let o=At(r);return o.length===0?null:zd(o,ZA)}function tb(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,He.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}function nb(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
49
+ `);return eb("sha512").update(t).digest("hex").slice(0,16)}function rb(e){let t=process.platform==="win32"?xn(M("LOCALAPPDATA")??e,"npm-cache"):xn(e,".npm"),n=M("npm_config_cache")??M("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}function Xd(e){return typeof e=="string"&&e.length>0&&e.length<=He.PACKAGE_FIELD_MAX?e:null}function ob(e,t,n){let r=nb(e);for(let o of rb(n)){let s=xn(o,"_npx",r),i=q(xn(s,"node_modules",...t.split("/"),"package.json"),{}),a=Xd(i.version);if(a!==null)return a;let c=q(xn(s,"package-lock.json"),{}),l=Xd(c.packages?.[`node_modules/${t}`]?.version);if(l!==null)return l}return null}function sb(e){return e.length<=He.PACKAGE_FIELD_MAX?e:`${e.slice(0,He.PACKAGE_FIELD_MAX-1)}\u2026`}function ui(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,He.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let s=(0,He.packageNameFromSpec)(o);return s===null?null:{package_name:s,package_spec:sb(o),...tb(o,ob(r,s,n))}}function qd(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=Qr(e.trim());return n===void 0?null:ui(n,r,t)}function eo(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;let n=e,r=Array.isArray(n.args)?n.args.filter(o=>typeof o=="string"):[];return ui(typeof n.command=="string"?n.command:null,r,t)}function Zd(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:ui(jt(n[1]??""),bn(e,"args"),t)}function cb(e){if(!e||typeof e!="object"||Array.isArray(e))return"unknown";let t=e;return typeof t.type=="string"&&t.type.length>0?t.type:typeof t.url=="string"?"http":typeof t.command=="string"?"stdio":"unknown"}function Qd(e,t,n){if(!e.claimFile(t))return;let o=e.readJson(t,{})?.mcpServers;if(!o||typeof o!="object")return;let s=e.componentPath(t);for(let[i,a]of Object.entries(o)){if(e.truncated)return;let c=cb(a),l=Bd(a,c);Object.assign(l,eo(a,e.home)??{});let u=Kd(a);e.push({kind:"MCP_SERVER",name:i,path:s,content_hash:ci(i,l,u),origin:n,enabled:u,attributes:l})}}function ep(e,t,n){if(!ib(t)||!e.claimFile(t))return;let r;try{r=ab(t,"utf8")}catch{return}let o=e.componentPath(t),s=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,i;for(;(i=s.exec(r))!==null;){if(e.truncated)return;let a=i[1]??i[2]??i[3];if(!a)continue;let c=r.slice(i.index+i[0].length),l=c.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),u=l===-1?c:c.slice(0,l),d="unknown";/^\s*url\s*=/m.test(u)?d="http":/^\s*command\s*=/m.test(u)&&(d="stdio");let f=Vd(u,d);Object.assign(f,Zd(u,e.home)??{});let p=Gd(u);e.push({kind:"MCP_SERVER",name:a,path:o,content_hash:ci(a,f,p),origin:n,enabled:p,attributes:f})}}import{existsSync as fb,readdirSync as db}from"node:fs";import{join as fe}from"node:path";function ub(e){if(e.prompt||e.type==="prompt")return"prompt";let t=e.command??e.bash??e.powershell??"";return/\bnpx\b/i.test(t)?"npx":/\.(sh|bash|zsh|js|mjs|cjs|ts|py)(\s|$|"|')/i.test(t)||/^(\.\/|~\/|\/|[A-Za-z]:[\\/])/.test(t.trim())?"script":"inline"}function lb(e){return Array.isArray(e.hooks)&&e.hooks.length>0?e.hooks:[{type:e.type,command:e.command,bash:e.bash,powershell:e.powershell,prompt:e.prompt}]}function li(e,t,n,r){let o=e.componentPath(t);for(let[s,i]of Object.entries(n))if(!(!Array.isArray(i)||e.truncated))for(let a of i){if(!a||typeof a!="object"||e.truncated)continue;let c=a;for(let l of lb(c)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??c.powershell??"",d=ub({type:l.type??c.type,command:l.command??c.command,bash:l.bash??c.bash,powershell:l.powershell??c.powershell,prompt:l.prompt??c.prompt}),f=typeof c.matcher=="string"?c.matcher:"",p=Z(u),g=f?`${s}:${f}:${d}:${p}`:`${s}:${d}:${p}`,S=`${s}|${f}|${d}|${u}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:Z(S),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:s,...f?{matcher:f}:{},action_kind:d,action_hash:p,...d!=="prompt"&&u.trim()?{command:Jd(u,e.home)}:{}}})}}}function fi(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||li(e,t,r.hooks,n)}var tp=50;function On(e,t,n,r){if(!fb(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(tp,()=>{Ct(e,{dir:fe(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Ct(e,{dir:fe(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Ct(e,{dir:fe(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});fi(e,fe(t,"hooks","hooks.json"),n),fi(e,fe(t,"hooks.json"),n);let i=e.components.length-o,a=s>=tp;return{componentCount:i,expandTruncated:a}}function In(e,t){e.push({kind:"PLUGIN",name:t.pluginKey,path:t.rowPath,content_hash:t.contentHash,origin:"user",enabled:t.enabled,attributes:{...t.marketplace?{marketplace:t.marketplace}:{},...t.version?{version:t.version}:{},scope:t.scope,component_count:t.componentCount,...t.expandTruncated?{expand_truncated:!0}:{}}})}function di(e){let t=e?.enabledPlugins;if(typeof t!="object"||t===null||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}function pb(e){let t=di(e.readJson(fe(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=tn(process.platform,e.home),o=e.readJson(n,{}),s={};if(o&&Object.keys(o).length>0)s=di(o);else for(let i of r)Object.assign(s,di(e.readJson(i,{})));return{...t,...s}}function np(e){let t=fe(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=pb(e),s=e.componentPath(t);for(let[i,a]of Object.entries(r)){if(e.truncated)return;let c=Array.isArray(a)?a:[a],l=c[0]??{},u=o[i]===!0,d=i.includes("@")?i.split("@").slice(1).join("@"):"",f=typeof l.version=="string"?l.version:"",p=typeof l.scope=="string"?l.scope:"user",g=`plugin:${i}`,S=0,A=!1;for(let b of c)if(typeof b.installPath=="string"&&b.installPath.length>0){let I=On(e,b.installPath,g,u);S+=I.componentCount,A=A||I.expandTruncated}In(e,{pluginKey:i,rowPath:s,enabled:u,scope:p,version:f||void 0,marketplace:d||void 0,componentCount:S,expandTruncated:A,contentHash:Z(`${i}|${f}|${p}|${u}|${S}`)})}}function mb(e){let t=e,n="";try{let r=db(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=fe(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),s=o[o.length-1];s&&(t=fe(e,s),n=s)}}catch{}return{installPath:t,version:n}}var gb=/^\d+$/;function _b(e){let t=e.filter(n=>!gb.test(n.pluginId));return t.length>0?t:e}function rp(e){let t=[{base:fe(e.home,".cursor/plugins/local"),scope:"local"},{base:fe(e.home,".cursor/plugins/cache"),scope:"cache"}];for(let{base:n,scope:r}of t)if(!e.truncated)for(let o of e.readEntries(n)){if(!o.isDirectory()||e.truncated)continue;if(r==="local"){let a=o.name,c=fe(n,o.name),l=`plugin:${a}`,{componentCount:u,expandTruncated:d}=On(e,c,l,!0);In(e,{pluginKey:a,rowPath:e.componentPath(c),enabled:!0,scope:"local",componentCount:u,expandTruncated:d,contentHash:Z(`${a}|local|${u}`)});continue}let s=o.name,i=[];for(let a of e.readEntries(fe(n,s))){if(!a.isDirectory())continue;let c=fe(n,s,a.name),{installPath:l,version:u}=mb(c);i.push({pluginId:a.name,installPath:l,version:u})}for(let a of _b(i)){if(e.truncated)break;let c=`${a.pluginId}@${s}`,l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=On(e,a.installPath,l,!0);In(e,{pluginKey:c,rowPath:e.componentPath(a.installPath),enabled:!0,scope:"cache",version:a.version||void 0,marketplace:s,componentCount:u,expandTruncated:d,contentHash:Z(`${c}|${a.version}|${u}`)})}}}import{existsSync as Eb}from"node:fs";var hb=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,pi="<path>",Sb=new RegExp(`${pi}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function to(e){let t=e.replace(hb,pi).replace(Sb,pi);return t.length>200?`${t.slice(0,200)}...`:t}var op=200,sp=200,mi=16*1024,ip=6,yb=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),Rb=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),Cb=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),Ab=new Set(["permissions"]),bb={claude:yb,cursor_sandbox:Rb,cursor_permissions:Cb,cursor_cli:Ab},kb=new Set(["allow","deny","ask"]);function dt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function no(e){return e.replace(/\\/g,"/")}function gi(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>gi(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${gi(t[r])}`).join(",")}}`}function xb(e){return Z(`${gi(e)}|settings1`)}function fp(e){let t=no(e);if(t.endsWith(".claude/settings.json")||t.endsWith(".claude/settings.local.json"))return"claude";if(t.endsWith(".cursor/sandbox.json"))return"cursor_sandbox";if(t.endsWith(".cursor/permissions.json"))return"cursor_permissions";if(t.endsWith(".cursor/cli-config.json")||t.endsWith(".cursor/cli.json"))return"cursor_cli"}function dp(e,t){if(e!=="claude")return{};let n=no(t);return n.endsWith("/.claude/remote-settings.json")?{profile:"claude",managedSource:"server"}:n.includes("/managed-settings.d/")&&n.endsWith(".json")?{profile:"claude",managedSource:"file_dropin"}:n.endsWith("/managed-settings.json")?{profile:"claude",managedSource:"file"}:{profile:"claude"}}function pp(e){let t=no(e).replace(/\/+$/,"");return t.length<=1?"":t}function mp(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}function Ob(e,t){let n=no(e);if(n==="~"||n.startsWith("~/"))return n;let r=pp(t);if(!r)return n;let o=n.slice(0,r.length);if(!(mp(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let i=n.slice(r.length);return i===""?"~":i.startsWith("/")?`~${i}`:n}var ap=new Map;function Ib(e){let t=ap.get(e);if(t!==void 0)return t;let n=pp(e),r=null;if(n){let o=n.split("/").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,mp(e)?"gi":"g")}return ap.set(e,r),r}function Tb(e,t){let n=Ib(t);return n?e.replace(n,"~"):e}function cp(e,t){return e.length<=sp?e:(t.truncated=!0,e.slice(0,sp))}function gp(e,t){return e.length<=op?e:(t.truncated=!0,e.slice(0,op))}function re(e,t,n,r){if(typeof e=="string"){if(t==="path")return cp(Ob(e,n),r);let o=t==="rule"?to(e):e;return cp(Tb(o,n),r)}if(typeof e=="number"||typeof e=="boolean"||e===null)return typeof e=="number"&&!Number.isFinite(e)?void 0:e;if(Array.isArray(e)){let o=gp(e,r),s=[];for(let i of o){let a=re(i,t,n,r);a!==void 0&&s.push(a)}return s}if(dt(e)){let o={};for(let[s,i]of Object.entries(e)){let a=re(i,t,n,r);a!==void 0&&(o[s]=a)}return o}}function up(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i="plain";kb.has(o)?i="rule":o==="additionalDirectories"&&(i="path");let a=re(s,i,t,n);a!==void 0&&(r[o]=a)}return r}function Pb(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){if(o==="files"&&Array.isArray(s)){let a=gp(s,n);r[o]=a.map(c=>{if(!dt(c))return re(c,"plain",t,n);let l={};for(let[u,d]of Object.entries(c)){let p=re(d,u==="path"?"path":"plain",t,n);p!==void 0&&(l[u]=p)}return l});continue}let i=re(s,"plain",t,n);i!==void 0&&(r[o]=i)}return r}function wb(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let a=re(s,o==="allowUnixSockets"?"path":"plain",t,n);a!==void 0&&(r[o]=a)}return r}function Nb(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i;o==="excludedCommands"?i=re(s,"rule",t,n):o==="filesystem"?i=re(s,"path",t,n):o==="network"?i=wb(s,t,n):o==="credentials"?i=Pb(s,t,n):i=re(s,"plain",t,n),i!==void 0&&(r[o]=i)}return r}function vb(e,t,n,r,o){return n==="claude"?e==="permissions"?up(t,r,o):e==="sandbox"?Nb(t,r,o):re(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?re(t,"path",r,o):re(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?re(t,"rule",r,o):re(t,"plain",r,o):e==="permissions"?up(t,r,o):re(t,"plain",r,o)}function Tn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function _i(e,t){return e?`${e}.${t}`:t}function hi(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let s=e[o];s!==null&&typeof s=="object"&&(t+1>=ip?(e.splice(o,1),r.add(n)):hi(s,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,s]of Object.entries(e))s!==null&&typeof s=="object"&&(t+1>=ip?(delete e[o],r.add(_i(n,o))):hi(s,t+1,_i(n,o),r))}function _p(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:Tn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))_p(o,_i(t,r),n)}function Mb(e,t,n){let r=Tn(e);if(r<=mi)return;t.truncated=!0;let o=[];for(_p(e,"",o);r>mi;){let s;for(let c of o)c.items.length>0&&(!s||c.bytes>s.bytes)&&(s=c);if(!s)break;let i=s.items.pop(),a=Tn(i)+(s.items.length>0?1:0);s.bytes-=a,r-=a,n.add(s.path)}for(;Tn(e)>mi;){let s,i=-1;for(let[a,c]of Object.entries(e)){let l=Tn(c);l>i&&(s=a,i=l)}if(s===void 0)break;delete e[s],n.add(s)}}function Lb(e,t,n){let r=bb[t],o={truncated:!1},s={},i=[];for(let c of Object.keys(e)){if(!r.has(c)){i.push(c);continue}let l=vb(c,e[c],t,n,o);l!==void 0&&(s[c]=l)}i.sort();let a=new Set;return hi(s,1,"",a),a.size>0&&(o.truncated=!0),Mb(s,o,a),{settings:s,keys_omitted:i,truncated:o.truncated,trimmed_paths:[...a].sort()}}function lp(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:xb(t.attributes),attributes:t.attributes};e.push(n)}function Si(e,t,n,r){if(!e.claimFile(t)||!Eb(t))return;let o=_a(t);if(!o.ok||!dt(o.value)){if(r.profile){let l=!o.ok&&o.reason==="read"?"read_error":"parse_error",u={profile:r.profile,[l]:!0};r.managedSource&&(u.managed_source=r.managedSource),lp(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}return}let s=o.value,i=s.hooks;if(dt(i)&&li(e,t,i,n),!r.profile)return;let a=Lb(s,r.profile,e.home),c={profile:r.profile,settings:a.settings,keys_omitted:a.keys_omitted};a.truncated&&(c.truncated=!0),a.trimmed_paths.length>0&&(c.trimmed_paths=a.trimmed_paths),r.managedSource&&(c.managed_source=r.managedSource),lp(e,{kind:r.kind,absPath:t,origin:n,attributes:c})}import{existsSync as Hb}from"node:fs";import{join as Ue}from"node:path";var hp=".claude/skills/synced",Sp=".claude/plugins/synced";function Ep(e){return[Ue(e,hp),Ue(e,Sp)]}function ro(e){return typeof e=="string"&&e.length>0?e:void 0}function yp(e){let t=Ue(e.home,hp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ue(t,n.name),o=e.readJson(Ue(r,"manifest.json"),{}),s=new Map((o?.skills??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let a=Ue(r,i.name,"SKILL.md");if(!i.isDirectory()||!Hb(a))continue;let c=s.get(i.name),l=ro(c?.source),u=ro(c?.creatorType);$t(e,{absolutePath:a,kind:"SKILL",origin:"user",enabled:!0,name:i.name,attributes:{scope:"synced",...l?{source:l}:{},...u?{creator_type:u}:{}}})}}}function Rp(e){let t=Ue(e.home,Sp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ue(t,n.name),o=e.readJson(Ue(r,"manifest.json"),{}),s=new Map((o?.plugins??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.truncated)return;if(!i.isDirectory()||i.name.startsWith("."))continue;let a=s.get(i.name),c=ro(a?.marketplaceName),l=ro(a?.version),u=c?`${i.name}@${c}`:i.name,d=Ue(r,i.name),{componentCount:f,expandTruncated:p}=On(e,d,`plugin:${u}`,!0);In(e,{pluginKey:u,rowPath:e.componentPath(d),enabled:!0,scope:"synced",version:l,marketplace:c,componentCount:f,expandTruncated:p,contentHash:Z(`${u}|${l??""}|synced|${f}`)})}}}function Db(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:s}=t;for(let i of n.skillRoots)Ct(e,{dir:Bt(r,i),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:Ep(e.home)});for(let i of n.dirs)Ct(e,{dir:Bt(r,i.dir),kind:i.kind,origin:o,enabled:!0,extensions:i.extensions});for(let i of n.memory){let a=vd(i.map(c=>Bt(r,c)));a&&$t(e,{absolutePath:a,kind:"MEMORY",origin:o,enabled:!0,name:Ub(a)})}for(let i of Zc(n))Si(e,Bt(r,i),o,{kind:"SETTINGS",profile:fp(i)});for(let i of n.mcpJson??[])Qd(e,Bt(r,i),o);for(let i of n.mcpToml??[])ep(e,Bt(r,i),o);if(s){if(n.managed){for(let i of sr(n.managed,process.platform,e.home))if(i.toLowerCase().endsWith(".json")){let a=dp(n.managed,i);Si(e,i,o,{kind:"MANAGED_SETTINGS",...a})}}n.plugins==="claude"?(np(e),Rp(e),yp(e)):n.plugins==="cursor"&&rp(e)}}function Cp(e,t){try{let n=new Kr(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)Db(n,{layout:r,levelDir:t.levelDir,origin:t.origin,includeMachineWide:t.includeMachineWide});return{scopeRef:t.scopeRef,anchor:t.levelDir,components:n.components,truncated:n.truncated}}catch{return}}function Ei(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let c=Cp(t,{layouts:Object.values(vt),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:et,scopeRef:""});c&&(r.user=c)}let s=n.inGitRepo===!0,i=null,a=n.launchCwd;if(a!==void 0){let c=Object.values(it),l=Hs({launchCwd:a,gitRoot:n.gitRoot,inGitRepo:s,remote:n.remote,home:t,hasProjectSpec:u=>eu(c,u)});i=l.parentRel;for(let u of l.anchors){let d=bs(u.dir);if(o!==void 0&&!o(u.scope,d))continue;let f=Cp(t,{layouts:c,levelDir:u.dir,origin:u.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:Us,scopeRef:d});f&&(r[u.scope]=f)}r.parent||(i=null)}return{scopes:r,parentRel:i,cwdInGitRepo:s}}function yi(e,t,n={}){let r=n.truncated===!0,o=hn(e),s=new Set(e.map(u=>Re(u.path,u.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let a=[],c=t;for(let u of e){let d=Re(u.path,u.name);c[d]!==Dr(u)&&a.push(u)}let l=[];if(!r){for(let u of Object.keys(c))if(!s.has(u)){let d=rf(u);d&&l.push(d)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:a,removed:l,unchanged:a.length===0&&l.length===0}}var bp=2*1024*1024,Fb=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function Ri(e,t,n){let r=new Set(t.map(s=>Re(s.path,s.name))),o=[];for(let s of e)s.text!==void 0&&(n.has(s.content_hash)||r.has(Re(s.path,s.name))||o.push(s));return o}function Ci(e,t,n){let r=new Set(e);for(let s of t)r.add(s);let o=new Set(n.map(s=>s.content_hash));return[...r].filter(s=>o.has(s))}function Ap(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function kp(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function Ai(e,t=bp){let n=[],r=[];for(let u of e)Fb.has(u.kind)?n.push(u):r.push(u);r.sort((u,d)=>(u.text?.length??0)-(d.text?.length??0));let o=[...n,...r],s=[],i=2,a=0,c=0,l=[];for(let u of o){let d=s.length>0?1:0,f=Ap(u)+d;if(i+f<=t){s.push(u),i+=f,u.text!==void 0&&l.push(u.content_hash);continue}if(u.text!==void 0){let p=kp(u),g=Ap(p)+d;if(i+g<=t){s.push(p),i+=g,a+=1;continue}}c+=1}return{components:s,textDeferredCount:a,droppedCount:c,textHashesSent:l}}function bi(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:kp(n))}var $b=["user","cwd","repo","parent"];function ki(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,s=[];for(let T of $b){let O=t.scopes[T];if(!O)continue;let K=n(T,O.scopeRef),D=K.components,x=yi(O.components,D,{forceFull:D===void 0,truncated:O.truncated}),N=new Set(K.textHashes),H=Ri(O.components,x.upserts,N),m=bi([...x.upserts,...H],N);s.push({scope:T,walk:O,delta:x,outgoing:m,outgoingKeys:new Set(m.map(k=>Re(k.path,k.name))),deliveredTextHashes:N,cachedComponents:D})}let i=s.flatMap(T=>T.outgoing),a=Ai(i,o),c=new Set(a.components.map(T=>Re(T.path,T.name))),l=[],u=[],d=[],f=[],p=[],g=[],S=[];for(let T of s){let{scope:O,walk:K,delta:D}=T;g.push(...K.components),l.push(O);let x=a.components.filter(k=>T.outgoingKeys.has(Re(k.path,k.name))),N=[...T.outgoingKeys].some(k=>!c.has(k)),H=D.truncated||N;H?d.push(O):D.full&&u.push(O),f.push(...x),!D.full&&!H&&p.push(...D.removed);let m=D.full?{}:{...T.cachedComponents??{}};if(!H)for(let k of D.removed)delete m[Re(k.path,k.name)];for(let k of x)m[Re(k.path,k.name)]=Dr(k);S.push({scope:O,scopeRef:K.scopeRef,components:m,textHashes:Ci(T.deliveredTextHashes,x.filter(k=>k.text!==void 0).map(k=>k.content_hash),K.components),collectedAtMs:r,included:x.length>0||D.removed.length>0&&!H||D.full})}let A={user_spec_hash:hn(g),user_spec_count:g.length,user_spec_truncated:d.length>0};l.length>0&&(A.user_spec_scopes=l,A.user_spec_full_scopes=u,A.user_spec_truncated_scopes=d,A.user_spec_cwd_in_git_repo=t.cwdInGitRepo),u.length>0&&u.length===l.length&&(A.user_spec_full=!0),f.length>0&&(A.user_spec=f),p.length>0&&(A.user_spec_removed=p),a.textDeferredCount>0&&(A.user_spec_text_deferred=a.textDeferredCount);let b=t.scopes.cwd;b&&(A.user_spec_cwd_scope_ref=b.scopeRef);let I=t.scopes.repo;I&&(A.user_spec_repo_scope_ref=I.scopeRef);let P=t.scopes.parent;return P&&(A.user_spec_parent_scope_ref=P.scopeRef,t.parentRel&&(A.user_spec_parent_rel=t.parentRel)),{fields:A,scopes:S}}var oo={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function xi(e){return e==="cwd"||e==="repo"||e==="parent"}function Pn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Oi(e){return!Pn(e)||!Pn(e.components)||!Object.values(e.components).every(t=>typeof t=="string")||!Array.isArray(e.text_hashes)||!e.text_hashes.every(t=>typeof t=="string")?!1:typeof e.collected_at_ms=="number"&&Number.isFinite(e.collected_at_ms)}function xp(e){return jb(e)}function Op(e){return Bb(e)}function Ip(e){return Kb(e)}function jb(e){if(!Pn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function Bb(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Tp(e,t){if(!Pn(e))return;let n=e[t];return Oi(n)?n:void 0}function Kb(e){if(!Pn(e))return{};let t={};for(let[n,r]of Object.entries(e))Oi(r)&&(t[n]=r);return t}function Ii(e,t=20){let n=[];for(let[r,o]of Object.entries(e))Oi(o)&&n.push([r,o]);return n.sort((r,o)=>o[1].collected_at_ms-r[1].collected_at_ms),Object.fromEntries(n.slice(0,t))}var Jb=["allow","deny","ask"];function io(e){let t=q(e,{}),n=[];for(let r of Jb)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:to(o),mode:r});return{model:t.model??"",permissionKeys:n}}function Yb(e){let{serverManaged:t,fileBased:n}=tn(process.platform,e),r=io(t);if(r.model||r.permissionKeys.length>0)return r;let o="",s=[];for(let i of n){let a=io(i);a.model&&(o=a.model),s.push(...a.permissionKeys)}return{model:o,permissionKeys:s}}function Xb(e){let t=new Set,n=[];for(let r of e){let o=`${r.mode}\0${r.key}`;t.has(o)||(t.add(o),n.push(r))}return n}var qb=10,Zb="self-config-cache.json",wp=5;function Gt(){return M("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function Qb(){return M("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}var ek={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function tk(e,t=ne){let n=ek[e];if(!n||n.length===0)return null;let r=async o=>{let s=n[o];if(s===void 0)return null;let a=((await t(s,["--version"],2e3)).split(`
50
+ `)[0]??"").trim();return a||r(o+1)};return r(0)}function nk(e=Pp()){return Kt(e,".ev-ai","agent-hook",Zb)}function rk(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
51
+ `);return Z(n)}function so(e,t,n=!1){let r=rk(e),o=e.length;return t===r?n?{hash:r,count:o,truncated:n}:{hash:r,count:o}:n?{hash:r,count:o,entries:e,truncated:n}:{hash:r,count:o,entries:e}}function Ti(e,t,n=[]){let r=0,o=!1,s=new Set;for(let i of[...t.map(a=>Kt(e,a)),...n]){let a=zb(i);if(s.has(a))continue;s.add(a);let c=Ro(i);c.present&&(o=!0,r+=c.size)}return o?{present:!0,size:r}:{present:!1,size:0}}function ok(e){return Vb(e)?Se(Wb(e,"utf8"),{}):{}}function sk(e,t){try{ce(e,`${JSON.stringify(t)}
52
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: self-config cache write failed open: ${r}`)}}function ik(e,t,n){if(t==="user")return{components:xp(e.user_spec_components),textHashes:Op(e.user_spec_text_hashes)};if(!xi(t))return{components:void 0,textHashes:[]};let r=Tp(e[oo[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}function ak(e,t,n,r){let o={...e,send_count:n};for(let s of Object.keys(t)){let i=t[s];i.entries!==void 0&&(o[s]=i.hash)}if(r){o.user_spec_layout_version=wp,r.home&&(o.user_spec_collected_at_ms=r.home.collectedAtMs,r.home.included&&(o.user_spec=r.hash,o.user_spec_components=r.home.components),o.user_spec_text_hashes=r.home.textHashes);for(let s of r.project){if(!xi(s.scope))continue;let i=oo[s.scope],a=Ip(o[i]),c=a[s.scopeRef];a[s.scopeRef]={components:s.included?s.components:c?.components??{},text_hashes:s.textHashes,collected_at_ms:s.collectedAtMs},o[i]=Ii(a)}}return o}async function Np(e,t=process.cwd(),n=Pp(),r={}){let o=e==="claude",s=r.gitRoot??t,i=await tk(e),a="",c=[];if(o){let H=Yb(n),m=io(Kt(n,".claude/settings.json")),k=io(Kt(t,".claude/settings.local.json"));a=H.model||k.model||m.model,c=Xb([...H.permissionKeys,...m.permissionKeys,...k.permissionKeys]).slice(0,200)}let l={present:!1,size:0},u=H=>{let m=[],k=!1;for(let U of H){let de=ha(Kt(n,U));if(m=m.concat(de.entries),k=k||de.truncated,m.length>=et){m=m.slice(0,et),k=!0;break}}return{entries:m,truncated:k}},d=nk(n),f=ok(d),p=f[e]??{},g=(p.send_count??0)+1,S=g>0&&g%qb===0,A=H=>S?void 0:p[H],b=u(ct.skills),I=u(ct.subagents),P=u(ct.commands),T=u(ct.rules),O={skills:so(b.entries,A("skills"),b.truncated),subagents:so(I.entries,A("subagents"),I.truncated),commands:so(P.entries,A("commands"),P.truncated),rules:so(T.entries,A("rules"),T.truncated)},K={runner_platform:e,config_scope:"user",cli_version:i,claude_version:o?i:null,model:o&&a||null,permission_keys:c,user_scope:{skills:O.skills,subagents:O.subagents,commands:O.commands,rules:O.rules,memory:Ti(n,ct.memory),settings:Ti(n,ct.settings,tu(n)),mcp:Ti(n,ct.mcp)},local_settings:o?Ro(Kt(t,".claude/settings.local.json")):l},D=null,x=r.nowMs??Date.now();if(!Gt()){let H=p.user_spec_layout_version!==wp,m=Ei(e,n,{launchCwd:Qb()?void 0:r.launchCwd,gitRoot:s,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(m.scopes).length>0){let k=ki({collected:m,cacheFor:(U,de)=>H?{components:void 0,textHashes:[]}:ik(p,U,de),nowMs:x});Object.assign(K,k.fields),D={hash:k.fields.user_spec_hash,home:k.scopes.find(U=>U.scope==="user")??null,project:k.scopes.filter(U=>U.scope!=="user")}}}let N=ak(p,O,g,D);return{config:K,commit:()=>{f[e]=N,sk(d,f)}}}import{homedir as Ok}from"node:os";import{join as Lp}from"node:path";function bt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{join as ao}from"node:path";function ck(e){return ao(e,".ev-ai","agent-hook","js","signed-v1")}function uk(e){return ao(ck(e),"scopes")}function vp(e,t){return ao(uk(e),t)}function Mp(e){return ao(e,"attempts")}function Pi(e){return String(e).padStart(10,"0")}var lk=/^(\d{10})$/,fk=/^(\d{10})\.done$/,dk=/^[0-9a-f]{128}$/,pk=64,Fp=["check_ms","download_ms","install_ms","total_ms"],mk=36e5;async function $p(e,t,n=!1){let r=Mp(t),o=await Yi(e,r),s=new Map,i=new Map,a=Hp(o,lk),c=Hp(o,fk),l=async f=>{let p=await Dp(e,Lp(r,gk(f)));return p&&s.set(f,{record:hk(p.value),mtimeMs:p.mtimeMs}),p!==void 0},u=async f=>{let p=Sk((await Dp(e,Lp(r,_k(f))))?.value);return p&&i.set(f,p),p!==void 0};if(!n)return await Promise.all([...a.map(l),...c.map(u)]),{claims:s,dones:i};await Promise.all([Up(a,l),Up(c,u)]);let d=wn(s);return d<wn(i)&&c.includes(d)&&await u(d),{claims:s,dones:i}}function Hp(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}async function Up(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}function wn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}function jp(e){if(e.record!=="empty"&&e.record.started_at){let t=Date.parse(e.record.started_at);if(Number.isFinite(t))return t}return e.mtimeMs}function Bp(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of Fp){let r=e[n];r!==void 0&&(t[n]=r)}return t}function gk(e){return Pi(e)}function _k(e){return`${Pi(e)}.done`}async function Dp(e,t){let n;try{n=await e.stat(t)}catch(o){if(Ot(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>go)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>go?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}function hk(e){if(!bt(e))return"empty";let t={};return typeof e.started_at=="string"&&(t.started_at=e.started_at),(e.owner==="bootstrap"||e.owner==="refresh")&&(t.owner=e.owner),e.resync===!0&&(t.resync=!0),t}function Sk(e){if(!bt(e))return;let t=e;if(typeof t.finished_at!="string"||typeof t.outcome!="string"||typeof t.interval_s!="number"||!Number.isFinite(t.interval_s))return;let n=yk(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...Ek(t)}}function Ek(e){let t={};typeof e.started_at=="string"&&Number.isFinite(Date.parse(e.started_at))&&(t.started_at=e.started_at);for(let n of Fp){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=mk&&(t[n]=r)}return t}function yk(e){if(!bt(e))return;let t=e;if(t.kind==="bundled")return t.why==="server"||t.why==="bootstrap_failed"?{kind:"bundled",why:t.why}:void 0;if(t.kind==="cached"&&typeof t.digest=="string"&&dk.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&Rk(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}function Rk(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==pk||t.toString("base64")!==e))return t.toString("hex")}function kk(e){return e==="bootstrap"?3e3:6e4}function xk(e,t){let n=wn(e.claims);if(n===0)return;let r=wn(e.dones),o=e.claims.get(n),s=e.dones.get(n);if(o&&!s){let a=jp(o),c=o.record==="empty"?void 0:o.record.owner,l=kk(c)+3e4;if(t-a>l)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:Kp(e.dones.get(r)?.selection)}}if(r===0)return;let i=e.dones.get(r);if(i)return{n:r,latest_claim:n,outcome:i.outcome,finished_at:i.finished_at,selection_version:Kp(i.selection),...Bp(i)}}async function Gp(e,t,n){try{let r=await $p(Xi(),vp(e,t),!0);return xk(r,n)}catch{return}}function Kp(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}function Ik(e=process.env){if(Object.values(Ua).some(n=>e[n]))return"plugin";let t=e.npm_lifecycle_script?.trim().split(/\s+/)[0]?.replace(/^["']|["']$/g,"");return e.npm_lifecycle_event==="npx"&&t===Ee?"npx":null}async function Vp(e=Ok()){let t=ms()?.launcherScope;if(!t)return{};let n=await Gp(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}function Vt(e,t,n){let r={installation_id:n.installationId};n.platformAgentId&&(r.platform_agent_id=n.platformAgentId),n.sessionId&&(r.session_id=n.sessionId),n.turnId&&(r.turn_id=n.turnId);let o={schema_version:nt,event:e,timestamp:Wn(),session_id:n.sessionId||null,turn_id:n.turnId||null,installation_id:n.installationId,platform:n.runnerPlatform,platform_agent_id:n.platformAgentId||null,runner_event:n.runnerEvent||null,agent_hook_version:Be,hook_delivery:Ik(),host_arch:process.arch,node_version:process.version,policy_version:null,policy_capabilities:[],...n.promptCaptureSource!==void 0?{prompt_capture_source:n.promptCaptureSource}:{},...n.telemetry!==void 0?{telemetry_source:n.telemetry.source}:{},correlation:r,payload:t},s=ms();return s&&(o.launcher_version=s.launcherVersion,o.hook_source=s.hookSource,o.hook_fallback_reason=s.fallbackReason??null,o.launcher_scope_match=hl(n.collectorUrl,s.launcherScope)),e==="session_start"&&(n.launcher_scope&&(o.launcher_scope=n.launcher_scope),n.launcher_attempt&&(o.launcher_attempt=n.launcher_attempt)),o}import{existsSync as Wp}from"node:fs";import{spawn as zp}from"node:child_process";import{fileURLToPath as Pk}from"node:url";import{gzipSync as Tk}from"node:zlib";function wi(e){return M("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<La?{body:e}:{body:Tk(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}function co(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}function Ni(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}var Nn="__post",vn="__work";async function wk(e,t,n={}){if(Gt())return e;let r=await xs(n.gitRoot??process.cwd(),ne,process.env,{runnerPlatform:t,home:n.home}),o=bt(e.self_config)?e.self_config:{};return{...e,self_config:{...o,runner_platform:typeof o.runner_platform=="string"?o.runner_platform:t,operator:r}}}function Nk(e,t){let n=bt(e.payload)?Object.keys(e.payload):[],r=e.correlation&&typeof e.correlation=="object"?Object.keys(e.correlation):[];return JSON.stringify({event:e.event,schema_version:e.schema_version,agent_hook_version:e.agent_hook_version,host_arch:e.host_arch,node_version:e.node_version,build_ms:e.build_ms,body_bytes:t,correlation_keys:r,payload_keys:n})}function Jp(e){switch(e){case"session_start":return wa;case"session_end":return Na;case"tool_invoked":case"skill_invoked":return xo;default:return xo}}function vk(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
53
+ ${n}`}function Yp(e,t=[],n=process.execPath,r=import.meta.url,o=Wp){if(tr(n))return{command:n,args:[e,...t]};let s=Pk(r);return o(s)?{command:n,args:[s,e,...t]}:{command:n,args:[e,...t]}}function Mk(e=process.execPath,t=import.meta.url,n=Wp){let r=process.argv.includes("--debug")?["--debug"]:[];return Yp(Nn,r,e,t,n)}function Lk(e){let t=e.indexOf(`
54
+ `);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}async function Xp(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();hc(n,t)}catch{}}function qp(e){let t=e instanceof Error?e.message:String(e);return{code:e!==null&&typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:void 0,message:t}}async function uo(e,t=fetch){let n=await e(),r=Lk(n);if(!r){_e.error("send fail code=bad-frame message=detached post stdin was not framed");return}let{meta:o,body:s}=r,i=wi(s),a=co(i.contentEncoding);try{let c=await t(o.url,{method:"POST",headers:a,body:i.body,signal:AbortSignal.timeout(Number(o.timeoutMs))});if(!c.ok){let l=(await c.text()).slice(0,200).replace(/[\n\r]/g,"");_e.error(`send fail http=${c.status} code=${c.status} message=${l}`);return}_e.info(`send ok http=${c.status}`),await Xp(c,o.url)}catch(c){let l=qp(c);_e.error(`send fail code=${l.code??"(none)"} message=${l.message}`)}}async function Hk(e,t,n,r=fetch){let o=Jp(e),s=wi(t),i=co(s.contentEncoding),a=Ni(s.body);E(`POST event=${e} url=${Tt(n)} size=${a} encoding=${s.contentEncoding??"identity"} platform=${process.platform}`);let c=Date.now(),l=performance.now();try{let u=await r(n,{method:"POST",headers:i,body:s.body,signal:AbortSignal.timeout(o)});if(!u.ok&&s.contentEncoding==="gzip"&&(u.status===400||u.status===415)){try{await u.text()}catch{}E(`POST gzip rejected http=${u.status} \u2014 retrying uncompressed`),u=await r(n,{method:"POST",headers:co(),body:t,signal:AbortSignal.timeout(o)})}let d=Date.now()-c;if(Es(performance.now()-l),u.ok)return E(`POST outcome=ok elapsed_ms=${d} http=${u.status}`),_e.info(`send ok http=${u.status}`),await Xp(u,n),!0;let f=(await u.text()).slice(0,200).replace(/[\n\r]/g,"");return E(`POST outcome=fail elapsed_ms=${d} http=${u.status} body=${f}`),_e.error(`send fail http=${u.status} code=${u.status} message=${f}`),!1}catch(u){let d=Date.now()-c;Es(performance.now()-l);let f=qp(u);return E(`POST outcome=fail elapsed_ms=${d} http=000 body=${f.message}`),_e.error(`send fail http=0 code=${f.code??"(none)"} message=${f.message}`),!1}}async function Zp(e,t,n,r,o){try{let s=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});s.on("error",()=>{}),s.stdin.on("error",()=>{});let i=!1;return await new Promise(a=>{let c=setTimeout(()=>{if(!i){E(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`);try{s.stdin.destroy()}catch{}}a()},va),l=()=>{i=!0,clearTimeout(c),a()};s.stdin.end(n,()=>l()),s.stdin.once("error",()=>l())}),s.unref(),s}catch(s){let i=s instanceof Error?s.message:String(s);return E(`WARN: ${o} spawn failed open: ${i}`),null}}async function Uk(e,t,n,r=zp,o=Mk){let s=Jp(e),i=vk(n,s,t),{command:a,args:c}=o();return Zp(a,c,i,r,"detached post")}async function Qp(e,t,n=zp,r=Yp){let{command:o,args:s}=r(vn,t);return Zp(o,s,e,n,"detached work")}async function Wt(e,t,n,r,o,s,i){if(!o)return E("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),_e.error("send fail code=missing message=collector URL missing"),!1;if(!er(o))return E(`WARN: collector URL blocked (https required): ${Tt(o)}`),_e.error("send fail code=blocked message=collector URL blocked"),!1;let a=performance.now(),c=await wk(t,n.runnerPlatform,i),l=performance.now(),u=r(e,c,{...n,collectorUrl:o});s!==void 0&&(u.build_ms=Math.max(0,Date.now()-s));let d=Tl({w4:a,w4e:l,w5:performance.now()},process.env,void 0,n.telemetry?.enabled===!0);d&&(u.perf=d);let f=JSON.stringify(u),p=`${f}
55
+ `,g=M("EV_AI_HOOK_DEBUG");g==="full"?E(`DEBUG envelope=${f}`):g==="1"&&E(`DEBUG summary=${Nk(u,Ni(p))}`);let S=process.argv.includes(vn),A=M("EV_AI_HOOK_SYNC")==="1";return xr(n.runnerEvent,n.runnerPlatform)||S||A?Hk(e,p,o):(await Uk(e,p,o),!1)}import{createReadStream as Dk}from"node:fs";import{stat as Fk}from"node:fs/promises";import{basename as $k,resolve as jk}from"node:path";import{createInterface as Bk}from"node:readline";var Kk=1024*1024;function Gk(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&$k(t).endsWith(".jsonl")}async function em(e){if(!e||!Gk(e))return null;try{let t=jk(e),n=await Fk(t);if(!n.isFile())return null;let r=Math.max(0,n.size-Kk),o=[],s=Bk({input:Dk(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let i of s)i.length!==0&&o.push(i);r>0&&o.length>0&&o.shift();for(let i=o.length-1;i>=0;i--){let a=o[i];if(a)try{let c=JSON.parse(a);if(c.type!=="assistant")continue;let l=c.message;if(!l||typeof l!="object")continue;let u=l.model;if(typeof u=="string"&&u.length>0)return u}catch{continue}}return null}catch{return null}}function lo(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:Fr(e.manifest.manifest,e.manifest.hookConfig),telemetry:rm(e)}}function rm(e){return Ec(e.manifest.localTelemetry,e.manifest.hookConfig)}function Ln(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}function Mi(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:vs(e.manifest.hookConfig)}}async function om(e){let t=Date.now();await nx(e);let{gitRoot:n}=e.manifest;await Hi(e,n);let r=Mi(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:jr(e.hookInput,e.manifest.manifest,r),envelopeFields:lo(e),launchCwd:Ms(e.hookInput,r),home:Wk()}}function tm(e){try{return ye(Vk(e))}catch{return null}}function sm(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function nm(e,t){let n=e.replaceAll("\\","/");if(!sm(n))return null;let r=ye(e),o=ye(t),s=tm(e)??r,i=tm(t)??o;return s.startsWith(`${i}/`)?s.slice(i.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}function im(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),s=nm(e,t)??(sm(r)?null:r),i=nm(e,n);return{repositorySourcePath:s,userSourcePath:i}}function vi(e,t,n,r,o){return am(e,im(n,t.gitRoot,t.home),r,o)}function am(e,{repositorySourcePath:t,userSourcePath:n},r,o){let s=t??n,i=s===null?null:o(s),a=i!==null&&s!==null?zk({installableKind:r,sourcePath:s,nativeKey:i,inRepository:t!==null,platformAgentId:e.platformAgentId,installationId:e.manifest.installationId}):void 0;return{sourcePath:s,nativeKey:i,componentReference:a}}function zk(e){try{let t=e.inRepository?Xk(e.platformAgentId,e.sourcePath):(0,B.installationRootExternalKey)(e.installationId,(0,B.userConfigRootFromPath)(e.sourcePath));return t?(0,B.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}function cm(e){let t=e.policyFindings;return t===void 0||t.length===0?{}:{policy_findings:t,...e.policyJudgeSpawnMs!==void 0?{policy_judge_spawn_ms:e.policyJudgeSpawnMs}:{}}}function Li(e,t,n){return Wt("tool_invoked",{...n,...cm(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,Vt,e.manifest.collectorUrl,t.buildStartedAtMs,Ln(e,t.home))}function Jk(e){return Ku(e.runnerEvent,e.runnerPlatform)?[]:cu(e.hookInput)}function Yk(e,t){return Li(e,t,{})}var um=new Set([...Object.values(St),".github"]);function Xk(e,t){let n=e.indexOf(":");if(n<=0)return null;let r=e.slice(0,n),o=t.replaceAll("\\","/").split("/").filter(Boolean),s=o.findIndex(i=>um.has(i));return s<0?null:`${r}:${o.slice(0,s+1).join("/")}`}var lm=".codex/config.toml",qk=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",lm]]);function Zk(e,t,n,r,o,s,i){if(e===null||t===null||!(i!==null||/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||/^MCP:.+__.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`))return;let c=s.find(S=>S.name.toLowerCase()===t.toLowerCase()),l=c?qk.get(c.source):o==="codex"?lm:void 0,u=c?.sourcePath??l;if((c?.scope==="user"||l!==void 0)&&u)try{let S=(0,B.userConfigRootFromPath)(u);return(0,B.buildComponentReference)({installationRootExternalKey:(0,B.installationRootExternalKey)(r,S),installableKind:B.ComponentKind.INTERFACE,sourcePath:u,nativeKey:c?.name??t})}catch{return}if(n===null)return;let f=n.indexOf(":");if(f<=0||f===n.length-1)return;let p=n.slice(f+1),g=p.replaceAll("\\","/").split("/").at(-1);if(!(g===void 0||!um.has(g)))try{return(0,B.buildComponentReference)({installationRootExternalKey:n,installableKind:B.ComponentKind.INTERFACE,sourcePath:p,nativeKey:t})}catch{return}}function Qk(...e){for(let t of e)if(t)return t;return null}function xt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return E(`WARN: ${n} failed open: ${r}`),t}function ex(e){let t={present:!1,size:0},n={hash:"",count:0};return{config:{runner_platform:e,config_scope:"user",cli_version:null,claude_version:null,model:null,permission_keys:[],user_scope:{skills:n,subagents:n,commands:n,rules:n,memory:t,settings:t,mcp:t},local_settings:t},commit:()=>{}}}function tx(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var kt=new Set,Mn=null;async function nx(e){if(Gt())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(kt.has(t))return;if(!Is(n)){kt.add(t);return}let r=rn({sessionId:e.sessionId,hostname:ar()});if(sf(r)){if(Mn){await Mn;return}Mn=(async()=>{if(kt.has(t)||!Is(n)){kt.add(t);return}if(!uc(n)){kt.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:i}=e.manifest,a=String(e.runnerPlatform),{operatorResolved:c,fields:l}=await fm(e,r,Ne("git",()=>br(i)),Ne("operator",()=>Os({gitRoot:i,installationStorePath:n,forceResend:!1,runnerPlatform:a}))),u={...l,self_config:tx(a,c.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await Wt("session_start",u,lo(e),Vt,e.manifest.collectorUrl,s,Ln(e)),o&&(c.commit(),kt.add(t))}finally{lc(n)}})().finally(()=>{Mn=null}),await Mn}}async function Hi(e,t,n){try{e.platformAgentId=await vu(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,n,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);E(`WARN: derivePlatformAgentId failed open: ${o}`)}}async function fm(e,t,n,r){let[o,s,i,a,c]=await Promise.allSettled([n,Ne("virt",()=>Va()),Ne("cloud",()=>wl(t)),Ne("host_env",()=>za(rm(e).enabled)),r]),l=xt(o,null,"gitSnapshot"),u=xt(s,"","detectVirt"),d=xt(i,null,"probeCloud"),f=xt(a,{},"hostEnv"),p=xt(c,{commit:()=>{}},"resolveOperatorForSend");return await Hi(e,e.manifest.gitRoot,l),{operatorResolved:p,fields:{identity:{host:ar(),context:t,virt:u||null,cloud:d,git:l},host_env:f,env_vars:Dl()}}}async function rx(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=rn({sessionId:e.sessionId,hostname:ar()}),o=String(e.runnerPlatform),s=Mi(e),i=Ms(e.hookInput,s),a=Ne("git",()=>br(n)),c=Vp().catch(()=>({})),l=Gt()?Promise.resolve({commit:()=>{}}):Ne("operator",()=>Os({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o})),u=fm(e,r,a,l),[d,f]=await Promise.allSettled([Ne("mcp_declared",()=>Rs(e.manifest.manifest,n,o)),a.catch(()=>null).then(K=>Ne("self_config",()=>Np(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:i,inGitRepo:e.manifest.inGitRepo,remote:K?.remote??null})))]),{operatorResolved:p,fields:g}=await u,S=xt(d,[],"mcpDeclared"),A=xt(f,ex(o),"selfConfig"),b=A.config,I=L(e.hookInput,"model");I&&(b.model=I);let P={...g,mcp:{declared:S},self_config:b,run_meta:{trigger:e.hookSource||"startup"},hook_input:jr(e.hookInput,e.manifest.manifest,{...s,launchCwd:i})},T=await c;await Wt("session_start",P,{...lo(e),...T},Vt,e.manifest.collectorUrl,t,Ln(e))&&(A.commit(),p.commit(),kt.add(e.manifest.installationId))}async function ox(e){let t=Date.now(),[,n]=await Promise.all([Hi(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?em(L(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=Qk(L(e.hookInput,"status"),L(e.hookInput,"stop_reason"),L(e.hookInput,"reason"),fn(L(e.hookInput,"error")),r==="stop"?$e(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),s=jr(e.hookInput,e.manifest.manifest,Mi(e));n&&(s.model=n),r!=="stopfailure"&&Fr(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&s.last_assistant_message===void 0&&(s.last_assistant_message=""),await Wt("session_end",{status:o,...n?{model:n}:{},hook_input:s},lo(e),Vt,e.manifest.collectorUrl,t,Ln(e))}async function sx(e){let t=Jk(e),n=Uu(e.hookInput),r=Bu(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&Fr(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let s=await om(e);await Promise.all([o?Yk(e,s):void 0,t.length===0?void 0:ix(e,s,t),n.length===0?void 0:ax(e,s,n)])}function dm(e,t,n,r){let o=r??au({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),s=vi(e,t,o,B.ComponentKind.SKILL,B.nativeKeyForSkillPath);if(s.sourcePath!==null&&Jo(s.sourcePath)?.toLowerCase()===n.toLowerCase())return s.componentReference===void 0?{}:{componentReference:s.componentReference};let i=r??Du({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),a=vi(e,t,i,B.ComponentKind.COMMAND,B.nativeKeyForCommandPath);return a.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:a.nativeKey,...a.componentReference===void 0?{}:{componentReference:a.componentReference}}}function ix(e,t,n){let r=hr(e.hookInput.tool_input);return Promise.all(n.map(o=>{let s=dm(e,t,o,r);return Li(e,t,{tool_name:"Skill",skill_name:o,...s.commandName===void 0?{}:{command_name:s.commandName},...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}function ax(e,t,n){return Promise.all(n.map(r=>{let o=Mu({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),s=vi(e,t,o,B.ComponentKind.RULE,B.nativeKeyForRulePath),i=s.nativeKey??Hu(r);return Li(e,t,{tool_name:"Rule",rule_name:i,...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}var cx=[{kind:B.ComponentKind.SKILL,nativeKeyFn:B.nativeKeyForSkillPath},{kind:B.ComponentKind.RULE,nativeKeyFn:B.nativeKeyForRulePath},{kind:B.ComponentKind.COMMAND,nativeKeyFn:B.nativeKeyForCommandPath}];function ux(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Xo(e.hookInput);if(r===null)return n.skillName===null?{}:dm(e,t,n.skillName,null);let o=im(r,t.gitRoot,t.home);for(let s of cx){let i=am(e,o,s.kind,s.nativeKeyFn);if(i.nativeKey!==null)return{...i.componentReference===void 0?{}:{componentReference:i.componentReference},...s.kind===B.ComponentKind.RULE?{ruleName:i.nativeKey}:{},...s.kind===B.ComponentKind.COMMAND?{commandName:i.nativeKey}:{}}}return{}}var lx=/mcp/i;function fx(e,t,n,r){let o=lx.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let s=o?qd(t,n):eo(r.declaredConfig,n);return s===null?{}:Object.fromEntries(Object.entries(s).filter(i=>typeof i[1]=="string").map(([i,a])=>[`mcp_${i}`,a]))}async function dx(e){let t=await om(e),n=Wu(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,s=Yo(e.hookInput),i=Yd(s,t.home),a=Ju(e.hookInput),c=Gu(e.runnerEvent),l=c===!1?Yu(e.hookInput,e.runnerEvent):null,u=fn(L(e.hookInput,"mcp_server_name")),d=u!==null||r!==null&&Or(r)?await Rs(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(()=>[]):[],{mcpServer:f,mcpTool:p}=qu(r,d.map(K=>K.name),u??""),g=Zk(r,f,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),d,u),S=g===void 0?ux(e,t,n):{},A=f===null?null:Ul(f,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),b=fx(e,s,t.home,{hasMcpIdentity:!!f||!!p,declaredConfig:A}),I=g??S.componentReference,P=S.ruleName??n.ruleName,T=S.commandName??n.commandName,O=zu(e.hookInput);await Wt("tool_invoked",{tool_name:r,skill_name:o,...P?{rule_name:P}:{},...T?{command_name:T}:{},success:c,duration_ms:a,...i?{executable:i}:{},...l?{failure_reason:l}:{},...f?{mcp_server:f}:{},...p?{mcp_tool:p}:{},...b,...I?{component_reference:I}:{},...O?{subagent_type:O}:{},...cm(e),hook_input:t.hookInput},t.envelopeFields,Vt,e.manifest.collectorUrl,t.buildStartedAtMs,Ln(e,t.home))}async function pm(e){switch(ze("w3"),e.internalEvent){case"session_start":await rx(e);return;case"session_end":await ox(e);return;case"skill_invoked":await sx(e);return;case"tool_invoked":await dx(e);return;default:return}}import{mkdirSync as px,readdirSync as mx,readFileSync as gx,statSync as mm,unlinkSync as _x,writeFileSync as hx}from"node:fs";import{homedir as fo}from"node:os";import{join as Ui}from"node:path";var Sx="turns",gm=1440*60*1e3,Ex=100,yx=new Set(["stop","stopfailure","sessionend"]);function Di(e=fo()){return Ui(ge(e),Sx)}function _m(e,t){return Ui(e,qt(t))}function Rx(e,t=Date.now()){let n;try{n=mx(e)}catch{return}let r=0;for(let o of n){if(r>=Ex)return;r+=1;try{let s=Ui(e,o);t-mm(s).mtimeMs>gm&&_x(s)}catch{}}}function Cx(e,t,n=fo()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let s=Di(n);px(s,{recursive:!0}),hx(_m(s,r),o,"utf8")}catch{}}function Ax(e,t=fo()){let n=e.trim();if(!n)return"";try{let r=_m(Di(t),n);return Date.now()-mm(r).mtimeMs>gm?"":gx(r,"utf8").trim()}catch{return""}}function hm(e,t,n,r=fo()){let o=t.trim(),s=yx.has(n.trim().toLowerCase());return s&&Rx(Di(r)),o?(Cx(e,o,r),o):s?Ax(e,r):""}async function bx(e,t,n){let r=t??await zn(nr),o=Se(r,{}),s=await bc(process.cwd(),{sessionId:ln(o)});if(ze("w2"),!s)return;let i=Vu(o,s.manifest.platform,n),a=is(e,i.runnerEvent);if(!a){E(`WARN: unknown hook event '${i.runnerEvent}'; skipping telemetry`);return}let c={hookInput:o,sessionId:i.sessionId,turnId:hm(i.sessionId,i.turnId,i.runnerEvent),runnerEvent:i.runnerEvent,runnerPlatform:i.runnerPlatform,hookSource:i.hookSource,internalEvent:a,manifest:s,platformAgentId:s.platformAgentId};await pm(c)}function kx(e,t=!1){if(M("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,s=un(r,o,void 0,n.runner);return xr(o,s)?!0:t}function Sm(e,t){let n=Zn(e),r=Se(t,{}),o=n.event??ss(r);return Ka()||ju(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}function ym(e){return ul(is(e.parsed.event,e.runnerEvent))}async function Em(e,t,n){let{parsed:r}=e,o=n??ds(r.slot);if(!o&&!ym(e)){let s=fs(r.cap),i=gl(s);if(!i){ps(s);return}o=i}try{await bx(r.event,t,r.runner)}finally{o&&Pr(o)}}async function Rm(e=process.argv.slice(2)){if(fr(e),Rl(),ze(e[0]===vn?"w0":"h0"),_l(),M("EV_AI_HOOK_JUDGE")==="1"){try{await zn(nr)}catch{}return Eo(),0}if(e[0]===Nn){try{await uo(Qt)}catch{}return 0}if(e[0]===vn){try{let n=await Qt();ze("w1");let r=Sm(e.slice(1),n);if(!r)return 0;await Em(r,n)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: detached work failed open: ${r}`)}return 0}let t;try{let n=await zn(nr);ze("h1");let r=Sm(e,n);if(!r)return 0;let{parsed:o,hookInput:s,runnerEvent:i}=r;if(t=ds(o.slot),!nl(s,i,o.runner))return 0;if(ze("h2"),kx(r))await Em(r,n,t);else{let a=t||ym(r)?void 0:fs(o.cap);if(a===void 0||pl(a)){ze("h3"),Ol();let c=await Qp(n,e);t&&c?.pid!==void 0&&fl(t,c.pid)}else ps(a)}}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: hook failed open: ${r}`)}finally{t&&Pr(t),Eo()}return 0}function po(){E("Usage: ev-ai-agent-hook <configure|install|migrate-to-plugin|update|uninstall|--version>"),E(" configure [--url <\u2026/{orgToken}/hook>]"),E(" (manifest only \u2014 pair with marketplace plugins)"),E(" install --url <\u2026/{orgToken}/hook>"),E(" [--delivery npx|binary|local] [--force]"),E(" [--no-claude] [--no-cursor] [--no-codex]"),E(" (fallback: merge hooks into .claude / .cursor / .codex configs)"),E(" (writes collector_url to shared manifest; hook commands use --runner only)"),E(" migrate-to-plugin"),E(" (strip ev-ai file hooks; keep collector manifest)"),E(" update (refresh binary pins from a local build; leaves hook configs alone)"),E(" uninstall"),E("Hook mode: --runner <platform> [--url <\u2026/hook>|--token <orgToken>] [event]"),E(" (--url/--token optional overrides; else collector_url from manifest)")}function Cm(e){return e.includes("--help")||e.includes("-h")}async function Px(e=process.argv.slice(2)){fr(e);let[t,...n]=e;if(t===Nn){try{await uo(Qt)}catch{}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${Be}
56
+ `),0):t==="configure"?Cm(n)?(po(),0):(await Wc(Nc(n)),0):t==="install"?Cm(n)?(po(),0):(await Gc(vc(n)),0):t==="migrate-to-plugin"?(await Jc(),0):t==="update"?(await Vc(),0):t==="uninstall"?(await Yc(),0):t==="help"||t==="--help"||t==="-h"?(po(),0):t===void 0?(po(),1):Rm(e)}function wx(e,t,n=xx){if(!t)return!1;try{return e===Tx(Ox(t)).href?!0:n(Ix(e))===n(t)}catch{return!1}}wx(import.meta.url,process.argv[1])&&process.env.VITEST===void 0&&Px().then(e=>{process.exit(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);E(t),process.exit(1)});export{wx as isCliEntrypoint,Px as main};