@ev-ai/agent-hook 1.3.8 → 1.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hook.mjs CHANGED
@@ -1,49 +1,52 @@
1
1
  import { createRequire as __createRequire } from 'node:module';
2
2
  const require = __createRequire(import.meta.url);
3
3
 
4
- var Rp=Object.create;var pi=Object.defineProperty;var Cp=Object.getOwnPropertyDescriptor;var Ap=Object.getOwnPropertyNames;var bp=Object.getPrototypeOf,Op=Object.prototype.hasOwnProperty;var Ge=(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 xp=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ap(t))!Op.call(e,o)&&o!==n&&pi(e,o,{get:()=>t[o],enumerable:!(r=Cp(t,o))||r.enumerable});return e};var Ve=(e,t,n)=>(n=e!=null?Rp(bp(e)):{},xp(t||!e||!e.__esModule?pi(n,"default",{value:e,enumerable:!0}):n,e));var Yn=z(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.MCP_MISSING_LAUNCH_SERIALIZED=Z.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;Z.foldMcpName=Qa;Z.buildMcpFamilyCanonicalKey=Ig;Z.launchContainsCredentials=kg;Z.serializeMcpLaunchIdentity=ec;Z.hashMcpLaunchIdentity=Wt;Z.projectMcpMissingLaunchIdentity=wg;Z.projectMcpLaunchIdentity=Mg;Z.maskMcpLaunchForDisplay=Lg;Z.normalizeMcpToolNames=Hg;var xg=Ge("node:crypto");Z.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";Z.MCP_MISSING_LAUNCH_SERIALIZED=`${Z.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function Ue(e){return e.toLocaleLowerCase("en-US")}function Qa(e){return Ue(e)}function Ig(e){return`interface:${Qa(e)}`}var Za=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),Tg=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function Ct(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function kg(e){return e.kind==="url"?Pg(e.url):e.kind==="command"?e.arguments.some(t=>Tg.test(t)):!1}function Pg(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(Za.has(Ue(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=Ue(i.split("=",1)[0]??"");return Za.has(a)})}}function ec(e){if(e.kind==="url")return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",Ct(Ue(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>Ue(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",Ct(Ue(e.command)),String(t.length),...t.map(Ct)].join("|")}return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",Ct(e.installationRootExternalKey),Ct(e.sourcePath),Ct(e.nativeKey)].join("|")}function Wt(e){return(0,xg.createHash)("sha256").update(e).digest("hex")}var Ng=Wt(Z.MCP_MISSING_LAUNCH_SERIALIZED);function wg(){return{kind:"unknown",arguments:[],serialized:Z.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:Ng}}function Mg(e){let t=ec(e);return e.kind==="url"?{kind:"url",url:Ue(e.url),arguments:[],serialized:t,contentHash:Wt(t)}:e.kind==="command"?{kind:"command",command:Ue(e.command),arguments:[...e.arguments].map(n=>Ue(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:Wt(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:Wt(t)}}var vg=/^(https?:\/\/)([^/?#]*@)/i;function Lg(e){return e.replace(vg,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}function Hg(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 qn=z(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.PACKAGE_FIELD_MAX=void 0;Te.npxExecBin=tc;Te.packageNameFromSpec=Xn;Te.pinnedPackageVersionFromSpec=nc;Te.pinnedPackageVersionFromNpx=Vg;Te.npxPackageSpecs=rc;Te.PACKAGE_FIELD_MAX=128;var Ug=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,Dg=new Set(["-p","--package"]),Fg=new Set(["-c","--call"]),$g=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),jg=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),Kg=/^--no-/;function Bg(e){return jg.has(e)||Kg.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 Gg=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function Xn(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 Ug.test(n)?n:null}function nc(e){let t=Xn(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return Gg.test(n)?n:void 0}function Vg(e,t){for(let n of rc(e,t)){let r=nc(n);if(r!==void 0)return r}}function rc(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(Fg.has(l))return[];if(Dg.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||Bg(l))){if($g.has(l)){i+=1;continue}return[]}}return o.length>0?o.every(i=>Xn(i)!==null)?o:[]:s===null||Xn(s)===null?[]:[s]}});var oc=z(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.McpPackageEcosystem=void 0;ot.resolveMcpPackageIdentity=o_;var zg=Yn(),Ro=qn();ot.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var Wg=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,Jg=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,Yg=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function Xg(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}var qg=new Set(["--from","--spec"]),Zg=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"]),Qg=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"]),e_=/^--no-/;function t_(e,t){let n=Xg(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(qg.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||Qg.has(l)||e_.test(l))){if(Zg.has(l)){i+=1;continue}return null}}return o??s}function n_(e){if(e.length===0||e.length>Ro.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!Jg.test(r)||!Yg.test(o)?null:{ecosystem:ot.McpPackageEcosystem.PYPI,packageName:r,version:o}}function r_(e){let t=(0,Ro.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return Wg.test(n)?{ecosystem:ot.McpPackageEcosystem.NPM,packageName:t,version:n}:null}function o_(e){if(e?.kind!=="command"||(0,zg.launchContainsCredentials)(e))return;for(let n of(0,Ro.npxPackageSpecs)(e.command,e.arguments)){let r=r_(n);if(r!==null)return r}let t=t_(e.command,e.arguments);if(t!==null)return n_(t)??void 0}});var lc=z(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.EMPTY_NPM_PUBLISHER=void 0;De.isNpmRegistryPublisher=i_;De.displayPublisherName=a_;De.classifyMcpProvenance=__;var ac=Yn(),Co=qn();De.EMPTY_NPM_PUBLISHER="npm:";var sc="npm:",s_=/^[A-Za-z0-9._-]+$/;function i_(e){return e.startsWith(sc)&&e!==De.EMPTY_NPM_PUBLISHER&&s_.test(e.slice(sc.length))}function a_(e){if(!(e==null||e===""||e===De.EMPTY_NPM_PUBLISHER))return e}function ic(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 c_(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 Ao(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}function u_(e){let t=Ao(e),n=c_(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||ic(t)||n!==void 0&&ic(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}function l_(e){let t=Ao(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}function f_(e){let t=Ao(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}function cc(e){let t={kind:"url",url:e};if((0,ac.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||u_(n.hostname))return{origin:"UNKNOWN"};let r=l_(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:f_(n)}}catch{return{origin:"UNKNOWN"}}}var uc="mcp-remote";function d_(e,t){if(e===uc)return t.find(n=>/^https?:\/\//i.test(n))}function p_(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}function m_(e,t,n){let r=d_(e,t);return r!==void 0?cc(r):e===uc?{origin:"UNKNOWN"}:p_(e,n)}function g_(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 __(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,ac.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return cc(t.url);let r=(0,Co.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,Co.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let s=m_(o,t.arguments,e.publisherName),i=typeof e.packageName=="string"?(0,Co.packageNameFromSpec)(e.packageName):null;return i!==null&&i===o&&s.packageName!==void 0?{...s,packageName:i,packageKey:i}:s}return g_(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}});var dc=z(Zn=>{"use strict";Object.defineProperty(Zn,"__esModule",{value:!0});Zn.mcpServerToolSegmentForms=fc;Zn.mcpServerNameMatchesToolSegment=h_;function fc(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}function h_(e,t){let n=t.toLowerCase();return fc(e).some(r=>r.toLowerCase()===n)}});var pc=z(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.parseFrontmatterField=Re.parseFrontmatterDescription=Re.usableCatalogText=void 0;var S_=/^(?:>|\|)[-+]?$/,E_=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,y_=e=>{let t=e?.trim()??"";if(!(t.length===0||S_.test(t)))return t};Re.usableCatalogText=y_;var R_=e=>(0,Re.parseFrontmatterField)(e,"description");Re.parseFrontmatterDescription=R_;var C_=(e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return b_(n[1],t)};Re.parseFrontmatterField=C_;var A_=e=>e.replace(/^["']|["']$/g,"");function b_(e,t){let n=e.split(`
5
- `),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=E_.exec(s);if(!i){let p=A_(s).trim();return(0,Re.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(`
6
- `).split(/\n{2,}/).map(p=>p.split(`
7
- `).map(g=>g.trim()).filter(Boolean).join(" ")).filter(p=>p.length>0).join(`
4
+ var bm=Object.create;var ho=Object.defineProperty;var Om=Object.getOwnPropertyDescriptor;var xm=Object.getOwnPropertyNames;var Im=Object.getPrototypeOf,km=Object.prototype.hasOwnProperty;var s=(e,t)=>ho(e,"name",{value:t,configurable:!0}),qe=(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 J=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Tm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of xm(t))!km.call(e,o)&&o!==n&&ho(e,o,{get:()=>t[o],enumerable:!(r=Om(t,o))||r.enumerable});return e};var Ze=(e,t,n)=>(n=e!=null?bm(Im(e)):{},Tm(t||!e||!e.__esModule?ho(n,"default",{value:e,enumerable:!0}):n,e));var yr=J(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.MCP_MISSING_LAUNCH_SERIALIZED=te.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;te.foldMcpName=Xc;te.buildMcpFamilyCanonicalKey=_h;te.launchContainsCredentials=Sh;te.serializeMcpLaunchIdentity=qc;te.hashMcpLaunchIdentity=En;te.projectMcpMissingLaunchIdentity=Rh;te.projectMcpLaunchIdentity=Ah;te.maskMcpLaunchForDisplay=bh;te.normalizeMcpToolNames=Oh;var gh=qe("node:crypto");te.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";te.MCP_MISSING_LAUNCH_SERIALIZED=`${te.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function Ve(e){return e.toLocaleLowerCase("en-US")}s(Ve,"foldCase");function Xc(e){return Ve(e)}s(Xc,"foldMcpName");function _h(e){return`interface:${Xc(e)}`}s(_h,"buildMcpFamilyCanonicalKey");var Yc=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),hh=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function jt(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(jt,"lengthPrefixed");function Sh(e){return e.kind==="url"?Eh(e.url):e.kind==="command"?e.arguments.some(t=>hh.test(t)):!1}s(Sh,"launchContainsCredentials");function Eh(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(Yc.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 i=e.split("?",2)[1];return i===void 0?!1:i.split("&").some(a=>{let c=Ve(a.split("=",1)[0]??"");return Yc.has(c)})}}s(Eh,"urlContainsCredentials");function qc(e){if(e.kind==="url")return[te.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",jt(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[te.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",jt(Ve(e.command)),String(t.length),...t.map(jt)].join("|")}return[te.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",jt(e.installationRootExternalKey),jt(e.sourcePath),jt(e.nativeKey)].join("|")}s(qc,"serializeMcpLaunchIdentity");function En(e){return(0,gh.createHash)("sha256").update(e).digest("hex")}s(En,"hashMcpLaunchIdentity");var yh=En(te.MCP_MISSING_LAUNCH_SERIALIZED);function Rh(){return{kind:"unknown",arguments:[],serialized:te.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:yh}}s(Rh,"projectMcpMissingLaunchIdentity");function Ah(e){let t=qc(e);return e.kind==="url"?{kind:"url",url:Ve(e.url),arguments:[],serialized:t,contentHash:En(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:En(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:En(t)}}s(Ah,"projectMcpLaunchIdentity");var Ch=/^(https?:\/\/)([^/?#]*@)/i;function bh(e){return e.replace(Ch,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}s(bh,"maskMcpLaunchForDisplay");function Oh(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n.sort((r,o)=>r<o?-1:r>o?1:0),n}s(Oh,"normalizeMcpToolNames")});var Ar=J(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.PACKAGE_FIELD_MAX=void 0;Me.npxExecBin=Zc;Me.packageNameFromSpec=Rr;Me.pinnedPackageVersionFromSpec=Qc;Me.pinnedPackageVersionFromNpx=Mh;Me.npxPackageSpecs=eu;Me.PACKAGE_FIELD_MAX=128;var xh=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,Ih=new Set(["-p","--package"]),kh=new Set(["-c","--call"]),Th=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),Ph=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),Nh=/^--no-/;function wh(e){return Ph.has(e)||Nh.test(e)}s(wh,"booleanFlag");function Zc(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}s(Zc,"npxExecBin");var Lh=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function Rr(e){if(e.length===0||e.length>Me.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return xh.test(n)?n:null}s(Rr,"packageNameFromSpec");function Qc(e){let t=Rr(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return Lh.test(n)?n:void 0}s(Qc,"pinnedPackageVersionFromSpec");function Mh(e,t){for(let n of eu(e,t)){let r=Qc(n);if(r!==void 0)return r}}s(Mh,"pinnedPackageVersionFromNpx");function eu(e,t){let n=Zc(e);if(n===null)return[];let r=[...t];if(n==="npm"){let a=r[0]?.toLowerCase();if(a!=="exec"&&a!=="x")return[];r=r.slice(1)}let o=[],i=null;for(let a=0;a<r.length;a+=1){let c=r[a]??"";if(c==="--"){i=r[a+1]??null;break}if(!c.startsWith("-")){i=c;break}let u=c.indexOf("="),f=u===-1?c:c.slice(0,u);if(kh.has(f))return[];if(Ih.has(f)){let l=u===-1?r[a+1]:c.slice(u+1);l!==void 0&&l.length>0&&o.push(l),u===-1&&(a+=1);continue}if(!(u!==-1||wh(f))){if(Th.has(f)){a+=1;continue}return[]}}return o.length>0?o.every(a=>Rr(a)!==null)?o:[]:i===null||Rr(i)===null?[]:[i]}s(eu,"npxPackageSpecs")});var tu=J(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.McpPackageEcosystem=void 0;Et.resolveMcpPackageIdentity=Wh;var vh=yr(),es=Ar();Et.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var Uh=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,Hh=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,Dh=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function Fh(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}s(Fh,"pythonRunnerBin");var $h=new Set(["--from","--spec"]),jh=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"]),Bh=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"]),Kh=/^--no-/;function Gh(e,t){let n=Fh(e);if(n===null)return null;let r=[...t];if(n==="uv"){if(r[0]?.toLowerCase()!=="tool"||r[1]?.toLowerCase()!=="run")return null;r=r.slice(2)}else if(n==="pipx"){if(r[0]?.toLowerCase()!=="run")return null;r=r.slice(1)}let o=null,i=null;for(let a=0;a<r.length;a+=1){let c=r[a]??"";if(c==="--"){i=r[a+1]??null;break}if(!c.startsWith("-")){i=c;break}let u=c.indexOf("="),f=u===-1?c:c.slice(0,u);if($h.has(f)){let l=u===-1?r[a+1]:c.slice(u+1);l!==void 0&&l.length>0&&(o=l),u===-1&&(a+=1);continue}if(!(u!==-1||Bh.has(f)||Kh.test(f))){if(jh.has(f)){a+=1;continue}return null}}return o??i}s(Gh,"pythonRunnerSpec");function Vh(e){if(e.length===0||e.length>es.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!Hh.test(r)||!Dh.test(o)?null:{ecosystem:Et.McpPackageEcosystem.PYPI,packageName:r,version:o}}s(Vh,"pypiIdentityFromSpec");function zh(e){let t=(0,es.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return Uh.test(n)?{ecosystem:Et.McpPackageEcosystem.NPM,packageName:t,version:n}:null}s(zh,"npmIdentityFromSpec");function Wh(e){if(e?.kind!=="command"||(0,vh.launchContainsCredentials)(e))return;for(let n of(0,es.npxPackageSpecs)(e.command,e.arguments)){let r=zh(n);if(r!==null)return r}let t=Gh(e.command,e.arguments);if(t!==null)return Vh(t)??void 0}s(Wh,"resolveMcpPackageIdentity")});var au=J(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.EMPTY_NPM_PUBLISHER=void 0;ze.isNpmRegistryPublisher=Yh;ze.displayPublisherName=Xh;ze.classifyMcpProvenance=sS;var ou=yr(),ts=Ar();ze.EMPTY_NPM_PUBLISHER="npm:";var nu="npm:",Jh=/^[A-Za-z0-9._-]+$/;function Yh(e){return e.startsWith(nu)&&e!==ze.EMPTY_NPM_PUBLISHER&&Jh.test(e.slice(nu.length))}s(Yh,"isNpmRegistryPublisher");function Xh(e){if(!(e==null||e===""||e===ze.EMPTY_NPM_PUBLISHER))return e}s(Xh,"displayPublisherName");function ru(e){let t=e.split(".").map(Number);return t.length!==4||t.some(n=>!Number.isInteger(n)||n<0||n>255)?!1:t[0]===0||t[0]===10||t[0]===127||t[0]===169&&t[1]===254||t[0]===172&&(t[1]??0)>=16&&(t[1]??0)<=31||t[0]===192&&t[1]===168}s(ru,"privateIpv4");function qh(e){let t=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(e);if(t?.[1])return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(e);if(!n)return;let r=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16);return`${r>>8&255}.${r&255}.${o>>8&255}.${o&255}`}s(qh,"ipv4MappedAddress");function ns(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}s(ns,"normalizedHost");function Zh(e){let t=ns(e),n=qh(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||ru(t)||n!==void 0&&ru(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}s(Zh,"privateHostname");function Qh(e){let t=ns(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}s(Qh,"publisherHost");function eS(e){let t=ns(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}s(eS,"publicOrigin");function su(e){let t={kind:"url",url:e};if((0,ou.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||Zh(n.hostname))return{origin:"UNKNOWN"};let r=Qh(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:eS(n)}}catch{return{origin:"UNKNOWN"}}}s(su,"classifyUrl");var iu="mcp-remote";function tS(e,t){if(e===iu)return t.find(n=>/^https?:\/\//i.test(n))}s(tS,"remoteUrlChild");function nS(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}s(nS,"thirdPartyPackage");function rS(e,t,n){let r=tS(e,t);return r!==void 0?su(r):e===iu?{origin:"UNKNOWN"}:nS(e,n)}s(rS,"classifyRegistryPackage");function oS(e){let t=e.replaceAll("\\","/");return t.startsWith("~/")||t.startsWith("/")||/^[A-Za-z]:\//.test(t)?!1:t.startsWith("./")||t.startsWith("../")||t==="scripts"||t.startsWith("scripts/")}s(oS,"isRepoRelativeCommand");function sS(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,ou.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return su(t.url);let r=(0,ts.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,ts.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let i=rS(o,t.arguments,e.publisherName),a=typeof e.packageName=="string"?(0,ts.packageNameFromSpec)(e.packageName):null;return a!==null&&a===o&&i.packageName!==void 0?{...i,packageName:a,packageKey:a}:i}return oS(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}s(sS,"classifyMcpProvenance")});var uu=J(Cr=>{"use strict";Object.defineProperty(Cr,"__esModule",{value:!0});Cr.mcpServerToolSegmentForms=cu;Cr.mcpServerNameMatchesToolSegment=iS;function cu(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}s(cu,"mcpServerToolSegmentForms");function iS(e,t){let n=t.toLowerCase();return cu(e).some(r=>r.toLowerCase()===n)}s(iS,"mcpServerNameMatchesToolSegment")});var lu=J(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.parseFrontmatterField=Ie.parseFrontmatterDescription=Ie.usableCatalogText=void 0;var aS=/^(?:>|\|)[-+]?$/,cS=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,uS=s(e=>{let t=e?.trim()??"";if(!(t.length===0||aS.test(t)))return t},"usableCatalogText");Ie.usableCatalogText=uS;var lS=s(e=>(0,Ie.parseFrontmatterField)(e,"description"),"parseFrontmatterDescription");Ie.parseFrontmatterDescription=lS;var fS=s((e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return pS(n[1],t)},"parseFrontmatterField");Ie.parseFrontmatterField=fS;var dS=s(e=>e.replace(/^["']|["']$/g,""),"stripYamlQuotes");function pS(e,t){let n=e.split(`
5
+ `),r=`${t}:`,o=n.findIndex(m=>m===r||m.startsWith(`${r} `)||m.startsWith(`${r} `));if(o<0)return;let i=(n[o]??"").slice(r.length).trim(),a=cS.exec(i);if(!a){let m=dS(i).trim();return(0,Ie.usableCatalogText)(m)}let c=[];for(let m=o+1;m<n.length;m+=1){let _=n[m]??"";if(_.trim()===""){c.push("");continue}if(_.length===_.trimStart().length)break;c.push(_)}let u=c.reduce((m,_)=>_.trim()===""?m:Math.min(m,_.length-_.trimStart().length),Number.POSITIVE_INFINITY),f=[],l=a[1]?.trim();l&&f.push(l);for(let m of c)f.push(m.trim()===""?"":m.slice(u));for(;f.length>0&&f[f.length-1]==="";)f.pop();let d=i.startsWith(">")?f.join(`
6
+ `).split(/\n{2,}/).map(m=>m.split(`
7
+ `).map(_=>_.trim()).filter(Boolean).join(" ")).filter(m=>m.length>0).join(`
8
8
 
9
- `):l.join(`
10
- `).trimEnd();return(0,Re.usableCatalogText)(f)}});var _c=z(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=O_;Q.capComponentTextBytes=gc;Q.prepareComponentInspectionText=x_;Q.redactComponentSource=bo;Q.componentSourceContainsRedactableSecret=M_;Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";Q.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;Q.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function O_(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 gc(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 x_(e){if(!(e==null||e.length===0))return gc(bo(e),Q.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}var I_=[/\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],T_=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,k_=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,P_=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,N_=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,mc=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function w_(e){let t=e.replace(k_,(n,r)=>`${r}${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(P_,(n,r)=>`${r}${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(T_,(n,r)=>`${r}${Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of I_)t=t.replace(n,Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}function bo(e){if(e.length===0)return e;let t=e.split(`
11
- `),n=!1;return t.map(o=>n?mc.test(o)?(n=!1,o):o.trim().length===0?o:Q.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:N_.test(o)&&!mc.test(o)?(n=!0,o):w_(o)).join(`
12
- `)}function M_(e){return bo(e)!==e}});var Ze=z(E=>{"use strict";Object.defineProperty(E,"__esModule",{value:!0});E.redactComponentSource=E.prepareComponentInspectionText=E.fitSnapshotInspectionTextBudget=E.componentSourceContainsRedactableSecret=E.capComponentTextBytes=E.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=E.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=E.COMPONENT_INSPECTION_TEXT_MAX_BYTES=E.usableCatalogText=E.parseFrontmatterField=E.parseFrontmatterDescription=E.mcpServerToolSegmentForms=E.mcpServerNameMatchesToolSegment=E.isNpmRegistryPublisher=E.EMPTY_NPM_PUBLISHER=E.displayPublisherName=E.classifyMcpProvenance=E.resolveMcpPackageIdentity=E.McpPackageEcosystem=E.pinnedPackageVersionFromSpec=E.pinnedPackageVersionFromNpx=E.packageNameFromSpec=E.npxPackageSpecs=E.npxExecBin=E.PACKAGE_FIELD_MAX=E.serializeMcpLaunchIdentity=E.projectMcpMissingLaunchIdentity=E.projectMcpLaunchIdentity=E.normalizeMcpToolNames=E.MCP_MISSING_LAUNCH_SERIALIZED=E.MCP_LAUNCH_IDENTITY_ALGORITHM=E.maskMcpLaunchForDisplay=E.launchContainsCredentials=E.hashMcpLaunchIdentity=E.foldMcpName=E.buildMcpFamilyCanonicalKey=E.ComponentKind=void 0;E.userConfigRootFromPath=B_;E.installationRootExternalKey=G_;E.normalizeRepositoryRelativePath=hc;E.nativeKeyForSkillPath=V_;E.nativeKeyForRulePath=z_;E.nativeKeyForCommandPath=W_;E.serializeComponentIdentity=Ec;E.buildComponentReference=Y_;E.validateComponentReference=X_;var v_=Ge("node:crypto"),L_=Ge("node:path"),H_="cmp1_",U_=/^cmp1_[A-Za-z0-9_-]{43}$/,D_=["/skills/","/skills-cursor/"],F_=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,$_=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,j_=[".cursor",".claude",".codex"],K_={".claude.json":".claude",".agents":".codex"};E.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function B_(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>j_.includes(o));return n||(t.map(o=>K_[o]).find(o=>o!==void 0)??"unknown")}function G_(e,t){return`runtime-install:${e}/${t}`}function Qn(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function hc(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=L_.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Qn(n,"sourcePath")}function V_(e){let t=e.replaceAll("\\","/");for(let n of D_){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function Sc(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 z_(e){return Sc(e,F_,/\.(mdc|md|rules)$/i)}function W_(e){return Sc(e,$_,/\.(md|mdc|toml)$/i)}function J_(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Ec(e){let t=[Qn(e.installationRootExternalKey,"installationRootExternalKey"),Qn(e.installableKind,"installableKind"),hc(e.sourcePath),Qn(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(J_).join("|")}`,"utf8")}function Y_(e){let t=(0,v_.createHash)("sha256").update(Ec(e)).digest("base64url");return`${H_}${t}`}function X_(e){return U_.test(e)}var Ce=Yn();Object.defineProperty(E,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:function(){return Ce.buildMcpFamilyCanonicalKey}});Object.defineProperty(E,"foldMcpName",{enumerable:!0,get:function(){return Ce.foldMcpName}});Object.defineProperty(E,"hashMcpLaunchIdentity",{enumerable:!0,get:function(){return Ce.hashMcpLaunchIdentity}});Object.defineProperty(E,"launchContainsCredentials",{enumerable:!0,get:function(){return Ce.launchContainsCredentials}});Object.defineProperty(E,"maskMcpLaunchForDisplay",{enumerable:!0,get:function(){return Ce.maskMcpLaunchForDisplay}});Object.defineProperty(E,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:function(){return Ce.MCP_LAUNCH_IDENTITY_ALGORITHM}});Object.defineProperty(E,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:function(){return Ce.MCP_MISSING_LAUNCH_SERIALIZED}});Object.defineProperty(E,"normalizeMcpToolNames",{enumerable:!0,get:function(){return Ce.normalizeMcpToolNames}});Object.defineProperty(E,"projectMcpLaunchIdentity",{enumerable:!0,get:function(){return Ce.projectMcpLaunchIdentity}});Object.defineProperty(E,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:function(){return Ce.projectMcpMissingLaunchIdentity}});Object.defineProperty(E,"serializeMcpLaunchIdentity",{enumerable:!0,get:function(){return Ce.serializeMcpLaunchIdentity}});var At=qn();Object.defineProperty(E,"PACKAGE_FIELD_MAX",{enumerable:!0,get:function(){return At.PACKAGE_FIELD_MAX}});Object.defineProperty(E,"npxExecBin",{enumerable:!0,get:function(){return At.npxExecBin}});Object.defineProperty(E,"npxPackageSpecs",{enumerable:!0,get:function(){return At.npxPackageSpecs}});Object.defineProperty(E,"packageNameFromSpec",{enumerable:!0,get:function(){return At.packageNameFromSpec}});Object.defineProperty(E,"pinnedPackageVersionFromNpx",{enumerable:!0,get:function(){return At.pinnedPackageVersionFromNpx}});Object.defineProperty(E,"pinnedPackageVersionFromSpec",{enumerable:!0,get:function(){return At.pinnedPackageVersionFromSpec}});var yc=oc();Object.defineProperty(E,"McpPackageEcosystem",{enumerable:!0,get:function(){return yc.McpPackageEcosystem}});Object.defineProperty(E,"resolveMcpPackageIdentity",{enumerable:!0,get:function(){return yc.resolveMcpPackageIdentity}});var er=lc();Object.defineProperty(E,"classifyMcpProvenance",{enumerable:!0,get:function(){return er.classifyMcpProvenance}});Object.defineProperty(E,"displayPublisherName",{enumerable:!0,get:function(){return er.displayPublisherName}});Object.defineProperty(E,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:function(){return er.EMPTY_NPM_PUBLISHER}});Object.defineProperty(E,"isNpmRegistryPublisher",{enumerable:!0,get:function(){return er.isNpmRegistryPublisher}});var Rc=dc();Object.defineProperty(E,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:function(){return Rc.mcpServerNameMatchesToolSegment}});Object.defineProperty(E,"mcpServerToolSegmentForms",{enumerable:!0,get:function(){return Rc.mcpServerToolSegmentForms}});var Oo=pc();Object.defineProperty(E,"parseFrontmatterDescription",{enumerable:!0,get:function(){return Oo.parseFrontmatterDescription}});Object.defineProperty(E,"parseFrontmatterField",{enumerable:!0,get:function(){return Oo.parseFrontmatterField}});Object.defineProperty(E,"usableCatalogText",{enumerable:!0,get:function(){return Oo.usableCatalogText}});var qe=_c();Object.defineProperty(E,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return qe.COMPONENT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(E,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:function(){return qe.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}});Object.defineProperty(E,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return qe.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(E,"capComponentTextBytes",{enumerable:!0,get:function(){return qe.capComponentTextBytes}});Object.defineProperty(E,"componentSourceContainsRedactableSecret",{enumerable:!0,get:function(){return qe.componentSourceContainsRedactableSecret}});Object.defineProperty(E,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:function(){return qe.fitSnapshotInspectionTextBudget}});Object.defineProperty(E,"prepareComponentInspectionText",{enumerable:!0,get:function(){return qe.prepareComponentInspectionText}});Object.defineProperty(E,"redactComponentSource",{enumerable:!0,get:function(){return qe.redactComponentSource}})});var Rr=z(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 Cr=z((aT,cl)=>{"use strict";var al=Rr();cl.exports=(e,t={})=>{let n=(r,o={})=>{let s=t.escapeInvalid&&al.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a="";if(r.value)return(s||i)&&al.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 ll=z((cT,ul)=>{"use strict";ul.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var El=z((uT,Sl)=>{"use strict";var fl=ll(),it=(e,t,n)=>{if(fl(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(fl(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(it.cache.hasOwnProperty(c))return it.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=hl(e)||hl(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=dl(S,Math.abs(l),f,r),l=f.a=0}return u>=0&&(p=dl(l,u,f,r)),f.negatives=g,f.positives=p,f.result=vE(g,p,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&p.length+g.length>1&&(f.result=`(?:${f.result})`),it.cache[c]=f,f.result};function vE(e,t,n){let r=cs(e,t,"-",!1,n)||[],o=cs(t,e,"",!1,n)||[],s=cs(e,t,"-?",!0,n)||[];return r.concat(s).concat(o).join("|")}function LE(e,t){let n=1,r=1,o=ml(e,n),s=new Set([t]);for(;e<=o&&o<=t;)s.add(o),n+=1,o=ml(e,n);for(o=gl(t+1,r)-1;e<o&&o<=t;)s.add(o),r+=1,o=gl(t+1,r)-1;return s=[...s],s.sort(DE),s}function HE(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=UE(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+=FE(c,l,n):i++}return i&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[i],digits:o}}function dl(e,t,n,r){let o=LE(e,t),s=[],i=e,a;for(let c=0;c<o.length;c++){let l=o[c],u=HE(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+_l(a.count),i=l+1;continue}n.isPadded&&(d=$E(l,n,r)),u.string=d+u.pattern+_l(u.count),s.push(u),i=l+1,a=u}return s}function cs(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 UE(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}function DE(e,t){return e>t?1:t>e?-1:0}function pl(e,t,n){return e.some(r=>r[t]===n)}function ml(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}function gl(e,t){return e-e%Math.pow(10,t)}function _l(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}function FE(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}function hl(e){return/^-?(0+)\d/.test(e)}function $E(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}}`}}it.cache={};it.clearCache=()=>it.cache={};Sl.exports=it});var fs=z((lT,xl)=>{"use strict";var jE=Ge("util"),Rl=El(),yl=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),KE=e=>t=>e===!0?Number(t):String(t),us=e=>typeof e=="number"||typeof e=="string"&&e!=="",sn=e=>Number.isInteger(+e),ls=e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},BE=(e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,GE=(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},br=(e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},VE=(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=>br(String(a),n)).join("|")),e.negatives.length&&(s=`-(${r}${e.negatives.map(a=>br(String(a),n)).join("|")})`),o&&s?i=`${o}|${s}`:i=o||s,t.wrap?`(${r}${i})`:i},Cl=(e,t,n,r)=>{if(n)return Rl(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let s=String.fromCharCode(t);return`[${o}-${s}]`},Al=(e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return Rl(e,t,n)},bl=(...e)=>new RangeError("Invalid range arguments: "+jE.inspect(...e)),Ol=(e,t,n)=>{if(n.strictRanges===!0)throw bl([e,t]);return[]},zE=(e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},WE=(e,t,n=1,r={})=>{let o=Number(e),s=Number(t);if(!Number.isInteger(o)||!Number.isInteger(s)){if(r.strictRanges===!0)throw bl([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=ls(a)||ls(c)||ls(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&BE(e,t,r)===!1,p=r.transform||KE(f);if(r.toRegex&&n===1)return Cl(br(e,d),br(t,d),!0,r);let g={negatives:[],positives:[]},S=I=>g[I<0?"negatives":"positives"].push(Math.abs(I)),C=[],A=0;for(;i?o>=s:o<=s;)r.toRegex===!0&&n>1?S(o):C.push(GE(p(o,A),d,f)),o=i?o-n:o+n,A++;return r.toRegex===!0?n>1?VE(g,r,d):Al(C,null,{wrap:!1,...r}):C},JE=(e,t,n=1,r={})=>{if(!sn(e)&&e.length>1||!sn(t)&&t.length>1)return Ol(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 Cl(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?Al(u,null,{wrap:!1,options:r}):u},Ar=(e,t,n,r={})=>{if(t==null&&us(e))return[e];if(!us(e)||!us(t))return Ol(e,t,r);if(typeof n=="function")return Ar(e,t,1,{transform:n});if(yl(n))return Ar(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,sn(n)?sn(e)&&sn(t)?WE(e,t,n,o):JE(e,t,Math.max(Math.abs(n),1),o):n!=null&&!yl(n)?zE(n,o):Ar(e,t,1,n)};xl.exports=Ar});var kl=z((fT,Tl)=>{"use strict";var YE=fs(),Il=Rr(),XE=(e,t={})=>{let n=(r,o={})=>{let s=Il.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=Il.reduce(r.nodes),d=YE(...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)};Tl.exports=XE});var wl=z((dT,Nl)=>{"use strict";var qE=fs(),Pl=Cr(),Ot=Rr(),at=(e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?Ot.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let s of o)r.push(at(s,t,n));else for(let s of t)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?at(o,s,n):o+s);return Ot.flatten(r)},ZE=(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(at(a.pop(),Pl(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){a.push(at(a.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let d=Ot.reduce(o.nodes);if(Ot.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=qE(...d,t);f.length===0&&(f=Pl(o,t)),a.push(at(a.pop(),f)),o.nodes=[];return}let c=Ot.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(at(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(at(l.pop(),f.value));continue}f.nodes&&r(f,o)}return l};return Ot.flatten(r(e))};Nl.exports=ZE});var vl=z((pT,Ml)=>{"use strict";Ml.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:`
13
- `,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 Fl=z((mT,Dl)=>{"use strict";var QE=Cr(),{MAX_LENGTH:Ll,CHAR_BACKSLASH:ds,CHAR_BACKTICK:ey,CHAR_COMMA:ty,CHAR_DOT:ny,CHAR_LEFT_PARENTHESES:ry,CHAR_RIGHT_PARENTHESES:oy,CHAR_LEFT_CURLY_BRACE:sy,CHAR_RIGHT_CURLY_BRACE:iy,CHAR_LEFT_SQUARE_BRACKET:Hl,CHAR_RIGHT_SQUARE_BRACKET:Ul,CHAR_DOUBLE_QUOTE:ay,CHAR_SINGLE_QUOTE:cy,CHAR_NO_BREAK_SPACE:uy,CHAR_ZERO_WIDTH_NOBREAK_SPACE:ly}=vl(),fy=(e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Ll,n.maxLength):Ll;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===ly||f===uy)){if(f===ds){g({type:"text",value:(t.keepEscaping?f:"")+p()});continue}if(f===Ul){g({type:"text",value:"\\"+f});continue}if(f===Hl){c++;let S;for(;u<l&&(S=p());){if(f+=S,S===Hl){c++;continue}if(S===ds){f+=p();continue}if(S===Ul&&(c--,c===0))break}g({type:"text",value:f});continue}if(f===ry){i=g({type:"paren",nodes:[]}),s.push(i),g({type:"text",value:f});continue}if(f===oy){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===ay||f===cy||f===ey){let S=f,C;for(t.keepQuotes!==!0&&(f="");u<l&&(C=p());){if(C===ds){f+=C+p();continue}if(C===S){t.keepQuotes===!0&&(f+=C);break}f+=C}g({type:"text",value:f});continue}if(f===sy){d++;let C={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(C),s.push(i),g({type:"open",value:f});continue}if(f===iy){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===ty&&d>0){if(i.ranges>0){i.ranges=0;let S=i.nodes.shift();i.nodes=[S,{type:"text",value:QE(i)}]}g({type:"comma",value:f}),i.commas++;continue}if(f===ny&&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 C=S[S.length-1];C.value+=a.value+f,a=C,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(A=>{A.nodes||(A.type==="open"&&(A.isOpen=!0),A.type==="close"&&(A.isClose=!0),A.nodes||(A.type="text"),A.invalid=!0)});let S=s[s.length-1],C=S.nodes.indexOf(i);S.nodes.splice(C,1,...i.nodes)}while(s.length>0);return g({type:"eos"}),o};Dl.exports=fy});var Kl=z((gT,jl)=>{"use strict";var $l=Cr(),dy=kl(),py=wl(),my=Fl(),ge=(e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=ge.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(ge.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n};ge.parse=(e,t={})=>my(e,t);ge.stringify=(e,t={})=>$l(typeof e=="string"?ge.parse(e,t):e,t);ge.compile=(e,t={})=>(typeof e=="string"&&(e=ge.parse(e,t)),dy(e,t));ge.expand=(e,t={})=>{typeof e=="string"&&(e=ge.parse(e,t));let n=py(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};ge.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?ge.compile(e,t):ge.expand(e,t);jl.exports=ge});var an=z((_T,Wl)=>{"use strict";var gy=Ge("path"),Ne="\\\\/",Bl=`[^${Ne}]`,_y=0,Ke="\\.",hy="\\+",Sy="\\?",Or="\\/",Ey="(?=.)",Gl="[^/]",ps=`(?:${Or}|$)`,Vl=`(?:^|${Or})`,ms=`${Ke}{1,2}${ps}`,yy=`(?!${Ke})`,Ry=`(?!${Vl}${ms})`,Cy=`(?!${Ke}{0,1}${ps})`,Ay=`(?!${ms})`,by=`[^.${Or}]`,Oy=`${Gl}*?`,zl={DOT_LITERAL:Ke,PLUS_LITERAL:hy,QMARK_LITERAL:Sy,SLASH_LITERAL:Or,ONE_CHAR:Ey,QMARK:Gl,END_ANCHOR:ps,DOTS_SLASH:ms,NO_DOT:yy,NO_DOTS:Ry,NO_DOT_SLASH:Cy,NO_DOTS_SLASH:Ay,QMARK_NO_DOT:by,STAR:Oy,START_ANCHOR:Vl},xy={...zl,SLASH_LITERAL:`[${Ne}]`,QMARK:Bl,STAR:`${Bl}*?`,DOTS_SLASH:`${Ke}{1,2}(?:[${Ne}]|$)`,NO_DOT:`(?!${Ke})`,NO_DOTS:`(?!(?:^|[${Ne}])${Ke}{1,2}(?:[${Ne}]|$))`,NO_DOT_SLASH:`(?!${Ke}{0,1}(?:[${Ne}]|$))`,NO_DOTS_SLASH:`(?!${Ke}{1,2}(?:[${Ne}]|$))`,QMARK_NO_DOT:`[^.${Ne}]`,START_ANCHOR:`(?:^|[${Ne}])`,END_ANCHOR:`(?:[${Ne}]|$)`},Iy={__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"};Wl.exports={DEFAULT_MAX_EXTGLOB_RECURSION:_y,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Iy,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:gy.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?xy:zl}}});var cn=z(ue=>{"use strict";var Ty=Ge("path"),ky=process.platform==="win32",{REGEX_BACKSLASH:Py,REGEX_REMOVE_BACKSLASH:Ny,REGEX_SPECIAL_CHARS:wy,REGEX_SPECIAL_CHARS_GLOBAL:My}=an();ue.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);ue.hasRegexChars=e=>wy.test(e);ue.isRegexChar=e=>e.length===1&&ue.hasRegexChars(e);ue.escapeRegex=e=>e.replace(My,"\\$1");ue.toPosixSlashes=e=>e.replace(Py,"/");ue.removeBackslashes=e=>e.replace(Ny,t=>t==="\\"?"":t);ue.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};ue.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:ky===!0||Ty.sep==="\\";ue.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?ue.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};ue.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};ue.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${e})${o}`;return t.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var tf=z((ST,ef)=>{"use strict";var Jl=cn(),{CHAR_ASTERISK:gs,CHAR_AT:vy,CHAR_BACKWARD_SLASH:un,CHAR_COMMA:Ly,CHAR_DOT:_s,CHAR_EXCLAMATION_MARK:hs,CHAR_FORWARD_SLASH:Ql,CHAR_LEFT_CURLY_BRACE:Ss,CHAR_LEFT_PARENTHESES:Es,CHAR_LEFT_SQUARE_BRACKET:Hy,CHAR_PLUS:Uy,CHAR_QUESTION_MARK:Yl,CHAR_RIGHT_CURLY_BRACE:Dy,CHAR_RIGHT_PARENTHESES:Xl,CHAR_RIGHT_SQUARE_BRACKET:Fy}=an(),ql=e=>e===Ql||e===un,Zl=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},$y=(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,C=!1,A=!1,I=!1,P=!1,T=!1,k=!1,B=0,D,O,w={value:"",depth:0,isGlob:!1},H=()=>l>=r,m=()=>c.charCodeAt(l+1),b=()=>(D=O,c.charCodeAt(++l));for(;l<r;){O=b();let se;if(O===un){I=w.backslashes=!0,O=b(),O===Ss&&(A=!0);continue}if(A===!0||O===Ss){for(B++;H()!==!0&&(O=b());){if(O===un){I=w.backslashes=!0,b();continue}if(O===Ss){B++;continue}if(A!==!0&&O===_s&&(O=b())===_s){if(f=w.isBrace=!0,g=w.isGlob=!0,k=!0,o===!0)continue;break}if(A!==!0&&O===Ly){if(f=w.isBrace=!0,g=w.isGlob=!0,k=!0,o===!0)continue;break}if(O===Dy&&(B--,B===0)){A=!1,f=w.isBrace=!0,k=!0;break}}if(o===!0)continue;break}if(O===Ql){if(s.push(l),i.push(w),w={value:"",depth:0,isGlob:!1},k===!0)continue;if(D===_s&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(O===Uy||O===vy||O===gs||O===Yl||O===hs)===!0&&m()===Es){if(g=w.isGlob=!0,S=w.isExtglob=!0,k=!0,O===hs&&l===u&&(T=!0),o===!0){for(;H()!==!0&&(O=b());){if(O===un){I=w.backslashes=!0,O=b();continue}if(O===Xl){g=w.isGlob=!0,k=!0;break}}continue}break}if(O===gs){if(D===gs&&(C=w.isGlobstar=!0),g=w.isGlob=!0,k=!0,o===!0)continue;break}if(O===Yl){if(g=w.isGlob=!0,k=!0,o===!0)continue;break}if(O===Hy){for(;H()!==!0&&(se=b());){if(se===un){I=w.backslashes=!0,b();continue}if(se===Fy){p=w.isBracket=!0,g=w.isGlob=!0,k=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&O===hs&&l===u){P=w.negated=!0,u++;continue}if(n.noparen!==!0&&O===Es){if(g=w.isGlob=!0,o===!0){for(;H()!==!0&&(O=b());){if(O===Es){I=w.backslashes=!0,O=b();continue}if(O===Xl){k=!0;break}}continue}break}if(g===!0){if(k=!0,o===!0)continue;break}}n.noext===!0&&(S=!1,g=!1);let U=c,fe="",_="";u>0&&(fe=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&&ql(U.charCodeAt(U.length-1))&&(U=U.slice(0,-1)),n.unescape===!0&&(_&&(_=Jl.removeBackslashes(_)),U&&I===!0&&(U=Jl.removeBackslashes(U)));let h={prefix:fe,input:e,start:u,base:U,glob:_,isBrace:f,isBracket:p,isGlob:g,isExtglob:S,isGlobstar:C,negated:P,negatedExtglob:T};if(n.tokens===!0&&(h.maxDepth=0,ql(O)||i.push(w),h.tokens=i),n.parts===!0||n.tokens===!0){let se;for(let F=0;F<s.length;F++){let Ae=se?se+1:u,be=s[F],de=e.slice(Ae,be);n.tokens&&(F===0&&u!==0?(i[F].isPrefix=!0,i[F].value=fe):i[F].value=de,Zl(i[F]),h.maxDepth+=i[F].depth),(F!==0||de!=="")&&a.push(de),se=be}if(se&&se+1<e.length){let F=e.slice(se+1);a.push(F),n.tokens&&(i[i.length-1].value=F,Zl(i[i.length-1]),h.maxDepth+=i[i.length-1].depth)}h.slashes=s,h.parts=a}return h};ef.exports=$y});var af=z((ET,sf)=>{"use strict";var ln=an(),oe=cn(),{MAX_LENGTH:xr,POSIX_REGEX_SOURCE:jy,REGEX_NON_SPECIAL_CHARS:Ky,REGEX_SPECIAL_CHARS_BACKREF:By,REPLACEMENTS:nf}=ln,Gy=(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=>oe.escapeRegex(o)).join("..")}return n},xt=(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},Vy=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},of=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(Vy(t))return t.replace(/\\(.)/g,"$1")},zy=e=>{let t=e.map(of).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},ys=(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}}}}},Wy=e=>{let t=0,n=[];for(;t<e.length;){let o=ys(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=of(s[0]);if(!i||i.length!==1)return;n.push(i),t+=o.end+1}return n.length<1?void 0:`${n.length===1?oe.escapeRegex(n[0]):`[${n.map(o=>oe.escapeRegex(o)).join("")}]`}*`},Jy=e=>{let t=0,n=e.trim(),r=ys(n);for(;r;)t++,n=r.body.trim(),r=ys(n);return t},Yy=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:ln.DEFAULT_MAX_EXTGLOB_RECURSION,r=rf(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||zy(r)))return{risky:!0};for(let o of r){let s=Wy(o);if(s)return{risky:!0,safeOutput:s};if(Jy(o)>n)return{risky:!0}}return{risky:!1}},Rs=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=nf[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(xr,n.maxLength):xr,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=oe.isWindows(t),l=ln.globChars(c),u=ln.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,SLASH_LITERAL:p,ONE_CHAR:g,DOTS_SLASH:S,NO_DOT:C,NO_DOT_SLASH:A,NO_DOTS_SLASH:I,QMARK:P,QMARK_NO_DOT:T,STAR:k,START_ANCHOR:B}=l,D=R=>`(${a}(?:(?!${B}${R.dot?S:d}).)*?)`,O=n.dot?"":C,w=n.dot?P:T,H=n.bash===!0?D(n):k;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=oe.removePrefix(e,m),o=e.length;let b=[],U=[],fe=[],_=s,h,se=()=>m.index===o-1,F=m.peek=(R=1)=>e[m.index+R],Ae=m.advance=()=>e[++m.index]||"",be=()=>e.slice(m.index+1),de=(R="",J=0)=>{m.consumed+=R,m.index+=J},Cn=R=>{m.output+=R.output!=null?R.output:R.value,de(R.value)},Ep=()=>{let R=1;for(;F()==="!"&&(F(2)!=="("||F(3)==="?");)Ae(),m.start++,R++;return R%2===0?!1:(m.negated=!0,m.start++,!0)},An=R=>{m[R]++,fe.push(R)},Be=R=>{m[R]--,fe.pop()},M=R=>{if(_.type==="globstar"){let J=m.braces>0&&(R.type==="comma"||R.type==="brace"),y=R.extglob===!0||b.length&&(R.type==="pipe"||R.type==="paren");R.type!=="slash"&&R.type!=="paren"&&!J&&!y&&(m.output=m.output.slice(0,-_.output.length),_.type="star",_.value="*",_.output=H,m.output+=_.output)}if(b.length&&R.type!=="paren"&&(b[b.length-1].inner+=R.value),(R.value||R.output)&&Cn(R),_&&_.type==="text"&&R.type==="text"){_.value+=R.value,_.output=(_.output||"")+R.value;return}R.prev=_,i.push(R),_=R},bn=(R,J)=>{let y={...u[J],conditions:1,inner:""};y.prev=_,y.parens=m.parens,y.output=m.output,y.startIndex=m.index,y.tokensIndex=i.length;let N=(n.capture?"(":"")+y.open;An("parens"),M({type:R,value:J,output:m.output?"":g}),M({type:"paren",extglob:!0,value:Ae(),output:N}),b.push(y)},yp=R=>{let J=e.slice(R.startIndex,m.index+1),y=e.slice(R.startIndex+2,m.index),N=Yy(y,n);if((R.type==="plus"||R.type==="star")&&N.risky){let G=N.safeOutput?(R.output?"":g)+(n.capture?`(${N.safeOutput})`:N.safeOutput):void 0,Oe=i[R.tokensIndex];Oe.type="text",Oe.value=J,Oe.output=G||oe.escapeRegex(J);for(let xe=R.tokensIndex+1;xe<i.length;xe++)i[xe].value="",i[xe].output="",delete i[xe].suffix;m.output=R.output+Oe.output,m.backtrack=!0,M({type:"paren",extglob:!0,value:h,output:""}),Be("parens");return}let V=R.close+(n.capture?")":""),re;if(R.type==="negate"){let G=H;if(R.inner&&R.inner.length>1&&R.inner.includes("/")&&(G=D(n)),(G!==H||se()||/^\)+$/.test(be()))&&(V=R.close=`)$))${G}`),R.inner.includes("*")&&(re=be())&&/^\.[^\\/.]+$/.test(re)){let Oe=Rs(re,{...t,fastpaths:!1}).output;V=R.close=`)${Oe})${G})`}R.prev.type==="bos"&&(m.negatedExtglob=!0)}M({type:"paren",extglob:!0,value:h,output:V}),Be("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let R=!1,J=e.replace(By,(y,N,V,re,G,Oe)=>re==="\\"?(R=!0,y):re==="?"?N?N+re+(G?P.repeat(G.length):""):Oe===0?w+(G?P.repeat(G.length):""):P.repeat(V.length):re==="."?d.repeat(V.length):re==="*"?N?N+re+(G?H:""):H:N?y:`\\${y}`);return R===!0&&(n.unescape===!0?J=J.replace(/\\/g,""):J=J.replace(/\\+/g,y=>y.length%2===0?"\\\\":y?"\\":"")),J===e&&n.contains===!0?(m.output=e,m):(m.output=oe.wrapOutput(J,m,t),m)}for(;!se();){if(h=Ae(),h==="\0")continue;if(h==="\\"){let y=F();if(y==="/"&&n.bash!==!0||y==="."||y===";")continue;if(!y){h+="\\",M({type:"text",value:h});continue}let N=/^\\+/.exec(be()),V=0;if(N&&N[0].length>2&&(V=N[0].length,m.index+=V,V%2!==0&&(h+="\\")),n.unescape===!0?h=Ae():h+=Ae(),m.brackets===0){M({type:"text",value:h});continue}}if(m.brackets>0&&(h!=="]"||_.value==="["||_.value==="[^")){if(n.posix!==!1&&h===":"){let y=_.value.slice(1);if(y.includes("[")&&(_.posix=!0,y.includes(":"))){let N=_.value.lastIndexOf("["),V=_.value.slice(0,N),re=_.value.slice(N+2),G=jy[re];if(G){_.value=V+G,m.backtrack=!0,Ae(),!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,Cn({value:h});continue}if(m.quotes===1&&h!=='"'){h=oe.escapeRegex(h),_.value+=h,Cn({value:h});continue}if(h==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===!0&&M({type:"text",value:h});continue}if(h==="("){An("parens"),M({type:"paren",value:h});continue}if(h===")"){if(m.parens===0&&n.strictBrackets===!0)throw new SyntaxError(xt("opening","("));let y=b[b.length-1];if(y&&m.parens===y.parens+1){yp(b.pop());continue}M({type:"paren",value:h,output:m.parens?")":"\\)"}),Be("parens");continue}if(h==="["){if(n.nobracket===!0||!be().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(xt("closing","]"));h=`\\${h}`}else An("brackets");M({type:"bracket",value:h});continue}if(h==="]"){if(n.nobracket===!0||_&&_.type==="bracket"&&_.value.length===1){M({type:"text",value:h,output:`\\${h}`});continue}if(m.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(xt("opening","["));M({type:"text",value:h,output:`\\${h}`});continue}Be("brackets");let y=_.value.slice(1);if(_.posix!==!0&&y[0]==="^"&&!y.includes("/")&&(h=`/${h}`),_.value+=h,Cn({value:h}),n.literalBrackets===!1||oe.hasRegexChars(y))continue;let N=oe.escapeRegex(_.value);if(m.output=m.output.slice(0,-_.value.length),n.literalBrackets===!0){m.output+=N,_.value=N;continue}_.value=`(${a}${N}|${_.value})`,m.output+=_.value;continue}if(h==="{"&&n.nobrace!==!0){An("braces");let y={type:"brace",value:h,output:"(",outputIndex:m.output.length,tokensIndex:m.tokens.length};U.push(y),M(y);continue}if(h==="}"){let y=U[U.length-1];if(n.nobrace===!0||!y){M({type:"text",value:h,output:h});continue}let N=")";if(y.dots===!0){let V=i.slice(),re=[];for(let G=V.length-1;G>=0&&(i.pop(),V[G].type!=="brace");G--)V[G].type!=="dots"&&re.unshift(V[G].value);N=Gy(re,n),m.backtrack=!0}if(y.comma!==!0&&y.dots!==!0){let V=m.output.slice(0,y.outputIndex),re=m.tokens.slice(y.tokensIndex);y.value=y.output="\\{",h=N="\\}",m.output=V;for(let G of re)m.output+=G.output||G.value}M({type:"brace",value:h,output:N}),Be("braces"),U.pop();continue}if(h==="|"){b.length>0&&b[b.length-1].conditions++,M({type:"text",value:h});continue}if(h===","){let y=h,N=U[U.length-1];N&&fe[fe.length-1]==="braces"&&(N.comma=!0,y="|"),M({type:"comma",value:h,output:y});continue}if(h==="/"){if(_.type==="dot"&&m.index===m.start+1){m.start=m.index+1,m.consumed="",m.output="",i.pop(),_=s;continue}M({type:"slash",value:h,output:p});continue}if(h==="."){if(m.braces>0&&_.type==="dot"){_.value==="."&&(_.output=d);let y=U[U.length-1];_.type="dots",_.output+=h,_.value+=h,y.dots=!0;continue}if(m.braces+m.parens===0&&_.type!=="bos"&&_.type!=="slash"){M({type:"text",value:h,output:d});continue}M({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 N=F(),V=h;if(N==="<"&&!oe.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(_.value==="("&&!/[!=<:]/.test(N)||N==="<"&&!/<([!=]|\w+>)/.test(be()))&&(V=`\\${h}`),M({type:"text",value:h,output:V});continue}if(n.dot!==!0&&(_.type==="slash"||_.type==="bos")){M({type:"qmark",value:h,output:T});continue}M({type:"qmark",value:h,output:P});continue}if(h==="!"){if(n.noextglob!==!0&&F()==="("&&(F(2)!=="?"||!/[!=<:]/.test(F(3)))){bn("negate",h);continue}if(n.nonegate!==!0&&m.index===0){Ep();continue}}if(h==="+"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){bn("plus",h);continue}if(_&&_.value==="("||n.regex===!1){M({type:"plus",value:h,output:f});continue}if(_&&(_.type==="bracket"||_.type==="paren"||_.type==="brace")||m.parens>0){M({type:"plus",value:h});continue}M({type:"plus",value:f});continue}if(h==="@"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){M({type:"at",extglob:!0,value:h,output:""});continue}M({type:"text",value:h});continue}if(h!=="*"){(h==="$"||h==="^")&&(h=`\\${h}`);let y=Ky.exec(be());y&&(h+=y[0],m.index+=y[0].length),M({type:"text",value:h});continue}if(_&&(_.type==="globstar"||_.star===!0)){_.type="star",_.star=!0,_.value+=h,_.output=H,m.backtrack=!0,m.globstar=!0,de(h);continue}let R=be();if(n.noextglob!==!0&&/^\([^?]/.test(R)){bn("star",h);continue}if(_.type==="star"){if(n.noglobstar===!0){de(h);continue}let y=_.prev,N=y.prev,V=y.type==="slash"||y.type==="bos",re=N&&(N.type==="star"||N.type==="globstar");if(n.bash===!0&&(!V||R[0]&&R[0]!=="/")){M({type:"star",value:h,output:""});continue}let G=m.braces>0&&(y.type==="comma"||y.type==="brace"),Oe=b.length&&(y.type==="pipe"||y.type==="paren");if(!V&&y.type!=="paren"&&!G&&!Oe){M({type:"star",value:h,output:""});continue}for(;R.slice(0,3)==="/**";){let xe=e[m.index+4];if(xe&&xe!=="/")break;R=R.slice(3),de("/**",3)}if(y.type==="bos"&&se()){_.type="globstar",_.value+=h,_.output=D(n),m.output=_.output,m.globstar=!0,de(h);continue}if(y.type==="slash"&&y.prev.type!=="bos"&&!re&&se()){m.output=m.output.slice(0,-(y.output+_.output).length),y.output=`(?:${y.output}`,_.type="globstar",_.output=D(n)+(n.strictSlashes?")":"|$)"),_.value+=h,m.globstar=!0,m.output+=y.output+_.output,de(h);continue}if(y.type==="slash"&&y.prev.type!=="bos"&&R[0]==="/"){let xe=R[1]!==void 0?"|$":"";m.output=m.output.slice(0,-(y.output+_.output).length),y.output=`(?:${y.output}`,_.type="globstar",_.output=`${D(n)}${p}|${p}${xe})`,_.value+=h,m.output+=y.output+_.output,m.globstar=!0,de(h+Ae()),M({type:"slash",value:"/",output:""});continue}if(y.type==="bos"&&R[0]==="/"){_.type="globstar",_.value+=h,_.output=`(?:^|${p}|${D(n)}${p})`,m.output=_.output,m.globstar=!0,de(h+Ae()),M({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,de(h);continue}let J={type:"star",value:h,output:H};if(n.bash===!0){J.output=".*?",(_.type==="bos"||_.type==="slash")&&(J.output=O+J.output),M(J);continue}if(_&&(_.type==="bracket"||_.type==="paren")&&n.regex===!0){J.output=h,M(J);continue}(m.index===m.start||_.type==="slash"||_.type==="dot")&&(_.type==="dot"?(m.output+=A,_.output+=A):n.dot===!0?(m.output+=I,_.output+=I):(m.output+=O,_.output+=O),F()!=="*"&&(m.output+=g,_.output+=g)),M(J)}for(;m.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(xt("closing","]"));m.output=oe.escapeLast(m.output,"["),Be("brackets")}for(;m.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(xt("closing",")"));m.output=oe.escapeLast(m.output,"("),Be("parens")}for(;m.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(xt("closing","}"));m.output=oe.escapeLast(m.output,"{"),Be("braces")}if(n.strictSlashes!==!0&&(_.type==="star"||_.type==="bracket")&&M({type:"maybe_slash",value:"",output:`${p}?`}),m.backtrack===!0){m.output="";for(let R of m.tokens)m.output+=R.output!=null?R.output:R.value,R.suffix&&(m.output+=R.suffix)}return m};Rs.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(xr,n.maxLength):xr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=nf[e]||e;let s=oe.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}=ln.globChars(s),S=n.dot?d:u,C=n.dot?f:u,A=n.capture?"":"?:",I={negated:!1,prefix:""},P=n.bash===!0?".*?":p;n.capture&&(P=`(${P})`);let T=O=>O.noglobstar===!0?P:`(${A}(?:(?!${g}${O.dot?l:i}).)*?)`,k=O=>{switch(O){case"*":return`${S}${c}${P}`;case".*":return`${i}${c}${P}`;case"*.*":return`${S}${P}${i}${c}${P}`;case"*/*":return`${S}${P}${a}${c}${C}${P}`;case"**":return S+T(n);case"**/*":return`(?:${S}${T(n)}${a})?${C}${c}${P}`;case"**/*.*":return`(?:${S}${T(n)}${a})?${C}${P}${i}${c}${P}`;case"**/.*":return`(?:${S}${T(n)}${a})?${i}${c}${P}`;default:{let w=/^(.*?)\.(\w+)$/.exec(O);if(!w)return;let H=k(w[1]);return H?H+i+w[2]:void 0}}},B=oe.removePrefix(e,I),D=k(B);return D&&n.strictSlashes!==!0&&(D+=`${a}?`),D};sf.exports=Rs});var uf=z((yT,cf)=>{"use strict";var Xy=Ge("path"),qy=tf(),Cs=af(),As=cn(),Zy=an(),Qy=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=Qy(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=As.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?As.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=As.isWindows(n))=>(t instanceof RegExp?t:ee.makeRe(t,n)).test(Xy.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)):Cs(e,{...t,fastpaths:!1});ee.scan=(e,t)=>qy(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=Cs.fastpaths(e,t)),o.output||(o=Cs(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=Zy;cf.exports=ee});var ff=z((RT,lf)=>{"use strict";lf.exports=uf()});var hf=z((CT,_f)=>{"use strict";var pf=Ge("util"),mf=Kl(),we=ff(),bs=cn(),df=e=>e===""||e==="./",gf=e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},W=(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=we(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};W.match=W;W.matcher=(e,t)=>we(e,t);W.isMatch=(e,t,n)=>we(t,n)(e);W.any=W.isMatch;W.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(W(e,t,{...n,onResult:s}));for(let a of o)i.has(a)||r.add(a);return[...r]};W.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=>W.contains(e,r,n));if(typeof t=="string"){if(df(e)||df(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return W.isMatch(e,t,{...n,contains:!0})};W.matchKeys=(e,t,n)=>{if(!bs.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=W(Object.keys(e),t,n),o={};for(let s of r)o[s]=e[s];return o};W.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=we(String(o),n);if(r.some(i=>s(i)))return!0}return!1};W.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=we(String(o),n);if(!r.every(i=>s(i)))return!1}return!0};W.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${pf.inspect(e)}"`);return[].concat(t).every(r=>we(r,n)(e))};W.capture=(e,t,n)=>{let r=bs.isWindows(n),s=we.makeRe(String(e),{...n,capture:!0}).exec(r?bs.toPosixSlashes(t):t);if(s)return s.slice(1).map(i=>i===void 0?"":i)};W.makeRe=(...e)=>we.makeRe(...e);W.scan=(...e)=>we.scan(...e);W.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of mf(String(r),t))n.push(we.parse(o,t));return n};W.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!gf(e)?[e]:mf(e,t)};W.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return W.braces(e,{...t,expand:!0})};W.hasBraces=gf;_f.exports=W});import{existsSync as Fp,readFileSync as $p}from"node:fs";import{hostname as ki,release as jp,userInfo as Kp,version as Bp}from"node:os";import*as ie from"node:os";import{performance as Gr}from"node:perf_hooks";var Ip=1024*1024,Tp=128;function On(e){return Math.round(e/Ip)}function Lt(e,t){let n=10**t;return Math.round(e*n)/n}function mi(e=process.platform){try{let t=Gr.now(),n={},r=0,o=0,s=e!=="win32";for(let{times:c}of ie.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(ie.uptime()),n.mem_free_mb=On(ie.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=On(process.availableMemory())),e!=="win32"){let[c,l,u]=ie.loadavg();n.load_1m=Lt(c??0,2),n.load_5m=Lt(l??0,2),n.load_15m=Lt(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=Gr.nodeTiming?.bootstrapComplete;return typeof a=="number"&&a>0&&(n.node_boot_ms=Lt(a,1)),n.sample_us=Math.round((Gr.now()-t)*1e3),n}catch{return}}function gi(){try{let e=ie.cpus(),t={},n=typeof ie.availableParallelism=="function"?ie.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,Tp);r&&(t.cpu_model=r);let o=ie.totalmem();t.mem_total_mb=On(o);let s=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof s=="number"&&s>0&&s<o&&(t.mem_limit_mb=On(s)),t.uptime_h=Lt(ie.uptime()/3600,1),t}catch{return{}}}import{createHash as kp,randomBytes as Pp}from"node:crypto";import{existsSync as xn,mkdirSync as Np,readdirSync as wp,readFileSync as Mp,renameSync as _i,statSync as yi,unlinkSync as hi,writeFileSync as vp}from"node:fs";import{homedir as Ri}from"node:os";import{basename as Lp,dirname as Si,isAbsolute as Hp,join as Ci,relative as Ai,resolve as Le,sep as Up}from"node:path";function x(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
14
- `)}function Ht(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}function Ut(e){return kp("sha256").update(e).digest("hex").slice(0,32)}function ae(e,t){Np(Si(e),{recursive:!0});let n=Ci(Si(e),`.${Lp(e)}.${process.pid}.${Pp(4).toString("hex")}.tmp`);try{vp(n,t,"utf8");try{_i(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){hi(e),_i(n,e);return}throw r}}catch(r){try{hi(n)}catch{}throw r}}function In(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}var zr;function Wr(e){zr=e}function Jr(){(zr?.stdout??process.stdout).write('{"continue":true}')}var Dt=new Set(["on","1","true"]),bi=new Set(["off","0","false"]);function v(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function Yr(){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 Tn(e){let t=zr?.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 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:""}function Vr(e,t){let n=Le(e),r=Le(t),o=Ai(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${Up}`)||Hp(o)?!1:Le(r,o)===n}function Oi(e,t,n=Ri()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return Le(e);let o=Le(r),s=Le(e);if(Vr(s,o))return s;let i=t.CURSOR_PLUGIN_ROOT?.trim();return Vr(s,Le(n,".cursor"))||i!==void 0&&i.length>0&&Vr(s,Le(i))?o:s}async function Xr(e=process.cwd(),t=process.env,n=Ri()){let r=Oi(e,t,n),o=r!==Le(e)&&xn(r)?r:e,s=await ye("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(s.ok&&s.stdout)return{root:s.stdout,inGitRepo:!0};if(v("EV_AI_HOOK_DEBUG")){let a=s.ok?"empty stdout":s.spawnFailed?"spawn failed":`exit ${String(s.code??"unknown")}`;x(`DEBUG: git rev-parse --show-toplevel failed (${a}) cwd=${e}`)}let i=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||v("CURSOR_PROJECT_DIR")||v("CLAUDE_PROJECT_DIR");if(i&&xn(i)){let a=await ye("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 qr(e=process.cwd()){return(await Xr(e)).root}function _e(e,t){try{return JSON.parse(e)}catch{return t}}var Ei=new Map;function kn(e){return e.charCodeAt(0)===65279?e.slice(1):e}function Dp(e){let t;try{t=Mp(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(kn(t))}}catch{return{ok:!1,reason:"parse"}}}function xi(e){let t=Ei.get(e);if(t!==void 0)return t;let n=Dp(e);return Ei.set(e,n),n}function Ii(e){return xi(e)}function q(e,t){let n=xi(e);return n.ok?n.value:t}function tt(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 ze=500;function Ti(e,t=2){if(!xn(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,i)=>{if(i>t||r)return;let a;try{a=wp(s,{withFileTypes:!0})}catch{return}for(let c of a){if(r)return;let l=Ci(s,c.name);if(c.isDirectory()){o(l,i+1);continue}if(c.isFile()){try{n.push({name:Ai(e,l),size:yi(l).size})}catch{continue}if(n.length>=ze){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function Zr(e){return xn(e)?{present:!0,size:yi(e).size}:{present:!1,size:0}}function mt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function Pi(e=process.env){return mt(Y("CURSOR_SANDBOX",e))}var Gp=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function Vp(e){return Gp.some(t=>!!Y(t,e))}function zp(e){if(Y("KUBERNETES_SERVICE_HOST",e)||mt(Y("REMOTE_CONTAINERS",e))||mt(Y("DEVCONTAINER",e)))return!0;try{if(Fp("/.dockerenv")||$p("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function Ni(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!Y(t,e))}function Wp(e,t=process.platform){return Ni(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!Y(n,e)):!1}function Jp(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function Yp(e){return e==="linux"}function Y(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return v(e)}function Xp(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!qp(Y("CURSOR_VERSION",n))}function qp(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function Qr(e){if(Jp(e.sessionId))return!0;let t=e.hostname??ki(),n=e.osUser??Mi(e.env);return Xp(t,n,e.env)}function Zp(e){return mt(Y("CURSOR_AGENT",e.env))?!0:Qr(e)}function Qp(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(Y("TERM",e)??Y("TERM_PROGRAM",e))||(Y("SSH_TTY",e)??Y("SSH_CONNECTION",e))||(Y("__CFBundleIdentifier",e)??Y("XPC_SERVICE_NAME",e))||Ni(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!Y(t,e))||Y("SESSIONNAME",e))}function Ft(e={}){let t=e.env;if(Y("GITHUB_ACTIONS",t))return"github_actions";if(mt(Y("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!Wp(t,n)&&Zp(e)&&(mt(Y("CURSOR_AGENT",t))||Yp(n)))return"cursor_cloud";if(Y("CODESPACES",t)||Y("CODESPACE_NAME",t))return"codespaces";if(Y("GITLAB_CI",t))return"gitlab_ci";if(Vp(t))return"managed";let r=Y("CI",t);return r&&r!=="false"&&r!=="0"?"managed":zp(t)?"container":Qp(t)?"interactive":"unknown"}async function wi(){return await te("systemd-detect-virt",[],1e3)}function Mi(e=process.env,t=Kp){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 em=32;function tm(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,em);return t.length>0?t:null}function nm(){try{return[Bp(),jp()].filter(Boolean).join(" ").trim()}catch{return""}}async function vi(e=!1){let t=tm(process.platform),n="";if(process.platform==="darwin")n=await te("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 te("lsb_release",["-sd"],1e3).then(i=>i.replace(/^"|"$/g,""))}n||(n=await te("uname",["-r"],1e3))}else process.platform==="win32"?n=nm():n=await te("ver",[],1e3);let r=Mi(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",s="";try{s=await te("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?gi():{}}}function Pn(){return ki()}import{createHash as pm}from"node:crypto";import{homedir as mm}from"node:os";import{dirname as sO,join as gm,parse as iO,resolve as aO}from"node:path";var Li="EV_AI_LAUNCHER_VERSION";var Hi="EV_AI_HOOK_SOURCE",Ui="EV_AI_HOOK_FALLBACK_REASON",Di="EV_AI_LAUNCHER_SCOPE",eo="EV_AI_LAUNCHER_READY_FD";var Fi="--defer-user-spec",Nn="--cap",$t="--slot";var $i=Buffer.from([1]);var $b=1024*1024,jb=4*1024*1024,Kb=64*1024,Bb=64*1024,Gb=64*1024;var to=4096,Vb=4*1024*1024;var ji="ev-ai.agent-hook.in-process.v1";import{join as Wi}from"node:path";import{open as Ki,mkdir as rm,readFile as om,readdir as sm,rename as im,stat as am,rmdir as cm,unlink as um,utimes as lm}from"node:fs/promises";var wn=new WeakMap;function Gi(e){if(e&&typeof e=="object"&&"code"in e)return e}function gt(e){return Gi(e)?.code==="ENOENT"}function jt(e){return Gi(e)?.code==="EEXIST"}async function Vi(e,t){try{return await e.readdir(t)}catch(n){if(gt(n))return[];throw n}}function zi(){return{async open(e,t){let n=await Ki(e,t),r={path:e};return wn.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=wn.get(e);wn.delete(e),t&&await t.close()},rename:im,async readdir(e){return sm(e)},readFile:om,async stat(e){let t=await am(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await rm(e,t)},unlink:um,rmdir:cm,utimes:lm,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=wn.get(e);if(!t)throw new Error("closed");return t}var Ji=4,Yi=10;function Mn(e=process.platform){return e==="win32"?Ji:Yi}var vn=6e4,Kt=2e3,Xi="slots",no=64;function qi(e){return Wi(e,".ev-ai","agent-hook",Xi)}function Ln(e,t){return Wi(e,`slot-${t}`)}function Hn(e,t){return`${e}
9
+ `):f.join(`
10
+ `).trimEnd();return(0,Ie.usableCatalogText)(d)}s(pS,"parseYamlFrontmatterScalar")});var pu=J(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=ne.COMPONENT_INSPECTION_TEXT_MAX_BYTES=ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;ne.fitSnapshotInspectionTextBudget=mS;ne.capComponentTextBytes=du;ne.prepareComponentInspectionText=gS;ne.redactComponentSource=rs;ne.componentSourceContainsRedactableSecret=AS;ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";ne.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;ne.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function mS(e){let t=0;return e.map(n=>{let r=n,o=r.skill?.inspectionText;if(o===void 0)return n;let i=Buffer.byteLength(o,"utf8");return t+i<=ne.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=i,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}s(mS,"fitSnapshotInspectionTextBudget");function du(e,t){if(e==null||e.length===0)return;let n=Buffer.from(e,"utf8");if(n.byteLength<=t)return e;let r=new TextDecoder("utf-8",{fatal:!0});for(let o=t;o>0;o-=1)try{return r.decode(n.subarray(0,o))}catch{}}s(du,"capComponentTextBytes");function gS(e){if(!(e==null||e.length===0))return du(rs(e),ne.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}s(gS,"prepareComponentInspectionText");var _S=[/\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],hS=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,SS=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,ES=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,yS=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,fu=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function RS(e){let t=e.replace(SS,(n,r)=>`${r}${ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(ES,(n,r)=>`${r}${ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(hS,(n,r)=>`${r}${ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of _S)t=t.replace(n,ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}s(RS,"redactLine");function rs(e){if(e.length===0)return e;let t=e.split(`
11
+ `),n=!1;return t.map(o=>n?fu.test(o)?(n=!1,o):o.trim().length===0?o:ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:yS.test(o)&&!fu.test(o)?(n=!0,o):RS(o)).join(`
12
+ `)}s(rs,"redactComponentSource");function AS(e){return rs(e)!==e}s(AS,"componentSourceContainsRedactableSecret")});var ct=J(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.redactComponentSource=y.prepareComponentInspectionText=y.fitSnapshotInspectionTextBudget=y.componentSourceContainsRedactableSecret=y.capComponentTextBytes=y.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=y.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=y.COMPONENT_INSPECTION_TEXT_MAX_BYTES=y.usableCatalogText=y.parseFrontmatterField=y.parseFrontmatterDescription=y.mcpServerToolSegmentForms=y.mcpServerNameMatchesToolSegment=y.isNpmRegistryPublisher=y.EMPTY_NPM_PUBLISHER=y.displayPublisherName=y.classifyMcpProvenance=y.resolveMcpPackageIdentity=y.McpPackageEcosystem=y.pinnedPackageVersionFromSpec=y.pinnedPackageVersionFromNpx=y.packageNameFromSpec=y.npxPackageSpecs=y.npxExecBin=y.PACKAGE_FIELD_MAX=y.serializeMcpLaunchIdentity=y.projectMcpMissingLaunchIdentity=y.projectMcpLaunchIdentity=y.normalizeMcpToolNames=y.MCP_MISSING_LAUNCH_SERIALIZED=y.MCP_LAUNCH_IDENTITY_ALGORITHM=y.maskMcpLaunchForDisplay=y.launchContainsCredentials=y.hashMcpLaunchIdentity=y.foldMcpName=y.buildMcpFamilyCanonicalKey=y.ComponentKind=void 0;y.userConfigRootFromPath=wS;y.installationRootExternalKey=LS;y.normalizeRepositoryRelativePath=mu;y.nativeKeyForSkillPath=MS;y.nativeKeyForRulePath=vS;y.nativeKeyForCommandPath=US;y.serializeComponentIdentity=_u;y.buildComponentReference=DS;y.validateComponentReference=FS;var CS=qe("node:crypto"),bS=qe("node:path"),OS="cmp1_",xS=/^cmp1_[A-Za-z0-9_-]{43}$/,IS=["/skills/","/skills-cursor/"],kS=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,TS=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,PS=[".cursor",".claude",".codex"],NS={".claude.json":".claude",".agents":".codex"};y.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function wS(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>PS.includes(o));return n||(t.map(o=>NS[o]).find(o=>o!==void 0)??"unknown")}s(wS,"userConfigRootFromPath");function LS(e,t){return`runtime-install:${e}/${t}`}s(LS,"installationRootExternalKey");function br(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}s(br,"requireValue");function mu(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=bS.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return br(n,"sourcePath")}s(mu,"normalizeRepositoryRelativePath");function MS(e){let t=e.replaceAll("\\","/");for(let n of IS){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}s(MS,"nativeKeyForSkillPath");function gu(e,t,n){let r=e.replaceAll("\\","/"),i=t.exec(r)?.[1];if(!i||i.split("/").includes(".."))return null;let a=i.replace(n,"");return a.length>0?a:null}s(gu,"nativeKeyUnderLayoutRoot");function vS(e){return gu(e,kS,/\.(mdc|md|rules)$/i)}s(vS,"nativeKeyForRulePath");function US(e){return gu(e,TS,/\.(md|mdc|toml)$/i)}s(US,"nativeKeyForCommandPath");function HS(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(HS,"field");function _u(e){let t=[br(e.installationRootExternalKey,"installationRootExternalKey"),br(e.installableKind,"installableKind"),mu(e.sourcePath),br(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(HS).join("|")}`,"utf8")}s(_u,"serializeComponentIdentity");function DS(e){let t=(0,CS.createHash)("sha256").update(_u(e)).digest("base64url");return`${OS}${t}`}s(DS,"buildComponentReference");function FS(e){return xS.test(e)}s(FS,"validateComponentReference");var ke=yr();Object.defineProperty(y,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:s(function(){return ke.buildMcpFamilyCanonicalKey},"get")});Object.defineProperty(y,"foldMcpName",{enumerable:!0,get:s(function(){return ke.foldMcpName},"get")});Object.defineProperty(y,"hashMcpLaunchIdentity",{enumerable:!0,get:s(function(){return ke.hashMcpLaunchIdentity},"get")});Object.defineProperty(y,"launchContainsCredentials",{enumerable:!0,get:s(function(){return ke.launchContainsCredentials},"get")});Object.defineProperty(y,"maskMcpLaunchForDisplay",{enumerable:!0,get:s(function(){return ke.maskMcpLaunchForDisplay},"get")});Object.defineProperty(y,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:s(function(){return ke.MCP_LAUNCH_IDENTITY_ALGORITHM},"get")});Object.defineProperty(y,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:s(function(){return ke.MCP_MISSING_LAUNCH_SERIALIZED},"get")});Object.defineProperty(y,"normalizeMcpToolNames",{enumerable:!0,get:s(function(){return ke.normalizeMcpToolNames},"get")});Object.defineProperty(y,"projectMcpLaunchIdentity",{enumerable:!0,get:s(function(){return ke.projectMcpLaunchIdentity},"get")});Object.defineProperty(y,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:s(function(){return ke.projectMcpMissingLaunchIdentity},"get")});Object.defineProperty(y,"serializeMcpLaunchIdentity",{enumerable:!0,get:s(function(){return ke.serializeMcpLaunchIdentity},"get")});var Bt=Ar();Object.defineProperty(y,"PACKAGE_FIELD_MAX",{enumerable:!0,get:s(function(){return Bt.PACKAGE_FIELD_MAX},"get")});Object.defineProperty(y,"npxExecBin",{enumerable:!0,get:s(function(){return Bt.npxExecBin},"get")});Object.defineProperty(y,"npxPackageSpecs",{enumerable:!0,get:s(function(){return Bt.npxPackageSpecs},"get")});Object.defineProperty(y,"packageNameFromSpec",{enumerable:!0,get:s(function(){return Bt.packageNameFromSpec},"get")});Object.defineProperty(y,"pinnedPackageVersionFromNpx",{enumerable:!0,get:s(function(){return Bt.pinnedPackageVersionFromNpx},"get")});Object.defineProperty(y,"pinnedPackageVersionFromSpec",{enumerable:!0,get:s(function(){return Bt.pinnedPackageVersionFromSpec},"get")});var hu=tu();Object.defineProperty(y,"McpPackageEcosystem",{enumerable:!0,get:s(function(){return hu.McpPackageEcosystem},"get")});Object.defineProperty(y,"resolveMcpPackageIdentity",{enumerable:!0,get:s(function(){return hu.resolveMcpPackageIdentity},"get")});var Or=au();Object.defineProperty(y,"classifyMcpProvenance",{enumerable:!0,get:s(function(){return Or.classifyMcpProvenance},"get")});Object.defineProperty(y,"displayPublisherName",{enumerable:!0,get:s(function(){return Or.displayPublisherName},"get")});Object.defineProperty(y,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:s(function(){return Or.EMPTY_NPM_PUBLISHER},"get")});Object.defineProperty(y,"isNpmRegistryPublisher",{enumerable:!0,get:s(function(){return Or.isNpmRegistryPublisher},"get")});var Su=uu();Object.defineProperty(y,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:s(function(){return Su.mcpServerNameMatchesToolSegment},"get")});Object.defineProperty(y,"mcpServerToolSegmentForms",{enumerable:!0,get:s(function(){return Su.mcpServerToolSegmentForms},"get")});var os=lu();Object.defineProperty(y,"parseFrontmatterDescription",{enumerable:!0,get:s(function(){return os.parseFrontmatterDescription},"get")});Object.defineProperty(y,"parseFrontmatterField",{enumerable:!0,get:s(function(){return os.parseFrontmatterField},"get")});Object.defineProperty(y,"usableCatalogText",{enumerable:!0,get:s(function(){return os.usableCatalogText},"get")});var at=pu();Object.defineProperty(y,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return at.COMPONENT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(y,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:s(function(){return at.COMPONENT_SOURCE_REDACTION_PLACEHOLDER},"get")});Object.defineProperty(y,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return at.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(y,"capComponentTextBytes",{enumerable:!0,get:s(function(){return at.capComponentTextBytes},"get")});Object.defineProperty(y,"componentSourceContainsRedactableSecret",{enumerable:!0,get:s(function(){return at.componentSourceContainsRedactableSecret},"get")});Object.defineProperty(y,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:s(function(){return at.fitSnapshotInspectionTextBudget},"get")});Object.defineProperty(y,"prepareComponentInspectionText",{enumerable:!0,get:s(function(){return at.prepareComponentInspectionText},"get")});Object.defineProperty(y,"redactComponentSource",{enumerable:!0,get:s(function(){return at.redactComponentSource},"get")})});var Vr=J(be=>{"use strict";be.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;be.find=(e,t)=>e.nodes.find(n=>n.type===t);be.exceedsLimit=(e,t,n=1,r)=>r===!1||!be.isInteger(e)||!be.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;be.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)};be.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;be.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;be.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;be.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);be.flatten=(...e)=>{let t=[],n=s(r=>{for(let o=0;o<r.length;o++){let i=r[o];if(Array.isArray(i)){n(i);continue}i!==void 0&&t.push(i)}return t},"flat");return n(e),t}});var zr=J((gN,ql)=>{"use strict";var Xl=Vr();ql.exports=(e,t={})=>{let n=s((r,o={})=>{let i=t.escapeInvalid&&Xl.isInvalidBrace(o),a=r.invalid===!0&&t.escapeInvalid===!0,c="";if(r.value)return(i||a)&&Xl.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let u of r.nodes)c+=n(u);return c},"stringify");return n(e)}});var Ql=J((hN,Zl)=>{"use strict";Zl.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var uf=J((SN,cf)=>{"use strict";var ef=Ql(),Rt=s((e,t,n)=>{if(ef(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(ef(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let o=String(r.relaxZeros),i=String(r.shorthand),a=String(r.capture),c=String(r.wrap),u=e+":"+t+"="+o+i+a+c;if(Rt.cache.hasOwnProperty(u))return Rt.cache[u].result;let f=Math.min(e,t),l=Math.max(e,t);if(Math.abs(f-l)===1){let E=e+"|"+t;return r.capture?`(${E})`:r.wrap===!1?E:`(?:${E})`}let p=af(e)||af(t),d={min:e,max:t,a:f,b:l},m=[],_=[];if(p&&(d.isPadded=p,d.maxLen=String(d.max).length),f<0){let E=l<0?Math.abs(l):1;_=tf(E,Math.abs(f),d,r),f=d.a=0}return l>=0&&(m=tf(f,l,d,r)),d.negatives=_,d.positives=m,d.result=yR(_,m,r),r.capture===!0?d.result=`(${d.result})`:r.wrap!==!1&&m.length+_.length>1&&(d.result=`(?:${d.result})`),Rt.cache[u]=d,d.result},"toRegexRange");function yR(e,t,n){let r=Ds(e,t,"-",!1,n)||[],o=Ds(t,e,"",!1,n)||[],i=Ds(e,t,"-?",!0,n)||[];return r.concat(i).concat(o).join("|")}s(yR,"collatePatterns");function RR(e,t){let n=1,r=1,o=rf(e,n),i=new Set([t]);for(;e<=o&&o<=t;)i.add(o),n+=1,o=rf(e,n);for(o=of(t+1,r)-1;e<o&&o<=t;)i.add(o),r+=1,o=of(t+1,r)-1;return i=[...i],i.sort(bR),i}s(RR,"splitToRanges");function AR(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=CR(e,t),o=r.length,i="",a=0;for(let c=0;c<o;c++){let[u,f]=r[c];u===f?i+=u:u!=="0"||f!=="9"?i+=OR(u,f,n):a++}return a&&(i+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:i,count:[a],digits:o}}s(AR,"rangeToPattern");function tf(e,t,n,r){let o=RR(e,t),i=[],a=e,c;for(let u=0;u<o.length;u++){let f=o[u],l=AR(String(a),String(f),r),p="";if(!n.isPadded&&c&&c.pattern===l.pattern){c.count.length>1&&c.count.pop(),c.count.push(l.count[0]),c.string=c.pattern+sf(c.count),a=f+1;continue}n.isPadded&&(p=xR(f,n,r)),l.string=p+l.pattern+sf(l.count),i.push(l),a=f+1,c=l}return i}s(tf,"splitToPatterns");function Ds(e,t,n,r,o){let i=[];for(let a of e){let{string:c}=a;!r&&!nf(t,"string",c)&&i.push(n+c),r&&nf(t,"string",c)&&i.push(n+c)}return i}s(Ds,"filterPatterns");function CR(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}s(CR,"zip");function bR(e,t){return e>t?1:t>e?-1:0}s(bR,"compare");function nf(e,t,n){return e.some(r=>r[t]===n)}s(nf,"contains");function rf(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}s(rf,"countNines");function of(e,t){return e-e%Math.pow(10,t)}s(of,"countZeros");function sf(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}s(sf,"toQuantifier");function OR(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}s(OR,"toCharacterClass");function af(e){return/^-?(0+)\d/.test(e)}s(af,"hasPadding");function xR(e,t,n){if(!t.isPadded)return e;let r=Math.abs(t.maxLen-String(e).length),o=n.relaxZeros!==!1;switch(r){case 0:return"";case 1:return o?"0?":"0";case 2:return o?"0{0,2}":"00";default:return o?`0{0,${r}}`:`0{${r}}`}}s(xR,"padZeros");Rt.cache={};Rt.clearCache=()=>Rt.cache={};cf.exports=Rt});var js=J((yN,_f)=>{"use strict";var IR=qe("util"),ff=uf(),lf=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"isObject"),kR=s(e=>t=>e===!0?Number(t):String(t),"transform"),Fs=s(e=>typeof e=="number"||typeof e=="string"&&e!=="","isValidValue"),kn=s(e=>Number.isInteger(+e),"isNumber"),$s=s(e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},"zeros"),TR=s((e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,"stringify"),PR=s((e,t,n)=>{if(t>0){let r=e[0]==="-"?"-":"";r&&(e=e.slice(1)),e=r+e.padStart(r?t-1:t,"0")}return n===!1?String(e):e},"pad"),Jr=s((e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},"toMaxLen"),NR=s((e,t,n)=>{e.negatives.sort((c,u)=>c<u?-1:c>u?1:0),e.positives.sort((c,u)=>c<u?-1:c>u?1:0);let r=t.capture?"":"?:",o="",i="",a;return e.positives.length&&(o=e.positives.map(c=>Jr(String(c),n)).join("|")),e.negatives.length&&(i=`-(${r}${e.negatives.map(c=>Jr(String(c),n)).join("|")})`),o&&i?a=`${o}|${i}`:a=o||i,t.wrap?`(${r}${a})`:a},"toSequence"),df=s((e,t,n,r)=>{if(n)return ff(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let i=String.fromCharCode(t);return`[${o}-${i}]`},"toRange"),pf=s((e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return ff(e,t,n)},"toRegex"),mf=s((...e)=>new RangeError("Invalid range arguments: "+IR.inspect(...e)),"rangeError"),gf=s((e,t,n)=>{if(n.strictRanges===!0)throw mf([e,t]);return[]},"invalidRange"),wR=s((e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},"invalidStep"),LR=s((e,t,n=1,r={})=>{let o=Number(e),i=Number(t);if(!Number.isInteger(o)||!Number.isInteger(i)){if(r.strictRanges===!0)throw mf([e,t]);return[]}o===0&&(o=0),i===0&&(i=0);let a=o>i,c=String(e),u=String(t),f=String(n);n=Math.max(Math.abs(n),1);let l=$s(c)||$s(u)||$s(f),p=l?Math.max(c.length,u.length,f.length):0,d=l===!1&&TR(e,t,r)===!1,m=r.transform||kR(d);if(r.toRegex&&n===1)return df(Jr(e,p),Jr(t,p),!0,r);let _={negatives:[],positives:[]},E=s(k=>_[k<0?"negatives":"positives"].push(Math.abs(k)),"push"),C=[],b=0;for(;a?o>=i:o<=i;)r.toRegex===!0&&n>1?E(o):C.push(PR(m(o,b),p,d)),o=a?o-n:o+n,b++;return r.toRegex===!0?n>1?NR(_,r,p):pf(C,null,{wrap:!1,...r}):C},"fillNumbers"),MR=s((e,t,n=1,r={})=>{if(!kn(e)&&e.length>1||!kn(t)&&t.length>1)return gf(e,t,r);let o=r.transform||(d=>String.fromCharCode(d)),i=`${e}`.charCodeAt(0),a=`${t}`.charCodeAt(0),c=i>a,u=Math.min(i,a),f=Math.max(i,a);if(r.toRegex&&n===1)return df(u,f,!1,r);let l=[],p=0;for(;c?i>=a:i<=a;)l.push(o(i,p)),i=c?i-n:i+n,p++;return r.toRegex===!0?pf(l,null,{wrap:!1,options:r}):l},"fillLetters"),Wr=s((e,t,n,r={})=>{if(t==null&&Fs(e))return[e];if(!Fs(e)||!Fs(t))return gf(e,t,r);if(typeof n=="function")return Wr(e,t,1,{transform:n});if(lf(n))return Wr(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,kn(n)?kn(e)&&kn(t)?LR(e,t,n,o):MR(e,t,Math.max(Math.abs(n),1),o):n!=null&&!lf(n)?wR(n,o):Wr(e,t,1,n)},"fill");_f.exports=Wr});var Ef=J((AN,Sf)=>{"use strict";var vR=js(),hf=Vr(),UR=s((e,t={})=>{let n=s((r,o={})=>{let i=hf.isInvalidBrace(o),a=r.invalid===!0&&t.escapeInvalid===!0,c=i===!0||a===!0,u=t.escapeInvalid===!0?"\\":"",f="";if(r.isOpen===!0)return u+r.value;if(r.isClose===!0)return console.log("node.isClose",u,r.value),u+r.value;if(r.type==="open")return c?u+r.value:"(";if(r.type==="close")return c?u+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":c?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let l=hf.reduce(r.nodes),p=vR(...l,{...t,wrap:!1,toRegex:!0,strictZeros:!0});if(p.length!==0)return l.length>1&&p.length>1?`(${p})`:p}if(r.nodes)for(let l of r.nodes)f+=n(l,r);return f},"walk");return n(e)},"compile");Sf.exports=UR});var Af=J((bN,Rf)=>{"use strict";var HR=js(),yf=zr(),zt=Vr(),At=s((e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?zt.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let i of o)r.push(At(i,t,n));else for(let i of t)n===!0&&typeof i=="string"&&(i=`{${i}}`),r.push(Array.isArray(i)?At(o,i,n):o+i);return zt.flatten(r)},"append"),DR=s((e,t={})=>{let n=t.rangeLimit===void 0?1e3:t.rangeLimit,r=s((o,i={})=>{o.queue=[];let a=i,c=i.queue;for(;a.type!=="brace"&&a.type!=="root"&&a.parent;)a=a.parent,c=a.queue;if(o.invalid||o.dollar){c.push(At(c.pop(),yf(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){c.push(At(c.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let p=zt.reduce(o.nodes);if(zt.exceedsLimit(...p,t.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let d=HR(...p,t);d.length===0&&(d=yf(o,t)),c.push(At(c.pop(),d)),o.nodes=[];return}let u=zt.encloseBrace(o),f=o.queue,l=o;for(;l.type!=="brace"&&l.type!=="root"&&l.parent;)l=l.parent,f=l.queue;for(let p=0;p<o.nodes.length;p++){let d=o.nodes[p];if(d.type==="comma"&&o.type==="brace"){p===1&&f.push(""),f.push("");continue}if(d.type==="close"){c.push(At(c.pop(),f,u));continue}if(d.value&&d.type!=="open"){f.push(At(f.pop(),d.value));continue}d.nodes&&r(d,o)}return f},"walk");return zt.flatten(r(e))},"expand");Rf.exports=DR});var bf=J((xN,Cf)=>{"use strict";Cf.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:`
13
+ `,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 Tf=J((IN,kf)=>{"use strict";var FR=zr(),{MAX_LENGTH:Of,CHAR_BACKSLASH:Bs,CHAR_BACKTICK:$R,CHAR_COMMA:jR,CHAR_DOT:BR,CHAR_LEFT_PARENTHESES:KR,CHAR_RIGHT_PARENTHESES:GR,CHAR_LEFT_CURLY_BRACE:VR,CHAR_RIGHT_CURLY_BRACE:zR,CHAR_LEFT_SQUARE_BRACKET:xf,CHAR_RIGHT_SQUARE_BRACKET:If,CHAR_DOUBLE_QUOTE:WR,CHAR_SINGLE_QUOTE:JR,CHAR_NO_BREAK_SPACE:YR,CHAR_ZERO_WIDTH_NOBREAK_SPACE:XR}=bf(),qR=s((e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Of,n.maxLength):Of;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},i=[o],a=o,c=o,u=0,f=e.length,l=0,p=0,d,m=s(()=>e[l++],"advance"),_=s(E=>{if(E.type==="text"&&c.type==="dot"&&(c.type="text"),c&&c.type==="text"&&E.type==="text"){c.value+=E.value;return}return a.nodes.push(E),E.parent=a,E.prev=c,c=E,E},"push");for(_({type:"bos"});l<f;)if(a=i[i.length-1],d=m(),!(d===XR||d===YR)){if(d===Bs){_({type:"text",value:(t.keepEscaping?d:"")+m()});continue}if(d===If){_({type:"text",value:"\\"+d});continue}if(d===xf){u++;let E;for(;l<f&&(E=m());){if(d+=E,E===xf){u++;continue}if(E===Bs){d+=m();continue}if(E===If&&(u--,u===0))break}_({type:"text",value:d});continue}if(d===KR){a=_({type:"paren",nodes:[]}),i.push(a),_({type:"text",value:d});continue}if(d===GR){if(a.type!=="paren"){_({type:"text",value:d});continue}a=i.pop(),_({type:"text",value:d}),a=i[i.length-1];continue}if(d===WR||d===JR||d===$R){let E=d,C;for(t.keepQuotes!==!0&&(d="");l<f&&(C=m());){if(C===Bs){d+=C+m();continue}if(C===E){t.keepQuotes===!0&&(d+=C);break}d+=C}_({type:"text",value:d});continue}if(d===VR){p++;let C={type:"brace",open:!0,close:!1,dollar:c.value&&c.value.slice(-1)==="$"||a.dollar===!0,depth:p,commas:0,ranges:0,nodes:[]};a=_(C),i.push(a),_({type:"open",value:d});continue}if(d===zR){if(a.type!=="brace"){_({type:"text",value:d});continue}let E="close";a=i.pop(),a.close=!0,_({type:E,value:d}),p--,a=i[i.length-1];continue}if(d===jR&&p>0){if(a.ranges>0){a.ranges=0;let E=a.nodes.shift();a.nodes=[E,{type:"text",value:FR(a)}]}_({type:"comma",value:d}),a.commas++;continue}if(d===BR&&p>0&&a.commas===0){let E=a.nodes;if(p===0||E.length===0){_({type:"text",value:d});continue}if(c.type==="dot"){if(a.range=[],c.value+=d,c.type="range",a.nodes.length!==3&&a.nodes.length!==5){a.invalid=!0,a.ranges=0,c.type="text";continue}a.ranges++,a.args=[];continue}if(c.type==="range"){E.pop();let C=E[E.length-1];C.value+=c.value+d,c=C,a.ranges--;continue}_({type:"dot",value:d});continue}_({type:"text",value:d})}do if(a=i.pop(),a.type!=="root"){a.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 E=i[i.length-1],C=E.nodes.indexOf(a);E.nodes.splice(C,1,...a.nodes)}while(i.length>0);return _({type:"eos"}),o},"parse");kf.exports=qR});var wf=J((TN,Nf)=>{"use strict";var Pf=zr(),ZR=Ef(),QR=Af(),eA=Tf(),ye=s((e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=ye.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(ye.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n},"braces");ye.parse=(e,t={})=>eA(e,t);ye.stringify=(e,t={})=>Pf(typeof e=="string"?ye.parse(e,t):e,t);ye.compile=(e,t={})=>(typeof e=="string"&&(e=ye.parse(e,t)),ZR(e,t));ye.expand=(e,t={})=>{typeof e=="string"&&(e=ye.parse(e,t));let n=QR(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};ye.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?ye.compile(e,t):ye.expand(e,t);Nf.exports=ye});var Tn=J((NN,Hf)=>{"use strict";var tA=qe("path"),He="\\\\/",Lf=`[^${He}]`,nA=0,Ye="\\.",rA="\\+",oA="\\?",Yr="\\/",sA="(?=.)",Mf="[^/]",Ks=`(?:${Yr}|$)`,vf=`(?:^|${Yr})`,Gs=`${Ye}{1,2}${Ks}`,iA=`(?!${Ye})`,aA=`(?!${vf}${Gs})`,cA=`(?!${Ye}{0,1}${Ks})`,uA=`(?!${Gs})`,lA=`[^.${Yr}]`,fA=`${Mf}*?`,Uf={DOT_LITERAL:Ye,PLUS_LITERAL:rA,QMARK_LITERAL:oA,SLASH_LITERAL:Yr,ONE_CHAR:sA,QMARK:Mf,END_ANCHOR:Ks,DOTS_SLASH:Gs,NO_DOT:iA,NO_DOTS:aA,NO_DOT_SLASH:cA,NO_DOTS_SLASH:uA,QMARK_NO_DOT:lA,STAR:fA,START_ANCHOR:vf},dA={...Uf,SLASH_LITERAL:`[${He}]`,QMARK:Lf,STAR:`${Lf}*?`,DOTS_SLASH:`${Ye}{1,2}(?:[${He}]|$)`,NO_DOT:`(?!${Ye})`,NO_DOTS:`(?!(?:^|[${He}])${Ye}{1,2}(?:[${He}]|$))`,NO_DOT_SLASH:`(?!${Ye}{0,1}(?:[${He}]|$))`,NO_DOTS_SLASH:`(?!${Ye}{1,2}(?:[${He}]|$))`,QMARK_NO_DOT:`[^.${He}]`,START_ANCHOR:`(?:^|[${He}])`,END_ANCHOR:`(?:[${He}]|$)`},pA={__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"};Hf.exports={DEFAULT_MAX_EXTGLOB_RECURSION:nA,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:pA,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:tA.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?dA:Uf}}});var Pn=J(me=>{"use strict";var mA=qe("path"),gA=process.platform==="win32",{REGEX_BACKSLASH:_A,REGEX_REMOVE_BACKSLASH:hA,REGEX_SPECIAL_CHARS:SA,REGEX_SPECIAL_CHARS_GLOBAL:EA}=Tn();me.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);me.hasRegexChars=e=>SA.test(e);me.isRegexChar=e=>e.length===1&&me.hasRegexChars(e);me.escapeRegex=e=>e.replace(EA,"\\$1");me.toPosixSlashes=e=>e.replace(_A,"/");me.removeBackslashes=e=>e.replace(hA,t=>t==="\\"?"":t);me.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};me.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:gA===!0||mA.sep==="\\";me.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?me.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};me.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};me.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",i=`${r}(?:${e})${o}`;return t.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var Vf=J((LN,Gf)=>{"use strict";var Df=Pn(),{CHAR_ASTERISK:Vs,CHAR_AT:yA,CHAR_BACKWARD_SLASH:Nn,CHAR_COMMA:RA,CHAR_DOT:zs,CHAR_EXCLAMATION_MARK:Ws,CHAR_FORWARD_SLASH:Kf,CHAR_LEFT_CURLY_BRACE:Js,CHAR_LEFT_PARENTHESES:Ys,CHAR_LEFT_SQUARE_BRACKET:AA,CHAR_PLUS:CA,CHAR_QUESTION_MARK:Ff,CHAR_RIGHT_CURLY_BRACE:bA,CHAR_RIGHT_PARENTHESES:$f,CHAR_RIGHT_SQUARE_BRACKET:OA}=Tn(),jf=s(e=>e===Kf||e===Nn,"isPathSeparator"),Bf=s(e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},"depth"),xA=s((e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,i=[],a=[],c=[],u=e,f=-1,l=0,p=0,d=!1,m=!1,_=!1,E=!1,C=!1,b=!1,k=!1,w=!1,N=!1,I=!1,$=0,L,O,P={value:"",depth:0,isGlob:!1},H=s(()=>f>=r,"eos"),g=s(()=>u.charCodeAt(f+1),"peek"),x=s(()=>(L=O,u.charCodeAt(++f)),"advance");for(;f<r;){O=x();let fe;if(O===Nn){k=P.backslashes=!0,O=x(),O===Js&&(b=!0);continue}if(b===!0||O===Js){for($++;H()!==!0&&(O=x());){if(O===Nn){k=P.backslashes=!0,x();continue}if(O===Js){$++;continue}if(b!==!0&&O===zs&&(O=x())===zs){if(d=P.isBrace=!0,_=P.isGlob=!0,I=!0,o===!0)continue;break}if(b!==!0&&O===RA){if(d=P.isBrace=!0,_=P.isGlob=!0,I=!0,o===!0)continue;break}if(O===bA&&($--,$===0)){b=!1,d=P.isBrace=!0,I=!0;break}}if(o===!0)continue;break}if(O===Kf){if(i.push(f),a.push(P),P={value:"",depth:0,isGlob:!1},I===!0)continue;if(L===zs&&f===l+1){l+=2;continue}p=f+1;continue}if(n.noext!==!0&&(O===CA||O===yA||O===Vs||O===Ff||O===Ws)===!0&&g()===Ys){if(_=P.isGlob=!0,E=P.isExtglob=!0,I=!0,O===Ws&&f===l&&(N=!0),o===!0){for(;H()!==!0&&(O=x());){if(O===Nn){k=P.backslashes=!0,O=x();continue}if(O===$f){_=P.isGlob=!0,I=!0;break}}continue}break}if(O===Vs){if(L===Vs&&(C=P.isGlobstar=!0),_=P.isGlob=!0,I=!0,o===!0)continue;break}if(O===Ff){if(_=P.isGlob=!0,I=!0,o===!0)continue;break}if(O===AA){for(;H()!==!0&&(fe=x());){if(fe===Nn){k=P.backslashes=!0,x();continue}if(fe===OA){m=P.isBracket=!0,_=P.isGlob=!0,I=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&O===Ws&&f===l){w=P.negated=!0,l++;continue}if(n.noparen!==!0&&O===Ys){if(_=P.isGlob=!0,o===!0){for(;H()!==!0&&(O=x());){if(O===Ys){k=P.backslashes=!0,O=x();continue}if(O===$f){I=!0;break}}continue}break}if(_===!0){if(I=!0,o===!0)continue;break}}n.noext===!0&&(E=!1,_=!1);let j=u,_e="",h="";l>0&&(_e=u.slice(0,l),u=u.slice(l),p-=l),j&&_===!0&&p>0?(j=u.slice(0,p),h=u.slice(p)):_===!0?(j="",h=u):j=u,j&&j!==""&&j!=="/"&&j!==u&&jf(j.charCodeAt(j.length-1))&&(j=j.slice(0,-1)),n.unescape===!0&&(h&&(h=Df.removeBackslashes(h)),j&&k===!0&&(j=Df.removeBackslashes(j)));let S={prefix:_e,input:e,start:l,base:j,glob:h,isBrace:d,isBracket:m,isGlob:_,isExtglob:E,isGlobstar:C,negated:w,negatedExtglob:N};if(n.tokens===!0&&(S.maxDepth=0,jf(O)||a.push(P),S.tokens=a),n.parts===!0||n.tokens===!0){let fe;for(let B=0;B<i.length;B++){let Te=fe?fe+1:l,Pe=i[B],he=e.slice(Te,Pe);n.tokens&&(B===0&&l!==0?(a[B].isPrefix=!0,a[B].value=_e):a[B].value=he,Bf(a[B]),S.maxDepth+=a[B].depth),(B!==0||he!=="")&&c.push(he),fe=Pe}if(fe&&fe+1<e.length){let B=e.slice(fe+1);c.push(B),n.tokens&&(a[a.length-1].value=B,Bf(a[a.length-1]),S.maxDepth+=a[a.length-1].depth)}S.slashes=i,S.parts=c}return S},"scan");Gf.exports=xA});var Xf=J((vN,Yf)=>{"use strict";var wn=Tn(),le=Pn(),{MAX_LENGTH:Xr,POSIX_REGEX_SOURCE:IA,REGEX_NON_SPECIAL_CHARS:kA,REGEX_SPECIAL_CHARS_BACKREF:TA,REPLACEMENTS:zf}=wn,PA=s((e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(o=>le.escapeRegex(o)).join("..")}return n},"expandRange"),Wt=s((e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,"syntaxError"),Wf=s(e=>{let t=[],n=0,r=0,o=0,i="",a=!1;for(let c of e){if(a===!0){i+=c,a=!1;continue}if(c==="\\"){i+=c,a=!0;continue}if(c==='"'){o=o===1?0:1,i+=c;continue}if(o===0){if(c==="[")n++;else if(c==="]"&&n>0)n--;else if(n===0){if(c==="(")r++;else if(c===")"&&r>0)r--;else if(c==="|"&&r===0){t.push(i),i="";continue}}}i+=c}return t.push(i),t},"splitTopLevel"),NA=s(e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n==="\\"){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},"isPlainBranch"),Jf=s(e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(NA(t))return t.replace(/\\(.)/g,"$1")},"normalizeSimpleBranch"),wA=s(e=>{let t=e.map(Jf).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],i=t[r],a=o[0];if(!(!a||o!==a.repeat(o.length)||i!==a.repeat(i.length))&&(o===i||o.startsWith(i)||i.startsWith(o)))return!0}return!1},"hasRepeatedCharPrefixOverlap"),Xs=s((e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,o=0,i=!1;for(let a=1;a<e.length;a++){let c=e[a];if(i===!0){i=!1;continue}if(c==="\\"){i=!0;continue}if(c==='"'){o=o===1?0:1;continue}if(o!==1){if(c==="["){n++;continue}if(c==="]"&&n>0){n--;continue}if(!(n>0)){if(c==="("){r++;continue}if(c===")"&&(r--,r===0))return t===!0&&a!==e.length-1?void 0:{type:e[0],body:e.slice(2,a),end:a}}}}},"parseRepeatedExtglob"),LA=s(e=>{let t=0,n=[];for(;t<e.length;){let o=Xs(e.slice(t),!1);if(!o||o.type!=="*")return;let i=Wf(o.body).map(c=>c.trim());if(i.length!==1)return;let a=Jf(i[0]);if(!a||a.length!==1)return;n.push(a),t+=o.end+1}return n.length<1?void 0:`${n.length===1?le.escapeRegex(n[0]):`[${n.map(o=>le.escapeRegex(o)).join("")}]`}*`},"getStarExtglobSequenceOutput"),MA=s(e=>{let t=0,n=e.trim(),r=Xs(n);for(;r;)t++,n=r.body.trim(),r=Xs(n);return t},"repeatedExtglobRecursion"),vA=s((e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:wn.DEFAULT_MAX_EXTGLOB_RECURSION,r=Wf(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||wA(r)))return{risky:!0};for(let o of r){let i=LA(o);if(i)return{risky:!0,safeOutput:i};if(MA(o)>n)return{risky:!0}}return{risky:!1}},"analyzeRepeatedExtglob"),qs=s((e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=zf[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(Xr,n.maxLength):Xr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let i={type:"bos",value:"",output:n.prepend||""},a=[i],c=n.capture?"":"?:",u=le.isWindows(t),f=wn.globChars(u),l=wn.extglobChars(f),{DOT_LITERAL:p,PLUS_LITERAL:d,SLASH_LITERAL:m,ONE_CHAR:_,DOTS_SLASH:E,NO_DOT:C,NO_DOT_SLASH:b,NO_DOTS_SLASH:k,QMARK:w,QMARK_NO_DOT:N,STAR:I,START_ANCHOR:$}=f,L=s(A=>`(${c}(?:(?!${$}${A.dot?E:p}).)*?)`,"globstar"),O=n.dot?"":C,P=n.dot?w:N,H=n.bash===!0?L(n):I;n.capture&&(H=`(${H})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let g={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:a};e=le.removePrefix(e,g),o=e.length;let x=[],j=[],_e=[],h=i,S,fe=s(()=>g.index===o-1,"eos"),B=g.peek=(A=1)=>e[g.index+A],Te=g.advance=()=>e[++g.index]||"",Pe=s(()=>e.slice(g.index+1),"remaining"),he=s((A="",X=0)=>{g.consumed+=A,g.index+=X},"consume"),Kn=s(A=>{g.output+=A.output!=null?A.output:A.value,he(A.value)},"append"),Am=s(()=>{let A=1;for(;B()==="!"&&(B(2)!=="("||B(3)==="?");)Te(),g.start++,A++;return A%2===0?!1:(g.negated=!0,g.start++,!0)},"negate"),Gn=s(A=>{g[A]++,_e.push(A)},"increment"),Xe=s(A=>{g[A]--,_e.pop()},"decrement"),v=s(A=>{if(h.type==="globstar"){let X=g.braces>0&&(A.type==="comma"||A.type==="brace"),R=A.extglob===!0||x.length&&(A.type==="pipe"||A.type==="paren");A.type!=="slash"&&A.type!=="paren"&&!X&&!R&&(g.output=g.output.slice(0,-h.output.length),h.type="star",h.value="*",h.output=H,g.output+=h.output)}if(x.length&&A.type!=="paren"&&(x[x.length-1].inner+=A.value),(A.value||A.output)&&Kn(A),h&&h.type==="text"&&A.type==="text"){h.value+=A.value,h.output=(h.output||"")+A.value;return}A.prev=h,a.push(A),h=A},"push"),Vn=s((A,X)=>{let R={...l[X],conditions:1,inner:""};R.prev=h,R.parens=g.parens,R.output=g.output,R.startIndex=g.index,R.tokensIndex=a.length;let M=(n.capture?"(":"")+R.open;Gn("parens"),v({type:A,value:X,output:g.output?"":_}),v({type:"paren",extglob:!0,value:Te(),output:M}),x.push(R)},"extglobOpen"),Cm=s(A=>{let X=e.slice(A.startIndex,g.index+1),R=e.slice(A.startIndex+2,g.index),M=vA(R,n);if((A.type==="plus"||A.type==="star")&&M.risky){let z=M.safeOutput?(A.output?"":_)+(n.capture?`(${M.safeOutput})`:M.safeOutput):void 0,Ne=a[A.tokensIndex];Ne.type="text",Ne.value=X,Ne.output=z||le.escapeRegex(X);for(let we=A.tokensIndex+1;we<a.length;we++)a[we].value="",a[we].output="",delete a[we].suffix;g.output=A.output+Ne.output,g.backtrack=!0,v({type:"paren",extglob:!0,value:S,output:""}),Xe("parens");return}let W=A.close+(n.capture?")":""),ie;if(A.type==="negate"){let z=H;if(A.inner&&A.inner.length>1&&A.inner.includes("/")&&(z=L(n)),(z!==H||fe()||/^\)+$/.test(Pe()))&&(W=A.close=`)$))${z}`),A.inner.includes("*")&&(ie=Pe())&&/^\.[^\\/.]+$/.test(ie)){let Ne=qs(ie,{...t,fastpaths:!1}).output;W=A.close=`)${Ne})${z})`}A.prev.type==="bos"&&(g.negatedExtglob=!0)}v({type:"paren",extglob:!0,value:S,output:W}),Xe("parens")},"extglobClose");if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let A=!1,X=e.replace(TA,(R,M,W,ie,z,Ne)=>ie==="\\"?(A=!0,R):ie==="?"?M?M+ie+(z?w.repeat(z.length):""):Ne===0?P+(z?w.repeat(z.length):""):w.repeat(W.length):ie==="."?p.repeat(W.length):ie==="*"?M?M+ie+(z?H:""):H:M?R:`\\${R}`);return A===!0&&(n.unescape===!0?X=X.replace(/\\/g,""):X=X.replace(/\\+/g,R=>R.length%2===0?"\\\\":R?"\\":"")),X===e&&n.contains===!0?(g.output=e,g):(g.output=le.wrapOutput(X,g,t),g)}for(;!fe();){if(S=Te(),S==="\0")continue;if(S==="\\"){let R=B();if(R==="/"&&n.bash!==!0||R==="."||R===";")continue;if(!R){S+="\\",v({type:"text",value:S});continue}let M=/^\\+/.exec(Pe()),W=0;if(M&&M[0].length>2&&(W=M[0].length,g.index+=W,W%2!==0&&(S+="\\")),n.unescape===!0?S=Te():S+=Te(),g.brackets===0){v({type:"text",value:S});continue}}if(g.brackets>0&&(S!=="]"||h.value==="["||h.value==="[^")){if(n.posix!==!1&&S===":"){let R=h.value.slice(1);if(R.includes("[")&&(h.posix=!0,R.includes(":"))){let M=h.value.lastIndexOf("["),W=h.value.slice(0,M),ie=h.value.slice(M+2),z=IA[ie];if(z){h.value=W+z,g.backtrack=!0,Te(),!i.output&&a.indexOf(h)===1&&(i.output=_);continue}}}(S==="["&&B()!==":"||S==="-"&&B()==="]")&&(S=`\\${S}`),S==="]"&&(h.value==="["||h.value==="[^")&&(S=`\\${S}`),n.posix===!0&&S==="!"&&h.value==="["&&(S="^"),h.value+=S,Kn({value:S});continue}if(g.quotes===1&&S!=='"'){S=le.escapeRegex(S),h.value+=S,Kn({value:S});continue}if(S==='"'){g.quotes=g.quotes===1?0:1,n.keepQuotes===!0&&v({type:"text",value:S});continue}if(S==="("){Gn("parens"),v({type:"paren",value:S});continue}if(S===")"){if(g.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Wt("opening","("));let R=x[x.length-1];if(R&&g.parens===R.parens+1){Cm(x.pop());continue}v({type:"paren",value:S,output:g.parens?")":"\\)"}),Xe("parens");continue}if(S==="["){if(n.nobracket===!0||!Pe().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Wt("closing","]"));S=`\\${S}`}else Gn("brackets");v({type:"bracket",value:S});continue}if(S==="]"){if(n.nobracket===!0||h&&h.type==="bracket"&&h.value.length===1){v({type:"text",value:S,output:`\\${S}`});continue}if(g.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Wt("opening","["));v({type:"text",value:S,output:`\\${S}`});continue}Xe("brackets");let R=h.value.slice(1);if(h.posix!==!0&&R[0]==="^"&&!R.includes("/")&&(S=`/${S}`),h.value+=S,Kn({value:S}),n.literalBrackets===!1||le.hasRegexChars(R))continue;let M=le.escapeRegex(h.value);if(g.output=g.output.slice(0,-h.value.length),n.literalBrackets===!0){g.output+=M,h.value=M;continue}h.value=`(${c}${M}|${h.value})`,g.output+=h.value;continue}if(S==="{"&&n.nobrace!==!0){Gn("braces");let R={type:"brace",value:S,output:"(",outputIndex:g.output.length,tokensIndex:g.tokens.length};j.push(R),v(R);continue}if(S==="}"){let R=j[j.length-1];if(n.nobrace===!0||!R){v({type:"text",value:S,output:S});continue}let M=")";if(R.dots===!0){let W=a.slice(),ie=[];for(let z=W.length-1;z>=0&&(a.pop(),W[z].type!=="brace");z--)W[z].type!=="dots"&&ie.unshift(W[z].value);M=PA(ie,n),g.backtrack=!0}if(R.comma!==!0&&R.dots!==!0){let W=g.output.slice(0,R.outputIndex),ie=g.tokens.slice(R.tokensIndex);R.value=R.output="\\{",S=M="\\}",g.output=W;for(let z of ie)g.output+=z.output||z.value}v({type:"brace",value:S,output:M}),Xe("braces"),j.pop();continue}if(S==="|"){x.length>0&&x[x.length-1].conditions++,v({type:"text",value:S});continue}if(S===","){let R=S,M=j[j.length-1];M&&_e[_e.length-1]==="braces"&&(M.comma=!0,R="|"),v({type:"comma",value:S,output:R});continue}if(S==="/"){if(h.type==="dot"&&g.index===g.start+1){g.start=g.index+1,g.consumed="",g.output="",a.pop(),h=i;continue}v({type:"slash",value:S,output:m});continue}if(S==="."){if(g.braces>0&&h.type==="dot"){h.value==="."&&(h.output=p);let R=j[j.length-1];h.type="dots",h.output+=S,h.value+=S,R.dots=!0;continue}if(g.braces+g.parens===0&&h.type!=="bos"&&h.type!=="slash"){v({type:"text",value:S,output:p});continue}v({type:"dot",value:S,output:p});continue}if(S==="?"){if(!(h&&h.value==="(")&&n.noextglob!==!0&&B()==="("&&B(2)!=="?"){Vn("qmark",S);continue}if(h&&h.type==="paren"){let M=B(),W=S;if(M==="<"&&!le.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(h.value==="("&&!/[!=<:]/.test(M)||M==="<"&&!/<([!=]|\w+>)/.test(Pe()))&&(W=`\\${S}`),v({type:"text",value:S,output:W});continue}if(n.dot!==!0&&(h.type==="slash"||h.type==="bos")){v({type:"qmark",value:S,output:N});continue}v({type:"qmark",value:S,output:w});continue}if(S==="!"){if(n.noextglob!==!0&&B()==="("&&(B(2)!=="?"||!/[!=<:]/.test(B(3)))){Vn("negate",S);continue}if(n.nonegate!==!0&&g.index===0){Am();continue}}if(S==="+"){if(n.noextglob!==!0&&B()==="("&&B(2)!=="?"){Vn("plus",S);continue}if(h&&h.value==="("||n.regex===!1){v({type:"plus",value:S,output:d});continue}if(h&&(h.type==="bracket"||h.type==="paren"||h.type==="brace")||g.parens>0){v({type:"plus",value:S});continue}v({type:"plus",value:d});continue}if(S==="@"){if(n.noextglob!==!0&&B()==="("&&B(2)!=="?"){v({type:"at",extglob:!0,value:S,output:""});continue}v({type:"text",value:S});continue}if(S!=="*"){(S==="$"||S==="^")&&(S=`\\${S}`);let R=kA.exec(Pe());R&&(S+=R[0],g.index+=R[0].length),v({type:"text",value:S});continue}if(h&&(h.type==="globstar"||h.star===!0)){h.type="star",h.star=!0,h.value+=S,h.output=H,g.backtrack=!0,g.globstar=!0,he(S);continue}let A=Pe();if(n.noextglob!==!0&&/^\([^?]/.test(A)){Vn("star",S);continue}if(h.type==="star"){if(n.noglobstar===!0){he(S);continue}let R=h.prev,M=R.prev,W=R.type==="slash"||R.type==="bos",ie=M&&(M.type==="star"||M.type==="globstar");if(n.bash===!0&&(!W||A[0]&&A[0]!=="/")){v({type:"star",value:S,output:""});continue}let z=g.braces>0&&(R.type==="comma"||R.type==="brace"),Ne=x.length&&(R.type==="pipe"||R.type==="paren");if(!W&&R.type!=="paren"&&!z&&!Ne){v({type:"star",value:S,output:""});continue}for(;A.slice(0,3)==="/**";){let we=e[g.index+4];if(we&&we!=="/")break;A=A.slice(3),he("/**",3)}if(R.type==="bos"&&fe()){h.type="globstar",h.value+=S,h.output=L(n),g.output=h.output,g.globstar=!0,he(S);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&!ie&&fe()){g.output=g.output.slice(0,-(R.output+h.output).length),R.output=`(?:${R.output}`,h.type="globstar",h.output=L(n)+(n.strictSlashes?")":"|$)"),h.value+=S,g.globstar=!0,g.output+=R.output+h.output,he(S);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&A[0]==="/"){let we=A[1]!==void 0?"|$":"";g.output=g.output.slice(0,-(R.output+h.output).length),R.output=`(?:${R.output}`,h.type="globstar",h.output=`${L(n)}${m}|${m}${we})`,h.value+=S,g.output+=R.output+h.output,g.globstar=!0,he(S+Te()),v({type:"slash",value:"/",output:""});continue}if(R.type==="bos"&&A[0]==="/"){h.type="globstar",h.value+=S,h.output=`(?:^|${m}|${L(n)}${m})`,g.output=h.output,g.globstar=!0,he(S+Te()),v({type:"slash",value:"/",output:""});continue}g.output=g.output.slice(0,-h.output.length),h.type="globstar",h.output=L(n),h.value+=S,g.output+=h.output,g.globstar=!0,he(S);continue}let X={type:"star",value:S,output:H};if(n.bash===!0){X.output=".*?",(h.type==="bos"||h.type==="slash")&&(X.output=O+X.output),v(X);continue}if(h&&(h.type==="bracket"||h.type==="paren")&&n.regex===!0){X.output=S,v(X);continue}(g.index===g.start||h.type==="slash"||h.type==="dot")&&(h.type==="dot"?(g.output+=b,h.output+=b):n.dot===!0?(g.output+=k,h.output+=k):(g.output+=O,h.output+=O),B()!=="*"&&(g.output+=_,h.output+=_)),v(X)}for(;g.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Wt("closing","]"));g.output=le.escapeLast(g.output,"["),Xe("brackets")}for(;g.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Wt("closing",")"));g.output=le.escapeLast(g.output,"("),Xe("parens")}for(;g.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Wt("closing","}"));g.output=le.escapeLast(g.output,"{"),Xe("braces")}if(n.strictSlashes!==!0&&(h.type==="star"||h.type==="bracket")&&v({type:"maybe_slash",value:"",output:`${m}?`}),g.backtrack===!0){g.output="";for(let A of g.tokens)g.output+=A.output!=null?A.output:A.value,A.suffix&&(g.output+=A.suffix)}return g},"parse");qs.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(Xr,n.maxLength):Xr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=zf[e]||e;let i=le.isWindows(t),{DOT_LITERAL:a,SLASH_LITERAL:c,ONE_CHAR:u,DOTS_SLASH:f,NO_DOT:l,NO_DOTS:p,NO_DOTS_SLASH:d,STAR:m,START_ANCHOR:_}=wn.globChars(i),E=n.dot?p:l,C=n.dot?d:l,b=n.capture?"":"?:",k={negated:!1,prefix:""},w=n.bash===!0?".*?":m;n.capture&&(w=`(${w})`);let N=s(O=>O.noglobstar===!0?w:`(${b}(?:(?!${_}${O.dot?f:a}).)*?)`,"globstar"),I=s(O=>{switch(O){case"*":return`${E}${u}${w}`;case".*":return`${a}${u}${w}`;case"*.*":return`${E}${w}${a}${u}${w}`;case"*/*":return`${E}${w}${c}${u}${C}${w}`;case"**":return E+N(n);case"**/*":return`(?:${E}${N(n)}${c})?${C}${u}${w}`;case"**/*.*":return`(?:${E}${N(n)}${c})?${C}${w}${a}${u}${w}`;case"**/.*":return`(?:${E}${N(n)}${c})?${a}${u}${w}`;default:{let P=/^(.*?)\.(\w+)$/.exec(O);if(!P)return;let H=I(P[1]);return H?H+a+P[2]:void 0}}},"create"),$=le.removePrefix(e,k),L=I($);return L&&n.strictSlashes!==!0&&(L+=`${c}?`),L};Yf.exports=qs});var Zf=J((HN,qf)=>{"use strict";var UA=qe("path"),HA=Vf(),Zs=Xf(),Qs=Pn(),DA=Tn(),FA=s(e=>e&&typeof e=="object"&&!Array.isArray(e),"isObject"),re=s((e,t,n=!1)=>{if(Array.isArray(e)){let l=e.map(d=>re(d,t,n));return s(d=>{for(let m of l){let _=m(d);if(_)return _}return!1},"arrayMatcher")}let r=FA(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=t||{},i=Qs.isWindows(t),a=r?re.compileRe(e,t):re.makeRe(e,t,!1,!0),c=a.state;delete a.state;let u=s(()=>!1,"isIgnored");if(o.ignore){let l={...t,ignore:null,onMatch:null,onResult:null};u=re(o.ignore,l,n)}let f=s((l,p=!1)=>{let{isMatch:d,match:m,output:_}=re.test(l,a,t,{glob:e,posix:i}),E={glob:e,state:c,regex:a,posix:i,input:l,output:_,match:m,isMatch:d};return typeof o.onResult=="function"&&o.onResult(E),d===!1?(E.isMatch=!1,p?E:!1):u(l)?(typeof o.onIgnore=="function"&&o.onIgnore(E),E.isMatch=!1,p?E:!1):(typeof o.onMatch=="function"&&o.onMatch(E),p?E:!0)},"matcher");return n&&(f.state=c),f},"picomatch");re.test=(e,t,n,{glob:r,posix:o}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let i=n||{},a=i.format||(o?Qs.toPosixSlashes:null),c=e===r,u=c&&a?a(e):e;return c===!1&&(u=a?a(e):e,c=u===r),(c===!1||i.capture===!0)&&(i.matchBase===!0||i.basename===!0?c=re.matchBase(e,t,n,o):c=t.exec(u)),{isMatch:!!c,match:c,output:u}};re.matchBase=(e,t,n,r=Qs.isWindows(n))=>(t instanceof RegExp?t:re.makeRe(t,n)).test(UA.basename(e));re.isMatch=(e,t,n)=>re(t,n)(e);re.parse=(e,t)=>Array.isArray(e)?e.map(n=>re.parse(n,t)):Zs(e,{...t,fastpaths:!1});re.scan=(e,t)=>HA(e,t);re.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},i=o.contains?"":"^",a=o.contains?"":"$",c=`${i}(?:${e.output})${a}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let u=re.toRegex(c,t);return r===!0&&(u.state=e),u};re.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)),re.compileRe(o,t,n,r)};re.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/$^/}};re.constants=DA;qf.exports=re});var ed=J((FN,Qf)=>{"use strict";Qf.exports=Zf()});var id=J(($N,sd)=>{"use strict";var nd=qe("util"),rd=wf(),De=ed(),ei=Pn(),td=s(e=>e===""||e==="./","isEmptyString"),od=s(e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},"hasBraces"),Y=s((e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,i=new Set,a=0,c=s(l=>{i.add(l.output),n&&n.onResult&&n.onResult(l)},"onResult");for(let l=0;l<t.length;l++){let p=De(String(t[l]),{...n,onResult:c},!0),d=p.state.negated||p.state.negatedExtglob;d&&a++;for(let m of e){let _=p(m,!0);(d?!_.isMatch:_.isMatch)&&(d?r.add(_.output):(r.delete(_.output),o.add(_.output)))}}let f=(a===t.length?[...i]:[...o]).filter(l=>!r.has(l));if(n&&f.length===0){if(n.failglob===!0)throw new Error(`No matches found for "${t.join(", ")}"`);if(n.nonull===!0||n.nullglob===!0)return n.unescape?t.map(l=>l.replace(/\\/g,"")):t}return f},"micromatch");Y.match=Y;Y.matcher=(e,t)=>De(e,t);Y.isMatch=(e,t,n)=>De(t,n)(e);Y.any=Y.isMatch;Y.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],i=s(c=>{n.onResult&&n.onResult(c),o.push(c.output)},"onResult"),a=new Set(Y(e,t,{...n,onResult:i}));for(let c of o)a.has(c)||r.add(c);return[...r]};Y.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${nd.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>Y.contains(e,r,n));if(typeof t=="string"){if(td(e)||td(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return Y.isMatch(e,t,{...n,contains:!0})};Y.matchKeys=(e,t,n)=>{if(!ei.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=Y(Object.keys(e),t,n),o={};for(let i of r)o[i]=e[i];return o};Y.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=De(String(o),n);if(r.some(a=>i(a)))return!0}return!1};Y.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=De(String(o),n);if(!r.every(a=>i(a)))return!1}return!0};Y.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${nd.inspect(e)}"`);return[].concat(t).every(r=>De(r,n)(e))};Y.capture=(e,t,n)=>{let r=ei.isWindows(n),i=De.makeRe(String(e),{...n,capture:!0}).exec(r?ei.toPosixSlashes(t):t);if(i)return i.slice(1).map(a=>a===void 0?"":a)};Y.makeRe=(...e)=>De.makeRe(...e);Y.scan=(...e)=>De.scan(...e);Y.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of rd(String(r),t))n.push(De.parse(o,t));return n};Y.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!od(e)?[e]:rd(e,t)};Y.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return Y.braces(e,{...t,expand:!0})};Y.hasBraces=od;sd.exports=Y});import{existsSync as Bm,readFileSync as Km}from"node:fs";import{hostname as na,release as Gm,userInfo as Vm,version as zm}from"node:os";import*as de from"node:os";import{performance as So}from"node:perf_hooks";var Pm=1024*1024,Nm=128;function zn(e){return Math.round(e/Pm)}s(zn,"mb");function on(e,t){let n=10**t;return Math.round(e*n)/n}s(on,"round");function Bi(e=process.platform){try{let t=So.now(),n={},r=0,o=0,i=e!=="win32";for(let{times:u}of de.cpus())r+=u.user+u.nice+u.sys+(i?u.irq:0),o+=u.idle;if(r+o>0&&(n.cpu_busy_ms=Math.round(r),n.cpu_idle_ms=Math.round(o)),n.uptime_s=Math.round(de.uptime()),n.mem_free_mb=zn(de.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=zn(process.availableMemory())),e!=="win32"){let[u,f,l]=de.loadavg();n.load_1m=on(u??0,2),n.load_5m=on(f??0,2),n.load_15m=on(l??0,2)}let a=process.resourceUsage();n.proc_cpu_user_ms=Math.round(a.userCPUTime/1e3),n.proc_cpu_sys_ms=Math.round(a.systemCPUTime/1e3),n.proc_max_rss_mb=Math.round(a.maxRSS/1024),n.proc_page_faults=a.majorPageFault,e!=="win32"&&(n.proc_invol_ctx=a.involuntaryContextSwitches);let c=So.nodeTiming?.bootstrapComplete;return typeof c=="number"&&c>0&&(n.node_boot_ms=on(c,1)),n.sample_us=Math.round((So.now()-t)*1e3),n}catch{return}}s(Bi,"sampleSys");function Ki(){try{let e=de.cpus(),t={},n=typeof de.availableParallelism=="function"?de.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,Nm);r&&(t.cpu_model=r);let o=de.totalmem();t.mem_total_mb=zn(o);let i=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof i=="number"&&i>0&&i<o&&(t.mem_limit_mb=zn(i)),t.uptime_h=on(de.uptime()/3600,1),t}catch{return{}}}s(Ki,"hostSpecs");import{createHash as wm,randomBytes as Lm}from"node:crypto";import{existsSync as Wn,mkdirSync as Mm,readdirSync as vm,readFileSync as Um,renameSync as Gi,statSync as Ji,unlinkSync as Vi,writeFileSync as Hm}from"node:fs";import{homedir as Yi}from"node:os";import{basename as Dm,dirname as zi,isAbsolute as Fm,join as Xi,relative as qi,resolve as je,sep as $m}from"node:path";function T(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
14
+ `)}s(T,"logStderr");function sn(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}s(sn,"stripRemoteCredentials");function an(e){return wm("sha256").update(e).digest("hex").slice(0,32)}s(an,"sha32");function ce(e,t){Mm(zi(e),{recursive:!0});let n=Xi(zi(e),`.${Dm(e)}.${process.pid}.${Lm(4).toString("hex")}.tmp`);try{Hm(n,t,"utf8");try{Gi(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){Vi(e),Gi(n,e);return}throw r}}catch(r){try{Vi(n)}catch{}throw r}}s(ce,"writeFileAtomic");function Jn(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}s(Jn,"timestampUtc");var yo;function Ro(e){yo=e}s(Ro,"setHookStdio");function Ao(){(yo?.stdout??process.stdout).write('{"continue":true}')}s(Ao,"emitStdoutOk");var ft=new Set(["on","1","true"]),Yn=new Set(["off","0","false"]);function D(e){let t=process.env[e];return t===void 0||t===""?void 0:t}s(D,"readEnv");async function Co(){return new Promise(e=>{let t="";if(process.stdin.isTTY){e("");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",n=>{t+=n}),process.stdin.on("end",()=>{e(t)}),process.stdin.on("error",()=>{e(t)}),process.stdin.resume()})}s(Co,"readStdinUntilEnd");async function Xn(e){let t=yo?.stdin??process.stdin;return new Promise(n=>{let r="",o=!1,i=s(c=>{o||(o=!0,clearTimeout(a),n(c||"{}"))},"finish"),a=setTimeout(()=>{i(r)},e);if(t.isTTY){i("{}");return}t.setEncoding("utf8"),t.on("data",c=>{r+=c}),t.on("end",()=>{i(r)}),t.on("error",()=>{i(r)}),t.resume()})}s(Xn,"readStdinWithTimeout");async function Oe(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:i}=await import("node:util"),a=i(o);try{let{stdout:c}=await a(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:c.trim()}}catch(c){let u=c,f=typeof u.code=="number"?u.code:typeof u.status=="number"?u.status:void 0;return{ok:!1,code:f,spawnFailed:f===void 0}}}s(Oe,"execFileResult");async function oe(e,t,n=3e3,r={}){let o=await Oe(e,t,n,r);return o.ok?o.stdout:""}s(oe,"execFileText");function Eo(e,t){let n=je(e),r=je(t),o=qi(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${$m}`)||Fm(o)?!1:je(r,o)===n}s(Eo,"isPathInside");function Zi(e,t,n=Yi()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return je(e);let o=je(r),i=je(e);if(Eo(i,o))return i;let a=t.CURSOR_PLUGIN_ROOT?.trim();return Eo(i,je(n,".cursor"))||a!==void 0&&a.length>0&&Eo(i,je(a))?o:i}s(Zi,"cursorHookLaunchCwd");async function bo(e=process.cwd(),t=process.env,n=Yi()){let r=Zi(e,t,n),o=r!==je(e)&&Wn(r)?r:e,i=await Oe("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(i.ok&&i.stdout)return{root:i.stdout,inGitRepo:!0};if(D("EV_AI_HOOK_DEBUG")){let c=i.ok?"empty stdout":i.spawnFailed?"spawn failed":`exit ${String(i.code??"unknown")}`;T(`DEBUG: git rev-parse --show-toplevel failed (${c}) cwd=${e}`)}let a=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||D("CURSOR_PROJECT_DIR")||D("CLAUDE_PROJECT_DIR");if(a&&Wn(a)){let c=await Oe("git",["rev-parse","--show-toplevel"],2e3,{cwd:a});return c.ok&&c.stdout?{root:c.stdout,inGitRepo:!0}:{root:a,inGitRepo:!1}}return{root:e,inGitRepo:!1}}s(bo,"resolveGitWorkspace");async function Oo(e=process.cwd()){return(await bo(e)).root}s(Oo,"findGitRoot");function xe(e,t){try{return JSON.parse(e)}catch{return t}}s(xe,"parseJsonSafe");var Wi=new Map;function Tt(e){return e.charCodeAt(0)===65279?e.slice(1):e}s(Tt,"stripUtf8Bom");function jm(e){let t;try{t=Um(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Tt(t))}}catch{return{ok:!1,reason:"parse"}}}s(jm,"parseJsonFile");function Qi(e){let t=Wi.get(e);if(t!==void 0)return t;let n=jm(e);return Wi.set(e,n),n}s(Qi,"loadJsonFileStatus");function ea(e){return Qi(e)}s(ea,"readJsonFileStatus");function Z(e,t){let n=Qi(e);return n.ok?n.value:t}s(Z,"readJsonFileMemoized");function dt(e){return typeof e=="string"?e:""}s(dt,"pickString");function Be(e,t){let n=e[t];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(!t.includes("."))return;let r=t.split("."),o=e;for(let i of r){if(o===null||typeof o!="object"||Array.isArray(o))return;o=o[i]}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o}s(Be,"pickNestedScalar");function F(e,t){let n=Be(e,t);return typeof n=="string"?n:""}s(F,"pickNestedString");var Qe=500;function ta(e,t=2){if(!Wn(e))return{entries:[],truncated:!1};let n=[],r=!1,o=s((i,a)=>{if(a>t||r)return;let c;try{c=vm(i,{withFileTypes:!0})}catch{return}for(let u of c){if(r)return;let f=Xi(i,u.name);if(u.isDirectory()){o(f,a+1);continue}if(u.isFile()){try{n.push({name:qi(e,f),size:Ji(f).size})}catch{continue}if(n.length>=Qe){r=!0;return}}}},"walk");return o(e,1),{entries:n,truncated:r}}s(ta,"listDirFiles");function xo(e){return Wn(e)?{present:!0,size:Ji(e).size}:{present:!1,size:0}}s(xo,"fileSizeOrAbsent");function Pt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(Pt,"isTruthyFlag");function ra(e=process.env){return Pt(q("CURSOR_SANDBOX",e))}s(ra,"isCursorSandboxProcess");var Wm=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function Jm(e){return Wm.some(t=>!!q(t,e))}s(Jm,"hasManagedCiMarker");function Ym(e){if(q("KUBERNETES_SERVICE_HOST",e)||Pt(q("REMOTE_CONTAINERS",e))||Pt(q("DEVCONTAINER",e)))return!0;try{if(Bm("/.dockerenv")||Km("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}s(Ym,"hasContainerMarker");function oa(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!q(t,e))}s(oa,"hasIdeExtensionHostMarker");function Xm(e,t=process.platform){return oa(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!q(n,e)):!1}s(Xm,"hasLocalIdeHostMarker");function qm(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}s(qm,"isBackgroundComposerSessionId");function Zm(e){return e==="linux"}s(Zm,"isLinuxPlatform");function q(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return D(e)}s(q,"readContextEnv");function Qm(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!eg(q("CURSOR_VERSION",n))}s(Qm,"isCursorCloudHostFingerprint");function eg(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(eg,"trimEnvLocal");function Io(e){if(qm(e.sessionId))return!0;let t=e.hostname??na(),n=e.osUser??ia(e.env);return Qm(t,n,e.env)}s(Io,"hasCursorCloudExclusiveEvidence");function tg(e){return Pt(q("CURSOR_AGENT",e.env))?!0:Io(e)}s(tg,"hasCursorCloudEvidence");function ng(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(q("TERM",e)??q("TERM_PROGRAM",e))||(q("SSH_TTY",e)??q("SSH_CONNECTION",e))||(q("__CFBundleIdentifier",e)??q("XPC_SERVICE_NAME",e))||oa(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!q(t,e))||q("SESSIONNAME",e))}s(ng,"hasLocalSessionMarker");function cn(e={}){let t=e.env;if(q("GITHUB_ACTIONS",t))return"github_actions";if(Pt(q("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!Xm(t,n)&&tg(e)&&(Pt(q("CURSOR_AGENT",t))||Zm(n)))return"cursor_cloud";if(q("CODESPACES",t)||q("CODESPACE_NAME",t))return"codespaces";if(q("GITLAB_CI",t))return"gitlab_ci";if(Jm(t))return"managed";let r=q("CI",t);return r&&r!=="false"&&r!=="0"?"managed":Ym(t)?"container":ng(t)?"interactive":"unknown"}s(cn,"detectContext");async function sa(){return await oe("systemd-detect-virt",[],1e3)}s(sa,"detectVirt");function ia(e=process.env,t=Vm){for(let n of["USER","LOGNAME","USERNAME"]){let r=e[n];if(typeof r=="string"){let o=r.trim();if(o.length>0)return o}}try{return t().username??""}catch{return""}}s(ia,"resolveHostUsername");var rg=32;function og(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,rg);return t.length>0?t:null}s(og,"sanitizeOsPlatform");function sg(){try{return[zm(),Gm()].filter(Boolean).join(" ").trim()}catch{return""}}s(sg,"windowsVersion");async function aa(e=!1){let t=og(process.platform),n="";if(process.platform==="darwin")n=await oe("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:a}=await import("node:fs"),c=a("/etc/os-release","utf8"),u=c.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],f=c.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];n=u??f??""}catch{n=await oe("lsb_release",["-sd"],1e3).then(a=>a.replace(/^"|"$/g,""))}n||(n=await oe("uname",["-r"],1e3))}else process.platform==="win32"?n=sg():n=await oe("ver",[],1e3);let r=ia(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",i="";try{i=await oe("tty",[],500),i.includes("not a tty")&&(i="")}catch{i=""}return{os:t,os_version:n||null,user:r||null,shell:o||null,tty:i||null,...e?Ki():{}}}s(aa,"hostEnv");function qn(){return na()}s(qn,"hostName");import{createHash as _g}from"node:crypto";import{homedir as hg}from"node:os";import{dirname as mI,join as Sg,parse as gI,resolve as _I}from"node:path";var ca="EV_AI_LAUNCHER_VERSION";var ua="EV_AI_HOOK_SOURCE",la="EV_AI_HOOK_FALLBACK_REASON",fa="EV_AI_LAUNCHER_SCOPE",ko="EV_AI_LAUNCHER_READY_FD";var da="--defer-user-spec",Zn="--cap",un="--slot";var pa=Buffer.from([1]);var Wx=1024*1024,Jx=4*1024*1024,Yx=64*1024,Xx=64*1024,qx=64*1024;var To=4096,Zx=4*1024*1024;var ma="ev-ai.agent-hook.in-process.v1";import{join as ya}from"node:path";import{open as ga,mkdir as ig,readFile as ag,readdir as cg,rename as ug,stat as lg,rmdir as fg,unlink as dg,utimes as pg}from"node:fs/promises";var Qn=new WeakMap;function ha(e){if(e&&typeof e=="object"&&"code"in e)return e}s(ha,"asNodeError");function Nt(e){return ha(e)?.code==="ENOENT"}s(Nt,"isNotFound");function ln(e){return ha(e)?.code==="EEXIST"}s(ln,"isAlreadyExists");async function Sa(e,t){try{return await e.readdir(t)}catch(n){if(Nt(n))return[];throw n}}s(Sa,"readdirOrEmpty");function Ea(){return{async open(e,t){let n=await ga(e,t),r={path:e};return Qn.set(r,n),r},async write(e,t){let n=_a(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await _a(e).sync()},async close(e){let t=Qn.get(e);Qn.delete(e),t&&await t.close()},rename:ug,async readdir(e){return cg(e)},readFile:ag,async stat(e){let t=await lg(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:s(()=>t.isDirectory(),"isDirectory")}},async mkdir(e,t){await ig(e,t)},unlink:dg,rmdir:fg,utimes:pg,async fsyncDir(e){if(process.platform==="win32")return;let t=await ga(e,"r");try{await t.sync()}finally{await t.close()}}}}s(Ea,"productionFs");function _a(e){let t=Qn.get(e);if(!t)throw new Error("closed");return t}s(_a,"requireHandle");var Ra=4,Aa=10;function er(e=process.platform){return e==="win32"?Ra:Aa}s(er,"defaultMaxConcurrentHooks");var tr=6e4,fn=2e3,Ca="slots",Po=64;function ba(e){return ya(e,".ev-ai","agent-hook",Ca)}s(ba,"slotDirUnder");function nr(e,t){return ya(e,`slot-${t}`)}s(nr,"slotPath");function rr(e,t){return`${e}
15
15
  ${t}
16
- `}function ro(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 Zi(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 dm(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 Qi(e,t,n){let r=dm(e);if(!r)return Math.abs(n-t)<Kt;let o=n-r.acquiredAtMs;return o<-Kt||o>=vn?!1:Zi(r.pid)}var na="https://hooks.ev-ai.ai",ra=".claude/ev-ai-runtime-report.json",oa="config.json",_m="max_concurrent_hooks",fO=1024*1024,hm=new Set(["localhost","127.0.0.1","[::1]","::1"]),Sm=["claude","cursor","codex"],sa=[ra,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],oo=/^[A-Za-z0-9._~-]+$/;function Un(e){return e!==void 0&&Sm.includes(e)}function ia(e){if(!e||typeof e!="object")return;let t=e[_m];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}function ea(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function _t(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=_t(e,c);t=u.value,c=u.next;continue}if(l.startsWith("--runner=")){t=l.slice(9);continue}if(l==="--url"){let u=_t(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=_t(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=_t(e,c);u.value&&(s=u.value),c=u.next;continue}if(l.startsWith("--base-url=")){s=l.slice(11);continue}if(l===Nn){let u=_t(e,c);i=ea(u.value)??i,c=u.next;continue}if(l.startsWith(`${Nn}=`)){i=ea(l.slice(Nn.length+1))??i;continue}if(l===$t){let u=_t(e,c);a=ro(u.value)??a,c=u.next;continue}if(l.startsWith(`${$t}=`)){a=ro(l.slice($t.length+1))??a;continue}l!==Fi&&!l.startsWith("-")&&n===void 0&&(n=l)}}return{runner:Un(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s,...i!==void 0?{cap:i}:{},...a!==void 0?{slot:a}:{}}}function Dn(e,t=na){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function ht(e=mm()){return gm(e,".ev-ai",oa)}function aa(e,t){return{...e,...t}}function ta(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 Fn(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?hm.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 $n(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!Fn(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(ta(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(ta(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function ao(e){return new URL(e).toString()}function co(e){if(e.collector_url)return e.collector_url;let t=e.repo_ingest_token,n=typeof t=="string"?t.trim():void 0;return n?Dn(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 ca(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=Dn(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=$n(n);return r?{problem:r}:{url:ao(n)}}var Em="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",ym="COLLECTOR_URL",Rm=[ym,Em];function ua(e){let t;for(let n of Rm){let r=e[n]?.trim();if(!r)continue;let o=$n(r);if(o){t??={problem:o,envName:n};continue}return{url:ao(r),envName:n}}return t??{}}function Bt(e){if($n(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 pm("sha256").update(i).digest("hex").slice(0,32)}var Kn=2;var St="ev-ai-agent-hook";function Cm(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}function la(e){let t=Cm(e);return t===St||t===`${St}.exe`}var pO=`current/${St}`,mO=`.ev-ai/agent-hook/${St}`,fa=5e3,da=5e3,uo=3e3;var Bn=3e3,pa=1500,ma=4*1024,lo=256*1024,Am=4*1024,ga=32*1024,fo="1.3.8",gO=`@ev-ai/agent-hook@${fo}`;var _a={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{existsSync as Ih,mkdirSync as Th,readdirSync as kh,readFileSync as Ph,unlinkSync as Kc,writeFileSync as Nh}from"node:fs";import{homedir as Bc}from"node:os";import{join as No}from"node:path";import{createHash as Ra,randomBytes as xm}from"node:crypto";import{existsSync as Ca,mkdirSync as po,readFileSync as Aa,unlinkSync as ba,writeFileSync as Oa}from"node:fs";import{homedir as mo}from"node:os";import{dirname as Gn,join as go,resolve as Im}from"node:path";var bm=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),Om=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function pe(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||Om.has(n)||r.includes("[bot]")||bm.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}var Tm="installation.json",km="cloud-bootstrap.lock",Pm=6e4;function xa(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function me(e=mo()){return go(e,".ev-ai","agent-hook")}function Nm(e=mo()){return go(me(e),Tm)}function Ia(e){return go(Gn(e),km)}function Ta(){return xm(8).toString("hex")}function Et(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 ka(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function wm(e=process.env){let t=$(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!ka(t)){x(`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&&ka(e)?e:(e&&x(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),wm(t))}function Mm(e){return/^[0-9a-f]{16}$/.test(e)}function vm(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 Et(`github_actions|${t}|${n}`)}if($(e.CODESPACES)||$(e.CODESPACE_NAME)){let t=$(e.CODESPACE_NAME);if(t)return Et(`codespaces|${t}`);let n=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),r=$(e.GITHUB_USER)??$(e.GITHUB_ACTOR);if(n&&r)return Et(`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 Et(`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 Ht(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&&!pe(null,t))return t;let n=$(await te("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!pe(null,n)?n:null}function jm(e,t){let n=Um(e,t);return n?Et(`cursor_cloud|${n}|${Hm(e)??""}`):null}async function Km(e,t){let n=$(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await Fm(n),o=await $m(n);return Et(`claude_remote|${r}|${o??""}`)}function ha(e,t){let n=Pa(e,t);if(n)return n;let r=vm(t);return r||Ta()}async function Bm(e){let n=await te("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||Im(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 Vm(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 nt(e){if(Ca(e))try{return Vm(Aa(e,"utf8"))}catch{}}function _o(e){return nt(e)}function Na(e,t,n){let r=nt(e);if(!r||r.operator_identity_hash===t&&r.operator_identity_sent_at===n)return;let o={...r,operator_identity_hash:t,operator_identity_sent_at:n};try{ae(e,`${JSON.stringify(o,null,2)}
17
- `)}catch(s){let i=s instanceof Error?s.message:String(s);x(`WARN: operator identity cache write failed open: ${i}`)}}function wa(e,t=Date.now()){if(!e)return!0;if(nt(e)?.operator_identity_hash)return!1;let n=Ia(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{ba(n)}catch{}}}catch{}try{return po(Gn(n),{recursive:!0}),Oa(n,`${t}
18
- `,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(Ha(r))return!1;let o=r instanceof Error?r.message:String(r);return x(`WARN: cloud bootstrap claim failed open: ${o}`),!0}}function Ma(e){if(e)try{ba(Ia(e))}catch{}}function va(e,t){let r=nt(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=nt(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{ae(e,`${JSON.stringify(o,null,2)}
19
- `)}catch(s){let i=s instanceof Error?s.message:String(s);x(`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){po(Gn(e),{recursive:!0}),Oa(e,`${JSON.stringify(t,null,2)}
20
- `,{encoding:"utf8",flag:"wx"})}function Sa(e,t){try{return zm(e,t),t}catch(n){if(!Ha(n))throw n;return nt(e)}}function Ea(e,t){po(Gn(e),{recursive:!0}),ae(e,`${JSON.stringify(t,null,2)}
21
- `)}function ya(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}async function Ua(e,t={}){let n=t.home??mo(),r=t.env??process.env,o=await Bm(e),s=Nm(n),i={sessionId:t.sessionId,hostname:$(r.HOSTNAME)??void 0,osUser:$(r.USER)??$(r.LOGNAME)??$(r.USERNAME)??void 0,env:r},a=Ft(i),c=Pa(t.overrideId,r),l=a==="cursor_cloud"&&Qr(i)?jm(r,e):a==="claude_remote"?await Km(r,e):null,u=nt(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&&Mm(S.installation_id)&&l){let A={installation_id:l,...S.platform_agent_ids?{platform_agent_ids:S.platform_agent_ids}:{}};return Ea(s,A),{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?Ta():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 ug}from"node:fs";import{existsSync as Qm}from"node:fs";import{homedir as $a}from"node:os";import{join as eg}from"node:path";import{existsSync as Wm,readdirSync as Da}from"node:fs";import{homedir as Vn}from"node:os";import{join as ce}from"node:path";function Jm(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return ce(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}function Ym(e=process.platform){let t=Jm(e),n=[ce(t,"managed-settings.json")],r=ce(t,"managed-settings.d");try{if(!Wm(r))return n;let o=Da(r).filter(s=>s.endsWith(".json")&&!s.startsWith(".")).sort().map(s=>ce(r,s));n.push(...o)}catch{}return n}function Gt(e=process.platform,t=Vn()){return{serverManaged:ce(t,".claude","remote-settings.json"),fileBased:Ym(e)}}function Xm(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return ce(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}function qm(e=process.platform,t=Vn()){let n=[ce(Xm(e),"hooks.json")],r=ce(t,".cursor","managed");try{for(let o of Da(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(ce(r,o.name,"hooks.json"))}catch{}return n}function Zm(e=process.platform,t=Vn()){let n=e==="win32"?ce(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[ce(n,"requirements.toml")];return e!=="win32"&&r.push(ce(n,"managed_config.toml")),r.push(ce(t,".codex","managed_config.toml"),ce(n,"config.toml")),r}function zn(e,t=process.platform,n=Vn()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=Gt(t,n);return[r,...o]}case"cursor":return qm(t,n);default:return Zm(t,n)}}function ja(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}var tg={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 Fa(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}function ng(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:Fa(n.mcpJson,t.mcpJson),mcpToml:Fa(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}function Ka(e){return Object.fromEntries(Object.entries(tg).map(([t,n])=>[t,ng(n,n[e])]))}var yt=Ka("homeOnly"),Je=Ka("projectOnly");function rg(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}function og(e,t){return rg(e).some(n=>Qm(eg(t,n)))}function Ba(e,t){for(let n of e)if(og(n,t))return!0;return!1}function We(e){return[...new Set(e)]}function Ye(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:We(t),subagents:We(n),commands:We(r),rules:We(o),memory:We(s),settings:We(i),mcp:We(a)}}function sg(e,t=$a(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...zn(o.managed,n,t));return We(r)}var Xe=Ye(Object.values(yt));function Ga(e=$a(),t=process.platform){return sg(Object.values(yt),e,t)}import{existsSync as ig}from"node:fs";import{resolve as ho}from"node:path";function he(e){return ho(e).replaceAll("\\","/").replace(/\/$/,"")}function rt(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 Wn(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 ag=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function Vt(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!ag.test(t)?null:t}function Rt(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 cg(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}function Ie(e,t,n,r=ig){for(let o of e)for(let s of t){let i=he(ho(o,s)),a=ho(o,s,n).replaceAll("\\","/");if(cg(i,a)&&r(a))return a}return null}var za=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Wa=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,lg=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,Va=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"]),fg=/^[a-z][a-z0-9-]{1,63}$/,dg=[".cursor/skills",".claude/skills",".agents/skills"],pg=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],mg=rt(dg,Ye(Object.values(Je)).skills),gg=rt(pg,Ye(Object.values(yt)).skills),_g=new Set(["read","read_file","view"]),hg=new Set(["bash","shell","zsh"]);function So(e){let t=e.replace(/\\/g,"/");return za.exec(t)?.[1]??null}function Sg(e){let t=e.replace(/\\/g,"/"),r=Wa.exec(t)?.[1];return r?r.toLowerCase():null}function Eg(e){return So(e)??Sg(e)}function yg(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 Jn(e){return typeof e=="string"?Jn(_e(e,null)):!e||typeof e!="object"?null:yg(e)}function Ja(e){if(typeof e=="string")return Ja(_e(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}function Eo(e){let t=Ja(e.tool_input);if(t)return t;let n=tt(e.command);return n.length>0?n:null}function Rg(e){let t=e.replace(/\\/g,"/"),n=za.exec(t);if(n?.[1])return n[1];let o=Wa.exec(t)?.[1];return o?o.toLowerCase():null}function Cg(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function yo(e){let t=Jn(e.tool_input)??tt(e.file_path);return t.length>0?t:null}function zt(e,t,n){let r=Cg(e).toLowerCase();if(_g.has(r)){let o=yo(e);return o?t(o):null}if(hg.has(r)){let o=Eo(e);return o?n(o):null}return null}function Ya(e){return zt(e,Eg,Rg)}function Ag(e){let t=new Set,n=[];for(let r of e.matchAll(lg)){let o=r[1]?.toLowerCase();!o||t.has(o)||bg(o)||(t.add(o),n.push(o))}return n}function bg(e){let t=e.split("/")[0];return Va.has(e)||t!==void 0&&Va.has(t)}function Xa(e){let t=e.skillId.toLowerCase();if(!fg.test(t))return null;let n=e.exists??ug,r=`${t}/SKILL.md`,o=Ie(Rt(e.launchCwd,e.gitRoot),mg,r,n);return o!==null?o:e.home?Ie([he(e.home)],gg,r,n):null}function Og(e){return tt(e.prompt)}function qa(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=Og(e);return n?Ag(n):[]}var xo=Ve(Ze(),1);import{existsSync as Z_}from"node:fs";var st={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function Jt(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function q_(e){if(!e)return"";let t=Ht(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return Jt(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return Jt(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?Jt(o[1]):Jt(t)}async function tr(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?Ht(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 Cc(e,t,n,r=process.cwd(),o,s,i){if(t)return t;let a=st[n];if(!a)return"";let c=xa(n,e.scope_path,i);if(s){let g=va(s,c);if(g)return g}let l=o??await tr(r),u=l?.remote?q_(l.remote):"";if(u||(u=Jt(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 Q_=[".cursor/rules",".claude/rules",".codex/rules"],eh=Ye(Object.values(Je)).rules;function th(e){return rt(Wn(e?st[e]:void 0,Q_),eh)}var nh=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function Ac(e){let t=Vt(e.relativePath);if(!t)return null;let n=e.exists??Z_,r=Rt(e.launchCwd,e.gitRoot),o=th(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 rh(e){let t=e.replace(/\\/g,"/"),r=nh.exec(t)?.[1];return r?(0,xo.nativeKeyForRulePath)(r):null}function bc(e){return zt(e,xo.nativeKeyForRulePath,rh)}function Oc(e){return e.replace(/\.(mdc|md|rules)$/i,"")}function xc(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=Vt(i);!a||n.has(a)||(n.add(a),r.push(a))}return r}var Io=Ve(Ze(),1);import{existsSync as oh}from"node:fs";var sh=[".cursor/commands",".claude/commands",".codex/prompts"],ih=Ye(Object.values(Je)).commands;function ah(e){return rt(Wn(e?st[e]:void 0,sh),ih)}var ch=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function Ic(e){let t=Vt(e.commandId);if(!t)return null;let n=e.exists??oh,r=`${t}.md`,o=ah(e.runnerPlatform),s=Ie(Rt(e.launchCwd,e.gitRoot),o,r,n);return s!==null?s:e.home?Ie([he(e.home)],o,r,n):null}function uh(e){let t=e.replace(/\\/g,"/"),r=ch.exec(t)?.[1];return r?(0,Io.nativeKeyForCommandPath)(r):null}function Tc(e){return zt(e,Io.nativeKeyForCommandPath,uh)}var nr=Ve(Ze(),1);function kc(e){let t=ca(e);if(t.problem){x(`WARN: ignoring --url/--token collector override: ${t.problem}`);return}return t.url}function Pc(e,t){if(L(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function lh(){return!!(v("CURSOR_VERSION")??v("CURSOR_PROJECT_DIR"))}function Nc(e,t,n){return e!=="claude"&&e!=="codex"?!1:Pc(t,n)?!0:lh()}var fh=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function Yt(e,t,n,r){return Pc(e,t)?"cursor":Un(r)?r:Un(n)?n:L(e,"turn_id")?"codex":L(e,"session_id")||fh.has(t.toLowerCase())?"claude":"unknown"}function rr(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function dh(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 wc(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}function Mc(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}function vc(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function Xt(e){return L(e,"session_id")||L(e,"conversation_id")}function To(e){return L(e,"prompt.id")||L(e,"prompt_id")||L(e,"generation_id")||L(e,"turn_id")}function ko(e){return L(e,"hook_event_name")||L(e,"event")}function Lc(e,t,n){let r=Xt(e),o=To(e),s=ko(e),i=L(e,"source"),a=Yt(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:i,runnerPlatform:a}}var ph=["session_start","session_end","tool_invoked","skill_invoked"];function mh(e){return ph.includes(e)}function Po(e,t){return e&&mh(e)?e:dh(t.toLowerCase())}var gh={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function or(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function Hc(e,t=""){let n=L(e,"tool_name")||L(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!or(n)&&(n=`MCP:${n}`):n=gh[r]??null;let o=e.tool_input,i=(o&&typeof o=="object"?tt(o.skill)||tt(o.skill_name):"")||L(e,"skill_name")||null,a=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;i??=Ya(a);let c=bc(a),l=Tc(a);return{toolName:n,skillName:i,ruleName:c,commandName:l}}var _h=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function Uc(e){for(let t of["subagent_type","agent_type"]){let n=L(e,t);if(n&&_h.test(n))return n}return null}function Dc(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 hh="error",Sh="interrupted",Eh="permission_denied",yh=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function qt(e){return yh.test(e)?e:null}function Rh(e){for(let t of["failure_type","error_type"]){let n=qt(L(e,t));if(n)return n}return null}function Fc(e,t){return He(e,"is_interrupt")===!0?Sh:t.toLowerCase()==="permissiondenied"?Eh:Rh(e)??hh}function $c(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}function Ch(e,t){return $c(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}function Ah(e,t){return $c(t,n=>(0,nr.mcpServerNameMatchesToolSegment)(n,e))}function bh(e,t){let n=null,r=0;for(let s of t)if(s)for(let i of(0,nr.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:Ah(o[1],t)??o[1],mcpTool:o[2]}}function Oh(e,t){if(/^mcp__/i.test(e))return bh(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:Ch(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}function xh(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}function jc(e,t=[],n=""){let r=e?Oh(e,t):{mcpServer:null,mcpTool:null},o=qt(n.trim());if(!o)return r;let s=r.mcpTool;return!s&&e&&!or(e)&&(s=e),s&&(s=xh(s,o)),{mcpServer:o,mcpTool:s}}var Gc=3e4,wh="claims",Mh=!0,vh=100,Lh=new Set(["sessionstart","sessionend","stopfailure"]),Hh=["tool_name","tool","command","file_path","url"];function Uh(e=Bc()){return No(me(e),wh)}function Vc(e,t){try{let n=Ph(e,"utf8").split(`
22
- `,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}function Dh(e){let t=[];for(let n of Hh){let r=L(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":Ut(t.join("\0"))}function Fh(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=Lh.has(n);if(!a&&!c)return;let l=e.runnerPlatform.trim()||"unknown";return Ut(`${l}|${t}|${n}|${r}|${o}|${i}|${s}`)}function $h(e,t=Date.now()){let n;try{n=kh(e)}catch{return}let r=0;for(let o of n){if(r>=vh)break;r+=1;let s=No(e,o),i=Vc(s,t);if(!(!Number.isFinite(i)||i<Gc))try{Kc(s)}catch{}}}function jh(e,t,n=Date.now()){let r=No(t,e);try{if(Ih(r)){let o=Vc(r,n);if(Number.isFinite(o)&&o>=0&&o<Gc)return!1;try{Kc(r)}catch{}}}catch{}try{Th(t,{recursive:!0}),Nh(r,`${n}
23
- `,{encoding:"utf8",flag:"wx"})}catch(o){if(jt(o))return!1;let s=o instanceof Error?o.message:String(o);return x(`WARN: event claim failed open: ${s}`),!0}return $h(t,n),!0}function Kh(e,t,n){let r=Xt(e),o=To(e),s=L(e,"tool_use_id"),i=L(e,"subagent_id")||L(e,"agent_id"),a=Yt(e,t,void 0,n),c=Dh(e);return{runnerPlatform:a,sessionId:r,runnerEvent:t,turnId:o,toolUseId:s,subagentId:i,callFingerprint:c}}function zc(e,t,n,r=Bc(),o=Date.now()){if(!Mh)return!0;let s=Fh(Kh(e,t,n));if(!s)return!0;let i=jh(s,Uh(r),o);return!i&&v("EV_AI_HOOK_DEBUG")&&x(`DEBUG: duplicate hook event suppressed (claim ${s.slice(0,8)}\u2026)`),i}import{mkdirSync as Bh,readFileSync as wo,statSync as Xc,unlinkSync as qc,writeFileSync as Mo}from"node:fs";import{homedir as Zc}from"node:os";function Qc(e){return e==="session_start"||e==="session_end"}var sr=new Set,Wc=!1;function vo(e=Zc()){return qi(e)}function Lo(e,t=Zc(),n=process.platform){if(e!==void 0)return e>0?e:Mn(n);let r=q(ht(t),{});return ia(r)??Mn(n)}function Zt(e){return Hn(e.pid,e.acquiredAtMs)}function eu(e){try{let t=Xc(e);return t.isFile()&&t.size<=no?wo(e,"utf8"):void 0}catch{return}}function Ho(e,t=vo()){if(!e)return;let n=Ln(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=eu(n);if(o===Zt(r))return ir(r);if(o===Hn(process.ppid,e.acquiredAtMs))try{return Mo(n,Zt(r),{encoding:"utf8",mode:384}),ir(r)}catch{return}}function tu(e,t){if(e.path){sr.delete(e);try{eu(e.path)===Zt(e)&&Mo(e.path,Hn(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}function nu(e,t=Date.now()){let n,r;try{let o=Xc(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=no?wo(e,"utf8"):""}catch{return!1}return Qi(n,r,t)}function ru(e,t=vo(),n=Date.now){for(let r=0;r<e;r+=1)if(!nu(Ln(t,r),n()))return!0;return e<=0}function ou(e){return{pid:process.pid,acquiredAtMs:e}}function Jc(e,t){let n=e instanceof Error?e.message:String(e);return x(`WARN: hook process slot failed open: ${n}`),ou(t)}function ir(e){return sr.add(e),Wc||(Wc=!0,process.once("exit",()=>{for(let t of[...sr])ar(t)})),e}function Yc(e){try{return Mo(e.path,Zt(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(jt(t))return!1;throw t}}function su(e,t=vo(),n=Date.now){if(e<=0)return ou(n());try{Bh(t,{recursive:!0})}catch(s){return Jc(s,n())}let r,o=0;for(let s=0;s<e;s+=1)try{let i={path:Ln(t,s),pid:process.pid,acquiredAtMs:n()};if(Yc(i))return ir(i);if(nu(i.path,n())){o+=1;continue}try{qc(i.path)}catch(a){if(!gt(a))throw a}if(i.acquiredAtMs=n(),Yc(i))return ir(i);o+=1}catch(i){r??=i}return r===void 0||o>0?null:Jc(r,n())}function ar(e,t=Date.now()){if(sr.delete(e),!(!e.path||t-e.acquiredAtMs>=vn-Kt))try{wo(e.path,"utf8")===Zt(e)&&qc(e.path)}catch{}}function Uo(e){v("EV_AI_HOOK_DEBUG")&&x(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}import{closeSync as Gh,writeSync as Vh}from"node:fs";function iu(e=process.env){let t=e[eo];if(delete e[eo],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{Vh(n,$i)}catch{}try{Gh(n)}catch{}}}function Do(e=process.env){let t=e[Li];if(t)return{launcherVersion:t,hookSource:e[Hi]??"",fallbackReason:e[Ui],launcherScope:e[Di]}}function au(e,t){return(e?Bt(e):void 0)===t}import{readFileSync as Yh,statSync as Xh}from"node:fs";import{homedir as qh}from"node:os";import{join as Zh}from"node:path";var lu="EV_AI_PERF_L",Fo="EV_AI_PERF_H",zh="EV_AI_HOOK_PERF";var Wh=/^[a-z][a-z0-9_]{0,23}$/;var cr={origin:0,marks:{},values:{}},ur=!1;function fu(e=process.env){ur=e[zh]!=="0",cr.origin=performance.timeOrigin}function Qt(){return ur}function Fe(e,t=performance.now()){ur&&(cr.marks[e]=t)}function du(){return cr}function pu(e){return Math.round(e*10)/10}function cu(e){return Object.entries(e).map(([t,n])=>`${t}=${pu(n)}`).join(",")}function Jh(e){return`${pu(e.origin)}|${cu(e.marks)}|${cu(e.values)}`}function uu(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||!Wh.test(o)||!(s>=0&&s<=36e5))return!1;t[o]=s}return Object.keys(t).length<=32}function $o(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(!(!uu(n,i.marks)||!uu(r,i.values)))return i}function mu(){return ur?Jh(cr):void 0}var Qh="perf-prev.json",eS=512,tS=1440*60*1e3,nS=12e4,rS=50,en={},gu=!1;function Ko(e){return Math.round(e*10)/10}function ke(e,t){if(!Qt())return t();let n=performance.now();return t().finally(()=>{en[e]=Ko(performance.now()-n)})}function oS(){for(let e of Object.keys(en))delete en[e]}function hu(){if(!Qt())return;let e=mu();e&&(process.env[Fo]=e)}function _u(e,t){if(!e)return;let n=t-e.origin;return n>=-rS&&n<=nS?e:void 0}function sS(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 Su(e=qh()){return Zh(me(e),Qh)}function iS(e,t){if(!gu){gu=!0;try{let n=Su(t);if(Xh(n).size>eS)return;let r=JSON.parse(Yh(n,"utf8"));return!sS(r)||e-r.at>tS?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}function Bo(e,t){if(!Qt())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{ae(Su(t),JSON.stringify(n))}catch{}}function jo(e,t,n,r,o=n.marks){let s=Math.max(0,n.origin-r);e[t]=Ko(s);for(let[i,a]of Object.entries(o))e[i]=Ko(s+a)}function Eu(e,t=process.env,n,r=!1){let o=r?mi():void 0;if(!Qt())return o?{sys:o}:void 0;let s=du(),i="w0"in s.marks?"w":"h",a=i==="w"?_u($o(t[Fo]),s.origin):void 0,c=_u($o(t[lu]),(a??s).origin),l=c?"l":a?"h":i,u=(c??a??s).origin,d={};c&&jo(d,"l",c,u),a&&jo(d,"h",a,u),jo(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(en).length>0&&(f.spans={...en},oS());let p=iS(Date.now(),n);return p&&(f.prev=p),o&&(f.sys=o),f}import{realpathSync as vA}from"node:fs";import{homedir as LA}from"node:os";var K=Ve(Ze(),1);import{existsSync as aS,readFileSync as cS}from"node:fs";import{homedir as yu}from"node:os";import{join as uS}from"node:path";var lS="cloud-cache.json",fS=1440*60*1e3,dS=900*1e3;function pS(e=yu()){return uS(me(e),lS)}function mS(e){if(!aS(e))return;let t=_e(cS(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 gS(e,t){try{ae(e,`${JSON.stringify(t)}
24
- `)}catch(n){let r=n instanceof Error?n.message:String(n);x(`WARN: cloud cache write failed open: ${r}`)}}function _S(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?dS:fS;return n-e.probed_at<r}async function hS(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 SS(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 ES(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 yS(e){let t=await Promise.allSettled([hS(e),SS(e),ES(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}async function Ru(e,t){if(e==="interactive")return null;let n=t?.home??yu(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),s=pS(n),i=mS(s);if(_S(i,e,o))return i.result;let a=await yS(r);return gS(s,{context:e,probed_at:o,result:a}),a}var Ou=Ve(Ze(),1);import{existsSync as Au}from"node:fs";import{homedir as bu}from"node:os";import{join as tn,resolve as Go,sep as Cu}from"node:path";function lr(e,t,n){if(!Au(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 RS(e,t,n){if(!Au(e))return;let r=q(e,{}),o=Go(t),s=null;for(let a of Object.keys(r.projects??{})){let c=Go(a);(o===c||o.startsWith(c.endsWith(Cu)?c:c+Cu))&&(s===null||c.length>Go(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 xu(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"?(lr(tn(r,".claude.json"),{source:"claude_json_user"},o),RS(tn(r,".claude.json"),t,o)):n==="cursor"&&lr(tn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),lr(tn(t,".mcp.json"),{source:"mcp_json"},o),lr(tn(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}async function Vo(e,t=process.cwd(),n="claude",r=bu()){return[...xu(e,t,n,r).values()].map(o=>o.declared)}function Iu(e,t,n=process.cwd(),r="claude",o=bu()){let s=xu(t,n,r,o),i=s.get(e);if(i!==void 0)return i.config??null;for(let[a,c]of s)if((0,Ou.mcpServerNameMatchesToolSegment)(a,e))return c.config??null;return null}var CS=["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"],AS=["CURSOR_PROJECT_DIR"],bS=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function OS(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)bS.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}function Tu(e=process.env){let t=CS.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:OS(e[r]??"")}:{name:r,present:!1}),n=AS.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}import{homedir as tE}from"node:os";import{homedir as ku}from"node:os";import{join as xS}from"node:path";function IS(e=ku()){return xS(e,".claude.json")}function fr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Pu(e=ku()){let n=q(IS(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=fr(n.emailAddress),o=fr(n.fullName)??fr(n.displayName),s=fr(n.accountUuid),i=r??s;return!i||pe(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:i,identity_source:"claude_oauth"}}import{homedir as Mu}from"node:os";import{join as Nu}from"node:path";var TS="https://api.openai.com/auth";function bt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function vu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function kS(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 vu(r)}catch{return null}}function wu(e,t,n){return bt(e[n])??bt(t?.[n])}function PS(e=process.env,t=Mu()){let n=bt(e.CODEX_HOME)??Nu(t,".codex");return Nu(n,"auth.json")}function Lu(e=process.env,t=Mu()){let n=q(PS(e,t),{}),r=bt(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&bt(n.OPENAI_API_KEY))return null;let o=bt(n.tokens?.id_token);if(!o)return null;let s=kS(o);if(!s)return null;let i=vu(s[TS]),a=wu(s,i,"name"),c=wu(s,i,"email");return!c||pe(a,c)?null:{git_user_name:null,git_user_email:null,platform_login:c,identity_source:"codex_oauth"}}import{homedir as mr}from"node:os";import{join as $e}from"node:path";import{join as NS}from"node:path";var wS="cursor-ide-identity.json",MS=840*60*1e3;function Uu(e){return NS(me(e),wS)}function Hu(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Du(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:Hu(t.email),auth_id:Hu(t.auth_id)}}function Fu(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<MS}function $u(e,t){try{ae(e,`${JSON.stringify(t)}
25
- `)}catch(n){let r=n instanceof Error?n.message:String(n);x(`WARN: cursor IDE identity cache write failed open: ${r}`)}}import{execFileSync as vS}from"node:child_process";import{existsSync as LS}from"node:fs";import{createRequire as HS}from"node:module";import{pathToFileURL as US}from"node:url";var Ku=HS(import.meta.url),dr=`
16
+ `}s(rr,"slotRecord");function No(e){let t=e===void 0?null:/^(\d+):(\d+)$/.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&Number.isSafeInteger(r)?{index:n,acquiredAtMs:r}:void 0}s(No,"parseSlotRef");function Oa(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}s(Oa,"isPidAlive");var mg=/^(\d+)\n(\d+)\n$/;function gg(e){let t=mg.exec(e);if(!t)return;let n=Number(t[1]),r=Number(t[2]);return Number.isSafeInteger(n)&&n>0&&Number.isSafeInteger(r)?{pid:n,acquiredAtMs:r}:void 0}s(gg,"parseSlotRecord");function xa(e,t,n){let r=gg(e);if(!r)return Math.abs(n-t)<fn;let o=n-r.acquiredAtMs;return o<-fn||o>=tr?!1:Oa(r.pid)}s(xa,"isSlotRecordHeld");var Na="https://hooks.ev-ai.ai",wa=".claude/ev-ai-runtime-report.json",La="config.json",Eg="max_concurrent_hooks",yI=1024*1024,yg=new Set(["localhost","127.0.0.1","[::1]","::1"]),Rg=["claude","cursor","codex"],Ma=[wa,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],wo=/^[A-Za-z0-9._~-]+$/;function or(e){return e!==void 0&&Rg.includes(e)}s(or,"isKnownRunner");function va(e){if(!e||typeof e!="object")return;let t=e[Eg];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}s(va,"maxConcurrentHooksFromConfig");function Ia(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}s(Ia,"parseCapArg");function wt(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}s(wt,"takeFlagValue");function sr(e){let t,n,r,o,i,a,c;for(let u=0;u<e.length;u++){let f=e[u];if(f!==void 0){if(f==="--runner"){let l=wt(e,u);t=l.value,u=l.next;continue}if(f.startsWith("--runner=")){t=f.slice(9);continue}if(f==="--url"){let l=wt(e,u);l.value&&(r=l.value),u=l.next;continue}if(f.startsWith("--url=")){r=f.slice(6);continue}if(f==="--token"){let l=wt(e,u);l.value&&(o=l.value),u=l.next;continue}if(f.startsWith("--token=")){o=f.slice(8);continue}if(f==="--base-url"){let l=wt(e,u);l.value&&(i=l.value),u=l.next;continue}if(f.startsWith("--base-url=")){i=f.slice(11);continue}if(f===Zn){let l=wt(e,u);a=Ia(l.value)??a,u=l.next;continue}if(f.startsWith(`${Zn}=`)){a=Ia(f.slice(Zn.length+1))??a;continue}if(f===un){let l=wt(e,u);c=No(l.value)??c,u=l.next;continue}if(f.startsWith(`${un}=`)){c=No(f.slice(un.length+1))??c;continue}f!==da&&!f.startsWith("-")&&n===void 0&&(n=f)}}return{runner:or(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:i,...a!==void 0?{cap:a}:{},...c!==void 0?{slot:c}:{}}}s(sr,"parseHookArgv");function ir(e,t=Na){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}s(ir,"buildCollectorUrl");function pt(e=hg()){return Sg(e,".ev-ai",La)}s(pt,"homeManifestPath");function Ua(e,t){return{...e,...t}}s(Ua,"mergeManifestOverlay");function ka(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===127||n===39)return!0}return!1}s(ka,"hasUnsafeCollectorUrlChars");function ar(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?yg.has(t.hostname):!1}catch{return!1}}s(ar,"isAllowedCollectorUrl");function Lo(e){try{let n=new URL(e).pathname.split("/").filter(r=>r.length>0);if(n.length>=2&&n[n.length-1]==="hook"){let r=n[n.length-2];return r&&r.length>0?r:void 0}return}catch{return}}s(Lo,"extractOrgTokenFromCollectorUrl");function Lt(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!ar(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Lo(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!wo.test(n))return`org token must match ${wo.source}`;if(ka(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(ka(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}s(Lt,"collectorUrlProblem");function dn(e){return new URL(e).toString()}s(dn,"normalizeCollectorUrl");function Ha(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?ir(n):""}s(Ha,"resolveCollectorUrl");function Mt(e){try{let t=new URL(e),n=t.pathname.split("/").filter(r=>r.length>0);return n.length>=2&&n[n.length-1]==="hook"&&(n[n.length-2]="***",t.pathname=`/${n.join("/")}`),t.toString()}catch{return"<invalid-url>"}}s(Mt,"redactCollectorUrlForLog");function Da(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=ir(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=Lt(n);return r?{problem:r}:{url:dn(n)}}s(Da,"collectorUrlFromArgv");var Ag="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",Cg="COLLECTOR_URL",Ta="collector_url_override",bg=[Ag,Cg];function Og(e){let t;for(let n of bg){let r=e[n]?.trim();if(!r)continue;let o=Lt(r);if(o){t??={problem:o,envName:n};continue}return{url:dn(r),envName:n}}return t??{}}s(Og,"collectorUrlFromPluginOption");function Pa(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=Lt(t);return n?{problem:n}:{url:dn(t)}}s(Pa,"candidateFromUnknown");function Fa(e){let t=[],n=Pa(e.homeConfig?.[Ta]);if(n.problem&&t.push({label:Ta,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=Da(sr(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=Og(e.env);if(o.problem&&o.envName&&t.push({label:o.envName,problem:o.problem}),o.url)return{url:o.url,source:"plugin_option",warnings:t};let i=Pa(e.homeConfig?.collector_url);if(i.problem&&t.push({label:"collector_url",problem:i.problem}),i.url)return{url:i.url,source:"home_config",warnings:t};let a=e.homeConfig?.repo_ingest_token,c=typeof a=="string"&&a.trim()?{...e.manifest,repo_ingest_token:a}:e.manifest,u=c?Ha(c):"";if(u){let f=Lt(u);if(f)t.push({label:"manifest collector_url",problem:f});else return{url:dn(u),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}s(Fa,"selectCollectorUrl");function mt(e){if(Lt(e))return;let t;try{t=new URL(e)}catch{return}let n=Lo(e);if(!n)return;let o=t.pathname.split("/").filter(c=>c.length>0).slice(0,-2),i=o.length>0?`/${o.join("/")}`:"",a=`${t.origin}${i}/${n}`;return _g("sha256").update(a).digest("hex").slice(0,32)}s(mt,"scopeIdForCollectorUrl");var cr=2;var vt="ev-ai-agent-hook";function xg(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}s(xg,"hookBinaryBasenameFromPath");function $a(e){let t=xg(e);return t===vt||t===`${vt}.exe`}s($a,"isHookBinaryPath");var CI=`current/${vt}`,bI=`.ev-ai/agent-hook/${vt}`,ja=5e3,Ba=5e3,Mo=3e3;var ur=3e3,Ka=1500,Ga=4*1024,vo=256*1024,Ig=4*1024,Va=32*1024,Ke="1.3.10",OI=`@ev-ai/agent-hook@${Ke}`;var za={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{existsSync as _E,mkdirSync as hE,readdirSync as SE,readFileSync as EE,unlinkSync as Du,writeFileSync as yE}from"node:fs";import{homedir as Fu}from"node:os";import{join as us}from"node:path";import{createHash as Sc,randomBytes as g_}from"node:crypto";import{existsSync as Ec,mkdirSync as zo,readFileSync as yc,unlinkSync as Rc,writeFileSync as Ac}from"node:fs";import{homedir as Wo}from"node:os";import{dirname as gr,join as Jo,resolve as __}from"node:path";var kg=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),Tg=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function Se(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||Tg.has(n)||r.includes("[bot]")||kg.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),i=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(i.endsWith("bot")||i.includes("[bot]"))return!0}return!1}s(Se,"isBotOperatorIdentity");import{randomBytes as Lg}from"node:crypto";import{appendFileSync as Mg,mkdirSync as vg,readdirSync as Ug,readFileSync as Fo,renameSync as ec,statSync as gn,unlinkSync as oc}from"node:fs";import{homedir as et,tmpdir as Hg}from"node:os";import{dirname as Do,join as gt}from"node:path";var Ya="EV_AI_PERF_L",Uo="EV_AI_PERF_H",pn="EV_AI_RUN_ID",Pg="EV_AI_HOOK_PERF";var Ng=/^[a-z][a-z0-9_]{0,23}$/;var lr={origin:0,marks:{},values:{}},fr=!1;function Xa(e=process.env){fr=e[Pg]!=="0",lr.origin=performance.timeOrigin}s(Xa,"startTimings");function mn(){return fr}s(mn,"timingsActive");function Ge(e,t=performance.now()){fr&&(lr.marks[e]=t)}s(Ge,"mark");function qa(){return lr}s(qa,"ownTimings");function Za(e){return Math.round(e*10)/10}s(Za,"round1");function Wa(e){return Object.entries(e).map(([t,n])=>`${t}=${Za(n)}`).join(",")}s(Wa,"entries");function wg(e){return`${Za(e.origin)}|${Wa(e.marks)}|${Wa(e.values)}`}s(wg,"serializeTimings");function Ja(e,t){if(!e)return!0;for(let n of e.split(",")){let r=n.indexOf("="),o=n.slice(0,r),i=Number(n.slice(r+1));if(r<1||!Ng.test(o)||!(i>=0&&i<=36e5))return!1;t[o]=i}return Object.keys(t).length<=32}s(Ja,"parseEntries");function Ho(e){if(!e||e.length>1024)return;let[t,n,r,...o]=e.split("|"),i=Number(t);if(o.length>0||!Number.isFinite(i)||i<=0)return;let a={origin:i,marks:{},values:{}};if(!(!Ja(n,a.marks)||!Ja(r,a.values)))return a}s(Ho,"parseTimings");function Qa(){return fr?wg(lr):void 0}s(Qa,"serializeOwnTimings");var Dg="hooks-debug.log",Fg=/^hooks-debug\.log\.\d+$/,$g=/^hooks-debug\.log(\.1)?\.send-\d+$/,tc="ev-ai-agent-hooks.log",jg="EV_AI_HOOK_RUN_LOG",Ut="unlimited",Bg="off",$o=1024*1024,Kg=8*1024,nc=$o/2-Kg,Gg=10080*60*1e3,Vg=1024*1024,zg="run-log-windows.json",Wg=64*1024,jo=/^[a-z0-9]{8}$/,rc="abcdefghijklmnopqrstuvwxyz0123456789",Jg=/[^A-Za-z0-9._:/+-]/g,Yg=128,tt={info(){},error(){}},Re=tt;function pr(e=et()){return gt(e,".ev-ai",Dg)}s(pr,"fileLogPath");function sc(e){try{let t=JSON.parse(Tt(Fo(gt(e,".ev-ai","config.json"),"utf8")));return _t(t)?t:void 0}catch{return}}s(sc,"readHomeConfig");function Xg(e){return e?.debug===!0}s(Xg,"debugFromHomeConfig");function Bo(e,t=!1){return e.includes("--debug")||t}s(Bo,"isHookDebugEnabled");function _t(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(_t,"isRecord");function qg(e,t){let n=e?.log_until;if(typeof n!="string")return;let r=[];if(n===Ut)return{on:!0,source:"local_config",scopes:r,localUntil:n};if(n===Bg)return{on:!1,source:"local_config",scopes:r,localUntil:n};let o=Date.parse(n);return Number.isNaN(o)?void 0:{on:o>t,source:"local_config",scopes:r,localUntil:n}}s(qg,"localRunLog");function Zg(e){if(!_t(e)||!_t(e.config))return;let t=e.config.log_until;if(typeof t!="string")return;if(t===Ut)return{until:t,untilMs:Number.POSITIVE_INFINITY};let n=Date.parse(t);return Number.isNaN(n)?void 0:{until:t,untilMs:n}}s(Zg,"scopeUntilMs");function ic(e=et(),t=process.env,n=Date.now()){return ac(e,()=>sc(e),t,n)}s(ic,"readRunLogSwitch");function ac(e,t,n,r){let o=n[jg]?.trim().toLowerCase();if(o&&ft.has(o))return{on:!0,source:"env",scopes:[]};if(o&&Yn.has(o))return{on:!1,source:"env",scopes:[]};let i=qg(t(),r);if(i)return i;let a=[];try{let c=gt(e,".ev-ai","agent-hook","hook-config.json"),u=gn(c);if(!u.isFile()||u.size>Vg)return{on:!1,source:"remote",scopes:a};let f=JSON.parse(Fo(c,"utf8"));if(_t(f))for(let[l,p]of Object.entries(f)){let d=Zg(p);d&&d.untilMs>r&&a.push({scopeId:l,...d})}}catch{}return{on:a.length>0,source:"remote",scopes:a}}s(ac,"runLogSwitch");function cc(e=et()){return gt(e,".ev-ai","agent-hook",zg)}s(cc,"runLogWindowsPath");function Ko(e=et()){try{let t=cc(e),n=gn(t);if(!n.isFile()||n.size>Wg)return{};let r=JSON.parse(Fo(t,"utf8")),o={};if(_t(r))for(let[i,a]of Object.entries(r))typeof a=="string"&&(o[i]=a);return o}catch{return{}}}s(Ko,"readRunLogWindows");function Go(e,t=et()){try{let n=Ko(t),r={...n};if(e(r),JSON.stringify(r)===JSON.stringify(n))return;ce(cc(t),`${JSON.stringify(r,null,2)}
17
+ `)}catch{}}s(Go,"updateRunLogWindows");function Qg(e,t){Go(n=>{for(let r of t)n[r.scopeId]=r.until},e)}s(Qg,"recordRunLogWindows");function e_(e){return e.replace(/[\r\n]/g," ")}s(e_,"oneLine");function t_(e){try{if(gn(e).size<nc)return;let t=`${e}.${process.pid}`;ec(e,t);try{ec(t,gn(t).size>=nc?`${e}.1`:e)}catch{oc(t)}}catch{}}s(t_,"rotateIfFull");var n_=/\bhttps?:\/\/[^\s'"<>`]+/gi;function r_(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname.replace(/\/[^/]+\/hook(?![\w-])/,"/***/hook")}`}catch{return"<url>"}}s(r_,"redactUrl");function o_(e,t=et()){let n=e.replace(n_,r_);return t.length>1?n.replaceAll(t,"~"):n}s(o_,"scrubForLog");function s_(e,t){try{vg(Do(e),{recursive:!0}),t_(e),Mg(e,t,{encoding:"utf8",mode:384})}catch{}}s(s_,"appendLine");function uc(e=process.argv,t=pr(),n,r){a_();let o=et(),i,a=!1,c=s(()=>(a||(i=sc(o),a=!0),i),"readOnce"),u=Bo(e,n??Xg(c())),f=u||r!==void 0?void 0:ac(o,c,process.env,Date.now());if(!u&&!(r??f?.on)){Re=tt;return}f?.source==="remote"&&Qg(o,f.scopes);let l=s((p,d)=>{s_(t,`${new Date().toISOString()} ${p} ${o_(e_(d),o)}
18
+ `)},"write");Re={info(p){l("info",p)},error(p){l("error",p)}}}s(uc,"initFileLogger");function lc(){return Re!==tt}s(lc,"fileLoggerActive");var ue={info(e){Re.info(e)},error(e){Re.error(e)}},i_=new Set(["post_failed","timeout"]),ae={},Vo=!1;function a_(){ae={},Vo=!1}s(a_,"resetRunState");function fc(){return Vo}s(fc,"runLineWritten");function Q(e){if(Re===tt)return;if(e.outcome===void 0){ae={...ae,...e};return}if(ae.outcome!==void 0&&i_.has(ae.outcome)){ae.err===void 0&&e.err!==void 0&&(ae={...ae,err:e.err});return}let{runner:t,event:n,session:r,tool:o,ackMs:i}=ae;ae={runner:t,event:n,session:r,tool:o,ackMs:i,...e}}s(Q,"noteRun");function nt(e){let t=_t(e)?e.cause:void 0;for(let n of[t,e])if(_t(n)&&typeof n.code=="string"&&n.code!=="")return n.code;return e instanceof Error?e.name:typeof e}s(nt,"runErrorKind");var c_=4096;function u_(e){return(e.stack??"").split(`
19
+ `).map(t=>t.trim()).filter(t=>t.startsWith("at ")).join(" | ")}s(u_,"stackFrames");function mr(e){try{return l_(e).join(" ").slice(0,c_)}catch{return"err=unknown message=(unprintable)"}}s(mr,"errorDetail");function l_(e){let t=[`err=${nt(e)}`];if(!(e instanceof Error))return t.push(`message=${String(e)}`),t;t.push(`message=${e.message}`);let n=u_(e);n&&t.push(`stack=${n}`);let r=e.cause;for(let o=0;r!==void 0&&o<3;o+=1)t.push(r instanceof Error?`cause=${f_(r)}`:`cause=${String(r)}`),r=r instanceof Error?r.cause:void 0;return t}s(l_,"errorParts");function f_(e){if(e instanceof AggregateError&&e.errors.length>0){let t=e.errors.map(n=>n instanceof Error?n.message:String(n));return`${e.name}: ${t.join("; ")}`}return`${e.name}: ${e.message}`}s(f_,"causeText");function U(e,t,n=process.env){if(Re===tt)return;let r=n[pn],o=r!==void 0&&jo.test(r)?` run=${r}`:"";Re.error(`failed where=${e}${o} ${mr(t)}`)}s(U,"logFailure");function d_(){let e="";for(let t of Lg(8))e+=rc[t%rc.length];return e}s(d_,"newRunId");function dc(e=process.env){if(Re===tt)return;let t=e[pn];if(t!==void 0&&jo.test(t))return t;let n=d_();return e[pn]=n,n}s(dc,"ensureRunId");function p_(e){if(typeof e=="number")return Number.isInteger(e)?String(e):e.toFixed(1);let t=e.replace(Jg,"_").slice(0,Yg);return t===""?"_":t}s(p_,"runValue");function Ht(e,t,n,r=process.env){if(Re===tt)return;Vo=!0;let o=r[pn],a=[["run",o!==void 0&&jo.test(o)?o:void 0],["p",e],["start",new Date(performance.timeOrigin).toISOString()],["v",t],["runner",ae.runner],["event",ae.event],["tool",ae.tool],["session",ae.session],["outcome",ae.outcome??n],["ms",performance.now()],["ack_ms",ae.ackMs],["post_ms",ae.postMs],["http",ae.http],["err",ae.err]].filter(c=>c[1]!==void 0&&c[1]!=="").map(([c,u])=>`${c}=${p_(u)}`);Re.info(`run ${a.join(" ")}`)}s(Ht,"writeRunLine");function dr(e,t){try{t-gn(e).mtimeMs>Gg&&oc(e)}catch{}}s(dr,"unlinkIfStale");function pc(e=Date.now(),t=et(),n=m_()){if(Re!==tt)return;let r=pr(t);dr(r,e),dr(`${r}.1`,e);try{for(let o of Ug(Do(r)))(Fg.test(o)||$g.test(o))&&dr(gt(Do(r),o),e)}catch{}dr(n,e)}s(pc,"purgeStaleLog");function m_(e=process.platform){return e==="win32"?gt(Hg(),tc):gt("/tmp",tc)}s(m_,"legacyLogPath");var h_="installation.json",S_="cloud-bootstrap.lock",E_=6e4;function Cc(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}s(Cc,"platformAgentIdCacheKey");function Ee(e=Wo()){return Jo(e,".ev-ai","agent-hook")}s(Ee,"agentHookHome");function y_(e=Wo()){return Jo(Ee(e),h_)}s(y_,"installationStorePath");function bc(e){return Jo(gr(e),S_)}s(bc,"cloudBootstrapLockPath");function Oc(){return g_(8).toString("hex")}s(Oc,"randomInstallationId");function Dt(e){return Sc("sha256").update(e).digest("hex").slice(0,16)}s(Dt,"sha16");function K(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(K,"trimEnv");function xc(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}s(xc,"isValidInstallationId");function R_(e=process.env){let t=K(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!xc(t)){T(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}s(R_,"readInstallationIdEnvOverride");function Ic(e,t){return e&&xc(e)?e:(e&&T(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),R_(t))}s(Ic,"resolvePinnedInstallationId");function A_(e){return/^[0-9a-f]{16}$/.test(e)}s(A_,"isEphemeralInstallationIdShape");function C_(e=process.env){if(K(e.GITHUB_ACTIONS)){let t=K(e.GITHUB_REPOSITORY_ID)??K(e.GITHUB_REPOSITORY),n=K(e.GITHUB_ACTOR)??K(e.GITHUB_TRIGGERING_ACTOR)??K(e.GITHUB_USER);if(t&&n)return Dt(`github_actions|${t}|${n}`)}if(K(e.CODESPACES)||K(e.CODESPACE_NAME)){let t=K(e.CODESPACE_NAME);if(t)return Dt(`codespaces|${t}`);let n=K(e.GITHUB_REPOSITORY_ID)??K(e.GITHUB_REPOSITORY),r=K(e.GITHUB_USER)??K(e.GITHUB_ACTOR);if(n&&r)return Dt(`codespaces|${n}|${r}`)}if(K(e.GITLAB_CI)){let t=K(e.CI_PROJECT_ID)??K(e.CI_PROJECT_PATH),n=K(e.GITLAB_USER_LOGIN)??K(e.GITLAB_USER_EMAIL)??K(e.GITLAB_USER_NAME);if(t&&n)return Dt(`gitlab|${t}|${n}`)}return null}s(C_,"deriveEphemeralInstallationId");var b_="cursoragent@cursor.com";function O_(e){let t=K(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===b_?null:t}s(O_,"cursorCloudUserEmail");function x_(e,t){return K(e.CURSOR_PROJECT_DIR)??K(e.CLAUDE_PROJECT_DIR)??t}s(x_,"cursorCloudWorkspacePath");function I_(e){return sn(e).replace(/\.git$/i,"").toLowerCase()}s(I_,"normalizeRemoteForSeed");async function k_(e){let t=await oe("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?I_(t):e}s(k_,"resolveRepoSeed");async function T_(e){let t=K(await oe("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!Se(null,t))return t;let n=K(await oe("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!Se(null,n)?n:null}s(T_,"readClaudeRemoteOperatorEmail");function P_(e,t){let n=x_(e,t);return n?Dt(`cursor_cloud|${n}|${O_(e)??""}`):null}s(P_,"deriveCursorCloudInstallationId");async function N_(e,t){let n=K(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await k_(n),o=await T_(n);return Dt(`claude_remote|${r}|${o??""}`)}s(N_,"deriveClaudeRemoteInstallationId");function mc(e,t){let n=Ic(e,t);if(n)return n;let r=C_(t);return r||Oc()}s(mc,"chooseNewInstallationId");async function w_(e){let n=await oe("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||__(e);return Sc("sha256").update(n).digest("hex").slice(0,16)}s(w_,"computeRepoKey");function L_(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&r.length>0&&(t[n]=r);return Object.keys(t).length>0?t:void 0}s(L_,"readPlatformAgentIds");function M_(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=L_(t.platform_agent_ids);return{installation_id:t.installation_id,...t.pinned===!0?{pinned:!0}:{},...n?{platform_agent_ids:n}:{},...typeof t.operator_identity_hash=="string"?{operator_identity_hash:t.operator_identity_hash}:{},...typeof t.operator_identity_sent_at=="string"?{operator_identity_sent_at:t.operator_identity_sent_at}:{}}}catch{return}}s(M_,"parseInstallationRecord");function ht(e){if(Ec(e))try{return M_(yc(e,"utf8"))}catch{}}s(ht,"readInstallationRecord");function Yo(e){return ht(e)}s(Yo,"readInstallationStore");function kc(e,t,n){let r=ht(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)}
20
+ `)}catch(i){let a=i instanceof Error?i.message:String(i);T(`WARN: operator identity cache write failed open: ${a}`),U("operator_identity_cache",i)}}s(kc,"writeOperatorIdentityCache");function Tc(e,t=Date.now()){if(!e)return!0;if(ht(e)?.operator_identity_hash)return!1;let n=bc(e);try{if(Ec(n)){let r=Number.NaN;try{r=Number(yc(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<E_)return!1;try{Rc(n)}catch{}}}catch{}try{return zo(gr(n),{recursive:!0}),Ac(n,`${t}
21
+ `,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(Lc(r))return!1;let o=r instanceof Error?r.message:String(r);return T(`WARN: cloud bootstrap claim failed open: ${o}`),U("cloud_bootstrap_claim",r),!0}}s(Tc,"tryClaimCloudIdentityBootstrap");function Pc(e){if(e)try{Rc(bc(e))}catch{}}s(Pc,"releaseCloudIdentityBootstrapClaim");function Nc(e,t){let r=ht(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}s(Nc,"readCachedPlatformAgentId");function wc(e,t,n){if(!n)return;let r=ht(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)}
22
+ `)}catch(i){let a=i instanceof Error?i.message:String(i);T(`WARN: platform_agent_id cache write failed open: ${a}`),U("platform_agent_id_cache",i)}}s(wc,"writeCachedPlatformAgentId");function Lc(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}s(Lc,"isEexistError");function v_(e,t){zo(gr(e),{recursive:!0}),Ac(e,`${JSON.stringify(t,null,2)}
23
+ `,{encoding:"utf8",flag:"wx"})}s(v_,"writeInstallationRecordExclusive");function gc(e,t){try{return v_(e,t),t}catch(n){if(!Lc(n))throw n;return ht(e)}}s(gc,"tryCreateInstallationRecord");function _c(e,t){zo(gr(e),{recursive:!0}),ce(e,`${JSON.stringify(t,null,2)}
24
+ `)}s(_c,"replaceInstallationRecord");function hc(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}s(hc,"newInstallationRecord");async function Mc(e,t={}){let n=t.home??Wo(),r=t.env??process.env,o=await w_(e),i=y_(n),a={sessionId:t.sessionId,hostname:K(r.HOSTNAME)??void 0,osUser:K(r.USER)??K(r.LOGNAME)??K(r.USERNAME)??void 0,env:r},c=cn(a),u=Ic(t.overrideId,r),f=c==="cursor_cloud"&&Io(a)?P_(r,e):c==="claude_remote"?await N_(r,e):null,l=ht(i);if(l){let E=l;if(u&&u===l.installation_id&&l.pinned!==!0&&(E={...l,pinned:!0},_c(i,E)),!!f&&f!==E.installation_id&&!u&&E.pinned!==!0&&A_(E.installation_id)&&f){let b={installation_id:f,...E.platform_agent_ids?{platform_agent_ids:E.platform_agent_ids}:{}};return _c(i,b),{installationId:f,storePath:i,repoKey:o}}return{installationId:E.installation_id,storePath:i,repoKey:o}}let p=u??f??mc(void 0,r),d=gc(i,hc(p,u));if(d)return{installationId:d.installation_id,storePath:i,repoKey:o};let m=u??f??mc(void 0,r),_=gc(i,hc(m===p?Oc():m,u));if(_)return{installationId:_.installation_id,storePath:i,repoKey:o};throw new Error(`Failed to create installation record at ${i}`)}s(Mc,"resolveOrCreateInstallationId");import{existsSync as Z_}from"node:fs";import{existsSync as B_}from"node:fs";import{homedir as Hc}from"node:os";import{join as K_}from"node:path";import{existsSync as U_,readdirSync as vc}from"node:fs";import{homedir as _r}from"node:os";import{join as pe}from"node:path";function H_(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return pe(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}s(H_,"claudeManagedSettingsDir");function D_(e=process.platform){let t=H_(e),n=[pe(t,"managed-settings.json")],r=pe(t,"managed-settings.d");try{if(!U_(r))return n;let o=vc(r).filter(i=>i.endsWith(".json")&&!i.startsWith(".")).sort().map(i=>pe(r,i));n.push(...o)}catch{}return n}s(D_,"listClaudeManagedSettingsFiles");function _n(e=process.platform,t=_r()){return{serverManaged:pe(t,".claude","remote-settings.json"),fileBased:D_(e)}}s(_n,"claudeManagedSettingsSources");function F_(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return pe(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}s(F_,"cursorEnterpriseSettingsDir");function $_(e=process.platform,t=_r()){let n=[pe(F_(e),"hooks.json")],r=pe(t,".cursor","managed");try{for(let o of vc(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(pe(r,o.name,"hooks.json"))}catch{}return n}s($_,"listCursorManagedSettingsFiles");function j_(e=process.platform,t=_r()){let n=e==="win32"?pe(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[pe(n,"requirements.toml")];return e!=="win32"&&r.push(pe(n,"managed_config.toml")),r.push(pe(t,".codex","managed_config.toml"),pe(n,"config.toml")),r}s(j_,"listCodexManagedSettingsFiles");function hr(e,t=process.platform,n=_r()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=_n(t,n);return[r,...o]}case"cursor":return $_(t,n);default:return j_(t,n)}}s(hr,"managedSettingsFiles");function Dc(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}s(Dc,"hookParsableSettings");var G_={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 Uc(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}s(Uc,"concatOptional");function V_(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:Uc(n.mcpJson,t.mcpJson),mcpToml:Uc(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}s(V_,"layoutForScope");function Fc(e){return Object.fromEntries(Object.entries(G_).map(([t,n])=>[t,V_(n,n[e])]))}s(Fc,"layoutsForScope");var Ft=Fc("homeOnly"),ot=Fc("projectOnly");function z_(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}s(z_,"layoutRelativePaths");function W_(e,t){return z_(e).some(n=>B_(K_(t,n)))}s(W_,"layoutHasAnyEntry");function $c(e,t){for(let n of e)if(W_(n,t))return!0;return!1}s($c,"anyLayoutHasAnyEntry");function rt(e){return[...new Set(e)]}s(rt,"uniqueRels");function st(e){let t=[],n=[],r=[],o=[],i=[],a=[],c=[];for(let u of e){t.push(...u.skillRoots);for(let f of u.dirs)f.kind==="SUBAGENT"?n.push(f.dir):f.kind==="COMMAND"?r.push(f.dir):o.push(f.dir);i.push(...u.memory.flat()),a.push(...u.settings),c.push(...u.mcpJson??[],...u.mcpToml??[])}return{skills:rt(t),subagents:rt(n),commands:rt(r),rules:rt(o),memory:rt(i),settings:rt(a),mcp:rt(c)}}s(st,"userScopePathsFromLayouts");function J_(e,t=Hc(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...hr(o.managed,n,t));return rt(r)}s(J_,"managedSettingsFromLayouts");var it=st(Object.values(Ft));function jc(e=Hc(),t=process.platform){return J_(Object.values(Ft),e,t)}s(jc,"userScopeManagedSettings");import{existsSync as Y_}from"node:fs";import{resolve as Xo}from"node:path";function Ae(e){return Xo(e).replaceAll("\\","/").replace(/\/$/,"")}s(Ae,"posixAbs");function St(e,t){let n=new Set(t),r=[];for(let o of e)n.delete(o)&&r.push(o);for(let o of[...n].sort())r.push(o);return r}s(St,"uniqueOrderedRoots");function Sr(e,t){if(!e)return t;let n=`${e}/`,r=[],o=[];for(let i of t)i===e||i.startsWith(n)?r.push(i):o.push(i);return r.length===0?t:[...r,...o]}s(Sr,"preferMarkerDirRoots");var X_=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function hn(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!X_.test(t)?null:t}s(hn,"sanitizeComponentRelativePath");function $t(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let i=Ae(o);n.has(i)||(n.add(i),r.push(i))}return r}s($t,"projectAnchors");function q_(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}s(q_,"isInside");function Le(e,t,n,r=Y_){for(let o of e)for(let i of t){let a=Ae(Xo(o,i)),c=Xo(o,i,n).replaceAll("\\","/");if(q_(a,c)&&r(c))return c}return null}s(Le,"firstExistingUnderRoots");var Kc=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Gc=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,Q_=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,Bc=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"]),eh=/^[a-z][a-z0-9-]{1,63}$/,th=[".cursor/skills",".claude/skills",".agents/skills"],nh=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],rh=St(th,st(Object.values(ot)).skills),oh=St(nh,st(Object.values(Ft)).skills),sh=new Set(["read","read_file","view"]),ih=new Set(["bash","shell","zsh"]);function qo(e){let t=e.replace(/\\/g,"/");return Kc.exec(t)?.[1]??null}s(qo,"skillIdFromSkillMdPath");function ah(e){let t=e.replace(/\\/g,"/"),r=Gc.exec(t)?.[1];return r?r.toLowerCase():null}s(ah,"skillIdFromCodexCommandPath");function ch(e){return qo(e)??ah(e)}s(ch,"skillIdFromReferencedPath");function uh(e){for(let t of["path","file_path","target_file"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}return null}s(uh,"pathFromToolInputRecord");function Er(e){return typeof e=="string"?Er(xe(e,null)):!e||typeof e!="object"?null:uh(e)}s(Er,"pathFromToolInput");function Vc(e){if(typeof e=="string")return Vc(xe(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}s(Vc,"commandFromToolInput");function Zo(e){let t=Vc(e.tool_input);if(t)return t;let n=dt(e.command);return n.length>0?n:null}s(Zo,"commandFromHookInput");function lh(e){let t=e.replace(/\\/g,"/"),n=Kc.exec(t);if(n?.[1])return n[1];let o=Gc.exec(t)?.[1];return o?o.toLowerCase():null}s(lh,"skillIdFromShellCommand");function fh(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}s(fh,"toolNameFromHookInput");function Qo(e){let t=Er(e.tool_input)??dt(e.file_path);return t.length>0?t:null}s(Qo,"filePathFromHookInput");function Sn(e,t,n){let r=fh(e).toLowerCase();if(sh.has(r)){let o=Qo(e);return o?t(o):null}if(ih.has(r)){let o=Zo(e);return o?n(o):null}return null}s(Sn,"nameFromReadOrShellHookInput");function zc(e){return Sn(e,ch,lh)}s(zc,"skillNameFromReadHookInput");function dh(e){let t=new Set,n=[];for(let r of e.matchAll(Q_)){let o=r[1]?.toLowerCase();!o||t.has(o)||ph(o)||(t.add(o),n.push(o))}return n}s(dh,"extractSlashSkillNames");function ph(e){let t=e.split("/")[0];return Bc.has(e)||t!==void 0&&Bc.has(t)}s(ph,"isDeniedSlashId");function Wc(e){let t=e.skillId.toLowerCase();if(!eh.test(t))return null;let n=e.exists??Z_,r=`${t}/SKILL.md`,o=Le($t(e.launchCwd,e.gitRoot),rh,r,n);return o!==null?o:e.home?Le([Ae(e.home)],oh,r,n):null}s(Wc,"resolveSkillMdPath");function mh(e){return dt(e.prompt)}s(mh,"promptFromHookInput");function Jc(e){let t=F(e,"command_name");if(t){let r=F(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=mh(e);return n?dh(n):[]}s(Jc,"skillNamesFromHookInput");var ss=Ze(ct(),1);import{existsSync as jS}from"node:fs";var yt={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function yn(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}s(yn,"normalizePathSlug");function $S(e){if(!e)return"";let t=sn(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return yn(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return yn(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?yn(o[1]):yn(t)}s($S,"normalizeGitRemoteToSlug");async function xr(e=process.cwd()){let t=await Oe("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,i]=await Promise.all([Oe("git",["remote","get-url","origin"],2e3,{cwd:e}),Oe("git",["branch","--show-current"],2e3,{cwd:e}),Oe("git",["rev-parse","HEAD"],2e3,{cwd:e}),Oe("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?sn(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:i.ok?i.stdout.length>0:null}}s(xr,"gitSnapshot");async function Eu(e,t,n,r=process.cwd(),o,i,a){if(t)return t;let c=yt[n];if(!c)return"";let u=Cc(n,e.scope_path,a);if(i){let _=Nc(i,u);if(_)return _}let f=o??await xr(r),l=f?.remote?$S(f.remote):"";if(l||(l=yn(process.env.GITHUB_REPOSITORY??"")),!l)return"";let p=e.scope_path??"",d=p?`${p}/`:"",m=`${l}:${d}${c}`;return i&&wc(i,u,m),m}s(Eu,"derivePlatformAgentId");var BS=[".cursor/rules",".claude/rules",".codex/rules"],KS=st(Object.values(ot)).rules;function GS(e){return St(Sr(e?yt[e]:void 0,BS),KS)}s(GS,"ruleRootsForRunner");var VS=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function yu(e){let t=hn(e.relativePath);if(!t)return null;let n=e.exists??jS,r=$t(e.launchCwd,e.gitRoot),o=GS(e.runnerPlatform),i=Le(r,o,t,n);if(i!==null)return i;if(!t.includes("/")){let a=Le(r,["."],t,n);if(a!==null)return a}return e.home?Le([Ae(e.home)],o,t,n):null}s(yu,"resolveRuleMdPath");function zS(e){let t=e.replace(/\\/g,"/"),r=VS.exec(t)?.[1];return r?(0,ss.nativeKeyForRulePath)(r):null}s(zS,"ruleNameFromShellCommand");function Ru(e){return Sn(e,ss.nativeKeyForRulePath,zS)}s(Ru,"ruleNameFromReadHookInput");function Au(e){return e.replace(/\.(mdc|md|rules)$/i,"")}s(Au,"stripRuleExtension");function Cu(e){let t=e.attachments;if(!Array.isArray(t))return[];let n=new Set,r=[];for(let o of t){if(!o||typeof o!="object"||Array.isArray(o))continue;let i=o;if(i.type!=="rule")continue;let a=typeof i.file_path=="string"?i.file_path:"",c=hn(a);!c||n.has(c)||(n.add(c),r.push(c))}return r}s(Cu,"ruleAttachmentPathsFromHookInput");var is=Ze(ct(),1);import{existsSync as WS}from"node:fs";var JS=[".cursor/commands",".claude/commands",".codex/prompts"],YS=st(Object.values(ot)).commands;function XS(e){return St(Sr(e?yt[e]:void 0,JS),YS)}s(XS,"commandRootsForRunner");var qS=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function bu(e){let t=hn(e.commandId);if(!t)return null;let n=e.exists??WS,r=`${t}.md`,o=XS(e.runnerPlatform),i=Le($t(e.launchCwd,e.gitRoot),o,r,n);return i!==null?i:e.home?Le([Ae(e.home)],o,r,n):null}s(bu,"resolveCommandMdPath");function ZS(e){let t=e.replace(/\\/g,"/"),r=qS.exec(t)?.[1];return r?(0,is.nativeKeyForCommandPath)(r):null}s(ZS,"commandNameFromShellCommand");function Ou(e){return Sn(e,is.nativeKeyForCommandPath,ZS)}s(Ou,"commandNameFromReadHookInput");var Ir=Ze(ct(),1);function xu(e,t){if(F(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}s(xu,"cursorShapedPayload");function QS(){return!!(D("CURSOR_VERSION")??D("CURSOR_PROJECT_DIR"))}s(QS,"isCursorHostEnv");function Iu(e,t,n){return e!=="claude"&&e!=="codex"?!1:xu(t,n)?!0:QS()}s(Iu,"shouldSuppressForeignRunnerOnCursorHost");var eE=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function Kt(e,t,n,r){return xu(e,t)?"cursor":or(r)?r:or(n)?n:F(e,"turn_id")?"codex":F(e,"session_id")||eE.has(t.toLowerCase())?"claude":"unknown"}s(Kt,"detectRunnerPlatform");function kr(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}s(kr,"isInProcessEvent");function tE(e){switch(e){case"sessionstart":return"session_start";case"stop":case"sessionend":case"stopfailure":return"session_end";case"pretooluse":case"posttooluse":case"posttoolusefailure":case"permissiondenied":case"beforemcpexecution":case"beforeshellexecution":case"aftershellexecution":case"beforereadfile":case"afterfileedit":case"subagentstart":case"subagentstop":return"tool_invoked";case"beforesubmitprompt":case"userpromptexpansion":case"userpromptsubmit":return"skill_invoked";default:return""}}s(tE,"mapRunnerEventToInternal");function ku(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}s(ku,"isPromptSubmitRunnerEvent");function Tu(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}s(Tu,"suppressesSlashIds");function Pu(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}s(Pu,"toolSuccessFromRunnerEvent");function Gt(e){return F(e,"session_id")||F(e,"conversation_id")}s(Gt,"sessionIdFromHookInput");function as(e){return F(e,"prompt.id")||F(e,"prompt_id")||F(e,"generation_id")||F(e,"turn_id")}s(as,"turnIdFromHookInput");function cs(e){return F(e,"hook_event_name")||F(e,"event")}s(cs,"runnerEventFromHookInput");function Nu(e,t,n){let r=Gt(e),o=as(e),i=cs(e),a=F(e,"source"),c=Kt(e,i,t,n);return{sessionId:r,turnId:o,runnerEvent:i,hookSource:a,runnerPlatform:c}}s(Nu,"normalizeHookFields");var nE=["session_start","session_end","tool_invoked","skill_invoked"];function rE(e){return nE.includes(e)}s(rE,"isKnownInternalEvent");function Tr(e,t){return e&&rE(e)?e:tE(t.toLowerCase())}s(Tr,"resolveInternalEvent");var oE={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function Pr(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}s(Pr,"isMcpShapedToolName");function wu(e,t=""){let n=F(e,"tool_name")||F(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!Pr(n)&&(n=`MCP:${n}`):n=oE[r]??null;let o=e.tool_input,a=(o&&typeof o=="object"?dt(o.skill)||dt(o.skill_name):"")||F(e,"skill_name")||null,c=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;a??=zc(c);let u=Ru(c),f=Ou(c);return{toolName:n,skillName:a,ruleName:u,commandName:f}}s(wu,"extractToolNames");var sE=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function Lu(e){for(let t of["subagent_type","agent_type"]){let n=F(e,t);if(n&&sE.test(n))return n}return null}s(Lu,"extractSubagentType");function Mu(e){let t=Be(e,"duration_ms");if(typeof t=="number")return t;let n=Be(e,"duration");return typeof n=="number"?n:null}s(Mu,"extractDurationMs");var iE="error",aE="interrupted",cE="permission_denied",uE=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function Rn(e){return uE.test(e)?e:null}s(Rn,"categoricalValue");function lE(e){for(let t of["failure_type","error_type"]){let n=Rn(F(e,t));if(n)return n}return null}s(lE,"structuredFailureClass");function vu(e,t){return Be(e,"is_interrupt")===!0?aE:t.toLowerCase()==="permissiondenied"?cE:lE(e)??iE}s(vu,"extractFailureClass");function Uu(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}s(Uu,"longestDeclaredServer");function fE(e,t){return Uu(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}s(fE,"matchDeclaredMcpServer");function dE(e,t){return Uu(t,n=>(0,Ir.mcpServerNameMatchesToolSegment)(n,e))}s(dE,"matchDeclaredMcpServerSegment");function pE(e,t){let n=null,r=0;for(let i of t)if(i)for(let a of(0,Ir.mcpServerToolSegmentForms)(i)){let c=`${a}__`;e.length>c.length&&e.slice(0,c.length).toLowerCase()===c.toLowerCase()&&a.length>r&&(n={mcpServer:i,mcpTool:e.slice(c.length)},r=a.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:dE(o[1],t)??o[1],mcpTool:o[2]}}s(pE,"parseClaudeMcpNames");function mE(e,t){if(/^mcp__/i.test(e))return pE(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:fE(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}s(mE,"parseMcpNamesFromToolName");function gE(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}s(gE,"stripEncodedMcpServerPrefix");function Hu(e,t=[],n=""){let r=e?mE(e,t):{mcpServer:null,mcpTool:null},o=Rn(n.trim());if(!o)return r;let i=r.mcpTool;return!i&&e&&!Pr(e)&&(i=e),i&&(i=gE(i,o)),{mcpServer:o,mcpTool:i}}s(Hu,"extractMcpNames");var $u=3e4,RE="claims",AE=!0,CE=100,bE=new Set(["sessionstart","sessionend","stopfailure"]),OE=["tool_name","tool","command","file_path","url"];function xE(e=Fu()){return us(Ee(e),RE)}s(xE,"eventClaimDir");function ju(e,t){try{let n=EE(e,"utf8").split(`
25
+ `,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}s(ju,"claimAgeMs");function IE(e){let t=[];for(let n of OE){let r=F(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":an(t.join("\0"))}s(IE,"callFingerprintFromHookInput");function kE(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),i=e.subagentId?.trim()??"",a=e.callFingerprint?.trim()??"",c=!!(o||r||i),u=bE.has(n);if(!c&&!u)return;let f=e.runnerPlatform.trim()||"unknown";return an(`${f}|${t}|${n}|${r}|${o}|${a}|${i}`)}s(kE,"eventClaimKey");function TE(e,t=Date.now()){let n;try{n=SE(e)}catch{return}let r=0;for(let o of n){if(r>=CE)break;r+=1;let i=us(e,o),a=ju(i,t);if(!(!Number.isFinite(a)||a<$u))try{Du(i)}catch{}}}s(TE,"pruneStaleEventClaims");function PE(e,t,n=Date.now()){let r=us(t,e);try{if(_E(r)){let o=ju(r,n);if(Number.isFinite(o)&&o>=0&&o<$u)return!1;try{Du(r)}catch(i){if(!(i instanceof Error&&"code"in i&&i.code==="ENOENT"))return U("event_claim_steal",i),!0}}}catch{}try{hE(t,{recursive:!0}),yE(r,`${n}
26
+ `,{encoding:"utf8",flag:"wx"})}catch(o){if(ln(o))return!1;let i=o instanceof Error?o.message:String(o);return T(`WARN: event claim failed open: ${i}`),U("event_claim",o),!0}return TE(t,n),!0}s(PE,"tryClaimHookEvent");function NE(e,t,n){let r=Gt(e),o=as(e),i=F(e,"tool_use_id"),a=F(e,"subagent_id")||F(e,"agent_id"),c=Kt(e,t,void 0,n),u=IE(e);return{runnerPlatform:c,sessionId:r,runnerEvent:t,turnId:o,toolUseId:i,subagentId:a,callFingerprint:u}}s(NE,"identityFromHookInput");function Bu(e,t,n,r=Fu(),o=Date.now()){if(!AE)return!0;let i=kE(NE(e,t,n));if(!i)return!0;let a=PE(i,xE(r),o);return!a&&D("EV_AI_HOOK_DEBUG")&&T(`DEBUG: duplicate hook event suppressed (claim ${i.slice(0,8)}\u2026)`),a}s(Bu,"claimHookEvent");import{mkdirSync as wE,readFileSync as ls,statSync as zu,unlinkSync as Wu,writeFileSync as fs}from"node:fs";import{homedir as Ju}from"node:os";function Yu(e){return e==="session_start"||e==="session_end"}s(Yu,"isCapExemptEvent");var Nr=new Set,Ku=!1;function ds(e=Ju()){return ba(e)}s(ds,"hookSlotDir");function ps(e,t=Ju(),n=process.platform){if(e!==void 0)return e>0?e:er(n);let r=Z(pt(t),{});return va(r)??er(n)}s(ps,"maxConcurrentHookProcesses");function An(e){return rr(e.pid,e.acquiredAtMs)}s(An,"slotContent");function Xu(e){try{let t=zu(e);return t.isFile()&&t.size<=Po?ls(e,"utf8"):void 0}catch{return}}s(Xu,"readSlotText");function ms(e,t=ds()){if(!e)return;let n=nr(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=Xu(n);if(o===An(r))return wr(r);if(o===rr(process.ppid,e.acquiredAtMs))try{return fs(n,An(r),{encoding:"utf8",mode:384}),wr(r)}catch{return}}s(ms,"adoptHookSlot");function qu(e,t){if(e.path){Nr.delete(e);try{Xu(e.path)===An(e)&&fs(e.path,rr(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}s(qu,"handOffHookSlot");function Zu(e,t=Date.now()){let n,r;try{let o=zu(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=Po?ls(e,"utf8"):""}catch{return!1}return xa(n,r,t)}s(Zu,"isSlotHeld");function Qu(e,t=ds(),n=Date.now){for(let r=0;r<e;r+=1)if(!Zu(nr(t,r),n()))return!0;return e<=0}s(Qu,"hasFreeHookSlot");function el(e){return{pid:process.pid,acquiredAtMs:e}}s(el,"noopSlot");function Gu(e,t){let n=e instanceof Error?e.message:String(e);return T(`WARN: hook process slot failed open: ${n}`),U("slot",e),el(t)}s(Gu,"failOpen");function wr(e){return Nr.add(e),Ku||(Ku=!0,process.once("exit",()=>{for(let t of[...Nr])Lr(t)})),e}s(wr,"hold");function Vu(e){try{return fs(e.path,An(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(ln(t))return!1;throw t}}s(Vu,"tryCreateSlot");function tl(e,t=ds(),n=Date.now){if(e<=0)return el(n());try{wE(t,{recursive:!0})}catch(i){return Gu(i,n())}let r,o=0;for(let i=0;i<e;i+=1)try{let a={path:nr(t,i),pid:process.pid,acquiredAtMs:n()};if(Vu(a))return wr(a);if(Zu(a.path,n())){o+=1;continue}try{Wu(a.path)}catch(c){if(!Nt(c))throw c}if(a.acquiredAtMs=n(),Vu(a))return wr(a);o+=1}catch(a){r??=a}return r!==void 0&&o>0&&U("slot",r),r===void 0||o>0?null:Gu(r,n())}s(tl,"tryAcquireHookSlot");function Lr(e,t=Date.now()){if(Nr.delete(e),!(!e.path||t-e.acquiredAtMs>=tr-fn))try{ls(e.path,"utf8")===An(e)&&Wu(e.path)}catch{}}s(Lr,"releaseHookSlot");function gs(e){D("EV_AI_HOOK_DEBUG")&&T(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}s(gs,"logHookCapReached");import{closeSync as LE,writeSync as ME}from"node:fs";function nl(e=process.env){let t=e[ko];if(delete e[ko],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{ME(n,pa)}catch{}try{LE(n)}catch{}}}s(nl,"signalLauncherReady");function _s(e=process.env){let t=e[ca];if(t)return{launcherVersion:t,hookSource:e[ua]??"",fallbackReason:e[la],launcherScope:e[fa]}}s(_s,"readLauncherContext");function rl(e,t){return(e?mt(e):void 0)===t}s(rl,"launcherScopeMatch");import{readFileSync as vE,statSync as UE}from"node:fs";import{homedir as HE}from"node:os";import{join as DE}from"node:path";var FE="perf-prev.json",$E=512,jE=1440*60*1e3,BE=12e4,KE=50,Cn={},ol=!1;function Ss(e){return Math.round(e*10)/10}s(Ss,"round1");function ve(e,t){if(!mn())return t();let n=performance.now();return t().finally(()=>{Cn[e]=Ss(performance.now()-n)})}s(ve,"span");function GE(){for(let e of Object.keys(Cn))delete Cn[e]}s(GE,"clearSpans");function il(){if(!mn())return;let e=Qa();e&&(process.env[Uo]=e)}s(il,"handOffHookTimings");function sl(e,t){if(!e)return;let n=t-e.origin;return n>=-KE&&n<=BE?e:void 0}s(sl,"trusted");function VE(e){if(e===null||typeof e!="object")return!1;let t=e;return typeof t.at=="number"&&Number.isFinite(t.at)&&typeof t.post_ms=="number"&&Number.isFinite(t.post_ms)&&t.post_ms>=0}s(VE,"isPrevPost");function al(e=HE()){return DE(Ee(e),FE)}s(al,"perfPrevPath");function zE(e,t){if(!ol){ol=!0;try{let n=al(t);if(UE(n).size>$E)return;let r=JSON.parse(vE(n,"utf8"));return!VE(r)||e-r.at>jE?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}s(zE,"takePrevPost");function Es(e,t){if(!mn())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{ce(al(t),JSON.stringify(n))}catch{}}s(Es,"recordPostDuration");function hs(e,t,n,r,o=n.marks){let i=Math.max(0,n.origin-r);e[t]=Ss(i);for(let[a,c]of Object.entries(o))e[a]=Ss(i+c)}s(hs,"addProcess");function cl(e,t=process.env,n,r=!1){let o=r?Bi():void 0;if(!mn())return o?{sys:o}:void 0;let i=qa(),a="w0"in i.marks?"w":"h",c=a==="w"?sl(Ho(t[Uo]),i.origin):void 0,u=sl(Ho(t[Ya]),(c??i).origin),f=u?"l":c?"h":a,l=(u??c??i).origin,p={};u&&hs(p,"l",u,l),c&&hs(p,"h",c,l),hs(p,a,i,l,{...i.marks,...e});let d={base:f,t:p};a==="w"&&c&&p.h3!==void 0&&(d.ack_ms=p.h3),u?.values.bootstrap===1&&(d.bootstrap=!0),Object.keys(Cn).length>0&&(d.spans={...Cn},GE());let m=zE(Date.now(),n);return m&&(d.prev=m),o&&(d.sys=o),d}s(cl,"buildPerf");import{realpathSync as vO}from"node:fs";import{homedir as UO}from"node:os";var V=Ze(ct(),1);import{existsSync as WE,readFileSync as JE}from"node:fs";import{homedir as ul}from"node:os";import{join as YE}from"node:path";var XE="cloud-cache.json",qE=1440*60*1e3,ZE=900*1e3;function QE(e=ul()){return YE(Ee(e),XE)}s(QE,"cloudCachePath");function ey(e){if(!WE(e))return;let t=xe(JE(e,"utf8"),{});if(!(typeof t.context!="string"||typeof t.probed_at!="number"||t.result!==null&&t.result!==void 0&&typeof t.result!="object"))return{context:t.context,probed_at:t.probed_at,result:t.result??null}}s(ey,"readCloudCache");function ty(e,t){try{ce(e,`${JSON.stringify(t)}
27
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);T(`WARN: cloud cache write failed open: ${r}`),U("cloud_cache",n)}}s(ty,"writeCloudCache");function ny(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?ZE:qE;return n-e.probed_at<r}s(ny,"isCacheValid");async function ry(e){let t=await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"60"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=(await t.text()).trim();if(!n)return;let r={"X-aws-ec2-metadata-token":n},[o,i]=await Promise.all([fetch("http://169.254.169.254/latest/meta-data/placement/region",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{}),fetch("http://169.254.169.254/latest/meta-data/instance-id",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{})]);if(!o?.ok&&!i?.ok)return;let a=o?.ok?(await o.text()).trim():"",c=i?.ok?(await i.text()).trim():"";if(!(!a&&!c))return{provider:"aws",region:a,instance_id:c}}s(ry,"probeAws");async function oy(e){let t=await fetch("http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true",{headers:{"Metadata-Flavor":"Google"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=typeof n.zone=="string"?n.zone.split("/").pop()??"":"",o=n.id===void 0?"":String(n.id);if(!(!r&&!o))return{provider:"gcp",region:r,instance_id:o}}s(oy,"probeGcp");async function sy(e){let t=await fetch("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{headers:{Metadata:"true"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=n.compute?.location??"",o=n.compute?.vmId??"";if(!(!r&&!o))return{provider:"azure",region:r,instance_id:o}}s(sy,"probeAzure");async function iy(e){let t=await Promise.allSettled([ry(e),oy(e),sy(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}s(iy,"runCloudProbes");async function ll(e,t){if(e==="interactive")return null;let n=t?.home??ul(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),i=QE(n),a=ey(i);if(ny(a,e,o))return a.result;let c=await iy(r);return ty(i,{context:e,probed_at:o,result:c}),c}s(ll,"probeCloud");var ml=Ze(ct(),1);import{existsSync as dl}from"node:fs";import{homedir as pl}from"node:os";import{join as bn,resolve as ys,sep as fl}from"node:path";function Mr(e,t,n){if(!dl(e))return;let r=Z(e,{});for(let[o,i]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:i})}s(Mr,"readMcpServers");function ay(e,t,n){if(!dl(e))return;let r=Z(e,{}),o=ys(t),i=null;for(let c of Object.keys(r.projects??{})){let u=ys(c);(o===u||o.startsWith(u.endsWith(fl)?u:u+fl))&&(i===null||u.length>ys(i).length)&&(i=c)}if(i===null)return;let a=r.projects?.[i]?.mcpServers??{};for(let[c,u]of Object.entries(a))n.set(c,{declared:{name:c,source:"claude_json_project",sourcePath:".claude.json",scope:"user"},config:u})}s(ay,"readClaudeProjectMcpServers");function gl(e,t,n,r){let o=new Map;for(let i of e.mcp_servers??[])i.name&&o.set(i.name,{declared:{name:i.name,source:"manifest"}});return n==="claude"?(Mr(bn(r,".claude.json"),{source:"claude_json_user"},o),ay(bn(r,".claude.json"),t,o)):n==="cursor"&&Mr(bn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),Mr(bn(t,".mcp.json"),{source:"mcp_json"},o),Mr(bn(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}s(gl,"collectMcpServers");async function Rs(e,t=process.cwd(),n="claude",r=pl()){return[...gl(e,t,n,r).values()].map(o=>o.declared)}s(Rs,"mcpDeclared");function _l(e,t,n=process.cwd(),r="claude",o=pl()){let i=gl(t,n,r,o),a=i.get(e);if(a!==void 0)return a.config??null;for(let[c,u]of i)if((0,ml.mcpServerNameMatchesToolSegment)(c,e))return u.config??null;return null}s(_l,"mcpServerConfig");var cy=["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"],uy=["CURSOR_PROJECT_DIR"],ly=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function fy(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)ly.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}s(fy,"stripUrlUserinfo");function hl(e=process.env){let t=cy.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:fy(e[r]??"")}:{name:r,present:!1}),n=uy.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}s(hl,"readEnvVars");import{homedir as jy}from"node:os";import{homedir as Sl}from"node:os";import{join as dy}from"node:path";function py(e=Sl()){return dy(e,".claude.json")}s(py,"claudeUserConfigPath");function vr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(vr,"trimString");function El(e=Sl()){let n=Z(py(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=vr(n.emailAddress),o=vr(n.fullName)??vr(n.displayName),i=vr(n.accountUuid),a=r??i;return!a||Se(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:a,identity_source:"claude_oauth"}}s(El,"readClaudeOperatorIdentity");import{homedir as Al}from"node:os";import{join as yl}from"node:path";var my="https://api.openai.com/auth";function Vt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Vt,"trimString");function Cl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}s(Cl,"asJsonObject");function gy(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 Cl(r)}catch{return null}}s(gy,"decodeJwtPayload");function Rl(e,t,n){return Vt(e[n])??Vt(t?.[n])}s(Rl,"claim");function _y(e=process.env,t=Al()){let n=Vt(e.CODEX_HOME)??yl(t,".codex");return yl(n,"auth.json")}s(_y,"codexAuthPath");function bl(e=process.env,t=Al()){let n=Z(_y(e,t),{}),r=Vt(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&Vt(n.OPENAI_API_KEY))return null;let o=Vt(n.tokens?.id_token);if(!o)return null;let i=gy(o);if(!i)return null;let a=Cl(i[my]),c=Rl(i,a,"name"),u=Rl(i,a,"email");return!u||Se(c,u)?null:{git_user_name:null,git_user_email:null,platform_login:u,identity_source:"codex_oauth"}}s(bl,"readCodexOperatorIdentity");import{homedir as Dr}from"node:os";import{join as We}from"node:path";import{join as hy}from"node:path";var Sy="cursor-ide-identity.json",Ey=840*60*1e3;function xl(e){return hy(Ee(e),Sy)}s(xl,"cursorIdeIdentityCachePath");function Ol(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Ol,"nullableString");function Il(e){let t=Z(e,{}),n=t.read_at_ms,r=t.db_path;if(!(typeof n!="number"||!Number.isFinite(n)||typeof r!="string"))return{read_at_ms:n,db_path:r,email:Ol(t.email),auth_id:Ol(t.auth_id)}}s(Il,"readCursorIdeIdentityCache");function kl(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<Ey}s(kl,"isCursorIdeIdentityCacheFresh");function Tl(e,t){try{ce(e,`${JSON.stringify(t)}
28
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);T(`WARN: cursor IDE identity cache write failed open: ${r}`),U("cursor_identity_cache",n)}}s(Tl,"writeCursorIdeIdentityCache");import{execFileSync as yy}from"node:child_process";import{existsSync as Ry}from"node:fs";import{createRequire as Ay}from"node:module";import{pathToFileURL as Cy}from"node:url";var Nl=Ay(import.meta.url),Ur=`
26
29
  SELECT key, value
27
30
  FROM ItemTable
28
31
  WHERE key LIKE 'cursorAuth/%'
29
32
  AND key NOT LIKE '%Token%'
30
33
  AND key NOT LIKE '%token%'
31
34
  ORDER BY key
32
- `.trim(),zo=new Map;function ju(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 Bu(e){return e.toLowerCase().includes("token")}function Gu(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=ju(r.key),s=ju(r.value);o&&s&&!Bu(o)&&t.set(o,s)}return t}function DS(e){let t=US(e);return t.search="mode=ro&immutable=1",t.href}function FS(e){try{let t=Ku("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(dr)??n.prepare(dr);return Gu(r.all?.())}finally{n.close?.()}}catch{return null}}function $S(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 jS(e){try{return $S(()=>{let t=Ku("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return Gu(n.prepare(dr).all?.())}finally{n.close?.()}})}catch{return null}}function KS(e){let t=new Map;for(let n of e.split(`
33
- `)){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&&!Bu(s)&&t.set(s,i)}return t}function BS(e){try{let t=vS("sqlite3",["-noheader","-batch","-separator"," ",e,dr],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return KS(t)}catch{return null}}function Vu(e){let t=zo.get(e);if(t)return t;if(!LS(e)){let o=new Map;return zo.set(e,o),o}let n=DS(e),r=FS(n)??BS(n)??jS(n)??new Map;return zo.set(e,r),r}var GS="cursorAuth/cachedEmail",VS="cursorAuth/stripeMembershipAuthId";function pr(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function zS(e=mr(),t=process.platform,n=process.env){let r=pr(n.VSCODE_PORTABLE);if(r)return $e(r,"user-data");let o=pr(n.VSCODE_APPDATA);if(o)return $e(o,"Cursor");switch(t){case"darwin":return $e(e,"Library","Application Support","Cursor");case"win32":return $e(pr(n.APPDATA)??$e(e,"AppData","Roaming"),"Cursor");default:return $e(pr(n.XDG_CONFIG_HOME)??$e(e,".config"),"Cursor")}}function WS(e=mr()){return $e(e,".cursor","cli-config.json")}function JS(e=mr(),t=process.platform,n=process.env){return $e(zS(e,t,n),"User","globalStorage","state.vscdb")}function nn(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function YS(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):nn(e.userId)}function XS(e){return nn(e.email)??nn(e.authId)??YS(e)}function Wo(e){let t=nn(e.email),n=nn(e.displayName),r=XS(e);return!r||pe(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}function qS(e){let n=q(WS(e),{}).authInfo;return!n||typeof n!="object"?null:Wo(n)}function ZS(e,t,n){let r=JS(e,process.platform,t),o=Uu(e),s=Du(o);if(Fu(s,r,n))return Wo({email:s?.email,authId:s?.auth_id});let i=Vu(r),a=i.get(GS)??null,c=i.get(VS)??null;return $u(o,{read_at_ms:n,db_path:r,email:a,auth_id:c}),Wo({email:a,authId:c})}function zu(e=mr(),t=process.env,n=Date.now()){return qS(e)??ZS(e,t,n)}import{createHash as QS}from"node:crypto";import{resolve as eE}from"node:path";function X(e){return QS("sha256").update(e).digest("hex").slice(0,16)}function Jo(e){return X(eE(e))}function Se(e,t){return`${e}\0${t}`}function gr(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}function Wu(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}function rn(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(`
34
- `);return X(n)}function nE(e,t,n="git_config",r=null){return X(`${e??""}|${t??""}|${r??""}|${n}`)}function rE(e){let t=null,n=null;for(let r of e.split(`
35
- `)){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 oE(e,t=te){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return rE(n)}function sE(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 je(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 iE(e=process.env){let t=j(e.EV_AI_HOOK_OPERATOR_EMAIL),n=j(e.EV_AI_HOOK_OPERATOR_LOGIN),r=je(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=je(o,null,"github",o);if(s)return s;let i=j(e.GITLAB_USER_LOGIN),a=j(e.GITLAB_USER_EMAIL),c=je(j(e.GITLAB_USER_NAME)??i,a,"gitlab",a??i);if(c)return c;let l=j(e.BUILD_REQUESTEDFOREMAIL),u=je(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=je(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=je(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),C=je(S,null,"circleci",S);if(C)return C;let A=j(e.CODEBUILD_INITIATOR),I=je(A,null,"codebuild",A);if(I)return I;let P=j(e.DRONE_COMMIT_AUTHOR_EMAIL),T=j(e.DRONE_COMMIT_AUTHOR),k=je(T??j(e.DRONE_COMMIT_AUTHOR_NAME),P,"drone",P??T);if(k)return k;if(Ju(e.CLAUDE_CODE_REMOTE)||Ju(e.CURSOR_AGENT)){let B=j(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:B&&!pe(null,B)?B:null,identity_source:"cloud"}}return null}function Yo(e){return!!((e.git_user_name??e.git_user_email)&&!pe(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 Ju(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function aE(e,t,n){return e==="claude"?Pu(t):e==="cursor"?zu(t,n):e==="codex"?Lu(n,t):null}async function Xo(e,t=te,n=process.env,r={}){let o=await oE(e,t),s=sE(n),i=Yo(o)?o:s&&Yo(s)?s:null,a=aE(r.runnerPlatform,r.home??tE(),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=iE(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:Yo(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 qo(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??te,s=e.env??process.env,i=await Xo(t,o,s,{runnerPlatform:e.runnerPlatform,home:e.home}),a=nE(i.git_user_name,i.git_user_email,i.identity_source,i.platform_login),l=(n?_o(n):void 0)?.operator_identity_hash;if(!(r||l!==void 0&&l!==a||!l))return{commit:()=>{}};let p=n;return{operator:i,commit:()=>{p&&Na(p,a,In())}}}function Zo(e){return e?!_o(e)?.operator_identity_hash:!0}function Yu(e){return!0}import{existsSync as AC,readFileSync as bC}from"node:fs";import{homedir as yd}from"node:os";import{join as Pt,resolve as OC}from"node:path";import{basename as gC,join as kt}from"node:path";import{dirname as sl,resolve as Er}from"node:path";import{existsSync as cE}from"node:fs";import{homedir as Zu}from"node:os";import{relative as Qu,resolve as Pe,sep as Qe}from"node:path";var uE=["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"],lE=["prompt","tool_input","tool_response","last_assistant_message","command"],fE=new Set;function dE(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return fE}}function rs(e){let t=v("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Dt.has(t.toLowerCase()):e?.collect_prompt===!0}function _r(e,t){let n=el(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=v("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?Dt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}function el(e){return v("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||e.debug===!0||v("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}function pE(e){let t={};for(let n of uE){let r=He(e,n);r!==void 0&&(t[n]=r)}return t}function hr(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Pe(e),r=Pe(t),o=Qu(r,n);return!o||o==="."?".":o.startsWith(`..${Qe}`)||o===".."||Pe(r,o)!==n?null:o.split(Qe).join("/")}function tl(e,t){let n=Qu(Pe(t),Pe(e)).split(Qe).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}function nl(e){return typeof e!="string"||e.length===0?null:Pe(e).split(Qe).join("/")}function mE(){let e=v("CURSOR_PROJECT_DIR");if(!e)return null;let t=Pe(e);return cE(t)?t.split(Qe).join("/"):null}function es(e,t){return hr(e,t)!==null}function gE(e,t){let n=Pe(t??Zu(),".cursor").split(Qe).join("/");return es(e,n)}function _E(e,t,n){return t!==null&&es(e,t)?!0:t!==null&&gE(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&es(e,n.gitRoot)?!0:t===null}function rl(e,t){let n=nl(e.cwd);if(n!==null)return n;let r=Pe(process.cwd()).split(Qe).join("/"),o=mE();return _E(r,o,t)?r:o??r}function os(e,t={}){return rl(e,t)}function ss(e,t=Zu()){let n=Pe(t).split(Qe).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function Xu(e,t,n){let r=nl(n.launchCwd)??rl(t,n);e.cwd=ss(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?hr(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}var ol="\u2026[truncated]\u2026",ts=Buffer.byteLength(ol,"utf8"),hE=8;function on(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function qu(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}function SE(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}function EE(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=ts)return qu(e,t);let r=t-ts,o=Math.ceil(r/2),s=Math.floor(r/2);return`${qu(e,o)}${ol}${SE(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 yE(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 RE=256;function CE(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 AE(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let s=on(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=CE(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&&yE(e,u.path,EE(u.value,r))}}function bE(e,t){let n=Math.max(0,t-RE),r=Object.keys(e).filter(s=>!s.startsWith("_")).map(s=>({key:s,bytes:on(e[s])})).sort((s,i)=>i.bytes-s.bytes),o=[];for(let{key:s}of r){if(on(e)<=n)break;delete e[s],o.push(s)}o.length>0&&(e._dropped_keys=o.slice(0,10))}function Qo(e,t){let n=on(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,AE(r,t,ts+hE),on(r)>t&&bE(r,t),r}function OE(e,t,n){if(!(n.promptCapture??rs()))return;let r=dE(n.runnerEvent);for(let o of lE){if(r.has(o))continue;let s=t[o];s!==void 0&&(e[o]=s)}}function Sr(e,t,n={}){let r=el(t);if(r==="full"){let s={...e};return delete s.cwd,delete s.transcript_path,Xu(s,e,n),Qo(s,lo)}let o=pE(e);return Xu(o,e,n),r==="content"?(OE(o,e,n),Qo(o,lo)):Qo(o,ma)}function xE(e){return typeof e=="string"&&e.length>0}function is(e){let t=Er(e.home),n=Er(e.launchCwd),r=e.gitRoot?Er(e.gitRoot):null,o=new Set,s=[],i=null;e.inGitRepo&&xE(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&&hr(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&c){let l=sl(r);for(;;){let u=Er(l);if(u===t)break;let d=sl(u);if(d===u)break;if(e.hasProjectSpec(u)){s.push({scope:"parent",dir:u}),a=tl(u,n);break}l=d}}return{anchors:s,parentRel:a}}import{existsSync as il,readdirSync as IE,realpathSync as TE}from"node:fs";import{basename as kE,dirname as PE,relative as NE,resolve as wE,sep as ME}from"node:path";var as=400,yr=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??ze}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=wE(t).split(ME).join("/");return ss(r,this.home)}let n=NE(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${X(PE(t))}/${kE(t)}`:n}claimFile(t){try{let n=TE(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(!il(t))return[];try{return IE(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(il(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 Os,readFileSync as nR,statSync as rR}from"node:fs";import{basename as Cf,join as ct,relative as xs}from"node:path";var Sf=Ve(hf());var eR=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],Ef=eR.map(e=>Sf.default.matcher(e,{dot:!0}));function tR(e){return e===""?!1:Ef.some(t=>t(`${e}/`))}function yf(e,t){if(t==="")return!1;if(e==="")return tR(t);let n=e.replace(/\/+$/,"");return Ef.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}var Is=100*1024,oR=4;function sR(e){return e.length<=Is?e:`${e.slice(0,Is-1)}\u2026`}function iR(e){try{let t=nR(e),n=t.toString("utf8");return{hash:X(t),length:t.length,text:sR(n)}}catch{return null}}var Rf={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function aR(e){return e in Rf?Rf[e]:"UNSPECIFIED"}function It(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=iR(t.absolutePath);if(!n)return!1;let r=t.name??Cf(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=aR(t.kind);return s&&(o.trigger=s),t.attributes&&(o.attributes=t.attributes),e.push(o)}function cR(e,t,n){let r=xs(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?Cf(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function ut(e,t){let{dir:n,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c}=t;Ts(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c})}function Ts(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u}=t;if(!(o>oR))for(let d of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(d.isDirectory()&&yf(n.replace(/\\/g,"/"),xs(n,ct(r,d.name)).replace(/\\/g,"/"))||d.isDirectory()&&u?.includes(ct(r,d.name)))continue;if(c){if(!d.isDirectory())continue;let g=ct(r,d.name,c);if(Os(g)){let S=xs(n,ct(r,d.name)).replace(/\\/g,"/");It(e,{absolutePath:g,kind:s,origin:i,enabled:a,name:S||d.name});continue}Ts(e,{walkRoot:n,currentDir:ct(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(d.isDirectory()){Ts(e,{walkRoot:n,currentDir:ct(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=ct(r,d.name);It(e,{absolutePath:p,kind:s,origin:i,enabled:a,name:cR(n,p,!0)})}}function Af(e){for(let t of e)if(Os(t))try{if(rR(t).size>0)return t}catch{continue}return e.find(t=>Os(t))}import{existsSync as DR,readFileSync as FR}from"node:fs";var Ir=Ve(Ze(),1);var uR="<omitted>",lR=["package_name","package_spec","package_version","package_version_source"],bf=100,Of=120,Tr=[{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"}],xf=new Set(Tr.map(e=>e.attr)),fR=["enabled","disabled"],dR=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],pR=new Set(["type","command","url","args","env","envVars","headers",...fR,...dR,...Tr.map(e=>e.raw)]),mR=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",...lR,...xf,...[...xf].map(e=>`${e}_truncated`)]);function If(e,t){for(let n of t)pR.has(n)||mR.has(n)||(e[n]=uR)}var gR=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,_R=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,hR=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,SR=/^bearer(?:\s+|$)/i;function kr(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Tf(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function ks(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=kr(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function lt(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function ER(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,Ir.launchContainsCredentials)({kind:"url",url:e})||(0,Ir.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=dn([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,Ir.launchContainsCredentials)({kind:"url",url:r}):!0)}function kf(e,t,n){ER(t,n)&&(e.launch_had_credentials=!0)}function yR(e){return hR.test(e)||SR.test(e)?"<redacted>":e.includes("://")?lt(e):e}function Pf(e){if(/^https?:\/\//i.test(e))return lt(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Pf(e.slice(t+1))}`:yR(e)}function RR(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return gR.test(t)||_R.test(t)}function dn(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(RR(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Pf(r))}return t}function CR(e){let t=Tf(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Of?r.slice(0,Of):r))].sort();if(n.length!==0)return n.length>bf?{names:n.slice(0,bf),truncated:!0}:{names:n,truncated:!1}}function AR(e){let t=kr(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 Nf(e,t){let n=new Set;for(let{raw:r,attr:o}of Tr){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=CR(s);i&&(e[o]=i.names,i.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function wf(e,t){let n=kr(e),r={transport:t};if(!n)return r;If(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=Tf(n.args);a&&(r.command_or_url=lt(a));let l=dn(c);l.length>0&&(r.args=l),kf(r,a,c);let u=AR(n.env_http_headers),d=[...new Set([...ks(n.env),...ks(n.envVars),...ks(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),Nf(r,n),r}function Mf(e){let t=kr(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function ws(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return X(JSON.stringify({name:e,attributes:r,enabled:n}))}function Tt(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function fn(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 Ns(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function Ps(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=Tt(n[1]);return r.length>0?r:void 0}function bR(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],Tt(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(`
36
- ${e}`);return s?.[1]&&r(s[1]),n}function vf(e){return Ns(e,"enabled")===!1?!1:Ns(e,"disabled")!==!0}function OR(e,t){let n={};for(let{raw:r,attr:o}of Tr){if(o==="auto_approve"){let i=Ns(t,r);if(i!==void 0){n[r]=i;continue}}let s=fn(t,r);s.length>0&&(n[r]=s)}Nf(e,n)}var xR=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,IR=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function TR(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
37
- `)){let s=xR.exec(o);s?.[1]&&t.add(s[1])}for(let o of e.matchAll(IR))o[1]&&t.add(o[1]);return[...t]}function Lf(e,t){let n={transport:t};If(n,TR(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),s=r?Tt(r[1]??""):void 0,i=o?Tt(o[1]??""):void 0,a=s!==void 0&&s.length>0?s:i,c=fn(e,"args");a&&(n.command_or_url=lt(a));let l=dn(c);l.length>0&&(n.args=l),kf(n,a,c);let u=new Set;for(let A of e.split(`
38
- `)){let I=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(A);I?.[1]&&u.add(I[1])}let d=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(d?.[1])for(let A of d[1].split(",")){let I=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(A);I?.[1]&&u.add(I[1])}let f=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
39
- ${e}`);if(f?.[1])for(let A of f[1].split(`
40
- `)){let I=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(A);I?.[1]&&u.add(I[1])}for(let A of fn(e,"env_vars"))u.add(A);let p=bR(e,"env_http_headers");for(let[,A]of p)A.length>0&&u.add(A);let g=Ps(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(([A])=>A))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let S=Ps(e,"auth");S&&(n.auth=S);let C=Ps(e,"default_tools_approval_mode");return C&&(n.default_tools_approval_mode=C),OR(n,e),n}var Me=Ve(Ze(),1);import{createHash as wR}from"node:crypto";import{join as pn}from"node:path";var kR=300,PR=256;function Hf(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 Pr(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 Uf(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function NR(e){return Uf(e,kR)}function Df(e,t){let n=Hf(e.trim(),t),r=Pr(n);if(r.length===0)return"";let[o,...s]=r,i=lt(o),a=dn(s);return NR([i,...a].join(" "))}function Ff(e,t){if(typeof e!="string")return null;let n=Hf(e.trim(),t),r=Pr(n)[0];if(!r)return null;let o=lt(r);return o.length===0?null:Uf(o,PR)}function MR(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,Me.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}function vR(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
41
- `);return wR("sha512").update(t).digest("hex").slice(0,16)}function LR(e){let t=process.platform==="win32"?pn(v("LOCALAPPDATA")??e,"npm-cache"):pn(e,".npm"),n=v("npm_config_cache")??v("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}function $f(e){return typeof e=="string"&&e.length>0&&e.length<=Me.PACKAGE_FIELD_MAX?e:null}function HR(e,t,n){let r=vR(e);for(let o of LR(n)){let s=pn(o,"_npx",r),i=q(pn(s,"node_modules",...t.split("/"),"package.json"),{}),a=$f(i.version);if(a!==null)return a;let c=q(pn(s,"package-lock.json"),{}),l=$f(c.packages?.[`node_modules/${t}`]?.version);if(l!==null)return l}return null}function UR(e){return e.length<=Me.PACKAGE_FIELD_MAX?e:`${e.slice(0,Me.PACKAGE_FIELD_MAX-1)}\u2026`}function Ms(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,Me.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let s=(0,Me.packageNameFromSpec)(o);return s===null?null:{package_name:s,package_spec:UR(o),...MR(o,HR(r,s,n))}}function jf(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=Pr(e.trim());return n===void 0?null:Ms(n,r,t)}function Nr(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 Ms(typeof n.command=="string"?n.command:null,r,t)}function Kf(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:Ms(Tt(n[1]??""),fn(e,"args"),t)}function $R(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 Bf(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=$R(a),l=wf(a,c);Object.assign(l,Nr(a,e.home)??{});let u=Mf(a);e.push({kind:"MCP_SERVER",name:i,path:s,content_hash:ws(i,l,u),origin:n,enabled:u,attributes:l})}}function Gf(e,t,n){if(!DR(t)||!e.claimFile(t))return;let r;try{r=FR(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=Lf(u,d);Object.assign(f,Kf(u,e.home)??{});let p=vf(u);e.push({kind:"MCP_SERVER",name:a,path:o,content_hash:ws(a,f,p),origin:n,enabled:p,attributes:f})}}import{existsSync as BR,readdirSync as GR}from"node:fs";import{join as le}from"node:path";function jR(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 KR(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 vs(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 KR(c)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??c.powershell??"",d=jR({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=X(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:X(S),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:s,...f?{matcher:f}:{},action_kind:d,action_hash:p,...d!=="prompt"&&u.trim()?{command:Df(u,e.home)}:{}}})}}}function Ls(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||vs(e,t,r.hooks,n)}var Vf=50;function mn(e,t,n,r){if(!BR(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(Vf,()=>{ut(e,{dir:le(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),ut(e,{dir:le(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),ut(e,{dir:le(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});Ls(e,le(t,"hooks","hooks.json"),n),Ls(e,le(t,"hooks.json"),n);let i=e.components.length-o,a=s>=Vf;return{componentCount:i,expandTruncated:a}}function gn(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 Hs(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 VR(e){let t=Hs(e.readJson(le(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=Gt(process.platform,e.home),o=e.readJson(n,{}),s={};if(o&&Object.keys(o).length>0)s=Hs(o);else for(let i of r)Object.assign(s,Hs(e.readJson(i,{})));return{...t,...s}}function zf(e){let t=le(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=VR(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,C=!1;for(let A of c)if(typeof A.installPath=="string"&&A.installPath.length>0){let I=mn(e,A.installPath,g,u);S+=I.componentCount,C=C||I.expandTruncated}gn(e,{pluginKey:i,rowPath:s,enabled:u,scope:p,version:f||void 0,marketplace:d||void 0,componentCount:S,expandTruncated:C,contentHash:X(`${i}|${f}|${p}|${u}|${S}`)})}}function zR(e){let t=e,n="";try{let r=GR(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=le(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),s=o[o.length-1];s&&(t=le(e,s),n=s)}}catch{}return{installPath:t,version:n}}var WR=/^\d+$/;function JR(e){let t=e.filter(n=>!WR.test(n.pluginId));return t.length>0?t:e}function Wf(e){let t=[{base:le(e.home,".cursor/plugins/local"),scope:"local"},{base:le(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=le(n,o.name),l=`plugin:${a}`,{componentCount:u,expandTruncated:d}=mn(e,c,l,!0);gn(e,{pluginKey:a,rowPath:e.componentPath(c),enabled:!0,scope:"local",componentCount:u,expandTruncated:d,contentHash:X(`${a}|local|${u}`)});continue}let s=o.name,i=[];for(let a of e.readEntries(le(n,s))){if(!a.isDirectory())continue;let c=le(n,s,a.name),{installPath:l,version:u}=zR(c);i.push({pluginId:a.name,installPath:l,version:u})}for(let a of JR(i)){if(e.truncated)break;let c=`${a.pluginId}@${s}`,l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=mn(e,a.installPath,l,!0);gn(e,{pluginKey:c,rowPath:e.componentPath(a.installPath),enabled:!0,scope:"cache",version:a.version||void 0,marketplace:s,componentCount:u,expandTruncated:d,contentHash:X(`${c}|${a.version}|${u}`)})}}}import{existsSync as qR}from"node:fs";var YR=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,Us="<path>",XR=new RegExp(`${Us}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function wr(e){let t=e.replace(YR,Us).replace(XR,Us);return t.length>200?`${t.slice(0,200)}...`:t}var Jf=200,Yf=200,Ds=16*1024,Xf=6,ZR=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),QR=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),eC=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),tC=new Set(["permissions"]),nC={claude:ZR,cursor_sandbox:QR,cursor_permissions:eC,cursor_cli:tC},rC=new Set(["allow","deny","ask"]);function et(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mr(e){return e.replace(/\\/g,"/")}function Fs(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Fs(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${Fs(t[r])}`).join(",")}}`}function oC(e){return X(`${Fs(e)}|settings1`)}function td(e){let t=Mr(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 nd(e,t){if(e!=="claude")return{};let n=Mr(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 rd(e){let t=Mr(e).replace(/\/+$/,"");return t.length<=1?"":t}function od(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}function sC(e,t){let n=Mr(e);if(n==="~"||n.startsWith("~/"))return n;let r=rd(t);if(!r)return n;let o=n.slice(0,r.length);if(!(od(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let i=n.slice(r.length);return i===""?"~":i.startsWith("/")?`~${i}`:n}var qf=new Map;function iC(e){let t=qf.get(e);if(t!==void 0)return t;let n=rd(e),r=null;if(n){let o=n.split("/").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,od(e)?"gi":"g")}return qf.set(e,r),r}function aC(e,t){let n=iC(t);return n?e.replace(n,"~"):e}function Zf(e,t){return e.length<=Yf?e:(t.truncated=!0,e.slice(0,Yf))}function sd(e,t){return e.length<=Jf?e:(t.truncated=!0,e.slice(0,Jf))}function ne(e,t,n,r){if(typeof e=="string"){if(t==="path")return Zf(sC(e,n),r);let o=t==="rule"?wr(e):e;return Zf(aC(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=sd(e,r),s=[];for(let i of o){let a=ne(i,t,n,r);a!==void 0&&s.push(a)}return s}if(et(e)){let o={};for(let[s,i]of Object.entries(e)){let a=ne(i,t,n,r);a!==void 0&&(o[s]=a)}return o}}function Qf(e,t,n){if(!et(e))return ne(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i="plain";rC.has(o)?i="rule":o==="additionalDirectories"&&(i="path");let a=ne(s,i,t,n);a!==void 0&&(r[o]=a)}return r}function cC(e,t,n){if(!et(e))return ne(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){if(o==="files"&&Array.isArray(s)){let a=sd(s,n);r[o]=a.map(c=>{if(!et(c))return ne(c,"plain",t,n);let l={};for(let[u,d]of Object.entries(c)){let p=ne(d,u==="path"?"path":"plain",t,n);p!==void 0&&(l[u]=p)}return l});continue}let i=ne(s,"plain",t,n);i!==void 0&&(r[o]=i)}return r}function uC(e,t,n){if(!et(e))return ne(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let a=ne(s,o==="allowUnixSockets"?"path":"plain",t,n);a!==void 0&&(r[o]=a)}return r}function lC(e,t,n){if(!et(e))return ne(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i;o==="excludedCommands"?i=ne(s,"rule",t,n):o==="filesystem"?i=ne(s,"path",t,n):o==="network"?i=uC(s,t,n):o==="credentials"?i=cC(s,t,n):i=ne(s,"plain",t,n),i!==void 0&&(r[o]=i)}return r}function fC(e,t,n,r,o){return n==="claude"?e==="permissions"?Qf(t,r,o):e==="sandbox"?lC(t,r,o):ne(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?ne(t,"path",r,o):ne(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?ne(t,"rule",r,o):ne(t,"plain",r,o):e==="permissions"?Qf(t,r,o):ne(t,"plain",r,o)}function _n(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function $s(e,t){return e?`${e}.${t}`:t}function js(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>=Xf?(e.splice(o,1),r.add(n)):js(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>=Xf?(delete e[o],r.add($s(n,o))):js(s,t+1,$s(n,o),r))}function id(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:_n(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))id(o,$s(t,r),n)}function dC(e,t,n){let r=_n(e);if(r<=Ds)return;t.truncated=!0;let o=[];for(id(e,"",o);r>Ds;){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=_n(i)+(s.items.length>0?1:0);s.bytes-=a,r-=a,n.add(s.path)}for(;_n(e)>Ds;){let s,i=-1;for(let[a,c]of Object.entries(e)){let l=_n(c);l>i&&(s=a,i=l)}if(s===void 0)break;delete e[s],n.add(s)}}function pC(e,t,n){let r=nC[t],o={truncated:!1},s={},i=[];for(let c of Object.keys(e)){if(!r.has(c)){i.push(c);continue}let l=fC(c,e[c],t,n,o);l!==void 0&&(s[c]=l)}i.sort();let a=new Set;return js(s,1,"",a),a.size>0&&(o.truncated=!0),dC(s,o,a),{settings:s,keys_omitted:i,truncated:o.truncated,trimmed_paths:[...a].sort()}}function ed(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:oC(t.attributes),attributes:t.attributes};e.push(n)}function Ks(e,t,n,r){if(!e.claimFile(t)||!qR(t))return;let o=Ii(t);if(!o.ok||!et(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),ed(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}return}let s=o.value,i=s.hooks;if(et(i)&&vs(e,t,i,n),!r.profile)return;let a=pC(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),ed(e,{kind:r.kind,absPath:t,origin:n,attributes:c})}import{existsSync as mC}from"node:fs";import{join as ve}from"node:path";var ad=".claude/skills/synced",cd=".claude/plugins/synced";function ud(e){return[ve(e,ad),ve(e,cd)]}function vr(e){return typeof e=="string"&&e.length>0?e:void 0}function ld(e){let t=ve(e.home,ad);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=ve(t,n.name),o=e.readJson(ve(r,"manifest.json"),{}),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=ve(r,i.name,"SKILL.md");if(!i.isDirectory()||!mC(a))continue;let c=s.get(i.name),l=vr(c?.source),u=vr(c?.creatorType);It(e,{absolutePath:a,kind:"SKILL",origin:"user",enabled:!0,name:i.name,attributes:{scope:"synced",...l?{source:l}:{},...u?{creator_type:u}:{}}})}}}function fd(e){let t=ve(e.home,cd);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=ve(t,n.name),o=e.readJson(ve(r,"manifest.json"),{}),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=vr(a?.marketplaceName),l=vr(a?.version),u=c?`${i.name}@${c}`:i.name,d=ve(r,i.name),{componentCount:f,expandTruncated:p}=mn(e,d,`plugin:${u}`,!0);gn(e,{pluginKey:u,rowPath:e.componentPath(d),enabled:!0,scope:"synced",version:l,marketplace:c,componentCount:f,expandTruncated:p,contentHash:X(`${u}|${l??""}|synced|${f}`)})}}}function _C(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:s}=t;for(let i of n.skillRoots)ut(e,{dir:kt(r,i),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:ud(e.home)});for(let i of n.dirs)ut(e,{dir:kt(r,i.dir),kind:i.kind,origin:o,enabled:!0,extensions:i.extensions});for(let i of n.memory){let a=Af(i.map(c=>kt(r,c)));a&&It(e,{absolutePath:a,kind:"MEMORY",origin:o,enabled:!0,name:gC(a)})}for(let i of ja(n))Ks(e,kt(r,i),o,{kind:"SETTINGS",profile:td(i)});for(let i of n.mcpJson??[])Bf(e,kt(r,i),o);for(let i of n.mcpToml??[])Gf(e,kt(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=nd(n.managed,i);Ks(e,i,o,{kind:"MANAGED_SETTINGS",...a})}}n.plugins==="claude"?(zf(e),fd(e),ld(e)):n.plugins==="cursor"&&Wf(e)}}function dd(e,t){try{let n=new yr(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)_C(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 Bs(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let c=dd(t,{layouts:Object.values(yt),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:ze,scopeRef:""});c&&(r.user=c)}let s=n.inGitRepo===!0,i=null,a=n.launchCwd;if(a!==void 0){let c=Object.values(Je),l=is({launchCwd:a,gitRoot:n.gitRoot,inGitRepo:s,remote:n.remote,home:t,hasProjectSpec:u=>Ba(c,u)});i=l.parentRel;for(let u of l.anchors){let d=Jo(u.dir);if(o!==void 0&&!o(u.scope,d))continue;let f=dd(t,{layouts:c,levelDir:u.dir,origin:u.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:as,scopeRef:d});f&&(r[u.scope]=f)}r.parent||(i=null)}return{scopes:r,parentRel:i,cwdInGitRepo:s}}function Gs(e,t,n={}){let r=n.truncated===!0,o=rn(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]!==gr(u)&&a.push(u)}let l=[];if(!r){for(let u of Object.keys(c))if(!s.has(u)){let d=Wu(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 md=2*1024*1024,hC=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function Vs(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 zs(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 gd(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function Ws(e,t=md){let n=[],r=[];for(let u of e)hC.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=gd(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 Js(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:gd(n))}var SC=["user","cwd","repo","parent"];function Ys(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,s=[];for(let T of SC){let k=t.scopes[T];if(!k)continue;let B=n(T,k.scopeRef),D=B.components,O=Gs(k.components,D,{forceFull:D===void 0,truncated:k.truncated}),w=new Set(B.textHashes),H=Vs(k.components,O.upserts,w),m=Js([...O.upserts,...H],w);s.push({scope:T,walk:k,delta:O,outgoing:m,outgoingKeys:new Set(m.map(b=>Se(b.path,b.name))),deliveredTextHashes:w,cachedComponents:D})}let i=s.flatMap(T=>T.outgoing),a=Ws(i,o),c=new Set(a.components.map(T=>Se(T.path,T.name))),l=[],u=[],d=[],f=[],p=[],g=[],S=[];for(let T of s){let{scope:k,walk:B,delta:D}=T;g.push(...B.components),l.push(k);let O=a.components.filter(b=>T.outgoingKeys.has(Se(b.path,b.name))),w=[...T.outgoingKeys].some(b=>!c.has(b)),H=D.truncated||w;H?d.push(k):D.full&&u.push(k),f.push(...O),!D.full&&!H&&p.push(...D.removed);let m=D.full?{}:{...T.cachedComponents??{}};if(!H)for(let b of D.removed)delete m[Se(b.path,b.name)];for(let b of O)m[Se(b.path,b.name)]=gr(b);S.push({scope:k,scopeRef:B.scopeRef,components:m,textHashes:zs(T.deliveredTextHashes,O.filter(b=>b.text!==void 0).map(b=>b.content_hash),B.components),collectedAtMs:r,included:O.length>0||D.removed.length>0&&!H||D.full})}let C={user_spec_hash:rn(g),user_spec_count:g.length,user_spec_truncated:d.length>0};l.length>0&&(C.user_spec_scopes=l,C.user_spec_full_scopes=u,C.user_spec_truncated_scopes=d,C.user_spec_cwd_in_git_repo=t.cwdInGitRepo),u.length>0&&u.length===l.length&&(C.user_spec_full=!0),f.length>0&&(C.user_spec=f),p.length>0&&(C.user_spec_removed=p),a.textDeferredCount>0&&(C.user_spec_text_deferred=a.textDeferredCount);let A=t.scopes.cwd;A&&(C.user_spec_cwd_scope_ref=A.scopeRef);let I=t.scopes.repo;I&&(C.user_spec_repo_scope_ref=I.scopeRef);let P=t.scopes.parent;return P&&(C.user_spec_parent_scope_ref=P.scopeRef,t.parentRel&&(C.user_spec_parent_rel=t.parentRel)),{fields:C,scopes:S}}var Lr={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function Xs(e){return e==="cwd"||e==="repo"||e==="parent"}function hn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function qs(e){return!hn(e)||!hn(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 _d(e){return EC(e)}function hd(e){return yC(e)}function Sd(e){return RC(e)}function EC(e){if(!hn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function yC(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Ed(e,t){if(!hn(e))return;let n=e[t];return qs(n)?n:void 0}function RC(e){if(!hn(e))return{};let t={};for(let[n,r]of Object.entries(e))qs(r)&&(t[n]=r);return t}function Zs(e,t=20){let n=[];for(let[r,o]of Object.entries(e))qs(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 xC=["allow","deny","ask"];function Ur(e){let t=q(e,{}),n=[];for(let r of xC)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:wr(o),mode:r});return{model:t.model??"",permissionKeys:n}}function IC(e){let{serverManaged:t,fileBased:n}=Gt(process.platform,e),r=Ur(t);if(r.model||r.permissionKeys.length>0)return r;let o="",s=[];for(let i of n){let a=Ur(i);a.model&&(o=a.model),s.push(...a.permissionKeys)}return{model:o,permissionKeys:s}}function TC(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 kC=10,PC="self-config-cache.json",Rd=5;function Nt(){return v("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function NC(){return v("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}var wC={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function MC(e,t=te){let n=wC[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(`
42
- `)[0]??"").trim();return a||r(o+1)};return r(0)}function vC(e=yd()){return Pt(e,".ev-ai","agent-hook",PC)}function LC(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
43
- `);return X(n)}function Hr(e,t,n=!1){let r=LC(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 Qs(e,t,n=[]){let r=0,o=!1,s=new Set;for(let i of[...t.map(a=>Pt(e,a)),...n]){let a=OC(i);if(s.has(a))continue;s.add(a);let c=Zr(i);c.present&&(o=!0,r+=c.size)}return o?{present:!0,size:r}:{present:!1,size:0}}function HC(e){return AC(e)?_e(bC(e,"utf8"),{}):{}}function UC(e,t){try{ae(e,`${JSON.stringify(t)}
44
- `)}catch(n){let r=n instanceof Error?n.message:String(n);x(`WARN: self-config cache write failed open: ${r}`)}}function DC(e,t,n){if(t==="user")return{components:_d(e.user_spec_components),textHashes:hd(e.user_spec_text_hashes)};if(!Xs(t))return{components:void 0,textHashes:[]};let r=Ed(e[Lr[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}function FC(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=Rd,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(!Xs(s.scope))continue;let i=Lr[s.scope],a=Sd(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]=Zs(a)}}return o}async function Cd(e,t=process.cwd(),n=yd(),r={}){let o=e==="claude",s=r.gitRoot??t,i=await MC(e),a="",c=[];if(o){let H=IC(n),m=Ur(Pt(n,".claude/settings.json")),b=Ur(Pt(t,".claude/settings.local.json"));a=H.model||b.model||m.model,c=TC([...H.permissionKeys,...m.permissionKeys,...b.permissionKeys]).slice(0,200)}let l={present:!1,size:0},u=H=>{let m=[],b=!1;for(let U of H){let fe=Ti(Pt(n,U));if(m=m.concat(fe.entries),b=b||fe.truncated,m.length>=ze){m=m.slice(0,ze),b=!0;break}}return{entries:m,truncated:b}},d=vC(n),f=HC(d),p=f[e]??{},g=(p.send_count??0)+1,S=g>0&&g%kC===0,C=H=>S?void 0:p[H],A=u(Xe.skills),I=u(Xe.subagents),P=u(Xe.commands),T=u(Xe.rules),k={skills:Hr(A.entries,C("skills"),A.truncated),subagents:Hr(I.entries,C("subagents"),I.truncated),commands:Hr(P.entries,C("commands"),P.truncated),rules:Hr(T.entries,C("rules"),T.truncated)},B={runner_platform:e,config_scope:"user",cli_version:i,claude_version:o?i:null,model:o&&a||null,permission_keys:c,user_scope:{skills:k.skills,subagents:k.subagents,commands:k.commands,rules:k.rules,memory:Qs(n,Xe.memory),settings:Qs(n,Xe.settings,Ga(n)),mcp:Qs(n,Xe.mcp)},local_settings:o?Zr(Pt(t,".claude/settings.local.json")):l},D=null,O=r.nowMs??Date.now();if(!Nt()){let H=p.user_spec_layout_version!==Rd,m=Bs(e,n,{launchCwd:NC()?void 0:r.launchCwd,gitRoot:s,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(m.scopes).length>0){let b=Ys({collected:m,cacheFor:(U,fe)=>H?{components:void 0,textHashes:[]}:DC(p,U,fe),nowMs:O});Object.assign(B,b.fields),D={hash:b.fields.user_spec_hash,home:b.scopes.find(U=>U.scope==="user")??null,project:b.scopes.filter(U=>U.scope!=="user")}}}let w=FC(p,k,g,D);return{config:B,commit:()=>{f[e]=w,UC(d,f)}}}import{homedir as sA}from"node:os";import{join as Od}from"node:path";function ft(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{join as Dr}from"node:path";function $C(e){return Dr(e,".ev-ai","agent-hook","js","signed-v1")}function jC(e){return Dr($C(e),"scopes")}function Ad(e,t){return Dr(jC(e),t)}function bd(e){return Dr(e,"attempts")}function ei(e){return String(e).padStart(10,"0")}var KC=/^(\d{10})$/,BC=/^(\d{10})\.done$/,GC=/^[0-9a-f]{128}$/,VC=64,kd=["check_ms","download_ms","install_ms","total_ms"],zC=36e5;async function Pd(e,t,n=!1){let r=bd(t),o=await Vi(e,r),s=new Map,i=new Map,a=xd(o,KC),c=xd(o,BC),l=async f=>{let p=await Td(e,Od(r,WC(f)));return p&&s.set(f,{record:YC(p.value),mtimeMs:p.mtimeMs}),p!==void 0},u=async f=>{let p=XC((await Td(e,Od(r,JC(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([Id(a,l),Id(c,u)]);let d=Sn(s);return d<Sn(i)&&c.includes(d)&&await u(d),{claims:s,dones:i}}function xd(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}async function Id(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}function Sn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}function Nd(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 wd(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of kd){let r=e[n];r!==void 0&&(t[n]=r)}return t}function WC(e){return ei(e)}function JC(e){return`${ei(e)}.done`}async function Td(e,t){let n;try{n=await e.stat(t)}catch(o){if(gt(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>to)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>to?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}function YC(e){if(!ft(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 XC(e){if(!ft(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=ZC(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...qC(t)}}function qC(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 kd){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=zC&&(t[n]=r)}return t}function ZC(e){if(!ft(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"&&GC.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&QC(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}function QC(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==VC||t.toString("base64")!==e))return t.toString("hex")}function rA(e){return e==="bootstrap"?3e3:6e4}function oA(e,t){let n=Sn(e.claims);if(n===0)return;let r=Sn(e.dones),o=e.claims.get(n),s=e.dones.get(n);if(o&&!s){let a=Nd(o),c=o.record==="empty"?void 0:o.record.owner,l=rA(c)+3e4;if(t-a>l)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:Md(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:Md(i.selection),...wd(i)}}async function vd(e,t,n){try{let r=await Pd(zi(),Ad(e,t),!0);return oA(r,n)}catch{return}}function Md(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}function iA(e=process.env){if(Object.values(_a).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===St?"npx":null}async function Ld(e=sA()){let t=Do()?.launcherScope;if(!t)return{};let n=await vd(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}function wt(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:Kn,event:e,timestamp:In(),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:fo,hook_delivery:iA(),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=Do();return s&&(o.launcher_version=s.launcherVersion,o.hook_source=s.hookSource,o.hook_fallback_reason=s.fallbackReason??null,o.launcher_scope_match=au(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 Fd}from"node:fs";import{spawn as $d}from"node:child_process";import{fileURLToPath as SA}from"node:url";import{gzipSync as aA}from"node:zlib";function ti(e){return v("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<ga?{body:e}:{body:aA(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}function Fr(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}import{readFileSync as cA,statSync as uA}from"node:fs";import{homedir as ri}from"node:os";import{join as lA}from"node:path";var fA="hook-config.json",dA=1440*60*1e3,pA=2048,mA=1024*1024;function Mt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Hd(e=ri()){return lA(me(e),fA)}function Ud(e){let t=Hd(e);try{let n=uA(t);if(!n.isFile()||n.size>mA)return;let r=JSON.parse(cA(t,"utf8"));return Mt(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}function gA(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 $r(e,t=ri()){if(!e)return;let n=Bt(e);if(!n)return;let r=Ud(t),o=r?r[n]:void 0;if(!(!Mt(o)||!Mt(o.config)))return gA(o.config)}function _A(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!Mt(n)||!Mt(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>pA))return n.hook_config}function hA(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(!(Mt(s)&&JSON.stringify(s.config)===JSON.stringify(n)&&typeof s.fetched_at_ms=="number"&&s.fetched_at_ms<=r&&r-s.fetched_at_ms<dA))return o[t]={config:n,fetched_at_ms:r},o}function Dd(e,t,n=ri(),r=Date.now()){let o=_A(e),s=t?Bt(t):void 0;if(o===void 0||!s)return"skipped";try{let i=Ud(n);if(i===void 0)return"skipped";let a=hA(i??{},s,o,r);return a?(ae(Hd(n),`${JSON.stringify(a,null,2)}
45
- `),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(i){let a=i instanceof Error?i.message:String(i);return x(`WARN: hook config write failed open: ${a}`),"failed"}}var oi="__post",En="__work";async function EA(e,t,n={}){if(Nt())return e;let r=await Xo(n.gitRoot??process.cwd(),te,process.env,{runnerPlatform:t,home:n.home}),o=ft(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 yA(e,t){let n=ft(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 jd(e){switch(e){case"session_start":return fa;case"session_end":return da;case"tool_invoked":case"skill_invoked":return uo;default:return uo}}function RA(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
46
- ${n}`}function Kd(e,t=[],n=process.execPath,r=import.meta.url,o=Fd){if(la(n))return{command:n,args:[e,...t]};let s=SA(r);return o(s)?{command:n,args:[s,e,...t]}:{command:n,args:[e,...t]}}function CA(e=process.execPath,t=import.meta.url,n=Fd){return Kd(oi,[],e,t,n)}function AA(e){let t=e.indexOf(`
47
- `);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 Bd(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();Dd(n,t)}catch{}}async function Gd(e,t=fetch){let n=await e(),r=AA(n);if(!r)return;let{meta:o,body:s}=r,i=ti(s),a=Fr(i.contentEncoding);try{let c=await t(o.url,{method:"POST",headers:a,body:i.body,signal:AbortSignal.timeout(Number(o.timeoutMs))});await Bd(c,o.url)}catch{}}async function bA(e,t,n,r=fetch){let o=jd(e),s=ti(t),i=Fr(s.contentEncoding),a=ni(s.body);x(`POST event=${e} url=${jn(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{}x(`POST gzip rejected http=${u.status} \u2014 retrying uncompressed`),u=await r(n,{method:"POST",headers:Fr(),body:t,signal:AbortSignal.timeout(o)})}let d=Date.now()-c;if(Bo(performance.now()-l),u.ok)return x(`POST outcome=ok elapsed_ms=${d} http=${u.status}`),await Bd(u,n),!0;let f=(await u.text()).slice(0,200).replace(/[\n\r]/g,"");return x(`POST outcome=fail elapsed_ms=${d} http=${u.status} body=${f}`),!1}catch(u){let d=Date.now()-c;Bo(performance.now()-l);let f=u instanceof Error?u.message:String(u);return x(`POST outcome=fail elapsed_ms=${d} http=000 body=${f}`),!1}}async function Vd(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){x(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`);try{s.stdin.destroy()}catch{}}a()},pa),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 x(`WARN: ${o} spawn failed open: ${i}`),null}}async function OA(e,t,n,r=$d,o=CA){let s=jd(e),i=RA(n,s,t),{command:a,args:c}=o();return Vd(a,c,i,r,"detached post")}async function zd(e,t,n=$d,r=Kd){let{command:o,args:s}=r(En,t);return Vd(o,s,e,n,"detached work")}async function vt(e,t,n,r,o,s,i){if(!o)return x("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),!1;if(!Fn(o))return x(`WARN: collector URL blocked (https required): ${jn(o)}`),!1;let a=performance.now(),c=await EA(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=Eu({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}
48
- `,g=v("EV_AI_HOOK_DEBUG");g==="full"?x(`DEBUG envelope=${f}`):g==="1"&&x(`DEBUG summary=${yA(u,ni(p))}`);let S=process.argv.includes(En),C=v("EV_AI_HOOK_SYNC")==="1";return rr(n.runnerEvent,n.runnerPlatform)||S||C?bA(e,p,o):(await OA(e,p,o),!1)}import{createReadStream as xA}from"node:fs";import{stat as IA}from"node:fs/promises";import{basename as TA,resolve as kA}from"node:path";import{createInterface as PA}from"node:readline";var NA=1024*1024;function wA(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&TA(t).endsWith(".jsonl")}async function Wd(e){if(!e||!wA(e))return null;try{let t=kA(e),n=await IA(t);if(!n.isFile())return null;let r=Math.max(0,n.size-NA),o=[],s=PA({input:xA(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}}var MA="EV_AI_HOOK_TELEMETRY";function Jd(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}function Yd(e,t,n=process.env){let r=n[MA]?.trim().toLowerCase();return r&&Dt.has(r)?{enabled:!0,source:"env"}:r&&bi.has(r)?{enabled:!1,source:"env"}:e!==void 0?{enabled:e,source:"local_config"}:t?.collect_telemetry!==void 0?{enabled:t.collect_telemetry,source:"org_config"}:{enabled:!0,source:"default"}}function jr(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:_r(e.manifest.manifest,e.manifest.hookConfig),telemetry:Zd(e)}}function Zd(e){return Yd(e.manifest.localTelemetry,e.manifest.hookConfig)}function Rn(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}function ii(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:rs(e.manifest.hookConfig)}}async function Qd(e){let t=Date.now();await VA(e);let{gitRoot:n}=e.manifest;await ci(e,n);let r=ii(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:Sr(e.hookInput,e.manifest.manifest,r),envelopeFields:jr(e),launchCwd:os(e.hookInput,r),home:LA()}}function Xd(e){try{return he(vA(e))}catch{return null}}function ep(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function qd(e,t){let n=e.replaceAll("\\","/");if(!ep(n))return null;let r=he(e),o=he(t),s=Xd(e)??r,i=Xd(t)??o;return s.startsWith(`${i}/`)?s.slice(i.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}function tp(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),s=qd(e,t)??(ep(r)?null:r),i=qd(e,n);return{repositorySourcePath:s,userSourcePath:i}}function si(e,t,n,r,o){return np(e,tp(n,t.gitRoot,t.home),r,o)}function np(e,{repositorySourcePath:t,userSourcePath:n},r,o){let s=t??n,i=s===null?null:o(s),a=i!==null&&s!==null?HA({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 HA(e){try{let t=e.inRepository?FA(e.platformAgentId,e.sourcePath):(0,K.installationRootExternalKey)(e.installationId,(0,K.userConfigRootFromPath)(e.sourcePath));return t?(0,K.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}function rp(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 ai(e,t,n){return vt("tool_invoked",{...n,...rp(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,wt,e.manifest.collectorUrl,t.buildStartedAtMs,Rn(e,t.home))}function UA(e){return Mc(e.runnerEvent,e.runnerPlatform)?[]:qa(e.hookInput)}function DA(e,t){return ai(e,t,{})}var op=new Set([...Object.values(st),".github"]);function FA(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=>op.has(i));return s<0?null:`${r}:${o.slice(0,s+1).join("/")}`}var sp=".codex/config.toml",$A=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",sp]]);function jA(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?$A.get(c.source):o==="codex"?sp:void 0,u=c?.sourcePath??l;if((c?.scope==="user"||l!==void 0)&&u)try{let S=(0,K.userConfigRootFromPath)(u);return(0,K.buildComponentReference)({installationRootExternalKey:(0,K.installationRootExternalKey)(r,S),installableKind:K.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||!op.has(g)))try{return(0,K.buildComponentReference)({installationRootExternalKey:n,installableKind:K.ComponentKind.INTERFACE,sourcePath:p,nativeKey:t})}catch{return}}function KA(...e){for(let t of e)if(t)return t;return null}function pt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return x(`WARN: ${n} failed open: ${r}`),t}function BA(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 GA(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var dt=new Set,yn=null;async function VA(e){if(Nt())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(dt.has(t))return;if(!Zo(n)){dt.add(t);return}let r=Ft({sessionId:e.sessionId,hostname:Pn()});if(Yu(r)){if(yn){await yn;return}yn=(async()=>{if(dt.has(t)||!Zo(n)){dt.add(t);return}if(!wa(n)){dt.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:i}=e.manifest,a=String(e.runnerPlatform),{operatorResolved:c,fields:l}=await ip(e,r,ke("git",()=>tr(i)),ke("operator",()=>qo({gitRoot:i,installationStorePath:n,forceResend:!1,runnerPlatform:a}))),u={...l,self_config:GA(a,c.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await vt("session_start",u,jr(e),wt,e.manifest.collectorUrl,s,Rn(e)),o&&(c.commit(),dt.add(t))}finally{Ma(n)}})().finally(()=>{yn=null}),await yn}}async function ci(e,t,n){try{e.platformAgentId=await Cc(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,n,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);x(`WARN: derivePlatformAgentId failed open: ${o}`)}}async function ip(e,t,n,r){let[o,s,i,a,c]=await Promise.allSettled([n,ke("virt",()=>wi()),ke("cloud",()=>Ru(t)),ke("host_env",()=>vi(Zd(e).enabled)),r]),l=pt(o,null,"gitSnapshot"),u=pt(s,"","detectVirt"),d=pt(i,null,"probeCloud"),f=pt(a,{},"hostEnv"),p=pt(c,{commit:()=>{}},"resolveOperatorForSend");return await ci(e,e.manifest.gitRoot,l),{operatorResolved:p,fields:{identity:{host:Pn(),context:t,virt:u||null,cloud:d,git:l},host_env:f,env_vars:Tu()}}}async function zA(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=Ft({sessionId:e.sessionId,hostname:Pn()}),o=String(e.runnerPlatform),s=ii(e),i=os(e.hookInput,s),a=ke("git",()=>tr(n)),c=Ld().catch(()=>({})),l=Nt()?Promise.resolve({commit:()=>{}}):ke("operator",()=>qo({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o})),u=ip(e,r,a,l),[d,f]=await Promise.allSettled([ke("mcp_declared",()=>Vo(e.manifest.manifest,n,o)),a.catch(()=>null).then(B=>ke("self_config",()=>Cd(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:i,inGitRepo:e.manifest.inGitRepo,remote:B?.remote??null})))]),{operatorResolved:p,fields:g}=await u,S=pt(d,[],"mcpDeclared"),C=pt(f,BA(o),"selfConfig"),A=C.config,I=L(e.hookInput,"model");I&&(A.model=I);let P={...g,mcp:{declared:S},self_config:A,run_meta:{trigger:e.hookSource||"startup"},hook_input:Sr(e.hookInput,e.manifest.manifest,{...s,launchCwd:i})},T=await c;await vt("session_start",P,{...jr(e),...T},wt,e.manifest.collectorUrl,t,Rn(e))&&(C.commit(),p.commit(),dt.add(e.manifest.installationId))}async function WA(e){let t=Date.now(),[,n]=await Promise.all([ci(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?Wd(L(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=KA(L(e.hookInput,"status"),L(e.hookInput,"stop_reason"),L(e.hookInput,"reason"),qt(L(e.hookInput,"error")),r==="stop"?He(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),s=Sr(e.hookInput,e.manifest.manifest,ii(e));n&&(s.model=n),r!=="stopfailure"&&_r(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&s.last_assistant_message===void 0&&(s.last_assistant_message=""),await vt("session_end",{status:o,...n?{model:n}:{},hook_input:s},jr(e),wt,e.manifest.collectorUrl,t,Rn(e))}async function JA(e){let t=UA(e),n=xc(e.hookInput),r=wc(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&_r(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let s=await Qd(e);await Promise.all([o?DA(e,s):void 0,t.length===0?void 0:YA(e,s,t),n.length===0?void 0:XA(e,s,n)])}function ap(e,t,n,r){let o=r??Xa({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),s=si(e,t,o,K.ComponentKind.SKILL,K.nativeKeyForSkillPath);if(s.sourcePath!==null&&So(s.sourcePath)?.toLowerCase()===n.toLowerCase())return s.componentReference===void 0?{}:{componentReference:s.componentReference};let i=r??Ic({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),a=si(e,t,i,K.ComponentKind.COMMAND,K.nativeKeyForCommandPath);return a.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:a.nativeKey,...a.componentReference===void 0?{}:{componentReference:a.componentReference}}}function YA(e,t,n){let r=Jn(e.hookInput.tool_input);return Promise.all(n.map(o=>{let s=ap(e,t,o,r);return ai(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 XA(e,t,n){return Promise.all(n.map(r=>{let o=Ac({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),s=si(e,t,o,K.ComponentKind.RULE,K.nativeKeyForRulePath),i=s.nativeKey??Oc(r);return ai(e,t,{tool_name:"Rule",rule_name:i,...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}var qA=[{kind:K.ComponentKind.SKILL,nativeKeyFn:K.nativeKeyForSkillPath},{kind:K.ComponentKind.RULE,nativeKeyFn:K.nativeKeyForRulePath},{kind:K.ComponentKind.COMMAND,nativeKeyFn:K.nativeKeyForCommandPath}];function ZA(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=yo(e.hookInput);if(r===null)return n.skillName===null?{}:ap(e,t,n.skillName,null);let o=tp(r,t.gitRoot,t.home);for(let s of qA){let i=np(e,o,s.kind,s.nativeKeyFn);if(i.nativeKey!==null)return{...i.componentReference===void 0?{}:{componentReference:i.componentReference},...s.kind===K.ComponentKind.RULE?{ruleName:i.nativeKey}:{},...s.kind===K.ComponentKind.COMMAND?{commandName:i.nativeKey}:{}}}return{}}var QA=/mcp/i;function eb(e,t,n,r){let o=QA.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let s=o?jf(t,n):Nr(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 tb(e){let t=await Qd(e),n=Hc(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,s=Eo(e.hookInput),i=Ff(s,t.home),a=Dc(e.hookInput),c=vc(e.runnerEvent),l=c===!1?Fc(e.hookInput,e.runnerEvent):null,u=qt(L(e.hookInput,"mcp_server_name")),d=u!==null||r!==null&&or(r)?await Vo(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(()=>[]):[],{mcpServer:f,mcpTool:p}=jc(r,d.map(B=>B.name),u??""),g=jA(r,f,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),d,u),S=g===void 0?ZA(e,t,n):{},C=f===null?null:Iu(f,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),A=eb(e,s,t.home,{hasMcpIdentity:!!f||!!p,declaredConfig:C}),I=g??S.componentReference,P=S.ruleName??n.ruleName,T=S.commandName??n.commandName,k=Uc(e.hookInput);await vt("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}:{},...A,...I?{component_reference:I}:{},...k?{subagent_type:k}:{},...rp(e),hook_input:t.hookInput},t.envelopeFields,wt,e.manifest.collectorUrl,t.buildStartedAtMs,Rn(e,t.home))}async function cp(e){switch(Fe("w3"),e.internalEvent){case"session_start":await zA(e);return;case"session_end":await WA(e);return;case"skill_invoked":await JA(e);return;case"tool_invoked":await tb(e);return;default:return}}import{existsSync as li,readFileSync as nb}from"node:fs";import{dirname as rb,isAbsolute as ob,join as sb,relative as ib}from"node:path";function up(e){for(let t of sa){let n=sb(e,t);if(li(n))return n}}async function ab(e=process.cwd(),t){let n=t??await qr(e);return up(n)??up(e)}async function cb(e,t){let n=t??await qr(rb(e)),r=ib(n,e);if(r.startsWith("..")||ob(r))return!1;let o=await ye("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(x(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}function ui(e){let t=nb(e,"utf8");return _e(kn(t),{})}function ub(){return{schema_version:Kn,mcp_servers:[]}}function lb(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(x(`WARN: ignoring capture_hook_input=full in git-tracked manifest ${t}; use EV_AI_HOOK_CAPTURE_FULL_INPUT=1 or an untracked operator manifest`),delete e.capture_hook_input),e.debug===!0&&r.has("debug")&&(x(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}function fb(){let e=ua(process.env);return e.problem&&x(`WARN: ignoring ${e.envName}: ${e.problem}`),e.url??""}async function lp(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await Xr(e),o=v("EV_AI_HOOK_MANIFEST"),s=o&&li(o)?o:void 0,i=s?void 0:li(ht())?ht():void 0,a=s?void 0:await ab(e,n),c=i?ui(i):void 0,l=a?ui(a):void 0,u=Jd(s?q(ht(),{}):c),d,f,p,g=new Set;if(s){d=ui(s),f=s,p=s;for(let T of Object.keys(d))g.add(T)}else if(c&&l){d=aa(l,c),f=i,p=a;for(let T of Object.keys(l))T in c||g.add(T)}else if(c)d=c,f=i;else if(l){d=l,f=a,p=a;for(let T of Object.keys(l))g.add(T)}else d=ub();delete d.installation_id;let S=p?await cb(p,n):!1;lb(d,p,S,g);let{installationId:C,storePath:A,repoKey:I}=await Ua(n,{sessionId:t.sessionId}),P=co(d)||fb();return{manifestPath:f??A,manifest:d,installationId:C,installationStorePath:A,repoKey:I,collectorUrl:P,hookConfig:$r(P),...u!==void 0?{localTelemetry:u}:{},platformAgentId:d.platform_agent_id??"",gitRoot:n,inGitRepo:r}}import{mkdirSync as db,readdirSync as pb,readFileSync as mb,statSync as fp,unlinkSync as gb,writeFileSync as _b}from"node:fs";import{homedir as Kr}from"node:os";import{join as fi}from"node:path";var hb="turns",dp=1440*60*1e3,Sb=100,Eb=new Set(["stop","stopfailure","sessionend"]);function di(e=Kr()){return fi(me(e),hb)}function pp(e,t){return fi(e,Ut(t))}function yb(e,t=Date.now()){let n;try{n=pb(e)}catch{return}let r=0;for(let o of n){if(r>=Sb)return;r+=1;try{let s=fi(e,o);t-fp(s).mtimeMs>dp&&gb(s)}catch{}}}function Rb(e,t,n=Kr()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let s=di(n);db(s,{recursive:!0}),_b(pp(s,r),o,"utf8")}catch{}}function Cb(e,t=Kr()){let n=e.trim();if(!n)return"";try{let r=pp(di(t),n);return Date.now()-fp(r).mtimeMs>dp?"":mb(r,"utf8").trim()}catch{return""}}function mp(e,t,n,r=Kr()){let o=t.trim(),s=Eb.has(n.trim().toLowerCase());return s&&yb(di(r)),o?(Rb(e,o,r),o):s?Cb(e,r):""}async function Ab(e,t,n,r){let o=t??await Tn(Bn),s=_e(o,{}),i=await lp(process.cwd(),{sessionId:Xt(s)});if(Fe("w2"),!i)return;r&&(i.collectorUrl=r,i.hookConfig=$r(r));let a=Lc(s,i.manifest.platform,n),c=Po(e,a.runnerEvent);if(!c){x(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`);return}let l={hookInput:s,sessionId:a.sessionId,turnId:mp(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await cp(l)}function bb(e,t=!1){if(v("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,s=Yt(r,o,void 0,n.runner);return rr(o,s)?!0:t}function gp(e,t){let n=so(e),r=_e(t,{}),o=n.event??ko(r);return Pi()||Nc(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}function hp(e){return Qc(Po(e.parsed.event,e.runnerEvent))}async function _p(e,t,n){let{parsed:r}=e,o=n??Ho(r.slot);if(!o&&!hp(e)){let s=Lo(r.cap),i=su(s);if(!i){Uo(s);return}o=i}try{await Ab(r.event,t,r.runner,kc(r))}finally{o&&ar(o)}}async function Br(e=process.argv.slice(2)){if(fu(),Fe(e[0]===En?"w0":"h0"),iu(),v("EV_AI_HOOK_JUDGE")==="1"){try{await Tn(Bn)}catch{}return Jr(),0}if(e[0]===oi){try{await Gd(Yr)}catch{}return 0}if(e[0]===En){try{let n=await Yr();Fe("w1");let r=gp(e.slice(1),n);if(!r)return 0;await _p(r,n)}catch(n){let r=n instanceof Error?n.message:String(n);x(`WARN: detached work failed open: ${r}`)}return 0}let t;try{let n=await Tn(Bn);Fe("h1");let r=gp(e,n);if(!r)return 0;let{parsed:o,hookInput:s,runnerEvent:i}=r;if(t=Ho(o.slot),!zc(s,i,o.runner))return 0;if(Fe("h2"),bb(r))await _p(r,n,t);else{let a=t||hp(r)?void 0:Lo(o.cap);if(a===void 0||ru(a)){Fe("h3"),hu();let c=await zd(n,e);t&&c?.pid!==void 0&&tu(t,c.pid)}else Uo(a)}}catch(n){let r=n instanceof Error?n.message:String(n);x(`WARN: hook failed open: ${r}`)}finally{t&&ar(t),Jr()}return 0}var Ob=Symbol.for(ji);function Sp(){return globalThis[Ob]===!0}async function xb(e){Wr(e);try{return await Br(e.argv)}finally{Wr(void 0)}}Sp()||Br().then(e=>{process.exit(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);process.stderr.write(`[ev-ai-agent-hook] ${t}
49
- `),process.exit(1)});export{xb as runInLauncher};
35
+ `.trim(),As=new Map;function Pl(e){if(typeof e=="string"){let t=e.trim();return t.length>0?t:null}if(e instanceof Uint8Array){let t=Buffer.from(e).toString("utf8").trim();return t.length>0?t:null}return null}s(Pl,"asText");function wl(e){return e.toLowerCase().includes("token")}s(wl,"isTokenKey");function Ll(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=Pl(r.key),i=Pl(r.value);o&&i&&!wl(o)&&t.set(o,i)}return t}s(Ll,"rowsToMap");function by(e){let t=Cy(e);return t.search="mode=ro&immutable=1",t.href}s(by,"sqliteReadonlyUri");function Oy(e){try{let t=Nl("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(Ur)??n.prepare(Ur);return Ll(r.all?.())}finally{n.close?.()}}catch{return null}}s(Oy,"readViaBunSqlite");function xy(e){let t=process.emitWarning.bind(process);process.emitWarning=((n,...r)=>{(typeof n=="string"?n:n instanceof Error?n.message:"").includes("SQLite is an experimental feature")||t(n,...r)});try{return e()}finally{process.emitWarning=t}}s(xy,"withSqliteExperimentalWarningSuppressed");function Iy(e){try{return xy(()=>{let t=Nl("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return Ll(n.prepare(Ur).all?.())}finally{n.close?.()}})}catch{return null}}s(Iy,"readViaNodeSqlite");function ky(e){let t=new Map;for(let n of e.split(`
36
+ `)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let i=r.slice(0,o).trim(),a=r.slice(o+1).trim();i&&a&&!wl(i)&&t.set(i,a)}return t}s(ky,"parseCliTable");function Ty(e){try{let t=yy("sqlite3",["-noheader","-batch","-separator"," ",e,Ur],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return ky(t)}catch{return null}}s(Ty,"readViaSqliteCli");function Ml(e){let t=As.get(e);if(t)return t;if(!Ry(e)){let o=new Map;return As.set(e,o),o}let n=by(e),r=Oy(n)??Ty(n)??Iy(n)??new Map;return As.set(e,r),r}s(Ml,"readCursorAuthItems");var Py="cursorAuth/cachedEmail",Ny="cursorAuth/stripeMembershipAuthId";function Hr(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(Hr,"trimEnv");function wy(e=Dr(),t=process.platform,n=process.env){let r=Hr(n.VSCODE_PORTABLE);if(r)return We(r,"user-data");let o=Hr(n.VSCODE_APPDATA);if(o)return We(o,"Cursor");switch(t){case"darwin":return We(e,"Library","Application Support","Cursor");case"win32":return We(Hr(n.APPDATA)??We(e,"AppData","Roaming"),"Cursor");default:return We(Hr(n.XDG_CONFIG_HOME)??We(e,".config"),"Cursor")}}s(wy,"cursorUserDataDir");function Ly(e=Dr()){return We(e,".cursor","cli-config.json")}s(Ly,"cursorCliConfigPath");function My(e=Dr(),t=process.platform,n=process.env){return We(wy(e,t,n),"User","globalStorage","state.vscdb")}s(My,"cursorIdeStateDbPath");function On(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(On,"trimString");function vy(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):On(e.userId)}s(vy,"numericUserId");function Uy(e){return On(e.email)??On(e.authId)??vy(e)}s(Uy,"platformLogin");function Cs(e){let t=On(e.email),n=On(e.displayName),r=Uy(e);return!r||Se(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}s(Cs,"identityFromAuth");function Hy(e){let n=Z(Ly(e),{}).authInfo;return!n||typeof n!="object"?null:Cs(n)}s(Hy,"readCliOperatorIdentity");function Dy(e,t,n){let r=My(e,process.platform,t),o=xl(e),i=Il(o);if(kl(i,r,n))return Cs({email:i?.email,authId:i?.auth_id});let a=Ml(r),c=a.get(Py)??null,u=a.get(Ny)??null;return Tl(o,{read_at_ms:n,db_path:r,email:c,auth_id:u}),Cs({email:c,authId:u})}s(Dy,"readIdeOperatorIdentity");function vl(e=Dr(),t=process.env,n=Date.now()){return Hy(e)??Dy(e,t,n)}s(vl,"readCursorOperatorIdentity");import{createHash as Fy}from"node:crypto";import{resolve as $y}from"node:path";function ee(e){return Fy("sha256").update(e).digest("hex").slice(0,16)}s(ee,"sha16");function bs(e){return ee($y(e))}s(bs,"dirScopeRef");function Ce(e,t){return`${e}\0${t}`}s(Ce,"componentKey");function Fr(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}s(Fr,"componentDeltaHash");function Ul(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}s(Ul,"parseComponentKey");function xn(e){let n=[...e].sort((r,o)=>{let i=r.path.localeCompare(o.path);return i!==0?i:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
37
+ `);return ee(n)}s(xn,"hashUserSpec");function By(e,t,n="git_config",r=null){return ee(`${e??""}|${t??""}|${r??""}|${n}`)}s(By,"hashOperatorIdentity");function Ky(e){let t=null,n=null;for(let r of e.split(`
38
+ `)){let o=r.trim();if(!o)continue;let i=o.indexOf(" ");if(i<=0)continue;let a=o.slice(0,i).toLowerCase(),c=o.slice(i+1).trim();c&&(a==="user.name"?t=c:a==="user.email"&&(n=c))}return{git_user_name:t,git_user_email:n,platform_login:null}}s(Ky,"parseGitUserConfig");async function Gy(e,t=oe){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return Ky(n)}s(Gy,"readGitOperatorIdentity");function Vy(e=process.env){let t=G(e.GIT_AUTHOR_NAME),n=G(e.GIT_AUTHOR_EMAIL);if(t||n)return{git_user_name:t,git_user_email:n,platform_login:null,identity_source:"git_env"};let r=G(e.GIT_COMMITTER_NAME),o=G(e.GIT_COMMITTER_EMAIL);if(r||o)return{git_user_name:r,git_user_email:o,platform_login:null,identity_source:"git_env"};let i=G(e.EMAIL);return i?{git_user_name:null,git_user_email:i,platform_login:null,identity_source:"git_env"}:null}s(Vy,"readGitEnvOperatorIdentity");function Je(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}s(Je,"actorIdentity");function zy(e=process.env){let t=G(e.EV_AI_HOOK_OPERATOR_EMAIL),n=G(e.EV_AI_HOOK_OPERATOR_LOGIN),r=Je(G(e.EV_AI_HOOK_OPERATOR_NAME),t,"configured",t??n);if(r)return r;let o=G(e.GITHUB_ACTOR)??G(e.GITHUB_TRIGGERING_ACTOR)??G(e.GITHUB_USER),i=Je(o,null,"github",o);if(i)return i;let a=G(e.GITLAB_USER_LOGIN),c=G(e.GITLAB_USER_EMAIL),u=Je(G(e.GITLAB_USER_NAME)??a,c,"gitlab",c??a);if(u)return u;let f=G(e.BUILD_REQUESTEDFOREMAIL),l=Je(G(e.BUILD_REQUESTEDFOR),f,"azure_devops",f??G(e.BUILD_REQUESTEDFORID));if(l)return l;let p=G(e.BUILDKITE_BUILD_CREATOR_EMAIL),d=Je(G(e.BUILDKITE_BUILD_CREATOR),p,"buildkite",p);if(d)return d;let m=G(e.BUILD_USER_EMAIL)??G(e.CHANGE_AUTHOR_EMAIL),_=Je(G(e.BUILD_USER)??G(e.CHANGE_AUTHOR),m,"jenkins",m??G(e.BUILD_USER_ID));if(_)return _;let E=G(e.CIRCLE_USERNAME),C=Je(E,null,"circleci",E);if(C)return C;let b=G(e.CODEBUILD_INITIATOR),k=Je(b,null,"codebuild",b);if(k)return k;let w=G(e.DRONE_COMMIT_AUTHOR_EMAIL),N=G(e.DRONE_COMMIT_AUTHOR),I=Je(N??G(e.DRONE_COMMIT_AUTHOR_NAME),w,"drone",w??N);if(I)return I;if(Hl(e.CLAUDE_CODE_REMOTE)||Hl(e.CURSOR_AGENT)){let $=G(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:$&&!Se(null,$)?$:null,identity_source:"cloud"}}return null}s(zy,"readCloudOperatorIdentity");function Os(e){return!!((e.git_user_name??e.git_user_email)&&!Se(e.git_user_name,e.git_user_email))}s(Os,"isHumanOperator");function G(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(G,"trimEnv");function Hl(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(Hl,"isTruthyEnv");function Wy(e,t,n){return e==="claude"?El(t):e==="cursor"?vl(t,n):e==="codex"?bl(n,t):null}s(Wy,"readRunnerOperatorIdentity");async function xs(e,t=oe,n=process.env,r={}){let o=await Gy(e,t),i=Vy(n),a=Os(o)?o:i&&Os(i)?i:null,c=Wy(r.runnerPlatform,r.home??jy(),n);if(c)return{git_user_name:a?.git_user_name??null,git_user_email:a?.git_user_email??null,platform_login:c.platform_login,identity_source:c.identity_source};let u=zy(n);return u?.platform_login?{git_user_name:a?.git_user_name??null,git_user_email:a?.git_user_email??null,platform_login:u.platform_login,identity_source:u.identity_source}:a?{...a,platform_login:null,identity_source:Os(o)?"git_config":"git_env"}:u||(o.git_user_name||o.git_user_email?{...o,identity_source:"git_config"}:i||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}s(xs,"resolveOperatorIdentity");async function Is(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??oe,i=e.env??process.env,a=await xs(t,o,i,{runnerPlatform:e.runnerPlatform,home:e.home}),c=By(a.git_user_name,a.git_user_email,a.identity_source,a.platform_login),f=(n?Yo(n):void 0)?.operator_identity_hash;if(!(r||f!==void 0&&f!==c||!f))return{commit:s(()=>{},"commit")};let m=n;return{operator:a,commit:s(()=>{m&&kc(m,c,Jn())},"commit")}}s(Is,"resolveOperatorForSend");function ks(e){return e?!Yo(e)?.operator_identity_hash:!0}s(ks,"operatorIdentityNeverSent");function Dl(e){return!0}s(Dl,"shouldBootstrapCloudIdentity");import{existsSync as ub,readFileSync as lb}from"node:fs";import{homedir as up}from"node:os";import{join as qt,resolve as fb}from"node:path";import{basename as tb,join as Xt}from"node:path";import{dirname as Jl,resolve as Kr}from"node:path";import{existsSync as Jy}from"node:fs";import{homedir as jl}from"node:os";import{relative as Bl,resolve as Ue,sep as ut}from"node:path";var Yy=["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"],Xy=["prompt","tool_input","tool_response","last_assistant_message","command"],qy=new Set;function Zy(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return qy}}s(Zy,"excludedContentKeys");function Ls(e){let t=D("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?ft.has(t.toLowerCase()):e?.collect_prompt===!0}s(Ls,"isPromptCaptureEnabled");function $r(e,t){let n=Kl(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=D("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?ft.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}s($r,"promptCaptureSource");function Kl(e){return D("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||Bo(process.argv,e.debug===!0)||D("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}s(Kl,"hookInputCaptureMode");function Qy(e){let t={};for(let n of Yy){let r=Be(e,n);r!==void 0&&(t[n]=r)}return t}s(Qy,"allowlistedHookInput");function jr(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Ue(e),r=Ue(t),o=Bl(r,n);return!o||o==="."?".":o.startsWith(`..${ut}`)||o===".."||Ue(r,o)!==n?null:o.split(ut).join("/")}s(jr,"cwdRelativeToGitRoot");function Gl(e,t){let n=Bl(Ue(t),Ue(e)).split(ut).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}s(Gl,"specDirRelativeToCwd");function Vl(e){return typeof e!="string"||e.length===0?null:Ue(e).split(ut).join("/")}s(Vl,"absoluteCwdForSend");function eR(){let e=D("CURSOR_PROJECT_DIR");if(!e)return null;let t=Ue(e);return Jy(t)?t.split(ut).join("/"):null}s(eR,"cursorProjectDirAbs");function Ps(e,t){return jr(e,t)!==null}s(Ps,"isPathInside");function tR(e,t){let n=Ue(t??jl(),".cursor").split(ut).join("/");return Ps(e,n)}s(tR,"isCursorUserHookLaunch");function nR(e,t,n){return t!==null&&Ps(e,t)?!0:t!==null&&tR(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&Ps(e,n.gitRoot)?!0:t===null}s(nR,"shouldKeepProcessCwd");function zl(e,t){let n=Vl(e.cwd);if(n!==null)return n;let r=Ue(process.cwd()).split(ut).join("/"),o=eR();return nR(r,o,t)?r:o??r}s(zl,"resolvedCwdForSend");function Ms(e,t={}){return zl(e,t)}s(Ms,"resolveLaunchCwd");function vs(e,t=jl()){let n=Ue(t).split(ut).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}s(vs,"tildeHomeCwd");function Fl(e,t,n){let r=Vl(n.launchCwd)??zl(t,n);e.cwd=vs(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?jr(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}s(Fl,"attachCwdFields");var Wl="\u2026[truncated]\u2026",Ns=Buffer.byteLength(Wl,"utf8"),rR=8;function In(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(In,"jsonByteLength");function $l(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}s($l,"utf8Head");function oR(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}s(oR,"utf8Tail");function sR(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=Ns)return $l(e,t);let r=t-Ns,o=Math.ceil(r/2),i=Math.floor(r/2);return`${$l(e,o)}${Wl}${oR(e,i)}`}s(sR,"truncateHeadTail");function ws(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)=>{ws(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||ws(o,[...t,r],n)}s(ws,"collectStrings");function iR(e,t,n){let r=e;for(let i=0;i<t.length-1;i++){let a=t[i];if(a===void 0)return;r=(Array.isArray(r),r[a])}let o=t[t.length-1];if(!(o===void 0||r===null||typeof r!="object")){if(Array.isArray(r)){r[o]=n;return}r[o]=n}}s(iR,"setAtPath");var aR=256;function cR(e,t,n){let r=n,o=Math.max(n,e[0]?.bytes??n);for(;r<o;){let i=Math.ceil((r+o)/2),a=0;for(let c of e)c.bytes>i&&(a+=c.bytes-i);a>=t?r=i:o=i-1}return r}s(cR,"stringBudgetFor");function uR(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let i=In(e);if(i<=t)return;let a=[];ws(e,[],a),a.sort((l,p)=>p.bytes-l.bytes);let c=a.filter(l=>l.bytes>n);if(c.length===0)return;let u=cR(c,i-t,n),f=Math.max(n,Math.min(u,r-1));if(f>=r)return;r=f;for(let l of c)l.bytes>r&&iR(e,l.path,sR(l.value,r))}}s(uR,"clampStringsToBudget");function lR(e,t){let n=Math.max(0,t-aR),r=Object.keys(e).filter(i=>!i.startsWith("_")).map(i=>({key:i,bytes:In(e[i])})).sort((i,a)=>a.bytes-i.bytes),o=[];for(let{key:i}of r){if(In(e)<=n)break;delete e[i],o.push(i)}o.length>0&&(e._dropped_keys=o.slice(0,10))}s(lR,"dropLargestKeys");function Ts(e,t){let n=In(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,uR(r,t,Ns+rR),In(r)>t&&lR(r,t),r}s(Ts,"fitWithinByteLimit");function fR(e,t,n){if(!(n.promptCapture??Ls()))return;let r=Zy(n.runnerEvent);for(let o of Xy){if(r.has(o))continue;let i=t[o];i!==void 0&&(e[o]=i)}}s(fR,"attachContentFields");function Br(e,t,n={}){let r=Kl(t);if(r==="full"){let i={...e};return delete i.cwd,delete i.transcript_path,Fl(i,e,n),Ts(i,vo)}let o=Qy(e);return Fl(o,e,n),r==="content"?(fR(o,e,n),Ts(o,vo)):Ts(o,Ga)}s(Br,"sanitizeHookInput");function dR(e){return typeof e=="string"&&e.length>0}s(dR,"hasOrigin");function Us(e){let t=Kr(e.home),n=Kr(e.launchCwd),r=e.gitRoot?Kr(e.gitRoot):null,o=new Set,i=[],a=null;e.inGitRepo&&dR(e.remote)&&r!==null&&r!==t&&(a=r,o.add(r)),n!==t&&!o.has(n)&&(i.push({scope:"cwd",dir:n}),o.add(n)),a!==null&&i.push({scope:"repo",dir:a});let c=null,u=r!==null&&jr(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&u){let f=Jl(r);for(;;){let l=Kr(f);if(l===t)break;let p=Jl(l);if(p===l)break;if(e.hasProjectSpec(l)){i.push({scope:"parent",dir:l}),c=Gl(l,n);break}f=p}}return{anchors:i,parentRel:c}}s(Us,"resolveProjectAnchors");import{existsSync as Yl,readdirSync as pR,realpathSync as mR}from"node:fs";import{basename as gR,dirname as _R,relative as hR,resolve as SR,sep as ER}from"node:path";var Hs=400,Gr=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??Qe}static{s(this,"UserSpecContext")}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=SR(t).split(ER).join("/");return vs(r,this.home)}let n=hR(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${ee(_R(t))}/${gR(t)}`:n}claimFile(t){try{let n=mR(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(!Yl(t))return[];try{return pR(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(Yl(t))return Z(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),i=t-(this.pluginExpandRemaining??0);return{result:o,expanded:i}}finally{this.pluginExpandRemaining=r}}};import{existsSync as ti,readFileSync as BA,statSync as KA}from"node:fs";import{basename as fd,join as Ct,relative as ni}from"node:path";var ad=Ze(id());var $A=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],cd=$A.map(e=>ad.default.matcher(e,{dot:!0}));function jA(e){return e===""?!1:cd.some(t=>t(`${e}/`))}s(jA,"isExcludedDirPath");function ud(e,t){if(t==="")return!1;if(e==="")return jA(t);let n=e.replace(/\/+$/,"");return cd.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}s(ud,"isExcludedDirBelow");var ri=100*1024,GA=4;function VA(e){return e.length<=ri?e:`${e.slice(0,ri-1)}\u2026`}s(VA,"truncateContentText");function zA(e){try{let t=BA(e),n=t.toString("utf8");return{hash:ee(t),length:t.length,text:VA(n)}}catch{return null}}s(zA,"readFileMeta");var ld={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function WA(e){return e in ld?ld[e]:"UNSPECIFIED"}s(WA,"triggerForKind");function Jt(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=zA(t.absolutePath);if(!n)return!1;let r=t.name??fd(t.absolutePath).replace(/\.(md|mdc|toml)$/i,""),o={kind:t.kind,name:r,path:e.componentPath(t.absolutePath),text:n.text,content_hash:n.hash,content_length:n.length,origin:t.origin,enabled:t.enabled},i=WA(t.kind);return i&&(o.trigger=i),t.attributes&&(o.attributes=t.attributes),e.push(o)}s(Jt,"addFile");function JA(e,t,n){let r=ni(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?fd(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}s(JA,"nameFromWalkRoot");function bt(e,t){let{dir:n,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u}=t;oi(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u})}s(bt,"walkComponentDir");function oi(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l}=t;if(!(o>GA))for(let p of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(p.isDirectory()&&ud(n.replace(/\\/g,"/"),ni(n,Ct(r,p.name)).replace(/\\/g,"/"))||p.isDirectory()&&l?.includes(Ct(r,p.name)))continue;if(u){if(!p.isDirectory())continue;let _=Ct(r,p.name,u);if(ti(_)){let E=ni(n,Ct(r,p.name)).replace(/\\/g,"/");Jt(e,{absolutePath:_,kind:i,origin:a,enabled:c,name:E||p.name});continue}oi(e,{walkRoot:n,currentDir:Ct(r,p.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(p.isDirectory()){oi(e,{walkRoot:n,currentDir:Ct(r,p.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(!p.isFile()||!f)continue;let d=p.name.toLowerCase();if(!f.some(_=>d.endsWith(_)))continue;let m=Ct(r,p.name);Jt(e,{absolutePath:m,kind:i,origin:a,enabled:c,name:JA(n,m,!0)})}}s(oi,"walkRecursive");function dd(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))}s(dd,"firstExistingFile");import{existsSync as bC,readFileSync as OC}from"node:fs";var qr=Ze(ct(),1);var YA="<omitted>",XA=["package_name","package_spec","package_version","package_version_source"],pd=100,md=120,Zr=[{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"}],gd=new Set(Zr.map(e=>e.attr)),qA=["enabled","disabled"],ZA=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],QA=new Set(["type","command","url","args","env","envVars","headers",...qA,...ZA,...Zr.map(e=>e.raw)]),eC=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",...XA,...gd,...[...gd].map(e=>`${e}_truncated`)]);function _d(e,t){for(let n of t)QA.has(n)||eC.has(n)||(e[n]=YA)}s(_d,"addOmittedKeys");var tC=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,nC=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,rC=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,oC=/^bearer(?:\s+|$)/i;function Qr(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}s(Qr,"asRecord");function hd(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}s(hd,"stringList");function si(e){if(Array.isArray(e)){let n=[];for(let r of e){if(typeof r!="string"||r.length===0)continue;let o=r.split("=",1)[0]?.trim();o&&n.push(o)}return n}let t=Qr(e);return t?Object.keys(t).filter(n=>n.length>0):[]}s(si,"envNamesFromValue");function Ot(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}s(Ot,"redactCommandOrUrl");function sC(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,qr.launchContainsCredentials)({kind:"url",url:e})||(0,qr.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,qr.launchContainsCredentials)({kind:"url",url:r}):!0)}s(sC,"rawLaunchHadCredentials");function Sd(e,t,n){sC(t,n)&&(e.launch_had_credentials=!0)}s(Sd,"markLaunchCredentials");function iC(e){return rC.test(e)||oC.test(e)?"<redacted>":e.includes("://")?Ot(e):e}s(iC,"redactSecretShapedValue");function Ed(e){if(/^https?:\/\//i.test(e))return Ot(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Ed(e.slice(t+1))}`:iC(e)}s(Ed,"redactArg");function aC(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return tC.test(t)||nC.test(t)}s(aC,"authArgKey");function Mn(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(aC(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Ed(r))}return t}s(Mn,"redactArgs");function cC(e){let t=hd(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>md?r.slice(0,md):r))].sort();if(n.length!==0)return n.length>pd?{names:n.slice(0,pd),truncated:!0}:{names:n,truncated:!1}}s(cC,"toolNameList");function uC(e){let t=Qr(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,i]of Object.entries(t))o.length>0&&n.push(o),typeof i=="string"&&i.length>0&&r.push(i);return{headers:n,envVars:r}}s(uC,"envHeaderNames");function yd(e,t){let n=new Set;for(let{raw:r,attr:o}of Zr){if(n.has(o)||!(r in t))continue;let i=t[r];if(o==="auto_approve"&&typeof i=="boolean"){e.auto_approve=i,n.add(o);continue}let a=cC(i);a&&(e[o]=a.names,a.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}s(yd,"applyToolListAttributes");function Rd(e,t){let n=Qr(e),r={transport:t};if(!n)return r;_d(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,i=typeof n.url=="string"?n.url:void 0,a=typeof n.serverUrl=="string"?n.serverUrl:void 0,c=o??i??a,u=hd(n.args);c&&(r.command_or_url=Ot(c));let f=Mn(u);f.length>0&&(r.args=f),Sd(r,c,u);let l=uC(n.env_http_headers),p=[...new Set([...si(n.env),...si(n.envVars),...si(n.env_vars),...l.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();p.length>0&&(r.env_var_names=p),l.headers.length>0&&(r.env_http_header_names=[...new Set(l.headers)].sort());for(let E of["headers","http_headers","env_http_headers"])if(n[E]!==void 0&&n[E]!==null){r.headers_present=!0;break}let d=typeof n.auth=="string"?n.auth:void 0;d&&(r.auth=d);let m=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;m&&(r.bearer_token_env_var=m);let _=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return _&&(r.default_tools_approval_mode=_),yd(r,n),r}s(Rd,"sanitizeMcpServerAttributes");function Ad(e){let t=Qr(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}s(Ad,"mcpServerEnabledFromJson");function ci(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return ee(JSON.stringify({name:e,attributes:r,enabled:n}))}s(ci,"hashSanitizedMcpAttributes");function Yt(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}s(Yt,"parseTomlQuoted");function Ln(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*\\[([^\\]]*)\\]`,"m").exec(e);return n?.[1]?[...n[1].matchAll(/"([^"]*)"|'([^']*)'/g)].map(r=>r[1]??r[2]??"").filter(r=>r.length>0):[]}s(Ln,"parseTomlPlainStringArray");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"}s(ai,"parseTomlBoolean");function ii(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=Yt(n[1]);return r.length>0?r:void 0}s(ii,"parseTomlScalarString");function lC(e,t){let n=[],r=s(a=>{for(let c of a.split(/[,\n]/)){let u=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(c);u?.[1]&&n.push([u[1],Yt(u[2]??"")])}},"collect"),o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let i=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
39
+ ${e}`);return i?.[1]&&r(i[1]),n}s(lC,"parseTomlMap");function Cd(e){return ai(e,"enabled")===!1?!1:ai(e,"disabled")!==!0}s(Cd,"mcpServerEnabledFromToml");function fC(e,t){let n={};for(let{raw:r,attr:o}of Zr){if(o==="auto_approve"){let a=ai(t,r);if(a!==void 0){n[r]=a;continue}}let i=Ln(t,r);i.length>0&&(n[r]=i)}yd(e,n)}s(fC,"applyToolListsFromToml");var dC=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,pC=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function mC(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
40
+ `)){let i=dC.exec(o);i?.[1]&&t.add(i[1])}for(let o of e.matchAll(pC))o[1]&&t.add(o[1]);return[...t]}s(mC,"tomlDeclaredKeys");function bd(e,t){let n={transport:t};_d(n,mC(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),i=r?Yt(r[1]??""):void 0,a=o?Yt(o[1]??""):void 0,c=i!==void 0&&i.length>0?i:a,u=Ln(e,"args");c&&(n.command_or_url=Ot(c));let f=Mn(u);f.length>0&&(n.args=f),Sd(n,c,u);let l=new Set;for(let b of e.split(`
41
+ `)){let k=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);k?.[1]&&l.add(k[1])}let p=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(p?.[1])for(let b of p[1].split(",")){let k=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);k?.[1]&&l.add(k[1])}let d=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
42
+ ${e}`);if(d?.[1])for(let b of d[1].split(`
43
+ `)){let k=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);k?.[1]&&l.add(k[1])}for(let b of Ln(e,"env_vars"))l.add(b);let m=lC(e,"env_http_headers");for(let[,b]of m)b.length>0&&l.add(b);let _=ii(e,"bearer_token_env_var");_&&(l.add(_),n.bearer_token_env_var=_),l.size>0&&(n.env_var_names=[...l].sort()),m.length>0&&(n.env_http_header_names=[...new Set(m.map(([b])=>b))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let E=ii(e,"auth");E&&(n.auth=E);let C=ii(e,"default_tools_approval_mode");return C&&(n.default_tools_approval_mode=C),fC(n,e),n}s(bd,"parseTomlMcpSection");var Fe=Ze(ct(),1);import{createHash as SC}from"node:crypto";import{join as vn}from"node:path";var gC=300,_C=256;function Od(e,t){if(!t)return e;let n=[...new Set([t,t.replace(/\\/g,"/")])].filter(o=>o.length>1),r=e;for(let o of n)r=r.split(o).join("~");return r}s(Od,"rewriteHomePrefix");function eo(e){let t=[],n="",r=null;for(let o of e){if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(/\s/.test(o)){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}s(eo,"tokenizeCommand");function xd(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}s(xd,"capLength");function hC(e){return xd(e,gC)}s(hC,"capCommand");function Id(e,t){let n=Od(e.trim(),t),r=eo(n);if(r.length===0)return"";let[o,...i]=r,a=Ot(o),c=Mn(i);return hC([a,...c].join(" "))}s(Id,"sanitizeHookCommand");function kd(e,t){if(typeof e!="string")return null;let n=Od(e.trim(),t),r=eo(n)[0];if(!r)return null;let o=Ot(r);return o.length===0?null:xd(o,_C)}s(kd,"executableFromCommand");function EC(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,Fe.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}s(EC,"packageVersionFields");function yC(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
44
+ `);return SC("sha512").update(t).digest("hex").slice(0,16)}s(yC,"npxCacheKey");function RC(e){let t=process.platform==="win32"?vn(D("LOCALAPPDATA")??e,"npm-cache"):vn(e,".npm"),n=D("npm_config_cache")??D("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}s(RC,"npmCacheRoots");function Td(e){return typeof e=="string"&&e.length>0&&e.length<=Fe.PACKAGE_FIELD_MAX?e:null}s(Td,"usableVersion");function AC(e,t,n){let r=yC(e);for(let o of RC(n)){let i=vn(o,"_npx",r),a=Z(vn(i,"node_modules",...t.split("/"),"package.json"),{}),c=Td(a.version);if(c!==null)return c;let u=Z(vn(i,"package-lock.json"),{}),f=Td(u.packages?.[`node_modules/${t}`]?.version);if(f!==null)return f}return null}s(AC,"installedVersion");function CC(e){return e.length<=Fe.PACKAGE_FIELD_MAX?e:`${e.slice(0,Fe.PACKAGE_FIELD_MAX-1)}\u2026`}s(CC,"capField");function ui(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,Fe.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let i=(0,Fe.packageNameFromSpec)(o);return i===null?null:{package_name:i,package_spec:CC(o),...EC(o,AC(r,i,n))}}s(ui,"resolveNpxPackage");function Pd(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=eo(e.trim());return n===void 0?null:ui(n,r,t)}s(Pd,"resolveNpxPackageFromCommand");function to(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)}s(to,"npxPackageFromMcpConfig");function Nd(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:ui(Yt(n[1]??""),Ln(e,"args"),t)}s(Nd,"npxPackageFromTomlSection");function xC(e){if(!e||typeof e!="object"||Array.isArray(e))return"unknown";let t=e;return typeof t.type=="string"&&t.type.length>0?t.type:typeof t.url=="string"?"http":typeof t.command=="string"?"stdio":"unknown"}s(xC,"mcpTransport");function wd(e,t,n){if(!e.claimFile(t))return;let o=e.readJson(t,{})?.mcpServers;if(!o||typeof o!="object")return;let i=e.componentPath(t);for(let[a,c]of Object.entries(o)){if(e.truncated)return;let u=xC(c),f=Rd(c,u);Object.assign(f,to(c,e.home)??{});let l=Ad(c);e.push({kind:"MCP_SERVER",name:a,path:i,content_hash:ci(a,f,l),origin:n,enabled:l,attributes:f})}}s(wd,"collectMcpJson");function Ld(e,t,n){if(!bC(t)||!e.claimFile(t))return;let r;try{r=OC(t,"utf8")}catch{return}let o=e.componentPath(t),i=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,a;for(;(a=i.exec(r))!==null;){if(e.truncated)return;let c=a[1]??a[2]??a[3];if(!c)continue;let u=r.slice(a.index+a[0].length),f=u.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),l=f===-1?u:u.slice(0,f),p="unknown";/^\s*url\s*=/m.test(l)?p="http":/^\s*command\s*=/m.test(l)&&(p="stdio");let d=bd(l,p);Object.assign(d,Nd(l,e.home)??{});let m=Cd(l);e.push({kind:"MCP_SERVER",name:c,path:o,content_hash:ci(c,d,m),origin:n,enabled:m,attributes:d})}}s(Ld,"collectCodexMcpToml");import{existsSync as TC,readdirSync as PC}from"node:fs";import{join as ge}from"node:path";function IC(e){if(e.prompt||e.type==="prompt")return"prompt";let t=e.command??e.bash??e.powershell??"";return/\bnpx\b/i.test(t)?"npx":/\.(sh|bash|zsh|js|mjs|cjs|ts|py)(\s|$|"|')/i.test(t)||/^(\.\/|~\/|\/|[A-Za-z]:[\\/])/.test(t.trim())?"script":"inline"}s(IC,"classifyActionKind");function kC(e){return Array.isArray(e.hooks)&&e.hooks.length>0?e.hooks:[{type:e.type,command:e.command,bash:e.bash,powershell:e.powershell,prompt:e.prompt}]}s(kC,"normalizeHookActions");function li(e,t,n,r){let o=e.componentPath(t);for(let[i,a]of Object.entries(n))if(!(!Array.isArray(a)||e.truncated))for(let c of a){if(!c||typeof c!="object"||e.truncated)continue;let u=c;for(let f of kC(u)){if(e.truncated)return;let l=f.command??f.bash??f.prompt??f.powershell??u.powershell??"",p=IC({type:f.type??u.type,command:f.command??u.command,bash:f.bash??u.bash,powershell:f.powershell??u.powershell,prompt:f.prompt??u.prompt}),d=typeof u.matcher=="string"?u.matcher:"",m=ee(l),_=d?`${i}:${d}:${p}:${m}`:`${i}:${p}:${m}`,E=`${i}|${d}|${p}|${l}|attrs2`;e.push({kind:"HOOK",name:_,path:o,content_hash:ee(E),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:i,...d?{matcher:d}:{},action_kind:p,action_hash:m,...p!=="prompt"&&l.trim()?{command:Id(l,e.home)}:{}}})}}}s(li,"collectHooksFromObject");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)}s(fi,"collectHooksFile");var Md=50;function Un(e,t,n,r){if(!TC(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:i}=e.withPluginExpandCap(Md,()=>{bt(e,{dir:ge(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),bt(e,{dir:ge(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),bt(e,{dir:ge(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});fi(e,ge(t,"hooks","hooks.json"),n),fi(e,ge(t,"hooks.json"),n);let a=e.components.length-o,c=i>=Md;return{componentCount:a,expandTruncated:c}}s(Un,"expandPluginTree");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}:{}}})}s(Hn,"addPluginRow");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}s(di,"readEnabledPlugins");function NC(e){let t=di(e.readJson(ge(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=_n(process.platform,e.home),o=e.readJson(n,{}),i={};if(o&&Object.keys(o).length>0)i=di(o);else for(let a of r)Object.assign(i,di(e.readJson(a,{})));return{...t,...i}}s(NC,"resolveClaudeEnabledPlugins");function vd(e){let t=ge(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=NC(e),i=e.componentPath(t);for(let[a,c]of Object.entries(r)){if(e.truncated)return;let u=Array.isArray(c)?c:[c],f=u[0]??{},l=o[a]===!0,p=a.includes("@")?a.split("@").slice(1).join("@"):"",d=typeof f.version=="string"?f.version:"",m=typeof f.scope=="string"?f.scope:"user",_=`plugin:${a}`,E=0,C=!1;for(let b of u)if(typeof b.installPath=="string"&&b.installPath.length>0){let k=Un(e,b.installPath,_,l);E+=k.componentCount,C=C||k.expandTruncated}Hn(e,{pluginKey:a,rowPath:i,enabled:l,scope:m,version:d||void 0,marketplace:p||void 0,componentCount:E,expandTruncated:C,contentHash:ee(`${a}|${d}|${m}|${l}|${E}`)})}}s(vd,"collectClaudePlugins");function wC(e){let t=e,n="";try{let r=PC(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=ge(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),i=o[o.length-1];i&&(t=ge(e,i),n=i)}}catch{}return{installPath:t,version:n}}s(wC,"pickVersionDir");var LC=/^\d+$/;function MC(e){let t=e.filter(n=>!LC.test(n.pluginId));return t.length>0?t:e}s(MC,"dedupeCursorCachePlugins");function Ud(e){let t=[{base:ge(e.home,".cursor/plugins/local"),scope:"local"},{base:ge(e.home,".cursor/plugins/cache"),scope:"cache"}];for(let{base:n,scope:r}of t)if(!e.truncated)for(let o of e.readEntries(n)){if(!o.isDirectory()||e.truncated)continue;if(r==="local"){let c=o.name,u=ge(n,o.name),f=`plugin:${c}`,{componentCount:l,expandTruncated:p}=Un(e,u,f,!0);Hn(e,{pluginKey:c,rowPath:e.componentPath(u),enabled:!0,scope:"local",componentCount:l,expandTruncated:p,contentHash:ee(`${c}|local|${l}`)});continue}let i=o.name,a=[];for(let c of e.readEntries(ge(n,i))){if(!c.isDirectory())continue;let u=ge(n,i,c.name),{installPath:f,version:l}=wC(u);a.push({pluginId:c.name,installPath:f,version:l})}for(let c of MC(a)){if(e.truncated)break;let u=`${c.pluginId}@${i}`,f=`plugin:${u}`,{componentCount:l,expandTruncated:p}=Un(e,c.installPath,f,!0);Hn(e,{pluginKey:u,rowPath:e.componentPath(c.installPath),enabled:!0,scope:"cache",version:c.version||void 0,marketplace:i,componentCount:l,expandTruncated:p,contentHash:ee(`${u}|${c.version}|${l}`)})}}}s(Ud,"collectCursorPlugins");import{existsSync as HC}from"node:fs";var vC=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,pi="<path>",UC=new RegExp(`${pi}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function no(e){let t=e.replace(vC,pi).replace(UC,pi);return t.length>200?`${t.slice(0,200)}...`:t}s(no,"redactPermissionKey");var Hd=200,Dd=200,mi=16*1024,Fd=6,DC=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),FC=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),$C=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),jC=new Set(["permissions"]),BC={claude:DC,cursor_sandbox:FC,cursor_permissions:$C,cursor_cli:jC},KC=new Set(["allow","deny","ask"]);function lt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(lt,"isRecord");function ro(e){return e.replace(/\\/g,"/")}s(ro,"posixPath");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(",")}}`}s(gi,"canonicalJson");function GC(e){return ee(`${gi(e)}|settings1`)}s(GC,"hashSettingsAttributes");function Gd(e){let t=ro(e);if(t.endsWith(".claude/settings.json")||t.endsWith(".claude/settings.local.json"))return"claude";if(t.endsWith(".cursor/sandbox.json"))return"cursor_sandbox";if(t.endsWith(".cursor/permissions.json"))return"cursor_permissions";if(t.endsWith(".cursor/cli-config.json")||t.endsWith(".cursor/cli.json"))return"cursor_cli"}s(Gd,"settingsProfileFor");function Vd(e,t){if(e!=="claude")return{};let n=ro(t);return n.endsWith("/.claude/remote-settings.json")?{profile:"claude",managedSource:"server"}:n.includes("/managed-settings.d/")&&n.endsWith(".json")?{profile:"claude",managedSource:"file_dropin"}:n.endsWith("/managed-settings.json")?{profile:"claude",managedSource:"file"}:{profile:"claude"}}s(Vd,"managedSettingsMeta");function zd(e){let t=ro(e).replace(/\/+$/,"");return t.length<=1?"":t}s(zd,"homePosix");function Wd(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}s(Wd,"isWindowsHome");function VC(e,t){let n=ro(e);if(n==="~"||n.startsWith("~/"))return n;let r=zd(t);if(!r)return n;let o=n.slice(0,r.length);if(!(Wd(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let a=n.slice(r.length);return a===""?"~":a.startsWith("/")?`~${a}`:n}s(VC,"tildePath");var $d=new Map;function zC(e){let t=$d.get(e);if(t!==void 0)return t;let n=zd(e),r=null;if(n){let o=n.split("/").map(i=>i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,Wd(e)?"gi":"g")}return $d.set(e,r),r}s(zC,"homeTextPattern");function WC(e,t){let n=zC(t);return n?e.replace(n,"~"):e}s(WC,"tildeHomeInText");function jd(e,t){return e.length<=Dd?e:(t.truncated=!0,e.slice(0,Dd))}s(jd,"capString");function Jd(e,t){return e.length<=Hd?e:(t.truncated=!0,e.slice(0,Hd))}s(Jd,"capArray");function se(e,t,n,r){if(typeof e=="string"){if(t==="path")return jd(VC(e,n),r);let o=t==="rule"?no(e):e;return jd(WC(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=Jd(e,r),i=[];for(let a of o){let c=se(a,t,n,r);c!==void 0&&i.push(c)}return i}if(lt(e)){let o={};for(let[i,a]of Object.entries(e)){let c=se(a,t,n,r);c!==void 0&&(o[i]=c)}return o}}s(se,"transformValue");function Bd(e,t,n){if(!lt(e))return se(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a="plain";KC.has(o)?a="rule":o==="additionalDirectories"&&(a="path");let c=se(i,a,t,n);c!==void 0&&(r[o]=c)}return r}s(Bd,"transformPermissions");function JC(e,t,n){if(!lt(e))return se(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){if(o==="files"&&Array.isArray(i)){let c=Jd(i,n);r[o]=c.map(u=>{if(!lt(u))return se(u,"plain",t,n);let f={};for(let[l,p]of Object.entries(u)){let m=se(p,l==="path"?"path":"plain",t,n);m!==void 0&&(f[l]=m)}return f});continue}let a=se(i,"plain",t,n);a!==void 0&&(r[o]=a)}return r}s(JC,"transformCredentials");function YC(e,t,n){if(!lt(e))return se(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let c=se(i,o==="allowUnixSockets"?"path":"plain",t,n);c!==void 0&&(r[o]=c)}return r}s(YC,"transformNetwork");function XC(e,t,n){if(!lt(e))return se(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a;o==="excludedCommands"?a=se(i,"rule",t,n):o==="filesystem"?a=se(i,"path",t,n):o==="network"?a=YC(i,t,n):o==="credentials"?a=JC(i,t,n):a=se(i,"plain",t,n),a!==void 0&&(r[o]=a)}return r}s(XC,"transformSandbox");function qC(e,t,n,r,o){return n==="claude"?e==="permissions"?Bd(t,r,o):e==="sandbox"?XC(t,r,o):se(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?se(t,"path",r,o):se(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?se(t,"rule",r,o):se(t,"plain",r,o):e==="permissions"?Bd(t,r,o):se(t,"plain",r,o)}s(qC,"transformByProfile");function Dn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Dn,"jsonBytes");function _i(e,t){return e?`${e}.${t}`:t}s(_i,"childPath");function hi(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let i=e[o];i!==null&&typeof i=="object"&&(t+1>=Fd?(e.splice(o,1),r.add(n)):hi(i,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,i]of Object.entries(e))i!==null&&typeof i=="object"&&(t+1>=Fd?(delete e[o],r.add(_i(n,o))):hi(i,t+1,_i(n,o),r))}s(hi,"pruneDepth");function Yd(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:Dn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))Yd(o,_i(t,r),n)}s(Yd,"collectTrimCandidates");function ZC(e,t,n){let r=Dn(e);if(r<=mi)return;t.truncated=!0;let o=[];for(Yd(e,"",o);r>mi;){let i;for(let u of o)u.items.length>0&&(!i||u.bytes>i.bytes)&&(i=u);if(!i)break;let a=i.items.pop(),c=Dn(a)+(i.items.length>0?1:0);i.bytes-=c,r-=c,n.add(i.path)}for(;Dn(e)>mi;){let i,a=-1;for(let[c,u]of Object.entries(e)){let f=Dn(u);f>a&&(i=c,a=f)}if(i===void 0)break;delete e[i],n.add(i)}}s(ZC,"fitSettingsJson");function QC(e,t,n){let r=BC[t],o={truncated:!1},i={},a=[];for(let u of Object.keys(e)){if(!r.has(u)){a.push(u);continue}let f=qC(u,e[u],t,n,o);f!==void 0&&(i[u]=f)}a.sort();let c=new Set;return hi(i,1,"",c),c.size>0&&(o.truncated=!0),ZC(i,o,c),{settings:i,keys_omitted:a,truncated:o.truncated,trimmed_paths:[...c].sort()}}s(QC,"extractSettingsPosture");function Kd(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:GC(t.attributes),attributes:t.attributes};e.push(n)}s(Kd,"pushPostureRow");function Si(e,t,n,r){if(!e.claimFile(t)||!HC(t))return;let o=ea(t);if(!o.ok||!lt(o.value)){if(r.profile){let f=!o.ok&&o.reason==="read"?"read_error":"parse_error",l={profile:r.profile,[f]:!0};r.managedSource&&(l.managed_source=r.managedSource),Kd(e,{kind:r.kind,absPath:t,origin:n,attributes:l})}return}let i=o.value,a=i.hooks;if(lt(a)&&li(e,t,a,n),!r.profile)return;let c=QC(i,r.profile,e.home),u={profile:r.profile,settings:c.settings,keys_omitted:c.keys_omitted};c.truncated&&(u.truncated=!0),c.trimmed_paths.length>0&&(u.trimmed_paths=c.trimmed_paths),r.managedSource&&(u.managed_source=r.managedSource),Kd(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}s(Si,"collectSettingsFile");import{existsSync as eb}from"node:fs";import{join as $e}from"node:path";var Xd=".claude/skills/synced",qd=".claude/plugins/synced";function Zd(e){return[$e(e,Xd),$e(e,qd)]}s(Zd,"claudeSyncedDirs");function oo(e){return typeof e=="string"&&e.length>0?e:void 0}s(oo,"stringField");function Qd(e){let t=$e(e.home,Xd);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=$e(t,n.name),o=e.readJson($e(r,"manifest.json"),{}),i=new Map((o?.skills??[]).flatMap(a=>a.name?[[a.name,a]]:[]));for(let a of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let c=$e(r,a.name,"SKILL.md");if(!a.isDirectory()||!eb(c))continue;let u=i.get(a.name),f=oo(u?.source),l=oo(u?.creatorType);Jt(e,{absolutePath:c,kind:"SKILL",origin:"user",enabled:!0,name:a.name,attributes:{scope:"synced",...f?{source:f}:{},...l?{creator_type:l}:{}}})}}}s(Qd,"collectClaudeSyncedSkills");function ep(e){let t=$e(e.home,qd);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=$e(t,n.name),o=e.readJson($e(r,"manifest.json"),{}),i=new Map((o?.plugins??[]).flatMap(a=>a.name?[[a.name,a]]:[]));for(let a of e.readEntries(r)){if(e.truncated)return;if(!a.isDirectory()||a.name.startsWith("."))continue;let c=i.get(a.name),u=oo(c?.marketplaceName),f=oo(c?.version),l=u?`${a.name}@${u}`:a.name,p=$e(r,a.name),{componentCount:d,expandTruncated:m}=Un(e,p,`plugin:${l}`,!0);Hn(e,{pluginKey:l,rowPath:e.componentPath(p),enabled:!0,scope:"synced",version:f,marketplace:u,componentCount:d,expandTruncated:m,contentHash:ee(`${l}|${f??""}|synced|${d}`)})}}}s(ep,"collectClaudeSyncedPlugins");function nb(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:i}=t;for(let a of n.skillRoots)bt(e,{dir:Xt(r,a),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:Zd(e.home)});for(let a of n.dirs)bt(e,{dir:Xt(r,a.dir),kind:a.kind,origin:o,enabled:!0,extensions:a.extensions});for(let a of n.memory){let c=dd(a.map(u=>Xt(r,u)));c&&Jt(e,{absolutePath:c,kind:"MEMORY",origin:o,enabled:!0,name:tb(c)})}for(let a of Dc(n))Si(e,Xt(r,a),o,{kind:"SETTINGS",profile:Gd(a)});for(let a of n.mcpJson??[])wd(e,Xt(r,a),o);for(let a of n.mcpToml??[])Ld(e,Xt(r,a),o);if(i){if(n.managed){for(let a of hr(n.managed,process.platform,e.home))if(a.toLowerCase().endsWith(".json")){let c=Vd(n.managed,a);Si(e,a,o,{kind:"MANAGED_SETTINGS",...c})}}n.plugins==="claude"?(vd(e),ep(e),Qd(e)):n.plugins==="cursor"&&Ud(e)}}s(nb,"walkPlatformLayout");function tp(e,t){try{let n=new Gr(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)nb(n,{layout:r,levelDir:t.levelDir,origin:t.origin,includeMachineWide:t.includeMachineWide});return{scopeRef:t.scopeRef,anchor:t.levelDir,components:n.components,truncated:n.truncated}}catch(n){U("user_spec_scope",n);return}}s(tp,"walkScope");function Ei(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let u=tp(t,{layouts:Object.values(Ft),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:Qe,scopeRef:""});u&&(r.user=u)}let i=n.inGitRepo===!0,a=null,c=n.launchCwd;if(c!==void 0){let u=Object.values(ot),f=Us({launchCwd:c,gitRoot:n.gitRoot,inGitRepo:i,remote:n.remote,home:t,hasProjectSpec:s(l=>$c(u,l),"hasProjectSpec")});a=f.parentRel;for(let l of f.anchors){let p=bs(l.dir);if(o!==void 0&&!o(l.scope,p))continue;let d=tp(t,{layouts:u,levelDir:l.dir,origin:l.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:Hs,scopeRef:p});d&&(r[l.scope]=d)}r.parent||(a=null)}return{scopes:r,parentRel:a,cwdInGitRepo:i}}s(Ei,"collectUserSpec");function yi(e,t,n={}){let r=n.truncated===!0,o=xn(e),i=new Set(e.map(l=>Ce(l.path,l.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let c=[],u=t;for(let l of e){let p=Ce(l.path,l.name);u[p]!==Fr(l)&&c.push(l)}let f=[];if(!r){for(let l of Object.keys(u))if(!i.has(l)){let p=Ul(l);p&&f.push(p)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:c,removed:f,unchanged:c.length===0&&f.length===0}}s(yi,"diffUserSpec");var rp=2*1024*1024,rb=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function Ri(e,t,n){let r=new Set(t.map(i=>Ce(i.path,i.name))),o=[];for(let i of e)i.text!==void 0&&(n.has(i.content_hash)||r.has(Ce(i.path,i.name))||o.push(i));return o}s(Ri,"collectPendingTextBodies");function Ai(e,t,n){let r=new Set(e);for(let i of t)r.add(i);let o=new Set(n.map(i=>i.content_hash));return[...r].filter(i=>o.has(i))}s(Ai,"pruneDeliveredTextHashes");function np(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(np,"jsonSize");function op(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}s(op,"withoutText");function Ci(e,t=rp){let n=[],r=[];for(let l of e)rb.has(l.kind)?n.push(l):r.push(l);r.sort((l,p)=>(l.text?.length??0)-(p.text?.length??0));let o=[...n,...r],i=[],a=2,c=0,u=0,f=[];for(let l of o){let p=i.length>0?1:0,d=np(l)+p;if(a+d<=t){i.push(l),a+=d,l.text!==void 0&&f.push(l.content_hash);continue}if(l.text!==void 0){let m=op(l),_=np(m)+p;if(a+_<=t){i.push(m),a+=_,c+=1;continue}}u+=1}return{components:i,textDeferredCount:c,droppedCount:u,textHashesSent:f}}s(Ci,"fitUserSpecWithinBudget");function bi(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:op(n))}s(bi,"stripAlreadyDeliveredText");var ob=["user","cwd","repo","parent"];function Oi(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,i=[];for(let N of ob){let I=t.scopes[N];if(!I)continue;let $=n(N,I.scopeRef),L=$.components,O=yi(I.components,L,{forceFull:L===void 0,truncated:I.truncated}),P=new Set($.textHashes),H=Ri(I.components,O.upserts,P),g=bi([...O.upserts,...H],P);i.push({scope:N,walk:I,delta:O,outgoing:g,outgoingKeys:new Set(g.map(x=>Ce(x.path,x.name))),deliveredTextHashes:P,cachedComponents:L})}let a=i.flatMap(N=>N.outgoing),c=Ci(a,o),u=new Set(c.components.map(N=>Ce(N.path,N.name))),f=[],l=[],p=[],d=[],m=[],_=[],E=[];for(let N of i){let{scope:I,walk:$,delta:L}=N;_.push(...$.components),f.push(I);let O=c.components.filter(x=>N.outgoingKeys.has(Ce(x.path,x.name))),P=[...N.outgoingKeys].some(x=>!u.has(x)),H=L.truncated||P;H?p.push(I):L.full&&l.push(I),d.push(...O),!L.full&&!H&&m.push(...L.removed);let g=L.full?{}:{...N.cachedComponents??{}};if(!H)for(let x of L.removed)delete g[Ce(x.path,x.name)];for(let x of O)g[Ce(x.path,x.name)]=Fr(x);E.push({scope:I,scopeRef:$.scopeRef,components:g,textHashes:Ai(N.deliveredTextHashes,O.filter(x=>x.text!==void 0).map(x=>x.content_hash),$.components),collectedAtMs:r,included:O.length>0||L.removed.length>0&&!H||L.full})}let C={user_spec_hash:xn(_),user_spec_count:_.length,user_spec_truncated:p.length>0};f.length>0&&(C.user_spec_scopes=f,C.user_spec_full_scopes=l,C.user_spec_truncated_scopes=p,C.user_spec_cwd_in_git_repo=t.cwdInGitRepo),l.length>0&&l.length===f.length&&(C.user_spec_full=!0),d.length>0&&(C.user_spec=d),m.length>0&&(C.user_spec_removed=m),c.textDeferredCount>0&&(C.user_spec_text_deferred=c.textDeferredCount);let b=t.scopes.cwd;b&&(C.user_spec_cwd_scope_ref=b.scopeRef);let k=t.scopes.repo;k&&(C.user_spec_repo_scope_ref=k.scopeRef);let w=t.scopes.parent;return w&&(C.user_spec_parent_scope_ref=w.scopeRef,t.parentRel&&(C.user_spec_parent_rel=t.parentRel)),{fields:C,scopes:E}}s(Oi,"buildUserSpecSend");var so={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function xi(e){return e==="cwd"||e==="repo"||e==="parent"}s(xi,"isProjectSpecScope");function Fn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Fn,"isPlainObject");function Ii(e){return!Fn(e)||!Fn(e.components)||!Object.values(e.components).every(t=>typeof t=="string")||!Array.isArray(e.text_hashes)||!e.text_hashes.every(t=>typeof t=="string")?!1:typeof e.collected_at_ms=="number"&&Number.isFinite(e.collected_at_ms)}s(Ii,"isDirScopeCacheEntry");function sp(e){return sb(e)}s(sp,"readStringHashMap");function ip(e){return ib(e)}s(ip,"readStringArray");function ap(e){return ab(e)}s(ap,"cloneDirScopeMap");function sb(e){if(!Fn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}s(sb,"readComponentHashMap");function ib(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}s(ib,"readTextHashes");function cp(e,t){if(!Fn(e))return;let n=e[t];return Ii(n)?n:void 0}s(cp,"readDirScopeCacheEntry");function ab(e){if(!Fn(e))return{};let t={};for(let[n,r]of Object.entries(e))Ii(r)&&(t[n]=r);return t}s(ab,"readDirScopeCacheMap");function ki(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))}s(ki,"boundDirScopeCache");var db=["allow","deny","ask"];function ao(e){let t=Z(e,{}),n=[];for(let r of db)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:no(o),mode:r});return{model:t.model??"",permissionKeys:n}}s(ao,"readClaudeSettings");function pb(e){let{serverManaged:t,fileBased:n}=_n(process.platform,e),r=ao(t);if(r.model||r.permissionKeys.length>0)return r;let o="",i=[];for(let a of n){let c=ao(a);c.model&&(o=c.model),i.push(...c.permissionKeys)}return{model:o,permissionKeys:i}}s(pb,"readClaudeManagedSettings");function mb(e){let t=new Set,n=[];for(let r of e){let o=`${r.mode}\0${r.key}`;t.has(o)||(t.add(o),n.push(r))}return n}s(mb,"dedupePermissionKeys");var gb=10,_b="self-config-cache.json",lp=5;function Zt(){return D("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}s(Zt,"isUserSpecDisabled");function hb(){return D("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}s(hb,"isCwdSpecDisabled");var Sb={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function Eb(e,t=oe){let n=Sb[e];if(!n||n.length===0)return null;let r=s(async o=>{let i=n[o];if(i===void 0)return null;let c=((await t(i,["--version"],2e3)).split(`
45
+ `)[0]??"").trim();return c||r(o+1)},"tryNext");return r(0)}s(Eb,"resolveCliVersion");function yb(e=up()){return qt(e,".ev-ai","agent-hook",_b)}s(yb,"selfConfigCachePath");function Rb(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
46
+ `);return ee(n)}s(Rb,"hashConfigEntries");function io(e,t,n=!1){let r=Rb(e),o=e.length;return t===r?n?{hash:r,count:o,truncated:n}:{hash:r,count:o}:n?{hash:r,count:o,entries:e,truncated:n}:{hash:r,count:o,entries:e}}s(io,"buildHashedList");function Ti(e,t,n=[]){let r=0,o=!1,i=new Set;for(let a of[...t.map(c=>qt(e,c)),...n]){let c=fb(a);if(i.has(c))continue;i.add(c);let u=xo(a);u.present&&(o=!0,r+=u.size)}return o?{present:!0,size:r}:{present:!1,size:0}}s(Ti,"filePresenceUnion");function Ab(e){return ub(e)?xe(lb(e,"utf8"),{}):{}}s(Ab,"readSelfConfigCache");function Cb(e,t){try{ce(e,`${JSON.stringify(t)}
47
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);T(`WARN: self-config cache write failed open: ${r}`),U("self_config_cache",n)}}s(Cb,"writeSelfConfigCache");function bb(e,t,n){if(t==="user")return{components:sp(e.user_spec_components),textHashes:ip(e.user_spec_text_hashes)};if(!xi(t))return{components:void 0,textHashes:[]};let r=cp(e[so[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}s(bb,"cacheSliceFor");function Ob(e,t,n,r){let o={...e,send_count:n};for(let i of Object.keys(t)){let a=t[i];a.entries!==void 0&&(o[i]=a.hash)}if(r){o.user_spec_layout_version=lp,r.home&&(o.user_spec_collected_at_ms=r.home.collectedAtMs,r.home.included&&(o.user_spec=r.hash,o.user_spec_components=r.home.components),o.user_spec_text_hashes=r.home.textHashes);for(let i of r.project){if(!xi(i.scope))continue;let a=so[i.scope],c=ap(o[a]),u=c[i.scopeRef];c[i.scopeRef]={components:i.included?i.components:u?.components??{},text_hashes:i.textHashes,collected_at_ms:i.collectedAtMs},o[a]=ki(c)}}return o}s(Ob,"nextPlatformSelfConfigCache");async function fp(e,t=process.cwd(),n=up(),r={}){let o=e==="claude",i=r.gitRoot??t,a=await Eb(e),c="",u=[];if(o){let H=pb(n),g=ao(qt(n,".claude/settings.json")),x=ao(qt(t,".claude/settings.local.json"));c=H.model||x.model||g.model,u=mb([...H.permissionKeys,...g.permissionKeys,...x.permissionKeys]).slice(0,200)}let f={present:!1,size:0},l=s(H=>{let g=[],x=!1;for(let j of H){let _e=ta(qt(n,j));if(g=g.concat(_e.entries),x=x||_e.truncated,g.length>=Qe){g=g.slice(0,Qe),x=!0;break}}return{entries:g,truncated:x}},"listScopeWithMeta"),p=yb(n),d=Ab(p),m=d[e]??{},_=(m.send_count??0)+1,E=_>0&&_%gb===0,C=s(H=>E?void 0:m[H],"cachedHash"),b=l(it.skills),k=l(it.subagents),w=l(it.commands),N=l(it.rules),I={skills:io(b.entries,C("skills"),b.truncated),subagents:io(k.entries,C("subagents"),k.truncated),commands:io(w.entries,C("commands"),w.truncated),rules:io(N.entries,C("rules"),N.truncated)},$={runner_platform:e,config_scope:"user",cli_version:a,claude_version:o?a:null,model:o&&c||null,permission_keys:u,user_scope:{skills:I.skills,subagents:I.subagents,commands:I.commands,rules:I.rules,memory:Ti(n,it.memory),settings:Ti(n,it.settings,jc(n)),mcp:Ti(n,it.mcp)},local_settings:o?xo(qt(t,".claude/settings.local.json")):f},L=null,O=r.nowMs??Date.now();if(!Zt()){let H=m.user_spec_layout_version!==lp,g=Ei(e,n,{launchCwd:hb()?void 0:r.launchCwd,gitRoot:i,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(g.scopes).length>0){let x=Oi({collected:g,cacheFor:s((j,_e)=>H?{components:void 0,textHashes:[]}:bb(m,j,_e),"cacheFor"),nowMs:O});Object.assign($,x.fields),L={hash:x.fields.user_spec_hash,home:x.scopes.find(j=>j.scope==="user")??null,project:x.scopes.filter(j=>j.scope!=="user")}}}let P=Ob(m,I,_,L);return{config:$,commit:s(()=>{d[e]=P,Cb(p,d)},"commit")}}s(fp,"selfConfig");import{homedir as Vb}from"node:os";import{join as mp}from"node:path";function xt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(xt,"isRecord");import{join as co}from"node:path";function xb(e){return co(e,".ev-ai","agent-hook","js","signed-v1")}s(xb,"jsRoot");function Ib(e){return co(xb(e),"scopes")}s(Ib,"scopesRoot");function dp(e,t){return co(Ib(e),t)}s(dp,"scopeDir");function pp(e){return co(e,"attempts")}s(pp,"attemptsDir");function Pi(e){return String(e).padStart(10,"0")}s(Pi,"padAttempt");var kb=/^(\d{10})$/,Tb=/^(\d{10})\.done$/,Pb=/^[0-9a-f]{128}$/,Nb=64,Sp=["check_ms","download_ms","install_ms","total_ms"],wb=36e5;async function Ep(e,t,n=!1){let r=pp(t),o=await Sa(e,r),i=new Map,a=new Map,c=gp(o,kb),u=gp(o,Tb),f=s(async d=>{let m=await hp(e,mp(r,Lb(d)));return m&&i.set(d,{record:vb(m.value),mtimeMs:m.mtimeMs}),m!==void 0},"readClaimAt"),l=s(async d=>{let m=Ub((await hp(e,mp(r,Mb(d))))?.value);return m&&a.set(d,m),m!==void 0},"readDoneAt");if(!n)return await Promise.all([...c.map(f),...u.map(l)]),{claims:i,dones:a};await Promise.all([_p(c,f),_p(u,l)]);let p=$n(i);return p<$n(a)&&u.includes(p)&&await l(p),{claims:i,dones:a}}s(Ep,"scanAttempts");function gp(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}s(gp,"attemptNumbers");async function _p(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}s(_p,"firstFromTop");function $n(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}s($n,"maxKey");function yp(e){if(e.record!=="empty"&&e.record.started_at){let t=Date.parse(e.record.started_at);if(Number.isFinite(t))return t}return e.mtimeMs}s(yp,"claimStartMs");function Rp(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of Sp){let r=e[n];r!==void 0&&(t[n]=r)}return t}s(Rp,"pickTimings");function Lb(e){return Pi(e)}s(Lb,"claimFileName");function Mb(e){return`${Pi(e)}.done`}s(Mb,"doneFileName");async function hp(e,t){let n;try{n=await e.stat(t)}catch(o){if(Nt(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>To)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>To?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}s(hp,"readRecord");function vb(e){if(!xt(e))return"empty";let t={};return typeof e.started_at=="string"&&(t.started_at=e.started_at),(e.owner==="bootstrap"||e.owner==="refresh")&&(t.owner=e.owner),e.resync===!0&&(t.resync=!0),t}s(vb,"parseClaim");function Ub(e){if(!xt(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=Db(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...Hb(t)}}s(Ub,"parseDoneRecord");function Hb(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 Sp){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=wb&&(t[n]=r)}return t}s(Hb,"parseTimings");function Db(e){if(!xt(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"&&Pb.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&Fb(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}s(Db,"parseSelection");function Fb(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==Nb||t.toString("base64")!==e))return t.toString("hex")}s(Fb,"canonicalSha512Hex");function Kb(e){return e==="bootstrap"?3e3:6e4}s(Kb,"ownerBudgetMs");function Gb(e,t){let n=$n(e.claims);if(n===0)return;let r=$n(e.dones),o=e.claims.get(n),i=e.dones.get(n);if(o&&!i){let c=yp(o),u=o.record==="empty"?void 0:o.record.owner,f=Kb(u)+3e4;if(t-c>f)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:Ap(e.dones.get(r)?.selection)}}if(r===0)return;let a=e.dones.get(r);if(a)return{n:r,latest_claim:n,outcome:a.outcome,finished_at:a.finished_at,selection_version:Ap(a.selection),...Rp(a)}}s(Gb,"latestAttemptReport");async function Cp(e,t,n){try{let r=await Ep(Ea(),dp(e,t),!0);return Gb(r,n)}catch{return}}s(Cp,"readLatestAttemptReport");function Ap(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}s(Ap,"selectionVersion");function zb(e=process.env){if(Object.values(za).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===vt?"npx":null}s(zb,"hookDelivery");async function bp(e=Vb()){let t=_s()?.launcherScope;if(!t)return{};let n=await Cp(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}s(bp,"readSessionStartLauncherFields");function Qt(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:cr,event:e,timestamp:Jn(),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:Ke,hook_delivery:zb(),host_arch:process.arch,node_version:process.version,policy_version:null,policy_capabilities:[],...n.promptCaptureSource!==void 0?{prompt_capture_source:n.promptCaptureSource}:{},...n.telemetry!==void 0?{telemetry_source:n.telemetry.source}:{},correlation:r,payload:t},i=_s();return i&&(o.launcher_version=i.launcherVersion,o.hook_source=i.hookSource,o.hook_fallback_reason=i.fallbackReason??null,o.launcher_scope_match=rl(n.collectorUrl,i.launcherScope)),e==="session_start"&&(n.launcher_scope&&(o.launcher_scope=n.launcher_scope),n.launcher_attempt&&(o.launcher_attempt=n.launcher_attempt)),o}s(Qt,"buildEnvelope");import{existsSync as Tp}from"node:fs";import{spawn as Pp}from"node:child_process";import{fileURLToPath as oO}from"node:url";import{gzipSync as Wb}from"node:zlib";function Ni(e){return D("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<Va?{body:e}:{body:Wb(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}s(Ni,"gzipBodyIfLarge");function uo(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}s(uo,"collectorPostHeaders");function wi(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}s(wi,"postBodyByteLength");import{readFileSync as Jb,statSync as Yb}from"node:fs";import{homedir as Li}from"node:os";import{join as Xb}from"node:path";var qb="hook-config.json",Zb=1440*60*1e3,Qb=2048,eO=1024*1024;function en(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(en,"isRecord");function Op(e=Li()){return Xb(Ee(e),qb)}s(Op,"hookConfigPath");function xp(e){let t=Op(e);try{let n=Yb(t);if(!n.isFile()||n.size>eO)return;let r=JSON.parse(Jb(t,"utf8"));return en(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}s(xp,"readStore");function tO(e){let t={};return typeof e.collect_prompt=="boolean"&&(t.collect_prompt=e.collect_prompt),typeof e.collect_telemetry=="boolean"&&(t.collect_telemetry=e.collect_telemetry),typeof e.log_until=="string"&&(e.log_until===Ut||!Number.isNaN(Date.parse(e.log_until)))&&(t.log_until=e.log_until),t}s(tO,"knownKeys");function Ip(e,t=Li()){if(!e)return;let n=mt(e);if(!n)return;let r=xp(t),o=r?r[n]:void 0;if(!(!en(o)||!en(o.config)))return tO(o.config)}s(Ip,"readHookConfig");function nO(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!en(n)||!en(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>Qb))return n.hook_config}s(nO,"hookConfigFromBody");function rO(e,t,n,r){let o={...e},i=o[t];if(Object.keys(n).length===0)return i===void 0?void 0:(delete o[t],o);if(!(en(i)&&JSON.stringify(i.config)===JSON.stringify(n)&&typeof i.fetched_at_ms=="number"&&i.fetched_at_ms<=r&&r-i.fetched_at_ms<Zb))return o[t]={config:n,fetched_at_ms:r},o}s(rO,"nextStore");function kp(e,t,n=Li(),r=Date.now()){let o=nO(e),i=t?mt(t):void 0;if(o===void 0||!i)return"skipped";try{let a=xp(n);if(a===void 0)return ue.error("failed where=hook_config_read err=unreadable message=hook config store is not a readable JSON object"),"skipped";let c=rO(a??{},i,o,r);return c?(ce(Op(n),`${JSON.stringify(c,null,2)}
48
+ `),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(a){let c=a instanceof Error?a.message:String(a);return T(`WARN: hook config write failed open: ${c}`),U("hook_config_write",a),"failed"}}s(kp,"applyCollectorHookConfigResponse");var lo="__post",tn="__work";async function sO(e,t,n={}){if(Zt())return e;let r=await xs(n.gitRoot??process.cwd(),oe,process.env,{runnerPlatform:t,home:n.home}),o=xt(e.self_config)?e.self_config:{};return{...e,self_config:{...o,runner_platform:typeof o.runner_platform=="string"?o.runner_platform:t,operator:r}}}s(sO,"attachOperatorIdentity");function iO(e,t){let n=xt(e.payload)?Object.keys(e.payload):[],r=e.correlation&&typeof e.correlation=="object"?Object.keys(e.correlation):[];return JSON.stringify({event:e.event,schema_version:e.schema_version,agent_hook_version:e.agent_hook_version,host_arch:e.host_arch,node_version:e.node_version,build_ms:e.build_ms,body_bytes:t,correlation_keys:r,payload_keys:n})}s(iO,"debugEnvelopeSummary");function Np(e){switch(e){case"session_start":return ja;case"session_end":return Ba;case"tool_invoked":case"skill_invoked":return Mo;default:return Mo}}s(Np,"timeoutForEvent");function aO(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
49
+ ${n}`}s(aO,"frameDetachedPostStdin");function wp(e,t=[],n=process.execPath,r=import.meta.url,o=Tp){if($a(n))return{command:n,args:[e,...t]};let i=oO(r);return o(i)?{command:n,args:[i,e,...t]}:{command:n,args:[e,...t]}}s(wp,"resolveSelfReexecCommand");function cO(e=process.execPath,t=import.meta.url,n=Tp){let r=process.argv.includes("--debug")?["--debug"]:[];return wp(lo,r,e,t,n)}s(cO,"resolveSelfPostCommand");function uO(e){let t=e.indexOf(`
50
+ `);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}s(uO,"parseDetachedPostStdin");async function Lp(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();kp(n,t)}catch(n){U("collector_response",n)}}s(Lp,"applyCollectorHttpResponse");function Mp(e){let t=e instanceof Error?e.message:String(e);return{code:e!==null&&typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:void 0,message:t}}s(Mp,"errorParts");var vp=1e3;function Up(e,t){let n=e instanceof Error&&e.name==="TimeoutError"?"timeout":"post_failed";Q({outcome:n,postMs:t,err:nt(e)})}s(Up,"noteFailedPost");async function Hp(e,t=fetch){try{let n=await e(),r=uO(n);if(!r){ue.error("send fail code=bad-frame message=detached post stdin was not framed"),Q({outcome:"post_failed",err:"bad-frame"});return}let{meta:o,body:i}=r,a=Ni(i),c=uo(a.contentEncoding),u=performance.now();try{let f=await t(o.url,{method:"POST",headers:c,body:a.body,signal:AbortSignal.timeout(Number(o.timeoutMs))}),l=performance.now()-u;if(!f.ok){let p=(await f.text()).slice(0,vp).replace(/[\n\r]/g,"");ue.error(`send fail http=${f.status} code=${f.status} body=${p}`),Q({outcome:"post_failed",postMs:l,http:f.status});return}ue.info(`send ok http=${f.status}`),Q({outcome:"posted",postMs:l,http:f.status}),await Lp(f,o.url)}catch(f){let l=Mp(f);ue.error(`send fail code=${l.code??"(none)"} ${mr(f)}`),Up(f,performance.now()-u)}}catch(n){U("post",n),Q({outcome:"error",err:nt(n)})}finally{Ht("post",Ke,"error")}}s(Hp,"runDetachedPoster");async function lO(e,t,n,r=fetch){let o=Np(e),i=Ni(t),a=uo(i.contentEncoding),c=wi(i.body);T(`POST event=${e} url=${Mt(n)} size=${c} encoding=${i.contentEncoding??"identity"} platform=${process.platform}`);let u=Date.now(),f=performance.now();try{let l=await r(n,{method:"POST",headers:a,body:i.body,signal:AbortSignal.timeout(o)});if(!l.ok&&i.contentEncoding==="gzip"&&(l.status===400||l.status===415)){try{await l.text()}catch{}T(`POST gzip rejected http=${l.status} \u2014 retrying uncompressed`),l=await r(n,{method:"POST",headers:uo(),body:t,signal:AbortSignal.timeout(o)})}let p=Date.now()-u,d=performance.now()-f;if(Es(d),l.ok)return T(`POST outcome=ok elapsed_ms=${p} http=${l.status}`),ue.info(`send ok http=${l.status}`),Q({outcome:"posted",postMs:d,http:l.status}),await Lp(l,n),!0;let m=(await l.text()).slice(0,vp).replace(/[\n\r]/g,"");return T(`POST outcome=fail elapsed_ms=${p} http=${l.status} body=${m}`),ue.error(`send fail http=${l.status} code=${l.status} body=${m}`),Q({outcome:"post_failed",postMs:d,http:l.status}),!1}catch(l){let p=Date.now()-u,d=performance.now()-f;Es(d);let m=Mp(l);return T(`POST outcome=fail elapsed_ms=${p} http=000 body=${m.message}`),ue.error(`send fail http=0 code=${m.code??"(none)"} ${mr(l)}`),Up(l,d),!1}}s(lO,"postCollector");async function Dp(e,t,n,r,o){let i=o.replaceAll(" ","_");try{let a=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});a.on("error",u=>{U(i,u)}),a.stdin.on("error",u=>{U(`${i}_stdin`,u)});let c=!1;return await new Promise(u=>{let f=setTimeout(()=>{if(!c){T(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`),ue.error(`failed where=${i} err=timeout message=stdin handoff timed out`);try{a.stdin.destroy()}catch{}}u()},Ka),l=s(()=>{c=!0,clearTimeout(f),u()},"done");a.stdin.end(n,()=>l()),a.stdin.once("error",()=>l())}),a.unref(),a}catch(a){let c=a instanceof Error?a.message:String(a);return T(`WARN: ${o} spawn failed open: ${c}`),U(i,a),null}}s(Dp,"spawnDetachedStdinChild");async function fO(e,t,n,r=Pp,o=cO){let i=Np(e),a=aO(n,i,t),{command:c,args:u}=o();return Dp(c,u,a,r,"detached post")}s(fO,"postCollectorDetached");async function Fp(e,t,n=Pp,r=wp){let{command:o,args:i}=r(tn,t);return Dp(o,i,e,n,"detached work")}s(Fp,"runHookDetached");async function nn(e,t,n,r,o,i,a,c){if(!o)return T("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),ue.error("send fail code=missing message=collector URL missing"),Q({outcome:"no_collector",err:"missing"}),!1;if(!ar(o))return T(`WARN: collector URL blocked (https required): ${Mt(o)}`),ue.error("send fail code=blocked message=collector URL blocked"),Q({outcome:"no_collector",err:"blocked"}),!1;let u=performance.now(),f=await sO(t,n.runnerPlatform,a),l=performance.now(),p=r(e,f,{...n,collectorUrl:o});i!==void 0&&(p.build_ms=Math.max(0,Date.now()-i));let d=cl({w4:u,w4e:l,w5:performance.now()},process.env,void 0,n.telemetry?.enabled===!0);d&&(p.perf=d);let m=JSON.stringify(p),_=c?.attach(Buffer.byteLength(m,"utf8"));_&&(p.run_log=_,m=JSON.stringify(p));let E=`${m}
51
+ `,C=D("EV_AI_HOOK_DEBUG");C==="full"?T(`DEBUG envelope=${m}`):C==="1"&&T(`DEBUG summary=${iO(p,wi(E))}`);let b=process.argv.includes(tn),k=D("EV_AI_HOOK_SYNC")==="1";if(!(kr(n.runnerEvent,n.runnerPlatform)||b||k)){let N=await fO(e,E,o);return Q(N?.pid!==void 0?{outcome:"handed_off"}:{outcome:"post_failed",err:"spawn"}),!1}return lO(e,E,o)}s(nn,"emitAndPost");import{closeSync as dO,fstatSync as pO,linkSync as mO,openSync as gO,readdirSync as _O,readSync as hO,renameSync as SO,unlinkSync as zp}from"node:fs";import{homedir as EO}from"node:os";import{basename as yO,dirname as RO}from"node:path";var $p=$o,jp=2*1024*1024,AO=Buffer.byteLength(',"run_log":',"utf8");function Bp(e){let t=`${e}.send-${process.pid}`;try{return SO(e,t),{path:e,taken:t}}catch(n){return n.code==="ENOENT"?"missing":"busy"}}s(Bp,"take");function Kp(e){return typeof e=="object"}s(Kp,"isTaken");function CO(e){let t=`${yO(e)}.`;try{return _O(RO(e)).some(n=>n.startsWith(t)&&/\.send-\d+$/.test(n))}catch{return!1}}s(CO,"anyTakenLog");function bO(e){try{mO(e.taken,e.path),zp(e.taken)}catch{}}s(bO,"putBack");function OO(e){try{zp(e)}catch{}}s(OO,"unlinkQuiet");function Gp(e,t){let n;try{n=gO(e,"r");let r=pO(n);if(!r.isFile())return;let o=Math.min(r.size,Math.max(0,t)),i=Buffer.alloc(o),a=0;for(;a<o;){let c=hO(n,i,a,o-a,r.size-o+a);if(c===0)break;a+=c}return{tail:i.subarray(0,a),size:r.size}}catch{return}finally{if(n!==void 0)try{dO(n)}catch{}}}s(Gp,"readTail");function xO(e){let t=e.indexOf(10);return t===-1?e:e.subarray(t+1)}s(xO,"fromFirstWholeLine");function Vp(e,t,n){Go(r=>{r[t]===n&&delete r[t]},e)}s(Vp,"forgetWindow");function Wp(e,t=EO(),n=process.env,r=Date.now()){try{let o=e?mt(e):void 0;if(!o||lc())return;let i=Ko(t)[o];if(i===void 0||i===Ut)return;let a=Date.parse(i);if(Number.isNaN(a)||a>r)return;let c=ic(t,n,r);if(c.on||c.source!=="remote")return;let u=pr(t),f=Bp(u),l=Bp(`${u}.1`),p=Kp(f)?f:void 0,d=Kp(l)?l:void 0,m=[d,p].filter(P=>P!==void 0),_=s(()=>{for(let P of m)bO(P)},"putAllBack"),E=p?Gp(p.taken,$p):void 0,C=d?Gp(d.taken,$p-(E?.tail.length??0)):void 0,b=(E?.size??0)+(C?.size??0);if(b===0){_(),f!=="busy"&&l!=="busy"&&!CO(u)&&Vp(t,o,i);return}let k=Buffer.concat([C?.tail??Buffer.alloc(0),E?.tail??Buffer.alloc(0)]),w=k.length<b,N=w?xO(k):k,I={log_until:i,text:N.toString("utf8"),bytes:N.length,bytes_total:b,truncated:w},$=AO+Buffer.byteLength(JSON.stringify(I),"utf8"),L=!1,O=!1;return{attach(P){if(P+$>jp){T(`run log deferred: body=${P} run_log=${$} over ${jp}`);return}return L=!0,I},settle(P){if(!O){if(O=!0,!(L&&P)){_();return}for(let H of m)OO(H.taken);Vp(t,o,i)}}}}catch(o){T(`WARN: run log upload failed open: ${o instanceof Error?o.message:String(o)}`);return}}s(Wp,"prepareRunLogUpload");import{createReadStream as IO}from"node:fs";import{stat as kO}from"node:fs/promises";import{basename as TO,resolve as PO}from"node:path";import{createInterface as NO}from"node:readline";var wO=1024*1024;function LO(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&TO(t).endsWith(".jsonl")}s(LO,"isSafeClaudeTranscriptPath");async function Jp(e){if(!e||!LO(e))return null;try{let t=PO(e),n=await kO(t);if(!n.isFile())return null;let r=Math.max(0,n.size-wO),o=[],i=NO({input:IO(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let a of i)a.length!==0&&o.push(a);r>0&&o.length>0&&o.shift();for(let a=o.length-1;a>=0;a--){let c=o[a];if(c)try{let u=JSON.parse(c);if(u.type!=="assistant")continue;let f=u.message;if(!f||typeof f!="object")continue;let l=f.model;if(typeof l=="string"&&l.length>0)return l}catch{continue}}return null}catch{return null}}s(Jp,"lastAssistantModelFromTranscript");var MO="EV_AI_HOOK_TELEMETRY";function Yp(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}s(Yp,"telemetryFromHomeConfig");function Xp(e,t,n=process.env){let r=n[MO]?.trim().toLowerCase();return r&&ft.has(r)?{enabled:!0,source:"env"}:r&&Yn.has(r)?{enabled:!1,source:"env"}:e!==void 0?{enabled:e,source:"local_config"}:t?.collect_telemetry!==void 0?{enabled:t.collect_telemetry,source:"org_config"}:{enabled:!0,source:"default"}}s(Xp,"resolveTelemetry");function fo(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:$r(e.manifest.manifest,e.manifest.hookConfig),telemetry:Qp(e)}}s(fo,"envelopeFieldsFromContext");function Qp(e){return Xp(e.manifest.localTelemetry,e.manifest.hookConfig)}s(Qp,"telemetryFor");function Bn(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}s(Bn,"operatorContextFrom");function vi(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:Ls(e.manifest.hookConfig)}}s(vi,"hookInputSanitizeOptions");async function em(e){let t=Date.now();await zO(e);let{gitRoot:n}=e.manifest;await Hi(e,n);let r=vi(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:Br(e.hookInput,e.manifest.manifest,r),envelopeFields:fo(e),launchCwd:Ms(e.hookInput,r),home:UO()}}s(em,"prepareDerivedInvoke");function qp(e){try{return Ae(vO(e))}catch{return null}}s(qp,"tryRealpath");function tm(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}s(tm,"isAbsolutePath");function Zp(e,t){let n=e.replaceAll("\\","/");if(!tm(n))return null;let r=Ae(e),o=Ae(t),i=qp(e)??r,a=qp(t)??o;return i.startsWith(`${a}/`)?i.slice(a.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}s(Zp,"relativeToAnchor");function nm(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),i=Zp(e,t)??(tm(r)?null:r),a=Zp(e,n);return{repositorySourcePath:i,userSourcePath:a}}s(nm,"sourcePathsFromResolvedFile");function Mi(e,t,n,r,o){return rm(e,nm(n,t.gitRoot,t.home),r,o)}s(Mi,"exactFileComponentFromResolvedPath");function rm(e,{repositorySourcePath:t,userSourcePath:n},r,o){let i=t??n,a=i===null?null:o(i),c=a!==null&&i!==null?HO({installableKind:r,sourcePath:i,nativeKey:a,inRepository:t!==null,platformAgentId:e.platformAgentId,installationId:e.manifest.installationId}):void 0;return{sourcePath:i,nativeKey:a,componentReference:c}}s(rm,"exactFileComponent");function HO(e){try{let t=e.inRepository?$O(e.platformAgentId,e.sourcePath):(0,V.installationRootExternalKey)(e.installationId,(0,V.userConfigRootFromPath)(e.sourcePath));return t?(0,V.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}s(HO,"tryExactFileComponentReference");function om(e){let t=e.policyFindings;return t===void 0||t.length===0?{}:{policy_findings:t,...e.policyJudgeSpawnMs!==void 0?{policy_judge_spawn_ms:e.policyJudgeSpawnMs}:{}}}s(om,"policyPayload");function Ui(e,t,n){return nn("tool_invoked",{...n,...om(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,Qt,e.manifest.collectorUrl,t.buildStartedAtMs,Bn(e,t.home))}s(Ui,"postDerivedToolInvoked");function DO(e){return Tu(e.runnerEvent,e.runnerPlatform)?[]:Jc(e.hookInput)}s(DO,"slashIdsFromHookInput");function FO(e,t){return Ui(e,t,{})}s(FO,"postPromptSubmitted");var sm=new Set([...Object.values(yt),".github"]);function $O(e,t){let n=e.indexOf(":");if(n<=0)return null;let r=e.slice(0,n),o=t.replaceAll("\\","/").split("/").filter(Boolean),i=o.findIndex(a=>sm.has(a));return i<0?null:`${r}:${o.slice(0,i+1).join("/")}`}s($O,"repositoryConfigRootExternalKey");var im=".codex/config.toml",jO=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",im]]);function BO(e,t,n,r,o,i,a){if(e===null||t===null||!(a!==null||/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||/^MCP:.+__.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`))return;let u=i.find(E=>E.name.toLowerCase()===t.toLowerCase()),f=u?jO.get(u.source):o==="codex"?im:void 0,l=u?.sourcePath??f;if((u?.scope==="user"||f!==void 0)&&l)try{let E=(0,V.userConfigRootFromPath)(l);return(0,V.buildComponentReference)({installationRootExternalKey:(0,V.installationRootExternalKey)(r,E),installableKind:V.ComponentKind.INTERFACE,sourcePath:l,nativeKey:u?.name??t})}catch{return}if(n===null)return;let d=n.indexOf(":");if(d<=0||d===n.length-1)return;let m=n.slice(d+1),_=m.replaceAll("\\","/").split("/").at(-1);if(!(_===void 0||!sm.has(_)))try{return(0,V.buildComponentReference)({installationRootExternalKey:n,installableKind:V.ComponentKind.INTERFACE,sourcePath:m,nativeKey:t})}catch{return}}s(BO,"exactMcpComponentReference");function KO(...e){for(let t of e)if(t)return t;return null}s(KO,"firstNonEmpty");function kt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return T(`WARN: ${n} failed open: ${r}`),U(n,e.reason),t}s(kt,"settledOr");function GO(e){let t={present:!1,size:0},n={hash:"",count:0};return{config:{runner_platform:e,config_scope:"user",cli_version:null,claude_version:null,model:null,permission_keys:[],user_scope:{skills:n,subagents:n,commands:n,rules:n,memory:t,settings:t,mcp:t},local_settings:t},commit:s(()=>{},"commit")}}s(GO,"emptySelfConfigResult");function VO(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}s(VO,"cloudBootstrapSelfConfig");var It=new Set,jn=null;async function zO(e){if(Zt())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(It.has(t))return;if(!ks(n)){It.add(t);return}let r=cn({sessionId:e.sessionId,hostname:qn()});if(Dl(r)){if(jn){await jn;return}jn=(async()=>{if(It.has(t)||!ks(n)){It.add(t);return}if(!Tc(n)){It.add(t);return}let o=!1;try{let i=Date.now(),{gitRoot:a}=e.manifest,c=String(e.runnerPlatform),{operatorResolved:u,fields:f}=await am(e,r,ve("git",()=>xr(a)),ve("operator",()=>Is({gitRoot:a,installationStorePath:n,forceResend:!1,runnerPlatform:c}))),l={...f,self_config:VO(c,u.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await nn("session_start",l,fo(e),Qt,e.manifest.collectorUrl,i,Bn(e)),o&&(u.commit(),It.add(t))}finally{Pc(n)}})().finally(()=>{jn=null}),await jn}}s(zO,"maybeBootstrapCloudIdentity");async function Hi(e,t,n){try{e.platformAgentId=await Eu(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,n,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);T(`WARN: derivePlatformAgentId failed open: ${o}`),U("platform_agent_id",r)}}s(Hi,"resolvePlatformAgentId");async function am(e,t,n,r){let[o,i,a,c,u]=await Promise.allSettled([n,ve("virt",()=>sa()),ve("cloud",()=>ll(t)),ve("host_env",()=>aa(Qp(e).enabled)),r]),f=kt(o,null,"gitSnapshot"),l=kt(i,"","detectVirt"),p=kt(a,null,"probeCloud"),d=kt(c,{},"hostEnv"),m=kt(u,{commit:s(()=>{},"commit")},"resolveOperatorForSend");return await Hi(e,e.manifest.gitRoot,f),{operatorResolved:m,fields:{identity:{host:qn(),context:t,virt:l||null,cloud:p,git:f},host_env:d,env_vars:hl()}}}s(am,"collectIdentityPayload");async function WO(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=cn({sessionId:e.sessionId,hostname:qn()}),o=String(e.runnerPlatform),i=vi(e),a=Ms(e.hookInput,i),c=ve("git",()=>xr(n)),u=bp().catch(L=>(U("launcher_fields",L),{})),f=Zt()?Promise.resolve({commit:s(()=>{},"commit")}):ve("operator",()=>Is({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o})),l=am(e,r,c,f),[p,d]=await Promise.allSettled([ve("mcp_declared",()=>Rs(e.manifest.manifest,n,o)),c.catch(()=>null).then(L=>ve("self_config",()=>fp(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:a,inGitRepo:e.manifest.inGitRepo,remote:L?.remote??null})))]),{operatorResolved:m,fields:_}=await l,E=kt(p,[],"mcpDeclared"),C=kt(d,GO(o),"selfConfig"),b=C.config,k=F(e.hookInput,"model");k&&(b.model=k);let w={..._,mcp:{declared:E},self_config:b,run_meta:{trigger:e.hookSource||"startup"},hook_input:Br(e.hookInput,e.manifest.manifest,{...i,launchCwd:a})},N=await u,I=Wp(e.manifest.collectorUrl),$=!1;try{$=await nn("session_start",w,{...fo(e),...N},Qt,e.manifest.collectorUrl,t,Bn(e),I)}finally{I?.settle($)}$&&(C.commit(),m.commit(),It.add(e.manifest.installationId))}s(WO,"handleSessionStart");async function JO(e){let t=Date.now(),[,n]=await Promise.all([Hi(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?Jp(F(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=KO(F(e.hookInput,"status"),F(e.hookInput,"stop_reason"),F(e.hookInput,"reason"),Rn(F(e.hookInput,"error")),r==="stop"?Be(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),i=Br(e.hookInput,e.manifest.manifest,vi(e));n&&(i.model=n),r!=="stopfailure"&&$r(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&i.last_assistant_message===void 0&&(i.last_assistant_message=""),await nn("session_end",{status:o,...n?{model:n}:{},hook_input:i},fo(e),Qt,e.manifest.collectorUrl,t,Bn(e))}s(JO,"handleSessionEnd");async function YO(e){let t=DO(e),n=Cu(e.hookInput),r=ku(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&$r(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let i=await em(e);await Promise.all([o?FO(e,i):void 0,t.length===0?void 0:XO(e,i,t),n.length===0?void 0:qO(e,i,n)])}s(YO,"handleSkillInvoked");function cm(e,t,n,r){let o=r??Wc({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),i=Mi(e,t,o,V.ComponentKind.SKILL,V.nativeKeyForSkillPath);if(i.sourcePath!==null&&qo(i.sourcePath)?.toLowerCase()===n.toLowerCase())return i.componentReference===void 0?{}:{componentReference:i.componentReference};let a=r??bu({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),c=Mi(e,t,a,V.ComponentKind.COMMAND,V.nativeKeyForCommandPath);return c.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:c.nativeKey,...c.componentReference===void 0?{}:{componentReference:c.componentReference}}}s(cm,"slashComponentIdentity");function XO(e,t,n){let r=Er(e.hookInput.tool_input);return Promise.all(n.map(o=>{let i=cm(e,t,o,r);return Ui(e,t,{tool_name:"Skill",skill_name:o,...i.commandName===void 0?{}:{command_name:i.commandName},...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(XO,"postSkillInvokes");function qO(e,t,n){return Promise.all(n.map(r=>{let o=yu({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),i=Mi(e,t,o,V.ComponentKind.RULE,V.nativeKeyForRulePath),a=i.nativeKey??Au(r);return Ui(e,t,{tool_name:"Rule",rule_name:a,...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(qO,"postRuleInvokes");var ZO=[{kind:V.ComponentKind.SKILL,nativeKeyFn:V.nativeKeyForSkillPath},{kind:V.ComponentKind.RULE,nativeKeyFn:V.nativeKeyForRulePath},{kind:V.ComponentKind.COMMAND,nativeKeyFn:V.nativeKeyForCommandPath}];function QO(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Qo(e.hookInput);if(r===null)return n.skillName===null?{}:cm(e,t,n.skillName,null);let o=nm(r,t.gitRoot,t.home);for(let i of ZO){let a=rm(e,o,i.kind,i.nativeKeyFn);if(a.nativeKey!==null)return{...a.componentReference===void 0?{}:{componentReference:a.componentReference},...i.kind===V.ComponentKind.RULE?{ruleName:a.nativeKey}:{},...i.kind===V.ComponentKind.COMMAND?{commandName:a.nativeKey}:{}}}return{}}s(QO,"toolComponentIdentity");var ex=/mcp/i;function tx(e,t,n,r){let o=ex.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let i=o?Pd(t,n):to(r.declaredConfig,n);return i===null?{}:Object.fromEntries(Object.entries(i).filter(a=>typeof a[1]=="string").map(([a,c])=>[`mcp_${a}`,c]))}s(tx,"mcpPackageFields");async function nx(e){let t=await em(e),n=wu(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,i=Zo(e.hookInput),a=kd(i,t.home),c=Mu(e.hookInput),u=Pu(e.runnerEvent),f=u===!1?vu(e.hookInput,e.runnerEvent):null,l=Rn(F(e.hookInput,"mcp_server_name")),p=l!==null||r!==null&&Pr(r)?await Rs(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch($=>(U("mcpDeclared",$),[])):[],{mcpServer:d,mcpTool:m}=Hu(r,p.map($=>$.name),l??""),_=BO(r,d,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),p,l),E=_===void 0?QO(e,t,n):{},C=d===null?null:_l(d,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),b=tx(e,i,t.home,{hasMcpIdentity:!!d||!!m,declaredConfig:C}),k=_??E.componentReference,w=E.ruleName??n.ruleName,N=E.commandName??n.commandName,I=Lu(e.hookInput);await nn("tool_invoked",{tool_name:r,skill_name:o,...w?{rule_name:w}:{},...N?{command_name:N}:{},success:u,duration_ms:c,...a?{executable:a}:{},...f?{failure_reason:f}:{},...d?{mcp_server:d}:{},...m?{mcp_tool:m}:{},...b,...k?{component_reference:k}:{},...I?{subagent_type:I}:{},...om(e),hook_input:t.hookInput},t.envelopeFields,Qt,e.manifest.collectorUrl,t.buildStartedAtMs,Bn(e,t.home))}s(nx,"handleToolInvoked");async function um(e){switch(Ge("w3"),e.internalEvent){case"session_start":await WO(e);return;case"session_end":await JO(e);return;case"skill_invoked":await YO(e);return;case"tool_invoked":await nx(e);return;default:return}}s(um,"dispatchInternalEvent");import{existsSync as Fi,readFileSync as rx}from"node:fs";import{dirname as ox,isAbsolute as sx,join as ix,relative as ax}from"node:path";function lm(e){for(let t of Ma){let n=ix(e,t);if(Fi(n))return n}}s(lm,"firstExistingManifest");async function cx(e=process.cwd(),t){let n=t??await Oo(e);return lm(n)??lm(e)}s(cx,"findRepoManifestPath");async function ux(e,t){let n=t??await Oo(ox(e)),r=ax(n,e);if(r.startsWith("..")||sx(r))return!1;let o=await Oe("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(T(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}s(ux,"isManifestGitTracked");function Di(e){let t=rx(e,"utf8");return xe(Tt(t),{})}s(Di,"loadRepoManifestFromFile");function lx(){return{schema_version:cr,mcp_servers:[]}}s(lx,"defaultSharedManifest");function fx(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(T(`WARN: ignoring capture_hook_input=full in git-tracked manifest ${t}; use EV_AI_HOOK_CAPTURE_FULL_INPUT=1 or an untracked operator manifest`),delete e.capture_hook_input),e.debug===!0&&r.has("debug")&&(T(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}s(fx,"stripTrackedUnsafeFields");function dx(e){let t=Fa({argv:e.argv,env:process.env,homeConfig:e.homeConfig,manifest:e.manifest,manifestSource:e.manifestSource});for(let r of t.warnings){T(`WARN: ignoring ${r.label}: ${r.problem}`);let o=r.label.replace(/\s+/g,"_"),i=r.problem.replace(/\/[^/\s]+\/hook\b/g,"/***/hook");ue.error(`collector ignored label=${o} message=${i}`)}let n=t.url??"";return ue.info(`collector source=${t.source} url=${n?Mt(n):"(none)"}`),n}s(dx,"collectorUrlFromLoaded");function px(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}s(px,"recordOrUndefined");async function fm(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await bo(e),o=D("EV_AI_HOOK_MANIFEST"),i=o&&Fi(o)?o:void 0,a=i?void 0:Fi(pt())?pt():void 0,c=i?void 0:await cx(e,n),u=a?Di(a):void 0,f=c?Di(c):void 0,l=Yp(i?Z(pt(),{}):u),p,d,m,_=new Set;if(i){p=Di(i),d=i,m=i;for(let I of Object.keys(p))_.add(I)}else if(u&&f){p=Ua(f,u),d=a,m=c;for(let I of Object.keys(f))I in u||_.add(I)}else if(u)p=u,d=a;else if(f){p=f,d=c,m=c;for(let I of Object.keys(f))_.add(I)}else p=lx();delete p.installation_id;let E=m?await ux(m,n):!1;fx(p,m,E,_);let{installationId:C,storePath:b,repoKey:k}=await Mc(n,{sessionId:t.sessionId}),w=u??px(Z(pt(),null)),N=dx({argv:t.argv??process.argv,homeConfig:w,manifest:i?p:f,manifestSource:i?"manifest_override":"manifest"});return{manifestPath:d??b,manifest:p,installationId:C,installationStorePath:b,repoKey:k,collectorUrl:N,hookConfig:Ip(N),...l!==void 0?{localTelemetry:l}:{},platformAgentId:p.platform_agent_id??"",gitRoot:n,inGitRepo:r}}s(fm,"loadManifest");import{mkdirSync as mx,readdirSync as gx,readFileSync as _x,statSync as dm,unlinkSync as hx,writeFileSync as Sx}from"node:fs";import{homedir as po}from"node:os";import{join as $i}from"node:path";var Ex="turns",pm=1440*60*1e3,yx=100,Rx=new Set(["stop","stopfailure","sessionend"]);function ji(e=po()){return $i(Ee(e),Ex)}s(ji,"sessionTurnDir");function mm(e,t){return $i(e,an(t))}s(mm,"sessionTurnPath");function Ax(e,t=Date.now()){let n;try{n=gx(e)}catch{return}let r=0;for(let o of n){if(r>=yx)return;r+=1;try{let i=$i(e,o);t-dm(i).mtimeMs>pm&&hx(i)}catch{}}}s(Ax,"pruneStaleSessionTurns");function Cx(e,t,n=po()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let i=ji(n);mx(i,{recursive:!0}),Sx(mm(i,r),o,"utf8")}catch{}}s(Cx,"rememberSessionTurn");function bx(e,t=po()){let n=e.trim();if(!n)return"";try{let r=mm(ji(t),n);return Date.now()-dm(r).mtimeMs>pm?"":_x(r,"utf8").trim()}catch{return""}}s(bx,"recallSessionTurn");function gm(e,t,n,r=po()){let o=t.trim(),i=Rx.has(n.trim().toLowerCase());return i&&Ax(ji(r)),o?(Cx(e,o,r),o):i?bx(e,r):""}s(gm,"resolveTurnId");function Em(e){let t=xe(e,{});return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}s(Em,"parseHookInput");async function Ox(e,t,n){let r=t??await Xn(ur),o=Em(r),i=await fm(process.cwd(),{sessionId:Gt(o)});if(Ge("w2"),!i){Q({outcome:"no_manifest"});return}let a=Nu(o,i.manifest.platform,n),c=Tr(e,a.runnerEvent);if(!c){T(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`),Q({outcome:"unknown_event"});return}Q({runner:a.runnerPlatform,event:c,session:a.sessionId});let u={hookInput:o,sessionId:a.sessionId,turnId:gm(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await um(u)}s(Ox,"runHook");function xx(e,t=!1){if(D("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,i=Kt(r,o,void 0,n.runner);return kr(o,i)?!0:t}s(xx,"shouldRunHookInProcess");function _m(e,t){let n=sr(e),r=Em(t),o=n.event??cs(r);return ra()||Iu(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}s(_m,"preflight");function ym(e){return Yu(Tr(e.parsed.event,e.runnerEvent))}s(ym,"isCapExempt");async function hm(e,t,n){let{parsed:r}=e,o=n??ms(r.slot);if(!o&&!ym(e)){let i=ps(r.cap),a=tl(i);if(!a){gs(i),Q({outcome:"cap_dropped"});return}o=a}try{await Ox(r.event,t,r.runner)}finally{o&&Lr(o)}}s(hm,"runHookInSlot");var mo,rn=!1,Ix=500;function kx(){let e=s(()=>{process.exit(0)},"exitNow");setTimeout(e,Ix);try{process.stdout.write('{"continue":true}',e)}catch{e()}}s(kx,"ackThenExit");function go(e,t){let n=e[0]===tn?"w":e[0]===lo?"post":"h";mo=void 0,rn=!1;let r=s(a=>c=>{try{U(a,c),fc()||(Q({outcome:"error",err:nt(c)}),Ht(mo??n,Ke,"error"))}catch{}if(t){if(n==="h"&&!rn){rn=!0,kx();return}process.exit(0)}},"onCrash"),o=r("uncaught"),i=r("unhandled_rejection");return process.on("uncaughtException",o),process.on("unhandledRejection",i),()=>{process.off("uncaughtException",o),process.off("unhandledRejection",i)}}s(go,"installCrashLogging");async function _o(e=process.argv.slice(2),t=!1){if(t||uc(e),Xa(),mo=void 0,rn=!1,Ge(e[0]===tn?"w0":"h0"),nl(),D("EV_AI_HOOK_JUDGE")==="1"){try{await Xn(ur)}catch{}return Ao(),rn=!0,0}if(e[0]===lo){try{await Hp(Co)}catch{}return 0}if(e[0]===tn){let i=!1;try{let a=await Co();Ge("w1");let c=_m(e.slice(1),a);if(!c)return Q({outcome:"suppressed"}),0;Sm(c),i=Tr(c.parsed.event,c.runnerEvent)==="session_start",await hm(c,a)}catch(a){let c=a instanceof Error?a.message:String(a);T(`WARN: detached work failed open: ${c}`),U("work",a),Q({outcome:"error",err:nt(a)})}finally{Ht("w",Ke,"no_post"),i&&pc()}return 0}let n,r="error",o=!1;try{dc();let i=await Xn(ur);Ge("h1");let a=_m(e,i);if(!a)return r="suppressed",0;Sm(a);let{parsed:c,hookInput:u,runnerEvent:f}=a;if(n=ms(c.slot),!Bu(u,f,c.runner))return r="duplicate",0;if(Ge("h2"),xx(a))o=!0,mo="inproc",r="no_post",await hm(a,i,n);else{let l=n||ym(a)?void 0:ps(c.cap);if(l===void 0||Qu(l)){Ge("h3"),il();let p=await Fp(i,e);n&&p?.pid!==void 0&&qu(n,p.pid),p?.pid!==void 0?r="handed_off":(r="error",Q({err:"spawn"}))}else gs(l),r="cap_dropped"}}catch(i){let a=i instanceof Error?i.message:String(i);T(`WARN: hook failed open: ${a}`),U("hook",i),r="error",Q({outcome:"error",err:nt(i)})}finally{n&&Lr(n),Ao(),rn=!0,Q({ackMs:performance.now()}),Ht(o?"inproc":"h",Ke,r)}return 0}s(_o,"main");function Sm({parsed:e,hookInput:t,runnerEvent:n}){Q({runner:Kt(t,n,void 0,e.runner),event:n,session:Gt(t),tool:typeof t.tool_name=="string"?t.tool_name:void 0})}s(Sm,"noteInvocation");var Tx=Symbol.for(ma);function Rm(){return globalThis[Tx]===!0}s(Rm,"isLoadedByLauncher");async function Px(e){Ro(e);let t=go(e.argv,!1);try{return await _o(e.argv)}finally{t(),Ro(void 0)}}s(Px,"runInLauncher");Rm()||(go(process.argv.slice(2),!0),_o().then(e=>{process.exit(e)}).catch(e=>{U("entry",e);let t=e instanceof Error?e.message:String(e);process.stderr.write(`[ev-ai-agent-hook] ${t}
52
+ `),process.exit(1)}));export{Px as runInLauncher};