@ev-ai/agent-hook 1.3.9 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COLLECTED-DATA.md +9 -5
- package/README.md +25 -4
- package/dist/cli.mjs +51 -43
- package/dist/hook.mjs +47 -39
- package/dist/launcher-update.mjs +11 -4
- package/dist/launcher.mjs +6 -6
- package/dist/managed-hooks-snippet.cjs +70 -4
- package/dist/managed-hooks-snippet.d.ts +1 -0
- package/dist/managed-hooks-snippet.mjs +67 -3
- package/dist/plugin-hooks.mjs +10 -2
- package/package.json +4 -3
package/dist/hook.mjs
CHANGED
|
@@ -1,50 +1,58 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module';
|
|
2
2
|
const require = __createRequire(import.meta.url);
|
|
3
3
|
|
|
4
|
-
var Pp=Object.create;var mi=Object.defineProperty;var Np=Object.getOwnPropertyDescriptor;var wp=Object.getOwnPropertyNames;var Mp=Object.getPrototypeOf,vp=Object.prototype.hasOwnProperty;var Ve=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Lp=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of wp(t))!vp.call(e,o)&&o!==n&&mi(e,o,{get:()=>t[o],enumerable:!(r=Np(t,o))||r.enumerable});return e};var ze=(e,t,n)=>(n=e!=null?Pp(Mp(e)):{},Lp(t||!e||!e.__esModule?mi(n,"default",{value:e,enumerable:!0}):n,e));var Zn=z(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.MCP_MISSING_LAUNCH_SERIALIZED=Z.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;Z.foldMcpName=rc;Z.buildMcpFamilyCanonicalKey=Ug;Z.launchContainsCredentials=Fg;Z.serializeMcpLaunchIdentity=oc;Z.hashMcpLaunchIdentity=qt;Z.projectMcpMissingLaunchIdentity=Kg;Z.projectMcpLaunchIdentity=Bg;Z.maskMcpLaunchForDisplay=Vg;Z.normalizeMcpToolNames=zg;var Hg=Ve("node:crypto");Z.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";Z.MCP_MISSING_LAUNCH_SERIALIZED=`${Z.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function De(e){return e.toLocaleLowerCase("en-US")}function rc(e){return De(e)}function Ug(e){return`interface:${rc(e)}`}var nc=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),Dg=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function Ot(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Fg(e){return e.kind==="url"?$g(e.url):e.kind==="command"?e.arguments.some(t=>Dg.test(t)):!1}function $g(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(nc.has(De(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=De(i.split("=",1)[0]??"");return nc.has(a)})}}function oc(e){if(e.kind==="url")return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",Ot(De(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>De(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",Ot(De(e.command)),String(t.length),...t.map(Ot)].join("|")}return[Z.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",Ot(e.installationRootExternalKey),Ot(e.sourcePath),Ot(e.nativeKey)].join("|")}function qt(e){return(0,Hg.createHash)("sha256").update(e).digest("hex")}var jg=qt(Z.MCP_MISSING_LAUNCH_SERIALIZED);function Kg(){return{kind:"unknown",arguments:[],serialized:Z.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:jg}}function Bg(e){let t=oc(e);return e.kind==="url"?{kind:"url",url:De(e.url),arguments:[],serialized:t,contentHash:qt(t)}:e.kind==="command"?{kind:"command",command:De(e.command),arguments:[...e.arguments].map(n=>De(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:qt(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:qt(t)}}var Gg=/^(https?:\/\/)([^/?#]*@)/i;function Vg(e){return e.replace(Gg,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}function zg(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 er=z(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Te.PACKAGE_FIELD_MAX=void 0;Te.npxExecBin=sc;Te.packageNameFromSpec=Qn;Te.pinnedPackageVersionFromSpec=ic;Te.pinnedPackageVersionFromNpx=t_;Te.npxPackageSpecs=ac;Te.PACKAGE_FIELD_MAX=128;var Wg=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,Jg=new Set(["-p","--package"]),Yg=new Set(["-c","--call"]),Xg=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),qg=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),Zg=/^--no-/;function Qg(e){return qg.has(e)||Zg.test(e)}function sc(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}var e_=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function Qn(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 Wg.test(n)?n:null}function ic(e){let t=Qn(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return e_.test(n)?n:void 0}function t_(e,t){for(let n of ac(e,t)){let r=ic(n);if(r!==void 0)return r}}function ac(e,t){let n=sc(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(Yg.has(l))return[];if(Jg.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||Qg(l))){if(Xg.has(l)){i+=1;continue}return[]}}return o.length>0?o.every(i=>Qn(i)!==null)?o:[]:s===null||Qn(s)===null?[]:[s]}});var cc=z(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.McpPackageEcosystem=void 0;it.resolveMcpPackageIdentity=m_;var n_=Zn(),Ro=er();it.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var r_=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,o_=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,s_=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function i_(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}var a_=new Set(["--from","--spec"]),c_=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"]),u_=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"]),l_=/^--no-/;function f_(e,t){let n=i_(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(a_.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||u_.has(l)||l_.test(l))){if(c_.has(l)){i+=1;continue}return null}}return o??s}function d_(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!o_.test(r)||!s_.test(o)?null:{ecosystem:it.McpPackageEcosystem.PYPI,packageName:r,version:o}}function p_(e){let t=(0,Ro.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return r_.test(n)?{ecosystem:it.McpPackageEcosystem.NPM,packageName:t,version:n}:null}function m_(e){if(e?.kind!=="command"||(0,n_.launchContainsCredentials)(e))return;for(let n of(0,Ro.npxPackageSpecs)(e.command,e.arguments)){let r=p_(n);if(r!==null)return r}let t=f_(e.command,e.arguments);if(t!==null)return d_(t)??void 0}});var mc=z(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.EMPTY_NPM_PUBLISHER=void 0;Fe.isNpmRegistryPublisher=__;Fe.displayPublisherName=h_;Fe.classifyMcpProvenance=x_;var fc=Zn(),Co=er();Fe.EMPTY_NPM_PUBLISHER="npm:";var uc="npm:",g_=/^[A-Za-z0-9._-]+$/;function __(e){return e.startsWith(uc)&&e!==Fe.EMPTY_NPM_PUBLISHER&&g_.test(e.slice(uc.length))}function h_(e){if(!(e==null||e===""||e===Fe.EMPTY_NPM_PUBLISHER))return e}function lc(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 S_(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 E_(e){let t=Ao(e),n=S_(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||lc(t)||n!==void 0&&lc(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}function y_(e){let t=Ao(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}function R_(e){let t=Ao(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}function dc(e){let t={kind:"url",url:e};if((0,fc.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||E_(n.hostname))return{origin:"UNKNOWN"};let r=y_(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:R_(n)}}catch{return{origin:"UNKNOWN"}}}var pc="mcp-remote";function C_(e,t){if(e===pc)return t.find(n=>/^https?:\/\//i.test(n))}function A_(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}function b_(e,t,n){let r=C_(e,t);return r!==void 0?dc(r):e===pc?{origin:"UNKNOWN"}:A_(e,n)}function O_(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 x_(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,fc.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return dc(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=b_(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 O_(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}});var _c=z(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.mcpServerToolSegmentForms=gc;tr.mcpServerNameMatchesToolSegment=I_;function gc(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}function I_(e,t){let n=t.toLowerCase();return gc(e).some(r=>r.toLowerCase()===n)}});var hc=z(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.parseFrontmatterField=Ce.parseFrontmatterDescription=Ce.usableCatalogText=void 0;var k_=/^(?:>|\|)[-+]?$/,T_=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,P_=e=>{let t=e?.trim()??"";if(!(t.length===0||k_.test(t)))return t};Ce.usableCatalogText=P_;var N_=e=>(0,Ce.parseFrontmatterField)(e,"description");Ce.parseFrontmatterDescription=N_;var w_=(e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return v_(n[1],t)};Ce.parseFrontmatterField=w_;var M_=e=>e.replace(/^["']|["']$/g,"");function v_(e,t){let n=e.split(`
|
|
5
|
-
`),r=`${t}:`,o=n.findIndex(
|
|
6
|
-
`).split(/\n{2,}/).map(
|
|
7
|
-
`).map(g=>g.trim()).filter(Boolean).join(" ")).filter(
|
|
4
|
+
var Dm=Object.create;var Eo=Object.defineProperty;var Fm=Object.getOwnPropertyDescriptor;var $m=Object.getOwnPropertyNames;var Bm=Object.getPrototypeOf,jm=Object.prototype.hasOwnProperty;var s=(e,t)=>Eo(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 Km=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $m(t))!jm.call(e,o)&&o!==n&&Eo(e,o,{get:()=>t[o],enumerable:!(r=Fm(t,o))||r.enumerable});return e};var Ze=(e,t,n)=>(n=e!=null?Dm(Bm(e)):{},Km(t||!e||!e.__esModule?Eo(n,"default",{value:e,enumerable:!0}):n,e));var Ar=J(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.MCP_MISSING_LAUNCH_SERIALIZED=te.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;te.foldMcpName=su;te.buildMcpFamilyCanonicalKey=vh;te.launchContainsCredentials=Uh;te.serializeMcpLaunchIdentity=iu;te.hashMcpLaunchIdentity=Rn;te.projectMcpMissingLaunchIdentity=Fh;te.projectMcpLaunchIdentity=$h;te.maskMcpLaunchForDisplay=jh;te.normalizeMcpToolNames=Kh;var Lh=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 su(e){return Ve(e)}s(su,"foldMcpName");function vh(e){return`interface:${su(e)}`}s(vh,"buildMcpFamilyCanonicalKey");var ou=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),Mh=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function Kt(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(Kt,"lengthPrefixed");function Uh(e){return e.kind==="url"?Hh(e.url):e.kind==="command"?e.arguments.some(t=>Mh.test(t)):!1}s(Uh,"launchContainsCredentials");function Hh(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(ou.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 ou.has(c)})}}s(Hh,"urlContainsCredentials");function iu(e){if(e.kind==="url")return[te.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",Kt(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",Kt(Ve(e.command)),String(t.length),...t.map(Kt)].join("|")}return[te.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",Kt(e.installationRootExternalKey),Kt(e.sourcePath),Kt(e.nativeKey)].join("|")}s(iu,"serializeMcpLaunchIdentity");function Rn(e){return(0,Lh.createHash)("sha256").update(e).digest("hex")}s(Rn,"hashMcpLaunchIdentity");var Dh=Rn(te.MCP_MISSING_LAUNCH_SERIALIZED);function Fh(){return{kind:"unknown",arguments:[],serialized:te.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:Dh}}s(Fh,"projectMcpMissingLaunchIdentity");function $h(e){let t=iu(e);return e.kind==="url"?{kind:"url",url:Ve(e.url),arguments:[],serialized:t,contentHash:Rn(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:Rn(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:Rn(t)}}s($h,"projectMcpLaunchIdentity");var Bh=/^(https?:\/\/)([^/?#]*@)/i;function jh(e){return e.replace(Bh,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}s(jh,"maskMcpLaunchForDisplay");function Kh(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(Kh,"normalizeMcpToolNames")});var br=J(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.PACKAGE_FIELD_MAX=void 0;ve.npxExecBin=au;ve.packageNameFromSpec=Cr;ve.pinnedPackageVersionFromSpec=cu;ve.pinnedPackageVersionFromNpx=Zh;ve.npxPackageSpecs=uu;ve.PACKAGE_FIELD_MAX=128;var Gh=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,Vh=new Set(["-p","--package"]),zh=new Set(["-c","--call"]),Wh=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),Jh=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),Yh=/^--no-/;function Xh(e){return Jh.has(e)||Yh.test(e)}s(Xh,"booleanFlag");function au(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}s(au,"npxExecBin");var qh=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function Cr(e){if(e.length===0||e.length>ve.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return Gh.test(n)?n:null}s(Cr,"packageNameFromSpec");function cu(e){let t=Cr(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return qh.test(n)?n:void 0}s(cu,"pinnedPackageVersionFromSpec");function Zh(e,t){for(let n of uu(e,t)){let r=cu(n);if(r!==void 0)return r}}s(Zh,"pinnedPackageVersionFromNpx");function uu(e,t){let n=au(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(zh.has(f))return[];if(Vh.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||Xh(f))){if(Wh.has(f)){a+=1;continue}return[]}}return o.length>0?o.every(a=>Cr(a)!==null)?o:[]:i===null||Cr(i)===null?[]:[i]}s(uu,"npxPackageSpecs")});var lu=J(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.McpPackageEcosystem=void 0;Rt.resolveMcpPackageIdentity=fS;var Qh=Ar(),rs=br();Rt.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var eS=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,tS=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,nS=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function rS(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}s(rS,"pythonRunnerBin");var oS=new Set(["--from","--spec"]),sS=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"]),iS=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"]),aS=/^--no-/;function cS(e,t){let n=rS(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(oS.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||iS.has(f)||aS.test(f))){if(sS.has(f)){a+=1;continue}return null}}return o??i}s(cS,"pythonRunnerSpec");function uS(e){if(e.length===0||e.length>rs.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!tS.test(r)||!nS.test(o)?null:{ecosystem:Rt.McpPackageEcosystem.PYPI,packageName:r,version:o}}s(uS,"pypiIdentityFromSpec");function lS(e){let t=(0,rs.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return eS.test(n)?{ecosystem:Rt.McpPackageEcosystem.NPM,packageName:t,version:n}:null}s(lS,"npmIdentityFromSpec");function fS(e){if(e?.kind!=="command"||(0,Qh.launchContainsCredentials)(e))return;for(let n of(0,rs.npxPackageSpecs)(e.command,e.arguments)){let r=lS(n);if(r!==null)return r}let t=cS(e.command,e.arguments);if(t!==null)return uS(t)??void 0}s(fS,"resolveMcpPackageIdentity")});var _u=J(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.EMPTY_NPM_PUBLISHER=void 0;ze.isNpmRegistryPublisher=pS;ze.displayPublisherName=mS;ze.classifyMcpProvenance=CS;var pu=Ar(),os=br();ze.EMPTY_NPM_PUBLISHER="npm:";var fu="npm:",dS=/^[A-Za-z0-9._-]+$/;function pS(e){return e.startsWith(fu)&&e!==ze.EMPTY_NPM_PUBLISHER&&dS.test(e.slice(fu.length))}s(pS,"isNpmRegistryPublisher");function mS(e){if(!(e==null||e===""||e===ze.EMPTY_NPM_PUBLISHER))return e}s(mS,"displayPublisherName");function du(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(du,"privateIpv4");function gS(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(gS,"ipv4MappedAddress");function ss(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}s(ss,"normalizedHost");function _S(e){let t=ss(e),n=gS(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||du(t)||n!==void 0&&du(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}s(_S,"privateHostname");function hS(e){let t=ss(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}s(hS,"publisherHost");function SS(e){let t=ss(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}s(SS,"publicOrigin");function mu(e){let t={kind:"url",url:e};if((0,pu.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||_S(n.hostname))return{origin:"UNKNOWN"};let r=hS(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:SS(n)}}catch{return{origin:"UNKNOWN"}}}s(mu,"classifyUrl");var gu="mcp-remote";function ES(e,t){if(e===gu)return t.find(n=>/^https?:\/\//i.test(n))}s(ES,"remoteUrlChild");function yS(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}s(yS,"thirdPartyPackage");function RS(e,t,n){let r=ES(e,t);return r!==void 0?mu(r):e===gu?{origin:"UNKNOWN"}:yS(e,n)}s(RS,"classifyRegistryPackage");function AS(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(AS,"isRepoRelativeCommand");function CS(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,pu.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return mu(t.url);let r=(0,os.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,os.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let i=RS(o,t.arguments,e.publisherName),a=typeof e.packageName=="string"?(0,os.packageNameFromSpec)(e.packageName):null;return a!==null&&a===o&&i.packageName!==void 0?{...i,packageName:a,packageKey:a}:i}return AS(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}s(CS,"classifyMcpProvenance")});var Su=J(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.mcpServerToolSegmentForms=hu;xr.mcpServerNameMatchesToolSegment=bS;function hu(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}s(hu,"mcpServerToolSegmentForms");function bS(e,t){let n=t.toLowerCase();return hu(e).some(r=>r.toLowerCase()===n)}s(bS,"mcpServerNameMatchesToolSegment")});var Eu=J(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.parseFrontmatterField=Ie.parseFrontmatterDescription=Ie.usableCatalogText=void 0;var xS=/^(?:>|\|)[-+]?$/,OS=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,IS=s(e=>{let t=e?.trim()??"";if(!(t.length===0||xS.test(t)))return t},"usableCatalogText");Ie.usableCatalogText=IS;var kS=s(e=>(0,Ie.parseFrontmatterField)(e,"description"),"parseFrontmatterDescription");Ie.parseFrontmatterDescription=kS;var TS=s((e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return NS(n[1],t)},"parseFrontmatterField");Ie.parseFrontmatterField=TS;var PS=s(e=>e.replace(/^["']|["']$/g,""),"stripYamlQuotes");function NS(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=OS.exec(i);if(!a){let m=PS(i).trim();return(0,Ie.usableCatalogText)(m)}let c=[];for(let m=o+1;m<n.length;m+=1){let g=n[m]??"";if(g.trim()===""){c.push("");continue}if(g.length===g.trimStart().length)break;c.push(g)}let u=c.reduce((m,g)=>g.trim()===""?m:Math.min(m,g.length-g.trimStart().length),Number.POSITIVE_INFINITY),f=[],l=a[1]?.trim();l&&f.push(l);for(let m of c)f.push(m.trim()===""?"":m.slice(u));for(;f.length>0&&f[f.length-1]==="";)f.pop();let d=i.startsWith(">")?f.join(`
|
|
6
|
+
`).split(/\n{2,}/).map(m=>m.split(`
|
|
7
|
+
`).map(g=>g.trim()).filter(Boolean).join(" ")).filter(m=>m.length>0).join(`
|
|
8
8
|
|
|
9
|
-
`):
|
|
10
|
-
`).trimEnd();return(0,
|
|
11
|
-
`),n=!1;return t.map(o=>n?
|
|
12
|
-
`)}function B_(e){return bo(e)!==e}});var Qe=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=Q_;E.installationRootExternalKey=eh;E.normalizeRepositoryRelativePath=Rc;E.nativeKeyForSkillPath=th;E.nativeKeyForRulePath=nh;E.nativeKeyForCommandPath=rh;E.serializeComponentIdentity=Ac;E.buildComponentReference=sh;E.validateComponentReference=ih;var G_=Ve("node:crypto"),V_=Ve("node:path"),z_="cmp1_",W_=/^cmp1_[A-Za-z0-9_-]{43}$/,J_=["/skills/","/skills-cursor/"],Y_=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,X_=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,q_=[".cursor",".claude",".codex"],Z_={".claude.json":".claude",".agents":".codex"};E.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function Q_(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>q_.includes(o));return n||(t.map(o=>Z_[o]).find(o=>o!==void 0)??"unknown")}function eh(e,t){return`runtime-install:${e}/${t}`}function nr(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function Rc(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=V_.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return nr(n,"sourcePath")}function th(e){let t=e.replaceAll("\\","/");for(let n of J_){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function Cc(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 nh(e){return Cc(e,Y_,/\.(mdc|md|rules)$/i)}function rh(e){return Cc(e,X_,/\.(md|mdc|toml)$/i)}function oh(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Ac(e){let t=[nr(e.installationRootExternalKey,"installationRootExternalKey"),nr(e.installableKind,"installableKind"),Rc(e.sourcePath),nr(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(oh).join("|")}`,"utf8")}function sh(e){let t=(0,G_.createHash)("sha256").update(Ac(e)).digest("base64url");return`${z_}${t}`}function ih(e){return W_.test(e)}var Ae=Zn();Object.defineProperty(E,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:function(){return Ae.buildMcpFamilyCanonicalKey}});Object.defineProperty(E,"foldMcpName",{enumerable:!0,get:function(){return Ae.foldMcpName}});Object.defineProperty(E,"hashMcpLaunchIdentity",{enumerable:!0,get:function(){return Ae.hashMcpLaunchIdentity}});Object.defineProperty(E,"launchContainsCredentials",{enumerable:!0,get:function(){return Ae.launchContainsCredentials}});Object.defineProperty(E,"maskMcpLaunchForDisplay",{enumerable:!0,get:function(){return Ae.maskMcpLaunchForDisplay}});Object.defineProperty(E,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:function(){return Ae.MCP_LAUNCH_IDENTITY_ALGORITHM}});Object.defineProperty(E,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:function(){return Ae.MCP_MISSING_LAUNCH_SERIALIZED}});Object.defineProperty(E,"normalizeMcpToolNames",{enumerable:!0,get:function(){return Ae.normalizeMcpToolNames}});Object.defineProperty(E,"projectMcpLaunchIdentity",{enumerable:!0,get:function(){return Ae.projectMcpLaunchIdentity}});Object.defineProperty(E,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:function(){return Ae.projectMcpMissingLaunchIdentity}});Object.defineProperty(E,"serializeMcpLaunchIdentity",{enumerable:!0,get:function(){return Ae.serializeMcpLaunchIdentity}});var xt=er();Object.defineProperty(E,"PACKAGE_FIELD_MAX",{enumerable:!0,get:function(){return xt.PACKAGE_FIELD_MAX}});Object.defineProperty(E,"npxExecBin",{enumerable:!0,get:function(){return xt.npxExecBin}});Object.defineProperty(E,"npxPackageSpecs",{enumerable:!0,get:function(){return xt.npxPackageSpecs}});Object.defineProperty(E,"packageNameFromSpec",{enumerable:!0,get:function(){return xt.packageNameFromSpec}});Object.defineProperty(E,"pinnedPackageVersionFromNpx",{enumerable:!0,get:function(){return xt.pinnedPackageVersionFromNpx}});Object.defineProperty(E,"pinnedPackageVersionFromSpec",{enumerable:!0,get:function(){return xt.pinnedPackageVersionFromSpec}});var bc=cc();Object.defineProperty(E,"McpPackageEcosystem",{enumerable:!0,get:function(){return bc.McpPackageEcosystem}});Object.defineProperty(E,"resolveMcpPackageIdentity",{enumerable:!0,get:function(){return bc.resolveMcpPackageIdentity}});var rr=mc();Object.defineProperty(E,"classifyMcpProvenance",{enumerable:!0,get:function(){return rr.classifyMcpProvenance}});Object.defineProperty(E,"displayPublisherName",{enumerable:!0,get:function(){return rr.displayPublisherName}});Object.defineProperty(E,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:function(){return rr.EMPTY_NPM_PUBLISHER}});Object.defineProperty(E,"isNpmRegistryPublisher",{enumerable:!0,get:function(){return rr.isNpmRegistryPublisher}});var Oc=_c();Object.defineProperty(E,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:function(){return Oc.mcpServerNameMatchesToolSegment}});Object.defineProperty(E,"mcpServerToolSegmentForms",{enumerable:!0,get:function(){return Oc.mcpServerToolSegmentForms}});var Oo=hc();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 Ze=yc();Object.defineProperty(E,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return Ze.COMPONENT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(E,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:function(){return Ze.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}});Object.defineProperty(E,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return Ze.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(E,"capComponentTextBytes",{enumerable:!0,get:function(){return Ze.capComponentTextBytes}});Object.defineProperty(E,"componentSourceContainsRedactableSecret",{enumerable:!0,get:function(){return Ze.componentSourceContainsRedactableSecret}});Object.defineProperty(E,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:function(){return Ze.fitSnapshotInspectionTextBudget}});Object.defineProperty(E,"prepareComponentInspectionText",{enumerable:!0,get:function(){return Ze.prepareComponentInspectionText}});Object.defineProperty(E,"redactComponentSource",{enumerable:!0,get:function(){return Ze.redactComponentSource}})});var Or=z(ye=>{"use strict";ye.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;ye.find=(e,t)=>e.nodes.find(n=>n.type===t);ye.exceedsLimit=(e,t,n=1,r)=>r===!1||!ye.isInteger(e)||!ye.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;ye.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)};ye.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;ye.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;ye.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;ye.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);ye.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 xr=z((Nk,gl)=>{"use strict";var ml=Or();gl.exports=(e,t={})=>{let n=(r,o={})=>{let s=t.escapeInvalid&&ml.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a="";if(r.value)return(s||i)&&ml.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 hl=z((wk,_l)=>{"use strict";_l.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var xl=z((Mk,Ol)=>{"use strict";var Sl=hl(),ct=(e,t,n)=>{if(Sl(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(Sl(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let o=String(r.relaxZeros),s=String(r.shorthand),i=String(r.capture),a=String(r.wrap),c=e+":"+t+"="+o+s+i+a;if(ct.cache.hasOwnProperty(c))return ct.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=bl(e)||bl(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=El(S,Math.abs(l),f,r),l=f.a=0}return u>=0&&(p=El(l,u,f,r)),f.negatives=g,f.positives=p,f.result=ZE(g,p,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&p.length+g.length>1&&(f.result=`(?:${f.result})`),ct.cache[c]=f,f.result};function ZE(e,t,n){let r=us(e,t,"-",!1,n)||[],o=us(t,e,"",!1,n)||[],s=us(e,t,"-?",!0,n)||[];return r.concat(s).concat(o).join("|")}function QE(e,t){let n=1,r=1,o=Rl(e,n),s=new Set([t]);for(;e<=o&&o<=t;)s.add(o),n+=1,o=Rl(e,n);for(o=Cl(t+1,r)-1;e<o&&o<=t;)s.add(o),r+=1,o=Cl(t+1,r)-1;return s=[...s],s.sort(ny),s}function ey(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=ty(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+=ry(c,l,n):i++}return i&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[i],digits:o}}function El(e,t,n,r){let o=QE(e,t),s=[],i=e,a;for(let c=0;c<o.length;c++){let l=o[c],u=ey(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+Al(a.count),i=l+1;continue}n.isPadded&&(d=oy(l,n,r)),u.string=d+u.pattern+Al(u.count),s.push(u),i=l+1,a=u}return s}function us(e,t,n,r,o){let s=[];for(let i of e){let{string:a}=i;!r&&!yl(t,"string",a)&&s.push(n+a),r&&yl(t,"string",a)&&s.push(n+a)}return s}function ty(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}function ny(e,t){return e>t?1:t>e?-1:0}function yl(e,t,n){return e.some(r=>r[t]===n)}function Rl(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}function Cl(e,t){return e-e%Math.pow(10,t)}function Al(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}function ry(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}function bl(e){return/^-?(0+)\d/.test(e)}function oy(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}}`}}ct.cache={};ct.clearCache=()=>ct.cache={};Ol.exports=ct});var ds=z((vk,Ml)=>{"use strict";var sy=Ve("util"),kl=xl(),Il=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),iy=e=>t=>e===!0?Number(t):String(t),ls=e=>typeof e=="number"||typeof e=="string"&&e!=="",ln=e=>Number.isInteger(+e),fs=e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},ay=(e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,cy=(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},kr=(e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},uy=(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=>kr(String(a),n)).join("|")),e.negatives.length&&(s=`-(${r}${e.negatives.map(a=>kr(String(a),n)).join("|")})`),o&&s?i=`${o}|${s}`:i=o||s,t.wrap?`(${r}${i})`:i},Tl=(e,t,n,r)=>{if(n)return kl(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let s=String.fromCharCode(t);return`[${o}-${s}]`},Pl=(e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return kl(e,t,n)},Nl=(...e)=>new RangeError("Invalid range arguments: "+sy.inspect(...e)),wl=(e,t,n)=>{if(n.strictRanges===!0)throw Nl([e,t]);return[]},ly=(e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},fy=(e,t,n=1,r={})=>{let o=Number(e),s=Number(t);if(!Number.isInteger(o)||!Number.isInteger(s)){if(r.strictRanges===!0)throw Nl([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=fs(a)||fs(c)||fs(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&ay(e,t,r)===!1,p=r.transform||iy(f);if(r.toRegex&&n===1)return Tl(kr(e,d),kr(t,d),!0,r);let g={negatives:[],positives:[]},S=k=>g[k<0?"negatives":"positives"].push(Math.abs(k)),C=[],A=0;for(;i?o>=s:o<=s;)r.toRegex===!0&&n>1?S(o):C.push(cy(p(o,A),d,f)),o=i?o-n:o+n,A++;return r.toRegex===!0?n>1?uy(g,r,d):Pl(C,null,{wrap:!1,...r}):C},dy=(e,t,n=1,r={})=>{if(!ln(e)&&e.length>1||!ln(t)&&t.length>1)return wl(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 Tl(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?Pl(u,null,{wrap:!1,options:r}):u},Ir=(e,t,n,r={})=>{if(t==null&&ls(e))return[e];if(!ls(e)||!ls(t))return wl(e,t,r);if(typeof n=="function")return Ir(e,t,1,{transform:n});if(Il(n))return Ir(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,ln(n)?ln(e)&&ln(t)?fy(e,t,n,o):dy(e,t,Math.max(Math.abs(n),1),o):n!=null&&!Il(n)?ly(n,o):Ir(e,t,1,n)};Ml.exports=Ir});var Hl=z((Lk,Ll)=>{"use strict";var py=ds(),vl=Or(),my=(e,t={})=>{let n=(r,o={})=>{let s=vl.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=vl.reduce(r.nodes),d=py(...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)};Ll.exports=my});var Fl=z((Hk,Dl)=>{"use strict";var gy=ds(),Ul=xr(),kt=Or(),ut=(e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?kt.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let s of o)r.push(ut(s,t,n));else for(let s of t)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?ut(o,s,n):o+s);return kt.flatten(r)},_y=(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(ut(a.pop(),Ul(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){a.push(ut(a.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let d=kt.reduce(o.nodes);if(kt.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=gy(...d,t);f.length===0&&(f=Ul(o,t)),a.push(ut(a.pop(),f)),o.nodes=[];return}let c=kt.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(ut(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(ut(l.pop(),f.value));continue}f.nodes&&r(f,o)}return l};return kt.flatten(r(e))};Dl.exports=_y});var jl=z((Uk,$l)=>{"use strict";$l.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
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 zl=z((Dk,Vl)=>{"use strict";var hy=xr(),{MAX_LENGTH:Kl,CHAR_BACKSLASH:ps,CHAR_BACKTICK:Sy,CHAR_COMMA:Ey,CHAR_DOT:yy,CHAR_LEFT_PARENTHESES:Ry,CHAR_RIGHT_PARENTHESES:Cy,CHAR_LEFT_CURLY_BRACE:Ay,CHAR_RIGHT_CURLY_BRACE:by,CHAR_LEFT_SQUARE_BRACKET:Bl,CHAR_RIGHT_SQUARE_BRACKET:Gl,CHAR_DOUBLE_QUOTE:Oy,CHAR_SINGLE_QUOTE:xy,CHAR_NO_BREAK_SPACE:Iy,CHAR_ZERO_WIDTH_NOBREAK_SPACE:ky}=jl(),Ty=(e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Kl,n.maxLength):Kl;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===ky||f===Iy)){if(f===ps){g({type:"text",value:(t.keepEscaping?f:"")+p()});continue}if(f===Gl){g({type:"text",value:"\\"+f});continue}if(f===Bl){c++;let S;for(;u<l&&(S=p());){if(f+=S,S===Bl){c++;continue}if(S===ps){f+=p();continue}if(S===Gl&&(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===Cy){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===Oy||f===xy||f===Sy){let S=f,C;for(t.keepQuotes!==!0&&(f="");u<l&&(C=p());){if(C===ps){f+=C+p();continue}if(C===S){t.keepQuotes===!0&&(f+=C);break}f+=C}g({type:"text",value:f});continue}if(f===Ay){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===by){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===Ey&&d>0){if(i.ranges>0){i.ranges=0;let S=i.nodes.shift();i.nodes=[S,{type:"text",value:hy(i)}]}g({type:"comma",value:f}),i.commas++;continue}if(f===yy&&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};Vl.exports=Ty});var Yl=z((Fk,Jl)=>{"use strict";var Wl=xr(),Py=Hl(),Ny=Fl(),wy=zl(),_e=(e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=_e.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(_e.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n};_e.parse=(e,t={})=>wy(e,t);_e.stringify=(e,t={})=>Wl(typeof e=="string"?_e.parse(e,t):e,t);_e.compile=(e,t={})=>(typeof e=="string"&&(e=_e.parse(e,t)),Py(e,t));_e.expand=(e,t={})=>{typeof e=="string"&&(e=_e.parse(e,t));let n=Ny(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};_e.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?_e.compile(e,t):_e.expand(e,t);Jl.exports=_e});var fn=z(($k,ef)=>{"use strict";var My=Ve("path"),we="\\\\/",Xl=`[^${we}]`,vy=0,Be="\\.",Ly="\\+",Hy="\\?",Tr="\\/",Uy="(?=.)",ql="[^/]",ms=`(?:${Tr}|$)`,Zl=`(?:^|${Tr})`,gs=`${Be}{1,2}${ms}`,Dy=`(?!${Be})`,Fy=`(?!${Zl}${gs})`,$y=`(?!${Be}{0,1}${ms})`,jy=`(?!${gs})`,Ky=`[^.${Tr}]`,By=`${ql}*?`,Ql={DOT_LITERAL:Be,PLUS_LITERAL:Ly,QMARK_LITERAL:Hy,SLASH_LITERAL:Tr,ONE_CHAR:Uy,QMARK:ql,END_ANCHOR:ms,DOTS_SLASH:gs,NO_DOT:Dy,NO_DOTS:Fy,NO_DOT_SLASH:$y,NO_DOTS_SLASH:jy,QMARK_NO_DOT:Ky,STAR:By,START_ANCHOR:Zl},Gy={...Ql,SLASH_LITERAL:`[${we}]`,QMARK:Xl,STAR:`${Xl}*?`,DOTS_SLASH:`${Be}{1,2}(?:[${we}]|$)`,NO_DOT:`(?!${Be})`,NO_DOTS:`(?!(?:^|[${we}])${Be}{1,2}(?:[${we}]|$))`,NO_DOT_SLASH:`(?!${Be}{0,1}(?:[${we}]|$))`,NO_DOTS_SLASH:`(?!${Be}{1,2}(?:[${we}]|$))`,QMARK_NO_DOT:`[^.${we}]`,START_ANCHOR:`(?:^|[${we}])`,END_ANCHOR:`(?:[${we}]|$)`},Vy={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};ef.exports={DEFAULT_MAX_EXTGLOB_RECURSION:vy,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Vy,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:My.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?Gy:Ql}}});var dn=z(ue=>{"use strict";var zy=Ve("path"),Wy=process.platform==="win32",{REGEX_BACKSLASH:Jy,REGEX_REMOVE_BACKSLASH:Yy,REGEX_SPECIAL_CHARS:Xy,REGEX_SPECIAL_CHARS_GLOBAL:qy}=fn();ue.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);ue.hasRegexChars=e=>Xy.test(e);ue.isRegexChar=e=>e.length===1&&ue.hasRegexChars(e);ue.escapeRegex=e=>e.replace(qy,"\\$1");ue.toPosixSlashes=e=>e.replace(Jy,"/");ue.removeBackslashes=e=>e.replace(Yy,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:Wy===!0||zy.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 uf=z((Kk,cf)=>{"use strict";var tf=dn(),{CHAR_ASTERISK:_s,CHAR_AT:Zy,CHAR_BACKWARD_SLASH:pn,CHAR_COMMA:Qy,CHAR_DOT:hs,CHAR_EXCLAMATION_MARK:Ss,CHAR_FORWARD_SLASH:af,CHAR_LEFT_CURLY_BRACE:Es,CHAR_LEFT_PARENTHESES:ys,CHAR_LEFT_SQUARE_BRACKET:eR,CHAR_PLUS:tR,CHAR_QUESTION_MARK:nf,CHAR_RIGHT_CURLY_BRACE:nR,CHAR_RIGHT_PARENTHESES:rf,CHAR_RIGHT_SQUARE_BRACKET:rR}=fn(),of=e=>e===af||e===pn,sf=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},oR=(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,k=!1,P=!1,T=!1,x=!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===pn){k=w.backslashes=!0,O=b(),O===Es&&(A=!0);continue}if(A===!0||O===Es){for(B++;H()!==!0&&(O=b());){if(O===pn){k=w.backslashes=!0,b();continue}if(O===Es){B++;continue}if(A!==!0&&O===hs&&(O=b())===hs){if(f=w.isBrace=!0,g=w.isGlob=!0,x=!0,o===!0)continue;break}if(A!==!0&&O===Qy){if(f=w.isBrace=!0,g=w.isGlob=!0,x=!0,o===!0)continue;break}if(O===nR&&(B--,B===0)){A=!1,f=w.isBrace=!0,x=!0;break}}if(o===!0)continue;break}if(O===af){if(s.push(l),i.push(w),w={value:"",depth:0,isGlob:!1},x===!0)continue;if(D===hs&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(O===tR||O===Zy||O===_s||O===nf||O===Ss)===!0&&m()===ys){if(g=w.isGlob=!0,S=w.isExtglob=!0,x=!0,O===Ss&&l===u&&(T=!0),o===!0){for(;H()!==!0&&(O=b());){if(O===pn){k=w.backslashes=!0,O=b();continue}if(O===rf){g=w.isGlob=!0,x=!0;break}}continue}break}if(O===_s){if(D===_s&&(C=w.isGlobstar=!0),g=w.isGlob=!0,x=!0,o===!0)continue;break}if(O===nf){if(g=w.isGlob=!0,x=!0,o===!0)continue;break}if(O===eR){for(;H()!==!0&&(se=b());){if(se===pn){k=w.backslashes=!0,b();continue}if(se===rR){p=w.isBracket=!0,g=w.isGlob=!0,x=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&O===Ss&&l===u){P=w.negated=!0,u++;continue}if(n.noparen!==!0&&O===ys){if(g=w.isGlob=!0,o===!0){for(;H()!==!0&&(O=b());){if(O===ys){k=w.backslashes=!0,O=b();continue}if(O===rf){x=!0;break}}continue}break}if(g===!0){if(x=!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&&of(U.charCodeAt(U.length-1))&&(U=U.slice(0,-1)),n.unescape===!0&&(_&&(_=tf.removeBackslashes(_)),U&&k===!0&&(U=tf.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,of(O)||i.push(w),h.tokens=i),n.parts===!0||n.tokens===!0){let se;for(let F=0;F<s.length;F++){let be=se?se+1:u,Oe=s[F],de=e.slice(be,Oe);n.tokens&&(F===0&&u!==0?(i[F].isPrefix=!0,i[F].value=fe):i[F].value=de,sf(i[F]),h.maxDepth+=i[F].depth),(F!==0||de!=="")&&a.push(de),se=Oe}if(se&&se+1<e.length){let F=e.slice(se+1);a.push(F),n.tokens&&(i[i.length-1].value=F,sf(i[i.length-1]),h.maxDepth+=i[i.length-1].depth)}h.slashes=s,h.parts=a}return h};cf.exports=oR});var mf=z((Bk,pf)=>{"use strict";var mn=fn(),oe=dn(),{MAX_LENGTH:Pr,POSIX_REGEX_SOURCE:sR,REGEX_NON_SPECIAL_CHARS:iR,REGEX_SPECIAL_CHARS_BACKREF:aR,REPLACEMENTS:lf}=mn,cR=(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},Tt=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,ff=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},uR=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},df=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(uR(t))return t.replace(/\\(.)/g,"$1")},lR=e=>{let t=e.map(df).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],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},Rs=(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}}}}},fR=e=>{let t=0,n=[];for(;t<e.length;){let o=Rs(e.slice(t),!1);if(!o||o.type!=="*")return;let s=ff(o.body).map(a=>a.trim());if(s.length!==1)return;let i=df(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("")}]`}*`},dR=e=>{let t=0,n=e.trim(),r=Rs(n);for(;r;)t++,n=r.body.trim(),r=Rs(n);return t},pR=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:mn.DEFAULT_MAX_EXTGLOB_RECURSION,r=ff(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||lR(r)))return{risky:!0};for(let o of r){let s=fR(o);if(s)return{risky:!0,safeOutput:s};if(dR(o)>n)return{risky:!0}}return{risky:!1}},Cs=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=lf[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(Pr,n.maxLength):Pr,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=mn.globChars(c),u=mn.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:k,QMARK:P,QMARK_NO_DOT:T,STAR:x,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):x;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],be=m.advance=()=>e[++m.index]||"",Oe=()=>e.slice(m.index+1),de=(R="",J=0)=>{m.consumed+=R,m.index+=J},xn=R=>{m.output+=R.output!=null?R.output:R.value,de(R.value)},kp=()=>{let R=1;for(;F()==="!"&&(F(2)!=="("||F(3)==="?");)be(),m.start++,R++;return R%2===0?!1:(m.negated=!0,m.start++,!0)},In=R=>{m[R]++,fe.push(R)},Ge=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)&&xn(R),_&&_.type==="text"&&R.type==="text"){_.value+=R.value,_.output=(_.output||"")+R.value;return}R.prev=_,i.push(R),_=R},kn=(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;In("parens"),M({type:R,value:J,output:m.output?"":g}),M({type:"paren",extglob:!0,value:be(),output:N}),b.push(y)},Tp=R=>{let J=e.slice(R.startIndex,m.index+1),y=e.slice(R.startIndex+2,m.index),N=pR(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,xe=i[R.tokensIndex];xe.type="text",xe.value=J,xe.output=G||oe.escapeRegex(J);for(let Ie=R.tokensIndex+1;Ie<i.length;Ie++)i[Ie].value="",i[Ie].output="",delete i[Ie].suffix;m.output=R.output+xe.output,m.backtrack=!0,M({type:"paren",extglob:!0,value:h,output:""}),Ge("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(Oe()))&&(V=R.close=`)$))${G}`),R.inner.includes("*")&&(re=Oe())&&/^\.[^\\/.]+$/.test(re)){let xe=Cs(re,{...t,fastpaths:!1}).output;V=R.close=`)${xe})${G})`}R.prev.type==="bos"&&(m.negatedExtglob=!0)}M({type:"paren",extglob:!0,value:h,output:V}),Ge("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let R=!1,J=e.replace(aR,(y,N,V,re,G,xe)=>re==="\\"?(R=!0,y):re==="?"?N?N+re+(G?P.repeat(G.length):""):xe===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=be(),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(Oe()),V=0;if(N&&N[0].length>2&&(V=N[0].length,m.index+=V,V%2!==0&&(h+="\\")),n.unescape===!0?h=be():h+=be(),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=sR[re];if(G){_.value=V+G,m.backtrack=!0,be(),!s.output&&i.indexOf(_)===1&&(s.output=g);continue}}}(h==="["&&F()!==":"||h==="-"&&F()==="]")&&(h=`\\${h}`),h==="]"&&(_.value==="["||_.value==="[^")&&(h=`\\${h}`),n.posix===!0&&h==="!"&&_.value==="["&&(h="^"),_.value+=h,xn({value:h});continue}if(m.quotes===1&&h!=='"'){h=oe.escapeRegex(h),_.value+=h,xn({value:h});continue}if(h==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===!0&&M({type:"text",value:h});continue}if(h==="("){In("parens"),M({type:"paren",value:h});continue}if(h===")"){if(m.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Tt("opening","("));let y=b[b.length-1];if(y&&m.parens===y.parens+1){Tp(b.pop());continue}M({type:"paren",value:h,output:m.parens?")":"\\)"}),Ge("parens");continue}if(h==="["){if(n.nobracket===!0||!Oe().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Tt("closing","]"));h=`\\${h}`}else In("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(Tt("opening","["));M({type:"text",value:h,output:`\\${h}`});continue}Ge("brackets");let y=_.value.slice(1);if(_.posix!==!0&&y[0]==="^"&&!y.includes("/")&&(h=`/${h}`),_.value+=h,xn({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){In("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=cR(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}),Ge("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)!=="?"){kn("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(Oe()))&&(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)))){kn("negate",h);continue}if(n.nonegate!==!0&&m.index===0){kp();continue}}if(h==="+"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){kn("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=iR.exec(Oe());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=Oe();if(n.noextglob!==!0&&/^\([^?]/.test(R)){kn("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"),xe=b.length&&(y.type==="pipe"||y.type==="paren");if(!V&&y.type!=="paren"&&!G&&!xe){M({type:"star",value:h,output:""});continue}for(;R.slice(0,3)==="/**";){let Ie=e[m.index+4];if(Ie&&Ie!=="/")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 Ie=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}${Ie})`,_.value+=h,m.output+=y.output+_.output,m.globstar=!0,de(h+be()),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+be()),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+=k,_.output+=k):(m.output+=O,_.output+=O),F()!=="*"&&(m.output+=g,_.output+=g)),M(J)}for(;m.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Tt("closing","]"));m.output=oe.escapeLast(m.output,"["),Ge("brackets")}for(;m.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Tt("closing",")"));m.output=oe.escapeLast(m.output,"("),Ge("parens")}for(;m.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Tt("closing","}"));m.output=oe.escapeLast(m.output,"{"),Ge("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};Cs.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(Pr,n.maxLength):Pr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=lf[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}=mn.globChars(s),S=n.dot?d:u,C=n.dot?f:u,A=n.capture?"":"?:",k={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}).)*?)`,x=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=x(w[1]);return H?H+i+w[2]:void 0}}},B=oe.removePrefix(e,k),D=x(B);return D&&n.strictSlashes!==!0&&(D+=`${a}?`),D};pf.exports=Cs});var _f=z((Gk,gf)=>{"use strict";var mR=Ve("path"),gR=uf(),As=mf(),bs=dn(),_R=fn(),hR=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=hR(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=bs.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?bs.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=bs.isWindows(n))=>(t instanceof RegExp?t:ee.makeRe(t,n)).test(mR.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)):As(e,{...t,fastpaths:!1});ee.scan=(e,t)=>gR(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=As.fastpaths(e,t)),o.output||(o=As(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=_R;gf.exports=ee});var Sf=z((Vk,hf)=>{"use strict";hf.exports=_f()});var bf=z((zk,Af)=>{"use strict";var yf=Ve("util"),Rf=Yl(),Me=Sf(),Os=dn(),Ef=e=>e===""||e==="./",Cf=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=Me(String(t[u]),{...n,onResult:a},!0),f=d.state.negated||d.state.negatedExtglob;f&&i++;for(let p of e){let g=d(p,!0);(f?!g.isMatch:g.isMatch)&&(f?r.add(g.output):(r.delete(g.output),o.add(g.output)))}}let l=(i===t.length?[...s]:[...o]).filter(u=>!r.has(u));if(n&&l.length===0){if(n.failglob===!0)throw new Error(`No matches found for "${t.join(", ")}"`);if(n.nonull===!0||n.nullglob===!0)return n.unescape?t.map(u=>u.replace(/\\/g,"")):t}return l};W.match=W;W.matcher=(e,t)=>Me(e,t);W.isMatch=(e,t,n)=>Me(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: "${yf.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>W.contains(e,r,n));if(typeof t=="string"){if(Ef(e)||Ef(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(!Os.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=Me(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=Me(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: "${yf.inspect(e)}"`);return[].concat(t).every(r=>Me(r,n)(e))};W.capture=(e,t,n)=>{let r=Os.isWindows(n),s=Me.makeRe(String(e),{...n,capture:!0}).exec(r?Os.toPosixSlashes(t):t);if(s)return s.slice(1).map(i=>i===void 0?"":i)};W.makeRe=(...e)=>Me.makeRe(...e);W.scan=(...e)=>Me.scan(...e);W.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of Rf(String(r),t))n.push(Me.parse(o,t));return n};W.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!Cf(e)?[e]:Rf(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=Cf;Af.exports=W});import{existsSync as Jp,readFileSync as Yp}from"node:fs";import{hostname as Pi,release as Xp,userInfo as qp,version as Zp}from"node:os";import*as ie from"node:os";import{performance as Wr}from"node:perf_hooks";var Hp=1024*1024,Up=128;function Tn(e){return Math.round(e/Hp)}function Dt(e,t){let n=10**t;return Math.round(e*n)/n}function gi(e=process.platform){try{let t=Wr.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=Tn(ie.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=Tn(process.availableMemory())),e!=="win32"){let[c,l,u]=ie.loadavg();n.load_1m=Dt(c??0,2),n.load_5m=Dt(l??0,2),n.load_15m=Dt(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=Wr.nodeTiming?.bootstrapComplete;return typeof a=="number"&&a>0&&(n.node_boot_ms=Dt(a,1)),n.sample_us=Math.round((Wr.now()-t)*1e3),n}catch{return}}function _i(){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,Up);r&&(t.cpu_model=r);let o=ie.totalmem();t.mem_total_mb=Tn(o);let s=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof s=="number"&&s>0&&s<o&&(t.mem_limit_mb=Tn(s)),t.uptime_h=Dt(ie.uptime()/3600,1),t}catch{return{}}}import{createHash as Dp,randomBytes as Fp}from"node:crypto";import{existsSync as Pn,mkdirSync as $p,readdirSync as jp,readFileSync as Kp,renameSync as hi,statSync as Ri,unlinkSync as Si,writeFileSync as Bp}from"node:fs";import{homedir as Ci}from"node:os";import{basename as Gp,dirname as Ei,isAbsolute as Vp,join as Ai,relative as bi,resolve as He,sep as zp}from"node:path";function I(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
|
|
14
|
-
`)}function Ft(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}function $t(e){return Dp("sha256").update(e).digest("hex").slice(0,32)}function ae(e,t){$p(Ei(e),{recursive:!0});let n=Ai(Ei(e),`.${Gp(e)}.${process.pid}.${Fp(4).toString("hex")}.tmp`);try{Bp(n,t,"utf8");try{hi(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){Si(e),hi(n,e);return}throw r}}catch(r){try{Si(n)}catch{}throw r}}function Nn(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}var Yr;function Xr(e){Yr=e}function qr(){(Yr?.stdout??process.stdout).write('{"continue":true}')}var jt=new Set(["on","1","true"]),Oi=new Set(["off","0","false"]);function v(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function Zr(){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 wn(e){let t=Yr?.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 Re(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 Re(e,t,n,r);return o.ok?o.stdout:""}function Jr(e,t){let n=He(e),r=He(t),o=bi(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${zp}`)||Vp(o)?!1:He(r,o)===n}function xi(e,t,n=Ci()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return He(e);let o=He(r),s=He(e);if(Jr(s,o))return s;let i=t.CURSOR_PLUGIN_ROOT?.trim();return Jr(s,He(n,".cursor"))||i!==void 0&&i.length>0&&Jr(s,He(i))?o:s}async function Qr(e=process.cwd(),t=process.env,n=Ci()){let r=xi(e,t,n),o=r!==He(e)&&Pn(r)?r:e,s=await Re("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")}`;I(`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&&Pn(i)){let a=await Re("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 eo(e=process.cwd()){return(await Qr(e)).root}function he(e,t){try{return JSON.parse(e)}catch{return t}}var yi=new Map;function Mn(e){return e.charCodeAt(0)===65279?e.slice(1):e}function Wp(e){let t;try{t=Kp(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Mn(t))}}catch{return{ok:!1,reason:"parse"}}}function Ii(e){let t=yi.get(e);if(t!==void 0)return t;let n=Wp(e);return yi.set(e,n),n}function ki(e){return Ii(e)}function X(e,t){let n=Ii(e);return n.ok?n.value:t}function nt(e){return typeof e=="string"?e:""}function Ue(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=Ue(e,t);return typeof n=="string"?n:""}var We=500;function Ti(e,t=2){if(!Pn(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,i)=>{if(i>t||r)return;let a;try{a=jp(s,{withFileTypes:!0})}catch{return}for(let c of a){if(r)return;let l=Ai(s,c.name);if(c.isDirectory()){o(l,i+1);continue}if(c.isFile()){try{n.push({name:bi(e,l),size:Ri(l).size})}catch{continue}if(n.length>=We){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function to(e){return Pn(e)?{present:!0,size:Ri(e).size}:{present:!1,size:0}}function _t(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function Ni(e=process.env){return _t(Y("CURSOR_SANDBOX",e))}var Qp=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function em(e){return Qp.some(t=>!!Y(t,e))}function tm(e){if(Y("KUBERNETES_SERVICE_HOST",e)||_t(Y("REMOTE_CONTAINERS",e))||_t(Y("DEVCONTAINER",e)))return!0;try{if(Jp("/.dockerenv")||Yp("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function wi(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!Y(t,e))}function nm(e,t=process.platform){return wi(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!Y(n,e)):!1}function rm(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function om(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 sm(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!im(Y("CURSOR_VERSION",n))}function im(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function no(e){if(rm(e.sessionId))return!0;let t=e.hostname??Pi(),n=e.osUser??vi(e.env);return sm(t,n,e.env)}function am(e){return _t(Y("CURSOR_AGENT",e.env))?!0:no(e)}function cm(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))||wi(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!Y(t,e))||Y("SESSIONNAME",e))}function Kt(e={}){let t=e.env;if(Y("GITHUB_ACTIONS",t))return"github_actions";if(_t(Y("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!nm(t,n)&&am(e)&&(_t(Y("CURSOR_AGENT",t))||om(n)))return"cursor_cloud";if(Y("CODESPACES",t)||Y("CODESPACE_NAME",t))return"codespaces";if(Y("GITLAB_CI",t))return"gitlab_ci";if(em(t))return"managed";let r=Y("CI",t);return r&&r!=="false"&&r!=="0"?"managed":tm(t)?"container":cm(t)?"interactive":"unknown"}async function Mi(){return await te("systemd-detect-virt",[],1e3)}function vi(e=process.env,t=qp){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 um=32;function lm(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,um);return t.length>0?t:null}function fm(){try{return[Zp(),Xp()].filter(Boolean).join(" ").trim()}catch{return""}}async function Li(e=!1){let t=lm(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=fm():n=await te("ver",[],1e3);let r=vi(),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?_i():{}}}function vn(){return Pi()}import{createHash as Cm}from"node:crypto";import{homedir as Am}from"node:os";import{dirname as bO,join as bm,parse as OO,resolve as xO}from"node:path";var Hi="EV_AI_LAUNCHER_VERSION";var Ui="EV_AI_HOOK_SOURCE",Di="EV_AI_HOOK_FALLBACK_REASON",Fi="EV_AI_LAUNCHER_SCOPE",ro="EV_AI_LAUNCHER_READY_FD";var $i="--defer-user-spec",Ln="--cap",Bt="--slot";var ji=Buffer.from([1]);var sO=1024*1024,iO=4*1024*1024,aO=64*1024,cO=64*1024,uO=64*1024;var oo=4096,lO=4*1024*1024;var Ki="ev-ai.agent-hook.in-process.v1";import{join as Ji}from"node:path";import{open as Bi,mkdir as dm,readFile as pm,readdir as mm,rename as gm,stat as _m,rmdir as hm,unlink as Sm,utimes as Em}from"node:fs/promises";var Hn=new WeakMap;function Vi(e){if(e&&typeof e=="object"&&"code"in e)return e}function ht(e){return Vi(e)?.code==="ENOENT"}function Gt(e){return Vi(e)?.code==="EEXIST"}async function zi(e,t){try{return await e.readdir(t)}catch(n){if(ht(n))return[];throw n}}function Wi(){return{async open(e,t){let n=await Bi(e,t),r={path:e};return Hn.set(r,n),r},async write(e,t){let n=Gi(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await Gi(e).sync()},async close(e){let t=Hn.get(e);Hn.delete(e),t&&await t.close()},rename:gm,async readdir(e){return mm(e)},readFile:pm,async stat(e){let t=await _m(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await dm(e,t)},unlink:Sm,rmdir:hm,utimes:Em,async fsyncDir(e){if(process.platform==="win32")return;let t=await Bi(e,"r");try{await t.sync()}finally{await t.close()}}}}function Gi(e){let t=Hn.get(e);if(!t)throw new Error("closed");return t}var Yi=4,Xi=10;function Un(e=process.platform){return e==="win32"?Yi:Xi}var Dn=6e4,Vt=2e3,qi="slots",so=64;function Zi(e){return Ji(e,".ev-ai","agent-hook",qi)}function Fn(e,t){return Ji(e,`slot-${t}`)}function $n(e,t){return`${e}
|
|
9
|
+
`):f.join(`
|
|
10
|
+
`).trimEnd();return(0,Ie.usableCatalogText)(d)}s(NS,"parseYamlFrontmatterScalar")});var Au=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=wS;ne.capComponentTextBytes=Ru;ne.prepareComponentInspectionText=LS;ne.redactComponentSource=is;ne.componentSourceContainsRedactableSecret=$S;ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";ne.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;ne.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function wS(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(wS,"fitSnapshotInspectionTextBudget");function Ru(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(Ru,"capComponentTextBytes");function LS(e){if(!(e==null||e.length===0))return Ru(is(e),ne.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}s(LS,"prepareComponentInspectionText");var vS=[/\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],MS=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,US=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,HS=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,DS=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,yu=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function FS(e){let t=e.replace(US,(n,r)=>`${r}${ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(HS,(n,r)=>`${r}${ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(MS,(n,r)=>`${r}${ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of vS)t=t.replace(n,ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}s(FS,"redactLine");function is(e){if(e.length===0)return e;let t=e.split(`
|
|
11
|
+
`),n=!1;return t.map(o=>n?yu.test(o)?(n=!1,o):o.trim().length===0?o:ne.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:DS.test(o)&&!yu.test(o)?(n=!0,o):FS(o)).join(`
|
|
12
|
+
`)}s(is,"redactComponentSource");function $S(e){return is(e)!==e}s($S,"componentSourceContainsRedactableSecret")});var ct=J(R=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.redactComponentSource=R.prepareComponentInspectionText=R.fitSnapshotInspectionTextBudget=R.componentSourceContainsRedactableSecret=R.capComponentTextBytes=R.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=R.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=R.COMPONENT_INSPECTION_TEXT_MAX_BYTES=R.usableCatalogText=R.parseFrontmatterField=R.parseFrontmatterDescription=R.mcpServerToolSegmentForms=R.mcpServerNameMatchesToolSegment=R.isNpmRegistryPublisher=R.EMPTY_NPM_PUBLISHER=R.displayPublisherName=R.classifyMcpProvenance=R.resolveMcpPackageIdentity=R.McpPackageEcosystem=R.pinnedPackageVersionFromSpec=R.pinnedPackageVersionFromNpx=R.packageNameFromSpec=R.npxPackageSpecs=R.npxExecBin=R.PACKAGE_FIELD_MAX=R.serializeMcpLaunchIdentity=R.projectMcpMissingLaunchIdentity=R.projectMcpLaunchIdentity=R.normalizeMcpToolNames=R.MCP_MISSING_LAUNCH_SERIALIZED=R.MCP_LAUNCH_IDENTITY_ALGORITHM=R.maskMcpLaunchForDisplay=R.launchContainsCredentials=R.hashMcpLaunchIdentity=R.foldMcpName=R.buildMcpFamilyCanonicalKey=R.ComponentKind=void 0;R.userConfigRootFromPath=XS;R.installationRootExternalKey=qS;R.normalizeRepositoryRelativePath=Cu;R.nativeKeyForSkillPath=ZS;R.nativeKeyForRulePath=QS;R.nativeKeyForCommandPath=eE;R.serializeComponentIdentity=xu;R.buildComponentReference=nE;R.validateComponentReference=rE;var BS=qe("node:crypto"),jS=qe("node:path"),KS="cmp1_",GS=/^cmp1_[A-Za-z0-9_-]{43}$/,VS=["/skills/","/skills-cursor/"],zS=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,WS=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,JS=[".cursor",".claude",".codex"],YS={".claude.json":".claude",".agents":".codex"};R.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function XS(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>JS.includes(o));return n||(t.map(o=>YS[o]).find(o=>o!==void 0)??"unknown")}s(XS,"userConfigRootFromPath");function qS(e,t){return`runtime-install:${e}/${t}`}s(qS,"installationRootExternalKey");function Or(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}s(Or,"requireValue");function Cu(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=jS.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Or(n,"sourcePath")}s(Cu,"normalizeRepositoryRelativePath");function ZS(e){let t=e.replaceAll("\\","/");for(let n of VS){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}s(ZS,"nativeKeyForSkillPath");function bu(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(bu,"nativeKeyUnderLayoutRoot");function QS(e){return bu(e,zS,/\.(mdc|md|rules)$/i)}s(QS,"nativeKeyForRulePath");function eE(e){return bu(e,WS,/\.(md|mdc|toml)$/i)}s(eE,"nativeKeyForCommandPath");function tE(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(tE,"field");function xu(e){let t=[Or(e.installationRootExternalKey,"installationRootExternalKey"),Or(e.installableKind,"installableKind"),Cu(e.sourcePath),Or(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(tE).join("|")}`,"utf8")}s(xu,"serializeComponentIdentity");function nE(e){let t=(0,BS.createHash)("sha256").update(xu(e)).digest("base64url");return`${KS}${t}`}s(nE,"buildComponentReference");function rE(e){return GS.test(e)}s(rE,"validateComponentReference");var ke=Ar();Object.defineProperty(R,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:s(function(){return ke.buildMcpFamilyCanonicalKey},"get")});Object.defineProperty(R,"foldMcpName",{enumerable:!0,get:s(function(){return ke.foldMcpName},"get")});Object.defineProperty(R,"hashMcpLaunchIdentity",{enumerable:!0,get:s(function(){return ke.hashMcpLaunchIdentity},"get")});Object.defineProperty(R,"launchContainsCredentials",{enumerable:!0,get:s(function(){return ke.launchContainsCredentials},"get")});Object.defineProperty(R,"maskMcpLaunchForDisplay",{enumerable:!0,get:s(function(){return ke.maskMcpLaunchForDisplay},"get")});Object.defineProperty(R,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:s(function(){return ke.MCP_LAUNCH_IDENTITY_ALGORITHM},"get")});Object.defineProperty(R,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:s(function(){return ke.MCP_MISSING_LAUNCH_SERIALIZED},"get")});Object.defineProperty(R,"normalizeMcpToolNames",{enumerable:!0,get:s(function(){return ke.normalizeMcpToolNames},"get")});Object.defineProperty(R,"projectMcpLaunchIdentity",{enumerable:!0,get:s(function(){return ke.projectMcpLaunchIdentity},"get")});Object.defineProperty(R,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:s(function(){return ke.projectMcpMissingLaunchIdentity},"get")});Object.defineProperty(R,"serializeMcpLaunchIdentity",{enumerable:!0,get:s(function(){return ke.serializeMcpLaunchIdentity},"get")});var Gt=br();Object.defineProperty(R,"PACKAGE_FIELD_MAX",{enumerable:!0,get:s(function(){return Gt.PACKAGE_FIELD_MAX},"get")});Object.defineProperty(R,"npxExecBin",{enumerable:!0,get:s(function(){return Gt.npxExecBin},"get")});Object.defineProperty(R,"npxPackageSpecs",{enumerable:!0,get:s(function(){return Gt.npxPackageSpecs},"get")});Object.defineProperty(R,"packageNameFromSpec",{enumerable:!0,get:s(function(){return Gt.packageNameFromSpec},"get")});Object.defineProperty(R,"pinnedPackageVersionFromNpx",{enumerable:!0,get:s(function(){return Gt.pinnedPackageVersionFromNpx},"get")});Object.defineProperty(R,"pinnedPackageVersionFromSpec",{enumerable:!0,get:s(function(){return Gt.pinnedPackageVersionFromSpec},"get")});var Ou=lu();Object.defineProperty(R,"McpPackageEcosystem",{enumerable:!0,get:s(function(){return Ou.McpPackageEcosystem},"get")});Object.defineProperty(R,"resolveMcpPackageIdentity",{enumerable:!0,get:s(function(){return Ou.resolveMcpPackageIdentity},"get")});var Ir=_u();Object.defineProperty(R,"classifyMcpProvenance",{enumerable:!0,get:s(function(){return Ir.classifyMcpProvenance},"get")});Object.defineProperty(R,"displayPublisherName",{enumerable:!0,get:s(function(){return Ir.displayPublisherName},"get")});Object.defineProperty(R,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:s(function(){return Ir.EMPTY_NPM_PUBLISHER},"get")});Object.defineProperty(R,"isNpmRegistryPublisher",{enumerable:!0,get:s(function(){return Ir.isNpmRegistryPublisher},"get")});var Iu=Su();Object.defineProperty(R,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:s(function(){return Iu.mcpServerNameMatchesToolSegment},"get")});Object.defineProperty(R,"mcpServerToolSegmentForms",{enumerable:!0,get:s(function(){return Iu.mcpServerToolSegmentForms},"get")});var as=Eu();Object.defineProperty(R,"parseFrontmatterDescription",{enumerable:!0,get:s(function(){return as.parseFrontmatterDescription},"get")});Object.defineProperty(R,"parseFrontmatterField",{enumerable:!0,get:s(function(){return as.parseFrontmatterField},"get")});Object.defineProperty(R,"usableCatalogText",{enumerable:!0,get:s(function(){return as.usableCatalogText},"get")});var at=Au();Object.defineProperty(R,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return at.COMPONENT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(R,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:s(function(){return at.COMPONENT_SOURCE_REDACTION_PLACEHOLDER},"get")});Object.defineProperty(R,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return at.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(R,"capComponentTextBytes",{enumerable:!0,get:s(function(){return at.capComponentTextBytes},"get")});Object.defineProperty(R,"componentSourceContainsRedactableSecret",{enumerable:!0,get:s(function(){return at.componentSourceContainsRedactableSecret},"get")});Object.defineProperty(R,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:s(function(){return at.fitSnapshotInspectionTextBudget},"get")});Object.defineProperty(R,"prepareComponentInspectionText",{enumerable:!0,get:s(function(){return at.prepareComponentInspectionText},"get")});Object.defineProperty(R,"redactComponentSource",{enumerable:!0,get:s(function(){return at.redactComponentSource},"get")})});var zr=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 Wr=J((lw,of)=>{"use strict";var rf=zr();of.exports=(e,t={})=>{let n=s((r,o={})=>{let i=t.escapeInvalid&&rf.isInvalidBrace(o),a=r.invalid===!0&&t.escapeInvalid===!0,c="";if(r.value)return(i||a)&&rf.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 af=J((dw,sf)=>{"use strict";sf.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var _f=J((pw,gf)=>{"use strict";var cf=af(),Ct=s((e,t,n)=>{if(cf(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(cf(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let o=String(r.relaxZeros),i=String(r.shorthand),a=String(r.capture),c=String(r.wrap),u=e+":"+t+"="+o+i+a+c;if(Ct.cache.hasOwnProperty(u))return Ct.cache[u].result;let f=Math.min(e,t),l=Math.max(e,t);if(Math.abs(f-l)===1){let h=e+"|"+t;return r.capture?`(${h})`:r.wrap===!1?h:`(?:${h})`}let p=mf(e)||mf(t),d={min:e,max:t,a:f,b:l},m=[],g=[];if(p&&(d.isPadded=p,d.maxLen=String(d.max).length),f<0){let h=l<0?Math.abs(l):1;g=uf(h,Math.abs(f),d,r),f=d.a=0}return l>=0&&(m=uf(f,l,d,r)),d.negatives=g,d.positives=m,d.result=DR(g,m,r),r.capture===!0?d.result=`(${d.result})`:r.wrap!==!1&&m.length+g.length>1&&(d.result=`(?:${d.result})`),Ct.cache[u]=d,d.result},"toRegexRange");function DR(e,t,n){let r=Bs(e,t,"-",!1,n)||[],o=Bs(t,e,"",!1,n)||[],i=Bs(e,t,"-?",!0,n)||[];return r.concat(i).concat(o).join("|")}s(DR,"collatePatterns");function FR(e,t){let n=1,r=1,o=ff(e,n),i=new Set([t]);for(;e<=o&&o<=t;)i.add(o),n+=1,o=ff(e,n);for(o=df(t+1,r)-1;e<o&&o<=t;)i.add(o),r+=1,o=df(t+1,r)-1;return i=[...i],i.sort(jR),i}s(FR,"splitToRanges");function $R(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=BR(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+=KR(u,f,n):a++}return a&&(i+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:i,count:[a],digits:o}}s($R,"rangeToPattern");function uf(e,t,n,r){let o=FR(e,t),i=[],a=e,c;for(let u=0;u<o.length;u++){let f=o[u],l=$R(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+pf(c.count),a=f+1;continue}n.isPadded&&(p=GR(f,n,r)),l.string=p+l.pattern+pf(l.count),i.push(l),a=f+1,c=l}return i}s(uf,"splitToPatterns");function Bs(e,t,n,r,o){let i=[];for(let a of e){let{string:c}=a;!r&&!lf(t,"string",c)&&i.push(n+c),r&&lf(t,"string",c)&&i.push(n+c)}return i}s(Bs,"filterPatterns");function BR(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}s(BR,"zip");function jR(e,t){return e>t?1:t>e?-1:0}s(jR,"compare");function lf(e,t,n){return e.some(r=>r[t]===n)}s(lf,"contains");function ff(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}s(ff,"countNines");function df(e,t){return e-e%Math.pow(10,t)}s(df,"countZeros");function pf(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}s(pf,"toQuantifier");function KR(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}s(KR,"toCharacterClass");function mf(e){return/^-?(0+)\d/.test(e)}s(mf,"hasPadding");function GR(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(GR,"padZeros");Ct.cache={};Ct.clearCache=()=>Ct.cache={};gf.exports=Ct});var Gs=J((gw,Cf)=>{"use strict";var VR=qe("util"),Sf=_f(),hf=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"isObject"),zR=s(e=>t=>e===!0?Number(t):String(t),"transform"),js=s(e=>typeof e=="number"||typeof e=="string"&&e!=="","isValidValue"),Pn=s(e=>Number.isInteger(+e),"isNumber"),Ks=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"),WR=s((e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,"stringify"),JR=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"),Yr=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"),YR=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=>Yr(String(c),n)).join("|")),e.negatives.length&&(i=`-(${r}${e.negatives.map(c=>Yr(String(c),n)).join("|")})`),o&&i?a=`${o}|${i}`:a=o||i,t.wrap?`(${r}${a})`:a},"toSequence"),Ef=s((e,t,n,r)=>{if(n)return Sf(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let i=String.fromCharCode(t);return`[${o}-${i}]`},"toRange"),yf=s((e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return Sf(e,t,n)},"toRegex"),Rf=s((...e)=>new RangeError("Invalid range arguments: "+VR.inspect(...e)),"rangeError"),Af=s((e,t,n)=>{if(n.strictRanges===!0)throw Rf([e,t]);return[]},"invalidRange"),XR=s((e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},"invalidStep"),qR=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 Rf([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=Ks(c)||Ks(u)||Ks(f),p=l?Math.max(c.length,u.length,f.length):0,d=l===!1&&WR(e,t,r)===!1,m=r.transform||zR(d);if(r.toRegex&&n===1)return Ef(Yr(e,p),Yr(t,p),!0,r);let g={negatives:[],positives:[]},h=s(T=>g[T<0?"negatives":"positives"].push(Math.abs(T)),"push"),y=[],b=0;for(;a?o>=i:o<=i;)r.toRegex===!0&&n>1?h(o):y.push(JR(m(o,b),p,d)),o=a?o-n:o+n,b++;return r.toRegex===!0?n>1?YR(g,r,p):yf(y,null,{wrap:!1,...r}):y},"fillNumbers"),ZR=s((e,t,n=1,r={})=>{if(!Pn(e)&&e.length>1||!Pn(t)&&t.length>1)return Af(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 Ef(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?yf(l,null,{wrap:!1,options:r}):l},"fillLetters"),Jr=s((e,t,n,r={})=>{if(t==null&&js(e))return[e];if(!js(e)||!js(t))return Af(e,t,r);if(typeof n=="function")return Jr(e,t,1,{transform:n});if(hf(n))return Jr(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,Pn(n)?Pn(e)&&Pn(t)?qR(e,t,n,o):ZR(e,t,Math.max(Math.abs(n),1),o):n!=null&&!hf(n)?XR(n,o):Jr(e,t,1,n)},"fill");Cf.exports=Jr});var Of=J((hw,xf)=>{"use strict";var QR=Gs(),bf=zr(),eA=s((e,t={})=>{let n=s((r,o={})=>{let i=bf.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=bf.reduce(r.nodes),p=QR(...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");xf.exports=eA});var Tf=J((Ew,kf)=>{"use strict";var tA=Gs(),If=Wr(),Jt=zr(),bt=s((e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?Jt.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let i of o)r.push(bt(i,t,n));else for(let i of t)n===!0&&typeof i=="string"&&(i=`{${i}}`),r.push(Array.isArray(i)?bt(o,i,n):o+i);return Jt.flatten(r)},"append"),nA=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(bt(c.pop(),If(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){c.push(bt(c.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let p=Jt.reduce(o.nodes);if(Jt.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=tA(...p,t);d.length===0&&(d=If(o,t)),c.push(bt(c.pop(),d)),o.nodes=[];return}let u=Jt.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(bt(c.pop(),f,u));continue}if(d.value&&d.type!=="open"){f.push(bt(f.pop(),d.value));continue}d.nodes&&r(d,o)}return f},"walk");return Jt.flatten(r(e))},"expand");kf.exports=nA});var Nf=J((Rw,Pf)=>{"use strict";Pf.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 Uf=J((Aw,Mf)=>{"use strict";var rA=Wr(),{MAX_LENGTH:wf,CHAR_BACKSLASH:Vs,CHAR_BACKTICK:oA,CHAR_COMMA:sA,CHAR_DOT:iA,CHAR_LEFT_PARENTHESES:aA,CHAR_RIGHT_PARENTHESES:cA,CHAR_LEFT_CURLY_BRACE:uA,CHAR_RIGHT_CURLY_BRACE:lA,CHAR_LEFT_SQUARE_BRACKET:Lf,CHAR_RIGHT_SQUARE_BRACKET:vf,CHAR_DOUBLE_QUOTE:fA,CHAR_SINGLE_QUOTE:dA,CHAR_NO_BREAK_SPACE:pA,CHAR_ZERO_WIDTH_NOBREAK_SPACE:mA}=Nf(),gA=s((e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(wf,n.maxLength):wf;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},i=[o],a=o,c=o,u=0,f=e.length,l=0,p=0,d,m=s(()=>e[l++],"advance"),g=s(h=>{if(h.type==="text"&&c.type==="dot"&&(c.type="text"),c&&c.type==="text"&&h.type==="text"){c.value+=h.value;return}return a.nodes.push(h),h.parent=a,h.prev=c,c=h,h},"push");for(g({type:"bos"});l<f;)if(a=i[i.length-1],d=m(),!(d===mA||d===pA)){if(d===Vs){g({type:"text",value:(t.keepEscaping?d:"")+m()});continue}if(d===vf){g({type:"text",value:"\\"+d});continue}if(d===Lf){u++;let h;for(;l<f&&(h=m());){if(d+=h,h===Lf){u++;continue}if(h===Vs){d+=m();continue}if(h===vf&&(u--,u===0))break}g({type:"text",value:d});continue}if(d===aA){a=g({type:"paren",nodes:[]}),i.push(a),g({type:"text",value:d});continue}if(d===cA){if(a.type!=="paren"){g({type:"text",value:d});continue}a=i.pop(),g({type:"text",value:d}),a=i[i.length-1];continue}if(d===fA||d===dA||d===oA){let h=d,y;for(t.keepQuotes!==!0&&(d="");l<f&&(y=m());){if(y===Vs){d+=y+m();continue}if(y===h){t.keepQuotes===!0&&(d+=y);break}d+=y}g({type:"text",value:d});continue}if(d===uA){p++;let y={type:"brace",open:!0,close:!1,dollar:c.value&&c.value.slice(-1)==="$"||a.dollar===!0,depth:p,commas:0,ranges:0,nodes:[]};a=g(y),i.push(a),g({type:"open",value:d});continue}if(d===lA){if(a.type!=="brace"){g({type:"text",value:d});continue}let h="close";a=i.pop(),a.close=!0,g({type:h,value:d}),p--,a=i[i.length-1];continue}if(d===sA&&p>0){if(a.ranges>0){a.ranges=0;let h=a.nodes.shift();a.nodes=[h,{type:"text",value:rA(a)}]}g({type:"comma",value:d}),a.commas++;continue}if(d===iA&&p>0&&a.commas===0){let h=a.nodes;if(p===0||h.length===0){g({type:"text",value:d});continue}if(c.type==="dot"){if(a.range=[],c.value+=d,c.type="range",a.nodes.length!==3&&a.nodes.length!==5){a.invalid=!0,a.ranges=0,c.type="text";continue}a.ranges++,a.args=[];continue}if(c.type==="range"){h.pop();let y=h[h.length-1];y.value+=c.value+d,c=y,a.ranges--;continue}g({type:"dot",value:d});continue}g({type:"text",value:d})}do if(a=i.pop(),a.type!=="root"){a.nodes.forEach(b=>{b.nodes||(b.type==="open"&&(b.isOpen=!0),b.type==="close"&&(b.isClose=!0),b.nodes||(b.type="text"),b.invalid=!0)});let h=i[i.length-1],y=h.nodes.indexOf(a);h.nodes.splice(y,1,...a.nodes)}while(i.length>0);return g({type:"eos"}),o},"parse");Mf.exports=gA});var Ff=J((bw,Df)=>{"use strict";var Hf=Wr(),_A=Of(),hA=Tf(),SA=Uf(),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={})=>SA(e,t);ye.stringify=(e,t={})=>Hf(typeof e=="string"?ye.parse(e,t):e,t);ye.compile=(e,t={})=>(typeof e=="string"&&(e=ye.parse(e,t)),_A(e,t));ye.expand=(e,t={})=>{typeof e=="string"&&(e=ye.parse(e,t));let n=hA(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);Df.exports=ye});var Nn=J((Ow,Gf)=>{"use strict";var EA=qe("path"),He="\\\\/",$f=`[^${He}]`,yA=0,Ye="\\.",RA="\\+",AA="\\?",Xr="\\/",CA="(?=.)",Bf="[^/]",zs=`(?:${Xr}|$)`,jf=`(?:^|${Xr})`,Ws=`${Ye}{1,2}${zs}`,bA=`(?!${Ye})`,xA=`(?!${jf}${Ws})`,OA=`(?!${Ye}{0,1}${zs})`,IA=`(?!${Ws})`,kA=`[^.${Xr}]`,TA=`${Bf}*?`,Kf={DOT_LITERAL:Ye,PLUS_LITERAL:RA,QMARK_LITERAL:AA,SLASH_LITERAL:Xr,ONE_CHAR:CA,QMARK:Bf,END_ANCHOR:zs,DOTS_SLASH:Ws,NO_DOT:bA,NO_DOTS:xA,NO_DOT_SLASH:OA,NO_DOTS_SLASH:IA,QMARK_NO_DOT:kA,STAR:TA,START_ANCHOR:jf},PA={...Kf,SLASH_LITERAL:`[${He}]`,QMARK:$f,STAR:`${$f}*?`,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}]|$)`},NA={__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"};Gf.exports={DEFAULT_MAX_EXTGLOB_RECURSION:yA,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:NA,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:EA.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?PA:Kf}}});var wn=J(ge=>{"use strict";var wA=qe("path"),LA=process.platform==="win32",{REGEX_BACKSLASH:vA,REGEX_REMOVE_BACKSLASH:MA,REGEX_SPECIAL_CHARS:UA,REGEX_SPECIAL_CHARS_GLOBAL:HA}=Nn();ge.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);ge.hasRegexChars=e=>UA.test(e);ge.isRegexChar=e=>e.length===1&&ge.hasRegexChars(e);ge.escapeRegex=e=>e.replace(HA,"\\$1");ge.toPosixSlashes=e=>e.replace(vA,"/");ge.removeBackslashes=e=>e.replace(MA,t=>t==="\\"?"":t);ge.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};ge.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:LA===!0||wA.sep==="\\";ge.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?ge.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};ge.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};ge.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",i=`${r}(?:${e})${o}`;return t.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var Zf=J((kw,qf)=>{"use strict";var Vf=wn(),{CHAR_ASTERISK:Js,CHAR_AT:DA,CHAR_BACKWARD_SLASH:Ln,CHAR_COMMA:FA,CHAR_DOT:Ys,CHAR_EXCLAMATION_MARK:Xs,CHAR_FORWARD_SLASH:Xf,CHAR_LEFT_CURLY_BRACE:qs,CHAR_LEFT_PARENTHESES:Zs,CHAR_LEFT_SQUARE_BRACKET:$A,CHAR_PLUS:BA,CHAR_QUESTION_MARK:zf,CHAR_RIGHT_CURLY_BRACE:jA,CHAR_RIGHT_PARENTHESES:Wf,CHAR_RIGHT_SQUARE_BRACKET:KA}=Nn(),Jf=s(e=>e===Xf||e===Ln,"isPathSeparator"),Yf=s(e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},"depth"),GA=s((e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,i=[],a=[],c=[],u=e,f=-1,l=0,p=0,d=!1,m=!1,g=!1,h=!1,y=!1,b=!1,T=!1,N=!1,O=!1,x=!1,v=0,L,I,w={value:"",depth:0,isGlob:!1},F=s(()=>f>=r,"eos"),_=s(()=>u.charCodeAt(f+1),"peek"),k=s(()=>(L=I,u.charCodeAt(++f)),"advance");for(;f<r;){I=k();let de;if(I===Ln){T=w.backslashes=!0,I=k(),I===qs&&(b=!0);continue}if(b===!0||I===qs){for(v++;F()!==!0&&(I=k());){if(I===Ln){T=w.backslashes=!0,k();continue}if(I===qs){v++;continue}if(b!==!0&&I===Ys&&(I=k())===Ys){if(d=w.isBrace=!0,g=w.isGlob=!0,x=!0,o===!0)continue;break}if(b!==!0&&I===FA){if(d=w.isBrace=!0,g=w.isGlob=!0,x=!0,o===!0)continue;break}if(I===jA&&(v--,v===0)){b=!1,d=w.isBrace=!0,x=!0;break}}if(o===!0)continue;break}if(I===Xf){if(i.push(f),a.push(w),w={value:"",depth:0,isGlob:!1},x===!0)continue;if(L===Ys&&f===l+1){l+=2;continue}p=f+1;continue}if(n.noext!==!0&&(I===BA||I===DA||I===Js||I===zf||I===Xs)===!0&&_()===Zs){if(g=w.isGlob=!0,h=w.isExtglob=!0,x=!0,I===Xs&&f===l&&(O=!0),o===!0){for(;F()!==!0&&(I=k());){if(I===Ln){T=w.backslashes=!0,I=k();continue}if(I===Wf){g=w.isGlob=!0,x=!0;break}}continue}break}if(I===Js){if(L===Js&&(y=w.isGlobstar=!0),g=w.isGlob=!0,x=!0,o===!0)continue;break}if(I===zf){if(g=w.isGlob=!0,x=!0,o===!0)continue;break}if(I===$A){for(;F()!==!0&&(de=k());){if(de===Ln){T=w.backslashes=!0,k();continue}if(de===KA){m=w.isBracket=!0,g=w.isGlob=!0,x=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&I===Xs&&f===l){N=w.negated=!0,l++;continue}if(n.noparen!==!0&&I===Zs){if(g=w.isGlob=!0,o===!0){for(;F()!==!0&&(I=k());){if(I===Zs){T=w.backslashes=!0,I=k();continue}if(I===Wf){x=!0;break}}continue}break}if(g===!0){if(x=!0,o===!0)continue;break}}n.noext===!0&&(h=!1,g=!1);let B=u,he="",S="";l>0&&(he=u.slice(0,l),u=u.slice(l),p-=l),B&&g===!0&&p>0?(B=u.slice(0,p),S=u.slice(p)):g===!0?(B="",S=u):B=u,B&&B!==""&&B!=="/"&&B!==u&&Jf(B.charCodeAt(B.length-1))&&(B=B.slice(0,-1)),n.unescape===!0&&(S&&(S=Vf.removeBackslashes(S)),B&&T===!0&&(B=Vf.removeBackslashes(B)));let E={prefix:he,input:e,start:l,base:B,glob:S,isBrace:d,isBracket:m,isGlob:g,isExtglob:h,isGlobstar:y,negated:N,negatedExtglob:O};if(n.tokens===!0&&(E.maxDepth=0,Jf(I)||a.push(w),E.tokens=a),n.parts===!0||n.tokens===!0){let de;for(let j=0;j<i.length;j++){let Te=de?de+1:l,Pe=i[j],Se=e.slice(Te,Pe);n.tokens&&(j===0&&l!==0?(a[j].isPrefix=!0,a[j].value=he):a[j].value=Se,Yf(a[j]),E.maxDepth+=a[j].depth),(j!==0||Se!=="")&&c.push(Se),de=Pe}if(de&&de+1<e.length){let j=e.slice(de+1);c.push(j),n.tokens&&(a[a.length-1].value=j,Yf(a[a.length-1]),E.maxDepth+=a[a.length-1].depth)}E.slashes=i,E.parts=c}return E},"scan");qf.exports=GA});var rd=J((Pw,nd)=>{"use strict";var vn=Nn(),fe=wn(),{MAX_LENGTH:qr,POSIX_REGEX_SOURCE:VA,REGEX_NON_SPECIAL_CHARS:zA,REGEX_SPECIAL_CHARS_BACKREF:WA,REPLACEMENTS:Qf}=vn,JA=s((e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(o=>fe.escapeRegex(o)).join("..")}return n},"expandRange"),Yt=s((e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,"syntaxError"),ed=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"),YA=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"),td=s(e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(YA(t))return t.replace(/\\(.)/g,"$1")},"normalizeSimpleBranch"),XA=s(e=>{let t=e.map(td).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"),Qs=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"),qA=s(e=>{let t=0,n=[];for(;t<e.length;){let o=Qs(e.slice(t),!1);if(!o||o.type!=="*")return;let i=ed(o.body).map(c=>c.trim());if(i.length!==1)return;let a=td(i[0]);if(!a||a.length!==1)return;n.push(a),t+=o.end+1}return n.length<1?void 0:`${n.length===1?fe.escapeRegex(n[0]):`[${n.map(o=>fe.escapeRegex(o)).join("")}]`}*`},"getStarExtglobSequenceOutput"),ZA=s(e=>{let t=0,n=e.trim(),r=Qs(n);for(;r;)t++,n=r.body.trim(),r=Qs(n);return t},"repeatedExtglobRecursion"),QA=s((e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:vn.DEFAULT_MAX_EXTGLOB_RECURSION,r=ed(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||XA(r)))return{risky:!0};for(let o of r){let i=qA(o);if(i)return{risky:!0,safeOutput:i};if(ZA(o)>n)return{risky:!0}}return{risky:!1}},"analyzeRepeatedExtglob"),ei=s((e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=Qf[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(qr,n.maxLength):qr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let i={type:"bos",value:"",output:n.prepend||""},a=[i],c=n.capture?"":"?:",u=fe.isWindows(t),f=vn.globChars(u),l=vn.extglobChars(f),{DOT_LITERAL:p,PLUS_LITERAL:d,SLASH_LITERAL:m,ONE_CHAR:g,DOTS_SLASH:h,NO_DOT:y,NO_DOT_SLASH:b,NO_DOTS_SLASH:T,QMARK:N,QMARK_NO_DOT:O,STAR:x,START_ANCHOR:v}=f,L=s(C=>`(${c}(?:(?!${v}${C.dot?h:p}).)*?)`,"globstar"),I=n.dot?"":y,w=n.dot?N:O,F=n.bash===!0?L(n):x;n.capture&&(F=`(${F})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let _={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:a};e=fe.removePrefix(e,_),o=e.length;let k=[],B=[],he=[],S=i,E,de=s(()=>_.index===o-1,"eos"),j=_.peek=(C=1)=>e[_.index+C],Te=_.advance=()=>e[++_.index]||"",Pe=s(()=>e.slice(_.index+1),"remaining"),Se=s((C="",X=0)=>{_.consumed+=C,_.index+=X},"consume"),Vn=s(C=>{_.output+=C.output!=null?C.output:C.value,Se(C.value)},"append"),Um=s(()=>{let C=1;for(;j()==="!"&&(j(2)!=="("||j(3)==="?");)Te(),_.start++,C++;return C%2===0?!1:(_.negated=!0,_.start++,!0)},"negate"),zn=s(C=>{_[C]++,he.push(C)},"increment"),Xe=s(C=>{_[C]--,he.pop()},"decrement"),U=s(C=>{if(S.type==="globstar"){let X=_.braces>0&&(C.type==="comma"||C.type==="brace"),A=C.extglob===!0||k.length&&(C.type==="pipe"||C.type==="paren");C.type!=="slash"&&C.type!=="paren"&&!X&&!A&&(_.output=_.output.slice(0,-S.output.length),S.type="star",S.value="*",S.output=F,_.output+=S.output)}if(k.length&&C.type!=="paren"&&(k[k.length-1].inner+=C.value),(C.value||C.output)&&Vn(C),S&&S.type==="text"&&C.type==="text"){S.value+=C.value,S.output=(S.output||"")+C.value;return}C.prev=S,a.push(C),S=C},"push"),Wn=s((C,X)=>{let A={...l[X],conditions:1,inner:""};A.prev=S,A.parens=_.parens,A.output=_.output,A.startIndex=_.index,A.tokensIndex=a.length;let M=(n.capture?"(":"")+A.open;zn("parens"),U({type:C,value:X,output:_.output?"":g}),U({type:"paren",extglob:!0,value:Te(),output:M}),k.push(A)},"extglobOpen"),Hm=s(C=>{let X=e.slice(C.startIndex,_.index+1),A=e.slice(C.startIndex+2,_.index),M=QA(A,n);if((C.type==="plus"||C.type==="star")&&M.risky){let z=M.safeOutput?(C.output?"":g)+(n.capture?`(${M.safeOutput})`:M.safeOutput):void 0,Ne=a[C.tokensIndex];Ne.type="text",Ne.value=X,Ne.output=z||fe.escapeRegex(X);for(let we=C.tokensIndex+1;we<a.length;we++)a[we].value="",a[we].output="",delete a[we].suffix;_.output=C.output+Ne.output,_.backtrack=!0,U({type:"paren",extglob:!0,value:E,output:""}),Xe("parens");return}let W=C.close+(n.capture?")":""),ie;if(C.type==="negate"){let z=F;if(C.inner&&C.inner.length>1&&C.inner.includes("/")&&(z=L(n)),(z!==F||de()||/^\)+$/.test(Pe()))&&(W=C.close=`)$))${z}`),C.inner.includes("*")&&(ie=Pe())&&/^\.[^\\/.]+$/.test(ie)){let Ne=ei(ie,{...t,fastpaths:!1}).output;W=C.close=`)${Ne})${z})`}C.prev.type==="bos"&&(_.negatedExtglob=!0)}U({type:"paren",extglob:!0,value:E,output:W}),Xe("parens")},"extglobClose");if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let C=!1,X=e.replace(WA,(A,M,W,ie,z,Ne)=>ie==="\\"?(C=!0,A):ie==="?"?M?M+ie+(z?N.repeat(z.length):""):Ne===0?w+(z?N.repeat(z.length):""):N.repeat(W.length):ie==="."?p.repeat(W.length):ie==="*"?M?M+ie+(z?F:""):F:M?A:`\\${A}`);return C===!0&&(n.unescape===!0?X=X.replace(/\\/g,""):X=X.replace(/\\+/g,A=>A.length%2===0?"\\\\":A?"\\":"")),X===e&&n.contains===!0?(_.output=e,_):(_.output=fe.wrapOutput(X,_,t),_)}for(;!de();){if(E=Te(),E==="\0")continue;if(E==="\\"){let A=j();if(A==="/"&&n.bash!==!0||A==="."||A===";")continue;if(!A){E+="\\",U({type:"text",value:E});continue}let M=/^\\+/.exec(Pe()),W=0;if(M&&M[0].length>2&&(W=M[0].length,_.index+=W,W%2!==0&&(E+="\\")),n.unescape===!0?E=Te():E+=Te(),_.brackets===0){U({type:"text",value:E});continue}}if(_.brackets>0&&(E!=="]"||S.value==="["||S.value==="[^")){if(n.posix!==!1&&E===":"){let A=S.value.slice(1);if(A.includes("[")&&(S.posix=!0,A.includes(":"))){let M=S.value.lastIndexOf("["),W=S.value.slice(0,M),ie=S.value.slice(M+2),z=VA[ie];if(z){S.value=W+z,_.backtrack=!0,Te(),!i.output&&a.indexOf(S)===1&&(i.output=g);continue}}}(E==="["&&j()!==":"||E==="-"&&j()==="]")&&(E=`\\${E}`),E==="]"&&(S.value==="["||S.value==="[^")&&(E=`\\${E}`),n.posix===!0&&E==="!"&&S.value==="["&&(E="^"),S.value+=E,Vn({value:E});continue}if(_.quotes===1&&E!=='"'){E=fe.escapeRegex(E),S.value+=E,Vn({value:E});continue}if(E==='"'){_.quotes=_.quotes===1?0:1,n.keepQuotes===!0&&U({type:"text",value:E});continue}if(E==="("){zn("parens"),U({type:"paren",value:E});continue}if(E===")"){if(_.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Yt("opening","("));let A=k[k.length-1];if(A&&_.parens===A.parens+1){Hm(k.pop());continue}U({type:"paren",value:E,output:_.parens?")":"\\)"}),Xe("parens");continue}if(E==="["){if(n.nobracket===!0||!Pe().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Yt("closing","]"));E=`\\${E}`}else zn("brackets");U({type:"bracket",value:E});continue}if(E==="]"){if(n.nobracket===!0||S&&S.type==="bracket"&&S.value.length===1){U({type:"text",value:E,output:`\\${E}`});continue}if(_.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Yt("opening","["));U({type:"text",value:E,output:`\\${E}`});continue}Xe("brackets");let A=S.value.slice(1);if(S.posix!==!0&&A[0]==="^"&&!A.includes("/")&&(E=`/${E}`),S.value+=E,Vn({value:E}),n.literalBrackets===!1||fe.hasRegexChars(A))continue;let M=fe.escapeRegex(S.value);if(_.output=_.output.slice(0,-S.value.length),n.literalBrackets===!0){_.output+=M,S.value=M;continue}S.value=`(${c}${M}|${S.value})`,_.output+=S.value;continue}if(E==="{"&&n.nobrace!==!0){zn("braces");let A={type:"brace",value:E,output:"(",outputIndex:_.output.length,tokensIndex:_.tokens.length};B.push(A),U(A);continue}if(E==="}"){let A=B[B.length-1];if(n.nobrace===!0||!A){U({type:"text",value:E,output:E});continue}let M=")";if(A.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=JA(ie,n),_.backtrack=!0}if(A.comma!==!0&&A.dots!==!0){let W=_.output.slice(0,A.outputIndex),ie=_.tokens.slice(A.tokensIndex);A.value=A.output="\\{",E=M="\\}",_.output=W;for(let z of ie)_.output+=z.output||z.value}U({type:"brace",value:E,output:M}),Xe("braces"),B.pop();continue}if(E==="|"){k.length>0&&k[k.length-1].conditions++,U({type:"text",value:E});continue}if(E===","){let A=E,M=B[B.length-1];M&&he[he.length-1]==="braces"&&(M.comma=!0,A="|"),U({type:"comma",value:E,output:A});continue}if(E==="/"){if(S.type==="dot"&&_.index===_.start+1){_.start=_.index+1,_.consumed="",_.output="",a.pop(),S=i;continue}U({type:"slash",value:E,output:m});continue}if(E==="."){if(_.braces>0&&S.type==="dot"){S.value==="."&&(S.output=p);let A=B[B.length-1];S.type="dots",S.output+=E,S.value+=E,A.dots=!0;continue}if(_.braces+_.parens===0&&S.type!=="bos"&&S.type!=="slash"){U({type:"text",value:E,output:p});continue}U({type:"dot",value:E,output:p});continue}if(E==="?"){if(!(S&&S.value==="(")&&n.noextglob!==!0&&j()==="("&&j(2)!=="?"){Wn("qmark",E);continue}if(S&&S.type==="paren"){let M=j(),W=E;if(M==="<"&&!fe.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(S.value==="("&&!/[!=<:]/.test(M)||M==="<"&&!/<([!=]|\w+>)/.test(Pe()))&&(W=`\\${E}`),U({type:"text",value:E,output:W});continue}if(n.dot!==!0&&(S.type==="slash"||S.type==="bos")){U({type:"qmark",value:E,output:O});continue}U({type:"qmark",value:E,output:N});continue}if(E==="!"){if(n.noextglob!==!0&&j()==="("&&(j(2)!=="?"||!/[!=<:]/.test(j(3)))){Wn("negate",E);continue}if(n.nonegate!==!0&&_.index===0){Um();continue}}if(E==="+"){if(n.noextglob!==!0&&j()==="("&&j(2)!=="?"){Wn("plus",E);continue}if(S&&S.value==="("||n.regex===!1){U({type:"plus",value:E,output:d});continue}if(S&&(S.type==="bracket"||S.type==="paren"||S.type==="brace")||_.parens>0){U({type:"plus",value:E});continue}U({type:"plus",value:d});continue}if(E==="@"){if(n.noextglob!==!0&&j()==="("&&j(2)!=="?"){U({type:"at",extglob:!0,value:E,output:""});continue}U({type:"text",value:E});continue}if(E!=="*"){(E==="$"||E==="^")&&(E=`\\${E}`);let A=zA.exec(Pe());A&&(E+=A[0],_.index+=A[0].length),U({type:"text",value:E});continue}if(S&&(S.type==="globstar"||S.star===!0)){S.type="star",S.star=!0,S.value+=E,S.output=F,_.backtrack=!0,_.globstar=!0,Se(E);continue}let C=Pe();if(n.noextglob!==!0&&/^\([^?]/.test(C)){Wn("star",E);continue}if(S.type==="star"){if(n.noglobstar===!0){Se(E);continue}let A=S.prev,M=A.prev,W=A.type==="slash"||A.type==="bos",ie=M&&(M.type==="star"||M.type==="globstar");if(n.bash===!0&&(!W||C[0]&&C[0]!=="/")){U({type:"star",value:E,output:""});continue}let z=_.braces>0&&(A.type==="comma"||A.type==="brace"),Ne=k.length&&(A.type==="pipe"||A.type==="paren");if(!W&&A.type!=="paren"&&!z&&!Ne){U({type:"star",value:E,output:""});continue}for(;C.slice(0,3)==="/**";){let we=e[_.index+4];if(we&&we!=="/")break;C=C.slice(3),Se("/**",3)}if(A.type==="bos"&&de()){S.type="globstar",S.value+=E,S.output=L(n),_.output=S.output,_.globstar=!0,Se(E);continue}if(A.type==="slash"&&A.prev.type!=="bos"&&!ie&&de()){_.output=_.output.slice(0,-(A.output+S.output).length),A.output=`(?:${A.output}`,S.type="globstar",S.output=L(n)+(n.strictSlashes?")":"|$)"),S.value+=E,_.globstar=!0,_.output+=A.output+S.output,Se(E);continue}if(A.type==="slash"&&A.prev.type!=="bos"&&C[0]==="/"){let we=C[1]!==void 0?"|$":"";_.output=_.output.slice(0,-(A.output+S.output).length),A.output=`(?:${A.output}`,S.type="globstar",S.output=`${L(n)}${m}|${m}${we})`,S.value+=E,_.output+=A.output+S.output,_.globstar=!0,Se(E+Te()),U({type:"slash",value:"/",output:""});continue}if(A.type==="bos"&&C[0]==="/"){S.type="globstar",S.value+=E,S.output=`(?:^|${m}|${L(n)}${m})`,_.output=S.output,_.globstar=!0,Se(E+Te()),U({type:"slash",value:"/",output:""});continue}_.output=_.output.slice(0,-S.output.length),S.type="globstar",S.output=L(n),S.value+=E,_.output+=S.output,_.globstar=!0,Se(E);continue}let X={type:"star",value:E,output:F};if(n.bash===!0){X.output=".*?",(S.type==="bos"||S.type==="slash")&&(X.output=I+X.output),U(X);continue}if(S&&(S.type==="bracket"||S.type==="paren")&&n.regex===!0){X.output=E,U(X);continue}(_.index===_.start||S.type==="slash"||S.type==="dot")&&(S.type==="dot"?(_.output+=b,S.output+=b):n.dot===!0?(_.output+=T,S.output+=T):(_.output+=I,S.output+=I),j()!=="*"&&(_.output+=g,S.output+=g)),U(X)}for(;_.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Yt("closing","]"));_.output=fe.escapeLast(_.output,"["),Xe("brackets")}for(;_.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Yt("closing",")"));_.output=fe.escapeLast(_.output,"("),Xe("parens")}for(;_.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Yt("closing","}"));_.output=fe.escapeLast(_.output,"{"),Xe("braces")}if(n.strictSlashes!==!0&&(S.type==="star"||S.type==="bracket")&&U({type:"maybe_slash",value:"",output:`${m}?`}),_.backtrack===!0){_.output="";for(let C of _.tokens)_.output+=C.output!=null?C.output:C.value,C.suffix&&(_.output+=C.suffix)}return _},"parse");ei.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(qr,n.maxLength):qr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=Qf[e]||e;let i=fe.isWindows(t),{DOT_LITERAL:a,SLASH_LITERAL:c,ONE_CHAR:u,DOTS_SLASH:f,NO_DOT:l,NO_DOTS:p,NO_DOTS_SLASH:d,STAR:m,START_ANCHOR:g}=vn.globChars(i),h=n.dot?p:l,y=n.dot?d:l,b=n.capture?"":"?:",T={negated:!1,prefix:""},N=n.bash===!0?".*?":m;n.capture&&(N=`(${N})`);let O=s(I=>I.noglobstar===!0?N:`(${b}(?:(?!${g}${I.dot?f:a}).)*?)`,"globstar"),x=s(I=>{switch(I){case"*":return`${h}${u}${N}`;case".*":return`${a}${u}${N}`;case"*.*":return`${h}${N}${a}${u}${N}`;case"*/*":return`${h}${N}${c}${u}${y}${N}`;case"**":return h+O(n);case"**/*":return`(?:${h}${O(n)}${c})?${y}${u}${N}`;case"**/*.*":return`(?:${h}${O(n)}${c})?${y}${N}${a}${u}${N}`;case"**/.*":return`(?:${h}${O(n)}${c})?${a}${u}${N}`;default:{let w=/^(.*?)\.(\w+)$/.exec(I);if(!w)return;let F=x(w[1]);return F?F+a+w[2]:void 0}}},"create"),v=fe.removePrefix(e,T),L=x(v);return L&&n.strictSlashes!==!0&&(L+=`${c}?`),L};nd.exports=ei});var sd=J((ww,od)=>{"use strict";var eC=qe("path"),tC=Zf(),ti=rd(),ni=wn(),nC=Nn(),rC=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 g=m(d);if(g)return g}return!1},"arrayMatcher")}let r=rC(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=ni.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:g}=re.test(l,a,t,{glob:e,posix:i}),h={glob:e,state:c,regex:a,posix:i,input:l,output:g,match:m,isMatch:d};return typeof o.onResult=="function"&&o.onResult(h),d===!1?(h.isMatch=!1,p?h:!1):u(l)?(typeof o.onIgnore=="function"&&o.onIgnore(h),h.isMatch=!1,p?h:!1):(typeof o.onMatch=="function"&&o.onMatch(h),p?h:!0)},"matcher");return n&&(f.state=c),f},"picomatch");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?ni.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=ni.isWindows(n))=>(t instanceof RegExp?t:re.makeRe(t,n)).test(eC.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)):ti(e,{...t,fastpaths:!1});re.scan=(e,t)=>tC(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=ti.fastpaths(e,t)),o.output||(o=ti(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=nC;od.exports=re});var ad=J((vw,id)=>{"use strict";id.exports=sd()});var pd=J((Mw,dd)=>{"use strict";var ud=qe("util"),ld=Ff(),De=ad(),ri=wn(),cd=s(e=>e===""||e==="./","isEmptyString"),fd=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 g=p(m,!0);(d?!g.isMatch:g.isMatch)&&(d?r.add(g.output):(r.delete(g.output),o.add(g.output)))}}let f=(a===t.length?[...i]:[...o]).filter(l=>!r.has(l));if(n&&f.length===0){if(n.failglob===!0)throw new Error(`No matches found for "${t.join(", ")}"`);if(n.nonull===!0||n.nullglob===!0)return n.unescape?t.map(l=>l.replace(/\\/g,"")):t}return f},"micromatch");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: "${ud.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>Y.contains(e,r,n));if(typeof t=="string"){if(cd(e)||cd(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return Y.isMatch(e,t,{...n,contains:!0})};Y.matchKeys=(e,t,n)=>{if(!ri.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: "${ud.inspect(e)}"`);return[].concat(t).every(r=>De(r,n)(e))};Y.capture=(e,t,n)=>{let r=ri.isWindows(n),i=De.makeRe(String(e),{...n,capture:!0}).exec(r?ri.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 ld(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||!fd(e)?[e]:ld(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=fd;dd.exports=Y});import{existsSync as og,readFileSync as sg}from"node:fs";import{hostname as ca,release as ig,userInfo as ag,version as cg}from"node:os";import*as pe from"node:os";import{performance as yo}from"node:perf_hooks";var Gm=1024*1024,Vm=128;function Jn(e){return Math.round(e/Gm)}s(Jn,"mb");function an(e,t){let n=10**t;return Math.round(e*n)/n}s(an,"round");function zi(e=process.platform){try{let t=yo.now(),n={},r=0,o=0,i=e!=="win32";for(let{times:u}of pe.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(pe.uptime()),n.mem_free_mb=Jn(pe.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=Jn(process.availableMemory())),e!=="win32"){let[u,f,l]=pe.loadavg();n.load_1m=an(u??0,2),n.load_5m=an(f??0,2),n.load_15m=an(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=yo.nodeTiming?.bootstrapComplete;return typeof c=="number"&&c>0&&(n.node_boot_ms=an(c,1)),n.sample_us=Math.round((yo.now()-t)*1e3),n}catch{return}}s(zi,"sampleSys");function Wi(){try{let e=pe.cpus(),t={},n=typeof pe.availableParallelism=="function"?pe.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,Vm);r&&(t.cpu_model=r);let o=pe.totalmem();t.mem_total_mb=Jn(o);let i=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof i=="number"&&i>0&&i<o&&(t.mem_limit_mb=Jn(i)),t.uptime_h=an(pe.uptime()/3600,1),t}catch{return{}}}s(Wi,"hostSpecs");import{createHash as zm,randomBytes as Wm}from"node:crypto";import{existsSync as Yn,mkdirSync as Jm,readdirSync as Ym,readFileSync as Xm,renameSync as Xi,statSync as qi,unlinkSync as Zi,writeFileSync as qm}from"node:fs";import{homedir as Qi}from"node:os";import{basename as Zm,dirname as Ji,isAbsolute as Qm,join as ea,relative as ta,resolve as Be,sep as eg}from"node:path";function P(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
|
|
14
|
+
`)}s(P,"logStderr");function cn(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}s(cn,"stripRemoteCredentials");function un(e){return zm("sha256").update(e).digest("hex").slice(0,32)}s(un,"sha32");var tg=3;function na(e){return e instanceof Error&&"code"in e?e.code:void 0}s(na,"errnoCode");function ra(e){let t=na(e);return t==="EEXIST"||t==="EPERM"||t==="EACCES"}s(ra,"isRenameReplaceBlocked");function ng(e,t,n){let r=n;for(let o=0;o<tg;o+=1){try{Zi(t)}catch(i){if(na(i)!=="ENOENT")throw i}try{Xi(e,t);return}catch(i){if(!ra(i))throw i;r=i}}throw r}s(ng,"replaceByUnlinkThenRename");function ue(e,t){Jm(Ji(e),{recursive:!0});let n=ea(Ji(e),`.${Zm(e)}.${process.pid}.${Wm(4).toString("hex")}.tmp`);try{qm(n,t,"utf8");try{Xi(n,e)}catch(r){if(!ra(r))throw r;ng(n,e,r)}}catch(r){try{Zi(n)}catch{}throw r}}s(ue,"writeFileAtomic");function Xn(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}s(Xn,"timestampUtc");var Ao;function Co(e){Ao=e}s(Co,"setHookStdio");function bo(){(Ao?.stdout??process.stdout).write('{"continue":true}')}s(bo,"emitStdoutOk");var ft=new Set(["on","1","true"]),qn=new Set(["off","0","false"]);function H(e){let t=process.env[e];return t===void 0||t===""?void 0:t}s(H,"readEnv");async function xo(){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(xo,"readStdinUntilEnd");async function Zn(e){let t=Ao?.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(Zn,"readStdinWithTimeout");async function xe(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(xe,"execFileResult");async function oe(e,t,n=3e3,r={}){let o=await xe(e,t,n,r);return o.ok?o.stdout:""}s(oe,"execFileText");function Ro(e,t){let n=Be(e),r=Be(t),o=ta(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${eg}`)||Qm(o)?!1:Be(r,o)===n}s(Ro,"isPathInside");function oa(e,t,n=Qi()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return Be(e);let o=Be(r),i=Be(e);if(Ro(i,o))return i;let a=t.CURSOR_PLUGIN_ROOT?.trim();return Ro(i,Be(n,".cursor"))||a!==void 0&&a.length>0&&Ro(i,Be(a))?o:i}s(oa,"cursorHookLaunchCwd");async function Oo(e=process.cwd(),t=process.env,n=Qi()){let r=oa(e,t,n),o=r!==Be(e)&&Yn(r)?r:e,i=await xe("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(i.ok&&i.stdout)return{root:i.stdout,inGitRepo:!0};if(H("EV_AI_HOOK_DEBUG")){let c=i.ok?"empty stdout":i.spawnFailed?"spawn failed":`exit ${String(i.code??"unknown")}`;P(`DEBUG: git rev-parse --show-toplevel failed (${c}) cwd=${e}`)}let a=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||H("CURSOR_PROJECT_DIR")||H("CLAUDE_PROJECT_DIR");if(a&&Yn(a)){let c=await xe("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(Oo,"resolveGitWorkspace");async function Io(e=process.cwd()){return(await Oo(e)).root}s(Io,"findGitRoot");function Oe(e,t){try{return JSON.parse(e)}catch{return t}}s(Oe,"parseJsonSafe");var Yi=new Map;function wt(e){return e.charCodeAt(0)===65279?e.slice(1):e}s(wt,"stripUtf8Bom");function rg(e){let t;try{t=Xm(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(wt(t))}}catch{return{ok:!1,reason:"parse"}}}s(rg,"parseJsonFile");function sa(e){let t=Yi.get(e);if(t!==void 0)return t;let n=rg(e);return Yi.set(e,n),n}s(sa,"loadJsonFileStatus");function ia(e){return sa(e)}s(ia,"readJsonFileStatus");function q(e,t){let n=sa(e);return n.ok?n.value:t}s(q,"readJsonFileMemoized");function dt(e){return typeof e=="string"?e:""}s(dt,"pickString");function je(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(je,"pickNestedScalar");function $(e,t){let n=je(e,t);return typeof n=="string"?n:""}s($,"pickNestedString");var Qe=500;function aa(e,t=2){if(!Yn(e))return{entries:[],truncated:!1};let n=[],r=!1,o=s((i,a)=>{if(a>t||r)return;let c;try{c=Ym(i,{withFileTypes:!0})}catch{return}for(let u of c){if(r)return;let f=ea(i,u.name);if(u.isDirectory()){o(f,a+1);continue}if(u.isFile()){try{n.push({name:ta(e,f),size:qi(f).size})}catch{continue}if(n.length>=Qe){r=!0;return}}}},"walk");return o(e,1),{entries:n,truncated:r}}s(aa,"listDirFiles");function ko(e){return Yn(e)?{present:!0,size:qi(e).size}:{present:!1,size:0}}s(ko,"fileSizeOrAbsent");function Lt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(Lt,"isTruthyFlag");function ua(e=process.env){return Lt(Z("CURSOR_SANDBOX",e))}s(ua,"isCursorSandboxProcess");var ug=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function lg(e){return ug.some(t=>!!Z(t,e))}s(lg,"hasManagedCiMarker");function fg(e){if(Z("KUBERNETES_SERVICE_HOST",e)||Lt(Z("REMOTE_CONTAINERS",e))||Lt(Z("DEVCONTAINER",e)))return!0;try{if(og("/.dockerenv")||sg("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}s(fg,"hasContainerMarker");function la(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!Z(t,e))}s(la,"hasIdeExtensionHostMarker");function dg(e,t=process.platform){return la(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!Z(n,e)):!1}s(dg,"hasLocalIdeHostMarker");function pg(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}s(pg,"isBackgroundComposerSessionId");function mg(e){return e==="linux"}s(mg,"isLinuxPlatform");function Z(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return H(e)}s(Z,"readContextEnv");function gg(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!_g(Z("CURSOR_VERSION",n))}s(gg,"isCursorCloudHostFingerprint");function _g(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(_g,"trimEnvLocal");function To(e){if(pg(e.sessionId))return!0;let t=e.hostname??ca(),n=e.osUser??da(e.env);return gg(t,n,e.env)}s(To,"hasCursorCloudExclusiveEvidence");function hg(e){return Lt(Z("CURSOR_AGENT",e.env))?!0:To(e)}s(hg,"hasCursorCloudEvidence");function Sg(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(Z("TERM",e)??Z("TERM_PROGRAM",e))||(Z("SSH_TTY",e)??Z("SSH_CONNECTION",e))||(Z("__CFBundleIdentifier",e)??Z("XPC_SERVICE_NAME",e))||la(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!Z(t,e))||Z("SESSIONNAME",e))}s(Sg,"hasLocalSessionMarker");function Qn(e={}){let t=e.env;if(Z("GITHUB_ACTIONS",t))return"github_actions";if(Lt(Z("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!dg(t,n)&&hg(e)&&(Lt(Z("CURSOR_AGENT",t))||mg(n)))return"cursor_cloud";if(Z("CODESPACES",t)||Z("CODESPACE_NAME",t))return"codespaces";if(Z("GITLAB_CI",t))return"gitlab_ci";if(lg(t))return"managed";let r=Z("CI",t);return r&&r!=="false"&&r!=="0"?"managed":fg(t)?"container":Sg(t)?"interactive":"unknown"}s(Qn,"detectContext");async function fa(){return await oe("systemd-detect-virt",[],1e3)}s(fa,"detectVirt");function da(e=process.env,t=ag){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(da,"resolveHostUsername");var Eg=32;function yg(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,Eg);return t.length>0?t:null}s(yg,"sanitizeOsPlatform");function Rg(){try{return[cg(),ig()].filter(Boolean).join(" ").trim()}catch{return""}}s(Rg,"windowsVersion");async function pa(e=!1){let t=yg(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=Rg():n=await oe("ver",[],1e3);let r=da(),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?Wi():{}}}s(pa,"hostEnv");function Po(){return ca()}s(Po,"hostName");import{createHash as wg}from"node:crypto";import{homedir as Lg}from"node:os";import{dirname as XI,join as vg,parse as qI,resolve as ZI}from"node:path";var ma="EV_AI_LAUNCHER_VERSION";var ga="EV_AI_HOOK_SOURCE",_a="EV_AI_HOOK_FALLBACK_REASON",ha="EV_AI_LAUNCHER_SCOPE",No="EV_AI_LAUNCHER_READY_FD";var Sa="--defer-user-spec",er="--cap",ln="--slot";var Ea=Buffer.from([1]);var TI=1024*1024,PI=4*1024*1024,NI=64*1024,wI=64*1024,LI=64*1024;var wo=4096,vI=4*1024*1024;var ya="ev-ai.agent-hook.in-process.v1";import{join as Oa}from"node:path";import{open as Ra,mkdir as Ag,readFile as Cg,readdir as bg,rename as xg,stat as Og,rmdir as Ig,unlink as kg,utimes as Tg}from"node:fs/promises";var tr=new WeakMap;function Ca(e){if(e&&typeof e=="object"&&"code"in e)return e}s(Ca,"asNodeError");function vt(e){return Ca(e)?.code==="ENOENT"}s(vt,"isNotFound");function fn(e){return Ca(e)?.code==="EEXIST"}s(fn,"isAlreadyExists");async function ba(e,t){try{return await e.readdir(t)}catch(n){if(vt(n))return[];throw n}}s(ba,"readdirOrEmpty");function xa(){return{async open(e,t){let n=await Ra(e,t),r={path:e};return tr.set(r,n),r},async write(e,t){let n=Aa(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await Aa(e).sync()},async close(e){let t=tr.get(e);tr.delete(e),t&&await t.close()},rename:xg,async readdir(e){return bg(e)},readFile:Cg,async stat(e){let t=await Og(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:s(()=>t.isDirectory(),"isDirectory")}},async mkdir(e,t){await Ag(e,t)},unlink:kg,rmdir:Ig,utimes:Tg,async fsyncDir(e){if(process.platform==="win32")return;let t=await Ra(e,"r");try{await t.sync()}finally{await t.close()}}}}s(xa,"productionFs");function Aa(e){let t=tr.get(e);if(!t)throw new Error("closed");return t}s(Aa,"requireHandle");var Ia=4,ka=10;function nr(e=process.platform){return e==="win32"?Ia:ka}s(nr,"defaultMaxConcurrentHooks");var rr=6e4,dn=2e3,Ta="slots",Lo=64;function Pa(e){return Oa(e,".ev-ai","agent-hook",Ta)}s(Pa,"slotDirUnder");function or(e,t){return Oa(e,`slot-${t}`)}s(or,"slotPath");function sr(e,t){return`${e}
|
|
15
15
|
${t}
|
|
16
|
-
`}function io(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 Qi(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}var ym=/^(\d+)\n(\d+)\n$/;function Rm(e){let t=ym.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 ea(e,t,n){let r=Rm(e);if(!r)return Math.abs(n-t)<Vt;let o=n-r.acquiredAtMs;return o<-Vt||o>=Dn?!1:Qi(r.pid)}var sa="https://hooks.ev-ai.ai",ia=".claude/ev-ai-runtime-report.json",aa="config.json",Om="max_concurrent_hooks",PO=1024*1024,xm=new Set(["localhost","127.0.0.1","[::1]","::1"]),Im=["claude","cursor","codex"],ca=[ia,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],ao=/^[A-Za-z0-9._~-]+$/;function jn(e){return e!==void 0&&Im.includes(e)}function ua(e){if(!e||typeof e!="object")return;let t=e[Om];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}function ta(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function St(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function Kn(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=St(e,c);t=u.value,c=u.next;continue}if(l.startsWith("--runner=")){t=l.slice(9);continue}if(l==="--url"){let u=St(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=St(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=St(e,c);u.value&&(s=u.value),c=u.next;continue}if(l.startsWith("--base-url=")){s=l.slice(11);continue}if(l===Ln){let u=St(e,c);i=ta(u.value)??i,c=u.next;continue}if(l.startsWith(`${Ln}=`)){i=ta(l.slice(Ln.length+1))??i;continue}if(l===Bt){let u=St(e,c);a=io(u.value)??a,c=u.next;continue}if(l.startsWith(`${Bt}=`)){a=io(l.slice(Bt.length+1))??a;continue}l!==$i&&!l.startsWith("-")&&n===void 0&&(n=l)}}return{runner:jn(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s,...i!==void 0?{cap:i}:{},...a!==void 0?{slot:a}:{}}}function Bn(e,t=sa){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function rt(e=Am()){return bm(e,".ev-ai",aa)}function la(e,t){return{...e,...t}}function na(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 Gn(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?xm.has(t.hostname):!1}catch{return!1}}function co(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 Et(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!Gn(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=co(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!ao.test(n))return`org token must match ${ao.source} (got: ${n})`;if(na(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(na(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function zt(e){return new URL(e).toString()}function fa(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?Bn(n):""}function yt(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 da(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=Bn(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=Et(n);return r?{problem:r}:{url:zt(n)}}var km="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",Tm="COLLECTOR_URL",ra="collector_url_override",Pm=[km,Tm];function Nm(e){let t;for(let n of Pm){let r=e[n]?.trim();if(!r)continue;let o=Et(r);if(o){t??={problem:o,envName:n};continue}return{url:zt(r),envName:n}}return t??{}}function oa(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=Et(t);return n?{problem:n}:{url:zt(t)}}function pa(e){let t=[],n=oa(e.homeConfig?.[ra]);if(n.problem&&t.push({label:ra,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=da(Kn(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=Nm(e.env);if(o.problem&&o.envName&&t.push({label:o.envName,problem:o.problem}),o.url)return{url:o.url,source:"plugin_option",warnings:t};let s=oa(e.homeConfig?.collector_url);if(s.problem&&t.push({label:"collector_url",problem:s.problem}),s.url)return{url:s.url,source:"home_config",warnings:t};let i=e.homeConfig?.repo_ingest_token,a=typeof i=="string"&&i.trim()?{...e.manifest,repo_ingest_token:i}:e.manifest,c=a?fa(a):"";if(c){let l=Et(c);if(l)t.push({label:"manifest collector_url",problem:l});else return{url:zt(c),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}function Wt(e){if(Et(e))return;let t;try{t=new URL(e)}catch{return}let n=co(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 Cm("sha256").update(i).digest("hex").slice(0,32)}var Vn=2;var Rt="ev-ai-agent-hook";function wm(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}function ma(e){let t=wm(e);return t===Rt||t===`${Rt}.exe`}var wO=`current/${Rt}`,MO=`.ev-ai/agent-hook/${Rt}`,ga=5e3,_a=5e3,uo=3e3;var zn=3e3,ha=1500,Sa=4*1024,lo=256*1024,Mm=4*1024,Ea=32*1024,fo="1.3.9",vO=`@ev-ai/agent-hook@${fo}`;var ya={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{existsSync as Uh,mkdirSync as Dh,readdirSync as Fh,readFileSync as $h,unlinkSync as Vc,writeFileSync as jh}from"node:fs";import{homedir as zc}from"node:os";import{join as No}from"node:path";import{createHash as Oa,randomBytes as Hm}from"node:crypto";import{existsSync as xa,mkdirSync as po,readFileSync as Ia,unlinkSync as ka,writeFileSync as Ta}from"node:fs";import{homedir as mo}from"node:os";import{dirname as Wn,join as go,resolve as Um}from"node:path";var vm=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),Lm=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]")||Lm.has(n)||r.includes("[bot]")||vm.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 Dm="installation.json",Fm="cloud-bootstrap.lock",$m=6e4;function Pa(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function me(e=mo()){return go(e,".ev-ai","agent-hook")}function jm(e=mo()){return go(me(e),Dm)}function Na(e){return go(Wn(e),Fm)}function wa(){return Hm(8).toString("hex")}function Ct(e){return Oa("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 Ma(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function Km(e=process.env){let t=$(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!Ma(t)){I(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}function va(e,t){return e&&Ma(e)?e:(e&&I(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),Km(t))}function Bm(e){return/^[0-9a-f]{16}$/.test(e)}function Gm(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 Ct(`github_actions|${t}|${n}`)}if($(e.CODESPACES)||$(e.CODESPACE_NAME)){let t=$(e.CODESPACE_NAME);if(t)return Ct(`codespaces|${t}`);let n=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),r=$(e.GITHUB_USER)??$(e.GITHUB_ACTOR);if(n&&r)return Ct(`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 Ct(`gitlab|${t}|${n}`)}return null}var Vm="cursoragent@cursor.com";function zm(e){let t=$(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===Vm?null:t}function Wm(e,t){return $(e.CURSOR_PROJECT_DIR)??$(e.CLAUDE_PROJECT_DIR)??t}function Jm(e){return Ft(e).replace(/\.git$/i,"").toLowerCase()}async function Ym(e){let t=await te("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?Jm(t):e}async function Xm(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 qm(e,t){let n=Wm(e,t);return n?Ct(`cursor_cloud|${n}|${zm(e)??""}`):null}async function Zm(e,t){let n=$(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await Ym(n),o=await Xm(n);return Ct(`claude_remote|${r}|${o??""}`)}function Ra(e,t){let n=va(e,t);if(n)return n;let r=Gm(t);return r||wa()}async function Qm(e){let n=await te("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||Um(e);return Oa("sha256").update(n).digest("hex").slice(0,16)}function eg(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 tg(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=eg(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 ot(e){if(xa(e))try{return tg(Ia(e,"utf8"))}catch{}}function _o(e){return ot(e)}function La(e,t,n){let r=ot(e);if(!r||r.operator_identity_hash===t&&r.operator_identity_sent_at===n)return;let o={...r,operator_identity_hash:t,operator_identity_sent_at:n};try{ae(e,`${JSON.stringify(o,null,2)}
|
|
17
|
-
`)}catch
|
|
18
|
-
|
|
19
|
-
`)}catch(s){let
|
|
20
|
-
|
|
21
|
-
`)}function ba(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}async function ja(e,t={}){let n=t.home??mo(),r=t.env??process.env,o=await Qm(e),s=jm(n),i={sessionId:t.sessionId,hostname:$(r.HOSTNAME)??void 0,osUser:$(r.USER)??$(r.LOGNAME)??$(r.USERNAME)??void 0,env:r},a=Kt(i),c=va(t.overrideId,r),l=a==="cursor_cloud"&&no(i)?qm(r,e):a==="claude_remote"?await Zm(r,e):null,u=ot(s);if(u){let S=u;if(c&&c===u.installation_id&&u.pinned!==!0&&(S={...u,pinned:!0},Aa(s,S)),!!l&&l!==S.installation_id&&!c&&S.pinned!==!0&&Bm(S.installation_id)&&l){let A={installation_id:l,...S.platform_agent_ids?{platform_agent_ids:S.platform_agent_ids}:{}};return Aa(s,A),{installationId:l,storePath:s,repoKey:o}}return{installationId:S.installation_id,storePath:s,repoKey:o}}let d=c??l??Ra(void 0,r),f=Ca(s,ba(d,c));if(f)return{installationId:f.installation_id,storePath:s,repoKey:o};let p=c??l??Ra(void 0,r),g=Ca(s,ba(p===d?wa():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 Eg}from"node:fs";import{existsSync as ug}from"node:fs";import{homedir as Ga}from"node:os";import{join as lg}from"node:path";import{existsSync as rg,readdirSync as Ka}from"node:fs";import{homedir as Jn}from"node:os";import{join as ce}from"node:path";function og(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 sg(e=process.platform){let t=og(e),n=[ce(t,"managed-settings.json")],r=ce(t,"managed-settings.d");try{if(!rg(r))return n;let o=Ka(r).filter(s=>s.endsWith(".json")&&!s.startsWith(".")).sort().map(s=>ce(r,s));n.push(...o)}catch{}return n}function Jt(e=process.platform,t=Jn()){return{serverManaged:ce(t,".claude","remote-settings.json"),fileBased:sg(e)}}function ig(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 ag(e=process.platform,t=Jn()){let n=[ce(ig(e),"hooks.json")],r=ce(t,".cursor","managed");try{for(let o of Ka(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(ce(r,o.name,"hooks.json"))}catch{}return n}function cg(e=process.platform,t=Jn()){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 Yn(e,t=process.platform,n=Jn()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=Jt(t,n);return[r,...o]}case"cursor":return ag(t,n);default:return cg(t,n)}}function Va(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}var fg={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 Ba(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}function dg(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:Ba(n.mcpJson,t.mcpJson),mcpToml:Ba(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}function za(e){return Object.fromEntries(Object.entries(fg).map(([t,n])=>[t,dg(n,n[e])]))}var At=za("homeOnly"),Ye=za("projectOnly");function pg(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}function mg(e,t){return pg(e).some(n=>ug(lg(t,n)))}function Wa(e,t){for(let n of e)if(mg(n,t))return!0;return!1}function Je(e){return[...new Set(e)]}function Xe(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:Je(t),subagents:Je(n),commands:Je(r),rules:Je(o),memory:Je(s),settings:Je(i),mcp:Je(a)}}function gg(e,t=Ga(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...Yn(o.managed,n,t));return Je(r)}var qe=Xe(Object.values(At));function Ja(e=Ga(),t=process.platform){return gg(Object.values(At),e,t)}import{existsSync as _g}from"node:fs";import{resolve as ho}from"node:path";function Se(e){return ho(e).replaceAll("\\","/").replace(/\/$/,"")}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}function Xn(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 hg=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function Yt(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!hg.test(t)?null:t}function bt(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let s=Se(o);n.has(s)||(n.add(s),r.push(s))}return r}function Sg(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}function ke(e,t,n,r=_g){for(let o of e)for(let s of t){let i=Se(ho(o,s)),a=ho(o,s,n).replaceAll("\\","/");if(Sg(i,a)&&r(a))return a}return null}var Xa=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,qa=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,yg=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,Ya=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"]),Rg=/^[a-z][a-z0-9-]{1,63}$/,Cg=[".cursor/skills",".claude/skills",".agents/skills"],Ag=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],bg=st(Cg,Xe(Object.values(Ye)).skills),Og=st(Ag,Xe(Object.values(At)).skills),xg=new Set(["read","read_file","view"]),Ig=new Set(["bash","shell","zsh"]);function So(e){let t=e.replace(/\\/g,"/");return Xa.exec(t)?.[1]??null}function kg(e){let t=e.replace(/\\/g,"/"),r=qa.exec(t)?.[1];return r?r.toLowerCase():null}function Tg(e){return So(e)??kg(e)}function Pg(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 qn(e){return typeof e=="string"?qn(he(e,null)):!e||typeof e!="object"?null:Pg(e)}function Za(e){if(typeof e=="string")return Za(he(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=Za(e.tool_input);if(t)return t;let n=nt(e.command);return n.length>0?n:null}function Ng(e){let t=e.replace(/\\/g,"/"),n=Xa.exec(t);if(n?.[1])return n[1];let o=qa.exec(t)?.[1];return o?o.toLowerCase():null}function wg(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function yo(e){let t=qn(e.tool_input)??nt(e.file_path);return t.length>0?t:null}function Xt(e,t,n){let r=wg(e).toLowerCase();if(xg.has(r)){let o=yo(e);return o?t(o):null}if(Ig.has(r)){let o=Eo(e);return o?n(o):null}return null}function Qa(e){return Xt(e,Tg,Ng)}function Mg(e){let t=new Set,n=[];for(let r of e.matchAll(yg)){let o=r[1]?.toLowerCase();!o||t.has(o)||vg(o)||(t.add(o),n.push(o))}return n}function vg(e){let t=e.split("/")[0];return Ya.has(e)||t!==void 0&&Ya.has(t)}function ec(e){let t=e.skillId.toLowerCase();if(!Rg.test(t))return null;let n=e.exists??Eg,r=`${t}/SKILL.md`,o=ke(bt(e.launchCwd,e.gitRoot),bg,r,n);return o!==null?o:e.home?ke([Se(e.home)],Og,r,n):null}function Lg(e){return nt(e.prompt)}function tc(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=Lg(e);return n?Mg(n):[]}var xo=ze(Qe(),1);import{existsSync as ch}from"node:fs";var at={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function Zt(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function ah(e){if(!e)return"";let t=Ft(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return Zt(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return Zt(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?Zt(o[1]):Zt(t)}async function or(e=process.cwd()){let t=await Re("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([Re("git",["remote","get-url","origin"],2e3,{cwd:e}),Re("git",["branch","--show-current"],2e3,{cwd:e}),Re("git",["rev-parse","HEAD"],2e3,{cwd:e}),Re("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Ft(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:s.ok?s.stdout.length>0:null}}async function xc(e,t,n,r=process.cwd(),o,s,i){if(t)return t;let a=at[n];if(!a)return"";let c=Pa(n,e.scope_path,i);if(s){let g=Da(s,c);if(g)return g}let l=o??await or(r),u=l?.remote?ah(l.remote):"";if(u||(u=Zt(process.env.GITHUB_REPOSITORY??"")),!u)return"";let d=e.scope_path??"",f=d?`${d}/`:"",p=`${u}:${f}${a}`;return s&&Fa(s,c,p),p}var uh=[".cursor/rules",".claude/rules",".codex/rules"],lh=Xe(Object.values(Ye)).rules;function fh(e){return st(Xn(e?at[e]:void 0,uh),lh)}var dh=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function Ic(e){let t=Yt(e.relativePath);if(!t)return null;let n=e.exists??ch,r=bt(e.launchCwd,e.gitRoot),o=fh(e.runnerPlatform),s=ke(r,o,t,n);if(s!==null)return s;if(!t.includes("/")){let i=ke(r,["."],t,n);if(i!==null)return i}return e.home?ke([Se(e.home)],o,t,n):null}function ph(e){let t=e.replace(/\\/g,"/"),r=dh.exec(t)?.[1];return r?(0,xo.nativeKeyForRulePath)(r):null}function kc(e){return Xt(e,xo.nativeKeyForRulePath,ph)}function Tc(e){return e.replace(/\.(mdc|md|rules)$/i,"")}function Pc(e){let t=e.attachments;if(!Array.isArray(t))return[];let n=new Set,r=[];for(let o of t){if(!o||typeof o!="object"||Array.isArray(o))continue;let s=o;if(s.type!=="rule")continue;let i=typeof s.file_path=="string"?s.file_path:"",a=Yt(i);!a||n.has(a)||(n.add(a),r.push(a))}return r}var Io=ze(Qe(),1);import{existsSync as mh}from"node:fs";var gh=[".cursor/commands",".claude/commands",".codex/prompts"],_h=Xe(Object.values(Ye)).commands;function hh(e){return st(Xn(e?at[e]:void 0,gh),_h)}var Sh=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function Nc(e){let t=Yt(e.commandId);if(!t)return null;let n=e.exists??mh,r=`${t}.md`,o=hh(e.runnerPlatform),s=ke(bt(e.launchCwd,e.gitRoot),o,r,n);return s!==null?s:e.home?ke([Se(e.home)],o,r,n):null}function Eh(e){let t=e.replace(/\\/g,"/"),r=Sh.exec(t)?.[1];return r?(0,Io.nativeKeyForCommandPath)(r):null}function wc(e){return Xt(e,Io.nativeKeyForCommandPath,Eh)}var sr=ze(Qe(),1);function Mc(e,t){if(L(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function yh(){return!!(v("CURSOR_VERSION")??v("CURSOR_PROJECT_DIR"))}function vc(e,t,n){return e!=="claude"&&e!=="codex"?!1:Mc(t,n)?!0:yh()}var Rh=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function Qt(e,t,n,r){return Mc(e,t)?"cursor":jn(r)?r:jn(n)?n:L(e,"turn_id")?"codex":L(e,"session_id")||Rh.has(t.toLowerCase())?"claude":"unknown"}function ir(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function Ch(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 Lc(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}function Hc(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}function Uc(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function en(e){return L(e,"session_id")||L(e,"conversation_id")}function ko(e){return L(e,"prompt.id")||L(e,"prompt_id")||L(e,"generation_id")||L(e,"turn_id")}function To(e){return L(e,"hook_event_name")||L(e,"event")}function Dc(e,t,n){let r=en(e),o=ko(e),s=To(e),i=L(e,"source"),a=Qt(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:i,runnerPlatform:a}}var Ah=["session_start","session_end","tool_invoked","skill_invoked"];function bh(e){return Ah.includes(e)}function Po(e,t){return e&&bh(e)?e:Ch(t.toLowerCase())}var Oh={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function ar(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function Fc(e,t=""){let n=L(e,"tool_name")||L(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!ar(n)&&(n=`MCP:${n}`):n=Oh[r]??null;let o=e.tool_input,i=(o&&typeof o=="object"?nt(o.skill)||nt(o.skill_name):"")||L(e,"skill_name")||null,a=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;i??=Qa(a);let c=kc(a),l=wc(a);return{toolName:n,skillName:i,ruleName:c,commandName:l}}var xh=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function $c(e){for(let t of["subagent_type","agent_type"]){let n=L(e,t);if(n&&xh.test(n))return n}return null}function jc(e){let t=Ue(e,"duration_ms");if(typeof t=="number")return t;let n=Ue(e,"duration");return typeof n=="number"?n:null}var Ih="error",kh="interrupted",Th="permission_denied",Ph=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function tn(e){return Ph.test(e)?e:null}function Nh(e){for(let t of["failure_type","error_type"]){let n=tn(L(e,t));if(n)return n}return null}function Kc(e,t){return Ue(e,"is_interrupt")===!0?kh:t.toLowerCase()==="permissiondenied"?Th:Nh(e)??Ih}function Bc(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}function wh(e,t){return Bc(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}function Mh(e,t){return Bc(t,n=>(0,sr.mcpServerNameMatchesToolSegment)(n,e))}function vh(e,t){let n=null,r=0;for(let s of t)if(s)for(let i of(0,sr.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:Mh(o[1],t)??o[1],mcpTool:o[2]}}function Lh(e,t){if(/^mcp__/i.test(e))return vh(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:wh(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}function Hh(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}function Gc(e,t=[],n=""){let r=e?Lh(e,t):{mcpServer:null,mcpTool:null},o=tn(n.trim());if(!o)return r;let s=r.mcpTool;return!s&&e&&!ar(e)&&(s=e),s&&(s=Hh(s,o)),{mcpServer:o,mcpTool:s}}var Wc=3e4,Kh="claims",Bh=!0,Gh=100,Vh=new Set(["sessionstart","sessionend","stopfailure"]),zh=["tool_name","tool","command","file_path","url"];function Wh(e=zc()){return No(me(e),Kh)}function Jc(e,t){try{let n=$h(e,"utf8").split(`
|
|
22
|
-
|
|
23
|
-
`,{encoding:"utf8",flag:"wx"})}
|
|
24
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);I(`WARN: cloud cache write failed open: ${r}`)}}function xS(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?CS:RS;return n-e.probed_at<r}async function IS(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 kS(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 TS(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 PS(e){let t=await Promise.allSettled([IS(e),kS(e),TS(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}async function bu(e,t){if(e==="interactive")return null;let n=t?.home??Au(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),s=AS(n),i=bS(s);if(xS(i,e,o))return i.result;let a=await PS(r);return OS(s,{context:e,probed_at:o,result:a}),a}var ku=ze(Qe(),1);import{existsSync as xu}from"node:fs";import{homedir as Iu}from"node:os";import{join as sn,resolve as Go,sep as Ou}from"node:path";function pr(e,t,n){if(!xu(e))return;let r=X(e,{});for(let[o,s]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:s})}function NS(e,t,n){if(!xu(e))return;let r=X(e,{}),o=Go(t),s=null;for(let a of Object.keys(r.projects??{})){let c=Go(a);(o===c||o.startsWith(c.endsWith(Ou)?c:c+Ou))&&(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 Tu(e,t,n,r){let o=new Map;for(let s of e.mcp_servers??[])s.name&&o.set(s.name,{declared:{name:s.name,source:"manifest"}});return n==="claude"?(pr(sn(r,".claude.json"),{source:"claude_json_user"},o),NS(sn(r,".claude.json"),t,o)):n==="cursor"&&pr(sn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),pr(sn(t,".mcp.json"),{source:"mcp_json"},o),pr(sn(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}async function Vo(e,t=process.cwd(),n="claude",r=Iu()){return[...Tu(e,t,n,r).values()].map(o=>o.declared)}function Pu(e,t,n=process.cwd(),r="claude",o=Iu()){let s=Tu(t,n,r,o),i=s.get(e);if(i!==void 0)return i.config??null;for(let[a,c]of s)if((0,ku.mcpServerNameMatchesToolSegment)(a,e))return c.config??null;return null}var wS=["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"],MS=["CURSOR_PROJECT_DIR"],vS=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function LS(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)vS.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}function Nu(e=process.env){let t=wS.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:LS(e[r]??"")}:{name:r,present:!1}),n=MS.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}import{homedir as fE}from"node:os";import{homedir as wu}from"node:os";import{join as HS}from"node:path";function US(e=wu()){return HS(e,".claude.json")}function mr(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Mu(e=wu()){let n=X(US(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=mr(n.emailAddress),o=mr(n.fullName)??mr(n.displayName),s=mr(n.accountUuid),i=r??s;return!i||pe(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:i,identity_source:"claude_oauth"}}import{homedir as Hu}from"node:os";import{join as vu}from"node:path";var DS="https://api.openai.com/auth";function It(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Uu(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function FS(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 Uu(r)}catch{return null}}function Lu(e,t,n){return It(e[n])??It(t?.[n])}function $S(e=process.env,t=Hu()){let n=It(e.CODEX_HOME)??vu(t,".codex");return vu(n,"auth.json")}function Du(e=process.env,t=Hu()){let n=X($S(e,t),{}),r=It(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&It(n.OPENAI_API_KEY))return null;let o=It(n.tokens?.id_token);if(!o)return null;let s=FS(o);if(!s)return null;let i=Uu(s[DS]),a=Lu(s,i,"name"),c=Lu(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 hr}from"node:os";import{join as je}from"node:path";import{join as jS}from"node:path";var KS="cursor-ide-identity.json",BS=840*60*1e3;function $u(e){return jS(me(e),KS)}function Fu(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function ju(e){let t=X(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:Fu(t.email),auth_id:Fu(t.auth_id)}}function Ku(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<BS}function Bu(e,t){try{ae(e,`${JSON.stringify(t)}
|
|
25
|
-
|
|
16
|
+
`}s(sr,"slotRecord");function vo(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(vo,"parseSlotRef");function Na(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}s(Na,"isPidAlive");var Pg=/^(\d+)\n(\d+)\n$/;function Ng(e){let t=Pg.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(Ng,"parseSlotRecord");function wa(e,t,n){let r=Ng(e);if(!r)return Math.abs(n-t)<dn;let o=n-r.acquiredAtMs;return o<-dn||o>=rr?!1:Na(r.pid)}s(wa,"isSlotRecordHeld");var Ha="https://hooks.ev-ai.ai",Da=".claude/ev-ai-runtime-report.json",Fa="config.json",Mg="max_concurrent_hooks",nk=1024*1024,Ug=new Set(["localhost","127.0.0.1","[::1]","::1"]),Hg=["claude","cursor","codex"],$a=[Da,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Mo=/^[A-Za-z0-9._~-]+$/;function ir(e){return e!==void 0&&Hg.includes(e)}s(ir,"isKnownRunner");function Ba(e){if(!e||typeof e!="object")return;let t=e[Mg];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}s(Ba,"maxConcurrentHooksFromConfig");function La(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}s(La,"parseCapArg");function Mt(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}s(Mt,"takeFlagValue");function ar(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=Mt(e,u);t=l.value,u=l.next;continue}if(f.startsWith("--runner=")){t=f.slice(9);continue}if(f==="--url"){let l=Mt(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=Mt(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=Mt(e,u);l.value&&(i=l.value),u=l.next;continue}if(f.startsWith("--base-url=")){i=f.slice(11);continue}if(f===er){let l=Mt(e,u);a=La(l.value)??a,u=l.next;continue}if(f.startsWith(`${er}=`)){a=La(f.slice(er.length+1))??a;continue}if(f===ln){let l=Mt(e,u);c=vo(l.value)??c,u=l.next;continue}if(f.startsWith(`${ln}=`)){c=vo(f.slice(ln.length+1))??c;continue}f!==Sa&&!f.startsWith("-")&&n===void 0&&(n=f)}}return{runner:ir(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:i,...a!==void 0?{cap:a}:{},...c!==void 0?{slot:c}:{}}}s(ar,"parseHookArgv");function cr(e,t=Ha){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}s(cr,"buildCollectorUrl");function pt(e=Lg()){return vg(e,".ev-ai",Fa)}s(pt,"homeManifestPath");function ja(e,t){return{...e,...t}}s(ja,"mergeManifestOverlay");function va(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(va,"hasUnsafeCollectorUrlChars");function ur(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?Ug.has(t.hostname):!1}catch{return!1}}s(ur,"isAllowedCollectorUrl");function Uo(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(Uo,"extractOrgTokenFromCollectorUrl");function Ut(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!ur(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Uo(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Mo.test(n))return`org token must match ${Mo.source}`;if(va(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(va(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}s(Ut,"collectorUrlProblem");function pn(e){return new URL(e).toString()}s(pn,"normalizeCollectorUrl");function Ka(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?cr(n):""}s(Ka,"resolveCollectorUrl");function Ht(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(Ht,"redactCollectorUrlForLog");function Ga(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=cr(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=Ut(n);return r?{problem:r}:{url:pn(n)}}s(Ga,"collectorUrlFromArgv");var Dg="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",Fg="COLLECTOR_URL",Ma="collector_url_override",$g=[Dg,Fg];function Bg(e){let t;for(let n of $g){let r=e[n]?.trim();if(!r)continue;let o=Ut(r);if(o){t??={problem:o,envName:n};continue}return{url:pn(r),envName:n}}return t??{}}s(Bg,"collectorUrlFromPluginOption");function Ua(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=Ut(t);return n?{problem:n}:{url:pn(t)}}s(Ua,"candidateFromUnknown");function Va(e){let t=[],n=Ua(e.homeConfig?.[Ma]);if(n.problem&&t.push({label:Ma,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=Ga(ar(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=Bg(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=Ua(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?Ka(c):"";if(u){let f=Ut(u);if(f)t.push({label:"manifest collector_url",problem:f});else return{url:pn(u),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}s(Va,"selectCollectorUrl");function mt(e){if(Ut(e))return;let t;try{t=new URL(e)}catch{return}let n=Uo(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 wg("sha256").update(a).digest("hex").slice(0,32)}s(mt,"scopeIdForCollectorUrl");var lr=2;var Dt="ev-ai-agent-hook";function jg(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}s(jg,"hookBinaryBasenameFromPath");function za(e){let t=jg(e);return t===Dt||t===`${Dt}.exe`}s(za,"isHookBinaryPath");var sk=`current/${Dt}`,ik=`.ev-ai/agent-hook/${Dt}`,Wa=5e3,Ja=5e3,Ho=3e3;var fr=3e3,Ya=1500,Xa=4*1024,Do=256*1024,Kg=4*1024,qa=32*1024,Ke="1.3.11",ak=`@ev-ai/agent-hook@${Ke}`;var Za={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{existsSync as vE,mkdirSync as ME,readdirSync as UE,readFileSync as HE,unlinkSync as Wu,writeFileSync as DE}from"node:fs";import{homedir as Ju}from"node:os";import{join as ds}from"node:path";import{createHash as Ic,randomBytes as L_}from"node:crypto";import{existsSync as kc,mkdirSync as Xo,readFileSync as Tc,unlinkSync as Pc,writeFileSync as Nc}from"node:fs";import{homedir as _r}from"node:os";import{dirname as hr,join as qo,resolve as v_}from"node:path";var Gg=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com","claude@anthropic.com","agent@cursor.local"]),Vg=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function le(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||Vg.has(n)||r.includes("[bot]")||Gg.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(le,"isBotOperatorIdentity");import{homedir as Fo}from"node:os";import{join as Wg}from"node:path";function Qa(e=Fo()){return Wg(e,".claude.json")}s(Qa,"claudeUserConfigPath");function gt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(gt,"trimString");function ec(e=Fo()){let n=q(Qa(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=gt(n.emailAddress),o=gt(n.fullName)??gt(n.displayName),i=gt(n.accountUuid),a=r??i;return!a||le(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:a,identity_source:"claude_oauth"}}s(ec,"readClaudeOperatorIdentity");function tc(e=Fo()){let n=q(Qa(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=gt(n.emailAddress),o=gt(n.fullName)??gt(n.displayName);return le(o,r)?null:r?.toLowerCase()??null}s(tc,"readClaudeAccountKey");import{randomBytes as qg}from"node:crypto";import{appendFileSync as Zg,mkdirSync as Qg,readdirSync as e_,readFileSync as Ko,renameSync as uc,statSync as _n,unlinkSync as pc}from"node:fs";import{homedir as et,tmpdir as t_}from"node:os";import{dirname as jo,join as _t}from"node:path";var oc="EV_AI_PERF_L",$o="EV_AI_PERF_H",mn="EV_AI_RUN_ID",Jg="EV_AI_HOOK_PERF";var Yg=/^[a-z][a-z0-9_]{0,23}$/;var dr={origin:0,marks:{},values:{}},pr=!1;function sc(e=process.env){pr=e[Jg]!=="0",dr.origin=performance.timeOrigin}s(sc,"startTimings");function gn(){return pr}s(gn,"timingsActive");function Ge(e,t=performance.now()){pr&&(dr.marks[e]=t)}s(Ge,"mark");function ic(){return dr}s(ic,"ownTimings");function ac(e){return Math.round(e*10)/10}s(ac,"round1");function nc(e){return Object.entries(e).map(([t,n])=>`${t}=${ac(n)}`).join(",")}s(nc,"entries");function Xg(e){return`${ac(e.origin)}|${nc(e.marks)}|${nc(e.values)}`}s(Xg,"serializeTimings");function rc(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||!Yg.test(o)||!(i>=0&&i<=36e5))return!1;t[o]=i}return Object.keys(t).length<=32}s(rc,"parseEntries");function Bo(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(!(!rc(n,a.marks)||!rc(r,a.values)))return a}s(Bo,"parseTimings");function cc(){return pr?Xg(dr):void 0}s(cc,"serializeOwnTimings");var n_="hooks-debug.log",r_=/^hooks-debug\.log\.\d+$/,o_=/^hooks-debug\.log(\.1)?\.send-\d+$/,lc="ev-ai-agent-hooks.log",s_="EV_AI_HOOK_RUN_LOG",Ft="unlimited",i_="off",Go=1024*1024,a_=8*1024,fc=Go/2-a_,c_=10080*60*1e3,u_=1024*1024,l_="run-log-windows.json",f_=64*1024,Vo=/^[a-z0-9]{8}$/,dc="abcdefghijklmnopqrstuvwxyz0123456789",d_=/[^A-Za-z0-9._:/+-]/g,p_=128,tt={info(){},error(){}},Re=tt;function gr(e=et()){return _t(e,".ev-ai",n_)}s(gr,"fileLogPath");function mc(e){try{let t=JSON.parse(wt(Ko(_t(e,".ev-ai","config.json"),"utf8")));return ht(t)?t:void 0}catch{return}}s(mc,"readHomeConfig");function m_(e){return e?.debug===!0}s(m_,"debugFromHomeConfig");function zo(e,t=!1){return e.includes("--debug")||t}s(zo,"isHookDebugEnabled");function ht(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(ht,"isRecord");function g_(e,t){let n=e?.log_until;if(typeof n!="string")return;let r=[];if(n===Ft)return{on:!0,source:"local_config",scopes:r,localUntil:n};if(n===i_)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(g_,"localRunLog");function __(e){if(!ht(e)||!ht(e.config))return;let t=e.config.log_until;if(typeof t!="string")return;if(t===Ft)return{until:t,untilMs:Number.POSITIVE_INFINITY};let n=Date.parse(t);return Number.isNaN(n)?void 0:{until:t,untilMs:n}}s(__,"scopeUntilMs");function gc(e=et(),t=process.env,n=Date.now()){return _c(e,()=>mc(e),t,n)}s(gc,"readRunLogSwitch");function _c(e,t,n,r){let o=n[s_]?.trim().toLowerCase();if(o&&ft.has(o))return{on:!0,source:"env",scopes:[]};if(o&&qn.has(o))return{on:!1,source:"env",scopes:[]};let i=g_(t(),r);if(i)return i;let a=[];try{let c=_t(e,".ev-ai","agent-hook","hook-config.json"),u=_n(c);if(!u.isFile()||u.size>u_)return{on:!1,source:"remote",scopes:a};let f=JSON.parse(Ko(c,"utf8"));if(ht(f))for(let[l,p]of Object.entries(f)){let d=__(p);d&&d.untilMs>r&&a.push({scopeId:l,...d})}}catch{}return{on:a.length>0,source:"remote",scopes:a}}s(_c,"runLogSwitch");function hc(e=et()){return _t(e,".ev-ai","agent-hook",l_)}s(hc,"runLogWindowsPath");function Wo(e=et()){try{let t=hc(e),n=_n(t);if(!n.isFile()||n.size>f_)return{};let r=JSON.parse(Ko(t,"utf8")),o={};if(ht(r))for(let[i,a]of Object.entries(r))typeof a=="string"&&(o[i]=a);return o}catch{return{}}}s(Wo,"readRunLogWindows");function Jo(e,t=et()){try{let n=Wo(t),r={...n};if(e(r),JSON.stringify(r)===JSON.stringify(n))return;ue(hc(t),`${JSON.stringify(r,null,2)}
|
|
17
|
+
`)}catch{}}s(Jo,"updateRunLogWindows");function h_(e,t){Jo(n=>{for(let r of t)n[r.scopeId]=r.until},e)}s(h_,"recordRunLogWindows");function S_(e){return e.replace(/[\r\n]/g," ")}s(S_,"oneLine");function E_(e){try{if(_n(e).size<fc)return;let t=`${e}.${process.pid}`;uc(e,t);try{uc(t,_n(t).size>=fc?`${e}.1`:e)}catch{pc(t)}}catch{}}s(E_,"rotateIfFull");var y_=/\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 A_(e,t=et()){let n=e.replace(y_,R_);return t.length>1?n.replaceAll(t,"~"):n}s(A_,"scrubForLog");function C_(e,t){try{Qg(jo(e),{recursive:!0}),E_(e),Zg(e,t,{encoding:"utf8",mode:384})}catch{}}s(C_,"appendLine");function Sc(e=process.argv,t=gr(),n,r){x_();let o=et(),i,a=!1,c=s(()=>(a||(i=mc(o),a=!0),i),"readOnce"),u=zo(e,n??m_(c())),f=u||r!==void 0?void 0:_c(o,c,process.env,Date.now());if(!u&&!(r??f?.on)){Re=tt;return}f?.source==="remote"&&h_(o,f.scopes);let l=s((p,d)=>{C_(t,`${new Date().toISOString()} ${p} ${A_(S_(d),o)}
|
|
18
|
+
`)},"write");Re={info(p){l("info",p)},error(p){l("error",p)}}}s(Sc,"initFileLogger");function Ec(){return Re!==tt}s(Ec,"fileLoggerActive");var ce={info(e){Re.info(e)},error(e){Re.error(e)}},b_=new Set(["post_failed","timeout"]),ae={},Yo=!1;function x_(){ae={},Yo=!1}s(x_,"resetRunState");function yc(){return Yo}s(yc,"runLineWritten");function Q(e){if(Re===tt)return;if(e.outcome===void 0){ae={...ae,...e};return}if(ae.outcome!==void 0&&b_.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=ht(e)?e.cause:void 0;for(let n of[t,e])if(ht(n)&&typeof n.code=="string"&&n.code!=="")return n.code;return e instanceof Error?e.name:typeof e}s(nt,"runErrorKind");var O_=4096;function I_(e){return(e.stack??"").split(`
|
|
19
|
+
`).map(t=>t.trim()).filter(t=>t.startsWith("at ")).join(" | ")}s(I_,"stackFrames");function hn(e){try{return k_(e).join(" ").slice(0,O_)}catch{return"err=unknown message=(unprintable)"}}s(hn,"errorDetail");function k_(e){let t=[`err=${nt(e)}`];if(!(e instanceof Error))return t.push(`message=${String(e)}`),t;t.push(`message=${e.message}`);let n=I_(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=${T_(r)}`:`cause=${String(r)}`),r=r instanceof Error?r.cause:void 0;return t}s(k_,"errorParts");function T_(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(T_,"causeText");function D(e,t,n=process.env){if(Re===tt)return;let r=n[mn],o=r!==void 0&&Vo.test(r)?` run=${r}`:"";Re.error(`failed where=${e}${o} ${hn(t)}`)}s(D,"logFailure");function P_(){let e="";for(let t of qg(8))e+=dc[t%dc.length];return e}s(P_,"newRunId");function Rc(e=process.env){if(Re===tt)return;let t=e[mn];if(t!==void 0&&Vo.test(t))return t;let n=P_();return e[mn]=n,n}s(Rc,"ensureRunId");function N_(e){if(typeof e=="number")return Number.isInteger(e)?String(e):e.toFixed(1);let t=e.replace(d_,"_").slice(0,p_);return t===""?"_":t}s(N_,"runValue");function $t(e,t,n,r=process.env){if(Re===tt)return;Yo=!0;let o=r[mn],a=[["run",o!==void 0&&Vo.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}=${N_(u)}`);Re.info(`run ${a.join(" ")}`)}s($t,"writeRunLine");function mr(e,t){try{t-_n(e).mtimeMs>c_&&pc(e)}catch{}}s(mr,"unlinkIfStale");function Ac(e=Date.now(),t=et(),n=w_()){if(Re!==tt)return;let r=gr(t);mr(r,e),mr(`${r}.1`,e);try{for(let o of e_(jo(r)))(r_.test(o)||o_.test(o))&&mr(_t(jo(r),o),e)}catch{}mr(n,e)}s(Ac,"purgeStaleLog");function w_(e=process.platform){return e==="win32"?_t(t_(),lc):_t("/tmp",lc)}s(w_,"legacyLogPath");var M_="installation.json",U_="cloud-bootstrap.lock",H_=6e4;function wc(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}s(wc,"platformAgentIdCacheKey");function Ee(e=_r()){return qo(e,".ev-ai","agent-hook")}s(Ee,"agentHookHome");function D_(e=_r()){return qo(Ee(e),M_)}s(D_,"installationStorePath");function Lc(e){return qo(hr(e),U_)}s(Lc,"cloudBootstrapLockPath");function vc(){return L_(8).toString("hex")}s(vc,"randomInstallationId");function St(e){return Ic("sha256").update(e).digest("hex").slice(0,16)}s(St,"sha16");function K(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(K,"trimEnv");function Mc(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}s(Mc,"isValidInstallationId");function F_(e=process.env){let t=K(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!Mc(t)){P(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}s(F_,"readInstallationIdEnvOverride");function Uc(e,t){return e&&Mc(e)?e:(e&&P(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),F_(t))}s(Uc,"resolvePinnedInstallationId");function $_(e){return/^[0-9a-f]{16}$/.test(e)}s($_,"isEphemeralInstallationIdShape");function B_(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 St(`github_actions|${t}|${n}`)}if(K(e.CODESPACES)||K(e.CODESPACE_NAME)){let t=K(e.CODESPACE_NAME);if(t)return St(`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 St(`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 St(`gitlab|${t}|${n}`)}return null}s(B_,"deriveEphemeralInstallationId");var j_="cursoragent@cursor.com";function K_(e){let t=K(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===j_?null:t}s(K_,"cursorCloudUserEmail");function G_(e,t){return K(e.CURSOR_PROJECT_DIR)??K(e.CLAUDE_PROJECT_DIR)??t}s(G_,"cursorCloudWorkspacePath");function V_(e){return cn(e).replace(/\.git$/i,"").toLowerCase()}s(V_,"normalizeRemoteForSeed");async function z_(e){let t=await oe("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?V_(t):e}s(z_,"resolveRepoSeed");async function W_(e){let t=K(await oe("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!le(null,t))return t;let n=K(await oe("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!le(null,n)?n:null}s(W_,"readClaudeRemoteOperatorEmail");function J_(e,t){let n=G_(e,t);return n?St(`cursor_cloud|${n}|${K_(e)??""}`):null}s(J_,"deriveCursorCloudInstallationId");async function Y_(e,t,n=_r()){let r=tc(n);if(r)return ce.info("claude_remote installation key=email"),St(`claude_remote/v2|${r}`);ce.info("claude_remote installation key=v1");let o=K(e.CLAUDE_PROJECT_DIR)??t;if(!o)return null;let i=await z_(o),a=await W_(o);return St(`claude_remote|${i}|${a??""}`)}s(Y_,"deriveClaudeRemoteInstallationId");function Cc(e,t){let n=Uc(e,t);if(n)return n;let r=B_(t);return r||vc()}s(Cc,"chooseNewInstallationId");async function X_(e){let n=await oe("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||v_(e);return Ic("sha256").update(n).digest("hex").slice(0,16)}s(X_,"computeRepoKey");function q_(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(q_,"readPlatformAgentIds");function Z_(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=q_(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(Z_,"parseInstallationRecord");function Et(e){if(kc(e))try{return Z_(Tc(e,"utf8"))}catch{}}s(Et,"readInstallationRecord");function Zo(e){return Et(e)}s(Zo,"readInstallationStore");function Hc(e,t,n){let r=Et(e);if(!r||r.operator_identity_hash===t&&r.operator_identity_sent_at===n)return;let o={...r,operator_identity_hash:t,operator_identity_sent_at:n};try{ue(e,`${JSON.stringify(o,null,2)}
|
|
20
|
+
`)}catch(i){let a=i instanceof Error?i.message:String(i);P(`WARN: operator identity cache write failed open: ${a}`),D("operator_identity_cache",i)}}s(Hc,"writeOperatorIdentityCache");function Dc(e,t=Date.now()){if(!e)return!0;if(Et(e)?.operator_identity_hash)return!1;let n=Lc(e);try{if(kc(n)){let r=Number.NaN;try{r=Number(Tc(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<H_)return!1;try{Pc(n)}catch{}}}catch{}try{return Xo(hr(n),{recursive:!0}),Nc(n,`${t}
|
|
21
|
+
`,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(jc(r))return!1;let o=r instanceof Error?r.message:String(r);return P(`WARN: cloud bootstrap claim failed open: ${o}`),D("cloud_bootstrap_claim",r),!0}}s(Dc,"tryClaimCloudIdentityBootstrap");function Fc(e){if(e)try{Pc(Lc(e))}catch{}}s(Fc,"releaseCloudIdentityBootstrapClaim");function $c(e,t){let r=Et(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}s($c,"readCachedPlatformAgentId");function Bc(e,t,n){if(!n)return;let r=Et(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={...r,platform_agent_ids:{...r.platform_agent_ids,[t]:n}};try{ue(e,`${JSON.stringify(o,null,2)}
|
|
22
|
+
`)}catch(i){let a=i instanceof Error?i.message:String(i);P(`WARN: platform_agent_id cache write failed open: ${a}`),D("platform_agent_id_cache",i)}}s(Bc,"writeCachedPlatformAgentId");function jc(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}s(jc,"isEexistError");function Q_(e,t){Xo(hr(e),{recursive:!0}),Nc(e,`${JSON.stringify(t,null,2)}
|
|
23
|
+
`,{encoding:"utf8",flag:"wx"})}s(Q_,"writeInstallationRecordExclusive");function bc(e,t){try{return Q_(e,t),t}catch(n){if(!jc(n))throw n;return Et(e)}}s(bc,"tryCreateInstallationRecord");function xc(e,t){Xo(hr(e),{recursive:!0}),ue(e,`${JSON.stringify(t,null,2)}
|
|
24
|
+
`)}s(xc,"replaceInstallationRecord");function Oc(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}s(Oc,"newInstallationRecord");async function Kc(e,t={}){let n=t.home??_r(),r=t.env??process.env,o=await X_(e),i=D_(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=Qn(a),u=Uc(t.overrideId,r),f=c==="cursor_cloud"&&To(a)?J_(r,e):c==="claude_remote"?await Y_(r,e,n):null,l=Et(i);if(l){let h=l;if(u&&u===l.installation_id&&l.pinned!==!0&&(h={...l,pinned:!0},xc(i,h)),!!f&&f!==h.installation_id&&!u&&h.pinned!==!0&&$_(h.installation_id)&&f){let b={installation_id:f,...h.platform_agent_ids?{platform_agent_ids:h.platform_agent_ids}:{}};return xc(i,b),{installationId:f,storePath:i,repoKey:o}}return{installationId:h.installation_id,storePath:i,repoKey:o}}let p=u??f??Cc(void 0,r),d=bc(i,Oc(p,u));if(d)return{installationId:d.installation_id,storePath:i,repoKey:o};let m=u??f??Cc(void 0,r),g=bc(i,Oc(m===p?vc():m,u));if(g)return{installationId:g.installation_id,storePath:i,repoKey:o};throw new Error(`Failed to create installation record at ${i}`)}s(Kc,"resolveOrCreateInstallationId");import{existsSync as _h}from"node:fs";import{existsSync as ih}from"node:fs";import{homedir as zc}from"node:os";import{join as ah}from"node:path";import{existsSync as eh,readdirSync as Gc}from"node:fs";import{homedir as Sr}from"node:os";import{join as me}from"node:path";function th(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return me(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}s(th,"claudeManagedSettingsDir");function nh(e=process.platform){let t=th(e),n=[me(t,"managed-settings.json")],r=me(t,"managed-settings.d");try{if(!eh(r))return n;let o=Gc(r).filter(i=>i.endsWith(".json")&&!i.startsWith(".")).sort().map(i=>me(r,i));n.push(...o)}catch{}return n}s(nh,"listClaudeManagedSettingsFiles");function Sn(e=process.platform,t=Sr()){return{serverManaged:me(t,".claude","remote-settings.json"),fileBased:nh(e)}}s(Sn,"claudeManagedSettingsSources");function rh(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return me(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}s(rh,"cursorEnterpriseSettingsDir");function oh(e=process.platform,t=Sr()){let n=[me(rh(e),"hooks.json")],r=me(t,".cursor","managed");try{for(let o of Gc(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(me(r,o.name,"hooks.json"))}catch{}return n}s(oh,"listCursorManagedSettingsFiles");function sh(e=process.platform,t=Sr()){let n=e==="win32"?me(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[me(n,"requirements.toml")];return e!=="win32"&&r.push(me(n,"managed_config.toml")),r.push(me(t,".codex","managed_config.toml"),me(n,"config.toml")),r}s(sh,"listCodexManagedSettingsFiles");function Er(e,t=process.platform,n=Sr()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=Sn(t,n);return[r,...o]}case"cursor":return oh(t,n);default:return sh(t,n)}}s(Er,"managedSettingsFiles");function Wc(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}s(Wc,"hookParsableSettings");var ch={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 Vc(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}s(Vc,"concatOptional");function uh(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:Vc(n.mcpJson,t.mcpJson),mcpToml:Vc(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}s(uh,"layoutForScope");function Jc(e){return Object.fromEntries(Object.entries(ch).map(([t,n])=>[t,uh(n,n[e])]))}s(Jc,"layoutsForScope");var Bt=Jc("homeOnly"),ot=Jc("projectOnly");function lh(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}s(lh,"layoutRelativePaths");function fh(e,t){return lh(e).some(n=>ih(ah(t,n)))}s(fh,"layoutHasAnyEntry");function Yc(e,t){for(let n of e)if(fh(n,t))return!0;return!1}s(Yc,"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 dh(e,t=zc(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...Er(o.managed,n,t));return rt(r)}s(dh,"managedSettingsFromLayouts");var it=st(Object.values(Bt));function Xc(e=zc(),t=process.platform){return dh(Object.values(Bt),e,t)}s(Xc,"userScopeManagedSettings");import{existsSync as ph}from"node:fs";import{resolve as Qo}from"node:path";function Ae(e){return Qo(e).replaceAll("\\","/").replace(/\/$/,"")}s(Ae,"posixAbs");function yt(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(yt,"uniqueOrderedRoots");function yr(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(yr,"preferMarkerDirRoots");var mh=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function En(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!mh.test(t)?null:t}s(En,"sanitizeComponentRelativePath");function jt(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(jt,"projectAnchors");function gh(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}s(gh,"isInside");function Le(e,t,n,r=ph){for(let o of e)for(let i of t){let a=Ae(Qo(o,i)),c=Qo(o,i,n).replaceAll("\\","/");if(gh(a,c)&&r(c))return c}return null}s(Le,"firstExistingUnderRoots");var Zc=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Qc=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,hh=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,qc=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"]),Sh=/^[a-z][a-z0-9-]{1,63}$/,Eh=[".cursor/skills",".claude/skills",".agents/skills"],yh=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],Rh=yt(Eh,st(Object.values(ot)).skills),Ah=yt(yh,st(Object.values(Bt)).skills),Ch=new Set(["read","read_file","view"]),bh=new Set(["bash","shell","zsh"]);function es(e){let t=e.replace(/\\/g,"/");return Zc.exec(t)?.[1]??null}s(es,"skillIdFromSkillMdPath");function xh(e){let t=e.replace(/\\/g,"/"),r=Qc.exec(t)?.[1];return r?r.toLowerCase():null}s(xh,"skillIdFromCodexCommandPath");function Oh(e){return es(e)??xh(e)}s(Oh,"skillIdFromReferencedPath");function Ih(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(Ih,"pathFromToolInputRecord");function Rr(e){return typeof e=="string"?Rr(Oe(e,null)):!e||typeof e!="object"?null:Ih(e)}s(Rr,"pathFromToolInput");function eu(e){if(typeof e=="string")return eu(Oe(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}s(eu,"commandFromToolInput");function ts(e){let t=eu(e.tool_input);if(t)return t;let n=dt(e.command);return n.length>0?n:null}s(ts,"commandFromHookInput");function kh(e){let t=e.replace(/\\/g,"/"),n=Zc.exec(t);if(n?.[1])return n[1];let o=Qc.exec(t)?.[1];return o?o.toLowerCase():null}s(kh,"skillIdFromShellCommand");function Th(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}s(Th,"toolNameFromHookInput");function ns(e){let t=Rr(e.tool_input)??dt(e.file_path);return t.length>0?t:null}s(ns,"filePathFromHookInput");function yn(e,t,n){let r=Th(e).toLowerCase();if(Ch.has(r)){let o=ns(e);return o?t(o):null}if(bh.has(r)){let o=ts(e);return o?n(o):null}return null}s(yn,"nameFromReadOrShellHookInput");function tu(e){return yn(e,Oh,kh)}s(tu,"skillNameFromReadHookInput");function Ph(e){let t=new Set,n=[];for(let r of e.matchAll(hh)){let o=r[1]?.toLowerCase();!o||t.has(o)||Nh(o)||(t.add(o),n.push(o))}return n}s(Ph,"extractSlashSkillNames");function Nh(e){let t=e.split("/")[0];return qc.has(e)||t!==void 0&&qc.has(t)}s(Nh,"isDeniedSlashId");function nu(e){let t=e.skillId.toLowerCase();if(!Sh.test(t))return null;let n=e.exists??_h,r=`${t}/SKILL.md`,o=Le(jt(e.launchCwd,e.gitRoot),Rh,r,n);return o!==null?o:e.home?Le([Ae(e.home)],Ah,r,n):null}s(nu,"resolveSkillMdPath");function wh(e){return dt(e.prompt)}s(wh,"promptFromHookInput");function ru(e){let t=$(e,"command_name");if(t){let r=$(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=wh(e);return n?Ph(n):[]}s(ru,"skillNamesFromHookInput");var cs=Ze(ct(),1);import{existsSync as sE}from"node:fs";var At={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function An(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}s(An,"normalizePathSlug");function oE(e){if(!e)return"";let t=cn(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return An(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return An(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?An(o[1]):An(t)}s(oE,"normalizeGitRemoteToSlug");async function kr(e=process.cwd()){let t=await xe("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([xe("git",["remote","get-url","origin"],2e3,{cwd:e}),xe("git",["branch","--show-current"],2e3,{cwd:e}),xe("git",["rev-parse","HEAD"],2e3,{cwd:e}),xe("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?cn(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:i.ok?i.stdout.length>0:null}}s(kr,"gitSnapshot");async function ku(e,t,n,r=process.cwd(),o,i,a){if(t)return t;let c=At[n];if(!c)return"";let u=wc(n,e.scope_path,a);if(i){let g=$c(i,u);if(g)return g}let f=o??await kr(r),l=f?.remote?oE(f.remote):"";if(l||(l=An(process.env.GITHUB_REPOSITORY??"")),!l)return"";let p=e.scope_path??"",d=p?`${p}/`:"",m=`${l}:${d}${c}`;return i&&Bc(i,u,m),m}s(ku,"derivePlatformAgentId");var iE=[".cursor/rules",".claude/rules",".codex/rules"],aE=st(Object.values(ot)).rules;function cE(e){return yt(yr(e?At[e]:void 0,iE),aE)}s(cE,"ruleRootsForRunner");var uE=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function Tu(e){let t=En(e.relativePath);if(!t)return null;let n=e.exists??sE,r=jt(e.launchCwd,e.gitRoot),o=cE(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(Tu,"resolveRuleMdPath");function lE(e){let t=e.replace(/\\/g,"/"),r=uE.exec(t)?.[1];return r?(0,cs.nativeKeyForRulePath)(r):null}s(lE,"ruleNameFromShellCommand");function Pu(e){return yn(e,cs.nativeKeyForRulePath,lE)}s(Pu,"ruleNameFromReadHookInput");function Nu(e){return e.replace(/\.(mdc|md|rules)$/i,"")}s(Nu,"stripRuleExtension");function wu(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=En(a);!c||n.has(c)||(n.add(c),r.push(c))}return r}s(wu,"ruleAttachmentPathsFromHookInput");var us=Ze(ct(),1);import{existsSync as fE}from"node:fs";var dE=[".cursor/commands",".claude/commands",".codex/prompts"],pE=st(Object.values(ot)).commands;function mE(e){return yt(yr(e?At[e]:void 0,dE),pE)}s(mE,"commandRootsForRunner");var gE=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function Lu(e){let t=En(e.commandId);if(!t)return null;let n=e.exists??fE,r=`${t}.md`,o=mE(e.runnerPlatform),i=Le(jt(e.launchCwd,e.gitRoot),o,r,n);return i!==null?i:e.home?Le([Ae(e.home)],o,r,n):null}s(Lu,"resolveCommandMdPath");function _E(e){let t=e.replace(/\\/g,"/"),r=gE.exec(t)?.[1];return r?(0,us.nativeKeyForCommandPath)(r):null}s(_E,"commandNameFromShellCommand");function vu(e){return yn(e,us.nativeKeyForCommandPath,_E)}s(vu,"commandNameFromReadHookInput");var Tr=Ze(ct(),1);function Mu(e,t){if($(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}s(Mu,"cursorShapedPayload");function hE(){return!!(H("CURSOR_VERSION")??H("CURSOR_PROJECT_DIR"))}s(hE,"isCursorHostEnv");function Uu(e,t,n){return e!=="claude"&&e!=="codex"?!1:Mu(t,n)?!0:hE()}s(Uu,"shouldSuppressForeignRunnerOnCursorHost");var SE=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function Vt(e,t,n,r){return Mu(e,t)?"cursor":ir(r)?r:ir(n)?n:$(e,"turn_id")?"codex":$(e,"session_id")||SE.has(t.toLowerCase())?"claude":"unknown"}s(Vt,"detectRunnerPlatform");function Pr(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}s(Pr,"isInProcessEvent");function EE(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(EE,"mapRunnerEventToInternal");function Hu(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}s(Hu,"isPromptSubmitRunnerEvent");function Du(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}s(Du,"suppressesSlashIds");function Fu(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}s(Fu,"toolSuccessFromRunnerEvent");function zt(e){return $(e,"session_id")||$(e,"conversation_id")}s(zt,"sessionIdFromHookInput");function ls(e){return $(e,"prompt.id")||$(e,"prompt_id")||$(e,"generation_id")||$(e,"turn_id")}s(ls,"turnIdFromHookInput");function fs(e){return $(e,"hook_event_name")||$(e,"event")}s(fs,"runnerEventFromHookInput");function $u(e,t,n){let r=zt(e),o=ls(e),i=fs(e),a=$(e,"source"),c=Vt(e,i,t,n);return{sessionId:r,turnId:o,runnerEvent:i,hookSource:a,runnerPlatform:c}}s($u,"normalizeHookFields");var yE=["session_start","session_end","tool_invoked","skill_invoked"];function RE(e){return yE.includes(e)}s(RE,"isKnownInternalEvent");function Nr(e,t){return e&&RE(e)?e:EE(t.toLowerCase())}s(Nr,"resolveInternalEvent");var AE={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function wr(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}s(wr,"isMcpShapedToolName");function Bu(e,t=""){let n=$(e,"tool_name")||$(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!wr(n)&&(n=`MCP:${n}`):n=AE[r]??null;let o=e.tool_input,a=(o&&typeof o=="object"?dt(o.skill)||dt(o.skill_name):"")||$(e,"skill_name")||null,c=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;a??=tu(c);let u=Pu(c),f=vu(c);return{toolName:n,skillName:a,ruleName:u,commandName:f}}s(Bu,"extractToolNames");var CE=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function ju(e){for(let t of["subagent_type","agent_type"]){let n=$(e,t);if(n&&CE.test(n))return n}return null}s(ju,"extractSubagentType");function Ku(e){let t=je(e,"duration_ms");if(typeof t=="number")return t;let n=je(e,"duration");return typeof n=="number"?n:null}s(Ku,"extractDurationMs");var bE="error",xE="interrupted",OE="permission_denied",IE=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function Cn(e){return IE.test(e)?e:null}s(Cn,"categoricalValue");function kE(e){for(let t of["failure_type","error_type"]){let n=Cn($(e,t));if(n)return n}return null}s(kE,"structuredFailureClass");function Gu(e,t){return je(e,"is_interrupt")===!0?xE:t.toLowerCase()==="permissiondenied"?OE:kE(e)??bE}s(Gu,"extractFailureClass");function Vu(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}s(Vu,"longestDeclaredServer");function TE(e,t){return Vu(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}s(TE,"matchDeclaredMcpServer");function PE(e,t){return Vu(t,n=>(0,Tr.mcpServerNameMatchesToolSegment)(n,e))}s(PE,"matchDeclaredMcpServerSegment");function NE(e,t){let n=null,r=0;for(let i of t)if(i)for(let a of(0,Tr.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:PE(o[1],t)??o[1],mcpTool:o[2]}}s(NE,"parseClaudeMcpNames");function wE(e,t){if(/^mcp__/i.test(e))return NE(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:TE(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}s(wE,"parseMcpNamesFromToolName");function LE(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}s(LE,"stripEncodedMcpServerPrefix");function zu(e,t=[],n=""){let r=e?wE(e,t):{mcpServer:null,mcpTool:null},o=Cn(n.trim());if(!o)return r;let i=r.mcpTool;return!i&&e&&!wr(e)&&(i=e),i&&(i=LE(i,o)),{mcpServer:o,mcpTool:i}}s(zu,"extractMcpNames");var Yu=3e4,FE="claims",$E=!0,BE=100,jE=new Set(["sessionstart","sessionend","stopfailure"]),KE=["tool_name","tool","command","file_path","url"];function GE(e=Ju()){return ds(Ee(e),FE)}s(GE,"eventClaimDir");function Xu(e,t){try{let n=HE(e,"utf8").split(`
|
|
25
|
+
`,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}s(Xu,"claimAgeMs");function VE(e){let t=[];for(let n of KE){let r=$(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":un(t.join("\0"))}s(VE,"callFingerprintFromHookInput");function zE(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=jE.has(n);if(!c&&!u)return;let f=e.runnerPlatform.trim()||"unknown";return un(`${f}|${t}|${n}|${r}|${o}|${a}|${i}`)}s(zE,"eventClaimKey");function WE(e,t=Date.now()){let n;try{n=UE(e)}catch{return}let r=0;for(let o of n){if(r>=BE)break;r+=1;let i=ds(e,o),a=Xu(i,t);if(!(!Number.isFinite(a)||a<Yu))try{Wu(i)}catch{}}}s(WE,"pruneStaleEventClaims");function JE(e,t,n=Date.now()){let r=ds(t,e);try{if(vE(r)){let o=Xu(r,n);if(Number.isFinite(o)&&o>=0&&o<Yu)return!1;try{Wu(r)}catch(i){if(!(i instanceof Error&&"code"in i&&i.code==="ENOENT"))return D("event_claim_steal",i),!0}}}catch{}try{ME(t,{recursive:!0}),DE(r,`${n}
|
|
26
|
+
`,{encoding:"utf8",flag:"wx"})}catch(o){if(fn(o))return!1;let i=o instanceof Error?o.message:String(o);return P(`WARN: event claim failed open: ${i}`),D("event_claim",o),!0}return WE(t,n),!0}s(JE,"tryClaimHookEvent");function YE(e,t,n){let r=zt(e),o=ls(e),i=$(e,"tool_use_id"),a=$(e,"subagent_id")||$(e,"agent_id"),c=Vt(e,t,void 0,n),u=VE(e);return{runnerPlatform:c,sessionId:r,runnerEvent:t,turnId:o,toolUseId:i,subagentId:a,callFingerprint:u}}s(YE,"identityFromHookInput");function qu(e,t,n,r=Ju(),o=Date.now()){if(!$E)return!0;let i=zE(YE(e,t,n));if(!i)return!0;let a=JE(i,GE(r),o);return!a&&H("EV_AI_HOOK_DEBUG")&&P(`DEBUG: duplicate hook event suppressed (claim ${i.slice(0,8)}\u2026)`),a}s(qu,"claimHookEvent");import{mkdirSync as XE,readFileSync as ps,statSync as tl,unlinkSync as nl,writeFileSync as ms}from"node:fs";import{homedir as rl}from"node:os";function ol(e){return e==="session_start"||e==="session_end"}s(ol,"isCapExemptEvent");var Lr=new Set,Zu=!1;function gs(e=rl()){return Pa(e)}s(gs,"hookSlotDir");function _s(e,t=rl(),n=process.platform){if(e!==void 0)return e>0?e:nr(n);let r=q(pt(t),{});return Ba(r)??nr(n)}s(_s,"maxConcurrentHookProcesses");function bn(e){return sr(e.pid,e.acquiredAtMs)}s(bn,"slotContent");function sl(e){try{let t=tl(e);return t.isFile()&&t.size<=Lo?ps(e,"utf8"):void 0}catch{return}}s(sl,"readSlotText");function hs(e,t=gs()){if(!e)return;let n=or(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=sl(n);if(o===bn(r))return vr(r);if(o===sr(process.ppid,e.acquiredAtMs))try{return ms(n,bn(r),{encoding:"utf8",mode:384}),vr(r)}catch{return}}s(hs,"adoptHookSlot");function il(e,t){if(e.path){Lr.delete(e);try{sl(e.path)===bn(e)&&ms(e.path,sr(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}s(il,"handOffHookSlot");function al(e,t=Date.now()){let n,r;try{let o=tl(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=Lo?ps(e,"utf8"):""}catch{return!1}return wa(n,r,t)}s(al,"isSlotHeld");function cl(e,t=gs(),n=Date.now){for(let r=0;r<e;r+=1)if(!al(or(t,r),n()))return!0;return e<=0}s(cl,"hasFreeHookSlot");function ul(e){return{pid:process.pid,acquiredAtMs:e}}s(ul,"noopSlot");function Qu(e,t){let n=e instanceof Error?e.message:String(e);return P(`WARN: hook process slot failed open: ${n}`),D("slot",e),ul(t)}s(Qu,"failOpen");function vr(e){return Lr.add(e),Zu||(Zu=!0,process.once("exit",()=>{for(let t of[...Lr])Mr(t)})),e}s(vr,"hold");function el(e){try{return ms(e.path,bn(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(fn(t))return!1;throw t}}s(el,"tryCreateSlot");function ll(e,t=gs(),n=Date.now){if(e<=0)return ul(n());try{XE(t,{recursive:!0})}catch(i){return Qu(i,n())}let r,o=0;for(let i=0;i<e;i+=1)try{let a={path:or(t,i),pid:process.pid,acquiredAtMs:n()};if(el(a))return vr(a);if(al(a.path,n())){o+=1;continue}try{nl(a.path)}catch(c){if(!vt(c))throw c}if(a.acquiredAtMs=n(),el(a))return vr(a);o+=1}catch(a){r??=a}return r!==void 0&&o>0&&D("slot",r),r===void 0||o>0?null:Qu(r,n())}s(ll,"tryAcquireHookSlot");function Mr(e,t=Date.now()){if(Lr.delete(e),!(!e.path||t-e.acquiredAtMs>=rr-dn))try{ps(e.path,"utf8")===bn(e)&&nl(e.path)}catch{}}s(Mr,"releaseHookSlot");function Ss(e){H("EV_AI_HOOK_DEBUG")&&P(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}s(Ss,"logHookCapReached");import{closeSync as qE,writeSync as ZE}from"node:fs";function fl(e=process.env){let t=e[No];if(delete e[No],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{ZE(n,Ea)}catch{}try{qE(n)}catch{}}}s(fl,"signalLauncherReady");function Es(e=process.env){let t=e[ma];if(t)return{launcherVersion:t,hookSource:e[ga]??"",fallbackReason:e[_a],launcherScope:e[ha]}}s(Es,"readLauncherContext");function dl(e,t){return(e?mt(e):void 0)===t}s(dl,"launcherScopeMatch");import{readFileSync as QE,statSync as ey}from"node:fs";import{homedir as ty}from"node:os";import{join as ny}from"node:path";var ry="perf-prev.json",oy=512,sy=1440*60*1e3,iy=12e4,ay=50,xn={},pl=!1;function Rs(e){return Math.round(e*10)/10}s(Rs,"round1");function Me(e,t){if(!gn())return t();let n=performance.now();return t().finally(()=>{xn[e]=Rs(performance.now()-n)})}s(Me,"span");function cy(){for(let e of Object.keys(xn))delete xn[e]}s(cy,"clearSpans");function gl(){if(!gn())return;let e=cc();e&&(process.env[$o]=e)}s(gl,"handOffHookTimings");function ml(e,t){if(!e)return;let n=t-e.origin;return n>=-ay&&n<=iy?e:void 0}s(ml,"trusted");function uy(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(uy,"isPrevPost");function _l(e=ty()){return ny(Ee(e),ry)}s(_l,"perfPrevPath");function ly(e,t){if(!pl){pl=!0;try{let n=_l(t);if(ey(n).size>oy)return;let r=JSON.parse(QE(n,"utf8"));return!uy(r)||e-r.at>sy?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}s(ly,"takePrevPost");function As(e,t){if(!gn())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{ue(_l(t),JSON.stringify(n))}catch{}}s(As,"recordPostDuration");function ys(e,t,n,r,o=n.marks){let i=Math.max(0,n.origin-r);e[t]=Rs(i);for(let[a,c]of Object.entries(o))e[a]=Rs(i+c)}s(ys,"addProcess");function hl(e,t=process.env,n,r=!1){let o=r?zi():void 0;if(!gn())return o?{sys:o}:void 0;let i=ic(),a="w0"in i.marks?"w":"h",c=a==="w"?ml(Bo(t[$o]),i.origin):void 0,u=ml(Bo(t[oc]),(c??i).origin),f=u?"l":c?"h":a,l=(u??c??i).origin,p={};u&&ys(p,"l",u,l),c&&ys(p,"h",c,l),ys(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(xn).length>0&&(d.spans={...xn},cy());let m=ly(Date.now(),n);return m&&(d.prev=m),o&&(d.sys=o),d}s(hl,"buildPerf");import{realpathSync as hO}from"node:fs";import{homedir as SO}from"node:os";var V=Ze(ct(),1);import{existsSync as fy,readFileSync as dy}from"node:fs";import{homedir as Sl}from"node:os";import{join as py}from"node:path";var my="cloud-cache.json",gy=1440*60*1e3,_y=900*1e3;function hy(e=Sl()){return py(Ee(e),my)}s(hy,"cloudCachePath");function Sy(e){if(!fy(e))return;let t=Oe(dy(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(Sy,"readCloudCache");function Ey(e,t){try{ue(e,`${JSON.stringify(t)}
|
|
27
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);P(`WARN: cloud cache write failed open: ${r}`),D("cloud_cache",n)}}s(Ey,"writeCloudCache");function yy(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?_y:gy;return n-e.probed_at<r}s(yy,"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 Ay(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(Ay,"probeGcp");async function Cy(e){let t=await fetch("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{headers:{Metadata:"true"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=n.compute?.location??"",o=n.compute?.vmId??"";if(!(!r&&!o))return{provider:"azure",region:r,instance_id:o}}s(Cy,"probeAzure");async function by(e){let t=await Promise.allSettled([Ry(e),Ay(e),Cy(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}s(by,"runCloudProbes");async function El(e,t){if(e==="interactive")return null;let n=t?.home??Sl(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),i=hy(n),a=Sy(i);if(yy(a,e,o))return a.result;let c=await by(r);return Ey(i,{context:e,probed_at:o,result:c}),c}s(El,"probeCloud");var Cl=Ze(ct(),1);import{existsSync as Rl}from"node:fs";import{homedir as Al}from"node:os";import{join as On,resolve as Cs,sep as yl}from"node:path";function Ur(e,t,n){if(!Rl(e))return;let r=q(e,{});for(let[o,i]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:i})}s(Ur,"readMcpServers");function xy(e,t,n){if(!Rl(e))return;let r=q(e,{}),o=Cs(t),i=null;for(let c of Object.keys(r.projects??{})){let u=Cs(c);(o===u||o.startsWith(u.endsWith(yl)?u:u+yl))&&(i===null||u.length>Cs(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(xy,"readClaudeProjectMcpServers");function bl(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"?(Ur(On(r,".claude.json"),{source:"claude_json_user"},o),xy(On(r,".claude.json"),t,o)):n==="cursor"&&Ur(On(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),Ur(On(t,".mcp.json"),{source:"mcp_json"},o),Ur(On(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}s(bl,"collectMcpServers");async function bs(e,t=process.cwd(),n="claude",r=Al()){return[...bl(e,t,n,r).values()].map(o=>o.declared)}s(bs,"mcpDeclared");function xl(e,t,n=process.cwd(),r="claude",o=Al()){let i=bl(t,n,r,o),a=i.get(e);if(a!==void 0)return a.config??null;for(let[c,u]of i)if((0,Cl.mcpServerNameMatchesToolSegment)(c,e))return u.config??null;return null}s(xl,"mcpServerConfig");var Oy=["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"],Iy=["CURSOR_PROJECT_DIR"],ky=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function Ty(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)ky.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}s(Ty,"stripUrlUserinfo");function Ol(e=process.env){let t=Oy.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:Ty(e[r]??"")}:{name:r,present:!1}),n=Iy.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}s(Ol,"readEnvVars");import{homedir as rR}from"node:os";import{homedir as Tl}from"node:os";import{join as Il}from"node:path";var Py="https://api.openai.com/auth";function Wt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Wt,"trimString");function Pl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}s(Pl,"asJsonObject");function Ny(e){let t=e.split(".");if(t.length!==3||t.some(r=>r.length===0))return null;let n=t[1];if(!n)return null;try{let r=JSON.parse(Buffer.from(n,"base64url").toString("utf8"));return Pl(r)}catch{return null}}s(Ny,"decodeJwtPayload");function kl(e,t,n){return Wt(e[n])??Wt(t?.[n])}s(kl,"claim");function wy(e=process.env,t=Tl()){let n=Wt(e.CODEX_HOME)??Il(t,".codex");return Il(n,"auth.json")}s(wy,"codexAuthPath");function Nl(e=process.env,t=Tl()){let n=q(wy(e,t),{}),r=Wt(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&Wt(n.OPENAI_API_KEY))return null;let o=Wt(n.tokens?.id_token);if(!o)return null;let i=Ny(o);if(!i)return null;let a=Pl(i[Py]),c=kl(i,a,"name"),u=kl(i,a,"email");return!u||le(c,u)?null:{git_user_name:null,git_user_email:null,platform_login:u,identity_source:"codex_oauth"}}s(Nl,"readCodexOperatorIdentity");import{homedir as Fr}from"node:os";import{join as We}from"node:path";import{join as Ly}from"node:path";var vy="cursor-ide-identity.json",My=840*60*1e3;function Ll(e){return Ly(Ee(e),vy)}s(Ll,"cursorIdeIdentityCachePath");function wl(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(wl,"nullableString");function vl(e){let t=q(e,{}),n=t.read_at_ms,r=t.db_path;if(!(typeof n!="number"||!Number.isFinite(n)||typeof r!="string"))return{read_at_ms:n,db_path:r,email:wl(t.email),auth_id:wl(t.auth_id)}}s(vl,"readCursorIdeIdentityCache");function Ml(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<My}s(Ml,"isCursorIdeIdentityCacheFresh");function Ul(e,t){try{ue(e,`${JSON.stringify(t)}
|
|
28
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);P(`WARN: cursor IDE identity cache write failed open: ${r}`),D("cursor_identity_cache",n)}}s(Ul,"writeCursorIdeIdentityCache");import{execFileSync as Uy}from"node:child_process";import{existsSync as Hy}from"node:fs";import{createRequire as Dy}from"node:module";import{pathToFileURL as Fy}from"node:url";var Dl=Dy(import.meta.url),Hr=`
|
|
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(),
|
|
33
|
-
`)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let
|
|
34
|
-
`);return
|
|
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 mE(e,t=te){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return pE(n)}function gE(e=process.env){let t=j(e.GIT_AUTHOR_NAME),n=j(e.GIT_AUTHOR_EMAIL);if(t||n)return{git_user_name:t,git_user_email:n,platform_login:null,identity_source:"git_env"};let r=j(e.GIT_COMMITTER_NAME),o=j(e.GIT_COMMITTER_EMAIL);if(r||o)return{git_user_name:r,git_user_email:o,platform_login:null,identity_source:"git_env"};let s=j(e.EMAIL);return s?{git_user_name:null,git_user_email:s,platform_login:null,identity_source:"git_env"}:null}function Ke(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}function _E(e=process.env){let t=j(e.EV_AI_HOOK_OPERATOR_EMAIL),n=j(e.EV_AI_HOOK_OPERATOR_LOGIN),r=Ke(j(e.EV_AI_HOOK_OPERATOR_NAME),t,"configured",t??n);if(r)return r;let o=j(e.GITHUB_ACTOR)??j(e.GITHUB_TRIGGERING_ACTOR)??j(e.GITHUB_USER),s=Ke(o,null,"github",o);if(s)return s;let i=j(e.GITLAB_USER_LOGIN),a=j(e.GITLAB_USER_EMAIL),c=Ke(j(e.GITLAB_USER_NAME)??i,a,"gitlab",a??i);if(c)return c;let l=j(e.BUILD_REQUESTEDFOREMAIL),u=Ke(j(e.BUILD_REQUESTEDFOR),l,"azure_devops",l??j(e.BUILD_REQUESTEDFORID));if(u)return u;let d=j(e.BUILDKITE_BUILD_CREATOR_EMAIL),f=Ke(j(e.BUILDKITE_BUILD_CREATOR),d,"buildkite",d);if(f)return f;let p=j(e.BUILD_USER_EMAIL)??j(e.CHANGE_AUTHOR_EMAIL),g=Ke(j(e.BUILD_USER)??j(e.CHANGE_AUTHOR),p,"jenkins",p??j(e.BUILD_USER_ID));if(g)return g;let S=j(e.CIRCLE_USERNAME),C=Ke(S,null,"circleci",S);if(C)return C;let A=j(e.CODEBUILD_INITIATOR),k=Ke(A,null,"codebuild",A);if(k)return k;let P=j(e.DRONE_COMMIT_AUTHOR_EMAIL),T=j(e.DRONE_COMMIT_AUTHOR),x=Ke(T??j(e.DRONE_COMMIT_AUTHOR_NAME),P,"drone",P??T);if(x)return x;if(qu(e.CLAUDE_CODE_REMOTE)||qu(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 qu(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function hE(e,t,n){return e==="claude"?Mu(t):e==="cursor"?Yu(t,n):e==="codex"?Du(n,t):null}async function Xo(e,t=te,n=process.env,r={}){let o=await mE(e,t),s=gE(n),i=Yo(o)?o:s&&Yo(s)?s:null,a=hE(r.runnerPlatform,r.home??fE(),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=_E(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=dE(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&&La(p,a,Nn())}}}function Zo(e){return e?!_o(e)?.operator_identity_hash:!0}function Zu(e){return!0}import{existsSync as jC,readFileSync as KC}from"node:fs";import{homedir as Id}from"node:os";import{join as Mt,resolve as BC}from"node:path";import{basename as MC,join as wt}from"node:path";import{dirname as dl,resolve as Ar}from"node:path";import{existsSync as xE}from"node:fs";import{homedir as sl}from"node:os";import{relative as il,resolve as Ne,sep as et}from"node:path";import{appendFileSync as SE,mkdirSync as EE,readFileSync as yE}from"node:fs";import{homedir as Qu}from"node:os";import{dirname as RE,join as el}from"node:path";var CE="hooks-debug.log",tl={info(){},error(){}},Er=tl;function AE(e=Qu()){return el(e,".ev-ai",CE)}function bE(e=Qu()){try{let t=JSON.parse(yE(el(e,".ev-ai","config.json"),"utf8"));return t!==null&&typeof t=="object"&&!Array.isArray(t)&&t.debug===!0}catch{return!1}}function Qo(e,t=!1){return e.includes("--debug")||t}function OE(e){return e.replace(/[\r\n]/g," ")}function nl(e=process.argv,t=AE(),n=bE()){if(!Qo(e,n)){Er=tl;return}let r=(o,s)=>{try{EE(RE(t),{recursive:!0}),SE(t,`${new Date().toISOString()} ${o} ${OE(s)}
|
|
36
|
-
`,"utf8")}catch{}};Er={info(o){r("info",o)},error(o){r("error",o)}}}var ge={info(e){Er.info(e)},error(e){Er.error(e)}};var IE=["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"],kE=["prompt","tool_input","tool_response","last_assistant_message","command"],TE=new Set;function PE(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return TE}}function os(e){let t=v("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?jt.has(t.toLowerCase()):e?.collect_prompt===!0}function yr(e,t){let n=al(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!==""?jt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}function al(e){return v("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||Qo(process.argv,e.debug===!0)||v("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}function NE(e){let t={};for(let n of IE){let r=Ue(e,n);r!==void 0&&(t[n]=r)}return t}function Rr(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Ne(e),r=Ne(t),o=il(r,n);return!o||o==="."?".":o.startsWith(`..${et}`)||o===".."||Ne(r,o)!==n?null:o.split(et).join("/")}function cl(e,t){let n=il(Ne(t),Ne(e)).split(et).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}function ul(e){return typeof e!="string"||e.length===0?null:Ne(e).split(et).join("/")}function wE(){let e=v("CURSOR_PROJECT_DIR");if(!e)return null;let t=Ne(e);return xE(t)?t.split(et).join("/"):null}function ts(e,t){return Rr(e,t)!==null}function ME(e,t){let n=Ne(t??sl(),".cursor").split(et).join("/");return ts(e,n)}function vE(e,t,n){return t!==null&&ts(e,t)?!0:t!==null&&ME(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&ts(e,n.gitRoot)?!0:t===null}function ll(e,t){let n=ul(e.cwd);if(n!==null)return n;let r=Ne(process.cwd()).split(et).join("/"),o=wE();return vE(r,o,t)?r:o??r}function ss(e,t={}){return ll(e,t)}function is(e,t=sl()){let n=Ne(t).split(et).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function rl(e,t,n){let r=ul(n.launchCwd)??ll(t,n);e.cwd=is(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?Rr(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}var fl="\u2026[truncated]\u2026",ns=Buffer.byteLength(fl,"utf8"),LE=8;function un(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function ol(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}function HE(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 UE(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=ns)return ol(e,t);let r=t-ns,o=Math.ceil(r/2),s=Math.floor(r/2);return`${ol(e,o)}${fl}${HE(e,s)}`}function rs(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)=>{rs(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||rs(o,[...t,r],n)}function DE(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 FE=256;function $E(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 jE(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let s=un(e);if(s<=t)return;let i=[];rs(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=$E(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&&DE(e,u.path,UE(u.value,r))}}function KE(e,t){let n=Math.max(0,t-FE),r=Object.keys(e).filter(s=>!s.startsWith("_")).map(s=>({key:s,bytes:un(e[s])})).sort((s,i)=>i.bytes-s.bytes),o=[];for(let{key:s}of r){if(un(e)<=n)break;delete e[s],o.push(s)}o.length>0&&(e._dropped_keys=o.slice(0,10))}function es(e,t){let n=un(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,jE(r,t,ns+LE),un(r)>t&&KE(r,t),r}function BE(e,t,n){if(!(n.promptCapture??os()))return;let r=PE(n.runnerEvent);for(let o of kE){if(r.has(o))continue;let s=t[o];s!==void 0&&(e[o]=s)}}function Cr(e,t,n={}){let r=al(t);if(r==="full"){let s={...e};return delete s.cwd,delete s.transcript_path,rl(s,e,n),es(s,lo)}let o=NE(e);return rl(o,e,n),r==="content"?(BE(o,e,n),es(o,lo)):es(o,Sa)}function GE(e){return typeof e=="string"&&e.length>0}function as(e){let t=Ar(e.home),n=Ar(e.launchCwd),r=e.gitRoot?Ar(e.gitRoot):null,o=new Set,s=[],i=null;e.inGitRepo&&GE(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&&Rr(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&c){let l=dl(r);for(;;){let u=Ar(l);if(u===t)break;let d=dl(u);if(d===u)break;if(e.hasProjectSpec(u)){s.push({scope:"parent",dir:u}),a=cl(u,n);break}l=d}}return{anchors:s,parentRel:a}}import{existsSync as pl,readdirSync as VE,realpathSync as zE}from"node:fs";import{basename as WE,dirname as JE,relative as YE,resolve as XE,sep as qE}from"node:path";var cs=400,br=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??We}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=XE(t).split(qE).join("/");return is(r,this.home)}let n=YE(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${q(JE(t))}/${WE(t)}`:n}claimFile(t){try{let n=zE(t);return this.seenRealpaths.has(n)?!1:(this.seenRealpaths.add(n),!0)}catch{return this.seenRealpaths.has(t)?!1:(this.seenRealpaths.add(t),!0)}}get atGlobalCap(){return this.truncated||this.components.length>=this.maxEntries}get pluginBudgetSpent(){return this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0}readEntries(t){if(!pl(t))return[];try{return VE(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(pl(t))return X(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 xs,readFileSync as yR,statSync as RR}from"node:fs";import{basename as Tf,join as lt,relative as Is}from"node:path";var Of=ze(bf());var SR=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],xf=SR.map(e=>Of.default.matcher(e,{dot:!0}));function ER(e){return e===""?!1:xf.some(t=>t(`${e}/`))}function If(e,t){if(t==="")return!1;if(e==="")return ER(t);let n=e.replace(/\/+$/,"");return xf.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}var ks=100*1024,CR=4;function AR(e){return e.length<=ks?e:`${e.slice(0,ks-1)}\u2026`}function bR(e){try{let t=yR(e),n=t.toString("utf8");return{hash:q(t),length:t.length,text:AR(n)}}catch{return null}}var kf={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function OR(e){return e in kf?kf[e]:"UNSPECIFIED"}function Pt(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=bR(t.absolutePath);if(!n)return!1;let r=t.name??Tf(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=OR(t.kind);return s&&(o.trigger=s),t.attributes&&(o.attributes=t.attributes),e.push(o)}function xR(e,t,n){let r=Is(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?Tf(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function ft(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>CR))for(let d of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(d.isDirectory()&&If(n.replace(/\\/g,"/"),Is(n,lt(r,d.name)).replace(/\\/g,"/"))||d.isDirectory()&&u?.includes(lt(r,d.name)))continue;if(c){if(!d.isDirectory())continue;let g=lt(r,d.name,c);if(xs(g)){let S=Is(n,lt(r,d.name)).replace(/\\/g,"/");Pt(e,{absolutePath:g,kind:s,origin:i,enabled:a,name:S||d.name});continue}Ts(e,{walkRoot:n,currentDir:lt(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:lt(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=lt(r,d.name);Pt(e,{absolutePath:p,kind:s,origin:i,enabled:a,name:xR(n,p,!0)})}}function Pf(e){for(let t of e)if(xs(t))try{if(RR(t).size>0)return t}catch{continue}return e.find(t=>xs(t))}import{existsSync as nC,readFileSync as rC}from"node:fs";var Nr=ze(Qe(),1);var IR="<omitted>",kR=["package_name","package_spec","package_version","package_version_source"],Nf=100,wf=120,wr=[{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"}],Mf=new Set(wr.map(e=>e.attr)),TR=["enabled","disabled"],PR=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],NR=new Set(["type","command","url","args","env","envVars","headers",...TR,...PR,...wr.map(e=>e.raw)]),wR=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",...kR,...Mf,...[...Mf].map(e=>`${e}_truncated`)]);function vf(e,t){for(let n of t)NR.has(n)||wR.has(n)||(e[n]=IR)}var MR=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,vR=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,LR=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,HR=/^bearer(?:\s+|$)/i;function Mr(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Lf(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Ps(e){if(Array.isArray(e)){let n=[];for(let r of e){if(typeof r!="string"||r.length===0)continue;let o=r.split("=",1)[0]?.trim();o&&n.push(o)}return n}let t=Mr(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function dt(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function UR(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,Nr.launchContainsCredentials)({kind:"url",url:e})||(0,Nr.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=_n([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,Nr.launchContainsCredentials)({kind:"url",url:r}):!0)}function Hf(e,t,n){UR(t,n)&&(e.launch_had_credentials=!0)}function DR(e){return LR.test(e)||HR.test(e)?"<redacted>":e.includes("://")?dt(e):e}function Uf(e){if(/^https?:\/\//i.test(e))return dt(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Uf(e.slice(t+1))}`:DR(e)}function FR(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return MR.test(t)||vR.test(t)}function _n(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(FR(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Uf(r))}return t}function $R(e){let t=Lf(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>wf?r.slice(0,wf):r))].sort();if(n.length!==0)return n.length>Nf?{names:n.slice(0,Nf),truncated:!0}:{names:n,truncated:!1}}function jR(e){let t=Mr(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,s]of Object.entries(t))o.length>0&&n.push(o),typeof s=="string"&&s.length>0&&r.push(s);return{headers:n,envVars:r}}function Df(e,t){let n=new Set;for(let{raw:r,attr:o}of wr){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=$R(s);i&&(e[o]=i.names,i.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function Ff(e,t){let n=Mr(e),r={transport:t};if(!n)return r;vf(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=Lf(n.args);a&&(r.command_or_url=dt(a));let l=_n(c);l.length>0&&(r.args=l),Hf(r,a,c);let u=jR(n.env_http_headers),d=[...new Set([...Ps(n.env),...Ps(n.envVars),...Ps(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),Df(r,n),r}function $f(e){let t=Mr(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function Ms(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return q(JSON.stringify({name:e,attributes:r,enabled:n}))}function Nt(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function gn(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 ws(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function Ns(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=Nt(n[1]);return r.length>0?r:void 0}function KR(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],Nt(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(`
|
|
37
|
-
|
|
38
|
-
`)){let s
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
`)){let k=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(A);k?.[1]&&u.add(k[1])}for(let A of gn(e,"env_vars"))u.add(A);let p=KR(e,"env_http_headers");for(let[,A]of p)A.length>0&&u.add(A);let g=Ns(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=Ns(e,"auth");S&&(n.auth=S);let C=Ns(e,"default_tools_approval_mode");return C&&(n.default_tools_approval_mode=C),BR(n,e),n}var ve=ze(Qe(),1);import{createHash as XR}from"node:crypto";import{join as hn}from"node:path";var WR=300,JR=256;function Bf(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 vr(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 Gf(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function YR(e){return Gf(e,WR)}function Vf(e,t){let n=Bf(e.trim(),t),r=vr(n);if(r.length===0)return"";let[o,...s]=r,i=dt(o),a=_n(s);return YR([i,...a].join(" "))}function zf(e,t){if(typeof e!="string")return null;let n=Bf(e.trim(),t),r=vr(n)[0];if(!r)return null;let o=dt(r);return o.length===0?null:Gf(o,JR)}function qR(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,ve.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}function ZR(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
|
|
42
|
-
`);return XR("sha512").update(t).digest("hex").slice(0,16)}function QR(e){let t=process.platform==="win32"?hn(v("LOCALAPPDATA")??e,"npm-cache"):hn(e,".npm"),n=v("npm_config_cache")??v("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}function Wf(e){return typeof e=="string"&&e.length>0&&e.length<=ve.PACKAGE_FIELD_MAX?e:null}function eC(e,t,n){let r=ZR(e);for(let o of QR(n)){let s=hn(o,"_npx",r),i=X(hn(s,"node_modules",...t.split("/"),"package.json"),{}),a=Wf(i.version);if(a!==null)return a;let c=X(hn(s,"package-lock.json"),{}),l=Wf(c.packages?.[`node_modules/${t}`]?.version);if(l!==null)return l}return null}function tC(e){return e.length<=ve.PACKAGE_FIELD_MAX?e:`${e.slice(0,ve.PACKAGE_FIELD_MAX-1)}\u2026`}function vs(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,ve.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let s=(0,ve.packageNameFromSpec)(o);return s===null?null:{package_name:s,package_spec:tC(o),...qR(o,eC(r,s,n))}}function Jf(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=vr(e.trim());return n===void 0?null:vs(n,r,t)}function Lr(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 vs(typeof n.command=="string"?n.command:null,r,t)}function Yf(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:vs(Nt(n[1]??""),gn(e,"args"),t)}function oC(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 Xf(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=oC(a),l=Ff(a,c);Object.assign(l,Lr(a,e.home)??{});let u=$f(a);e.push({kind:"MCP_SERVER",name:i,path:s,content_hash:Ms(i,l,u),origin:n,enabled:u,attributes:l})}}function qf(e,t,n){if(!nC(t)||!e.claimFile(t))return;let r;try{r=rC(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=Kf(u,d);Object.assign(f,Yf(u,e.home)??{});let p=jf(u);e.push({kind:"MCP_SERVER",name:a,path:o,content_hash:Ms(a,f,p),origin:n,enabled:p,attributes:f})}}import{existsSync as aC,readdirSync as cC}from"node:fs";import{join as le}from"node:path";function sC(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 iC(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 Ls(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 iC(c)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??c.powershell??"",d=sC({type:l.type??c.type,command:l.command??c.command,bash:l.bash??c.bash,powershell:l.powershell??c.powershell,prompt:l.prompt??c.prompt}),f=typeof c.matcher=="string"?c.matcher:"",p=q(u),g=f?`${s}:${f}:${d}:${p}`:`${s}:${d}:${p}`,S=`${s}|${f}|${d}|${u}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:q(S),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:s,...f?{matcher:f}:{},action_kind:d,action_hash:p,...d!=="prompt"&&u.trim()?{command:Vf(u,e.home)}:{}}})}}}function Hs(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||Ls(e,t,r.hooks,n)}var Zf=50;function Sn(e,t,n,r){if(!aC(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(Zf,()=>{ft(e,{dir:le(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),ft(e,{dir:le(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),ft(e,{dir:le(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});Hs(e,le(t,"hooks","hooks.json"),n),Hs(e,le(t,"hooks.json"),n);let i=e.components.length-o,a=s>=Zf;return{componentCount:i,expandTruncated:a}}function En(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 Us(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 uC(e){let t=Us(e.readJson(le(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=Jt(process.platform,e.home),o=e.readJson(n,{}),s={};if(o&&Object.keys(o).length>0)s=Us(o);else for(let i of r)Object.assign(s,Us(e.readJson(i,{})));return{...t,...s}}function Qf(e){let t=le(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=uC(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 k=Sn(e,A.installPath,g,u);S+=k.componentCount,C=C||k.expandTruncated}En(e,{pluginKey:i,rowPath:s,enabled:u,scope:p,version:f||void 0,marketplace:d||void 0,componentCount:S,expandTruncated:C,contentHash:q(`${i}|${f}|${p}|${u}|${S}`)})}}function lC(e){let t=e,n="";try{let r=cC(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 fC=/^\d+$/;function dC(e){let t=e.filter(n=>!fC.test(n.pluginId));return t.length>0?t:e}function ed(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}=Sn(e,c,l,!0);En(e,{pluginKey:a,rowPath:e.componentPath(c),enabled:!0,scope:"local",componentCount:u,expandTruncated:d,contentHash:q(`${a}|local|${u}`)});continue}let s=o.name,i=[];for(let a of e.readEntries(le(n,s))){if(!a.isDirectory())continue;let c=le(n,s,a.name),{installPath:l,version:u}=lC(c);i.push({pluginId:a.name,installPath:l,version:u})}for(let a of dC(i)){if(e.truncated)break;let c=`${a.pluginId}@${s}`,l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=Sn(e,a.installPath,l,!0);En(e,{pluginKey:c,rowPath:e.componentPath(a.installPath),enabled:!0,scope:"cache",version:a.version||void 0,marketplace:s,componentCount:u,expandTruncated:d,contentHash:q(`${c}|${a.version}|${u}`)})}}}import{existsSync as gC}from"node:fs";var pC=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,Ds="<path>",mC=new RegExp(`${Ds}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function Hr(e){let t=e.replace(pC,Ds).replace(mC,Ds);return t.length>200?`${t.slice(0,200)}...`:t}var td=200,nd=200,Fs=16*1024,rd=6,_C=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),hC=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),SC=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),EC=new Set(["permissions"]),yC={claude:_C,cursor_sandbox:hC,cursor_permissions:SC,cursor_cli:EC},RC=new Set(["allow","deny","ask"]);function tt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ur(e){return e.replace(/\\/g,"/")}function $s(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>$s(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${$s(t[r])}`).join(",")}}`}function CC(e){return q(`${$s(e)}|settings1`)}function cd(e){let t=Ur(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 ud(e,t){if(e!=="claude")return{};let n=Ur(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 ld(e){let t=Ur(e).replace(/\/+$/,"");return t.length<=1?"":t}function fd(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}function AC(e,t){let n=Ur(e);if(n==="~"||n.startsWith("~/"))return n;let r=ld(t);if(!r)return n;let o=n.slice(0,r.length);if(!(fd(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let i=n.slice(r.length);return i===""?"~":i.startsWith("/")?`~${i}`:n}var od=new Map;function bC(e){let t=od.get(e);if(t!==void 0)return t;let n=ld(e),r=null;if(n){let o=n.split("/").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,fd(e)?"gi":"g")}return od.set(e,r),r}function OC(e,t){let n=bC(t);return n?e.replace(n,"~"):e}function sd(e,t){return e.length<=nd?e:(t.truncated=!0,e.slice(0,nd))}function dd(e,t){return e.length<=td?e:(t.truncated=!0,e.slice(0,td))}function ne(e,t,n,r){if(typeof e=="string"){if(t==="path")return sd(AC(e,n),r);let o=t==="rule"?Hr(e):e;return sd(OC(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=dd(e,r),s=[];for(let i of o){let a=ne(i,t,n,r);a!==void 0&&s.push(a)}return s}if(tt(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 id(e,t,n){if(!tt(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 xC(e,t,n){if(!tt(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=dd(s,n);r[o]=a.map(c=>{if(!tt(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 IC(e,t,n){if(!tt(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 kC(e,t,n){if(!tt(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=IC(s,t,n):o==="credentials"?i=xC(s,t,n):i=ne(s,"plain",t,n),i!==void 0&&(r[o]=i)}return r}function TC(e,t,n,r,o){return n==="claude"?e==="permissions"?id(t,r,o):e==="sandbox"?kC(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"?id(t,r,o):ne(t,"plain",r,o)}function yn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function js(e,t){return e?`${e}.${t}`:t}function Ks(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>=rd?(e.splice(o,1),r.add(n)):Ks(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>=rd?(delete e[o],r.add(js(n,o))):Ks(s,t+1,js(n,o),r))}function pd(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:yn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))pd(o,js(t,r),n)}function PC(e,t,n){let r=yn(e);if(r<=Fs)return;t.truncated=!0;let o=[];for(pd(e,"",o);r>Fs;){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=yn(i)+(s.items.length>0?1:0);s.bytes-=a,r-=a,n.add(s.path)}for(;yn(e)>Fs;){let s,i=-1;for(let[a,c]of Object.entries(e)){let l=yn(c);l>i&&(s=a,i=l)}if(s===void 0)break;delete e[s],n.add(s)}}function NC(e,t,n){let r=yC[t],o={truncated:!1},s={},i=[];for(let c of Object.keys(e)){if(!r.has(c)){i.push(c);continue}let l=TC(c,e[c],t,n,o);l!==void 0&&(s[c]=l)}i.sort();let a=new Set;return Ks(s,1,"",a),a.size>0&&(o.truncated=!0),PC(s,o,a),{settings:s,keys_omitted:i,truncated:o.truncated,trimmed_paths:[...a].sort()}}function ad(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:CC(t.attributes),attributes:t.attributes};e.push(n)}function Bs(e,t,n,r){if(!e.claimFile(t)||!gC(t))return;let o=ki(t);if(!o.ok||!tt(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),ad(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}return}let s=o.value,i=s.hooks;if(tt(i)&&Ls(e,t,i,n),!r.profile)return;let a=NC(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),ad(e,{kind:r.kind,absPath:t,origin:n,attributes:c})}import{existsSync as wC}from"node:fs";import{join as Le}from"node:path";var md=".claude/skills/synced",gd=".claude/plugins/synced";function _d(e){return[Le(e,md),Le(e,gd)]}function Dr(e){return typeof e=="string"&&e.length>0?e:void 0}function hd(e){let t=Le(e.home,md);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Le(t,n.name),o=e.readJson(Le(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=Le(r,i.name,"SKILL.md");if(!i.isDirectory()||!wC(a))continue;let c=s.get(i.name),l=Dr(c?.source),u=Dr(c?.creatorType);Pt(e,{absolutePath:a,kind:"SKILL",origin:"user",enabled:!0,name:i.name,attributes:{scope:"synced",...l?{source:l}:{},...u?{creator_type:u}:{}}})}}}function Sd(e){let t=Le(e.home,gd);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Le(t,n.name),o=e.readJson(Le(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=Dr(a?.marketplaceName),l=Dr(a?.version),u=c?`${i.name}@${c}`:i.name,d=Le(r,i.name),{componentCount:f,expandTruncated:p}=Sn(e,d,`plugin:${u}`,!0);En(e,{pluginKey:u,rowPath:e.componentPath(d),enabled:!0,scope:"synced",version:l,marketplace:c,componentCount:f,expandTruncated:p,contentHash:q(`${u}|${l??""}|synced|${f}`)})}}}function vC(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:s}=t;for(let i of n.skillRoots)ft(e,{dir:wt(r,i),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:_d(e.home)});for(let i of n.dirs)ft(e,{dir:wt(r,i.dir),kind:i.kind,origin:o,enabled:!0,extensions:i.extensions});for(let i of n.memory){let a=Pf(i.map(c=>wt(r,c)));a&&Pt(e,{absolutePath:a,kind:"MEMORY",origin:o,enabled:!0,name:MC(a)})}for(let i of Va(n))Bs(e,wt(r,i),o,{kind:"SETTINGS",profile:cd(i)});for(let i of n.mcpJson??[])Xf(e,wt(r,i),o);for(let i of n.mcpToml??[])qf(e,wt(r,i),o);if(s){if(n.managed){for(let i of Yn(n.managed,process.platform,e.home))if(i.toLowerCase().endsWith(".json")){let a=ud(n.managed,i);Bs(e,i,o,{kind:"MANAGED_SETTINGS",...a})}}n.plugins==="claude"?(Qf(e),Sd(e),hd(e)):n.plugins==="cursor"&&ed(e)}}function Ed(e,t){try{let n=new br(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)vC(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 Gs(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let c=Ed(t,{layouts:Object.values(At),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:We,scopeRef:""});c&&(r.user=c)}let s=n.inGitRepo===!0,i=null,a=n.launchCwd;if(a!==void 0){let c=Object.values(Ye),l=as({launchCwd:a,gitRoot:n.gitRoot,inGitRepo:s,remote:n.remote,home:t,hasProjectSpec:u=>Wa(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=Ed(t,{layouts:c,levelDir:u.dir,origin:u.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:cs,scopeRef:d});f&&(r[u.scope]=f)}r.parent||(i=null)}return{scopes:r,parentRel:i,cwdInGitRepo:s}}function Vs(e,t,n={}){let r=n.truncated===!0,o=cn(e),s=new Set(e.map(u=>Ee(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=Ee(u.path,u.name);c[d]!==Sr(u)&&a.push(u)}let l=[];if(!r){for(let u of Object.keys(c))if(!s.has(u)){let d=Xu(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 Rd=2*1024*1024,LC=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function zs(e,t,n){let r=new Set(t.map(s=>Ee(s.path,s.name))),o=[];for(let s of e)s.text!==void 0&&(n.has(s.content_hash)||r.has(Ee(s.path,s.name))||o.push(s));return o}function Ws(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 yd(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Cd(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function Js(e,t=Rd){let n=[],r=[];for(let u of e)LC.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=yd(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=Cd(u),g=yd(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 Ys(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:Cd(n))}var HC=["user","cwd","repo","parent"];function Xs(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,s=[];for(let T of HC){let x=t.scopes[T];if(!x)continue;let B=n(T,x.scopeRef),D=B.components,O=Vs(x.components,D,{forceFull:D===void 0,truncated:x.truncated}),w=new Set(B.textHashes),H=zs(x.components,O.upserts,w),m=Ys([...O.upserts,...H],w);s.push({scope:T,walk:x,delta:O,outgoing:m,outgoingKeys:new Set(m.map(b=>Ee(b.path,b.name))),deliveredTextHashes:w,cachedComponents:D})}let i=s.flatMap(T=>T.outgoing),a=Js(i,o),c=new Set(a.components.map(T=>Ee(T.path,T.name))),l=[],u=[],d=[],f=[],p=[],g=[],S=[];for(let T of s){let{scope:x,walk:B,delta:D}=T;g.push(...B.components),l.push(x);let O=a.components.filter(b=>T.outgoingKeys.has(Ee(b.path,b.name))),w=[...T.outgoingKeys].some(b=>!c.has(b)),H=D.truncated||w;H?d.push(x):D.full&&u.push(x),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[Ee(b.path,b.name)];for(let b of O)m[Ee(b.path,b.name)]=Sr(b);S.push({scope:x,scopeRef:B.scopeRef,components:m,textHashes:Ws(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:cn(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 k=t.scopes.repo;k&&(C.user_spec_repo_scope_ref=k.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 Fr={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function qs(e){return e==="cwd"||e==="repo"||e==="parent"}function Rn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Zs(e){return!Rn(e)||!Rn(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 Ad(e){return UC(e)}function bd(e){return DC(e)}function Od(e){return FC(e)}function UC(e){if(!Rn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function DC(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function xd(e,t){if(!Rn(e))return;let n=e[t];return Zs(n)?n:void 0}function FC(e){if(!Rn(e))return{};let t={};for(let[n,r]of Object.entries(e))Zs(r)&&(t[n]=r);return t}function Qs(e,t=20){let n=[];for(let[r,o]of Object.entries(e))Zs(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 GC=["allow","deny","ask"];function jr(e){let t=X(e,{}),n=[];for(let r of GC)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:Hr(o),mode:r});return{model:t.model??"",permissionKeys:n}}function VC(e){let{serverManaged:t,fileBased:n}=Jt(process.platform,e),r=jr(t);if(r.model||r.permissionKeys.length>0)return r;let o="",s=[];for(let i of n){let a=jr(i);a.model&&(o=a.model),s.push(...a.permissionKeys)}return{model:o,permissionKeys:s}}function zC(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 WC=10,JC="self-config-cache.json",kd=5;function vt(){return v("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function YC(){return v("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}var XC={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function qC(e,t=te){let n=XC[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(`
|
|
43
|
-
`)
|
|
44
|
-
`);return q(n)}function $r(e,t,n=!1){let r=QC(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 ei(e,t,n=[]){let r=0,o=!1,s=new Set;for(let i of[...t.map(a=>Mt(e,a)),...n]){let a=BC(i);if(s.has(a))continue;s.add(a);let c=to(i);c.present&&(o=!0,r+=c.size)}return o?{present:!0,size:r}:{present:!1,size:0}}function eA(e){return jC(e)?he(KC(e,"utf8"),{}):{}}function tA(e,t){try{ae(e,`${JSON.stringify(t)}
|
|
45
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);I(`WARN: self-config cache write failed open: ${r}`)}}function nA(e,t,n){if(t==="user")return{components:Ad(e.user_spec_components),textHashes:bd(e.user_spec_text_hashes)};if(!qs(t))return{components:void 0,textHashes:[]};let r=xd(e[Fr[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}function rA(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=kd,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(!qs(s.scope))continue;let i=Fr[s.scope],a=Od(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]=Qs(a)}}return o}async function Td(e,t=process.cwd(),n=Id(),r={}){let o=e==="claude",s=r.gitRoot??t,i=await qC(e),a="",c=[];if(o){let H=VC(n),m=jr(Mt(n,".claude/settings.json")),b=jr(Mt(t,".claude/settings.local.json"));a=H.model||b.model||m.model,c=zC([...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(Mt(n,U));if(m=m.concat(fe.entries),b=b||fe.truncated,m.length>=We){m=m.slice(0,We),b=!0;break}}return{entries:m,truncated:b}},d=ZC(n),f=eA(d),p=f[e]??{},g=(p.send_count??0)+1,S=g>0&&g%WC===0,C=H=>S?void 0:p[H],A=u(qe.skills),k=u(qe.subagents),P=u(qe.commands),T=u(qe.rules),x={skills:$r(A.entries,C("skills"),A.truncated),subagents:$r(k.entries,C("subagents"),k.truncated),commands:$r(P.entries,C("commands"),P.truncated),rules:$r(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:x.skills,subagents:x.subagents,commands:x.commands,rules:x.rules,memory:ei(n,qe.memory),settings:ei(n,qe.settings,Ja(n)),mcp:ei(n,qe.mcp)},local_settings:o?to(Mt(t,".claude/settings.local.json")):l},D=null,O=r.nowMs??Date.now();if(!vt()){let H=p.user_spec_layout_version!==kd,m=Gs(e,n,{launchCwd:YC()?void 0:r.launchCwd,gitRoot:s,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(m.scopes).length>0){let b=Xs({collected:m,cacheFor:(U,fe)=>H?{components:void 0,textHashes:[]}:nA(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=rA(p,x,g,D);return{config:B,commit:()=>{f[e]=w,tA(d,f)}}}import{homedir as AA}from"node:os";import{join as wd}from"node:path";function pt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{join as Kr}from"node:path";function oA(e){return Kr(e,".ev-ai","agent-hook","js","signed-v1")}function sA(e){return Kr(oA(e),"scopes")}function Pd(e,t){return Kr(sA(e),t)}function Nd(e){return Kr(e,"attempts")}function ti(e){return String(e).padStart(10,"0")}var iA=/^(\d{10})$/,aA=/^(\d{10})\.done$/,cA=/^[0-9a-f]{128}$/,uA=64,Hd=["check_ms","download_ms","install_ms","total_ms"],lA=36e5;async function Ud(e,t,n=!1){let r=Nd(t),o=await zi(e,r),s=new Map,i=new Map,a=Md(o,iA),c=Md(o,aA),l=async f=>{let p=await Ld(e,wd(r,fA(f)));return p&&s.set(f,{record:pA(p.value),mtimeMs:p.mtimeMs}),p!==void 0},u=async f=>{let p=mA((await Ld(e,wd(r,dA(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([vd(a,l),vd(c,u)]);let d=Cn(s);return d<Cn(i)&&c.includes(d)&&await u(d),{claims:s,dones:i}}function Md(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}async function vd(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}function Cn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}function Dd(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 Fd(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of Hd){let r=e[n];r!==void 0&&(t[n]=r)}return t}function fA(e){return ti(e)}function dA(e){return`${ti(e)}.done`}async function Ld(e,t){let n;try{n=await e.stat(t)}catch(o){if(ht(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>oo)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>oo?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}function pA(e){if(!pt(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 mA(e){if(!pt(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=_A(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...gA(t)}}function gA(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 Hd){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=lA&&(t[n]=r)}return t}function _A(e){if(!pt(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"&&cA.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&hA(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}function hA(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==uA||t.toString("base64")!==e))return t.toString("hex")}function RA(e){return e==="bootstrap"?3e3:6e4}function CA(e,t){let n=Cn(e.claims);if(n===0)return;let r=Cn(e.dones),o=e.claims.get(n),s=e.dones.get(n);if(o&&!s){let a=Dd(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:$d(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:$d(i.selection),...Fd(i)}}async function jd(e,t,n){try{let r=await Ud(Wi(),Pd(e,t),!0);return CA(r,n)}catch{return}}function $d(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}function bA(e=process.env){if(Object.values(ya).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===Rt?"npx":null}async function Kd(e=AA()){let t=Do()?.launcherScope;if(!t)return{};let n=await jd(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}function Lt(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:Vn,event:e,timestamp:Nn(),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:bA(),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=lu(n.collectorUrl,s.launcherScope)),e==="session_start"&&(n.launcher_scope&&(o.launcher_scope=n.launcher_scope),n.launcher_attempt&&(o.launcher_attempt=n.launcher_attempt)),o}import{existsSync as Wd}from"node:fs";import{spawn as Jd}from"node:child_process";import{fileURLToPath as HA}from"node:url";import{gzipSync as OA}from"node:zlib";function ni(e){return v("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<Ea?{body:e}:{body:OA(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}function Br(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}function ri(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}import{readFileSync as xA,statSync as IA}from"node:fs";import{homedir as oi}from"node:os";import{join as kA}from"node:path";var TA="hook-config.json",PA=1440*60*1e3,NA=2048,wA=1024*1024;function Ht(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Bd(e=oi()){return kA(me(e),TA)}function Gd(e){let t=Bd(e);try{let n=IA(t);if(!n.isFile()||n.size>wA)return;let r=JSON.parse(xA(t,"utf8"));return Ht(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}function MA(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 Vd(e,t=oi()){if(!e)return;let n=Wt(e);if(!n)return;let r=Gd(t),o=r?r[n]:void 0;if(!(!Ht(o)||!Ht(o.config)))return MA(o.config)}function vA(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!Ht(n)||!Ht(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>NA))return n.hook_config}function LA(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(!(Ht(s)&&JSON.stringify(s.config)===JSON.stringify(n)&&typeof s.fetched_at_ms=="number"&&s.fetched_at_ms<=r&&r-s.fetched_at_ms<PA))return o[t]={config:n,fetched_at_ms:r},o}function zd(e,t,n=oi(),r=Date.now()){let o=vA(e),s=t?Wt(t):void 0;if(o===void 0||!s)return"skipped";try{let i=Gd(n);if(i===void 0)return"skipped";let a=LA(i??{},s,o,r);return a?(ae(Bd(n),`${JSON.stringify(a,null,2)}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`,g=v("EV_AI_HOOK_DEBUG");g==="full"?I(`DEBUG envelope=${f}`):g==="1"&&I(`DEBUG summary=${DA(u,ri(p))}`);let S=process.argv.includes(An),C=v("EV_AI_HOOK_SYNC")==="1";return ir(n.runnerEvent,n.runnerPlatform)||S||C?KA(e,p,o):(await BA(e,p,o),!1)}import{createReadStream as GA}from"node:fs";import{stat as VA}from"node:fs/promises";import{basename as zA,resolve as WA}from"node:path";import{createInterface as JA}from"node:readline";var YA=1024*1024;function XA(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&zA(t).endsWith(".jsonl")}async function np(e){if(!e||!XA(e))return null;try{let t=WA(e),n=await VA(t);if(!n.isFile())return null;let r=Math.max(0,n.size-YA),o=[],s=JA({input:GA(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 qA="EV_AI_HOOK_TELEMETRY";function rp(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}function op(e,t,n=process.env){let r=n[qA]?.trim().toLowerCase();return r&&jt.has(r)?{enabled:!0,source:"env"}:r&&Oi.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 Gr(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:yr(e.manifest.manifest,e.manifest.hookConfig),telemetry:ap(e)}}function ap(e){return op(e.manifest.localTelemetry,e.manifest.hookConfig)}function On(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}function ai(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:os(e.manifest.hookConfig)}}async function cp(e){let t=Date.now();await ub(e);let{gitRoot:n}=e.manifest;await ui(e,n);let r=ai(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:Cr(e.hookInput,e.manifest.manifest,r),envelopeFields:Gr(e),launchCwd:ss(e.hookInput,r),home:QA()}}function sp(e){try{return Se(ZA(e))}catch{return null}}function up(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function ip(e,t){let n=e.replaceAll("\\","/");if(!up(n))return null;let r=Se(e),o=Se(t),s=sp(e)??r,i=sp(t)??o;return s.startsWith(`${i}/`)?s.slice(i.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}function lp(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),s=ip(e,t)??(up(r)?null:r),i=ip(e,n);return{repositorySourcePath:s,userSourcePath:i}}function ii(e,t,n,r,o){return fp(e,lp(n,t.gitRoot,t.home),r,o)}function fp(e,{repositorySourcePath:t,userSourcePath:n},r,o){let s=t??n,i=s===null?null:o(s),a=i!==null&&s!==null?eb({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 eb(e){try{let t=e.inRepository?rb(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 dp(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 ci(e,t,n){return Ut("tool_invoked",{...n,...dp(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,Lt,e.manifest.collectorUrl,t.buildStartedAtMs,On(e,t.home))}function tb(e){return Hc(e.runnerEvent,e.runnerPlatform)?[]:tc(e.hookInput)}function nb(e,t){return ci(e,t,{})}var pp=new Set([...Object.values(at),".github"]);function rb(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=>pp.has(i));return s<0?null:`${r}:${o.slice(0,s+1).join("/")}`}var mp=".codex/config.toml",ob=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",mp]]);function sb(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?ob.get(c.source):o==="codex"?mp: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||!pp.has(g)))try{return(0,K.buildComponentReference)({installationRootExternalKey:n,installableKind:K.ComponentKind.INTERFACE,sourcePath:p,nativeKey:t})}catch{return}}function ib(...e){for(let t of e)if(t)return t;return null}function gt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return I(`WARN: ${n} failed open: ${r}`),t}function ab(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 cb(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var mt=new Set,bn=null;async function ub(e){if(vt())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(mt.has(t))return;if(!Zo(n)){mt.add(t);return}let r=Kt({sessionId:e.sessionId,hostname:vn()});if(Zu(r)){if(bn){await bn;return}bn=(async()=>{if(mt.has(t)||!Zo(n)){mt.add(t);return}if(!Ha(n)){mt.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:i}=e.manifest,a=String(e.runnerPlatform),{operatorResolved:c,fields:l}=await gp(e,r,Pe("git",()=>or(i)),Pe("operator",()=>qo({gitRoot:i,installationStorePath:n,forceResend:!1,runnerPlatform:a}))),u={...l,self_config:cb(a,c.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await Ut("session_start",u,Gr(e),Lt,e.manifest.collectorUrl,s,On(e)),o&&(c.commit(),mt.add(t))}finally{Ua(n)}})().finally(()=>{bn=null}),await bn}}async function ui(e,t,n){try{e.platformAgentId=await xc(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,n,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);I(`WARN: derivePlatformAgentId failed open: ${o}`)}}async function gp(e,t,n,r){let[o,s,i,a,c]=await Promise.allSettled([n,Pe("virt",()=>Mi()),Pe("cloud",()=>bu(t)),Pe("host_env",()=>Li(ap(e).enabled)),r]),l=gt(o,null,"gitSnapshot"),u=gt(s,"","detectVirt"),d=gt(i,null,"probeCloud"),f=gt(a,{},"hostEnv"),p=gt(c,{commit:()=>{}},"resolveOperatorForSend");return await ui(e,e.manifest.gitRoot,l),{operatorResolved:p,fields:{identity:{host:vn(),context:t,virt:u||null,cloud:d,git:l},host_env:f,env_vars:Nu()}}}async function lb(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=Kt({sessionId:e.sessionId,hostname:vn()}),o=String(e.runnerPlatform),s=ai(e),i=ss(e.hookInput,s),a=Pe("git",()=>or(n)),c=Kd().catch(()=>({})),l=vt()?Promise.resolve({commit:()=>{}}):Pe("operator",()=>qo({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o})),u=gp(e,r,a,l),[d,f]=await Promise.allSettled([Pe("mcp_declared",()=>Vo(e.manifest.manifest,n,o)),a.catch(()=>null).then(B=>Pe("self_config",()=>Td(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=gt(d,[],"mcpDeclared"),C=gt(f,ab(o),"selfConfig"),A=C.config,k=L(e.hookInput,"model");k&&(A.model=k);let P={...g,mcp:{declared:S},self_config:A,run_meta:{trigger:e.hookSource||"startup"},hook_input:Cr(e.hookInput,e.manifest.manifest,{...s,launchCwd:i})},T=await c;await Ut("session_start",P,{...Gr(e),...T},Lt,e.manifest.collectorUrl,t,On(e))&&(C.commit(),p.commit(),mt.add(e.manifest.installationId))}async function fb(e){let t=Date.now(),[,n]=await Promise.all([ui(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?np(L(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=ib(L(e.hookInput,"status"),L(e.hookInput,"stop_reason"),L(e.hookInput,"reason"),tn(L(e.hookInput,"error")),r==="stop"?Ue(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),s=Cr(e.hookInput,e.manifest.manifest,ai(e));n&&(s.model=n),r!=="stopfailure"&&yr(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&s.last_assistant_message===void 0&&(s.last_assistant_message=""),await Ut("session_end",{status:o,...n?{model:n}:{},hook_input:s},Gr(e),Lt,e.manifest.collectorUrl,t,On(e))}async function db(e){let t=tb(e),n=Pc(e.hookInput),r=Lc(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&yr(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let s=await cp(e);await Promise.all([o?nb(e,s):void 0,t.length===0?void 0:pb(e,s,t),n.length===0?void 0:mb(e,s,n)])}function _p(e,t,n,r){let o=r??ec({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),s=ii(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??Nc({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),a=ii(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 pb(e,t,n){let r=qn(e.hookInput.tool_input);return Promise.all(n.map(o=>{let s=_p(e,t,o,r);return ci(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 mb(e,t,n){return Promise.all(n.map(r=>{let o=Ic({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),s=ii(e,t,o,K.ComponentKind.RULE,K.nativeKeyForRulePath),i=s.nativeKey??Tc(r);return ci(e,t,{tool_name:"Rule",rule_name:i,...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}var gb=[{kind:K.ComponentKind.SKILL,nativeKeyFn:K.nativeKeyForSkillPath},{kind:K.ComponentKind.RULE,nativeKeyFn:K.nativeKeyForRulePath},{kind:K.ComponentKind.COMMAND,nativeKeyFn:K.nativeKeyForCommandPath}];function _b(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?{}:_p(e,t,n.skillName,null);let o=lp(r,t.gitRoot,t.home);for(let s of gb){let i=fp(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 hb=/mcp/i;function Sb(e,t,n,r){let o=hb.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let s=o?Jf(t,n):Lr(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 Eb(e){let t=await cp(e),n=Fc(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,s=Eo(e.hookInput),i=zf(s,t.home),a=jc(e.hookInput),c=Uc(e.runnerEvent),l=c===!1?Kc(e.hookInput,e.runnerEvent):null,u=tn(L(e.hookInput,"mcp_server_name")),d=u!==null||r!==null&&ar(r)?await Vo(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(()=>[]):[],{mcpServer:f,mcpTool:p}=Gc(r,d.map(B=>B.name),u??""),g=sb(r,f,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),d,u),S=g===void 0?_b(e,t,n):{},C=f===null?null:Pu(f,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),A=Sb(e,s,t.home,{hasMcpIdentity:!!f||!!p,declaredConfig:C}),k=g??S.componentReference,P=S.ruleName??n.ruleName,T=S.commandName??n.commandName,x=$c(e.hookInput);await Ut("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,...k?{component_reference:k}:{},...x?{subagent_type:x}:{},...dp(e),hook_input:t.hookInput},t.envelopeFields,Lt,e.manifest.collectorUrl,t.buildStartedAtMs,On(e,t.home))}async function hp(e){switch($e("w3"),e.internalEvent){case"session_start":await lb(e);return;case"session_end":await fb(e);return;case"skill_invoked":await db(e);return;case"tool_invoked":await Eb(e);return;default:return}}import{existsSync as fi,readFileSync as yb}from"node:fs";import{dirname as Rb,isAbsolute as Cb,join as Ab,relative as bb}from"node:path";function Sp(e){for(let t of ca){let n=Ab(e,t);if(fi(n))return n}}async function Ob(e=process.cwd(),t){let n=t??await eo(e);return Sp(n)??Sp(e)}async function xb(e,t){let n=t??await eo(Rb(e)),r=bb(n,e);if(r.startsWith("..")||Cb(r))return!1;let o=await Re("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(I(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}function li(e){let t=yb(e,"utf8");return he(Mn(t),{})}function Ib(){return{schema_version:Vn,mcp_servers:[]}}function kb(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(I(`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")&&(I(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}function Tb(e){let t=pa({argv:e.argv,env:process.env,homeConfig:e.homeConfig,manifest:e.manifest,manifestSource:e.manifestSource});for(let r of t.warnings)I(`WARN: ignoring ${r.label}: ${r.problem}`),ge.error(`collector ${r.label} ignored: ${r.problem}`);let n=t.url??"";return ge.info(`collector source=${t.source} url=${n?yt(n):"(none)"}`),n}function Pb(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}async function Ep(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await Qr(e),o=v("EV_AI_HOOK_MANIFEST"),s=o&&fi(o)?o:void 0,i=s?void 0:fi(rt())?rt():void 0,a=s?void 0:await Ob(e,n),c=i?li(i):void 0,l=a?li(a):void 0,u=rp(s?X(rt(),{}):c),d,f,p,g=new Set;if(s){d=li(s),f=s,p=s;for(let x of Object.keys(d))g.add(x)}else if(c&&l){d=la(l,c),f=i,p=a;for(let x of Object.keys(l))x in c||g.add(x)}else if(c)d=c,f=i;else if(l){d=l,f=a,p=a;for(let x of Object.keys(l))g.add(x)}else d=Ib();delete d.installation_id;let S=p?await xb(p,n):!1;kb(d,p,S,g);let{installationId:C,storePath:A,repoKey:k}=await ja(n,{sessionId:t.sessionId}),P=c??Pb(X(rt(),null)),T=Tb({argv:t.argv??process.argv,homeConfig:P,manifest:s?d:l,manifestSource:s?"manifest_override":"manifest"});return{manifestPath:f??A,manifest:d,installationId:C,installationStorePath:A,repoKey:k,collectorUrl:T,hookConfig:Vd(T),...u!==void 0?{localTelemetry:u}:{},platformAgentId:d.platform_agent_id??"",gitRoot:n,inGitRepo:r}}import{mkdirSync as Nb,readdirSync as wb,readFileSync as Mb,statSync as yp,unlinkSync as vb,writeFileSync as Lb}from"node:fs";import{homedir as Vr}from"node:os";import{join as di}from"node:path";var Hb="turns",Rp=1440*60*1e3,Ub=100,Db=new Set(["stop","stopfailure","sessionend"]);function pi(e=Vr()){return di(me(e),Hb)}function Cp(e,t){return di(e,$t(t))}function Fb(e,t=Date.now()){let n;try{n=wb(e)}catch{return}let r=0;for(let o of n){if(r>=Ub)return;r+=1;try{let s=di(e,o);t-yp(s).mtimeMs>Rp&&vb(s)}catch{}}}function $b(e,t,n=Vr()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let s=pi(n);Nb(s,{recursive:!0}),Lb(Cp(s,r),o,"utf8")}catch{}}function jb(e,t=Vr()){let n=e.trim();if(!n)return"";try{let r=Cp(pi(t),n);return Date.now()-yp(r).mtimeMs>Rp?"":Mb(r,"utf8").trim()}catch{return""}}function Ap(e,t,n,r=Vr()){let o=t.trim(),s=Db.has(n.trim().toLowerCase());return s&&Fb(pi(r)),o?($b(e,o,r),o):s?jb(e,r):""}async function Kb(e,t,n){let r=t??await wn(zn),o=he(r,{}),s=await Ep(process.cwd(),{sessionId:en(o)});if($e("w2"),!s)return;let i=Dc(o,s.manifest.platform,n),a=Po(e,i.runnerEvent);if(!a){I(`WARN: unknown hook event '${i.runnerEvent}'; skipping telemetry`);return}let c={hookInput:o,sessionId:i.sessionId,turnId:Ap(i.sessionId,i.turnId,i.runnerEvent),runnerEvent:i.runnerEvent,runnerPlatform:i.runnerPlatform,hookSource:i.hookSource,internalEvent:a,manifest:s,platformAgentId:s.platformAgentId};await hp(c)}function Bb(e,t=!1){if(v("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,s=Qt(r,o,void 0,n.runner);return ir(o,s)?!0:t}function bp(e,t){let n=Kn(e),r=he(t,{}),o=n.event??To(r);return Ni()||vc(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}function xp(e){return nu(Po(e.parsed.event,e.runnerEvent))}async function Op(e,t,n){let{parsed:r}=e,o=n??Ho(r.slot);if(!o&&!xp(e)){let s=Lo(r.cap),i=cu(s);if(!i){Uo(s);return}o=i}try{await Kb(r.event,t,r.runner)}finally{o&&lr(o)}}async function zr(e=process.argv.slice(2)){if(nl(e),mu(),$e(e[0]===An?"w0":"h0"),uu(),v("EV_AI_HOOK_JUDGE")==="1"){try{await wn(zn)}catch{}return qr(),0}if(e[0]===si){try{await Qd(Zr)}catch{}return 0}if(e[0]===An){try{let n=await Zr();$e("w1");let r=bp(e.slice(1),n);if(!r)return 0;await Op(r,n)}catch(n){let r=n instanceof Error?n.message:String(n);I(`WARN: detached work failed open: ${r}`)}return 0}let t;try{let n=await wn(zn);$e("h1");let r=bp(e,n);if(!r)return 0;let{parsed:o,hookInput:s,runnerEvent:i}=r;if(t=Ho(o.slot),!Yc(s,i,o.runner))return 0;if($e("h2"),Bb(r))await Op(r,n,t);else{let a=t||xp(r)?void 0:Lo(o.cap);if(a===void 0||iu(a)){$e("h3"),yu();let c=await tp(n,e);t&&c?.pid!==void 0&&ou(t,c.pid)}else Uo(a)}}catch(n){let r=n instanceof Error?n.message:String(n);I(`WARN: hook failed open: ${r}`)}finally{t&&lr(t),qr()}return 0}var Gb=Symbol.for(Ki);function Ip(){return globalThis[Gb]===!0}async function Vb(e){Xr(e);try{return await zr(e.argv)}finally{Xr(void 0)}}Ip()||zr().then(e=>{process.exit(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);process.stderr.write(`[ev-ai-agent-hook] ${t}
|
|
50
|
-
|
|
35
|
+
`.trim(),xs=new Map;function Hl(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(Hl,"asText");function Fl(e){return e.toLowerCase().includes("token")}s(Fl,"isTokenKey");function $l(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=Hl(r.key),i=Hl(r.value);o&&i&&!Fl(o)&&t.set(o,i)}return t}s($l,"rowsToMap");function $y(e){let t=Fy(e);return t.search="mode=ro&immutable=1",t.href}s($y,"sqliteReadonlyUri");function By(e){try{let t=Dl("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(Hr)??n.prepare(Hr);return $l(r.all?.())}finally{n.close?.()}}catch{return null}}s(By,"readViaBunSqlite");function jy(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(jy,"withSqliteExperimentalWarningSuppressed");function Ky(e){try{return jy(()=>{let t=Dl("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return $l(n.prepare(Hr).all?.())}finally{n.close?.()}})}catch{return null}}s(Ky,"readViaNodeSqlite");function Gy(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&&!Fl(i)&&t.set(i,a)}return t}s(Gy,"parseCliTable");function Vy(e){try{let t=Uy("sqlite3",["-noheader","-batch","-separator"," ",e,Hr],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return Gy(t)}catch{return null}}s(Vy,"readViaSqliteCli");function Bl(e){let t=xs.get(e);if(t)return t;if(!Hy(e)){let o=new Map;return xs.set(e,o),o}let n=$y(e),r=By(n)??Vy(n)??Ky(n)??new Map;return xs.set(e,r),r}s(Bl,"readCursorAuthItems");var zy="cursorAuth/cachedEmail",Wy="cursorAuth/stripeMembershipAuthId";function Dr(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(Dr,"trimEnv");function Jy(e=Fr(),t=process.platform,n=process.env){let r=Dr(n.VSCODE_PORTABLE);if(r)return We(r,"user-data");let o=Dr(n.VSCODE_APPDATA);if(o)return We(o,"Cursor");switch(t){case"darwin":return We(e,"Library","Application Support","Cursor");case"win32":return We(Dr(n.APPDATA)??We(e,"AppData","Roaming"),"Cursor");default:return We(Dr(n.XDG_CONFIG_HOME)??We(e,".config"),"Cursor")}}s(Jy,"cursorUserDataDir");function Yy(e=Fr()){return We(e,".cursor","cli-config.json")}s(Yy,"cursorCliConfigPath");function Xy(e=Fr(),t=process.platform,n=process.env){return We(Jy(e,t,n),"User","globalStorage","state.vscdb")}s(Xy,"cursorIdeStateDbPath");function In(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(In,"trimString");function qy(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):In(e.userId)}s(qy,"numericUserId");function Zy(e){return In(e.email)??In(e.authId)??qy(e)}s(Zy,"platformLogin");function Os(e){let t=In(e.email),n=In(e.displayName),r=Zy(e);return!r||le(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}s(Os,"identityFromAuth");function Qy(e){let n=q(Yy(e),{}).authInfo;return!n||typeof n!="object"?null:Os(n)}s(Qy,"readCliOperatorIdentity");function eR(e,t,n){let r=Xy(e,process.platform,t),o=Ll(e),i=vl(o);if(Ml(i,r,n))return Os({email:i?.email,authId:i?.auth_id});let a=Bl(r),c=a.get(zy)??null,u=a.get(Wy)??null;return Ul(o,{read_at_ms:n,db_path:r,email:c,auth_id:u}),Os({email:c,authId:u})}s(eR,"readIdeOperatorIdentity");function jl(e=Fr(),t=process.env,n=Date.now()){return Qy(e)??eR(e,t,n)}s(jl,"readCursorOperatorIdentity");import{createHash as tR}from"node:crypto";import{resolve as nR}from"node:path";function ee(e){return tR("sha256").update(e).digest("hex").slice(0,16)}s(ee,"sha16");function Is(e){return ee(nR(e))}s(Is,"dirScopeRef");function Ce(e,t){return`${e}\0${t}`}s(Ce,"componentKey");function $r(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}s($r,"componentDeltaHash");function Kl(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}s(Kl,"parseComponentKey");function kn(e){let n=[...e].sort((r,o)=>{let i=r.path.localeCompare(o.path);return i!==0?i:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
|
|
37
|
+
`);return ee(n)}s(kn,"hashUserSpec");function oR(e,t,n="git_config",r=null){return ee(`${e??""}|${t??""}|${r??""}|${n}`)}s(oR,"hashOperatorIdentity");function sR(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(sR,"parseGitUserConfig");async function iR(e,t=oe){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return sR(n)}s(iR,"readGitOperatorIdentity");function aR(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(aR,"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 cR(e=process.env,t){let n=G(e.EV_AI_HOOK_OPERATOR_EMAIL),r=G(e.EV_AI_HOOK_OPERATOR_LOGIN),o=Je(G(e.EV_AI_HOOK_OPERATOR_NAME),n,"configured",n??r);if(o)return o;let i=G(e.GITHUB_ACTOR)??G(e.GITHUB_TRIGGERING_ACTOR)??G(e.GITHUB_USER),a=Je(i,null,"github",i);if(a)return a;let c=G(e.GITLAB_USER_LOGIN),u=G(e.GITLAB_USER_EMAIL),f=Je(G(e.GITLAB_USER_NAME)??c,u,"gitlab",u??c);if(f)return f;let l=G(e.BUILD_REQUESTEDFOREMAIL),p=Je(G(e.BUILD_REQUESTEDFOR),l,"azure_devops",l??G(e.BUILD_REQUESTEDFORID));if(p)return p;let d=G(e.BUILDKITE_BUILD_CREATOR_EMAIL),m=Je(G(e.BUILDKITE_BUILD_CREATOR),d,"buildkite",d);if(m)return m;let g=G(e.BUILD_USER_EMAIL)??G(e.CHANGE_AUTHOR_EMAIL),h=Je(G(e.BUILD_USER)??G(e.CHANGE_AUTHOR),g,"jenkins",g??G(e.BUILD_USER_ID));if(h)return h;let y=G(e.CIRCLE_USERNAME),b=Je(y,null,"circleci",y);if(b)return b;let T=G(e.CODEBUILD_INITIATOR),N=Je(T,null,"codebuild",T);if(N)return N;let O=G(e.DRONE_COMMIT_AUTHOR_EMAIL),x=G(e.DRONE_COMMIT_AUTHOR),v=Je(x??G(e.DRONE_COMMIT_AUTHOR_NAME),O,"drone",O??x);if(v)return v;if(Gl(e.CLAUDE_CODE_REMOTE)||Gl(e.CURSOR_AGENT)||t!==void 0&&uR.has(t)){let L=G(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:L&&!le(null,L)?L:null,identity_source:"cloud"}}return null}s(cR,"readCloudOperatorIdentity");var uR=new Set(["cursor_cloud","claude_remote"]);function ks(e){return!!((e.git_user_name??e.git_user_email)&&!le(e.git_user_name,e.git_user_email))}s(ks,"isHumanOperator");function G(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(G,"trimEnv");function Gl(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(Gl,"isTruthyEnv");function lR(e,t,n){return e==="claude"?ec(t):e==="cursor"?jl(t,n):e==="codex"?Nl(n,t):null}s(lR,"readRunnerOperatorIdentity");async function Ts(e,t=oe,n=process.env,r={}){let o=await iR(e,t),i=aR(n),a=ks(o)?o:i&&ks(i)?i:null,c=lR(r.runnerPlatform,r.home??rR(),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=cR(n,r.context);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:ks(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(Ts,"resolveOperatorIdentity");async function Ps(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??oe,i=e.env??process.env,a=await Ts(t,o,i,{runnerPlatform:e.runnerPlatform,home:e.home,context:e.context}),c=oR(a.git_user_name,a.git_user_email,a.identity_source,a.platform_login),f=(n?Zo(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&&Hc(m,c,Xn())},"commit")}}s(Ps,"resolveOperatorForSend");function Ns(e){return e?!Zo(e)?.operator_identity_hash:!0}s(Ns,"operatorIdentityNeverSent");var fR=new Set(["claude","codex"]);function Vl(e,t){return!(t!==void 0&&fR.has(t))}s(Vl,"shouldBootstrapCloudIdentity");import{existsSync as Ib,readFileSync as kb}from"node:fs";import{homedir as _p}from"node:os";import{join as Qt,resolve as Tb}from"node:path";import{basename as Eb,join as Zt}from"node:path";import{dirname as tf,resolve as Gr}from"node:path";import{existsSync as dR}from"node:fs";import{homedir as Jl}from"node:os";import{relative as Yl,resolve as Ue,sep as ut}from"node:path";var pR=["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"],mR=["prompt","tool_input","tool_response","last_assistant_message","command"],gR=new Set;function _R(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return gR}}s(_R,"excludedContentKeys");function Us(e){let t=H("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?ft.has(t.toLowerCase()):e?.collect_prompt===!0}s(Us,"isPromptCaptureEnabled");function Br(e,t){let n=Xl(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=H("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?ft.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}s(Br,"promptCaptureSource");function Xl(e){return H("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||zo(process.argv,e.debug===!0)||H("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}s(Xl,"hookInputCaptureMode");function hR(e){let t={};for(let n of pR){let r=je(e,n);r!==void 0&&(t[n]=r)}return t}s(hR,"allowlistedHookInput");function jr(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Ue(e),r=Ue(t),o=Yl(r,n);return!o||o==="."?".":o.startsWith(`..${ut}`)||o===".."||Ue(r,o)!==n?null:o.split(ut).join("/")}s(jr,"cwdRelativeToGitRoot");function ql(e,t){let n=Yl(Ue(t),Ue(e)).split(ut).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}s(ql,"specDirRelativeToCwd");function Zl(e){return typeof e!="string"||e.length===0?null:Ue(e).split(ut).join("/")}s(Zl,"absoluteCwdForSend");function SR(){let e=H("CURSOR_PROJECT_DIR");if(!e)return null;let t=Ue(e);return dR(t)?t.split(ut).join("/"):null}s(SR,"cursorProjectDirAbs");function Ls(e,t){return jr(e,t)!==null}s(Ls,"isPathInside");function ER(e,t){let n=Ue(t??Jl(),".cursor").split(ut).join("/");return Ls(e,n)}s(ER,"isCursorUserHookLaunch");function yR(e,t,n){return t!==null&&Ls(e,t)?!0:t!==null&&ER(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&Ls(e,n.gitRoot)?!0:t===null}s(yR,"shouldKeepProcessCwd");function Ql(e,t){let n=Zl(e.cwd);if(n!==null)return n;let r=Ue(process.cwd()).split(ut).join("/"),o=SR();return yR(r,o,t)?r:o??r}s(Ql,"resolvedCwdForSend");function Hs(e,t={}){return Ql(e,t)}s(Hs,"resolveLaunchCwd");function Ds(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(Ds,"tildeHomeCwd");function zl(e,t,n){let r=Zl(n.launchCwd)??Ql(t,n);e.cwd=Ds(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?jr(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}s(zl,"attachCwdFields");var ef="\u2026[truncated]\u2026",vs=Buffer.byteLength(ef,"utf8"),RR=8;function Tn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Tn,"jsonByteLength");function Wl(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}s(Wl,"utf8Head");function AR(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(AR,"utf8Tail");function CR(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=vs)return Wl(e,t);let r=t-vs,o=Math.ceil(r/2),i=Math.floor(r/2);return`${Wl(e,o)}${ef}${AR(e,i)}`}s(CR,"truncateHeadTail");function Ms(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)=>{Ms(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Ms(o,[...t,r],n)}s(Ms,"collectStrings");function bR(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(bR,"setAtPath");var xR=256;function OR(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(OR,"stringBudgetFor");function IR(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let i=Tn(e);if(i<=t)return;let a=[];Ms(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=OR(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&&bR(e,l.path,CR(l.value,r))}}s(IR,"clampStringsToBudget");function kR(e,t){let n=Math.max(0,t-xR),r=Object.keys(e).filter(i=>!i.startsWith("_")).map(i=>({key:i,bytes:Tn(e[i])})).sort((i,a)=>a.bytes-i.bytes),o=[];for(let{key:i}of r){if(Tn(e)<=n)break;delete e[i],o.push(i)}o.length>0&&(e._dropped_keys=o.slice(0,10))}s(kR,"dropLargestKeys");function ws(e,t){let n=Tn(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,IR(r,t,vs+RR),Tn(r)>t&&kR(r,t),r}s(ws,"fitWithinByteLimit");function TR(e,t,n){if(!(n.promptCapture??Us()))return;let r=_R(n.runnerEvent);for(let o of mR){if(r.has(o))continue;let i=t[o];i!==void 0&&(e[o]=i)}}s(TR,"attachContentFields");function Kr(e,t,n={}){let r=Xl(t);if(r==="full"){let i={...e};return delete i.cwd,delete i.transcript_path,zl(i,e,n),ws(i,Do)}let o=hR(e);return zl(o,e,n),r==="content"?(TR(o,e,n),ws(o,Do)):ws(o,Xa)}s(Kr,"sanitizeHookInput");function PR(e){return typeof e=="string"&&e.length>0}s(PR,"hasOrigin");function Fs(e){let t=Gr(e.home),n=Gr(e.launchCwd),r=e.gitRoot?Gr(e.gitRoot):null,o=new Set,i=[],a=null;e.inGitRepo&&PR(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=tf(r);for(;;){let l=Gr(f);if(l===t)break;let p=tf(l);if(p===l)break;if(e.hasProjectSpec(l)){i.push({scope:"parent",dir:l}),c=ql(l,n);break}f=p}}return{anchors:i,parentRel:c}}s(Fs,"resolveProjectAnchors");import{existsSync as nf,readdirSync as NR,realpathSync as wR}from"node:fs";import{basename as LR,dirname as vR,relative as MR,resolve as UR,sep as HR}from"node:path";var $s=400,Vr=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=UR(t).split(HR).join("/");return Ds(r,this.home)}let n=MR(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${ee(vR(t))}/${LR(t)}`:n}claimFile(t){try{let n=wR(t);return this.seenRealpaths.has(n)?!1:(this.seenRealpaths.add(n),!0)}catch{return this.seenRealpaths.has(t)?!1:(this.seenRealpaths.add(t),!0)}}get atGlobalCap(){return this.truncated||this.components.length>=this.maxEntries}get pluginBudgetSpent(){return this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0}readEntries(t){if(!nf(t))return[];try{return NR(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(nf(t))return q(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),i=t-(this.pluginExpandRemaining??0);return{result:o,expanded:i}}finally{this.pluginExpandRemaining=r}}};import{existsSync as oi,readFileSync as iC,statSync as aC}from"node:fs";import{basename as Sd,join as xt,relative as si}from"node:path";var md=Ze(pd());var oC=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],gd=oC.map(e=>md.default.matcher(e,{dot:!0}));function sC(e){return e===""?!1:gd.some(t=>t(`${e}/`))}s(sC,"isExcludedDirPath");function _d(e,t){if(t==="")return!1;if(e==="")return sC(t);let n=e.replace(/\/+$/,"");return gd.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}s(_d,"isExcludedDirBelow");var ii=100*1024,cC=4;function uC(e){return e.length<=ii?e:`${e.slice(0,ii-1)}\u2026`}s(uC,"truncateContentText");function lC(e){try{let t=iC(e),n=t.toString("utf8");return{hash:ee(t),length:t.length,text:uC(n)}}catch{return null}}s(lC,"readFileMeta");var hd={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function fC(e){return e in hd?hd[e]:"UNSPECIFIED"}s(fC,"triggerForKind");function Xt(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=lC(t.absolutePath);if(!n)return!1;let r=t.name??Sd(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=fC(t.kind);return i&&(o.trigger=i),t.attributes&&(o.attributes=t.attributes),e.push(o)}s(Xt,"addFile");function dC(e,t,n){let r=si(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?Sd(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}s(dC,"nameFromWalkRoot");function Ot(e,t){let{dir:n,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u}=t;ai(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u})}s(Ot,"walkComponentDir");function ai(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l}=t;if(!(o>cC))for(let p of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(p.isDirectory()&&_d(n.replace(/\\/g,"/"),si(n,xt(r,p.name)).replace(/\\/g,"/"))||p.isDirectory()&&l?.includes(xt(r,p.name)))continue;if(u){if(!p.isDirectory())continue;let g=xt(r,p.name,u);if(oi(g)){let h=si(n,xt(r,p.name)).replace(/\\/g,"/");Xt(e,{absolutePath:g,kind:i,origin:a,enabled:c,name:h||p.name});continue}ai(e,{walkRoot:n,currentDir:xt(r,p.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(p.isDirectory()){ai(e,{walkRoot:n,currentDir:xt(r,p.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(!p.isFile()||!f)continue;let d=p.name.toLowerCase();if(!f.some(g=>d.endsWith(g)))continue;let m=xt(r,p.name);Xt(e,{absolutePath:m,kind:i,origin:a,enabled:c,name:dC(n,m,!0)})}}s(ai,"walkRecursive");function Ed(e){for(let t of e)if(oi(t))try{if(aC(t).size>0)return t}catch{continue}return e.find(t=>oi(t))}s(Ed,"firstExistingFile");import{existsSync as jC,readFileSync as KC}from"node:fs";var Zr=Ze(ct(),1);var pC="<omitted>",mC=["package_name","package_spec","package_version","package_version_source"],yd=100,Rd=120,Qr=[{raw:"tools",attr:"tools"},{raw:"autoApprove",attr:"auto_approve"},{raw:"auto_approve",attr:"auto_approve"},{raw:"alwaysAllow",attr:"always_allow"},{raw:"always_allow",attr:"always_allow"},{raw:"enabledTools",attr:"enabled_tools"},{raw:"enabled_tools",attr:"enabled_tools"},{raw:"disabledTools",attr:"disabled_tools"},{raw:"disabled_tools",attr:"disabled_tools"}],Ad=new Set(Qr.map(e=>e.attr)),gC=["enabled","disabled"],_C=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],hC=new Set(["type","command","url","args","env","envVars","headers",...gC,..._C,...Qr.map(e=>e.raw)]),SC=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",...mC,...Ad,...[...Ad].map(e=>`${e}_truncated`)]);function Cd(e,t){for(let n of t)hC.has(n)||SC.has(n)||(e[n]=pC)}s(Cd,"addOmittedKeys");var EC=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,yC=/(?:^|[-_])(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\.)/,AC=/^bearer(?:\s+|$)/i;function eo(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}s(eo,"asRecord");function bd(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}s(bd,"stringList");function ci(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=eo(e);return t?Object.keys(t).filter(n=>n.length>0):[]}s(ci,"envNamesFromValue");function It(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}s(It,"redactCommandOrUrl");function CC(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,Zr.launchContainsCredentials)({kind:"url",url:e})||(0,Zr.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=Un([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,Zr.launchContainsCredentials)({kind:"url",url:r}):!0)}s(CC,"rawLaunchHadCredentials");function xd(e,t,n){CC(t,n)&&(e.launch_had_credentials=!0)}s(xd,"markLaunchCredentials");function bC(e){return RC.test(e)||AC.test(e)?"<redacted>":e.includes("://")?It(e):e}s(bC,"redactSecretShapedValue");function Od(e){if(/^https?:\/\//i.test(e))return It(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Od(e.slice(t+1))}`:bC(e)}s(Od,"redactArg");function xC(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return EC.test(t)||yC.test(t)}s(xC,"authArgKey");function Un(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(xC(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Od(r))}return t}s(Un,"redactArgs");function OC(e){let t=bd(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Rd?r.slice(0,Rd):r))].sort();if(n.length!==0)return n.length>yd?{names:n.slice(0,yd),truncated:!0}:{names:n,truncated:!1}}s(OC,"toolNameList");function IC(e){let t=eo(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(IC,"envHeaderNames");function Id(e,t){let n=new Set;for(let{raw:r,attr:o}of Qr){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=OC(i);a&&(e[o]=a.names,a.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}s(Id,"applyToolListAttributes");function kd(e,t){let n=eo(e),r={transport:t};if(!n)return r;Cd(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=bd(n.args);c&&(r.command_or_url=It(c));let f=Un(u);f.length>0&&(r.args=f),xd(r,c,u);let l=IC(n.env_http_headers),p=[...new Set([...ci(n.env),...ci(n.envVars),...ci(n.env_vars),...l.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();p.length>0&&(r.env_var_names=p),l.headers.length>0&&(r.env_http_header_names=[...new Set(l.headers)].sort());for(let h of["headers","http_headers","env_http_headers"])if(n[h]!==void 0&&n[h]!==null){r.headers_present=!0;break}let d=typeof n.auth=="string"?n.auth:void 0;d&&(r.auth=d);let m=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;m&&(r.bearer_token_env_var=m);let g=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return g&&(r.default_tools_approval_mode=g),Id(r,n),r}s(kd,"sanitizeMcpServerAttributes");function Td(e){let t=eo(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}s(Td,"mcpServerEnabledFromJson");function fi(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(fi,"hashSanitizedMcpAttributes");function qt(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}s(qt,"parseTomlQuoted");function Mn(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(Mn,"parseTomlPlainStringArray");function li(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}s(li,"parseTomlBoolean");function ui(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=qt(n[1]);return r.length>0?r:void 0}s(ui,"parseTomlScalarString");function kC(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],qt(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(kC,"parseTomlMap");function Pd(e){return li(e,"enabled")===!1?!1:li(e,"disabled")!==!0}s(Pd,"mcpServerEnabledFromToml");function TC(e,t){let n={};for(let{raw:r,attr:o}of Qr){if(o==="auto_approve"){let a=li(t,r);if(a!==void 0){n[r]=a;continue}}let i=Mn(t,r);i.length>0&&(n[r]=i)}Id(e,n)}s(TC,"applyToolListsFromToml");var PC=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,NC=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function wC(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=PC.exec(o);i?.[1]&&t.add(i[1])}for(let o of e.matchAll(NC))o[1]&&t.add(o[1]);return[...t]}s(wC,"tomlDeclaredKeys");function Nd(e,t){let n={transport:t};Cd(n,wC(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),i=r?qt(r[1]??""):void 0,a=o?qt(o[1]??""):void 0,c=i!==void 0&&i.length>0?i:a,u=Mn(e,"args");c&&(n.command_or_url=It(c));let f=Un(u);f.length>0&&(n.args=f),xd(n,c,u);let l=new Set;for(let b of e.split(`
|
|
41
|
+
`)){let T=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);T?.[1]&&l.add(T[1])}let p=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(p?.[1])for(let b of p[1].split(",")){let T=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);T?.[1]&&l.add(T[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 T=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(b);T?.[1]&&l.add(T[1])}for(let b of Mn(e,"env_vars"))l.add(b);let m=kC(e,"env_http_headers");for(let[,b]of m)b.length>0&&l.add(b);let g=ui(e,"bearer_token_env_var");g&&(l.add(g),n.bearer_token_env_var=g),l.size>0&&(n.env_var_names=[...l].sort()),m.length>0&&(n.env_http_header_names=[...new Set(m.map(([b])=>b))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let h=ui(e,"auth");h&&(n.auth=h);let y=ui(e,"default_tools_approval_mode");return y&&(n.default_tools_approval_mode=y),TC(n,e),n}s(Nd,"parseTomlMcpSection");var Fe=Ze(ct(),1);import{createHash as UC}from"node:crypto";import{join as Hn}from"node:path";var LC=300,vC=256;function wd(e,t){if(!t)return e;let n=[...new Set([t,t.replace(/\\/g,"/")])].filter(o=>o.length>1),r=e;for(let o of n)r=r.split(o).join("~");return r}s(wd,"rewriteHomePrefix");function to(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(to,"tokenizeCommand");function Ld(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}s(Ld,"capLength");function MC(e){return Ld(e,LC)}s(MC,"capCommand");function vd(e,t){let n=wd(e.trim(),t),r=to(n);if(r.length===0)return"";let[o,...i]=r,a=It(o),c=Un(i);return MC([a,...c].join(" "))}s(vd,"sanitizeHookCommand");function Md(e,t){if(typeof e!="string")return null;let n=wd(e.trim(),t),r=to(n)[0];if(!r)return null;let o=It(r);return o.length===0?null:Ld(o,vC)}s(Md,"executableFromCommand");function HC(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(HC,"packageVersionFields");function DC(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
|
|
44
|
+
`);return UC("sha512").update(t).digest("hex").slice(0,16)}s(DC,"npxCacheKey");function FC(e){let t=process.platform==="win32"?Hn(H("LOCALAPPDATA")??e,"npm-cache"):Hn(e,".npm"),n=H("npm_config_cache")??H("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}s(FC,"npmCacheRoots");function Ud(e){return typeof e=="string"&&e.length>0&&e.length<=Fe.PACKAGE_FIELD_MAX?e:null}s(Ud,"usableVersion");function $C(e,t,n){let r=DC(e);for(let o of FC(n)){let i=Hn(o,"_npx",r),a=q(Hn(i,"node_modules",...t.split("/"),"package.json"),{}),c=Ud(a.version);if(c!==null)return c;let u=q(Hn(i,"package-lock.json"),{}),f=Ud(u.packages?.[`node_modules/${t}`]?.version);if(f!==null)return f}return null}s($C,"installedVersion");function BC(e){return e.length<=Fe.PACKAGE_FIELD_MAX?e:`${e.slice(0,Fe.PACKAGE_FIELD_MAX-1)}\u2026`}s(BC,"capField");function di(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:BC(o),...HC(o,$C(r,i,n))}}s(di,"resolveNpxPackage");function Hd(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=to(e.trim());return n===void 0?null:di(n,r,t)}s(Hd,"resolveNpxPackageFromCommand");function no(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 di(typeof n.command=="string"?n.command:null,r,t)}s(no,"npxPackageFromMcpConfig");function Dd(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:di(qt(n[1]??""),Mn(e,"args"),t)}s(Dd,"npxPackageFromTomlSection");function GC(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(GC,"mcpTransport");function Fd(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=GC(c),f=kd(c,u);Object.assign(f,no(c,e.home)??{});let l=Td(c);e.push({kind:"MCP_SERVER",name:a,path:i,content_hash:fi(a,f,l),origin:n,enabled:l,attributes:f})}}s(Fd,"collectMcpJson");function $d(e,t,n){if(!jC(t)||!e.claimFile(t))return;let r;try{r=KC(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=Nd(l,p);Object.assign(d,Dd(l,e.home)??{});let m=Pd(l);e.push({kind:"MCP_SERVER",name:c,path:o,content_hash:fi(c,d,m),origin:n,enabled:m,attributes:d})}}s($d,"collectCodexMcpToml");import{existsSync as WC,readdirSync as JC}from"node:fs";import{join as _e}from"node:path";function VC(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(VC,"classifyActionKind");function zC(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(zC,"normalizeHookActions");function pi(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 zC(u)){if(e.truncated)return;let l=f.command??f.bash??f.prompt??f.powershell??u.powershell??"",p=VC({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),g=d?`${i}:${d}:${p}:${m}`:`${i}:${p}:${m}`,h=`${i}|${d}|${p}|${l}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:ee(h),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:i,...d?{matcher:d}:{},action_kind:p,action_hash:m,...p!=="prompt"&&l.trim()?{command:vd(l,e.home)}:{}}})}}}s(pi,"collectHooksFromObject");function mi(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||pi(e,t,r.hooks,n)}s(mi,"collectHooksFile");var Bd=50;function Dn(e,t,n,r){if(!WC(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:i}=e.withPluginExpandCap(Bd,()=>{Ot(e,{dir:_e(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Ot(e,{dir:_e(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Ot(e,{dir:_e(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});mi(e,_e(t,"hooks","hooks.json"),n),mi(e,_e(t,"hooks.json"),n);let a=e.components.length-o,c=i>=Bd;return{componentCount:a,expandTruncated:c}}s(Dn,"expandPluginTree");function Fn(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(Fn,"addPluginRow");function gi(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(gi,"readEnabledPlugins");function YC(e){let t=gi(e.readJson(_e(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=Sn(process.platform,e.home),o=e.readJson(n,{}),i={};if(o&&Object.keys(o).length>0)i=gi(o);else for(let a of r)Object.assign(i,gi(e.readJson(a,{})));return{...t,...i}}s(YC,"resolveClaudeEnabledPlugins");function jd(e){let t=_e(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=YC(e),i=e.componentPath(t);for(let[a,c]of Object.entries(r)){if(e.truncated)return;let u=Array.isArray(c)?c:[c],f=u[0]??{},l=o[a]===!0,p=a.includes("@")?a.split("@").slice(1).join("@"):"",d=typeof f.version=="string"?f.version:"",m=typeof f.scope=="string"?f.scope:"user",g=`plugin:${a}`,h=0,y=!1;for(let b of u)if(typeof b.installPath=="string"&&b.installPath.length>0){let T=Dn(e,b.installPath,g,l);h+=T.componentCount,y=y||T.expandTruncated}Fn(e,{pluginKey:a,rowPath:i,enabled:l,scope:m,version:d||void 0,marketplace:p||void 0,componentCount:h,expandTruncated:y,contentHash:ee(`${a}|${d}|${m}|${l}|${h}`)})}}s(jd,"collectClaudePlugins");function XC(e){let t=e,n="";try{let r=JC(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=_e(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),i=o[o.length-1];i&&(t=_e(e,i),n=i)}}catch{}return{installPath:t,version:n}}s(XC,"pickVersionDir");var qC=/^\d+$/;function ZC(e){let t=e.filter(n=>!qC.test(n.pluginId));return t.length>0?t:e}s(ZC,"dedupeCursorCachePlugins");function Kd(e){let t=[{base:_e(e.home,".cursor/plugins/local"),scope:"local"},{base:_e(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=_e(n,o.name),f=`plugin:${c}`,{componentCount:l,expandTruncated:p}=Dn(e,u,f,!0);Fn(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(_e(n,i))){if(!c.isDirectory())continue;let u=_e(n,i,c.name),{installPath:f,version:l}=XC(u);a.push({pluginId:c.name,installPath:f,version:l})}for(let c of ZC(a)){if(e.truncated)break;let u=`${c.pluginId}@${i}`,f=`plugin:${u}`,{componentCount:l,expandTruncated:p}=Dn(e,c.installPath,f,!0);Fn(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(Kd,"collectCursorPlugins");import{existsSync as tb}from"node:fs";var QC=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,_i="<path>",eb=new RegExp(`${_i}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function ro(e){let t=e.replace(QC,_i).replace(eb,_i);return t.length>200?`${t.slice(0,200)}...`:t}s(ro,"redactPermissionKey");var Gd=200,Vd=200,hi=16*1024,zd=6,nb=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),rb=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),ob=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),sb=new Set(["permissions"]),ib={claude:nb,cursor_sandbox:rb,cursor_permissions:ob,cursor_cli:sb},ab=new Set(["allow","deny","ask"]);function lt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(lt,"isRecord");function oo(e){return e.replace(/\\/g,"/")}s(oo,"posixPath");function Si(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Si(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${Si(t[r])}`).join(",")}}`}s(Si,"canonicalJson");function cb(e){return ee(`${Si(e)}|settings1`)}s(cb,"hashSettingsAttributes");function qd(e){let t=oo(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(qd,"settingsProfileFor");function Zd(e,t){if(e!=="claude")return{};let n=oo(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(Zd,"managedSettingsMeta");function Qd(e){let t=oo(e).replace(/\/+$/,"");return t.length<=1?"":t}s(Qd,"homePosix");function ep(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}s(ep,"isWindowsHome");function ub(e,t){let n=oo(e);if(n==="~"||n.startsWith("~/"))return n;let r=Qd(t);if(!r)return n;let o=n.slice(0,r.length);if(!(ep(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let a=n.slice(r.length);return a===""?"~":a.startsWith("/")?`~${a}`:n}s(ub,"tildePath");var Wd=new Map;function lb(e){let t=Wd.get(e);if(t!==void 0)return t;let n=Qd(e),r=null;if(n){let o=n.split("/").map(i=>i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,ep(e)?"gi":"g")}return Wd.set(e,r),r}s(lb,"homeTextPattern");function fb(e,t){let n=lb(t);return n?e.replace(n,"~"):e}s(fb,"tildeHomeInText");function Jd(e,t){return e.length<=Vd?e:(t.truncated=!0,e.slice(0,Vd))}s(Jd,"capString");function tp(e,t){return e.length<=Gd?e:(t.truncated=!0,e.slice(0,Gd))}s(tp,"capArray");function se(e,t,n,r){if(typeof e=="string"){if(t==="path")return Jd(ub(e,n),r);let o=t==="rule"?ro(e):e;return Jd(fb(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=tp(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 Yd(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";ab.has(o)?a="rule":o==="additionalDirectories"&&(a="path");let c=se(i,a,t,n);c!==void 0&&(r[o]=c)}return r}s(Yd,"transformPermissions");function db(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=tp(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(db,"transformCredentials");function pb(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(pb,"transformNetwork");function mb(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=pb(i,t,n):o==="credentials"?a=db(i,t,n):a=se(i,"plain",t,n),a!==void 0&&(r[o]=a)}return r}s(mb,"transformSandbox");function gb(e,t,n,r,o){return n==="claude"?e==="permissions"?Yd(t,r,o):e==="sandbox"?mb(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"?Yd(t,r,o):se(t,"plain",r,o)}s(gb,"transformByProfile");function $n(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s($n,"jsonBytes");function Ei(e,t){return e?`${e}.${t}`:t}s(Ei,"childPath");function yi(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>=zd?(e.splice(o,1),r.add(n)):yi(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>=zd?(delete e[o],r.add(Ei(n,o))):yi(i,t+1,Ei(n,o),r))}s(yi,"pruneDepth");function np(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))np(o,Ei(t,r),n)}s(np,"collectTrimCandidates");function _b(e,t,n){let r=$n(e);if(r<=hi)return;t.truncated=!0;let o=[];for(np(e,"",o);r>hi;){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=$n(a)+(i.items.length>0?1:0);i.bytes-=c,r-=c,n.add(i.path)}for(;$n(e)>hi;){let i,a=-1;for(let[c,u]of Object.entries(e)){let f=$n(u);f>a&&(i=c,a=f)}if(i===void 0)break;delete e[i],n.add(i)}}s(_b,"fitSettingsJson");function hb(e,t,n){let r=ib[t],o={truncated:!1},i={},a=[];for(let u of Object.keys(e)){if(!r.has(u)){a.push(u);continue}let f=gb(u,e[u],t,n,o);f!==void 0&&(i[u]=f)}a.sort();let c=new Set;return yi(i,1,"",c),c.size>0&&(o.truncated=!0),_b(i,o,c),{settings:i,keys_omitted:a,truncated:o.truncated,trimmed_paths:[...c].sort()}}s(hb,"extractSettingsPosture");function Xd(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:cb(t.attributes),attributes:t.attributes};e.push(n)}s(Xd,"pushPostureRow");function Ri(e,t,n,r){if(!e.claimFile(t)||!tb(t))return;let o=ia(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),Xd(e,{kind:r.kind,absPath:t,origin:n,attributes:l})}return}let i=o.value,a=i.hooks;if(lt(a)&&pi(e,t,a,n),!r.profile)return;let c=hb(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),Xd(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}s(Ri,"collectSettingsFile");import{existsSync as Sb}from"node:fs";import{join as $e}from"node:path";var rp=".claude/skills/synced",op=".claude/plugins/synced";function sp(e){return[$e(e,rp),$e(e,op)]}s(sp,"claudeSyncedDirs");function so(e){return typeof e=="string"&&e.length>0?e:void 0}s(so,"stringField");function ip(e){let t=$e(e.home,rp);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()||!Sb(c))continue;let u=i.get(a.name),f=so(u?.source),l=so(u?.creatorType);Xt(e,{absolutePath:c,kind:"SKILL",origin:"user",enabled:!0,name:a.name,attributes:{scope:"synced",...f?{source:f}:{},...l?{creator_type:l}:{}}})}}}s(ip,"collectClaudeSyncedSkills");function ap(e){let t=$e(e.home,op);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=so(c?.marketplaceName),f=so(c?.version),l=u?`${a.name}@${u}`:a.name,p=$e(r,a.name),{componentCount:d,expandTruncated:m}=Dn(e,p,`plugin:${l}`,!0);Fn(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(ap,"collectClaudeSyncedPlugins");function yb(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:i}=t;for(let a of n.skillRoots)Ot(e,{dir:Zt(r,a),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:sp(e.home)});for(let a of n.dirs)Ot(e,{dir:Zt(r,a.dir),kind:a.kind,origin:o,enabled:!0,extensions:a.extensions});for(let a of n.memory){let c=Ed(a.map(u=>Zt(r,u)));c&&Xt(e,{absolutePath:c,kind:"MEMORY",origin:o,enabled:!0,name:Eb(c)})}for(let a of Wc(n))Ri(e,Zt(r,a),o,{kind:"SETTINGS",profile:qd(a)});for(let a of n.mcpJson??[])Fd(e,Zt(r,a),o);for(let a of n.mcpToml??[])$d(e,Zt(r,a),o);if(i){if(n.managed){for(let a of Er(n.managed,process.platform,e.home))if(a.toLowerCase().endsWith(".json")){let c=Zd(n.managed,a);Ri(e,a,o,{kind:"MANAGED_SETTINGS",...c})}}n.plugins==="claude"?(jd(e),ap(e),ip(e)):n.plugins==="cursor"&&Kd(e)}}s(yb,"walkPlatformLayout");function cp(e,t){try{let n=new Vr(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)yb(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){D("user_spec_scope",n);return}}s(cp,"walkScope");function Ai(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let u=cp(t,{layouts:Object.values(Bt),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=Fs({launchCwd:c,gitRoot:n.gitRoot,inGitRepo:i,remote:n.remote,home:t,hasProjectSpec:s(l=>Yc(u,l),"hasProjectSpec")});a=f.parentRel;for(let l of f.anchors){let p=Is(l.dir);if(o!==void 0&&!o(l.scope,p))continue;let d=cp(t,{layouts:u,levelDir:l.dir,origin:l.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:$s,scopeRef:p});d&&(r[l.scope]=d)}r.parent||(a=null)}return{scopes:r,parentRel:a,cwdInGitRepo:i}}s(Ai,"collectUserSpec");function Ci(e,t,n={}){let r=n.truncated===!0,o=kn(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]!==$r(l)&&c.push(l)}let f=[];if(!r){for(let l of Object.keys(u))if(!i.has(l)){let p=Kl(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(Ci,"diffUserSpec");var lp=2*1024*1024,Rb=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function bi(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(bi,"collectPendingTextBodies");function xi(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(xi,"pruneDeliveredTextHashes");function up(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(up,"jsonSize");function fp(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}s(fp,"withoutText");function Oi(e,t=lp){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=up(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=fp(l),g=up(m)+p;if(a+g<=t){i.push(m),a+=g,c+=1;continue}}u+=1}return{components:i,textDeferredCount:c,droppedCount:u,textHashesSent:f}}s(Oi,"fitUserSpecWithinBudget");function Ii(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:fp(n))}s(Ii,"stripAlreadyDeliveredText");var Ab=["user","cwd","repo","parent"];function ki(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,i=[];for(let O of Ab){let x=t.scopes[O];if(!x)continue;let v=n(O,x.scopeRef),L=v.components,I=Ci(x.components,L,{forceFull:L===void 0,truncated:x.truncated}),w=new Set(v.textHashes),F=bi(x.components,I.upserts,w),_=Ii([...I.upserts,...F],w);i.push({scope:O,walk:x,delta:I,outgoing:_,outgoingKeys:new Set(_.map(k=>Ce(k.path,k.name))),deliveredTextHashes:w,cachedComponents:L})}let a=i.flatMap(O=>O.outgoing),c=Oi(a,o),u=new Set(c.components.map(O=>Ce(O.path,O.name))),f=[],l=[],p=[],d=[],m=[],g=[],h=[];for(let O of i){let{scope:x,walk:v,delta:L}=O;g.push(...v.components),f.push(x);let I=c.components.filter(k=>O.outgoingKeys.has(Ce(k.path,k.name))),w=[...O.outgoingKeys].some(k=>!u.has(k)),F=L.truncated||w;F?p.push(x):L.full&&l.push(x),d.push(...I),!L.full&&!F&&m.push(...L.removed);let _=L.full?{}:{...O.cachedComponents??{}};if(!F)for(let k of L.removed)delete _[Ce(k.path,k.name)];for(let k of I)_[Ce(k.path,k.name)]=$r(k);h.push({scope:x,scopeRef:v.scopeRef,components:_,textHashes:xi(O.deliveredTextHashes,I.filter(k=>k.text!==void 0).map(k=>k.content_hash),v.components),collectedAtMs:r,included:I.length>0||L.removed.length>0&&!F||L.full})}let y={user_spec_hash:kn(g),user_spec_count:g.length,user_spec_truncated:p.length>0};f.length>0&&(y.user_spec_scopes=f,y.user_spec_full_scopes=l,y.user_spec_truncated_scopes=p,y.user_spec_cwd_in_git_repo=t.cwdInGitRepo),l.length>0&&l.length===f.length&&(y.user_spec_full=!0),d.length>0&&(y.user_spec=d),m.length>0&&(y.user_spec_removed=m),c.textDeferredCount>0&&(y.user_spec_text_deferred=c.textDeferredCount);let b=t.scopes.cwd;b&&(y.user_spec_cwd_scope_ref=b.scopeRef);let T=t.scopes.repo;T&&(y.user_spec_repo_scope_ref=T.scopeRef);let N=t.scopes.parent;return N&&(y.user_spec_parent_scope_ref=N.scopeRef,t.parentRel&&(y.user_spec_parent_rel=t.parentRel)),{fields:y,scopes:h}}s(ki,"buildUserSpecSend");var io={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function Ti(e){return e==="cwd"||e==="repo"||e==="parent"}s(Ti,"isProjectSpecScope");function Bn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Bn,"isPlainObject");function Pi(e){return!Bn(e)||!Bn(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(Pi,"isDirScopeCacheEntry");function dp(e){return Cb(e)}s(dp,"readStringHashMap");function pp(e){return bb(e)}s(pp,"readStringArray");function mp(e){return xb(e)}s(mp,"cloneDirScopeMap");function Cb(e){if(!Bn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}s(Cb,"readComponentHashMap");function bb(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}s(bb,"readTextHashes");function gp(e,t){if(!Bn(e))return;let n=e[t];return Pi(n)?n:void 0}s(gp,"readDirScopeCacheEntry");function xb(e){if(!Bn(e))return{};let t={};for(let[n,r]of Object.entries(e))Pi(r)&&(t[n]=r);return t}s(xb,"readDirScopeCacheMap");function Ni(e,t=20){let n=[];for(let[r,o]of Object.entries(e))Pi(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(Ni,"boundDirScopeCache");var Pb=["allow","deny","ask"];function co(e){let t=q(e,{}),n=[];for(let r of Pb)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:ro(o),mode:r});return{model:t.model??"",permissionKeys:n}}s(co,"readClaudeSettings");function Nb(e){let{serverManaged:t,fileBased:n}=Sn(process.platform,e),r=co(t);if(r.model||r.permissionKeys.length>0)return r;let o="",i=[];for(let a of n){let c=co(a);c.model&&(o=c.model),i.push(...c.permissionKeys)}return{model:o,permissionKeys:i}}s(Nb,"readClaudeManagedSettings");function wb(e){let t=new Set,n=[];for(let r of e){let o=`${r.mode}\0${r.key}`;t.has(o)||(t.add(o),n.push(r))}return n}s(wb,"dedupePermissionKeys");var Lb=10,vb="self-config-cache.json",hp=5;function en(){return H("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}s(en,"isUserSpecDisabled");function Mb(){return H("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}s(Mb,"isCwdSpecDisabled");var Ub={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function Hb(e,t=oe){let n=Ub[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(Hb,"resolveCliVersion");function Db(e=_p()){return Qt(e,".ev-ai","agent-hook",vb)}s(Db,"selfConfigCachePath");function Fb(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
|
|
46
|
+
`);return ee(n)}s(Fb,"hashConfigEntries");function ao(e,t,n=!1){let r=Fb(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(ao,"buildHashedList");function wi(e,t,n=[]){let r=0,o=!1,i=new Set;for(let a of[...t.map(c=>Qt(e,c)),...n]){let c=Tb(a);if(i.has(c))continue;i.add(c);let u=ko(a);u.present&&(o=!0,r+=u.size)}return o?{present:!0,size:r}:{present:!1,size:0}}s(wi,"filePresenceUnion");function $b(e){return Ib(e)?Oe(kb(e,"utf8"),{}):{}}s($b,"readSelfConfigCache");function Bb(e,t){try{ue(e,`${JSON.stringify(t)}
|
|
47
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);P(`WARN: self-config cache write failed open: ${r}`),D("self_config_cache",n)}}s(Bb,"writeSelfConfigCache");function jb(e,t,n){if(t==="user")return{components:dp(e.user_spec_components),textHashes:pp(e.user_spec_text_hashes)};if(!Ti(t))return{components:void 0,textHashes:[]};let r=gp(e[io[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}s(jb,"cacheSliceFor");function Kb(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=hp,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(!Ti(i.scope))continue;let a=io[i.scope],c=mp(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]=Ni(c)}}return o}s(Kb,"nextPlatformSelfConfigCache");async function Sp(e,t=process.cwd(),n=_p(),r={}){let o=e==="claude",i=r.gitRoot??t,a=await Hb(e),c="",u=[];if(o){let F=Nb(n),_=co(Qt(n,".claude/settings.json")),k=co(Qt(t,".claude/settings.local.json"));c=F.model||k.model||_.model,u=wb([...F.permissionKeys,..._.permissionKeys,...k.permissionKeys]).slice(0,200)}let f={present:!1,size:0},l=s(F=>{let _=[],k=!1;for(let B of F){let he=aa(Qt(n,B));if(_=_.concat(he.entries),k=k||he.truncated,_.length>=Qe){_=_.slice(0,Qe),k=!0;break}}return{entries:_,truncated:k}},"listScopeWithMeta"),p=Db(n),d=$b(p),m=d[e]??{},g=(m.send_count??0)+1,h=g>0&&g%Lb===0,y=s(F=>h?void 0:m[F],"cachedHash"),b=l(it.skills),T=l(it.subagents),N=l(it.commands),O=l(it.rules),x={skills:ao(b.entries,y("skills"),b.truncated),subagents:ao(T.entries,y("subagents"),T.truncated),commands:ao(N.entries,y("commands"),N.truncated),rules:ao(O.entries,y("rules"),O.truncated)},v={runner_platform:e,config_scope:"user",cli_version:a,claude_version:o?a:null,model:o&&c||null,permission_keys:u,user_scope:{skills:x.skills,subagents:x.subagents,commands:x.commands,rules:x.rules,memory:wi(n,it.memory),settings:wi(n,it.settings,Xc(n)),mcp:wi(n,it.mcp)},local_settings:o?ko(Qt(t,".claude/settings.local.json")):f},L=null,I=r.nowMs??Date.now();if(!en()){let F=m.user_spec_layout_version!==hp,_=Ai(e,n,{launchCwd:Mb()?void 0:r.launchCwd,gitRoot:i,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(_.scopes).length>0){let k=ki({collected:_,cacheFor:s((B,he)=>F?{components:void 0,textHashes:[]}:jb(m,B,he),"cacheFor"),nowMs:I});Object.assign(v,k.fields),L={hash:k.fields.user_spec_hash,home:k.scopes.find(B=>B.scope==="user")??null,project:k.scopes.filter(B=>B.scope!=="user")}}}let w=Kb(m,x,g,L);return{config:v,commit:s(()=>{d[e]=w,Bb(p,d)},"commit")}}s(Sp,"selfConfig");import{homedir as ux}from"node:os";import{join as Rp}from"node:path";function kt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(kt,"isRecord");import{join as uo}from"node:path";function Gb(e){return uo(e,".ev-ai","agent-hook","js","signed-v1")}s(Gb,"jsRoot");function Vb(e){return uo(Gb(e),"scopes")}s(Vb,"scopesRoot");function Ep(e,t){return uo(Vb(e),t)}s(Ep,"scopeDir");function yp(e){return uo(e,"attempts")}s(yp,"attemptsDir");function Li(e){return String(e).padStart(10,"0")}s(Li,"padAttempt");var zb=/^(\d{10})$/,Wb=/^(\d{10})\.done$/,Jb=/^[0-9a-f]{128}$/,Yb=64,xp=["check_ms","download_ms","install_ms","total_ms"],Xb=36e5;async function Op(e,t,n=!1){let r=yp(t),o=await ba(e,r),i=new Map,a=new Map,c=Ap(o,zb),u=Ap(o,Wb),f=s(async d=>{let m=await bp(e,Rp(r,qb(d)));return m&&i.set(d,{record:Qb(m.value),mtimeMs:m.mtimeMs}),m!==void 0},"readClaimAt"),l=s(async d=>{let m=ex((await bp(e,Rp(r,Zb(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([Cp(c,f),Cp(u,l)]);let p=jn(i);return p<jn(a)&&u.includes(p)&&await l(p),{claims:i,dones:a}}s(Op,"scanAttempts");function Ap(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}s(Ap,"attemptNumbers");async function Cp(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}s(Cp,"firstFromTop");function jn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}s(jn,"maxKey");function Ip(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(Ip,"claimStartMs");function kp(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of xp){let r=e[n];r!==void 0&&(t[n]=r)}return t}s(kp,"pickTimings");function qb(e){return Li(e)}s(qb,"claimFileName");function Zb(e){return`${Li(e)}.done`}s(Zb,"doneFileName");async function bp(e,t){let n;try{n=await e.stat(t)}catch(o){if(vt(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>wo)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>wo?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}s(bp,"readRecord");function Qb(e){if(!kt(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(Qb,"parseClaim");function ex(e){if(!kt(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=nx(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...tx(t)}}s(ex,"parseDoneRecord");function tx(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 xp){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=Xb&&(t[n]=r)}return t}s(tx,"parseTimings");function nx(e){if(!kt(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"&&Jb.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&rx(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}s(nx,"parseSelection");function rx(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==Yb||t.toString("base64")!==e))return t.toString("hex")}s(rx,"canonicalSha512Hex");function ax(e){return e==="bootstrap"?3e3:6e4}s(ax,"ownerBudgetMs");function cx(e,t){let n=jn(e.claims);if(n===0)return;let r=jn(e.dones),o=e.claims.get(n),i=e.dones.get(n);if(o&&!i){let c=Ip(o),u=o.record==="empty"?void 0:o.record.owner,f=ax(u)+3e4;if(t-c>f)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:Tp(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:Tp(a.selection),...kp(a)}}s(cx,"latestAttemptReport");async function Pp(e,t,n){try{let r=await Op(xa(),Ep(e,t),!0);return cx(r,n)}catch{return}}s(Pp,"readLatestAttemptReport");function Tp(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}s(Tp,"selectionVersion");function lx(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===Dt?"npx":null}s(lx,"hookDelivery");async function Np(e=ux()){let t=Es()?.launcherScope;if(!t)return{};let n=await Pp(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}s(Np,"readSessionStartLauncherFields");function tn(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:lr,event:e,timestamp:Xn(),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:lx(),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=Es();return i&&(o.launcher_version=i.launcherVersion,o.hook_source=i.hookSource,o.hook_fallback_reason=i.fallbackReason??null,o.launcher_scope_match=dl(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(tn,"buildEnvelope");import{existsSync as Bp}from"node:fs";import{spawn as jp}from"node:child_process";import{fileURLToPath as Fx}from"node:url";import{gzipSync as fx}from"node:zlib";function vi(e){return H("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<qa?{body:e}:{body:fx(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}s(vi,"gzipBodyIfLarge");function lo(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}s(lo,"collectorPostHeaders");function Mi(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}s(Mi,"postBodyByteLength");import{readFileSync as dx,statSync as px}from"node:fs";import{homedir as Ui}from"node:os";import{join as mx}from"node:path";var gx="hook-config.json",_x=1440*60*1e3,hx=2048,Sx=1024*1024;function nn(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(nn,"isRecord");function wp(e=Ui()){return mx(Ee(e),gx)}s(wp,"hookConfigPath");function Lp(e){let t=wp(e);try{let n=px(t);if(!n.isFile()||n.size>Sx)return;let r=JSON.parse(dx(t,"utf8"));return nn(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}s(Lp,"readStore");function Ex(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===Ft||!Number.isNaN(Date.parse(e.log_until)))&&(t.log_until=e.log_until),t}s(Ex,"knownKeys");function vp(e,t=Ui()){if(!e)return;let n=mt(e);if(!n)return;let r=Lp(t),o=r?r[n]:void 0;if(!(!nn(o)||!nn(o.config)))return Ex(o.config)}s(vp,"readHookConfig");function yx(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!nn(n)||!nn(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>hx))return n.hook_config}s(yx,"hookConfigFromBody");function Rx(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(!(nn(i)&&JSON.stringify(i.config)===JSON.stringify(n)&&typeof i.fetched_at_ms=="number"&&i.fetched_at_ms<=r&&r-i.fetched_at_ms<_x))return o[t]={config:n,fetched_at_ms:r},o}s(Rx,"nextStore");function Mp(e,t,n=Ui(),r=Date.now()){let o=yx(e),i=t?mt(t):void 0;if(o===void 0||!i)return"skipped";try{let a=Lp(n);if(a===void 0)return ce.error("failed where=hook_config_read err=unreadable message=hook config store is not a readable JSON object"),"skipped";let c=Rx(a??{},i,o,r);return c?(ue(wp(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 P(`WARN: hook config write failed open: ${c}`),D("hook_config_write",a),"failed"}}s(Mp,"applyCollectorHookConfigResponse");var Tt=class extends Error{static{s(this,"ProxyError")}code;status;constructor(t,n,r){super(n),this.name="ProxyError",this.code=t,this.status=r}};function Up(e,t){for(let n of[t,t.toUpperCase()]){let r=e[n]?.trim();if(r)return{name:n,value:r}}}s(Up,"envValue");function fo(e){let t=e.toLowerCase().replace(/\.$/,"");return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}s(fo,"bareHost");function Ax(e){let t=fo(e);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}s(Ax,"isLoopbackHost");function Cx(e,t){let n=fo(e.hostname),r=e.port||(e.protocol==="http:"?"80":"443"),o=n.includes(":")||/^[\d.]+$/.test(n);return t.split(/[\s,]+/).some(i=>{let a=i.toLowerCase();if(a==="*")return!0;let c=/^\[([^\]]+)\](?::(\d+))?$/.exec(a)??/^([^:]+):(\d+)$/.exec(a);if(c){if(c[2]!==void 0&&c[2]!==r)return!1;a=c[1]??""}return a=a.replace(/^\*?\.?/,"").replace(/\.$/,""),a!==""&&(n===a||!o&&n.endsWith(`.${a}`))})}s(Cx,"noProxyMatches");function bx(e){try{let t=new URL(e.includes("://")?e:`http://${e}`);return(t.protocol==="http:"||t.protocol==="https:")&&t.hostname?t:void 0}catch{return}}s(bx,"parseProxyUrl");function Dp(e,t=process.env,n){if(e.protocol!=="https:"&&e.protocol!=="http:"||Ax(e.hostname))return;let r=Up(t,`${e.protocol.slice(0,-1)}_proxy`);if(!r)return;let o=Up(t,"no_proxy");if(o&&Cx(e,o.value))return;let i=bx(r.value);return n?.(i?`${e.host} via proxy ${i.protocol}//${i.host}`:`ignoring ${r.name}: not an http(s) URL`),i}s(Dp,"proxyForUrl");function Hp(e){try{return decodeURIComponent(e)}catch{return e}}s(Hp,"decodeUserinfo");function Fp(e){if(!e.username&&!e.password)return;let t=`${Hp(e.username)}:${Hp(e.password)}`;return`Basic ${Buffer.from(t,"utf8").toString("base64")}`}s(Fp,"proxyAuthorization");var xx=16*1024;async function Ox(e,t,n){let[r,o]=await Promise.all([import("node:net"),import("node:tls")]),i=fo(t.hostname),a=Number(t.port)||(t.protocol==="https:"?443:80),c=s(u=>r.isIP(u)?void 0:u,"servername");return new Promise((u,f)=>{let{signal:l,timeout:p}=n;if(l?.aborted){f(l.reason);return}let d=t.protocol==="https:"?o.connect({host:i,port:a,servername:c(i),ca:n.ca}):r.connect({host:i,port:a}),m=!1,g=Buffer.alloc(0),h=s(()=>m?!1:(m=!0,l?.removeEventListener("abort",T),d.setTimeout(0),d.removeListener("data",N),!0),"settle"),y=s(O=>{h()&&(d.destroy(),f(O))},"fail"),b=s(O=>{h()&&u(O)},"succeed"),T=s(()=>{y(l?.reason)},"onAbort");function N(O){g=Buffer.concat([g,O]);let x=g.indexOf(`\r
|
|
49
|
+
\r
|
|
50
|
+
`);if(x<0){g.length>xx&&y(new Tt("EPROXY_CONNECT","proxy CONNECT reply too large"));return}let v=Number(/^HTTP\/1\.[01] (\d{3})/.exec(g.toString("latin1",0,x))?.[1]??0);if(v<200||v>299){y(new Tt(v===407?"EPROXY_AUTH":"EPROXY_CONNECT",`proxy answered CONNECT with HTTP ${v||"garbage"}`,v||void 0));return}d.removeListener("data",N),d.pause(),x+4<g.length&&d.unshift(g.subarray(x+4));let L=fo(e.hostname);b(o.connect({socket:d,host:L,servername:c(L),ca:n.ca}))}s(N,"onData"),d.on("error",O=>{let x=O!==null&&typeof O=="object"&&"code"in O&&typeof O.code=="string"?O.code:"error";y(new Tt("EPROXY_UNREACHABLE",`proxy connection failed (${x})`))}),d.on("close",()=>{y(new Tt("EPROXY_UNREACHABLE","proxy closed the connection"))}),p!==void 0&&d.setTimeout(p,()=>{y(new Tt("EPROXY_TIMEOUT","proxy did not answer in time"))}),l?.addEventListener("abort",T,{once:!0}),d.once(t.protocol==="https:"?"secureConnect":"connect",()=>{if(e.protocol!=="https:"){b(d);return}let O=`${e.hostname}:${e.port||"443"}`,x=Fp(t);d.on("data",N),d.write(`CONNECT ${O} HTTP/1.1\r
|
|
51
|
+
Host: ${O}\r
|
|
52
|
+
${x?`Proxy-Authorization: ${x}\r
|
|
53
|
+
`:""}\r
|
|
54
|
+
`)})})}s(Ox,"openProxySocket");async function Ix(e,t,n,r){let o=await import("node:http"),i=await Ox(e,t,n),a=e.protocol==="https:",c=Fp(t),u={...n.headers,host:e.host};!a&&c&&(u["proxy-authorization"]=c);let f=o.request({method:n.method??"GET",path:a?`${e.pathname}${e.search}`:e.href,headers:u,createConnection:s(()=>i,"createConnection")},r);return n.timeout!==void 0&&f.setTimeout(n.timeout),f}s(Ix,"requestViaProxy");var kx=new Set([101,103,204,205,304]);function Tx(e){if(e!=null){if(typeof e=="string")return Buffer.from(e,"utf8");if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);if(e instanceof ArrayBuffer)return Buffer.from(e);throw new TypeError("proxied fetch supports string and byte bodies only")}}s(Tx,"requestBody");function Px(e){let t=(e??"").split(",").map(r=>r.trim().toLowerCase()).filter(r=>r!==""&&r!=="identity"),n=t.every(r=>["gzip","x-gzip","deflate","br"].includes(r));return t.length>0&&n?t.reverse():void 0}s(Px,"codingsToUndo");function Nx(e,t,n){let r={flush:t.constants.Z_SYNC_FLUSH,finishFlush:t.constants.Z_SYNC_FLUSH};if(e==="br")return t.createBrotliDecompress();if(e!=="deflate")return t.createGunzip(r);let o,i=new n({transform(a,c,u){if(!o){let f=((a[0]??0)&15)===8?t.createInflate(r):t.createInflateRaw(r);f.on("data",l=>i.push(l)),f.on("error",l=>i.destroy(l)),o=f}o.write(a,()=>u())},flush(a){if(!o){a();return}o.once("end",()=>a()),o.end()},destroy(a,c){o?.destroy(),c(a)}});return i}s(Nx,"decoderFor");async function wx(e){let t=new Headers;for(let c=0;c+1<e.rawHeaders.length;c+=2)t.append(e.rawHeaders[c]??"",e.rawHeaders[c+1]??"");let n=e.statusCode??0,r={status:n,statusText:e.statusMessage??"",headers:t};if(kx.has(n))return e.resume(),new Response(null,r);let o=await import("node:stream"),i=e,a=Px(t.get("content-encoding"));if(a){let c=await import("node:zlib"),u=a.map(f=>Nx(f,c,o.Transform));o.pipeline([e,...u],()=>{}),i=u[u.length-1]??e,t.delete("content-encoding"),t.delete("content-length")}return new Response(o.Readable.toWeb(i),r)}s(wx,"toResponse");function Lx(e,t,n,r){let o=n.signal??void 0;return new Promise((i,a)=>{if(o?.aborted){a(o.reason);return}let c,u={"accept-encoding":e.protocol==="https:"?"br, gzip, deflate":"gzip, deflate"};try{c=Tx(n.body),new Headers(n.headers).forEach((y,b)=>{u[b]=y})}catch(y){a(y);return}c&&(u["content-length"]=c.byteLength);let f=!1,l,p,d=s(()=>{o?.removeEventListener("abort",h)},"detach"),m=s(y=>{f||(f=!0,y())},"settle"),g=s(y=>{m(()=>{d(),a(o?.aborted?o.reason:new TypeError("fetch failed",{cause:y}))})},"failed"),h=s(()=>{l?.destroy(),p?.destroy(o?.reason instanceof Error?o.reason:new Error("aborted")),m(()=>{d(),a(o?.reason)})},"onAbort");o?.addEventListener("abort",h,{once:!0}),Ix(e,t,{method:n.method,headers:u,signal:o,ca:r},y=>{p=y,y.once("close",d),wx(y).then(b=>m(()=>i(b)),b=>{y.destroy(),g(b)})}).then(y=>{if(f){y.destroy();return}l=y,y.on("error",g),y.end(c)},g)})}s(Lx,"fetchOnce");var vx=new Set([301,302,303,307,308]),Mx=20,Ux=["content-type","content-encoding","content-language","content-location","content-length"];function Hx(e,t){try{return new URL(e,t)}catch{return}}s(Hx,"resolveLocation");async function Dx(e,t,n={},r={}){let o=n.redirect??"follow",i=new Headers(n.headers),a=n.method??"GET",c=n.body,u=e,f=t;for(let l=0;;l+=1){let p={method:a,headers:i,body:c,signal:n.signal,redirect:"manual"},d=f?await Lx(u,f,p,r.ca):await fetch(u,p),m=d.headers.get("location");if(o==="manual"||!vx.has(d.status)||m===null)return d;await d.body?.cancel();let g=Hx(m,u),h=o==="error"?"unexpected redirect":l>=Mx?"redirect count exceeded":g?.protocol==="http:"||g?.protocol==="https:"?void 0:"redirect location is not http(s)";if(h!==void 0||g===void 0)throw new TypeError("fetch failed",{cause:new Error(h)});let y=a.toUpperCase();if(d.status===303&&y!=="GET"&&y!=="HEAD"||d.status<=302&&y==="POST"){a="GET",c=void 0;for(let b of Ux)i.delete(b)}g.origin!==u.origin&&(i.delete("authorization"),i.delete("cookie")),u=g,f=Dp(u,r.env??process.env,r.debug)}}s(Dx,"fetchViaProxy");function $p(e,t,n,r=process.env){if(process.versions.bun!==void 0||!(typeof e=="string"||e instanceof URL))return fetch(e,t);let o;try{o=new URL(e)}catch{return fetch(e,t)}let i=Dp(o,r,n);return i?Dx(o,i,t,{env:r,debug:n}):fetch(e,t)}s($p,"fetchWithEnvProxy");var po="__post",rn="__work";async function $x(e,t,n={}){if(en())return e;let r=await Ts(n.gitRoot??process.cwd(),oe,process.env,{runnerPlatform:t,home:n.home,context:n.context}),o=kt(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($x,"attachOperatorIdentity");function Bx(e,t){let n=kt(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(Bx,"debugEnvelopeSummary");function Kp(e){switch(e){case"session_start":return Wa;case"session_end":return Ja;case"tool_invoked":case"skill_invoked":return Ho;default:return Ho}}s(Kp,"timeoutForEvent");function jx(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
|
|
55
|
+
${n}`}s(jx,"frameDetachedPostStdin");function Gp(e,t=[],n=process.execPath,r=import.meta.url,o=Bp){if(za(n))return{command:n,args:[e,...t]};let i=Fx(r);return o(i)?{command:n,args:[i,e,...t]}:{command:n,args:[e,...t]}}s(Gp,"resolveSelfReexecCommand");function Kx(e=process.execPath,t=import.meta.url,n=Bp){let r=process.argv.includes("--debug")?["--debug"]:[];return Gp(po,r,e,t,n)}s(Kx,"resolveSelfPostCommand");function Gx(e){let t=e.indexOf(`
|
|
56
|
+
`);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}s(Gx,"parseDetachedPostStdin");function Vx(e){H("EV_AI_HOOK_DEBUG")&&P(`DEBUG: ${e}`)}s(Vx,"debugProxy");var Vp=s((e,t)=>$p(e,t,Vx),"collectorFetch");function zp(e){H("EV_AI_HOOK_DEBUG")&&P(`DEBUG: send fail ${hn(e)}`)}s(zp,"debugFailedPost");async function Wp(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();Mp(n,t)}catch(n){D("collector_response",n)}}s(Wp,"applyCollectorHttpResponse");function Jp(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(Jp,"errorParts");var Yp=1e3;function Xp(e,t){let n=e instanceof Error&&e.name==="TimeoutError"?"timeout":"post_failed";Q({outcome:n,postMs:t,err:nt(e)})}s(Xp,"noteFailedPost");async function qp(e,t=Vp){try{let n=await e(),r=Gx(n);if(!r){ce.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=vi(i),c=lo(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,Yp).replace(/[\n\r]/g,"");ce.error(`send fail http=${f.status} code=${f.status} body=${p}`),Q({outcome:"post_failed",postMs:l,http:f.status});return}ce.info(`send ok http=${f.status}`),Q({outcome:"posted",postMs:l,http:f.status}),await Wp(f,o.url)}catch(f){let l=Jp(f);ce.error(`send fail code=${l.code??"(none)"} ${hn(f)}`),zp(f),Xp(f,performance.now()-u)}}catch(n){D("post",n),Q({outcome:"error",err:nt(n)})}finally{$t("post",Ke,"error")}}s(qp,"runDetachedPoster");async function zx(e,t,n,r=Vp){let o=Kp(e),i=vi(t),a=lo(i.contentEncoding),c=Mi(i.body);P(`POST event=${e} url=${Ht(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{}P(`POST gzip rejected http=${l.status} \u2014 retrying uncompressed`),l=await r(n,{method:"POST",headers:lo(),body:t,signal:AbortSignal.timeout(o)})}let p=Date.now()-u,d=performance.now()-f;if(As(d),l.ok)return P(`POST outcome=ok elapsed_ms=${p} http=${l.status}`),ce.info(`send ok http=${l.status}`),Q({outcome:"posted",postMs:d,http:l.status}),await Wp(l,n),!0;let m=(await l.text()).slice(0,Yp).replace(/[\n\r]/g,"");return P(`POST outcome=fail elapsed_ms=${p} http=${l.status} body=${m}`),ce.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;As(d);let m=Jp(l);return P(`POST outcome=fail elapsed_ms=${p} http=000 body=${m.message}`),ce.error(`send fail http=0 code=${m.code??"(none)"} ${hn(l)}`),zp(l),Xp(l,d),!1}}s(zx,"postCollector");async function Zp(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=>{D(i,u)}),a.stdin.on("error",u=>{D(`${i}_stdin`,u)});let c=!1;return await new Promise(u=>{let f=setTimeout(()=>{if(!c){P(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`),ce.error(`failed where=${i} err=timeout message=stdin handoff timed out`);try{a.stdin.destroy()}catch{}}u()},Ya),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 P(`WARN: ${o} spawn failed open: ${c}`),D(i,a),null}}s(Zp,"spawnDetachedStdinChild");async function Wx(e,t,n,r=jp,o=Kx){let i=Kp(e),a=jx(n,i,t),{command:c,args:u}=o();return Zp(c,u,a,r,"detached post")}s(Wx,"postCollectorDetached");async function Qp(e,t,n=jp,r=Gp){let{command:o,args:i}=r(rn,t);return Zp(o,i,e,n,"detached work")}s(Qp,"runHookDetached");async function on(e,t,n,r,o,i,a,c){if(!o)return P("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),ce.error("send fail code=missing message=collector URL missing"),Q({outcome:"no_collector",err:"missing"}),!1;if(!ur(o))return P(`WARN: collector URL blocked (https required): ${Ht(o)}`),ce.error("send fail code=blocked message=collector URL blocked"),Q({outcome:"no_collector",err:"blocked"}),!1;let u=performance.now(),f=await $x(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=hl({w4:u,w4e:l,w5:performance.now()},process.env,void 0,n.telemetry?.enabled===!0);d&&(p.perf=d);let m=JSON.stringify(p),g=c?.attach(Buffer.byteLength(m,"utf8"));g&&(p.run_log=g,m=JSON.stringify(p));let h=`${m}
|
|
57
|
+
`,y=H("EV_AI_HOOK_DEBUG");y==="full"?P(`DEBUG envelope=${m}`):y==="1"&&P(`DEBUG summary=${Bx(p,Mi(h))}`);let b=process.argv.includes(rn),T=H("EV_AI_HOOK_SYNC")==="1";if(!(Pr(n.runnerEvent,n.runnerPlatform)||b||T)){let O=await Wx(e,h,o);return Q(O?.pid!==void 0?{outcome:"handed_off"}:{outcome:"post_failed",err:"spawn"}),!1}return zx(e,h,o)}s(on,"emitAndPost");import{closeSync as Jx,fstatSync as Yx,linkSync as Xx,openSync as qx,readdirSync as Zx,readSync as Qx,renameSync as eO,unlinkSync as im}from"node:fs";import{homedir as tO}from"node:os";import{basename as nO,dirname as rO}from"node:path";var em=Go,tm=2*1024*1024,oO=Buffer.byteLength(',"run_log":',"utf8");function nm(e){let t=`${e}.send-${process.pid}`;try{return eO(e,t),{path:e,taken:t}}catch(n){return n.code==="ENOENT"?"missing":"busy"}}s(nm,"take");function rm(e){return typeof e=="object"}s(rm,"isTaken");function sO(e){let t=`${nO(e)}.`;try{return Zx(rO(e)).some(n=>n.startsWith(t)&&/\.send-\d+$/.test(n))}catch{return!1}}s(sO,"anyTakenLog");function iO(e){try{Xx(e.taken,e.path),im(e.taken)}catch{}}s(iO,"putBack");function aO(e){try{im(e)}catch{}}s(aO,"unlinkQuiet");function om(e,t){let n;try{n=qx(e,"r");let r=Yx(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=Qx(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{Jx(n)}catch{}}}s(om,"readTail");function cO(e){let t=e.indexOf(10);return t===-1?e:e.subarray(t+1)}s(cO,"fromFirstWholeLine");function sm(e,t,n){Jo(r=>{r[t]===n&&delete r[t]},e)}s(sm,"forgetWindow");function am(e,t=tO(),n=process.env,r=Date.now()){try{let o=e?mt(e):void 0;if(!o||Ec())return;let i=Wo(t)[o];if(i===void 0||i===Ft)return;let a=Date.parse(i);if(Number.isNaN(a)||a>r)return;let c=gc(t,n,r);if(c.on||c.source!=="remote")return;let u=gr(t),f=nm(u),l=nm(`${u}.1`),p=rm(f)?f:void 0,d=rm(l)?l:void 0,m=[d,p].filter(w=>w!==void 0),g=s(()=>{for(let w of m)iO(w)},"putAllBack"),h=p?om(p.taken,em):void 0,y=d?om(d.taken,em-(h?.tail.length??0)):void 0,b=(h?.size??0)+(y?.size??0);if(b===0){g(),f!=="busy"&&l!=="busy"&&!sO(u)&&sm(t,o,i);return}let T=Buffer.concat([y?.tail??Buffer.alloc(0),h?.tail??Buffer.alloc(0)]),N=T.length<b,O=N?cO(T):T,x={log_until:i,text:O.toString("utf8"),bytes:O.length,bytes_total:b,truncated:N},v=oO+Buffer.byteLength(JSON.stringify(x),"utf8"),L=!1,I=!1;return{attach(w){if(w+v>tm){P(`run log deferred: body=${w} run_log=${v} over ${tm}`);return}return L=!0,x},settle(w){if(!I){if(I=!0,!(L&&w)){g();return}for(let F of m)aO(F.taken);sm(t,o,i)}}}}catch(o){P(`WARN: run log upload failed open: ${o instanceof Error?o.message:String(o)}`);return}}s(am,"prepareRunLogUpload");import{createReadStream as uO}from"node:fs";import{stat as lO}from"node:fs/promises";import{basename as fO,resolve as dO}from"node:path";import{createInterface as pO}from"node:readline";var mO=1024*1024;function gO(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&fO(t).endsWith(".jsonl")}s(gO,"isSafeClaudeTranscriptPath");async function cm(e){if(!e||!gO(e))return null;try{let t=dO(e),n=await lO(t);if(!n.isFile())return null;let r=Math.max(0,n.size-mO),o=[],i=pO({input:uO(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(cm,"lastAssistantModelFromTranscript");var _O="EV_AI_HOOK_TELEMETRY";function um(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}s(um,"telemetryFromHomeConfig");function lm(e,t,n=process.env){let r=n[_O]?.trim().toLowerCase();return r&&ft.has(r)?{enabled:!0,source:"env"}:r&&qn.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(lm,"resolveTelemetry");function mo(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:Br(e.manifest.manifest,e.manifest.hookConfig),telemetry:pm(e)}}s(mo,"envelopeFieldsFromContext");function pm(e){return lm(e.manifest.localTelemetry,e.manifest.hookConfig)}s(pm,"telemetryFor");function Di(e){return Qn({sessionId:e.sessionId,hostname:Po()})}s(Di,"runnerContextOf");function Gn(e,t,n=Di(e)){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{},context:n}}s(Gn,"operatorContextFrom");function Fi(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:Us(e.manifest.hookConfig)}}s(Fi,"hookInputSanitizeOptions");async function mm(e){let t=Date.now();await kO(e);let{gitRoot:n}=e.manifest;await Bi(e,n);let r=Fi(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:Kr(e.hookInput,e.manifest.manifest,r),envelopeFields:mo(e),launchCwd:Hs(e.hookInput,r),home:SO()}}s(mm,"prepareDerivedInvoke");function fm(e){try{return Ae(hO(e))}catch{return null}}s(fm,"tryRealpath");function gm(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}s(gm,"isAbsolutePath");function dm(e,t){let n=e.replaceAll("\\","/");if(!gm(n))return null;let r=Ae(e),o=Ae(t),i=fm(e)??r,a=fm(t)??o;return i.startsWith(`${a}/`)?i.slice(a.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}s(dm,"relativeToAnchor");function _m(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),i=dm(e,t)??(gm(r)?null:r),a=dm(e,n);return{repositorySourcePath:i,userSourcePath:a}}s(_m,"sourcePathsFromResolvedFile");function Hi(e,t,n,r,o){return hm(e,_m(n,t.gitRoot,t.home),r,o)}s(Hi,"exactFileComponentFromResolvedPath");function hm(e,{repositorySourcePath:t,userSourcePath:n},r,o){let i=t??n,a=i===null?null:o(i),c=a!==null&&i!==null?EO({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(hm,"exactFileComponent");function EO(e){try{let t=e.inRepository?AO(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(EO,"tryExactFileComponentReference");function Sm(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(Sm,"policyPayload");function $i(e,t,n){return on("tool_invoked",{...n,...Sm(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,tn,e.manifest.collectorUrl,t.buildStartedAtMs,Gn(e,t.home))}s($i,"postDerivedToolInvoked");function yO(e){return Du(e.runnerEvent,e.runnerPlatform)?[]:ru(e.hookInput)}s(yO,"slashIdsFromHookInput");function RO(e,t){return $i(e,t,{})}s(RO,"postPromptSubmitted");var Em=new Set([...Object.values(At),".github"]);function AO(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=>Em.has(a));return i<0?null:`${r}:${o.slice(0,i+1).join("/")}`}s(AO,"repositoryConfigRootExternalKey");var ym=".codex/config.toml",CO=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",ym]]);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(h=>h.name.toLowerCase()===t.toLowerCase()),f=u?CO.get(u.source):o==="codex"?ym:void 0,l=u?.sourcePath??f;if((u?.scope==="user"||f!==void 0)&&l)try{let h=(0,V.userConfigRootFromPath)(l);return(0,V.buildComponentReference)({installationRootExternalKey:(0,V.installationRootExternalKey)(r,h),installableKind:V.ComponentKind.INTERFACE,sourcePath:l,nativeKey:u?.name??t})}catch{return}if(n===null)return;let d=n.indexOf(":");if(d<=0||d===n.length-1)return;let m=n.slice(d+1),g=m.replaceAll("\\","/").split("/").at(-1);if(!(g===void 0||!Em.has(g)))try{return(0,V.buildComponentReference)({installationRootExternalKey:n,installableKind:V.ComponentKind.INTERFACE,sourcePath:m,nativeKey:t})}catch{return}}s(bO,"exactMcpComponentReference");function xO(...e){for(let t of e)if(t)return t;return null}s(xO,"firstNonEmpty");function Nt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return P(`WARN: ${n} failed open: ${r}`),D(n,e.reason),t}s(Nt,"settledOr");function OO(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(OO,"emptySelfConfigResult");function IO(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}s(IO,"cloudBootstrapSelfConfig");var Pt=new Set,Kn=null;async function kO(e){if(en())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(Pt.has(t))return;if(!Ns(n)){Pt.add(t);return}let r=String(e.runnerPlatform),o=Di(e);if(Vl(o,r)){if(Kn){await Kn;return}Kn=(async()=>{if(Pt.has(t)||!Ns(n)){Pt.add(t);return}if(!Dc(n)){Pt.add(t);return}let i=!1;try{let a=Date.now(),{gitRoot:c}=e.manifest,{operatorResolved:u,fields:f}=await Rm(e,o,Me("git",()=>kr(c)),Me("operator",()=>Ps({gitRoot:c,installationStorePath:n,forceResend:!1,runnerPlatform:r,context:o}))),l={...f,self_config:IO(r,u.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};i=!!await on("session_start",l,mo(e),tn,e.manifest.collectorUrl,a,Gn(e,void 0,o)),i&&(u.commit(),Pt.add(t))}finally{Fc(n)}})().finally(()=>{Kn=null}),await Kn}}s(kO,"maybeBootstrapCloudIdentity");async function Bi(e,t,n){try{e.platformAgentId=await ku(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);P(`WARN: derivePlatformAgentId failed open: ${o}`),D("platform_agent_id",r)}}s(Bi,"resolvePlatformAgentId");async function Rm(e,t,n,r){let[o,i,a,c,u]=await Promise.allSettled([n,Me("virt",()=>fa()),Me("cloud",()=>El(t)),Me("host_env",()=>pa(pm(e).enabled)),r]),f=Nt(o,null,"gitSnapshot"),l=Nt(i,"","detectVirt"),p=Nt(a,null,"probeCloud"),d=Nt(c,{},"hostEnv"),m=Nt(u,{commit:s(()=>{},"commit")},"resolveOperatorForSend");return await Bi(e,e.manifest.gitRoot,f),{operatorResolved:m,fields:{identity:{host:Po(),context:t,virt:l||null,cloud:p,git:f},host_env:d,env_vars:Ol()}}}s(Rm,"collectIdentityPayload");async function TO(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=Di(e),o=String(e.runnerPlatform),i=Fi(e),a=Hs(e.hookInput,i),c=Me("git",()=>kr(n)),u=Np().catch(L=>(D("launcher_fields",L),{})),f=en()?Promise.resolve({commit:s(()=>{},"commit")}):Me("operator",()=>Ps({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o,context:r})),l=Rm(e,r,c,f),[p,d]=await Promise.allSettled([Me("mcp_declared",()=>bs(e.manifest.manifest,n,o)),c.catch(()=>null).then(L=>Me("self_config",()=>Sp(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:a,inGitRepo:e.manifest.inGitRepo,remote:L?.remote??null})))]),{operatorResolved:m,fields:g}=await l,h=Nt(p,[],"mcpDeclared"),y=Nt(d,OO(o),"selfConfig"),b=y.config,T=$(e.hookInput,"model");T&&(b.model=T);let N={...g,mcp:{declared:h},self_config:b,run_meta:{trigger:e.hookSource||"startup"},hook_input:Kr(e.hookInput,e.manifest.manifest,{...i,launchCwd:a})},O=await u,x=am(e.manifest.collectorUrl),v=!1;try{v=await on("session_start",N,{...mo(e),...O},tn,e.manifest.collectorUrl,t,Gn(e,void 0,r),x)}finally{x?.settle(v)}v&&(y.commit(),m.commit(),Pt.add(e.manifest.installationId))}s(TO,"handleSessionStart");async function PO(e){let t=Date.now(),[,n]=await Promise.all([Bi(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?cm($(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=xO($(e.hookInput,"status"),$(e.hookInput,"stop_reason"),$(e.hookInput,"reason"),Cn($(e.hookInput,"error")),r==="stop"?je(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),i=Kr(e.hookInput,e.manifest.manifest,Fi(e));n&&(i.model=n),r!=="stopfailure"&&Br(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&i.last_assistant_message===void 0&&(i.last_assistant_message=""),await on("session_end",{status:o,...n?{model:n}:{},hook_input:i},mo(e),tn,e.manifest.collectorUrl,t,Gn(e))}s(PO,"handleSessionEnd");async function NO(e){let t=yO(e),n=wu(e.hookInput),r=Hu(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&Br(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let i=await mm(e);await Promise.all([o?RO(e,i):void 0,t.length===0?void 0:wO(e,i,t),n.length===0?void 0:LO(e,i,n)])}s(NO,"handleSkillInvoked");function Am(e,t,n,r){let o=r??nu({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),i=Hi(e,t,o,V.ComponentKind.SKILL,V.nativeKeyForSkillPath);if(i.sourcePath!==null&&es(i.sourcePath)?.toLowerCase()===n.toLowerCase())return i.componentReference===void 0?{}:{componentReference:i.componentReference};let a=r??Lu({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),c=Hi(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(Am,"slashComponentIdentity");function wO(e,t,n){let r=Rr(e.hookInput.tool_input);return Promise.all(n.map(o=>{let i=Am(e,t,o,r);return $i(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(wO,"postSkillInvokes");function LO(e,t,n){return Promise.all(n.map(r=>{let o=Tu({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),i=Hi(e,t,o,V.ComponentKind.RULE,V.nativeKeyForRulePath),a=i.nativeKey??Nu(r);return $i(e,t,{tool_name:"Rule",rule_name:a,...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(LO,"postRuleInvokes");var vO=[{kind:V.ComponentKind.SKILL,nativeKeyFn:V.nativeKeyForSkillPath},{kind:V.ComponentKind.RULE,nativeKeyFn:V.nativeKeyForRulePath},{kind:V.ComponentKind.COMMAND,nativeKeyFn:V.nativeKeyForCommandPath}];function MO(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=ns(e.hookInput);if(r===null)return n.skillName===null?{}:Am(e,t,n.skillName,null);let o=_m(r,t.gitRoot,t.home);for(let i of vO){let a=hm(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(MO,"toolComponentIdentity");var UO=/mcp/i;function HO(e,t,n,r){let o=UO.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let i=o?Hd(t,n):no(r.declaredConfig,n);return i===null?{}:Object.fromEntries(Object.entries(i).filter(a=>typeof a[1]=="string").map(([a,c])=>[`mcp_${a}`,c]))}s(HO,"mcpPackageFields");async function DO(e){let t=await mm(e),n=Bu(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,i=ts(e.hookInput),a=Md(i,t.home),c=Ku(e.hookInput),u=Fu(e.runnerEvent),f=u===!1?Gu(e.hookInput,e.runnerEvent):null,l=Cn($(e.hookInput,"mcp_server_name")),p=l!==null||r!==null&&wr(r)?await bs(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(v=>(D("mcpDeclared",v),[])):[],{mcpServer:d,mcpTool:m}=zu(r,p.map(v=>v.name),l??""),g=bO(r,d,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),p,l),h=g===void 0?MO(e,t,n):{},y=d===null?null:xl(d,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),b=HO(e,i,t.home,{hasMcpIdentity:!!d||!!m,declaredConfig:y}),T=g??h.componentReference,N=h.ruleName??n.ruleName,O=h.commandName??n.commandName,x=ju(e.hookInput);await on("tool_invoked",{tool_name:r,skill_name:o,...N?{rule_name:N}:{},...O?{command_name:O}:{},success:u,duration_ms:c,...a?{executable:a}:{},...f?{failure_reason:f}:{},...d?{mcp_server:d}:{},...m?{mcp_tool:m}:{},...b,...T?{component_reference:T}:{},...x?{subagent_type:x}:{},...Sm(e),hook_input:t.hookInput},t.envelopeFields,tn,e.manifest.collectorUrl,t.buildStartedAtMs,Gn(e,t.home))}s(DO,"handleToolInvoked");async function Cm(e){switch(Ge("w3"),e.internalEvent){case"session_start":await TO(e);return;case"session_end":await PO(e);return;case"skill_invoked":await NO(e);return;case"tool_invoked":await DO(e);return;default:return}}s(Cm,"dispatchInternalEvent");import{existsSync as Ki,readFileSync as FO}from"node:fs";import{dirname as $O,isAbsolute as BO,join as jO,relative as KO}from"node:path";function bm(e){for(let t of $a){let n=jO(e,t);if(Ki(n))return n}}s(bm,"firstExistingManifest");async function GO(e=process.cwd(),t){let n=t??await Io(e);return bm(n)??bm(e)}s(GO,"findRepoManifestPath");async function VO(e,t){let n=t??await Io($O(e)),r=KO(n,e);if(r.startsWith("..")||BO(r))return!1;let o=await xe("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(P(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}s(VO,"isManifestGitTracked");function ji(e){let t=FO(e,"utf8");return Oe(wt(t),{})}s(ji,"loadRepoManifestFromFile");function zO(){return{schema_version:lr,mcp_servers:[]}}s(zO,"defaultSharedManifest");function WO(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(P(`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")&&(P(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}s(WO,"stripTrackedUnsafeFields");function JO(e){let t=Va({argv:e.argv,env:process.env,homeConfig:e.homeConfig,manifest:e.manifest,manifestSource:e.manifestSource});for(let r of t.warnings){P(`WARN: ignoring ${r.label}: ${r.problem}`);let o=r.label.replace(/\s+/g,"_"),i=r.problem.replace(/\/[^/\s]+\/hook\b/g,"/***/hook");ce.error(`collector ignored label=${o} message=${i}`)}let n=t.url??"";return ce.info(`collector source=${t.source} url=${n?Ht(n):"(none)"}`),n}s(JO,"collectorUrlFromLoaded");function YO(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}s(YO,"recordOrUndefined");async function xm(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await Oo(e),o=H("EV_AI_HOOK_MANIFEST"),i=o&&Ki(o)?o:void 0,a=i?void 0:Ki(pt())?pt():void 0,c=i?void 0:await GO(e,n),u=a?ji(a):void 0,f=c?ji(c):void 0,l=um(i?q(pt(),{}):u),p,d,m,g=new Set;if(i){p=ji(i),d=i,m=i;for(let x of Object.keys(p))g.add(x)}else if(u&&f){p=ja(f,u),d=a,m=c;for(let x of Object.keys(f))x in u||g.add(x)}else if(u)p=u,d=a;else if(f){p=f,d=c,m=c;for(let x of Object.keys(f))g.add(x)}else p=zO();delete p.installation_id;let h=m?await VO(m,n):!1;WO(p,m,h,g);let{installationId:y,storePath:b,repoKey:T}=await Kc(n,{sessionId:t.sessionId}),N=u??YO(q(pt(),null)),O=JO({argv:t.argv??process.argv,homeConfig:N,manifest:i?p:f,manifestSource:i?"manifest_override":"manifest"});return{manifestPath:d??b,manifest:p,installationId:y,installationStorePath:b,repoKey:T,collectorUrl:O,hookConfig:vp(O),...l!==void 0?{localTelemetry:l}:{},platformAgentId:p.platform_agent_id??"",gitRoot:n,inGitRepo:r}}s(xm,"loadManifest");import{mkdirSync as XO,readdirSync as qO,readFileSync as ZO,statSync as Om,unlinkSync as QO,writeFileSync as eI}from"node:fs";import{homedir as go}from"node:os";import{join as Gi}from"node:path";var tI="turns",Im=1440*60*1e3,nI=100,rI=new Set(["stop","stopfailure","sessionend"]);function Vi(e=go()){return Gi(Ee(e),tI)}s(Vi,"sessionTurnDir");function km(e,t){return Gi(e,un(t))}s(km,"sessionTurnPath");function oI(e,t=Date.now()){let n;try{n=qO(e)}catch{return}let r=0;for(let o of n){if(r>=nI)return;r+=1;try{let i=Gi(e,o);t-Om(i).mtimeMs>Im&&QO(i)}catch{}}}s(oI,"pruneStaleSessionTurns");function sI(e,t,n=go()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let i=Vi(n);XO(i,{recursive:!0}),eI(km(i,r),o,"utf8")}catch{}}s(sI,"rememberSessionTurn");function iI(e,t=go()){let n=e.trim();if(!n)return"";try{let r=km(Vi(t),n);return Date.now()-Om(r).mtimeMs>Im?"":ZO(r,"utf8").trim()}catch{return""}}s(iI,"recallSessionTurn");function Tm(e,t,n,r=go()){let o=t.trim(),i=rI.has(n.trim().toLowerCase());return i&&oI(Vi(r)),o?(sI(e,o,r),o):i?iI(e,r):""}s(Tm,"resolveTurnId");function Lm(e){let t=Oe(e,{});return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}s(Lm,"parseHookInput");async function aI(e,t,n){let r=t??await Zn(fr),o=Lm(r),i=await xm(process.cwd(),{sessionId:zt(o)});if(Ge("w2"),!i){Q({outcome:"no_manifest"});return}let a=$u(o,i.manifest.platform,n),c=Nr(e,a.runnerEvent);if(!c){P(`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:Tm(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await Cm(u)}s(aI,"runHook");function cI(e,t=!1){if(H("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,i=Vt(r,o,void 0,n.runner);return Pr(o,i)?!0:t}s(cI,"shouldRunHookInProcess");function Pm(e,t){let n=ar(e),r=Lm(t),o=n.event??fs(r);return ua()||Uu(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}s(Pm,"preflight");function vm(e){return ol(Nr(e.parsed.event,e.runnerEvent))}s(vm,"isCapExempt");async function Nm(e,t,n){let{parsed:r}=e,o=n??hs(r.slot);if(!o&&!vm(e)){let i=_s(r.cap),a=ll(i);if(!a){Ss(i),Q({outcome:"cap_dropped"});return}o=a}try{await aI(r.event,t,r.runner)}finally{o&&Mr(o)}}s(Nm,"runHookInSlot");var _o,sn=!1,uI=500;function lI(){let e=s(()=>{process.exit(0)},"exitNow");setTimeout(e,uI);try{process.stdout.write('{"continue":true}',e)}catch{e()}}s(lI,"ackThenExit");function ho(e,t){let n=e[0]===rn?"w":e[0]===po?"post":"h";_o=void 0,sn=!1;let r=s(a=>c=>{try{D(a,c),yc()||(Q({outcome:"error",err:nt(c)}),$t(_o??n,Ke,"error"))}catch{}if(t){if(n==="h"&&!sn){sn=!0,lI();return}process.exit(0)}},"onCrash"),o=r("uncaught"),i=r("unhandled_rejection");return process.on("uncaughtException",o),process.on("unhandledRejection",i),()=>{process.off("uncaughtException",o),process.off("unhandledRejection",i)}}s(ho,"installCrashLogging");async function So(e=process.argv.slice(2),t=!1){if(t||Sc(e),sc(),_o=void 0,sn=!1,Ge(e[0]===rn?"w0":"h0"),fl(),H("EV_AI_HOOK_JUDGE")==="1"){try{await Zn(fr)}catch{}return bo(),sn=!0,0}if(e[0]===po){try{await qp(xo)}catch{}return 0}if(e[0]===rn){let i=!1;try{let a=await xo();Ge("w1");let c=Pm(e.slice(1),a);if(!c)return Q({outcome:"suppressed"}),0;wm(c),i=Nr(c.parsed.event,c.runnerEvent)==="session_start",await Nm(c,a)}catch(a){let c=a instanceof Error?a.message:String(a);P(`WARN: detached work failed open: ${c}`),D("work",a),Q({outcome:"error",err:nt(a)})}finally{$t("w",Ke,"no_post"),i&&Ac()}return 0}let n,r="error",o=!1;try{Rc();let i=await Zn(fr);Ge("h1");let a=Pm(e,i);if(!a)return r="suppressed",0;wm(a);let{parsed:c,hookInput:u,runnerEvent:f}=a;if(n=hs(c.slot),!qu(u,f,c.runner))return r="duplicate",0;if(Ge("h2"),cI(a))o=!0,_o="inproc",r="no_post",await Nm(a,i,n);else{let l=n||vm(a)?void 0:_s(c.cap);if(l===void 0||cl(l)){Ge("h3"),gl();let p=await Qp(i,e);n&&p?.pid!==void 0&&il(n,p.pid),p?.pid!==void 0?r="handed_off":(r="error",Q({err:"spawn"}))}else Ss(l),r="cap_dropped"}}catch(i){let a=i instanceof Error?i.message:String(i);P(`WARN: hook failed open: ${a}`),D("hook",i),r="error",Q({outcome:"error",err:nt(i)})}finally{n&&Mr(n),bo(),sn=!0,Q({ackMs:performance.now()}),$t(o?"inproc":"h",Ke,r)}return 0}s(So,"main");function wm({parsed:e,hookInput:t,runnerEvent:n}){Q({runner:Vt(t,n,void 0,e.runner),event:n,session:zt(t),tool:typeof t.tool_name=="string"?t.tool_name:void 0})}s(wm,"noteInvocation");var fI=Symbol.for(ya);function Mm(){return globalThis[fI]===!0}s(Mm,"isLoadedByLauncher");async function dI(e){Co(e);let t=ho(e.argv,!1);try{return await So(e.argv)}finally{t(),Co(void 0)}}s(dI,"runInLauncher");Mm()||(ho(process.argv.slice(2),!0),So().then(e=>{process.exit(e)}).catch(e=>{D("entry",e);let t=e instanceof Error?e.message:String(e);process.stderr.write(`[ev-ai-agent-hook] ${t}
|
|
58
|
+
`),process.exit(1)}));export{dI as runInLauncher};
|