@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/cli.mjs
CHANGED
|
@@ -2,55 +2,63 @@
|
|
|
2
2
|
import { createRequire as __createRequire } from 'node:module';
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
|
|
5
|
-
var km=Object.create;var Fi=Object.defineProperty;var xm=Object.getOwnPropertyDescriptor;var Om=Object.getOwnPropertyNames;var Im=Object.getPrototypeOf,Tm=Object.prototype.hasOwnProperty;var Ze=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var z=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Pm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Om(t))!Tm.call(e,o)&&o!==n&&Fi(e,o,{get:()=>t[o],enumerable:!(r=xm(t,o))||r.enumerable});return e};var Qe=(e,t,n)=>(n=e!=null?km(Im(e)):{},Pm(t||!e||!e.__esModule?Fi(n,"default",{value:e,enumerable:!0}):n,e));var Sr=z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.MCP_MISSING_LAUNCH_SERIALIZED=Q.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;Q.foldMcpName=lu;Q.buildMcpFamilyCanonicalKey=Yh;Q.launchContainsCredentials=qh;Q.serializeMcpLaunchIdentity=fu;Q.hashMcpLaunchIdentity=an;Q.projectMcpMissingLaunchIdentity=eS;Q.projectMcpLaunchIdentity=tS;Q.maskMcpLaunchForDisplay=rS;Q.normalizeMcpToolNames=oS;var Jh=Ze("node:crypto");Q.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";Q.MCP_MISSING_LAUNCH_SERIALIZED=`${Q.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function Ve(e){return e.toLocaleLowerCase("en-US")}function lu(e){return Ve(e)}function Yh(e){return`interface:${lu(e)}`}var uu=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),Xh=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function Lt(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function qh(e){return e.kind==="url"?Zh(e.url):e.kind==="command"?e.arguments.some(t=>Xh.test(t)):!1}function Zh(e){try{let t=new URL(e);if(t.username.length>0||t.password.length>0)return!0;for(let n of t.searchParams.keys())if(uu.has(Ve(n)))return!0;return!1}catch{let t=e.split("://",2),n=t.length===2?t[1]:e,r=n.indexOf("@"),o=n.indexOf("/");if(r>0&&(o===-1||r<o))return!0;let s=e.split("?",2)[1];return s===void 0?!1:s.split("&").some(i=>{let a=Ve(i.split("=",1)[0]??"");return uu.has(a)})}}function fu(e){if(e.kind==="url")return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",Lt(Ve(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>Ve(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",Lt(Ve(e.command)),String(t.length),...t.map(Lt)].join("|")}return[Q.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",Lt(e.installationRootExternalKey),Lt(e.sourcePath),Lt(e.nativeKey)].join("|")}function an(e){return(0,Jh.createHash)("sha256").update(e).digest("hex")}var Qh=an(Q.MCP_MISSING_LAUNCH_SERIALIZED);function eS(){return{kind:"unknown",arguments:[],serialized:Q.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:Qh}}function tS(e){let t=fu(e);return e.kind==="url"?{kind:"url",url:Ve(e.url),arguments:[],serialized:t,contentHash:an(t)}:e.kind==="command"?{kind:"command",command:Ve(e.command),arguments:[...e.arguments].map(n=>Ve(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:an(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:an(t)}}var nS=/^(https?:\/\/)([^/?#]*@)/i;function rS(e){return e.replace(nS,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}function oS(e){let t=new Set,n=[];for(let r of e)r.length===0||t.has(r)||(t.add(r),n.push(r));return n.sort((r,o)=>r<o?-1:r>o?1:0),n}});var yr=z(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.PACKAGE_FIELD_MAX=void 0;we.npxExecBin=du;we.packageNameFromSpec=Er;we.pinnedPackageVersionFromSpec=pu;we.pinnedPackageVersionFromNpx=pS;we.npxPackageSpecs=mu;we.PACKAGE_FIELD_MAX=128;var sS=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,iS=new Set(["-p","--package"]),aS=new Set(["-c","--call"]),cS=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),uS=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),lS=/^--no-/;function fS(e){return uS.has(e)||lS.test(e)}function du(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}var dS=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function Er(e){if(e.length===0||e.length>we.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return sS.test(n)?n:null}function pu(e){let t=Er(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return dS.test(n)?n:void 0}function pS(e,t){for(let n of mu(e,t)){let r=pu(n);if(r!==void 0)return r}}function mu(e,t){let n=du(e);if(n===null)return[];let r=[...t];if(n==="npm"){let i=r[0]?.toLowerCase();if(i!=="exec"&&i!=="x")return[];r=r.slice(1)}let o=[],s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(aS.has(l))return[];if(iS.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&o.push(u),c===-1&&(i+=1);continue}if(!(c!==-1||fS(l))){if(cS.has(l)){i+=1;continue}return[]}}return o.length>0?o.every(i=>Er(i)!==null)?o:[]:s===null||Er(s)===null?[]:[s]}});var gu=z(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.McpPackageEcosystem=void 0;ht.resolveMcpPackageIdentity=xS;var mS=Sr(),qo=yr();ht.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var gS=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,_S=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,hS=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function SS(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}var ES=new Set(["--from","--spec"]),yS=new Set(["--python","-p","--with","--with-editable","--with-requirements","--index","--index-url","--default-index","--extra-index-url","--find-links","-f","--constraint","-c","--override","--refresh-package","--cache-dir","--directory","--project","--config-file","--color","--exclude-newer","--pip-args","--verbose-pip"]),RS=new Set(["-q","--quiet","-v","--verbose","-n","--native-tls","--offline","--isolated","--preview","--refresh","--reinstall","--upgrade","-U","--force","--system","--system-site-packages","--path","--managed-python","--progress"]),CS=/^--no-/;function AS(e,t){let n=SS(e);if(n===null)return null;let r=[...t];if(n==="uv"){if(r[0]?.toLowerCase()!=="tool"||r[1]?.toLowerCase()!=="run")return null;r=r.slice(2)}else if(n==="pipx"){if(r[0]?.toLowerCase()!=="run")return null;r=r.slice(1)}let o=null,s=null;for(let i=0;i<r.length;i+=1){let a=r[i]??"";if(a==="--"){s=r[i+1]??null;break}if(!a.startsWith("-")){s=a;break}let c=a.indexOf("="),l=c===-1?a:a.slice(0,c);if(ES.has(l)){let u=c===-1?r[i+1]:a.slice(c+1);u!==void 0&&u.length>0&&(o=u),c===-1&&(i+=1);continue}if(!(c!==-1||RS.has(l)||CS.test(l))){if(yS.has(l)){i+=1;continue}return null}}return o??s}function bS(e){if(e.length===0||e.length>qo.PACKAGE_FIELD_MAX)return null;let t=e.includes("==")?"==":e.includes("@")?"@":null;if(t===null)return null;let n=e.indexOf(t),r=e.slice(0,n),o=e.slice(n+t.length);return!_S.test(r)||!hS.test(o)?null:{ecosystem:ht.McpPackageEcosystem.PYPI,packageName:r,version:o}}function kS(e){let t=(0,qo.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return gS.test(n)?{ecosystem:ht.McpPackageEcosystem.NPM,packageName:t,version:n}:null}function xS(e){if(e?.kind!=="command"||(0,mS.launchContainsCredentials)(e))return;for(let n of(0,qo.npxPackageSpecs)(e.command,e.arguments)){let r=kS(n);if(r!==null)return r}let t=AS(e.command,e.arguments);if(t!==null)return bS(t)??void 0}});var Ru=z(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.EMPTY_NPM_PUBLISHER=void 0;We.isNpmRegistryPublisher=IS;We.displayPublisherName=TS;We.classifyMcpProvenance=DS;var Su=Sr(),Zo=yr();We.EMPTY_NPM_PUBLISHER="npm:";var _u="npm:",OS=/^[A-Za-z0-9._-]+$/;function IS(e){return e.startsWith(_u)&&e!==We.EMPTY_NPM_PUBLISHER&&OS.test(e.slice(_u.length))}function TS(e){if(!(e==null||e===""||e===We.EMPTY_NPM_PUBLISHER))return e}function hu(e){let t=e.split(".").map(Number);return t.length!==4||t.some(n=>!Number.isInteger(n)||n<0||n>255)?!1:t[0]===0||t[0]===10||t[0]===127||t[0]===169&&t[1]===254||t[0]===172&&(t[1]??0)>=16&&(t[1]??0)<=31||t[0]===192&&t[1]===168}function PS(e){let t=/^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(e);if(t?.[1])return t[1];let n=/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(e);if(!n)return;let r=Number.parseInt(n[1],16),o=Number.parseInt(n[2],16);return`${r>>8&255}.${r&255}.${o>>8&255}.${o&255}`}function Qo(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}function wS(e){let t=Qo(e),n=PS(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||hu(t)||n!==void 0&&hu(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}function NS(e){let t=Qo(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}function vS(e){let t=Qo(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}function Eu(e){let t={kind:"url",url:e};if((0,Su.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||wS(n.hostname))return{origin:"UNKNOWN"};let r=NS(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:vS(n)}}catch{return{origin:"UNKNOWN"}}}var yu="mcp-remote";function MS(e,t){if(e===yu)return t.find(n=>/^https?:\/\//i.test(n))}function LS(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}function HS(e,t,n){let r=MS(e,t);return r!==void 0?Eu(r):e===yu?{origin:"UNKNOWN"}:LS(e,n)}function US(e){let t=e.replaceAll("\\","/");return t.startsWith("~/")||t.startsWith("/")||/^[A-Za-z]:\//.test(t)?!1:t.startsWith("./")||t.startsWith("../")||t==="scripts"||t.startsWith("scripts/")}function DS(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,Su.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return Eu(t.url);let r=(0,Zo.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,Zo.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let s=HS(o,t.arguments,e.publisherName),i=typeof e.packageName=="string"?(0,Zo.packageNameFromSpec)(e.packageName):null;return i!==null&&i===o&&s.packageName!==void 0?{...s,packageName:i,packageKey:i}:s}return US(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}});var Au=z(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.mcpServerToolSegmentForms=Cu;Rr.mcpServerNameMatchesToolSegment=FS;function Cu(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}function FS(e,t){let n=t.toLowerCase();return Cu(e).some(r=>r.toLowerCase()===n)}});var bu=z(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.parseFrontmatterField=be.parseFrontmatterDescription=be.usableCatalogText=void 0;var $S=/^(?:>|\|)[-+]?$/,jS=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,BS=e=>{let t=e?.trim()??"";if(!(t.length===0||$S.test(t)))return t};be.usableCatalogText=BS;var KS=e=>(0,be.parseFrontmatterField)(e,"description");be.parseFrontmatterDescription=KS;var GS=(e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return WS(n[1],t)};be.parseFrontmatterField=GS;var VS=e=>e.replace(/^["']|["']$/g,"");function WS(e,t){let n=e.split(`
|
|
6
|
-
`),r=`${t}:`,o=n.findIndex(
|
|
7
|
-
`).split(/\n{2,}/).map(
|
|
8
|
-
`).map(g=>g.trim()).filter(Boolean).join(" ")).filter(
|
|
5
|
+
var vg=Object.create;var Ho=Object.defineProperty;var Lg=Object.getOwnPropertyDescriptor;var Mg=Object.getOwnPropertyNames;var Hg=Object.getPrototypeOf,Ug=Object.prototype.hasOwnProperty;var s=(e,t)=>Ho(e,"name",{value:t,configurable:!0}),rt=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Y=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Dg=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Mg(t))!Ug.call(e,o)&&o!==n&&Ho(e,o,{get:()=>t[o],enumerable:!(r=Lg(t,o))||r.enumerable});return e};var ot=(e,t,n)=>(n=e!=null?vg(Hg(e)):{},Dg(t||!e||!e.__esModule?Ho(n,"default",{value:e,enumerable:!0}):n,e));var $r=Y(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.MCP_MISSING_LAUNCH_SERIALIZED=ne.MCP_LAUNCH_IDENTITY_ALGORITHM=void 0;ne.foldMcpName=al;ne.buildMcpFamilyCanonicalKey=DE;ne.launchContainsCredentials=$E;ne.serializeMcpLaunchIdentity=cl;ne.hashMcpLaunchIdentity=Pn;ne.projectMcpMissingLaunchIdentity=KE;ne.projectMcpLaunchIdentity=GE;ne.maskMcpLaunchForDisplay=VE;ne.normalizeMcpToolNames=zE;var UE=rt("node:crypto");ne.MCP_LAUNCH_IDENTITY_ALGORITHM="mcp-launch-v1";ne.MCP_MISSING_LAUNCH_SERIALIZED=`${ne.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;function qe(e){return e.toLocaleLowerCase("en-US")}s(qe,"foldCase");function al(e){return qe(e)}s(al,"foldMcpName");function DE(e){return`interface:${al(e)}`}s(DE,"buildMcpFamilyCanonicalKey");var il=new Set(["access_token","api_key","apikey","auth","authorization","key","password","secret","token"]),FE=/^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;function Zt(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(Zt,"lengthPrefixed");function $E(e){return e.kind==="url"?jE(e.url):e.kind==="command"?e.arguments.some(t=>FE.test(t)):!1}s($E,"launchContainsCredentials");function jE(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(il.has(qe(n)))return!0;return!1}catch{let t=e.split("://",2),n=t.length===2?t[1]:e,r=n.indexOf("@"),o=n.indexOf("/");if(r>0&&(o===-1||r<o))return!0;let i=e.split("?",2)[1];return i===void 0?!1:i.split("&").some(a=>{let c=qe(a.split("=",1)[0]??"");return il.has(c)})}}s(jE,"urlContainsCredentials");function cl(e){if(e.kind==="url")return[ne.MCP_LAUNCH_IDENTITY_ALGORITHM,"url",Zt(qe(e.url))].join("|");if(e.kind==="command"){let t=[...e.arguments].map(n=>qe(n)).sort((n,r)=>n<r?-1:n>r?1:0);return[ne.MCP_LAUNCH_IDENTITY_ALGORITHM,"command",Zt(qe(e.command)),String(t.length),...t.map(Zt)].join("|")}return[ne.MCP_LAUNCH_IDENTITY_ALGORITHM,"unknown",Zt(e.installationRootExternalKey),Zt(e.sourcePath),Zt(e.nativeKey)].join("|")}s(cl,"serializeMcpLaunchIdentity");function Pn(e){return(0,UE.createHash)("sha256").update(e).digest("hex")}s(Pn,"hashMcpLaunchIdentity");var BE=Pn(ne.MCP_MISSING_LAUNCH_SERIALIZED);function KE(){return{kind:"unknown",arguments:[],serialized:ne.MCP_MISSING_LAUNCH_SERIALIZED,contentHash:BE}}s(KE,"projectMcpMissingLaunchIdentity");function GE(e){let t=cl(e);return e.kind==="url"?{kind:"url",url:qe(e.url),arguments:[],serialized:t,contentHash:Pn(t)}:e.kind==="command"?{kind:"command",command:qe(e.command),arguments:[...e.arguments].map(n=>qe(n)).sort((n,r)=>n<r?-1:n>r?1:0),serialized:t,contentHash:Pn(t)}:{kind:"unknown",arguments:[],serialized:t,contentHash:Pn(t)}}s(GE,"projectMcpLaunchIdentity");var WE=/^(https?:\/\/)([^/?#]*@)/i;function VE(e){return e.replace(WE,"$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi,"$1***")}s(VE,"maskMcpLaunchForDisplay");function zE(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(zE,"normalizeMcpToolNames")});var Br=Y(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.PACKAGE_FIELD_MAX=void 0;Ue.npxExecBin=ul;Ue.packageNameFromSpec=jr;Ue.pinnedPackageVersionFromSpec=ll;Ue.pinnedPackageVersionFromNpx=ny;Ue.npxPackageSpecs=fl;Ue.PACKAGE_FIELD_MAX=128;var JE=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,YE=new Set(["-p","--package"]),XE=new Set(["-c","--call"]),qE=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),ZE=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),QE=/^--no-/;function ey(e){return ZE.has(e)||QE.test(e)}s(ey,"booleanFlag");function ul(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}s(ul,"npxExecBin");var ty=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;function jr(e){if(e.length===0||e.length>Ue.PACKAGE_FIELD_MAX)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return JE.test(n)?n:null}s(jr,"packageNameFromSpec");function ll(e){let t=jr(e);if(t===null||!e.startsWith(`${t}@`))return;let n=e.slice(t.length+1);return ty.test(n)?n:void 0}s(ll,"pinnedPackageVersionFromSpec");function ny(e,t){for(let n of fl(e,t)){let r=ll(n);if(r!==void 0)return r}}s(ny,"pinnedPackageVersionFromNpx");function fl(e,t){let n=ul(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(XE.has(f))return[];if(YE.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||ey(f))){if(qE.has(f)){a+=1;continue}return[]}}return o.length>0?o.every(a=>jr(a)!==null)?o:[]:i===null||jr(i)===null?[]:[i]}s(fl,"npxPackageSpecs")});var dl=Y(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.McpPackageEcosystem=void 0;wt.resolveMcpPackageIdentity=gy;var ry=$r(),Ps=Br();wt.McpPackageEcosystem={NPM:"npm",PYPI:"pypi"};var oy=/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/,sy=/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/,iy=/^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;function ay(e){let n=(e.replaceAll("\\","/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="uvx"||n==="uv"||n==="pipx"?n:null}s(ay,"pythonRunnerBin");var cy=new Set(["--from","--spec"]),uy=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"]),ly=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"]),fy=/^--no-/;function dy(e,t){let n=ay(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(cy.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||ly.has(f)||fy.test(f))){if(uy.has(f)){a+=1;continue}return null}}return o??i}s(dy,"pythonRunnerSpec");function py(e){if(e.length===0||e.length>Ps.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!sy.test(r)||!iy.test(o)?null:{ecosystem:wt.McpPackageEcosystem.PYPI,packageName:r,version:o}}s(py,"pypiIdentityFromSpec");function my(e){let t=(0,Ps.packageNameFromSpec)(e);if(t===null||!e.startsWith(`${t}@`))return null;let n=e.slice(t.length+1);return oy.test(n)?{ecosystem:wt.McpPackageEcosystem.NPM,packageName:t,version:n}:null}s(my,"npmIdentityFromSpec");function gy(e){if(e?.kind!=="command"||(0,ry.launchContainsCredentials)(e))return;for(let n of(0,Ps.npxPackageSpecs)(e.command,e.arguments)){let r=my(n);if(r!==null)return r}let t=dy(e.command,e.arguments);if(t!==null)return py(t)??void 0}s(gy,"resolveMcpPackageIdentity")});var Sl=Y(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.EMPTY_NPM_PUBLISHER=void 0;Ze.isNpmRegistryPublisher=hy;Ze.displayPublisherName=Sy;Ze.classifyMcpProvenance=Oy;var gl=$r(),ws=Br();Ze.EMPTY_NPM_PUBLISHER="npm:";var pl="npm:",_y=/^[A-Za-z0-9._-]+$/;function hy(e){return e.startsWith(pl)&&e!==Ze.EMPTY_NPM_PUBLISHER&&_y.test(e.slice(pl.length))}s(hy,"isNpmRegistryPublisher");function Sy(e){if(!(e==null||e===""||e===Ze.EMPTY_NPM_PUBLISHER))return e}s(Sy,"displayPublisherName");function ml(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(ml,"privateIpv4");function Ey(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(Ey,"ipv4MappedAddress");function Ns(e){return e.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.$/,"")}s(Ns,"normalizedHost");function yy(e){let t=Ns(e),n=Ey(t);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||t.endsWith(".local")||!t.includes(".")&&!t.includes(":")||ml(t)||n!==void 0&&ml(n)||/^(?:fc|fd)[0-9a-f]{2}:/i.test(t)||/^fe[89ab][0-9a-f]:/i.test(t)}s(yy,"privateHostname");function Ry(e){let t=Ns(e);return t.includes(":")||/^[0-9.]+$/.test(t)||t.split(".").filter(Boolean).length<2?null:t}s(Ry,"publisherHost");function Cy(e){let t=Ns(e.hostname),n=t.includes(":")?`[${t}]`:t,r=e.port?`:${e.port}`:"";return`${e.protocol}//${n}${r}`}s(Cy,"publicOrigin");function _l(e){let t={kind:"url",url:e};if((0,gl.launchContainsCredentials)(t))return{origin:"UNKNOWN"};try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol)||yy(n.hostname))return{origin:"UNKNOWN"};let r=Ry(n.hostname);return{origin:"THIRD_PARTY",...r===null?{}:{publisherName:r},packageSourceUrl:Cy(n)}}catch{return{origin:"UNKNOWN"}}}s(_l,"classifyUrl");var hl="mcp-remote";function Ay(e,t){if(e===hl)return t.find(n=>/^https?:\/\//i.test(n))}s(Ay,"remoteUrlChild");function by(e,t){return{origin:"THIRD_PARTY",...t?{publisherName:t}:{},packageName:e,packageKey:e}}s(by,"thirdPartyPackage");function ky(e,t,n){let r=Ay(e,t);return r!==void 0?_l(r):e===hl?{origin:"UNKNOWN"}:by(e,n)}s(ky,"classifyRegistryPackage");function xy(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(xy,"isRepoRelativeCommand");function Oy(e){let t=e.launch;if(t===void 0||t.kind==="unknown")return{origin:"UNKNOWN"};if((0,gl.launchContainsCredentials)(t))return{origin:"UNKNOWN"};if(t.kind==="url")return _l(t.url);let r=(0,ws.npxPackageSpecs)(t.command,t.arguments)[0];if(r!==void 0){let o=(0,ws.packageNameFromSpec)(r);if(o===null)return{origin:"UNKNOWN"};let i=ky(o,t.arguments,e.publisherName),a=typeof e.packageName=="string"?(0,ws.packageNameFromSpec)(e.packageName):null;return a!==null&&a===o&&i.packageName!==void 0?{...i,packageName:a,packageKey:a}:i}return xy(t.command)?{origin:"INTERNAL"}:{origin:"UNKNOWN"}}s(Oy,"classifyMcpProvenance")});var yl=Y(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.mcpServerToolSegmentForms=El;Kr.mcpServerNameMatchesToolSegment=Iy;function El(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}s(El,"mcpServerToolSegmentForms");function Iy(e,t){let n=t.toLowerCase();return El(e).some(r=>r.toLowerCase()===n)}s(Iy,"mcpServerNameMatchesToolSegment")});var Rl=Y(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.parseFrontmatterField=Pe.parseFrontmatterDescription=Pe.usableCatalogText=void 0;var Ty=/^(?:>|\|)[-+]?$/,Py=/^(?:>|\|)[-+]?(?:\s+(.*))?$/,wy=s(e=>{let t=e?.trim()??"";if(!(t.length===0||Ty.test(t)))return t},"usableCatalogText");Pe.usableCatalogText=wy;var Ny=s(e=>(0,Pe.parseFrontmatterField)(e,"description"),"parseFrontmatterDescription");Pe.parseFrontmatterDescription=Ny;var vy=s((e,t)=>{let n=/^---\s*\n([\s\S]*?)\n---/.exec(e);if(n)return My(n[1],t)},"parseFrontmatterField");Pe.parseFrontmatterField=vy;var Ly=s(e=>e.replace(/^["']|["']$/g,""),"stripYamlQuotes");function My(e,t){let n=e.split(`
|
|
6
|
+
`),r=`${t}:`,o=n.findIndex(m=>m===r||m.startsWith(`${r} `)||m.startsWith(`${r} `));if(o<0)return;let i=(n[o]??"").slice(r.length).trim(),a=Py.exec(i);if(!a){let m=Ly(i).trim();return(0,Pe.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(`
|
|
7
|
+
`).split(/\n{2,}/).map(m=>m.split(`
|
|
8
|
+
`).map(g=>g.trim()).filter(Boolean).join(" ")).filter(m=>m.length>0).join(`
|
|
9
9
|
|
|
10
|
-
`):
|
|
11
|
-
`).trimEnd();return(0,
|
|
12
|
-
`),n=!1;return t.map(o=>n?
|
|
13
|
-
`)}function tE(e){return es(e)!==e}});var lt=z(y=>{"use strict";Object.defineProperty(y,"__esModule",{value:!0});y.redactComponentSource=y.prepareComponentInspectionText=y.fitSnapshotInspectionTextBudget=y.componentSourceContainsRedactableSecret=y.capComponentTextBytes=y.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=y.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=y.COMPONENT_INSPECTION_TEXT_MAX_BYTES=y.usableCatalogText=y.parseFrontmatterField=y.parseFrontmatterDescription=y.mcpServerToolSegmentForms=y.mcpServerNameMatchesToolSegment=y.isNpmRegistryPublisher=y.EMPTY_NPM_PUBLISHER=y.displayPublisherName=y.classifyMcpProvenance=y.resolveMcpPackageIdentity=y.McpPackageEcosystem=y.pinnedPackageVersionFromSpec=y.pinnedPackageVersionFromNpx=y.packageNameFromSpec=y.npxPackageSpecs=y.npxExecBin=y.PACKAGE_FIELD_MAX=y.serializeMcpLaunchIdentity=y.projectMcpMissingLaunchIdentity=y.projectMcpLaunchIdentity=y.normalizeMcpToolNames=y.MCP_MISSING_LAUNCH_SERIALIZED=y.MCP_LAUNCH_IDENTITY_ALGORITHM=y.maskMcpLaunchForDisplay=y.launchContainsCredentials=y.hashMcpLaunchIdentity=y.foldMcpName=y.buildMcpFamilyCanonicalKey=y.ComponentKind=void 0;y.userConfigRootFromPath=fE;y.installationRootExternalKey=dE;y.normalizeRepositoryRelativePath=Iu;y.nativeKeyForSkillPath=pE;y.nativeKeyForRulePath=mE;y.nativeKeyForCommandPath=gE;y.serializeComponentIdentity=Pu;y.buildComponentReference=hE;y.validateComponentReference=SE;var nE=Ze("node:crypto"),rE=Ze("node:path"),oE="cmp1_",sE=/^cmp1_[A-Za-z0-9_-]{43}$/,iE=["/skills/","/skills-cursor/"],aE=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,cE=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,uE=[".cursor",".claude",".codex"],lE={".claude.json":".claude",".agents":".codex"};y.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function fE(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>uE.includes(o));return n||(t.map(o=>lE[o]).find(o=>o!==void 0)??"unknown")}function dE(e,t){return`runtime-install:${e}/${t}`}function Cr(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function Iu(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=rE.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Cr(n,"sourcePath")}function pE(e){let t=e.replaceAll("\\","/");for(let n of iE){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function Tu(e,t,n){let r=e.replaceAll("\\","/"),s=t.exec(r)?.[1];if(!s||s.split("/").includes(".."))return null;let i=s.replace(n,"");return i.length>0?i:null}function mE(e){return Tu(e,aE,/\.(mdc|md|rules)$/i)}function gE(e){return Tu(e,cE,/\.(md|mdc|toml)$/i)}function _E(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Pu(e){let t=[Cr(e.installationRootExternalKey,"installationRootExternalKey"),Cr(e.installableKind,"installableKind"),Iu(e.sourcePath),Cr(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(_E).join("|")}`,"utf8")}function hE(e){let t=(0,nE.createHash)("sha256").update(Pu(e)).digest("base64url");return`${oE}${t}`}function SE(e){return sE.test(e)}var ke=Sr();Object.defineProperty(y,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:function(){return ke.buildMcpFamilyCanonicalKey}});Object.defineProperty(y,"foldMcpName",{enumerable:!0,get:function(){return ke.foldMcpName}});Object.defineProperty(y,"hashMcpLaunchIdentity",{enumerable:!0,get:function(){return ke.hashMcpLaunchIdentity}});Object.defineProperty(y,"launchContainsCredentials",{enumerable:!0,get:function(){return ke.launchContainsCredentials}});Object.defineProperty(y,"maskMcpLaunchForDisplay",{enumerable:!0,get:function(){return ke.maskMcpLaunchForDisplay}});Object.defineProperty(y,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:function(){return ke.MCP_LAUNCH_IDENTITY_ALGORITHM}});Object.defineProperty(y,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:function(){return ke.MCP_MISSING_LAUNCH_SERIALIZED}});Object.defineProperty(y,"normalizeMcpToolNames",{enumerable:!0,get:function(){return ke.normalizeMcpToolNames}});Object.defineProperty(y,"projectMcpLaunchIdentity",{enumerable:!0,get:function(){return ke.projectMcpLaunchIdentity}});Object.defineProperty(y,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:function(){return ke.projectMcpMissingLaunchIdentity}});Object.defineProperty(y,"serializeMcpLaunchIdentity",{enumerable:!0,get:function(){return ke.serializeMcpLaunchIdentity}});var Ht=yr();Object.defineProperty(y,"PACKAGE_FIELD_MAX",{enumerable:!0,get:function(){return Ht.PACKAGE_FIELD_MAX}});Object.defineProperty(y,"npxExecBin",{enumerable:!0,get:function(){return Ht.npxExecBin}});Object.defineProperty(y,"npxPackageSpecs",{enumerable:!0,get:function(){return Ht.npxPackageSpecs}});Object.defineProperty(y,"packageNameFromSpec",{enumerable:!0,get:function(){return Ht.packageNameFromSpec}});Object.defineProperty(y,"pinnedPackageVersionFromNpx",{enumerable:!0,get:function(){return Ht.pinnedPackageVersionFromNpx}});Object.defineProperty(y,"pinnedPackageVersionFromSpec",{enumerable:!0,get:function(){return Ht.pinnedPackageVersionFromSpec}});var wu=gu();Object.defineProperty(y,"McpPackageEcosystem",{enumerable:!0,get:function(){return wu.McpPackageEcosystem}});Object.defineProperty(y,"resolveMcpPackageIdentity",{enumerable:!0,get:function(){return wu.resolveMcpPackageIdentity}});var Ar=Ru();Object.defineProperty(y,"classifyMcpProvenance",{enumerable:!0,get:function(){return Ar.classifyMcpProvenance}});Object.defineProperty(y,"displayPublisherName",{enumerable:!0,get:function(){return Ar.displayPublisherName}});Object.defineProperty(y,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:function(){return Ar.EMPTY_NPM_PUBLISHER}});Object.defineProperty(y,"isNpmRegistryPublisher",{enumerable:!0,get:function(){return Ar.isNpmRegistryPublisher}});var Nu=Au();Object.defineProperty(y,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:function(){return Nu.mcpServerNameMatchesToolSegment}});Object.defineProperty(y,"mcpServerToolSegmentForms",{enumerable:!0,get:function(){return Nu.mcpServerToolSegmentForms}});var ts=bu();Object.defineProperty(y,"parseFrontmatterDescription",{enumerable:!0,get:function(){return ts.parseFrontmatterDescription}});Object.defineProperty(y,"parseFrontmatterField",{enumerable:!0,get:function(){return ts.parseFrontmatterField}});Object.defineProperty(y,"usableCatalogText",{enumerable:!0,get:function(){return ts.usableCatalogText}});var ut=Ou();Object.defineProperty(y,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return ut.COMPONENT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:function(){return ut.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}});Object.defineProperty(y,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:function(){return ut.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES}});Object.defineProperty(y,"capComponentTextBytes",{enumerable:!0,get:function(){return ut.capComponentTextBytes}});Object.defineProperty(y,"componentSourceContainsRedactableSecret",{enumerable:!0,get:function(){return ut.componentSourceContainsRedactableSecret}});Object.defineProperty(y,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:function(){return ut.fitSnapshotInspectionTextBudget}});Object.defineProperty(y,"prepareComponentInspectionText",{enumerable:!0,get:function(){return ut.prepareComponentInspectionText}});Object.defineProperty(y,"redactComponentSource",{enumerable:!0,get:function(){return ut.redactComponentSource}})});var Gr=z(Ce=>{"use strict";Ce.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Ce.find=(e,t)=>e.nodes.find(n=>n.type===t);Ce.exceedsLimit=(e,t,n=1,r)=>r===!1||!Ce.isInteger(e)||!Ce.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Ce.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||r.type==="open"||r.type==="close")&&r.escaped!==!0&&(r.value="\\"+r.value,r.escaped=!0)};Ce.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Ce.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;Ce.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Ce.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Ce.flatten=(...e)=>{let t=[],n=r=>{for(let o=0;o<r.length;o++){let s=r[o];if(Array.isArray(s)){n(s);continue}s!==void 0&&t.push(s)}return t};return n(e),t}});var Vr=z((ZP,Ef)=>{"use strict";var Sf=Gr();Ef.exports=(e,t={})=>{let n=(r,o={})=>{let s=t.escapeInvalid&&Sf.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a="";if(r.value)return(s||i)&&Sf.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let c of r.nodes)a+=n(c);return a};return n(e)}});var Rf=z((QP,yf)=>{"use strict";yf.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var Pf=z((ew,Tf)=>{"use strict";var Cf=Rf(),Et=(e,t,n)=>{if(Cf(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(Cf(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...n};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let o=String(r.relaxZeros),s=String(r.shorthand),i=String(r.capture),a=String(r.wrap),c=e+":"+t+"="+o+s+i+a;if(Et.cache.hasOwnProperty(c))return Et.cache[c].result;let l=Math.min(e,t),u=Math.max(e,t);if(Math.abs(l-u)===1){let S=e+"|"+t;return r.capture?`(${S})`:r.wrap===!1?S:`(?:${S})`}let d=If(e)||If(t),f={min:e,max:t,a:l,b:u},p=[],g=[];if(d&&(f.isPadded=d,f.maxLen=String(f.max).length),l<0){let S=u<0?Math.abs(u):1;g=Af(S,Math.abs(l),f,r),l=f.a=0}return u>=0&&(p=Af(l,u,f,r)),f.negatives=g,f.positives=p,f.result=nC(g,p,r),r.capture===!0?f.result=`(${f.result})`:r.wrap!==!1&&p.length+g.length>1&&(f.result=`(?:${f.result})`),Et.cache[c]=f,f.result};function nC(e,t,n){let r=Ds(e,t,"-",!1,n)||[],o=Ds(t,e,"",!1,n)||[],s=Ds(e,t,"-?",!0,n)||[];return r.concat(s).concat(o).join("|")}function rC(e,t){let n=1,r=1,o=kf(e,n),s=new Set([t]);for(;e<=o&&o<=t;)s.add(o),n+=1,o=kf(e,n);for(o=xf(t+1,r)-1;e<o&&o<=t;)s.add(o),r+=1,o=xf(t+1,r)-1;return s=[...s],s.sort(iC),s}function oC(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=sC(e,t),o=r.length,s="",i=0;for(let a=0;a<o;a++){let[c,l]=r[a];c===l?s+=c:c!=="0"||l!=="9"?s+=aC(c,l,n):i++}return i&&(s+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:s,count:[i],digits:o}}function Af(e,t,n,r){let o=rC(e,t),s=[],i=e,a;for(let c=0;c<o.length;c++){let l=o[c],u=oC(String(i),String(l),r),d="";if(!n.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+Of(a.count),i=l+1;continue}n.isPadded&&(d=cC(l,n,r)),u.string=d+u.pattern+Of(u.count),s.push(u),i=l+1,a=u}return s}function Ds(e,t,n,r,o){let s=[];for(let i of e){let{string:a}=i;!r&&!bf(t,"string",a)&&s.push(n+a),r&&bf(t,"string",a)&&s.push(n+a)}return s}function sC(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}function iC(e,t){return e>t?1:t>e?-1:0}function bf(e,t,n){return e.some(r=>r[t]===n)}function kf(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}function xf(e,t){return e-e%Math.pow(10,t)}function Of(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}function aC(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}function If(e){return/^-?(0+)\d/.test(e)}function cC(e,t,n){if(!t.isPadded)return e;let r=Math.abs(t.maxLen-String(e).length),o=n.relaxZeros!==!1;switch(r){case 0:return"";case 1:return o?"0?":"0";case 2:return o?"0{0,2}":"00";default:return o?`0{0,${r}}`:`0{${r}}`}}Et.cache={};Et.clearCache=()=>Et.cache={};Tf.exports=Et});var js=z((tw,Uf)=>{"use strict";var uC=Ze("util"),Nf=Pf(),wf=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),lC=e=>t=>e===!0?Number(t):String(t),Fs=e=>typeof e=="number"||typeof e=="string"&&e!=="",En=e=>Number.isInteger(+e),$s=e=>{let t=`${e}`,n=-1;if(t[0]==="-"&&(t=t.slice(1)),t==="0")return!1;for(;t[++n]==="0";);return n>0},fC=(e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,dC=(e,t,n)=>{if(t>0){let r=e[0]==="-"?"-":"";r&&(e=e.slice(1)),e=r+e.padStart(r?t-1:t,"0")}return n===!1?String(e):e},zr=(e,t)=>{let n=e[0]==="-"?"-":"";for(n&&(e=e.slice(1),t--);e.length<t;)e="0"+e;return n?"-"+e:e},pC=(e,t,n)=>{e.negatives.sort((a,c)=>a<c?-1:a>c?1:0),e.positives.sort((a,c)=>a<c?-1:a>c?1:0);let r=t.capture?"":"?:",o="",s="",i;return e.positives.length&&(o=e.positives.map(a=>zr(String(a),n)).join("|")),e.negatives.length&&(s=`-(${r}${e.negatives.map(a=>zr(String(a),n)).join("|")})`),o&&s?i=`${o}|${s}`:i=o||s,t.wrap?`(${r}${i})`:i},vf=(e,t,n,r)=>{if(n)return Nf(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let s=String.fromCharCode(t);return`[${o}-${s}]`},Mf=(e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return Nf(e,t,n)},Lf=(...e)=>new RangeError("Invalid range arguments: "+uC.inspect(...e)),Hf=(e,t,n)=>{if(n.strictRanges===!0)throw Lf([e,t]);return[]},mC=(e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},gC=(e,t,n=1,r={})=>{let o=Number(e),s=Number(t);if(!Number.isInteger(o)||!Number.isInteger(s)){if(r.strictRanges===!0)throw Lf([e,t]);return[]}o===0&&(o=0),s===0&&(s=0);let i=o>s,a=String(e),c=String(t),l=String(n);n=Math.max(Math.abs(n),1);let u=$s(a)||$s(c)||$s(l),d=u?Math.max(a.length,c.length,l.length):0,f=u===!1&&fC(e,t,r)===!1,p=r.transform||lC(f);if(r.toRegex&&n===1)return vf(zr(e,d),zr(t,d),!0,r);let g={negatives:[],positives:[]},S=I=>g[I<0?"negatives":"positives"].push(Math.abs(I)),A=[],b=0;for(;i?o>=s:o<=s;)r.toRegex===!0&&n>1?S(o):A.push(dC(p(o,b),d,f)),o=i?o-n:o+n,b++;return r.toRegex===!0?n>1?pC(g,r,d):Mf(A,null,{wrap:!1,...r}):A},_C=(e,t,n=1,r={})=>{if(!En(e)&&e.length>1||!En(t)&&t.length>1)return Hf(e,t,r);let o=r.transform||(f=>String.fromCharCode(f)),s=`${e}`.charCodeAt(0),i=`${t}`.charCodeAt(0),a=s>i,c=Math.min(s,i),l=Math.max(s,i);if(r.toRegex&&n===1)return vf(c,l,!1,r);let u=[],d=0;for(;a?s>=i:s<=i;)u.push(o(s,d)),s=a?s-n:s+n,d++;return r.toRegex===!0?Mf(u,null,{wrap:!1,options:r}):u},Wr=(e,t,n,r={})=>{if(t==null&&Fs(e))return[e];if(!Fs(e)||!Fs(t))return Hf(e,t,r);if(typeof n=="function")return Wr(e,t,1,{transform:n});if(wf(n))return Wr(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,En(n)?En(e)&&En(t)?gC(e,t,n,o):_C(e,t,Math.max(Math.abs(n),1),o):n!=null&&!wf(n)?mC(n,o):Wr(e,t,1,n)};Uf.exports=Wr});var $f=z((nw,Ff)=>{"use strict";var hC=js(),Df=Gr(),SC=(e,t={})=>{let n=(r,o={})=>{let s=Df.isInvalidBrace(o),i=r.invalid===!0&&t.escapeInvalid===!0,a=s===!0||i===!0,c=t.escapeInvalid===!0?"\\":"",l="";if(r.isOpen===!0)return c+r.value;if(r.isClose===!0)return console.log("node.isClose",c,r.value),c+r.value;if(r.type==="open")return a?c+r.value:"(";if(r.type==="close")return a?c+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":a?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let u=Df.reduce(r.nodes),d=hC(...u,{...t,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(r.nodes)for(let u of r.nodes)l+=n(u,r);return l};return n(e)};Ff.exports=SC});var Kf=z((rw,Bf)=>{"use strict";var EC=js(),jf=Vr(),Dt=Gr(),yt=(e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?Dt.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let s of o)r.push(yt(s,t,n));else for(let s of t)n===!0&&typeof s=="string"&&(s=`{${s}}`),r.push(Array.isArray(s)?yt(o,s,n):o+s);return Dt.flatten(r)},yC=(e,t={})=>{let n=t.rangeLimit===void 0?1e3:t.rangeLimit,r=(o,s={})=>{o.queue=[];let i=s,a=s.queue;for(;i.type!=="brace"&&i.type!=="root"&&i.parent;)i=i.parent,a=i.queue;if(o.invalid||o.dollar){a.push(yt(a.pop(),jf(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){a.push(yt(a.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let d=Dt.reduce(o.nodes);if(Dt.exceedsLimit(...d,t.step,n))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=EC(...d,t);f.length===0&&(f=jf(o,t)),a.push(yt(a.pop(),f)),o.nodes=[];return}let c=Dt.encloseBrace(o),l=o.queue,u=o;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,l=u.queue;for(let d=0;d<o.nodes.length;d++){let f=o.nodes[d];if(f.type==="comma"&&o.type==="brace"){d===1&&l.push(""),l.push("");continue}if(f.type==="close"){a.push(yt(a.pop(),l,c));continue}if(f.value&&f.type!=="open"){l.push(yt(l.pop(),f.value));continue}f.nodes&&r(f,o)}return l};return Dt.flatten(r(e))};Bf.exports=yC});var Vf=z((ow,Gf)=>{"use strict";Gf.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
14
|
-
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Xf=z((sw,Yf)=>{"use strict";var RC=Vr(),{MAX_LENGTH:Wf,CHAR_BACKSLASH:Bs,CHAR_BACKTICK:CC,CHAR_COMMA:AC,CHAR_DOT:bC,CHAR_LEFT_PARENTHESES:kC,CHAR_RIGHT_PARENTHESES:xC,CHAR_LEFT_CURLY_BRACE:OC,CHAR_RIGHT_CURLY_BRACE:IC,CHAR_LEFT_SQUARE_BRACKET:zf,CHAR_RIGHT_SQUARE_BRACKET:Jf,CHAR_DOUBLE_QUOTE:TC,CHAR_SINGLE_QUOTE:PC,CHAR_NO_BREAK_SPACE:wC,CHAR_ZERO_WIDTH_NOBREAK_SPACE:NC}=Vf(),vC=(e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Wf,n.maxLength):Wf;if(e.length>r)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${r})`);let o={type:"root",input:e,nodes:[]},s=[o],i=o,a=o,c=0,l=e.length,u=0,d=0,f,p=()=>e[u++],g=S=>{if(S.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&S.type==="text"){a.value+=S.value;return}return i.nodes.push(S),S.parent=i,S.prev=a,a=S,S};for(g({type:"bos"});u<l;)if(i=s[s.length-1],f=p(),!(f===NC||f===wC)){if(f===Bs){g({type:"text",value:(t.keepEscaping?f:"")+p()});continue}if(f===Jf){g({type:"text",value:"\\"+f});continue}if(f===zf){c++;let S;for(;u<l&&(S=p());){if(f+=S,S===zf){c++;continue}if(S===Bs){f+=p();continue}if(S===Jf&&(c--,c===0))break}g({type:"text",value:f});continue}if(f===kC){i=g({type:"paren",nodes:[]}),s.push(i),g({type:"text",value:f});continue}if(f===xC){if(i.type!=="paren"){g({type:"text",value:f});continue}i=s.pop(),g({type:"text",value:f}),i=s[s.length-1];continue}if(f===TC||f===PC||f===CC){let S=f,A;for(t.keepQuotes!==!0&&(f="");u<l&&(A=p());){if(A===Bs){f+=A+p();continue}if(A===S){t.keepQuotes===!0&&(f+=A);break}f+=A}g({type:"text",value:f});continue}if(f===OC){d++;let A={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||i.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};i=g(A),s.push(i),g({type:"open",value:f});continue}if(f===IC){if(i.type!=="brace"){g({type:"text",value:f});continue}let S="close";i=s.pop(),i.close=!0,g({type:S,value:f}),d--,i=s[s.length-1];continue}if(f===AC&&d>0){if(i.ranges>0){i.ranges=0;let S=i.nodes.shift();i.nodes=[S,{type:"text",value:RC(i)}]}g({type:"comma",value:f}),i.commas++;continue}if(f===bC&&d>0&&i.commas===0){let S=i.nodes;if(d===0||S.length===0){g({type:"text",value:f});continue}if(a.type==="dot"){if(i.range=[],a.value+=f,a.type="range",i.nodes.length!==3&&i.nodes.length!==5){i.invalid=!0,i.ranges=0,a.type="text";continue}i.ranges++,i.args=[];continue}if(a.type==="range"){S.pop();let A=S[S.length-1];A.value+=a.value+f,a=A,i.ranges--;continue}g({type:"dot",value:f});continue}g({type:"text",value:f})}do if(i=s.pop(),i.type!=="root"){i.nodes.forEach(b=>{b.nodes||(b.type==="open"&&(b.isOpen=!0),b.type==="close"&&(b.isClose=!0),b.nodes||(b.type="text"),b.invalid=!0)});let S=s[s.length-1],A=S.nodes.indexOf(i);S.nodes.splice(A,1,...i.nodes)}while(s.length>0);return g({type:"eos"}),o};Yf.exports=vC});var Qf=z((iw,Zf)=>{"use strict";var qf=Vr(),MC=$f(),LC=Kf(),HC=Xf(),he=(e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=he.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(he.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n};he.parse=(e,t={})=>HC(e,t);he.stringify=(e,t={})=>qf(typeof e=="string"?he.parse(e,t):e,t);he.compile=(e,t={})=>(typeof e=="string"&&(e=he.parse(e,t)),MC(e,t));he.expand=(e,t={})=>{typeof e=="string"&&(e=he.parse(e,t));let n=LC(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};he.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?he.compile(e,t):he.expand(e,t);Zf.exports=he});var yn=z((aw,od)=>{"use strict";var UC=Ze("path"),Me="\\\\/",ed=`[^${Me}]`,DC=0,Xe="\\.",FC="\\+",$C="\\?",Jr="\\/",jC="(?=.)",td="[^/]",Ks=`(?:${Jr}|$)`,nd=`(?:^|${Jr})`,Gs=`${Xe}{1,2}${Ks}`,BC=`(?!${Xe})`,KC=`(?!${nd}${Gs})`,GC=`(?!${Xe}{0,1}${Ks})`,VC=`(?!${Gs})`,WC=`[^.${Jr}]`,zC=`${td}*?`,rd={DOT_LITERAL:Xe,PLUS_LITERAL:FC,QMARK_LITERAL:$C,SLASH_LITERAL:Jr,ONE_CHAR:jC,QMARK:td,END_ANCHOR:Ks,DOTS_SLASH:Gs,NO_DOT:BC,NO_DOTS:KC,NO_DOT_SLASH:GC,NO_DOTS_SLASH:VC,QMARK_NO_DOT:WC,STAR:zC,START_ANCHOR:nd},JC={...rd,SLASH_LITERAL:`[${Me}]`,QMARK:ed,STAR:`${ed}*?`,DOTS_SLASH:`${Xe}{1,2}(?:[${Me}]|$)`,NO_DOT:`(?!${Xe})`,NO_DOTS:`(?!(?:^|[${Me}])${Xe}{1,2}(?:[${Me}]|$))`,NO_DOT_SLASH:`(?!${Xe}{0,1}(?:[${Me}]|$))`,NO_DOTS_SLASH:`(?!${Xe}{1,2}(?:[${Me}]|$))`,QMARK_NO_DOT:`[^.${Me}]`,START_ANCHOR:`(?:^|[${Me}])`,END_ANCHOR:`(?:[${Me}]|$)`},YC={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};od.exports={DEFAULT_MAX_EXTGLOB_RECURSION:DC,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:YC,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:UC.sep,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?JC:rd}}});var Rn=z(le=>{"use strict";var XC=Ze("path"),qC=process.platform==="win32",{REGEX_BACKSLASH:ZC,REGEX_REMOVE_BACKSLASH:QC,REGEX_SPECIAL_CHARS:eA,REGEX_SPECIAL_CHARS_GLOBAL:tA}=yn();le.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);le.hasRegexChars=e=>eA.test(e);le.isRegexChar=e=>e.length===1&&le.hasRegexChars(e);le.escapeRegex=e=>e.replace(tA,"\\$1");le.toPosixSlashes=e=>e.replace(ZC,"/");le.removeBackslashes=e=>e.replace(QC,t=>t==="\\"?"":t);le.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};le.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:qC===!0||XC.sep==="\\";le.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?le.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};le.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};le.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",s=`${r}(?:${e})${o}`;return t.negated===!0&&(s=`(?:^(?!${s}).*$)`),s}});var dd=z((uw,fd)=>{"use strict";var sd=Rn(),{CHAR_ASTERISK:Vs,CHAR_AT:nA,CHAR_BACKWARD_SLASH:Cn,CHAR_COMMA:rA,CHAR_DOT:Ws,CHAR_EXCLAMATION_MARK:zs,CHAR_FORWARD_SLASH:ld,CHAR_LEFT_CURLY_BRACE:Js,CHAR_LEFT_PARENTHESES:Ys,CHAR_LEFT_SQUARE_BRACKET:oA,CHAR_PLUS:sA,CHAR_QUESTION_MARK:id,CHAR_RIGHT_CURLY_BRACE:iA,CHAR_RIGHT_PARENTHESES:ad,CHAR_RIGHT_SQUARE_BRACKET:aA}=yn(),cd=e=>e===ld||e===Cn,ud=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},cA=(e,t)=>{let n=t||{},r=e.length-1,o=n.parts===!0||n.scanToEnd===!0,s=[],i=[],a=[],c=e,l=-1,u=0,d=0,f=!1,p=!1,g=!1,S=!1,A=!1,b=!1,I=!1,P=!1,T=!1,O=!1,K=0,D,x,N={value:"",depth:0,isGlob:!1},H=()=>l>=r,m=()=>c.charCodeAt(l+1),k=()=>(D=x,c.charCodeAt(++l));for(;l<r;){x=k();let ie;if(x===Cn){I=N.backslashes=!0,x=k(),x===Js&&(b=!0);continue}if(b===!0||x===Js){for(K++;H()!==!0&&(x=k());){if(x===Cn){I=N.backslashes=!0,k();continue}if(x===Js){K++;continue}if(b!==!0&&x===Ws&&(x=k())===Ws){if(f=N.isBrace=!0,g=N.isGlob=!0,O=!0,o===!0)continue;break}if(b!==!0&&x===rA){if(f=N.isBrace=!0,g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===iA&&(K--,K===0)){b=!1,f=N.isBrace=!0,O=!0;break}}if(o===!0)continue;break}if(x===ld){if(s.push(l),i.push(N),N={value:"",depth:0,isGlob:!1},O===!0)continue;if(D===Ws&&l===u+1){u+=2;continue}d=l+1;continue}if(n.noext!==!0&&(x===sA||x===nA||x===Vs||x===id||x===zs)===!0&&m()===Ys){if(g=N.isGlob=!0,S=N.isExtglob=!0,O=!0,x===zs&&l===u&&(T=!0),o===!0){for(;H()!==!0&&(x=k());){if(x===Cn){I=N.backslashes=!0,x=k();continue}if(x===ad){g=N.isGlob=!0,O=!0;break}}continue}break}if(x===Vs){if(D===Vs&&(A=N.isGlobstar=!0),g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===id){if(g=N.isGlob=!0,O=!0,o===!0)continue;break}if(x===oA){for(;H()!==!0&&(ie=k());){if(ie===Cn){I=N.backslashes=!0,k();continue}if(ie===aA){p=N.isBracket=!0,g=N.isGlob=!0,O=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&x===zs&&l===u){P=N.negated=!0,u++;continue}if(n.noparen!==!0&&x===Ys){if(g=N.isGlob=!0,o===!0){for(;H()!==!0&&(x=k());){if(x===Ys){I=N.backslashes=!0,x=k();continue}if(x===ad){O=!0;break}}continue}break}if(g===!0){if(O=!0,o===!0)continue;break}}n.noext===!0&&(S=!1,g=!1);let U=c,de="",_="";u>0&&(de=c.slice(0,u),c=c.slice(u),d-=u),U&&g===!0&&d>0?(U=c.slice(0,d),_=c.slice(d)):g===!0?(U="",_=c):U=c,U&&U!==""&&U!=="/"&&U!==c&&cd(U.charCodeAt(U.length-1))&&(U=U.slice(0,-1)),n.unescape===!0&&(_&&(_=sd.removeBackslashes(_)),U&&I===!0&&(U=sd.removeBackslashes(U)));let h={prefix:de,input:e,start:u,base:U,glob:_,isBrace:f,isBracket:p,isGlob:g,isExtglob:S,isGlobstar:A,negated:P,negatedExtglob:T};if(n.tokens===!0&&(h.maxDepth=0,cd(x)||i.push(N),h.tokens=i),n.parts===!0||n.tokens===!0){let ie;for(let F=0;F<s.length;F++){let xe=ie?ie+1:u,Oe=s[F],pe=e.slice(xe,Oe);n.tokens&&(F===0&&u!==0?(i[F].isPrefix=!0,i[F].value=de):i[F].value=pe,ud(i[F]),h.maxDepth+=i[F].depth),(F!==0||pe!=="")&&a.push(pe),ie=Oe}if(ie&&ie+1<e.length){let F=e.slice(ie+1);a.push(F),n.tokens&&(i[i.length-1].value=F,ud(i[i.length-1]),h.maxDepth+=i[i.length-1].depth)}h.slashes=s,h.parts=a}return h};fd.exports=cA});var hd=z((lw,_d)=>{"use strict";var An=yn(),se=Rn(),{MAX_LENGTH:Yr,POSIX_REGEX_SOURCE:uA,REGEX_NON_SPECIAL_CHARS:lA,REGEX_SPECIAL_CHARS_BACKREF:fA,REPLACEMENTS:pd}=An,dA=(e,t)=>{if(typeof t.expandRange=="function")return t.expandRange(...e,t);e.sort();let n=`[${e.join("-")}]`;try{new RegExp(n)}catch{return e.map(o=>se.escapeRegex(o)).join("..")}return n},Ft=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,md=e=>{let t=[],n=0,r=0,o=0,s="",i=!1;for(let a of e){if(i===!0){s+=a,i=!1;continue}if(a==="\\"){s+=a,i=!0;continue}if(a==='"'){o=o===1?0:1,s+=a;continue}if(o===0){if(a==="[")n++;else if(a==="]"&&n>0)n--;else if(n===0){if(a==="(")r++;else if(a===")"&&r>0)r--;else if(a==="|"&&r===0){t.push(s),s="";continue}}}s+=a}return t.push(s),t},pA=e=>{let t=!1;for(let n of e){if(t===!0){t=!1;continue}if(n==="\\"){t=!0;continue}if(/[?*+@!()[\]{}]/.test(n))return!1}return!0},gd=e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(pA(t))return t.replace(/\\(.)/g,"$1")},mA=e=>{let t=e.map(gd).filter(Boolean);for(let n=0;n<t.length;n++)for(let r=n+1;r<t.length;r++){let o=t[n],s=t[r],i=o[0];if(!(!i||o!==i.repeat(o.length)||s!==i.repeat(s.length))&&(o===s||o.startsWith(s)||s.startsWith(o)))return!0}return!1},Xs=(e,t=!0)=>{if(e[0]!=="+"&&e[0]!=="*"||e[1]!=="(")return;let n=0,r=0,o=0,s=!1;for(let i=1;i<e.length;i++){let a=e[i];if(s===!0){s=!1;continue}if(a==="\\"){s=!0;continue}if(a==='"'){o=o===1?0:1;continue}if(o!==1){if(a==="["){n++;continue}if(a==="]"&&n>0){n--;continue}if(!(n>0)){if(a==="("){r++;continue}if(a===")"&&(r--,r===0))return t===!0&&i!==e.length-1?void 0:{type:e[0],body:e.slice(2,i),end:i}}}}},gA=e=>{let t=0,n=[];for(;t<e.length;){let o=Xs(e.slice(t),!1);if(!o||o.type!=="*")return;let s=md(o.body).map(a=>a.trim());if(s.length!==1)return;let i=gd(s[0]);if(!i||i.length!==1)return;n.push(i),t+=o.end+1}return n.length<1?void 0:`${n.length===1?se.escapeRegex(n[0]):`[${n.map(o=>se.escapeRegex(o)).join("")}]`}*`},_A=e=>{let t=0,n=e.trim(),r=Xs(n);for(;r;)t++,n=r.body.trim(),r=Xs(n);return t},hA=(e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:An.DEFAULT_MAX_EXTGLOB_RECURSION,r=md(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||mA(r)))return{risky:!0};for(let o of r){let s=gA(o);if(s)return{risky:!0,safeOutput:s};if(_A(o)>n)return{risky:!0}}return{risky:!1}},qs=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=pd[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(Yr,n.maxLength):Yr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);let s={type:"bos",value:"",output:n.prepend||""},i=[s],a=n.capture?"":"?:",c=se.isWindows(t),l=An.globChars(c),u=An.extglobChars(l),{DOT_LITERAL:d,PLUS_LITERAL:f,SLASH_LITERAL:p,ONE_CHAR:g,DOTS_SLASH:S,NO_DOT:A,NO_DOT_SLASH:b,NO_DOTS_SLASH:I,QMARK:P,QMARK_NO_DOT:T,STAR:O,START_ANCHOR:K}=l,D=C=>`(${a}(?:(?!${K}${C.dot?S:d}).)*?)`,x=n.dot?"":A,N=n.dot?P:T,H=n.bash===!0?D(n):O;n.capture&&(H=`(${H})`),typeof n.noext=="boolean"&&(n.noextglob=n.noext);let m={input:e,index:-1,start:0,dot:n.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:i};e=se.removePrefix(e,m),o=e.length;let k=[],U=[],de=[],_=s,h,ie=()=>m.index===o-1,F=m.peek=(C=1)=>e[m.index+C],xe=m.advance=()=>e[++m.index]||"",Oe=()=>e.slice(m.index+1),pe=(C="",Y=0)=>{m.consumed+=C,m.index+=Y},Hn=C=>{m.output+=C.output!=null?C.output:C.value,pe(C.value)},Am=()=>{let C=1;for(;F()==="!"&&(F(2)!=="("||F(3)==="?");)xe(),m.start++,C++;return C%2===0?!1:(m.negated=!0,m.start++,!0)},Un=C=>{m[C]++,de.push(C)},qe=C=>{m[C]--,de.pop()},v=C=>{if(_.type==="globstar"){let Y=m.braces>0&&(C.type==="comma"||C.type==="brace"),R=C.extglob===!0||k.length&&(C.type==="pipe"||C.type==="paren");C.type!=="slash"&&C.type!=="paren"&&!Y&&!R&&(m.output=m.output.slice(0,-_.output.length),_.type="star",_.value="*",_.output=H,m.output+=_.output)}if(k.length&&C.type!=="paren"&&(k[k.length-1].inner+=C.value),(C.value||C.output)&&Hn(C),_&&_.type==="text"&&C.type==="text"){_.value+=C.value,_.output=(_.output||"")+C.value;return}C.prev=_,i.push(C),_=C},Dn=(C,Y)=>{let R={...u[Y],conditions:1,inner:""};R.prev=_,R.parens=m.parens,R.output=m.output,R.startIndex=m.index,R.tokensIndex=i.length;let w=(n.capture?"(":"")+R.open;Un("parens"),v({type:C,value:Y,output:m.output?"":g}),v({type:"paren",extglob:!0,value:xe(),output:w}),k.push(R)},bm=C=>{let Y=e.slice(C.startIndex,m.index+1),R=e.slice(C.startIndex+2,m.index),w=hA(R,n);if((C.type==="plus"||C.type==="star")&&w.risky){let G=w.safeOutput?(C.output?"":g)+(n.capture?`(${w.safeOutput})`:w.safeOutput):void 0,Ie=i[C.tokensIndex];Ie.type="text",Ie.value=Y,Ie.output=G||se.escapeRegex(Y);for(let Te=C.tokensIndex+1;Te<i.length;Te++)i[Te].value="",i[Te].output="",delete i[Te].suffix;m.output=C.output+Ie.output,m.backtrack=!0,v({type:"paren",extglob:!0,value:h,output:""}),qe("parens");return}let W=C.close+(n.capture?")":""),oe;if(C.type==="negate"){let G=H;if(C.inner&&C.inner.length>1&&C.inner.includes("/")&&(G=D(n)),(G!==H||ie()||/^\)+$/.test(Oe()))&&(W=C.close=`)$))${G}`),C.inner.includes("*")&&(oe=Oe())&&/^\.[^\\/.]+$/.test(oe)){let Ie=qs(oe,{...t,fastpaths:!1}).output;W=C.close=`)${Ie})${G})`}C.prev.type==="bos"&&(m.negatedExtglob=!0)}v({type:"paren",extglob:!0,value:h,output:W}),qe("parens")};if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let C=!1,Y=e.replace(fA,(R,w,W,oe,G,Ie)=>oe==="\\"?(C=!0,R):oe==="?"?w?w+oe+(G?P.repeat(G.length):""):Ie===0?N+(G?P.repeat(G.length):""):P.repeat(W.length):oe==="."?d.repeat(W.length):oe==="*"?w?w+oe+(G?H:""):H:w?R:`\\${R}`);return C===!0&&(n.unescape===!0?Y=Y.replace(/\\/g,""):Y=Y.replace(/\\+/g,R=>R.length%2===0?"\\\\":R?"\\":"")),Y===e&&n.contains===!0?(m.output=e,m):(m.output=se.wrapOutput(Y,m,t),m)}for(;!ie();){if(h=xe(),h==="\0")continue;if(h==="\\"){let R=F();if(R==="/"&&n.bash!==!0||R==="."||R===";")continue;if(!R){h+="\\",v({type:"text",value:h});continue}let w=/^\\+/.exec(Oe()),W=0;if(w&&w[0].length>2&&(W=w[0].length,m.index+=W,W%2!==0&&(h+="\\")),n.unescape===!0?h=xe():h+=xe(),m.brackets===0){v({type:"text",value:h});continue}}if(m.brackets>0&&(h!=="]"||_.value==="["||_.value==="[^")){if(n.posix!==!1&&h===":"){let R=_.value.slice(1);if(R.includes("[")&&(_.posix=!0,R.includes(":"))){let w=_.value.lastIndexOf("["),W=_.value.slice(0,w),oe=_.value.slice(w+2),G=uA[oe];if(G){_.value=W+G,m.backtrack=!0,xe(),!s.output&&i.indexOf(_)===1&&(s.output=g);continue}}}(h==="["&&F()!==":"||h==="-"&&F()==="]")&&(h=`\\${h}`),h==="]"&&(_.value==="["||_.value==="[^")&&(h=`\\${h}`),n.posix===!0&&h==="!"&&_.value==="["&&(h="^"),_.value+=h,Hn({value:h});continue}if(m.quotes===1&&h!=='"'){h=se.escapeRegex(h),_.value+=h,Hn({value:h});continue}if(h==='"'){m.quotes=m.quotes===1?0:1,n.keepQuotes===!0&&v({type:"text",value:h});continue}if(h==="("){Un("parens"),v({type:"paren",value:h});continue}if(h===")"){if(m.parens===0&&n.strictBrackets===!0)throw new SyntaxError(Ft("opening","("));let R=k[k.length-1];if(R&&m.parens===R.parens+1){bm(k.pop());continue}v({type:"paren",value:h,output:m.parens?")":"\\)"}),qe("parens");continue}if(h==="["){if(n.nobracket===!0||!Oe().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(Ft("closing","]"));h=`\\${h}`}else Un("brackets");v({type:"bracket",value:h});continue}if(h==="]"){if(n.nobracket===!0||_&&_.type==="bracket"&&_.value.length===1){v({type:"text",value:h,output:`\\${h}`});continue}if(m.brackets===0){if(n.strictBrackets===!0)throw new SyntaxError(Ft("opening","["));v({type:"text",value:h,output:`\\${h}`});continue}qe("brackets");let R=_.value.slice(1);if(_.posix!==!0&&R[0]==="^"&&!R.includes("/")&&(h=`/${h}`),_.value+=h,Hn({value:h}),n.literalBrackets===!1||se.hasRegexChars(R))continue;let w=se.escapeRegex(_.value);if(m.output=m.output.slice(0,-_.value.length),n.literalBrackets===!0){m.output+=w,_.value=w;continue}_.value=`(${a}${w}|${_.value})`,m.output+=_.value;continue}if(h==="{"&&n.nobrace!==!0){Un("braces");let R={type:"brace",value:h,output:"(",outputIndex:m.output.length,tokensIndex:m.tokens.length};U.push(R),v(R);continue}if(h==="}"){let R=U[U.length-1];if(n.nobrace===!0||!R){v({type:"text",value:h,output:h});continue}let w=")";if(R.dots===!0){let W=i.slice(),oe=[];for(let G=W.length-1;G>=0&&(i.pop(),W[G].type!=="brace");G--)W[G].type!=="dots"&&oe.unshift(W[G].value);w=dA(oe,n),m.backtrack=!0}if(R.comma!==!0&&R.dots!==!0){let W=m.output.slice(0,R.outputIndex),oe=m.tokens.slice(R.tokensIndex);R.value=R.output="\\{",h=w="\\}",m.output=W;for(let G of oe)m.output+=G.output||G.value}v({type:"brace",value:h,output:w}),qe("braces"),U.pop();continue}if(h==="|"){k.length>0&&k[k.length-1].conditions++,v({type:"text",value:h});continue}if(h===","){let R=h,w=U[U.length-1];w&&de[de.length-1]==="braces"&&(w.comma=!0,R="|"),v({type:"comma",value:h,output:R});continue}if(h==="/"){if(_.type==="dot"&&m.index===m.start+1){m.start=m.index+1,m.consumed="",m.output="",i.pop(),_=s;continue}v({type:"slash",value:h,output:p});continue}if(h==="."){if(m.braces>0&&_.type==="dot"){_.value==="."&&(_.output=d);let R=U[U.length-1];_.type="dots",_.output+=h,_.value+=h,R.dots=!0;continue}if(m.braces+m.parens===0&&_.type!=="bos"&&_.type!=="slash"){v({type:"text",value:h,output:d});continue}v({type:"dot",value:h,output:d});continue}if(h==="?"){if(!(_&&_.value==="(")&&n.noextglob!==!0&&F()==="("&&F(2)!=="?"){Dn("qmark",h);continue}if(_&&_.type==="paren"){let w=F(),W=h;if(w==="<"&&!se.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(_.value==="("&&!/[!=<:]/.test(w)||w==="<"&&!/<([!=]|\w+>)/.test(Oe()))&&(W=`\\${h}`),v({type:"text",value:h,output:W});continue}if(n.dot!==!0&&(_.type==="slash"||_.type==="bos")){v({type:"qmark",value:h,output:T});continue}v({type:"qmark",value:h,output:P});continue}if(h==="!"){if(n.noextglob!==!0&&F()==="("&&(F(2)!=="?"||!/[!=<:]/.test(F(3)))){Dn("negate",h);continue}if(n.nonegate!==!0&&m.index===0){Am();continue}}if(h==="+"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){Dn("plus",h);continue}if(_&&_.value==="("||n.regex===!1){v({type:"plus",value:h,output:f});continue}if(_&&(_.type==="bracket"||_.type==="paren"||_.type==="brace")||m.parens>0){v({type:"plus",value:h});continue}v({type:"plus",value:f});continue}if(h==="@"){if(n.noextglob!==!0&&F()==="("&&F(2)!=="?"){v({type:"at",extglob:!0,value:h,output:""});continue}v({type:"text",value:h});continue}if(h!=="*"){(h==="$"||h==="^")&&(h=`\\${h}`);let R=lA.exec(Oe());R&&(h+=R[0],m.index+=R[0].length),v({type:"text",value:h});continue}if(_&&(_.type==="globstar"||_.star===!0)){_.type="star",_.star=!0,_.value+=h,_.output=H,m.backtrack=!0,m.globstar=!0,pe(h);continue}let C=Oe();if(n.noextglob!==!0&&/^\([^?]/.test(C)){Dn("star",h);continue}if(_.type==="star"){if(n.noglobstar===!0){pe(h);continue}let R=_.prev,w=R.prev,W=R.type==="slash"||R.type==="bos",oe=w&&(w.type==="star"||w.type==="globstar");if(n.bash===!0&&(!W||C[0]&&C[0]!=="/")){v({type:"star",value:h,output:""});continue}let G=m.braces>0&&(R.type==="comma"||R.type==="brace"),Ie=k.length&&(R.type==="pipe"||R.type==="paren");if(!W&&R.type!=="paren"&&!G&&!Ie){v({type:"star",value:h,output:""});continue}for(;C.slice(0,3)==="/**";){let Te=e[m.index+4];if(Te&&Te!=="/")break;C=C.slice(3),pe("/**",3)}if(R.type==="bos"&&ie()){_.type="globstar",_.value+=h,_.output=D(n),m.output=_.output,m.globstar=!0,pe(h);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&!oe&&ie()){m.output=m.output.slice(0,-(R.output+_.output).length),R.output=`(?:${R.output}`,_.type="globstar",_.output=D(n)+(n.strictSlashes?")":"|$)"),_.value+=h,m.globstar=!0,m.output+=R.output+_.output,pe(h);continue}if(R.type==="slash"&&R.prev.type!=="bos"&&C[0]==="/"){let Te=C[1]!==void 0?"|$":"";m.output=m.output.slice(0,-(R.output+_.output).length),R.output=`(?:${R.output}`,_.type="globstar",_.output=`${D(n)}${p}|${p}${Te})`,_.value+=h,m.output+=R.output+_.output,m.globstar=!0,pe(h+xe()),v({type:"slash",value:"/",output:""});continue}if(R.type==="bos"&&C[0]==="/"){_.type="globstar",_.value+=h,_.output=`(?:^|${p}|${D(n)}${p})`,m.output=_.output,m.globstar=!0,pe(h+xe()),v({type:"slash",value:"/",output:""});continue}m.output=m.output.slice(0,-_.output.length),_.type="globstar",_.output=D(n),_.value+=h,m.output+=_.output,m.globstar=!0,pe(h);continue}let Y={type:"star",value:h,output:H};if(n.bash===!0){Y.output=".*?",(_.type==="bos"||_.type==="slash")&&(Y.output=x+Y.output),v(Y);continue}if(_&&(_.type==="bracket"||_.type==="paren")&&n.regex===!0){Y.output=h,v(Y);continue}(m.index===m.start||_.type==="slash"||_.type==="dot")&&(_.type==="dot"?(m.output+=b,_.output+=b):n.dot===!0?(m.output+=I,_.output+=I):(m.output+=x,_.output+=x),F()!=="*"&&(m.output+=g,_.output+=g)),v(Y)}for(;m.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ft("closing","]"));m.output=se.escapeLast(m.output,"["),qe("brackets")}for(;m.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ft("closing",")"));m.output=se.escapeLast(m.output,"("),qe("parens")}for(;m.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(Ft("closing","}"));m.output=se.escapeLast(m.output,"{"),qe("braces")}if(n.strictSlashes!==!0&&(_.type==="star"||_.type==="bracket")&&v({type:"maybe_slash",value:"",output:`${p}?`}),m.backtrack===!0){m.output="";for(let C of m.tokens)m.output+=C.output!=null?C.output:C.value,C.suffix&&(m.output+=C.suffix)}return m};qs.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(Yr,n.maxLength):Yr,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=pd[e]||e;let s=se.isWindows(t),{DOT_LITERAL:i,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:l,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:f,STAR:p,START_ANCHOR:g}=An.globChars(s),S=n.dot?d:u,A=n.dot?f:u,b=n.capture?"":"?:",I={negated:!1,prefix:""},P=n.bash===!0?".*?":p;n.capture&&(P=`(${P})`);let T=x=>x.noglobstar===!0?P:`(${b}(?:(?!${g}${x.dot?l:i}).)*?)`,O=x=>{switch(x){case"*":return`${S}${c}${P}`;case".*":return`${i}${c}${P}`;case"*.*":return`${S}${P}${i}${c}${P}`;case"*/*":return`${S}${P}${a}${c}${A}${P}`;case"**":return S+T(n);case"**/*":return`(?:${S}${T(n)}${a})?${A}${c}${P}`;case"**/*.*":return`(?:${S}${T(n)}${a})?${A}${P}${i}${c}${P}`;case"**/.*":return`(?:${S}${T(n)}${a})?${i}${c}${P}`;default:{let N=/^(.*?)\.(\w+)$/.exec(x);if(!N)return;let H=O(N[1]);return H?H+i+N[2]:void 0}}},K=se.removePrefix(e,I),D=O(K);return D&&n.strictSlashes!==!0&&(D+=`${a}?`),D};_d.exports=qs});var Ed=z((fw,Sd)=>{"use strict";var SA=Ze("path"),EA=dd(),Zs=hd(),Qs=Rn(),yA=yn(),RA=e=>e&&typeof e=="object"&&!Array.isArray(e),te=(e,t,n=!1)=>{if(Array.isArray(e)){let u=e.map(f=>te(f,t,n));return f=>{for(let p of u){let g=p(f);if(g)return g}return!1}}let r=RA(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let o=t||{},s=Qs.isWindows(t),i=r?te.compileRe(e,t):te.makeRe(e,t,!1,!0),a=i.state;delete i.state;let c=()=>!1;if(o.ignore){let u={...t,ignore:null,onMatch:null,onResult:null};c=te(o.ignore,u,n)}let l=(u,d=!1)=>{let{isMatch:f,match:p,output:g}=te.test(u,i,t,{glob:e,posix:s}),S={glob:e,state:a,regex:i,posix:s,input:u,output:g,match:p,isMatch:f};return typeof o.onResult=="function"&&o.onResult(S),f===!1?(S.isMatch=!1,d?S:!1):c(u)?(typeof o.onIgnore=="function"&&o.onIgnore(S),S.isMatch=!1,d?S:!1):(typeof o.onMatch=="function"&&o.onMatch(S),d?S:!0)};return n&&(l.state=a),l};te.test=(e,t,n,{glob:r,posix:o}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let s=n||{},i=s.format||(o?Qs.toPosixSlashes:null),a=e===r,c=a&&i?i(e):e;return a===!1&&(c=i?i(e):e,a=c===r),(a===!1||s.capture===!0)&&(s.matchBase===!0||s.basename===!0?a=te.matchBase(e,t,n,o):a=t.exec(c)),{isMatch:!!a,match:a,output:c}};te.matchBase=(e,t,n,r=Qs.isWindows(n))=>(t instanceof RegExp?t:te.makeRe(t,n)).test(SA.basename(e));te.isMatch=(e,t,n)=>te(t,n)(e);te.parse=(e,t)=>Array.isArray(e)?e.map(n=>te.parse(n,t)):Zs(e,{...t,fastpaths:!1});te.scan=(e,t)=>EA(e,t);te.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},s=o.contains?"":"^",i=o.contains?"":"$",a=`${s}(?:${e.output})${i}`;e&&e.negated===!0&&(a=`^(?!${a}).*$`);let c=te.toRegex(a,t);return r===!0&&(c.state=e),c};te.makeRe=(e,t={},n=!1,r=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(o.output=Zs.fastpaths(e,t)),o.output||(o=Zs(e,t)),te.compileRe(o,t,n,r)};te.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===!0)throw n;return/$^/}};te.constants=yA;Sd.exports=te});var Rd=z((dw,yd)=>{"use strict";yd.exports=Ed()});var Od=z((pw,xd)=>{"use strict";var Ad=Ze("util"),bd=Qf(),Le=Rd(),ei=Rn(),Cd=e=>e===""||e==="./",kd=e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},J=(e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,s=new Set,i=0,a=u=>{s.add(u.output),n&&n.onResult&&n.onResult(u)};for(let u=0;u<t.length;u++){let d=Le(String(t[u]),{...n,onResult:a},!0),f=d.state.negated||d.state.negatedExtglob;f&&i++;for(let p of e){let g=d(p,!0);(f?!g.isMatch:g.isMatch)&&(f?r.add(g.output):(r.delete(g.output),o.add(g.output)))}}let l=(i===t.length?[...s]:[...o]).filter(u=>!r.has(u));if(n&&l.length===0){if(n.failglob===!0)throw new Error(`No matches found for "${t.join(", ")}"`);if(n.nonull===!0||n.nullglob===!0)return n.unescape?t.map(u=>u.replace(/\\/g,"")):t}return l};J.match=J;J.matcher=(e,t)=>Le(e,t);J.isMatch=(e,t,n)=>Le(t,n)(e);J.any=J.isMatch;J.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],s=a=>{n.onResult&&n.onResult(a),o.push(a.output)},i=new Set(J(e,t,{...n,onResult:s}));for(let a of o)i.has(a)||r.add(a);return[...r]};J.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Ad.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>J.contains(e,r,n));if(typeof t=="string"){if(Cd(e)||Cd(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return J.isMatch(e,t,{...n,contains:!0})};J.matchKeys=(e,t,n)=>{if(!ei.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=J(Object.keys(e),t,n),o={};for(let s of r)o[s]=e[s];return o};J.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Le(String(o),n);if(r.some(i=>s(i)))return!0}return!1};J.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let s=Le(String(o),n);if(!r.every(i=>s(i)))return!1}return!0};J.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${Ad.inspect(e)}"`);return[].concat(t).every(r=>Le(r,n)(e))};J.capture=(e,t,n)=>{let r=ei.isWindows(n),s=Le.makeRe(String(e),{...n,capture:!0}).exec(r?ei.toPosixSlashes(t):t);if(s)return s.slice(1).map(i=>i===void 0?"":i)};J.makeRe=(...e)=>Le.makeRe(...e);J.scan=(...e)=>Le.scan(...e);J.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of bd(String(r),t))n.push(Le.parse(o,t));return n};J.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!kd(e)?[e]:bd(e,t)};J.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return J.braces(e,{...t,expand:!0})};J.hasBraces=kd;xd.exports=J});import{realpathSync as xx}from"node:fs";import{resolve as Ox}from"node:path";import{fileURLToPath as Ix,pathToFileURL as Tx}from"node:url";import{createHash as qm}from"node:crypto";import{homedir as Zm}from"node:os";import{dirname as rO,join as Qm,parse as oO,resolve as sO}from"node:path";var $i="EV_AI_LAUNCHER_VERSION";var ji="EV_AI_HOOK_SOURCE",Bi="EV_AI_HOOK_FALLBACK_REASON",Ki="EV_AI_LAUNCHER_SCOPE",mo="EV_AI_LAUNCHER_READY_FD";var Gi="--defer-user-spec",Fn="--cap",zt="--slot";var Vi=Buffer.from([1]);var vx=1024*1024,Mx=4*1024*1024,Lx=64*1024,Hx=64*1024,Ux=64*1024;var go=4096,Dx=4*1024*1024;import{join as qi}from"node:path";import{open as Wi,mkdir as wm,readFile as Nm,readdir as vm,rename as Mm,stat as Lm,rmdir as Hm,unlink as Um,utimes as Dm}from"node:fs/promises";var $n=new WeakMap;function Ji(e){if(e&&typeof e=="object"&&"code"in e)return e}function Ot(e){return Ji(e)?.code==="ENOENT"}function Jt(e){return Ji(e)?.code==="EEXIST"}async function Yi(e,t){try{return await e.readdir(t)}catch(n){if(Ot(n))return[];throw n}}function Xi(){return{async open(e,t){let n=await Wi(e,t),r={path:e};return $n.set(r,n),r},async write(e,t){let n=zi(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await zi(e).sync()},async close(e){let t=$n.get(e);$n.delete(e),t&&await t.close()},rename:Mm,async readdir(e){return vm(e)},readFile:Nm,async stat(e){let t=await Lm(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await wm(e,t)},unlink:Um,rmdir:Hm,utimes:Dm,async fsyncDir(e){if(process.platform==="win32")return;let t=await Wi(e,"r");try{await t.sync()}finally{await t.close()}}}}function zi(e){let t=$n.get(e);if(!t)throw new Error("closed");return t}var Zi=4,Qi=10;function jn(e=process.platform){return e==="win32"?Zi:Qi}var Bn=6e4,Yt=2e3,ea="slots",_o=64;function ta(e){return qi(e,".ev-ai","agent-hook",ea)}function Kn(e,t){return qi(e,`slot-${t}`)}function Gn(e,t){return`${e}
|
|
10
|
+
`):f.join(`
|
|
11
|
+
`).trimEnd();return(0,Pe.usableCatalogText)(d)}s(My,"parseYamlFrontmatterScalar")});var bl=Y(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=re.COMPONENT_INSPECTION_TEXT_MAX_BYTES=re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=void 0;re.fitSnapshotInspectionTextBudget=Hy;re.capComponentTextBytes=Al;re.prepareComponentInspectionText=Uy;re.redactComponentSource=vs;re.componentSourceContainsRedactableSecret=Gy;re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER="[REDACTED]";re.COMPONENT_INSPECTION_TEXT_MAX_BYTES=256*1024;re.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=3*1024*1024;function Hy(e){let t=0;return e.map(n=>{let r=n,o=r.skill?.inspectionText;if(o===void 0)return n;let i=Buffer.byteLength(o,"utf8");return t+i<=re.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES?(t+=i,n):{...n,skill:{...r.skill,inspectionText:void 0}}})}s(Hy,"fitSnapshotInspectionTextBudget");function Al(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(Al,"capComponentTextBytes");function Uy(e){if(!(e==null||e.length===0))return Al(vs(e),re.COMPONENT_INSPECTION_TEXT_MAX_BYTES)}s(Uy,"prepareComponentInspectionText");var Dy=[/\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],Fy=/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,$y=/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi,jy=/([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi,By=/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,Cl=/-----END [A-Z0-9 ]*PRIVATE KEY-----/;function Ky(e){let t=e.replace($y,(n,r)=>`${r}${re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);t=t.replace(jy,(n,r)=>`${r}${re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`),t=t.replace(Fy,(n,r)=>`${r}${re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);for(let n of Dy)t=t.replace(n,re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);return t}s(Ky,"redactLine");function vs(e){if(e.length===0)return e;let t=e.split(`
|
|
12
|
+
`),n=!1;return t.map(o=>n?Cl.test(o)?(n=!1,o):o.trim().length===0?o:re.COMPONENT_SOURCE_REDACTION_PLACEHOLDER:By.test(o)&&!Cl.test(o)?(n=!0,o):Ky(o)).join(`
|
|
13
|
+
`)}s(vs,"redactComponentSource");function Gy(e){return vs(e)!==e}s(Gy,"componentSourceContainsRedactableSecret")});var St=Y(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.redactComponentSource=C.prepareComponentInspectionText=C.fitSnapshotInspectionTextBudget=C.componentSourceContainsRedactableSecret=C.capComponentTextBytes=C.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES=C.COMPONENT_SOURCE_REDACTION_PLACEHOLDER=C.COMPONENT_INSPECTION_TEXT_MAX_BYTES=C.usableCatalogText=C.parseFrontmatterField=C.parseFrontmatterDescription=C.mcpServerToolSegmentForms=C.mcpServerNameMatchesToolSegment=C.isNpmRegistryPublisher=C.EMPTY_NPM_PUBLISHER=C.displayPublisherName=C.classifyMcpProvenance=C.resolveMcpPackageIdentity=C.McpPackageEcosystem=C.pinnedPackageVersionFromSpec=C.pinnedPackageVersionFromNpx=C.packageNameFromSpec=C.npxPackageSpecs=C.npxExecBin=C.PACKAGE_FIELD_MAX=C.serializeMcpLaunchIdentity=C.projectMcpMissingLaunchIdentity=C.projectMcpLaunchIdentity=C.normalizeMcpToolNames=C.MCP_MISSING_LAUNCH_SERIALIZED=C.MCP_LAUNCH_IDENTITY_ALGORITHM=C.maskMcpLaunchForDisplay=C.launchContainsCredentials=C.hashMcpLaunchIdentity=C.foldMcpName=C.buildMcpFamilyCanonicalKey=C.ComponentKind=void 0;C.userConfigRootFromPath=eR;C.installationRootExternalKey=tR;C.normalizeRepositoryRelativePath=kl;C.nativeKeyForSkillPath=nR;C.nativeKeyForRulePath=rR;C.nativeKeyForCommandPath=oR;C.serializeComponentIdentity=Ol;C.buildComponentReference=iR;C.validateComponentReference=aR;var Wy=rt("node:crypto"),Vy=rt("node:path"),zy="cmp1_",Jy=/^cmp1_[A-Za-z0-9_-]{43}$/,Yy=["/skills/","/skills-cursor/"],Xy=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,qy=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,Zy=[".cursor",".claude",".codex"],Qy={".claude.json":".claude",".agents":".codex"};C.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function eR(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>Zy.includes(o));return n||(t.map(o=>Qy[o]).find(o=>o!==void 0)??"unknown")}s(eR,"userConfigRootFromPath");function tR(e,t){return`runtime-install:${e}/${t}`}s(tR,"installationRootExternalKey");function Gr(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}s(Gr,"requireValue");function kl(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=Vy.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Gr(n,"sourcePath")}s(kl,"normalizeRepositoryRelativePath");function nR(e){let t=e.replaceAll("\\","/");for(let n of Yy){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}s(nR,"nativeKeyForSkillPath");function xl(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(xl,"nativeKeyUnderLayoutRoot");function rR(e){return xl(e,Xy,/\.(mdc|md|rules)$/i)}s(rR,"nativeKeyForRulePath");function oR(e){return xl(e,qy,/\.(md|mdc|toml)$/i)}s(oR,"nativeKeyForCommandPath");function sR(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}s(sR,"field");function Ol(e){let t=[Gr(e.installationRootExternalKey,"installationRootExternalKey"),Gr(e.installableKind,"installableKind"),kl(e.sourcePath),Gr(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(sR).join("|")}`,"utf8")}s(Ol,"serializeComponentIdentity");function iR(e){let t=(0,Wy.createHash)("sha256").update(Ol(e)).digest("base64url");return`${zy}${t}`}s(iR,"buildComponentReference");function aR(e){return Jy.test(e)}s(aR,"validateComponentReference");var we=$r();Object.defineProperty(C,"buildMcpFamilyCanonicalKey",{enumerable:!0,get:s(function(){return we.buildMcpFamilyCanonicalKey},"get")});Object.defineProperty(C,"foldMcpName",{enumerable:!0,get:s(function(){return we.foldMcpName},"get")});Object.defineProperty(C,"hashMcpLaunchIdentity",{enumerable:!0,get:s(function(){return we.hashMcpLaunchIdentity},"get")});Object.defineProperty(C,"launchContainsCredentials",{enumerable:!0,get:s(function(){return we.launchContainsCredentials},"get")});Object.defineProperty(C,"maskMcpLaunchForDisplay",{enumerable:!0,get:s(function(){return we.maskMcpLaunchForDisplay},"get")});Object.defineProperty(C,"MCP_LAUNCH_IDENTITY_ALGORITHM",{enumerable:!0,get:s(function(){return we.MCP_LAUNCH_IDENTITY_ALGORITHM},"get")});Object.defineProperty(C,"MCP_MISSING_LAUNCH_SERIALIZED",{enumerable:!0,get:s(function(){return we.MCP_MISSING_LAUNCH_SERIALIZED},"get")});Object.defineProperty(C,"normalizeMcpToolNames",{enumerable:!0,get:s(function(){return we.normalizeMcpToolNames},"get")});Object.defineProperty(C,"projectMcpLaunchIdentity",{enumerable:!0,get:s(function(){return we.projectMcpLaunchIdentity},"get")});Object.defineProperty(C,"projectMcpMissingLaunchIdentity",{enumerable:!0,get:s(function(){return we.projectMcpMissingLaunchIdentity},"get")});Object.defineProperty(C,"serializeMcpLaunchIdentity",{enumerable:!0,get:s(function(){return we.serializeMcpLaunchIdentity},"get")});var Qt=Br();Object.defineProperty(C,"PACKAGE_FIELD_MAX",{enumerable:!0,get:s(function(){return Qt.PACKAGE_FIELD_MAX},"get")});Object.defineProperty(C,"npxExecBin",{enumerable:!0,get:s(function(){return Qt.npxExecBin},"get")});Object.defineProperty(C,"npxPackageSpecs",{enumerable:!0,get:s(function(){return Qt.npxPackageSpecs},"get")});Object.defineProperty(C,"packageNameFromSpec",{enumerable:!0,get:s(function(){return Qt.packageNameFromSpec},"get")});Object.defineProperty(C,"pinnedPackageVersionFromNpx",{enumerable:!0,get:s(function(){return Qt.pinnedPackageVersionFromNpx},"get")});Object.defineProperty(C,"pinnedPackageVersionFromSpec",{enumerable:!0,get:s(function(){return Qt.pinnedPackageVersionFromSpec},"get")});var Il=dl();Object.defineProperty(C,"McpPackageEcosystem",{enumerable:!0,get:s(function(){return Il.McpPackageEcosystem},"get")});Object.defineProperty(C,"resolveMcpPackageIdentity",{enumerable:!0,get:s(function(){return Il.resolveMcpPackageIdentity},"get")});var Wr=Sl();Object.defineProperty(C,"classifyMcpProvenance",{enumerable:!0,get:s(function(){return Wr.classifyMcpProvenance},"get")});Object.defineProperty(C,"displayPublisherName",{enumerable:!0,get:s(function(){return Wr.displayPublisherName},"get")});Object.defineProperty(C,"EMPTY_NPM_PUBLISHER",{enumerable:!0,get:s(function(){return Wr.EMPTY_NPM_PUBLISHER},"get")});Object.defineProperty(C,"isNpmRegistryPublisher",{enumerable:!0,get:s(function(){return Wr.isNpmRegistryPublisher},"get")});var Tl=yl();Object.defineProperty(C,"mcpServerNameMatchesToolSegment",{enumerable:!0,get:s(function(){return Tl.mcpServerNameMatchesToolSegment},"get")});Object.defineProperty(C,"mcpServerToolSegmentForms",{enumerable:!0,get:s(function(){return Tl.mcpServerToolSegmentForms},"get")});var Ls=Rl();Object.defineProperty(C,"parseFrontmatterDescription",{enumerable:!0,get:s(function(){return Ls.parseFrontmatterDescription},"get")});Object.defineProperty(C,"parseFrontmatterField",{enumerable:!0,get:s(function(){return Ls.parseFrontmatterField},"get")});Object.defineProperty(C,"usableCatalogText",{enumerable:!0,get:s(function(){return Ls.usableCatalogText},"get")});var ht=bl();Object.defineProperty(C,"COMPONENT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return ht.COMPONENT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(C,"COMPONENT_SOURCE_REDACTION_PLACEHOLDER",{enumerable:!0,get:s(function(){return ht.COMPONENT_SOURCE_REDACTION_PLACEHOLDER},"get")});Object.defineProperty(C,"SNAPSHOT_INSPECTION_TEXT_MAX_BYTES",{enumerable:!0,get:s(function(){return ht.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES},"get")});Object.defineProperty(C,"capComponentTextBytes",{enumerable:!0,get:s(function(){return ht.capComponentTextBytes},"get")});Object.defineProperty(C,"componentSourceContainsRedactableSecret",{enumerable:!0,get:s(function(){return ht.componentSourceContainsRedactableSecret},"get")});Object.defineProperty(C,"fitSnapshotInspectionTextBudget",{enumerable:!0,get:s(function(){return ht.fitSnapshotInspectionTextBudget},"get")});Object.defineProperty(C,"prepareComponentInspectionText",{enumerable:!0,get:s(function(){return ht.prepareComponentInspectionText},"get")});Object.defineProperty(C,"redactComponentSource",{enumerable:!0,get:s(function(){return ht.redactComponentSource},"get")})});var lo=Y(Oe=>{"use strict";Oe.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Oe.find=(e,t)=>e.nodes.find(n=>n.type===t);Oe.exceedsLimit=(e,t,n=1,r)=>r===!1||!Oe.isInteger(e)||!Oe.isInteger(t)?!1:(Number(t)-Number(e))/Number(n)>=r;Oe.escapeNode=(e,t=0,n)=>{let r=e.nodes[t];r&&(n&&r.type===n||r.type==="open"||r.type==="close")&&r.escaped!==!0&&(r.value="\\"+r.value,r.escaped=!0)};Oe.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Oe.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;Oe.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Oe.reduce=e=>e.reduce((t,n)=>(n.type==="text"&&t.push(n.value),n.type==="range"&&(n.type="text"),t),[]);Oe.flatten=(...e)=>{let t=[],n=s(r=>{for(let o=0;o<r.length;o++){let i=r[o];if(Array.isArray(i)){n(i);continue}i!==void 0&&t.push(i)}return t},"flat");return n(e),t}});var fo=Y(($L,ad)=>{"use strict";var id=lo();ad.exports=(e,t={})=>{let n=s((r,o={})=>{let i=t.escapeInvalid&&id.isInvalidBrace(o),a=r.invalid===!0&&t.escapeInvalid===!0,c="";if(r.value)return(i||a)&&id.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 ud=Y((BL,cd)=>{"use strict";cd.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var Sd=Y((KL,hd)=>{"use strict";var ld=ud(),vt=s((e,t,n)=>{if(ld(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(ld(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(vt.cache.hasOwnProperty(u))return vt.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=_d(e)||_d(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=fd(h,Math.abs(f),d,r),f=d.a=0}return l>=0&&(m=fd(f,l,d,r)),d.negatives=g,d.positives=m,d.result=BA(g,m,r),r.capture===!0?d.result=`(${d.result})`:r.wrap!==!1&&m.length+g.length>1&&(d.result=`(?:${d.result})`),vt.cache[u]=d,d.result},"toRegexRange");function BA(e,t,n){let r=mi(e,t,"-",!1,n)||[],o=mi(t,e,"",!1,n)||[],i=mi(e,t,"-?",!0,n)||[];return r.concat(i).concat(o).join("|")}s(BA,"collatePatterns");function KA(e,t){let n=1,r=1,o=pd(e,n),i=new Set([t]);for(;e<=o&&o<=t;)i.add(o),n+=1,o=pd(e,n);for(o=md(t+1,r)-1;e<o&&o<=t;)i.add(o),r+=1,o=md(t+1,r)-1;return i=[...i],i.sort(VA),i}s(KA,"splitToRanges");function GA(e,t,n){if(e===t)return{pattern:e,count:[],digits:0};let r=WA(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+=zA(u,f,n):a++}return a&&(i+=n.shorthand===!0?"\\d":"[0-9]"),{pattern:i,count:[a],digits:o}}s(GA,"rangeToPattern");function fd(e,t,n,r){let o=KA(e,t),i=[],a=e,c;for(let u=0;u<o.length;u++){let f=o[u],l=GA(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+gd(c.count),a=f+1;continue}n.isPadded&&(p=JA(f,n,r)),l.string=p+l.pattern+gd(l.count),i.push(l),a=f+1,c=l}return i}s(fd,"splitToPatterns");function mi(e,t,n,r,o){let i=[];for(let a of e){let{string:c}=a;!r&&!dd(t,"string",c)&&i.push(n+c),r&&dd(t,"string",c)&&i.push(n+c)}return i}s(mi,"filterPatterns");function WA(e,t){let n=[];for(let r=0;r<e.length;r++)n.push([e[r],t[r]]);return n}s(WA,"zip");function VA(e,t){return e>t?1:t>e?-1:0}s(VA,"compare");function dd(e,t,n){return e.some(r=>r[t]===n)}s(dd,"contains");function pd(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}s(pd,"countNines");function md(e,t){return e-e%Math.pow(10,t)}s(md,"countZeros");function gd(e){let[t=0,n=""]=e;return n||t>1?`{${t+(n?","+n:"")}}`:""}s(gd,"toQuantifier");function zA(e,t,n){return`[${e}${t-e===1?"":"-"}${t}]`}s(zA,"toCharacterClass");function _d(e){return/^-?(0+)\d/.test(e)}s(_d,"hasPadding");function JA(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(JA,"padZeros");vt.cache={};vt.clearCache=()=>vt.cache={};hd.exports=vt});var hi=Y((WL,kd)=>{"use strict";var YA=rt("util"),yd=Sd(),Ed=s(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"isObject"),XA=s(e=>t=>e===!0?Number(t):String(t),"transform"),gi=s(e=>typeof e=="number"||typeof e=="string"&&e!=="","isValidValue"),Fn=s(e=>Number.isInteger(+e),"isNumber"),_i=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"),qA=s((e,t,n)=>typeof e=="string"||typeof t=="string"?!0:n.stringify===!0,"stringify"),ZA=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"),mo=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"),QA=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=>mo(String(c),n)).join("|")),e.negatives.length&&(i=`-(${r}${e.negatives.map(c=>mo(String(c),n)).join("|")})`),o&&i?a=`${o}|${i}`:a=o||i,t.wrap?`(${r}${a})`:a},"toSequence"),Rd=s((e,t,n,r)=>{if(n)return yd(e,t,{wrap:!1,...r});let o=String.fromCharCode(e);if(e===t)return o;let i=String.fromCharCode(t);return`[${o}-${i}]`},"toRange"),Cd=s((e,t,n)=>{if(Array.isArray(e)){let r=n.wrap===!0,o=n.capture?"":"?:";return r?`(${o}${e.join("|")})`:e.join("|")}return yd(e,t,n)},"toRegex"),Ad=s((...e)=>new RangeError("Invalid range arguments: "+YA.inspect(...e)),"rangeError"),bd=s((e,t,n)=>{if(n.strictRanges===!0)throw Ad([e,t]);return[]},"invalidRange"),eb=s((e,t)=>{if(t.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},"invalidStep"),tb=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 Ad([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=_i(c)||_i(u)||_i(f),p=l?Math.max(c.length,u.length,f.length):0,d=l===!1&&qA(e,t,r)===!1,m=r.transform||XA(d);if(r.toRegex&&n===1)return Rd(mo(e,p),mo(t,p),!0,r);let g={negatives:[],positives:[]},h=s(P=>g[P<0?"negatives":"positives"].push(Math.abs(P)),"push"),y=[],k=0;for(;a?o>=i:o<=i;)r.toRegex===!0&&n>1?h(o):y.push(ZA(m(o,k),p,d)),o=a?o-n:o+n,k++;return r.toRegex===!0?n>1?QA(g,r,p):Cd(y,null,{wrap:!1,...r}):y},"fillNumbers"),nb=s((e,t,n=1,r={})=>{if(!Fn(e)&&e.length>1||!Fn(t)&&t.length>1)return bd(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 Rd(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?Cd(l,null,{wrap:!1,options:r}):l},"fillLetters"),po=s((e,t,n,r={})=>{if(t==null&&gi(e))return[e];if(!gi(e)||!gi(t))return bd(e,t,r);if(typeof n=="function")return po(e,t,1,{transform:n});if(Ed(n))return po(e,t,0,n);let o={...r};return o.capture===!0&&(o.wrap=!0),n=n||o.step||1,Fn(n)?Fn(e)&&Fn(t)?tb(e,t,n,o):nb(e,t,Math.max(Math.abs(n),1),o):n!=null&&!Ed(n)?eb(n,o):po(e,t,1,n)},"fill");kd.exports=po});var Id=Y((zL,Od)=>{"use strict";var rb=hi(),xd=lo(),ob=s((e,t={})=>{let n=s((r,o={})=>{let i=xd.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=xd.reduce(r.nodes),p=rb(...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");Od.exports=ob});var wd=Y((YL,Pd)=>{"use strict";var sb=hi(),Td=fo(),rn=lo(),Lt=s((e="",t="",n=!1)=>{let r=[];if(e=[].concat(e),t=[].concat(t),!t.length)return e;if(!e.length)return n?rn.flatten(t).map(o=>`{${o}}`):t;for(let o of e)if(Array.isArray(o))for(let i of o)r.push(Lt(i,t,n));else for(let i of t)n===!0&&typeof i=="string"&&(i=`{${i}}`),r.push(Array.isArray(i)?Lt(o,i,n):o+i);return rn.flatten(r)},"append"),ib=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(Lt(c.pop(),Td(o,t)));return}if(o.type==="brace"&&o.invalid!==!0&&o.nodes.length===2){c.push(Lt(c.pop(),["{}"]));return}if(o.nodes&&o.ranges>0){let p=rn.reduce(o.nodes);if(rn.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=sb(...p,t);d.length===0&&(d=Td(o,t)),c.push(Lt(c.pop(),d)),o.nodes=[];return}let u=rn.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(Lt(c.pop(),f,u));continue}if(d.value&&d.type!=="open"){f.push(Lt(f.pop(),d.value));continue}d.nodes&&r(d,o)}return f},"walk");return rn.flatten(r(e))},"expand");Pd.exports=ib});var vd=Y((qL,Nd)=>{"use strict";Nd.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
14
|
+
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Dd=Y((ZL,Ud)=>{"use strict";var ab=fo(),{MAX_LENGTH:Ld,CHAR_BACKSLASH:Si,CHAR_BACKTICK:cb,CHAR_COMMA:ub,CHAR_DOT:lb,CHAR_LEFT_PARENTHESES:fb,CHAR_RIGHT_PARENTHESES:db,CHAR_LEFT_CURLY_BRACE:pb,CHAR_RIGHT_CURLY_BRACE:mb,CHAR_LEFT_SQUARE_BRACKET:Md,CHAR_RIGHT_SQUARE_BRACKET:Hd,CHAR_DOUBLE_QUOTE:gb,CHAR_SINGLE_QUOTE:_b,CHAR_NO_BREAK_SPACE:hb,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Sb}=vd(),Eb=s((e,t={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let n=t||{},r=typeof n.maxLength=="number"?Math.min(Ld,n.maxLength):Ld;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===Sb||d===hb)){if(d===Si){g({type:"text",value:(t.keepEscaping?d:"")+m()});continue}if(d===Hd){g({type:"text",value:"\\"+d});continue}if(d===Md){u++;let h;for(;l<f&&(h=m());){if(d+=h,h===Md){u++;continue}if(h===Si){d+=m();continue}if(h===Hd&&(u--,u===0))break}g({type:"text",value:d});continue}if(d===fb){a=g({type:"paren",nodes:[]}),i.push(a),g({type:"text",value:d});continue}if(d===db){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===gb||d===_b||d===cb){let h=d,y;for(t.keepQuotes!==!0&&(d="");l<f&&(y=m());){if(y===Si){d+=y+m();continue}if(y===h){t.keepQuotes===!0&&(d+=y);break}d+=y}g({type:"text",value:d});continue}if(d===pb){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===mb){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===ub&&p>0){if(a.ranges>0){a.ranges=0;let h=a.nodes.shift();a.nodes=[h,{type:"text",value:ab(a)}]}g({type:"comma",value:d}),a.commas++;continue}if(d===lb&&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(k=>{k.nodes||(k.type==="open"&&(k.isOpen=!0),k.type==="close"&&(k.isClose=!0),k.nodes||(k.type="text"),k.invalid=!0)});let h=i[i.length-1],y=h.nodes.indexOf(a);h.nodes.splice(y,1,...a.nodes)}while(i.length>0);return g({type:"eos"}),o},"parse");Ud.exports=Eb});var jd=Y((eM,$d)=>{"use strict";var Fd=fo(),yb=Id(),Rb=wd(),Cb=Dd(),Ce=s((e,t={})=>{let n=[];if(Array.isArray(e))for(let r of e){let o=Ce.create(r,t);Array.isArray(o)?n.push(...o):n.push(o)}else n=[].concat(Ce.create(e,t));return t&&t.expand===!0&&t.nodupes===!0&&(n=[...new Set(n)]),n},"braces");Ce.parse=(e,t={})=>Cb(e,t);Ce.stringify=(e,t={})=>Fd(typeof e=="string"?Ce.parse(e,t):e,t);Ce.compile=(e,t={})=>(typeof e=="string"&&(e=Ce.parse(e,t)),yb(e,t));Ce.expand=(e,t={})=>{typeof e=="string"&&(e=Ce.parse(e,t));let n=Rb(e,t);return t.noempty===!0&&(n=n.filter(Boolean)),t.nodupes===!0&&(n=[...new Set(n)]),n};Ce.create=(e,t={})=>e===""||e.length<3?[e]:t.expand!==!0?Ce.compile(e,t):Ce.expand(e,t);$d.exports=Ce});var $n=Y((nM,Vd)=>{"use strict";var Ab=rt("path"),$e="\\\\/",Bd=`[^${$e}]`,bb=0,tt="\\.",kb="\\+",xb="\\?",go="\\/",Ob="(?=.)",Kd="[^/]",Ei=`(?:${go}|$)`,Gd=`(?:^|${go})`,yi=`${tt}{1,2}${Ei}`,Ib=`(?!${tt})`,Tb=`(?!${Gd}${yi})`,Pb=`(?!${tt}{0,1}${Ei})`,wb=`(?!${yi})`,Nb=`[^.${go}]`,vb=`${Kd}*?`,Wd={DOT_LITERAL:tt,PLUS_LITERAL:kb,QMARK_LITERAL:xb,SLASH_LITERAL:go,ONE_CHAR:Ob,QMARK:Kd,END_ANCHOR:Ei,DOTS_SLASH:yi,NO_DOT:Ib,NO_DOTS:Tb,NO_DOT_SLASH:Pb,NO_DOTS_SLASH:wb,QMARK_NO_DOT:Nb,STAR:vb,START_ANCHOR:Gd},Lb={...Wd,SLASH_LITERAL:`[${$e}]`,QMARK:Bd,STAR:`${Bd}*?`,DOTS_SLASH:`${tt}{1,2}(?:[${$e}]|$)`,NO_DOT:`(?!${tt})`,NO_DOTS:`(?!(?:^|[${$e}])${tt}{1,2}(?:[${$e}]|$))`,NO_DOT_SLASH:`(?!${tt}{0,1}(?:[${$e}]|$))`,NO_DOTS_SLASH:`(?!${tt}{1,2}(?:[${$e}]|$))`,QMARK_NO_DOT:`[^.${$e}]`,START_ANCHOR:`(?:^|[${$e}])`,END_ANCHOR:`(?:[${$e}]|$)`},Mb={__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"};Vd.exports={DEFAULT_MAX_EXTGLOB_RECURSION:bb,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Mb,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:Ab.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?Lb:Wd}}});var jn=Y(he=>{"use strict";var Hb=rt("path"),Ub=process.platform==="win32",{REGEX_BACKSLASH:Db,REGEX_REMOVE_BACKSLASH:Fb,REGEX_SPECIAL_CHARS:$b,REGEX_SPECIAL_CHARS_GLOBAL:jb}=$n();he.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);he.hasRegexChars=e=>$b.test(e);he.isRegexChar=e=>e.length===1&&he.hasRegexChars(e);he.escapeRegex=e=>e.replace(jb,"\\$1");he.toPosixSlashes=e=>e.replace(Db,"/");he.removeBackslashes=e=>e.replace(Fb,t=>t==="\\"?"":t);he.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};he.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:Ub===!0||Hb.sep==="\\";he.escapeLast=(e,t,n)=>{let r=e.lastIndexOf(t,n);return r===-1?e:e[r-1]==="\\"?he.escapeLast(e,t,r-1):`${e.slice(0,r)}\\${e.slice(r)}`};he.removePrefix=(e,t={})=>{let n=e;return n.startsWith("./")&&(n=n.slice(2),t.prefix="./"),n};he.wrapOutput=(e,t={},n={})=>{let r=n.contains?"":"^",o=n.contains?"":"$",i=`${r}(?:${e})${o}`;return t.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var ep=Y((oM,Qd)=>{"use strict";var zd=jn(),{CHAR_ASTERISK:Ri,CHAR_AT:Bb,CHAR_BACKWARD_SLASH:Bn,CHAR_COMMA:Kb,CHAR_DOT:Ci,CHAR_EXCLAMATION_MARK:Ai,CHAR_FORWARD_SLASH:Zd,CHAR_LEFT_CURLY_BRACE:bi,CHAR_LEFT_PARENTHESES:ki,CHAR_LEFT_SQUARE_BRACKET:Gb,CHAR_PLUS:Wb,CHAR_QUESTION_MARK:Jd,CHAR_RIGHT_CURLY_BRACE:Vb,CHAR_RIGHT_PARENTHESES:Yd,CHAR_RIGHT_SQUARE_BRACKET:zb}=$n(),Xd=s(e=>e===Zd||e===Bn,"isPathSeparator"),qd=s(e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},"depth"),Jb=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,k=!1,P=!1,w=!1,O=!1,x=!1,L=0,v,I,N={value:"",depth:0,isGlob:!1},F=s(()=>f>=r,"eos"),_=s(()=>u.charCodeAt(f+1),"peek"),T=s(()=>(v=I,u.charCodeAt(++f)),"advance");for(;f<r;){I=T();let pe;if(I===Bn){P=N.backslashes=!0,I=T(),I===bi&&(k=!0);continue}if(k===!0||I===bi){for(L++;F()!==!0&&(I=T());){if(I===Bn){P=N.backslashes=!0,T();continue}if(I===bi){L++;continue}if(k!==!0&&I===Ci&&(I=T())===Ci){if(d=N.isBrace=!0,g=N.isGlob=!0,x=!0,o===!0)continue;break}if(k!==!0&&I===Kb){if(d=N.isBrace=!0,g=N.isGlob=!0,x=!0,o===!0)continue;break}if(I===Vb&&(L--,L===0)){k=!1,d=N.isBrace=!0,x=!0;break}}if(o===!0)continue;break}if(I===Zd){if(i.push(f),a.push(N),N={value:"",depth:0,isGlob:!1},x===!0)continue;if(v===Ci&&f===l+1){l+=2;continue}p=f+1;continue}if(n.noext!==!0&&(I===Wb||I===Bb||I===Ri||I===Jd||I===Ai)===!0&&_()===ki){if(g=N.isGlob=!0,h=N.isExtglob=!0,x=!0,I===Ai&&f===l&&(O=!0),o===!0){for(;F()!==!0&&(I=T());){if(I===Bn){P=N.backslashes=!0,I=T();continue}if(I===Yd){g=N.isGlob=!0,x=!0;break}}continue}break}if(I===Ri){if(v===Ri&&(y=N.isGlobstar=!0),g=N.isGlob=!0,x=!0,o===!0)continue;break}if(I===Jd){if(g=N.isGlob=!0,x=!0,o===!0)continue;break}if(I===Gb){for(;F()!==!0&&(pe=T());){if(pe===Bn){P=N.backslashes=!0,T();continue}if(pe===zb){m=N.isBracket=!0,g=N.isGlob=!0,x=!0;break}}if(o===!0)continue;break}if(n.nonegate!==!0&&I===Ai&&f===l){w=N.negated=!0,l++;continue}if(n.noparen!==!0&&I===ki){if(g=N.isGlob=!0,o===!0){for(;F()!==!0&&(I=T());){if(I===ki){P=N.backslashes=!0,I=T();continue}if(I===Yd){x=!0;break}}continue}break}if(g===!0){if(x=!0,o===!0)continue;break}}n.noext===!0&&(h=!1,g=!1);let j=u,Ee="",S="";l>0&&(Ee=u.slice(0,l),u=u.slice(l),p-=l),j&&g===!0&&p>0?(j=u.slice(0,p),S=u.slice(p)):g===!0?(j="",S=u):j=u,j&&j!==""&&j!=="/"&&j!==u&&Xd(j.charCodeAt(j.length-1))&&(j=j.slice(0,-1)),n.unescape===!0&&(S&&(S=zd.removeBackslashes(S)),j&&P===!0&&(j=zd.removeBackslashes(j)));let E={prefix:Ee,input:e,start:l,base:j,glob:S,isBrace:d,isBracket:m,isGlob:g,isExtglob:h,isGlobstar:y,negated:w,negatedExtglob:O};if(n.tokens===!0&&(E.maxDepth=0,Xd(I)||a.push(N),E.tokens=a),n.parts===!0||n.tokens===!0){let pe;for(let B=0;B<i.length;B++){let Ne=pe?pe+1:l,ve=i[B],ye=e.slice(Ne,ve);n.tokens&&(B===0&&l!==0?(a[B].isPrefix=!0,a[B].value=Ee):a[B].value=ye,qd(a[B]),E.maxDepth+=a[B].depth),(B!==0||ye!=="")&&c.push(ye),pe=ve}if(pe&&pe+1<e.length){let B=e.slice(pe+1);c.push(B),n.tokens&&(a[a.length-1].value=B,qd(a[a.length-1]),E.maxDepth+=a[a.length-1].depth)}E.slashes=i,E.parts=c}return E},"scan");Qd.exports=Jb});var sp=Y((iM,op)=>{"use strict";var Kn=$n(),de=jn(),{MAX_LENGTH:_o,POSIX_REGEX_SOURCE:Yb,REGEX_NON_SPECIAL_CHARS:Xb,REGEX_SPECIAL_CHARS_BACKREF:qb,REPLACEMENTS:tp}=Kn,Zb=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=>de.escapeRegex(o)).join("..")}return n},"expandRange"),on=s((e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,"syntaxError"),np=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"),Qb=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"),rp=s(e=>{let t=e.trim(),n=!0;for(;n===!0;)n=!1,/^@\([^\\()[\]{}|]+\)$/.test(t)&&(t=t.slice(2,-1),n=!0);if(Qb(t))return t.replace(/\\(.)/g,"$1")},"normalizeSimpleBranch"),ek=s(e=>{let t=e.map(rp).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"),xi=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"),tk=s(e=>{let t=0,n=[];for(;t<e.length;){let o=xi(e.slice(t),!1);if(!o||o.type!=="*")return;let i=np(o.body).map(c=>c.trim());if(i.length!==1)return;let a=rp(i[0]);if(!a||a.length!==1)return;n.push(a),t+=o.end+1}return n.length<1?void 0:`${n.length===1?de.escapeRegex(n[0]):`[${n.map(o=>de.escapeRegex(o)).join("")}]`}*`},"getStarExtglobSequenceOutput"),nk=s(e=>{let t=0,n=e.trim(),r=xi(n);for(;r;)t++,n=r.body.trim(),r=xi(n);return t},"repeatedExtglobRecursion"),rk=s((e,t)=>{if(t.maxExtglobRecursion===!1)return{risky:!1};let n=typeof t.maxExtglobRecursion=="number"?t.maxExtglobRecursion:Kn.DEFAULT_MAX_EXTGLOB_RECURSION,r=np(e).map(o=>o.trim());if(r.length>1&&(r.some(o=>o==="")||r.some(o=>/^[*?]+$/.test(o))||ek(r)))return{risky:!0};for(let o of r){let i=tk(o);if(i)return{risky:!0,safeOutput:i};if(nk(o)>n)return{risky:!0}}return{risky:!1}},"analyzeRepeatedExtglob"),Oi=s((e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=tp[e]||e;let n={...t},r=typeof n.maxLength=="number"?Math.min(_o,n.maxLength):_o,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=de.isWindows(t),f=Kn.globChars(u),l=Kn.extglobChars(f),{DOT_LITERAL:p,PLUS_LITERAL:d,SLASH_LITERAL:m,ONE_CHAR:g,DOTS_SLASH:h,NO_DOT:y,NO_DOT_SLASH:k,NO_DOTS_SLASH:P,QMARK:w,QMARK_NO_DOT:O,STAR:x,START_ANCHOR:L}=f,v=s(b=>`(${c}(?:(?!${L}${b.dot?h:p}).)*?)`,"globstar"),I=n.dot?"":y,N=n.dot?w:O,F=n.bash===!0?v(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=de.removePrefix(e,_),o=e.length;let T=[],j=[],Ee=[],S=i,E,pe=s(()=>_.index===o-1,"eos"),B=_.peek=(b=1)=>e[_.index+b],Ne=_.advance=()=>e[++_.index]||"",ve=s(()=>e.slice(_.index+1),"remaining"),ye=s((b="",q=0)=>{_.consumed+=b,_.index+=q},"consume"),er=s(b=>{_.output+=b.output!=null?b.output:b.value,ye(b.value)},"append"),wg=s(()=>{let b=1;for(;B()==="!"&&(B(2)!=="("||B(3)==="?");)Ne(),_.start++,b++;return b%2===0?!1:(_.negated=!0,_.start++,!0)},"negate"),tr=s(b=>{_[b]++,Ee.push(b)},"increment"),nt=s(b=>{_[b]--,Ee.pop()},"decrement"),U=s(b=>{if(S.type==="globstar"){let q=_.braces>0&&(b.type==="comma"||b.type==="brace"),A=b.extglob===!0||T.length&&(b.type==="pipe"||b.type==="paren");b.type!=="slash"&&b.type!=="paren"&&!q&&!A&&(_.output=_.output.slice(0,-S.output.length),S.type="star",S.value="*",S.output=F,_.output+=S.output)}if(T.length&&b.type!=="paren"&&(T[T.length-1].inner+=b.value),(b.value||b.output)&&er(b),S&&S.type==="text"&&b.type==="text"){S.value+=b.value,S.output=(S.output||"")+b.value;return}b.prev=S,a.push(b),S=b},"push"),nr=s((b,q)=>{let A={...l[q],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;tr("parens"),U({type:b,value:q,output:_.output?"":g}),U({type:"paren",extglob:!0,value:Ne(),output:M}),T.push(A)},"extglobOpen"),Ng=s(b=>{let q=e.slice(b.startIndex,_.index+1),A=e.slice(b.startIndex+2,_.index),M=rk(A,n);if((b.type==="plus"||b.type==="star")&&M.risky){let V=M.safeOutput?(b.output?"":g)+(n.capture?`(${M.safeOutput})`:M.safeOutput):void 0,Le=a[b.tokensIndex];Le.type="text",Le.value=q,Le.output=V||de.escapeRegex(q);for(let Me=b.tokensIndex+1;Me<a.length;Me++)a[Me].value="",a[Me].output="",delete a[Me].suffix;_.output=b.output+Le.output,_.backtrack=!0,U({type:"paren",extglob:!0,value:E,output:""}),nt("parens");return}let J=b.close+(n.capture?")":""),ae;if(b.type==="negate"){let V=F;if(b.inner&&b.inner.length>1&&b.inner.includes("/")&&(V=v(n)),(V!==F||pe()||/^\)+$/.test(ve()))&&(J=b.close=`)$))${V}`),b.inner.includes("*")&&(ae=ve())&&/^\.[^\\/.]+$/.test(ae)){let Le=Oi(ae,{...t,fastpaths:!1}).output;J=b.close=`)${Le})${V})`}b.prev.type==="bos"&&(_.negatedExtglob=!0)}U({type:"paren",extglob:!0,value:E,output:J}),nt("parens")},"extglobClose");if(n.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let b=!1,q=e.replace(qb,(A,M,J,ae,V,Le)=>ae==="\\"?(b=!0,A):ae==="?"?M?M+ae+(V?w.repeat(V.length):""):Le===0?N+(V?w.repeat(V.length):""):w.repeat(J.length):ae==="."?p.repeat(J.length):ae==="*"?M?M+ae+(V?F:""):F:M?A:`\\${A}`);return b===!0&&(n.unescape===!0?q=q.replace(/\\/g,""):q=q.replace(/\\+/g,A=>A.length%2===0?"\\\\":A?"\\":"")),q===e&&n.contains===!0?(_.output=e,_):(_.output=de.wrapOutput(q,_,t),_)}for(;!pe();){if(E=Ne(),E==="\0")continue;if(E==="\\"){let A=B();if(A==="/"&&n.bash!==!0||A==="."||A===";")continue;if(!A){E+="\\",U({type:"text",value:E});continue}let M=/^\\+/.exec(ve()),J=0;if(M&&M[0].length>2&&(J=M[0].length,_.index+=J,J%2!==0&&(E+="\\")),n.unescape===!0?E=Ne():E+=Ne(),_.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("["),J=S.value.slice(0,M),ae=S.value.slice(M+2),V=Yb[ae];if(V){S.value=J+V,_.backtrack=!0,Ne(),!i.output&&a.indexOf(S)===1&&(i.output=g);continue}}}(E==="["&&B()!==":"||E==="-"&&B()==="]")&&(E=`\\${E}`),E==="]"&&(S.value==="["||S.value==="[^")&&(E=`\\${E}`),n.posix===!0&&E==="!"&&S.value==="["&&(E="^"),S.value+=E,er({value:E});continue}if(_.quotes===1&&E!=='"'){E=de.escapeRegex(E),S.value+=E,er({value:E});continue}if(E==='"'){_.quotes=_.quotes===1?0:1,n.keepQuotes===!0&&U({type:"text",value:E});continue}if(E==="("){tr("parens"),U({type:"paren",value:E});continue}if(E===")"){if(_.parens===0&&n.strictBrackets===!0)throw new SyntaxError(on("opening","("));let A=T[T.length-1];if(A&&_.parens===A.parens+1){Ng(T.pop());continue}U({type:"paren",value:E,output:_.parens?")":"\\)"}),nt("parens");continue}if(E==="["){if(n.nobracket===!0||!ve().includes("]")){if(n.nobracket!==!0&&n.strictBrackets===!0)throw new SyntaxError(on("closing","]"));E=`\\${E}`}else tr("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(on("opening","["));U({type:"text",value:E,output:`\\${E}`});continue}nt("brackets");let A=S.value.slice(1);if(S.posix!==!0&&A[0]==="^"&&!A.includes("/")&&(E=`/${E}`),S.value+=E,er({value:E}),n.literalBrackets===!1||de.hasRegexChars(A))continue;let M=de.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){tr("braces");let A={type:"brace",value:E,output:"(",outputIndex:_.output.length,tokensIndex:_.tokens.length};j.push(A),U(A);continue}if(E==="}"){let A=j[j.length-1];if(n.nobrace===!0||!A){U({type:"text",value:E,output:E});continue}let M=")";if(A.dots===!0){let J=a.slice(),ae=[];for(let V=J.length-1;V>=0&&(a.pop(),J[V].type!=="brace");V--)J[V].type!=="dots"&&ae.unshift(J[V].value);M=Zb(ae,n),_.backtrack=!0}if(A.comma!==!0&&A.dots!==!0){let J=_.output.slice(0,A.outputIndex),ae=_.tokens.slice(A.tokensIndex);A.value=A.output="\\{",E=M="\\}",_.output=J;for(let V of ae)_.output+=V.output||V.value}U({type:"brace",value:E,output:M}),nt("braces"),j.pop();continue}if(E==="|"){T.length>0&&T[T.length-1].conditions++,U({type:"text",value:E});continue}if(E===","){let A=E,M=j[j.length-1];M&&Ee[Ee.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=j[j.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&&B()==="("&&B(2)!=="?"){nr("qmark",E);continue}if(S&&S.type==="paren"){let M=B(),J=E;if(M==="<"&&!de.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(S.value==="("&&!/[!=<:]/.test(M)||M==="<"&&!/<([!=]|\w+>)/.test(ve()))&&(J=`\\${E}`),U({type:"text",value:E,output:J});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:w});continue}if(E==="!"){if(n.noextglob!==!0&&B()==="("&&(B(2)!=="?"||!/[!=<:]/.test(B(3)))){nr("negate",E);continue}if(n.nonegate!==!0&&_.index===0){wg();continue}}if(E==="+"){if(n.noextglob!==!0&&B()==="("&&B(2)!=="?"){nr("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&&B()==="("&&B(2)!=="?"){U({type:"at",extglob:!0,value:E,output:""});continue}U({type:"text",value:E});continue}if(E!=="*"){(E==="$"||E==="^")&&(E=`\\${E}`);let A=Xb.exec(ve());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,ye(E);continue}let b=ve();if(n.noextglob!==!0&&/^\([^?]/.test(b)){nr("star",E);continue}if(S.type==="star"){if(n.noglobstar===!0){ye(E);continue}let A=S.prev,M=A.prev,J=A.type==="slash"||A.type==="bos",ae=M&&(M.type==="star"||M.type==="globstar");if(n.bash===!0&&(!J||b[0]&&b[0]!=="/")){U({type:"star",value:E,output:""});continue}let V=_.braces>0&&(A.type==="comma"||A.type==="brace"),Le=T.length&&(A.type==="pipe"||A.type==="paren");if(!J&&A.type!=="paren"&&!V&&!Le){U({type:"star",value:E,output:""});continue}for(;b.slice(0,3)==="/**";){let Me=e[_.index+4];if(Me&&Me!=="/")break;b=b.slice(3),ye("/**",3)}if(A.type==="bos"&&pe()){S.type="globstar",S.value+=E,S.output=v(n),_.output=S.output,_.globstar=!0,ye(E);continue}if(A.type==="slash"&&A.prev.type!=="bos"&&!ae&&pe()){_.output=_.output.slice(0,-(A.output+S.output).length),A.output=`(?:${A.output}`,S.type="globstar",S.output=v(n)+(n.strictSlashes?")":"|$)"),S.value+=E,_.globstar=!0,_.output+=A.output+S.output,ye(E);continue}if(A.type==="slash"&&A.prev.type!=="bos"&&b[0]==="/"){let Me=b[1]!==void 0?"|$":"";_.output=_.output.slice(0,-(A.output+S.output).length),A.output=`(?:${A.output}`,S.type="globstar",S.output=`${v(n)}${m}|${m}${Me})`,S.value+=E,_.output+=A.output+S.output,_.globstar=!0,ye(E+Ne()),U({type:"slash",value:"/",output:""});continue}if(A.type==="bos"&&b[0]==="/"){S.type="globstar",S.value+=E,S.output=`(?:^|${m}|${v(n)}${m})`,_.output=S.output,_.globstar=!0,ye(E+Ne()),U({type:"slash",value:"/",output:""});continue}_.output=_.output.slice(0,-S.output.length),S.type="globstar",S.output=v(n),S.value+=E,_.output+=S.output,_.globstar=!0,ye(E);continue}let q={type:"star",value:E,output:F};if(n.bash===!0){q.output=".*?",(S.type==="bos"||S.type==="slash")&&(q.output=I+q.output),U(q);continue}if(S&&(S.type==="bracket"||S.type==="paren")&&n.regex===!0){q.output=E,U(q);continue}(_.index===_.start||S.type==="slash"||S.type==="dot")&&(S.type==="dot"?(_.output+=k,S.output+=k):n.dot===!0?(_.output+=P,S.output+=P):(_.output+=I,S.output+=I),B()!=="*"&&(_.output+=g,S.output+=g)),U(q)}for(;_.brackets>0;){if(n.strictBrackets===!0)throw new SyntaxError(on("closing","]"));_.output=de.escapeLast(_.output,"["),nt("brackets")}for(;_.parens>0;){if(n.strictBrackets===!0)throw new SyntaxError(on("closing",")"));_.output=de.escapeLast(_.output,"("),nt("parens")}for(;_.braces>0;){if(n.strictBrackets===!0)throw new SyntaxError(on("closing","}"));_.output=de.escapeLast(_.output,"{"),nt("braces")}if(n.strictSlashes!==!0&&(S.type==="star"||S.type==="bracket")&&U({type:"maybe_slash",value:"",output:`${m}?`}),_.backtrack===!0){_.output="";for(let b of _.tokens)_.output+=b.output!=null?b.output:b.value,b.suffix&&(_.output+=b.suffix)}return _},"parse");Oi.fastpaths=(e,t)=>{let n={...t},r=typeof n.maxLength=="number"?Math.min(_o,n.maxLength):_o,o=e.length;if(o>r)throw new SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${r}`);e=tp[e]||e;let i=de.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}=Kn.globChars(i),h=n.dot?p:l,y=n.dot?d:l,k=n.capture?"":"?:",P={negated:!1,prefix:""},w=n.bash===!0?".*?":m;n.capture&&(w=`(${w})`);let O=s(I=>I.noglobstar===!0?w:`(${k}(?:(?!${g}${I.dot?f:a}).)*?)`,"globstar"),x=s(I=>{switch(I){case"*":return`${h}${u}${w}`;case".*":return`${a}${u}${w}`;case"*.*":return`${h}${w}${a}${u}${w}`;case"*/*":return`${h}${w}${c}${u}${y}${w}`;case"**":return h+O(n);case"**/*":return`(?:${h}${O(n)}${c})?${y}${u}${w}`;case"**/*.*":return`(?:${h}${O(n)}${c})?${y}${w}${a}${u}${w}`;case"**/.*":return`(?:${h}${O(n)}${c})?${a}${u}${w}`;default:{let N=/^(.*?)\.(\w+)$/.exec(I);if(!N)return;let F=x(N[1]);return F?F+a+N[2]:void 0}}},"create"),L=de.removePrefix(e,P),v=x(L);return v&&n.strictSlashes!==!0&&(v+=`${c}?`),v};op.exports=Oi});var ap=Y((cM,ip)=>{"use strict";var ok=rt("path"),sk=ep(),Ii=sp(),Ti=jn(),ik=$n(),ak=s(e=>e&&typeof e=="object"&&!Array.isArray(e),"isObject"),oe=s((e,t,n=!1)=>{if(Array.isArray(e)){let l=e.map(d=>oe(d,t,n));return s(d=>{for(let m of l){let g=m(d);if(g)return g}return!1},"arrayMatcher")}let r=ak(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=Ti.isWindows(t),a=r?oe.compileRe(e,t):oe.makeRe(e,t,!1,!0),c=a.state;delete a.state;let u=s(()=>!1,"isIgnored");if(o.ignore){let l={...t,ignore:null,onMatch:null,onResult:null};u=oe(o.ignore,l,n)}let f=s((l,p=!1)=>{let{isMatch:d,match:m,output:g}=oe.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");oe.test=(e,t,n,{glob:r,posix:o}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let i=n||{},a=i.format||(o?Ti.toPosixSlashes:null),c=e===r,u=c&&a?a(e):e;return c===!1&&(u=a?a(e):e,c=u===r),(c===!1||i.capture===!0)&&(i.matchBase===!0||i.basename===!0?c=oe.matchBase(e,t,n,o):c=t.exec(u)),{isMatch:!!c,match:c,output:u}};oe.matchBase=(e,t,n,r=Ti.isWindows(n))=>(t instanceof RegExp?t:oe.makeRe(t,n)).test(ok.basename(e));oe.isMatch=(e,t,n)=>oe(t,n)(e);oe.parse=(e,t)=>Array.isArray(e)?e.map(n=>oe.parse(n,t)):Ii(e,{...t,fastpaths:!1});oe.scan=(e,t)=>sk(e,t);oe.compileRe=(e,t,n=!1,r=!1)=>{if(n===!0)return e.output;let o=t||{},i=o.contains?"":"^",a=o.contains?"":"$",c=`${i}(?:${e.output})${a}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let u=oe.toRegex(c,t);return r===!0&&(u.state=e),u};oe.makeRe=(e,t={},n=!1,r=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let o={negated:!1,fastpaths:!0};return t.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(o.output=Ii.fastpaths(e,t)),o.output||(o=Ii(e,t)),oe.compileRe(o,t,n,r)};oe.toRegex=(e,t)=>{try{let n=t||{};return new RegExp(e,n.flags||(n.nocase?"i":""))}catch(n){if(t&&t.debug===!0)throw n;return/$^/}};oe.constants=ik;ip.exports=oe});var up=Y((lM,cp)=>{"use strict";cp.exports=ap()});var gp=Y((fM,mp)=>{"use strict";var fp=rt("util"),dp=jd(),je=up(),Pi=jn(),lp=s(e=>e===""||e==="./","isEmptyString"),pp=s(e=>{let t=e.indexOf("{");return t>-1&&e.indexOf("}",t)>-1},"hasBraces"),X=s((e,t,n)=>{t=[].concat(t),e=[].concat(e);let r=new Set,o=new Set,i=new Set,a=0,c=s(l=>{i.add(l.output),n&&n.onResult&&n.onResult(l)},"onResult");for(let l=0;l<t.length;l++){let p=je(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");X.match=X;X.matcher=(e,t)=>je(e,t);X.isMatch=(e,t,n)=>je(t,n)(e);X.any=X.isMatch;X.not=(e,t,n={})=>{t=[].concat(t).map(String);let r=new Set,o=[],i=s(c=>{n.onResult&&n.onResult(c),o.push(c.output)},"onResult"),a=new Set(X(e,t,{...n,onResult:i}));for(let c of o)a.has(c)||r.add(c);return[...r]};X.contains=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${fp.inspect(e)}"`);if(Array.isArray(t))return t.some(r=>X.contains(e,r,n));if(typeof t=="string"){if(lp(e)||lp(t))return!1;if(e.includes(t)||e.startsWith("./")&&e.slice(2).includes(t))return!0}return X.isMatch(e,t,{...n,contains:!0})};X.matchKeys=(e,t,n)=>{if(!Pi.isObject(e))throw new TypeError("Expected the first argument to be an object");let r=X(Object.keys(e),t,n),o={};for(let i of r)o[i]=e[i];return o};X.some=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=je(String(o),n);if(r.some(a=>i(a)))return!0}return!1};X.every=(e,t,n)=>{let r=[].concat(e);for(let o of[].concat(t)){let i=je(String(o),n);if(!r.every(a=>i(a)))return!1}return!0};X.all=(e,t,n)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${fp.inspect(e)}"`);return[].concat(t).every(r=>je(r,n)(e))};X.capture=(e,t,n)=>{let r=Pi.isWindows(n),i=je.makeRe(String(e),{...n,capture:!0}).exec(r?Pi.toPosixSlashes(t):t);if(i)return i.slice(1).map(a=>a===void 0?"":a)};X.makeRe=(...e)=>je.makeRe(...e);X.scan=(...e)=>je.scan(...e);X.parse=(e,t)=>{let n=[];for(let r of[].concat(e||[]))for(let o of dp(String(r),t))n.push(je.parse(o,t));return n};X.braces=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return t&&t.nobrace===!0||!pp(e)?[e]:dp(e,t)};X.braceExpand=(e,t)=>{if(typeof e!="string")throw new TypeError("Expected a string");return X.braces(e,{...t,expand:!0})};X.hasBraces=pp;mp.exports=X});import{realpathSync as zI}from"node:fs";import{resolve as JI}from"node:path";import{fileURLToPath as YI,pathToFileURL as XI}from"node:url";import{createHash as a_}from"node:crypto";import{homedir as c_}from"node:os";import{dirname as TT,join as u_,parse as PT,resolve as wT}from"node:path";var _a="EV_AI_LAUNCHER_VERSION";var ha="EV_AI_HOOK_SOURCE",Sa="EV_AI_HOOK_FALLBACK_REASON",Ea="EV_AI_LAUNCHER_SCOPE",Uo="EV_AI_LAUNCHER_READY_FD";var ya="--defer-user-spec",rr="--cap",_n="--slot";var Ra=Buffer.from([1]);var nT=1024*1024,rT=4*1024*1024,oT=64*1024,sT=64*1024,iT=64*1024;var Do=4096,aT=4*1024*1024;import{join as Oa}from"node:path";import{open as Ca,mkdir as Fg,readFile as $g,readdir as jg,rename as Bg,stat as Kg,rmdir as Gg,unlink as Wg,utimes as Vg}from"node:fs/promises";var or=new WeakMap;function ba(e){if(e&&typeof e=="object"&&"code"in e)return e}s(ba,"asNodeError");function Bt(e){return ba(e)?.code==="ENOENT"}s(Bt,"isNotFound");function hn(e){return ba(e)?.code==="EEXIST"}s(hn,"isAlreadyExists");async function ka(e,t){try{return await e.readdir(t)}catch(n){if(Bt(n))return[];throw n}}s(ka,"readdirOrEmpty");function xa(){return{async open(e,t){let n=await Ca(e,t),r={path:e};return or.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=or.get(e);or.delete(e),t&&await t.close()},rename:Bg,async readdir(e){return jg(e)},readFile:$g,async stat(e){let t=await Kg(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:s(()=>t.isDirectory(),"isDirectory")}},async mkdir(e,t){await Fg(e,t)},unlink:Wg,rmdir:Gg,utimes:Vg,async fsyncDir(e){if(process.platform==="win32")return;let t=await Ca(e,"r");try{await t.sync()}finally{await t.close()}}}}s(xa,"productionFs");function Aa(e){let t=or.get(e);if(!t)throw new Error("closed");return t}s(Aa,"requireHandle");var Ia=4,Ta=10;function sr(e=process.platform){return e==="win32"?Ia:Ta}s(sr,"defaultMaxConcurrentHooks");var ir=6e4,Sn=2e3,Pa="slots",Fo=64;function wa(e){return Oa(e,".ev-ai","agent-hook",Pa)}s(wa,"slotDirUnder");function ar(e,t){return Oa(e,`slot-${t}`)}s(ar,"slotPath");function cr(e,t){return`${e}
|
|
15
15
|
${t}
|
|
16
|
-
`}function
|
|
17
|
-
`)}function Xt(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}function qt(e){return jm("sha256").update(e).digest("hex").slice(0,32)}function ce(e,t){Km(ia(e),{recursive:!0});let n=la(ia(e),`.${zm(e)}.${process.pid}.${Bm(4).toString("hex")}.tmp`);try{Wm(n,t,"utf8");try{oa(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){sa(e),oa(n,e);return}throw r}}catch(r){try{sa(n)}catch{}throw r}}function Wn(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}var da;function Eo(){(da?.stdout??process.stdout).write('{"continue":true}')}var Zt=new Set(["on","1","true"]),pa=new Set(["off","0","false"]);function M(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function Qt(){return new Promise(e=>{let t="";if(process.stdin.isTTY){e("");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",n=>{t+=n}),process.stdin.on("end",()=>{e(t)}),process.stdin.on("error",()=>{e(t)}),process.stdin.resume()})}async function zn(e){let t=da?.stdin??process.stdin;return new Promise(n=>{let r="",o=!1,s=a=>{o||(o=!0,clearTimeout(i),n(a||"{}"))},i=setTimeout(()=>{s(r)},e);if(t.isTTY){s("{}");return}t.setEncoding("utf8"),t.on("data",a=>{r+=a}),t.on("end",()=>{s(r)}),t.on("error",()=>{s(r)}),t.resume()})}async function Ae(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:s}=await import("node:util"),i=s(o);try{let{stdout:a}=await i(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:a.trim()}}catch(a){let c=a,l=typeof c.code=="number"?c.code:typeof c.status=="number"?c.status:void 0;return{ok:!1,code:l,spawnFailed:l===void 0}}}async function ne(e,t,n=3e3,r={}){let o=await Ae(e,t,n,r);return o.ok?o.stdout:""}function So(e,t){let n=De(e),r=De(t),o=fa(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${Ym}`)||Jm(o)?!1:De(r,o)===n}function ma(e,t,n=ua()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return De(e);let o=De(r),s=De(e);if(So(s,o))return s;let i=t.CURSOR_PLUGIN_ROOT?.trim();return So(s,De(n,".cursor"))||i!==void 0&&i.length>0&&So(s,De(i))?o:s}async function yo(e=process.cwd(),t=process.env,n=ua()){let r=ma(e,t,n),o=r!==De(e)&&Vn(r)?r:e,s=await Ae("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(s.ok&&s.stdout)return{root:s.stdout,inGitRepo:!0};if(M("EV_AI_HOOK_DEBUG")){let a=s.ok?"empty stdout":s.spawnFailed?"spawn failed":`exit ${String(s.code??"unknown")}`;E(`DEBUG: git rev-parse --show-toplevel failed (${a}) cwd=${e}`)}let i=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||M("CURSOR_PROJECT_DIR")||M("CLAUDE_PROJECT_DIR");if(i&&Vn(i)){let a=await Ae("git",["rev-parse","--show-toplevel"],2e3,{cwd:i});return a.ok&&a.stdout?{root:a.stdout,inGitRepo:!0}:{root:i,inGitRepo:!1}}return{root:e,inGitRepo:!1}}async function Fe(e=process.cwd()){return(await yo(e)).root}function Se(e,t){try{return JSON.parse(e)}catch{return t}}var aa=new Map;function Jn(e){return e.charCodeAt(0)===65279?e.slice(1):e}function Xm(e){let t;try{t=Vm(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Jn(t))}}catch{return{ok:!1,reason:"parse"}}}function ga(e){let t=aa.get(e);if(t!==void 0)return t;let n=Xm(e);return aa.set(e,n),n}function _a(e){return ga(e)}function q(e,t){let n=ga(e);return n.ok?n.value:t}function pt(e){return typeof e=="string"?e:""}function $e(e,t){let n=e[t];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(!t.includes("."))return;let r=t.split("."),o=e;for(let s of r){if(o===null||typeof o!="object"||Array.isArray(o))return;o=o[s]}if(typeof o=="string"||typeof o=="number"||typeof o=="boolean")return o}function L(e,t){let n=$e(e,t);return typeof n=="string"?n:""}var et=500;function ha(e,t=2){if(!Vn(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,i)=>{if(i>t||r)return;let a;try{a=Gm(s,{withFileTypes:!0})}catch{return}for(let c of a){if(r)return;let l=la(s,c.name);if(c.isDirectory()){o(l,i+1);continue}if(c.isFile()){try{n.push({name:fa(e,l),size:ca(l).size})}catch{continue}if(n.length>=et){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function Ro(e){return Vn(e)?{present:!0,size:ca(e).size}:{present:!1,size:0}}var Ca="https://hooks.ev-ai.ai",Yn=".claude/ev-ai-runtime-report.json",Aa="config.json",eg="max_concurrent_hooks",uO=1024*1024,tg=new Set(["localhost","127.0.0.1","[::1]","::1"]),ng=["claude","cursor","codex"],Xn=[Yn,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Co=/^[A-Za-z0-9._~-]+$/;function qn(e){return e!==void 0&&ng.includes(e)}function ba(e){if(!e||typeof e!="object")return;let t=e[eg];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}function Sa(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}function It(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function Zn(e){let t,n,r,o,s,i,a;for(let c=0;c<e.length;c++){let l=e[c];if(l!==void 0){if(l==="--runner"){let u=It(e,c);t=u.value,c=u.next;continue}if(l.startsWith("--runner=")){t=l.slice(9);continue}if(l==="--url"){let u=It(e,c);u.value&&(r=u.value),c=u.next;continue}if(l.startsWith("--url=")){r=l.slice(6);continue}if(l==="--token"){let u=It(e,c);u.value&&(o=u.value),c=u.next;continue}if(l.startsWith("--token=")){o=l.slice(8);continue}if(l==="--base-url"){let u=It(e,c);u.value&&(s=u.value),c=u.next;continue}if(l.startsWith("--base-url=")){s=l.slice(11);continue}if(l===Fn){let u=It(e,c);i=Sa(u.value)??i,c=u.next;continue}if(l.startsWith(`${Fn}=`)){i=Sa(l.slice(Fn.length+1))??i;continue}if(l===zt){let u=It(e,c);a=ho(u.value)??a,c=u.next;continue}if(l.startsWith(`${zt}=`)){a=ho(l.slice(zt.length+1))??a;continue}l!==Gi&&!l.startsWith("-")&&n===void 0&&(n=l)}}return{runner:qn(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s,...i!==void 0?{cap:i}:{},...a!==void 0?{slot:a}:{}}}function Qn(e,t=Ca){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function mt(e=Zm()){return Qm(e,".ev-ai",Aa)}function ka(e,t){return{...e,...t}}function Ea(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===127||n===39)return!0}return!1}function er(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?tg.has(t.hostname):!1}catch{return!1}}function Ao(e){try{let n=new URL(e).pathname.split("/").filter(r=>r.length>0);if(n.length>=2&&n[n.length-1]==="hook"){let r=n[n.length-2];return r&&r.length>0?r:void 0}return}catch{return}}function je(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!er(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Ao(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Co.test(n))return`org token must match ${Co.source} (got: ${n})`;if(Ea(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(Ea(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function tt(e){return new URL(e).toString()}function xa(e){if(e.collector_url)return e.collector_url;let t=e.repo_ingest_token,n=typeof t=="string"?t.trim():void 0;return n?Qn(n):""}function Tt(e){try{let t=new URL(e),n=t.pathname.split("/").filter(r=>r.length>0);return n.length>=2&&n[n.length-1]==="hook"&&(n[n.length-2]="***",t.pathname=`/${n.join("/")}`),t.toString()}catch{return"<invalid-url>"}}function Oa(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=Qn(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=je(n);return r?{problem:r}:{url:tt(n)}}var rg="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",og="COLLECTOR_URL",ya="collector_url_override",sg=[rg,og];function ig(e){let t;for(let n of sg){let r=e[n]?.trim();if(!r)continue;let o=je(r);if(o){t??={problem:o,envName:n};continue}return{url:tt(r),envName:n}}return t??{}}function Ra(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=je(t);return n?{problem:n}:{url:tt(t)}}function Ia(e){let t=[],n=Ra(e.homeConfig?.[ya]);if(n.problem&&t.push({label:ya,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=Oa(Zn(e.argv));if(r.problem&&t.push({label:"--url/--token",problem:r.problem}),r.url)return{url:r.url,source:"argv",warnings:t};let o=ig(e.env);if(o.problem&&o.envName&&t.push({label:o.envName,problem:o.problem}),o.url)return{url:o.url,source:"plugin_option",warnings:t};let s=Ra(e.homeConfig?.collector_url);if(s.problem&&t.push({label:"collector_url",problem:s.problem}),s.url)return{url:s.url,source:"home_config",warnings:t};let i=e.homeConfig?.repo_ingest_token,a=typeof i=="string"&&i.trim()?{...e.manifest,repo_ingest_token:i}:e.manifest,c=a?xa(a):"";if(c){let l=je(c);if(l)t.push({label:"manifest collector_url",problem:l});else return{url:tt(c),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}function en(e){if(je(e))return;let t;try{t=new URL(e)}catch{return}let n=Ao(e);if(!n)return;let o=t.pathname.split("/").filter(a=>a.length>0).slice(0,-2),s=o.length>0?`/${o.join("/")}`:"",i=`${t.origin}${s}/${n}`;return qm("sha256").update(i).digest("hex").slice(0,32)}var nt=2,Ta="node_modules/@ev-ai/agent-hook/dist/hook.mjs",Ee="ev-ai-agent-hook";function ag(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}function tr(e){let t=ag(e);return t===Ee||t===`${Ee}.exe`}var Pa="https://cdn.ev-ai.ai/agent-hook";var bo=`current/${Ee}`,ko=`.ev-ai/agent-hook/${Ee}`,wa=5e3,Na=5e3,xo=3e3;var nr=3e3,va=1500,Ma=4*1024,Oo=256*1024,cg=4*1024,La=32*1024,Be="1.3.9",rr=`@ev-ai/agent-hook@${Be}`,Ha="ev-ai runtime report";var Ua={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{chmodSync as Tc,cpSync as Pc,existsSync as rt,mkdirSync as Bo,readFileSync as L_,rmSync as pr,symlinkSync as H_,writeFileSync as U_}from"node:fs";import{homedir as Ke}from"node:os";import{dirname as Ko,isAbsolute as D_,join as V,relative as wc,resolve as Oc,sep as F_}from"node:path";import{fileURLToPath as $_}from"node:url";import{existsSync as ug,readdirSync as Da}from"node:fs";import{homedir as or}from"node:os";import{join as ue}from"node:path";function Fa(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return ue(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}function Io(e=process.platform){let t=Fa(e),n=[ue(t,"managed-settings.json")],r=ue(t,"managed-settings.d");try{if(!ug(r))return n;let o=Da(r).filter(s=>s.endsWith(".json")&&!s.startsWith(".")).sort().map(s=>ue(r,s));n.push(...o)}catch{}return n}function tn(e=process.platform,t=or()){return{serverManaged:ue(t,".claude","remote-settings.json"),fileBased:Io(e)}}function lg(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return ue(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}function fg(e=process.platform,t=or()){let n=[ue(lg(e),"hooks.json")],r=ue(t,".cursor","managed");try{for(let o of Da(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(ue(r,o.name,"hooks.json"))}catch{}return n}function dg(e=process.platform,t=or()){let n=e==="win32"?ue(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[ue(n,"requirements.toml")];return e!=="win32"&&r.push(ue(n,"managed_config.toml")),r.push(ue(t,".codex","managed_config.toml"),ue(n,"config.toml")),r}function sr(e,t=process.platform,n=or()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=tn(t,n);return[r,...o]}case"cursor":return fg(t,n);default:return dg(t,n)}}import{createHash as Za,randomBytes as Lg}from"node:crypto";import{existsSync as Qa,mkdirSync as wo,readFileSync as ec,unlinkSync as tc,writeFileSync as nc}from"node:fs";import{homedir as No}from"node:os";import{dirname as cr,join as vo,resolve as Hg}from"node:path";var pg=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),mg=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function me(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||mg.has(n)||r.includes("[bot]")||pg.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),s=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(s.endsWith("bot")||s.includes("[bot]"))return!0}return!1}import{existsSync as hg,readFileSync as Sg}from"node:fs";import{hostname as Ba,release as Eg,userInfo as yg,version as Rg}from"node:os";import*as ae from"node:os";import{performance as To}from"node:perf_hooks";var gg=1024*1024,_g=128;function ir(e){return Math.round(e/gg)}function nn(e,t){let n=10**t;return Math.round(e*n)/n}function $a(e=process.platform){try{let t=To.now(),n={},r=0,o=0,s=e!=="win32";for(let{times:c}of ae.cpus())r+=c.user+c.nice+c.sys+(s?c.irq:0),o+=c.idle;if(r+o>0&&(n.cpu_busy_ms=Math.round(r),n.cpu_idle_ms=Math.round(o)),n.uptime_s=Math.round(ae.uptime()),n.mem_free_mb=ir(ae.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=ir(process.availableMemory())),e!=="win32"){let[c,l,u]=ae.loadavg();n.load_1m=nn(c??0,2),n.load_5m=nn(l??0,2),n.load_15m=nn(u??0,2)}let i=process.resourceUsage();n.proc_cpu_user_ms=Math.round(i.userCPUTime/1e3),n.proc_cpu_sys_ms=Math.round(i.systemCPUTime/1e3),n.proc_max_rss_mb=Math.round(i.maxRSS/1024),n.proc_page_faults=i.majorPageFault,e!=="win32"&&(n.proc_invol_ctx=i.involuntaryContextSwitches);let a=To.nodeTiming?.bootstrapComplete;return typeof a=="number"&&a>0&&(n.node_boot_ms=nn(a,1)),n.sample_us=Math.round((To.now()-t)*1e3),n}catch{return}}function ja(){try{let e=ae.cpus(),t={},n=typeof ae.availableParallelism=="function"?ae.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,_g);r&&(t.cpu_model=r);let o=ae.totalmem();t.mem_total_mb=ir(o);let s=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof s=="number"&&s>0&&s<o&&(t.mem_limit_mb=ir(s)),t.uptime_h=nn(ae.uptime()/3600,1),t}catch{return{}}}function Pt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function Ka(e=process.env){return Pt(X("CURSOR_SANDBOX",e))}var Cg=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function Ag(e){return Cg.some(t=>!!X(t,e))}function bg(e){if(X("KUBERNETES_SERVICE_HOST",e)||Pt(X("REMOTE_CONTAINERS",e))||Pt(X("DEVCONTAINER",e)))return!0;try{if(hg("/.dockerenv")||Sg("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function Ga(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!X(t,e))}function kg(e,t=process.platform){return Ga(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!X(n,e)):!1}function xg(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function Og(e){return e==="linux"}function X(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return M(e)}function Ig(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Tg(X("CURSOR_VERSION",n))}function Tg(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function Po(e){if(xg(e.sessionId))return!0;let t=e.hostname??Ba(),n=e.osUser??Wa(e.env);return Ig(t,n,e.env)}function Pg(e){return Pt(X("CURSOR_AGENT",e.env))?!0:Po(e)}function wg(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(X("TERM",e)??X("TERM_PROGRAM",e))||(X("SSH_TTY",e)??X("SSH_CONNECTION",e))||(X("__CFBundleIdentifier",e)??X("XPC_SERVICE_NAME",e))||Ga(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!X(t,e))||X("SESSIONNAME",e))}function rn(e={}){let t=e.env;if(X("GITHUB_ACTIONS",t))return"github_actions";if(Pt(X("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!kg(t,n)&&Pg(e)&&(Pt(X("CURSOR_AGENT",t))||Og(n)))return"cursor_cloud";if(X("CODESPACES",t)||X("CODESPACE_NAME",t))return"codespaces";if(X("GITLAB_CI",t))return"gitlab_ci";if(Ag(t))return"managed";let r=X("CI",t);return r&&r!=="false"&&r!=="0"?"managed":bg(t)?"container":wg(t)?"interactive":"unknown"}async function Va(){return await ne("systemd-detect-virt",[],1e3)}function Wa(e=process.env,t=yg){for(let n of["USER","LOGNAME","USERNAME"]){let r=e[n];if(typeof r=="string"){let o=r.trim();if(o.length>0)return o}}try{return t().username??""}catch{return""}}var Ng=32;function vg(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,Ng);return t.length>0?t:null}function Mg(){try{return[Rg(),Eg()].filter(Boolean).join(" ").trim()}catch{return""}}async function za(e=!1){let t=vg(process.platform),n="";if(process.platform==="darwin")n=await ne("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:i}=await import("node:fs"),a=i("/etc/os-release","utf8"),c=a.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],l=a.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];n=c??l??""}catch{n=await ne("lsb_release",["-sd"],1e3).then(i=>i.replace(/^"|"$/g,""))}n||(n=await ne("uname",["-r"],1e3))}else process.platform==="win32"?n=Mg():n=await ne("ver",[],1e3);let r=Wa(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",s="";try{s=await ne("tty",[],500),s.includes("not a tty")&&(s="")}catch{s=""}return{os:t,os_version:n||null,user:r||null,shell:o||null,tty:s||null,...e?ja():{}}}function ar(){return Ba()}var Ug="installation.json",Dg="cloud-bootstrap.lock",Fg=6e4;function rc(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function ge(e=No()){return vo(e,".ev-ai","agent-hook")}function $g(e=No()){return vo(ge(e),Ug)}function oc(e){return vo(cr(e),Dg)}function sc(){return Lg(8).toString("hex")}function wt(e){return Za("sha256").update(e).digest("hex").slice(0,16)}function $(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function ic(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function jg(e=process.env){let t=$(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!ic(t)){E(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}function ac(e,t){return e&&ic(e)?e:(e&&E(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),jg(t))}function Bg(e){return/^[0-9a-f]{16}$/.test(e)}function Kg(e=process.env){if($(e.GITHUB_ACTIONS)){let t=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),n=$(e.GITHUB_ACTOR)??$(e.GITHUB_TRIGGERING_ACTOR)??$(e.GITHUB_USER);if(t&&n)return wt(`github_actions|${t}|${n}`)}if($(e.CODESPACES)||$(e.CODESPACE_NAME)){let t=$(e.CODESPACE_NAME);if(t)return wt(`codespaces|${t}`);let n=$(e.GITHUB_REPOSITORY_ID)??$(e.GITHUB_REPOSITORY),r=$(e.GITHUB_USER)??$(e.GITHUB_ACTOR);if(n&&r)return wt(`codespaces|${n}|${r}`)}if($(e.GITLAB_CI)){let t=$(e.CI_PROJECT_ID)??$(e.CI_PROJECT_PATH),n=$(e.GITLAB_USER_LOGIN)??$(e.GITLAB_USER_EMAIL)??$(e.GITLAB_USER_NAME);if(t&&n)return wt(`gitlab|${t}|${n}`)}return null}var Gg="cursoragent@cursor.com";function Vg(e){let t=$(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===Gg?null:t}function Wg(e,t){return $(e.CURSOR_PROJECT_DIR)??$(e.CLAUDE_PROJECT_DIR)??t}function zg(e){return Xt(e).replace(/\.git$/i,"").toLowerCase()}async function Jg(e){let t=await ne("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?zg(t):e}async function Yg(e){let t=$(await ne("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!me(null,t))return t;let n=$(await ne("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!me(null,n)?n:null}function Xg(e,t){let n=Wg(e,t);return n?wt(`cursor_cloud|${n}|${Vg(e)??""}`):null}async function qg(e,t){let n=$(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await Jg(n),o=await Yg(n);return wt(`claude_remote|${r}|${o??""}`)}function Ja(e,t){let n=ac(e,t);if(n)return n;let r=Kg(t);return r||sc()}async function Zg(e){let n=await ne("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||Hg(e);return Za("sha256").update(n).digest("hex").slice(0,16)}function Qg(e){if(!e||typeof e!="object"||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&r.length>0&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function e_(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=Qg(t.platform_agent_ids);return{installation_id:t.installation_id,...t.pinned===!0?{pinned:!0}:{},...n?{platform_agent_ids:n}:{},...typeof t.operator_identity_hash=="string"?{operator_identity_hash:t.operator_identity_hash}:{},...typeof t.operator_identity_sent_at=="string"?{operator_identity_sent_at:t.operator_identity_sent_at}:{}}}catch{return}}function gt(e){if(Qa(e))try{return e_(ec(e,"utf8"))}catch{}}function Mo(e){return gt(e)}function cc(e,t,n){let r=gt(e);if(!r||r.operator_identity_hash===t&&r.operator_identity_sent_at===n)return;let o={...r,operator_identity_hash:t,operator_identity_sent_at:n};try{ce(e,`${JSON.stringify(o,null,2)}
|
|
18
|
-
`)}catch
|
|
19
|
-
|
|
20
|
-
`)}catch(s){let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
`)
|
|
24
|
-
`,
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
`}s(cr,"slotRecord");function $o(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($o,"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 zg=/^(\d+)\n(\d+)\n$/;function Jg(e){let t=zg.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(Jg,"parseSlotRecord");function va(e,t,n){let r=Jg(e);if(!r)return Math.abs(n-t)<Sn;let o=n-r.acquiredAtMs;return o<-Sn||o>=ir?!1:Na(r.pid)}s(va,"isSlotRecordHeld");import{createHash as Yg,randomBytes as Xg}from"node:crypto";import{existsSync as ur,mkdirSync as qg,readdirSync as Zg,readFileSync as Qg,renameSync as Ha,statSync as Ua,unlinkSync as Da,writeFileSync as e_}from"node:fs";import{homedir as Fa}from"node:os";import{basename as t_,dirname as La,isAbsolute as n_,join as $a,relative as ja,resolve as Ge,sep as r_}from"node:path";function R(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
|
|
17
|
+
`)}s(R,"logStderr");function En(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1")}s(En,"stripRemoteCredentials");function yn(e){return Yg("sha256").update(e).digest("hex").slice(0,32)}s(yn,"sha32");var o_=3;function Ba(e){return e instanceof Error&&"code"in e?e.code:void 0}s(Ba,"errnoCode");function Ka(e){let t=Ba(e);return t==="EEXIST"||t==="EPERM"||t==="EACCES"}s(Ka,"isRenameReplaceBlocked");function s_(e,t,n){let r=n;for(let o=0;o<o_;o+=1){try{Da(t)}catch(i){if(Ba(i)!=="ENOENT")throw i}try{Ha(e,t);return}catch(i){if(!Ka(i))throw i;r=i}}throw r}s(s_,"replaceByUnlinkThenRename");function le(e,t){qg(La(e),{recursive:!0});let n=$a(La(e),`.${t_(e)}.${process.pid}.${Xg(4).toString("hex")}.tmp`);try{e_(n,t,"utf8");try{Ha(n,e)}catch(r){if(!Ka(r))throw r;s_(n,e,r)}}catch(r){try{Da(n)}catch{}throw r}}s(le,"writeFileAtomic");function lr(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}s(lr,"timestampUtc");var Ga;function Bo(){(Ga?.stdout??process.stdout).write('{"continue":true}')}s(Bo,"emitStdoutOk");var Rt=new Set(["on","1","true"]),fr=new Set(["off","0","false"]);function D(e){let t=process.env[e];return t===void 0||t===""?void 0:t}s(D,"readEnv");async function Rn(){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(Rn,"readStdinUntilEnd");async function dr(e){let t=Ga?.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(dr,"readStdinWithTimeout");async function Ie(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:i}=await import("node:util"),a=i(o);try{let{stdout:c}=await a(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:c.trim()}}catch(c){let u=c,f=typeof u.code=="number"?u.code:typeof u.status=="number"?u.status:void 0;return{ok:!1,code:f,spawnFailed:f===void 0}}}s(Ie,"execFileResult");async function se(e,t,n=3e3,r={}){let o=await Ie(e,t,n,r);return o.ok?o.stdout:""}s(se,"execFileText");function jo(e,t){let n=Ge(e),r=Ge(t),o=ja(r,n);return!o||o==="."?!0:o===".."||o.startsWith(`..${r_}`)||n_(o)?!1:Ge(r,o)===n}s(jo,"isPathInside");function Wa(e,t,n=Fa()){let r=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim();if(!r)return Ge(e);let o=Ge(r),i=Ge(e);if(jo(i,o))return i;let a=t.CURSOR_PLUGIN_ROOT?.trim();return jo(i,Ge(n,".cursor"))||a!==void 0&&a.length>0&&jo(i,Ge(a))?o:i}s(Wa,"cursorHookLaunchCwd");async function Ko(e=process.cwd(),t=process.env,n=Fa()){let r=Wa(e,t,n),o=r!==Ge(e)&&ur(r)?r:e,i=await Ie("git",["rev-parse","--show-toplevel"],2e3,{cwd:o});if(i.ok&&i.stdout)return{root:i.stdout,inGitRepo:!0};if(D("EV_AI_HOOK_DEBUG")){let c=i.ok?"empty stdout":i.spawnFailed?"spawn failed":`exit ${String(i.code??"unknown")}`;R(`DEBUG: git rev-parse --show-toplevel failed (${c}) cwd=${e}`)}let a=(t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR)?.trim()||D("CURSOR_PROJECT_DIR")||D("CLAUDE_PROJECT_DIR");if(a&&ur(a)){let c=await Ie("git",["rev-parse","--show-toplevel"],2e3,{cwd:a});return c.ok&&c.stdout?{root:c.stdout,inGitRepo:!0}:{root:a,inGitRepo:!1}}return{root:e,inGitRepo:!1}}s(Ko,"resolveGitWorkspace");async function We(e=process.cwd()){return(await Ko(e)).root}s(We,"findGitRoot");function Te(e,t){try{return JSON.parse(e)}catch{return t}}s(Te,"parseJsonSafe");var Ma=new Map;function Kt(e){return e.charCodeAt(0)===65279?e.slice(1):e}s(Kt,"stripUtf8Bom");function i_(e){let t;try{t=Qg(e,"utf8")}catch{return{ok:!1,reason:"read"}}try{return{ok:!0,value:JSON.parse(Kt(t))}}catch{return{ok:!1,reason:"parse"}}}s(i_,"parseJsonFile");function Va(e){let t=Ma.get(e);if(t!==void 0)return t;let n=i_(e);return Ma.set(e,n),n}s(Va,"loadJsonFileStatus");function za(e){return Va(e)}s(za,"readJsonFileStatus");function Z(e,t){let n=Va(e);return n.ok?n.value:t}s(Z,"readJsonFileMemoized");function Ct(e){return typeof e=="string"?e:""}s(Ct,"pickString");function Ve(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(Ve,"pickNestedScalar");function $(e,t){let n=Ve(e,t);return typeof n=="string"?n:""}s($,"pickNestedString");var st=500;function Ja(e,t=2){if(!ur(e))return{entries:[],truncated:!1};let n=[],r=!1,o=s((i,a)=>{if(a>t||r)return;let c;try{c=Zg(i,{withFileTypes:!0})}catch{return}for(let u of c){if(r)return;let f=$a(i,u.name);if(u.isDirectory()){o(f,a+1);continue}if(u.isFile()){try{n.push({name:ja(e,f),size:Ua(f).size})}catch{continue}if(n.length>=st){r=!0;return}}}},"walk");return o(e,1),{entries:n,truncated:r}}s(Ja,"listDirFiles");function Go(e){return ur(e)?{present:!0,size:Ua(e).size}:{present:!1,size:0}}s(Go,"fileSizeOrAbsent");var Qa="https://hooks.ev-ai.ai",pr=".claude/ev-ai-runtime-report.json",ec="config.json",l_="max_concurrent_hooks",MT=1024*1024,f_=new Set(["localhost","127.0.0.1","[::1]","::1"]),d_=["claude","cursor","codex"],mr=[pr,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],Wo=/^[A-Za-z0-9._~-]+$/;function gr(e){return e!==void 0&&d_.includes(e)}s(gr,"isKnownRunner");function tc(e){if(!e||typeof e!="object")return;let t=e[l_];return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?t:void 0}s(tc,"maxConcurrentHooksFromConfig");function Ya(e){if(e===void 0||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)?t:void 0}s(Ya,"parseCapArg");function Gt(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}s(Gt,"takeFlagValue");function _r(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=Gt(e,u);t=l.value,u=l.next;continue}if(f.startsWith("--runner=")){t=f.slice(9);continue}if(f==="--url"){let l=Gt(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=Gt(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=Gt(e,u);l.value&&(i=l.value),u=l.next;continue}if(f.startsWith("--base-url=")){i=f.slice(11);continue}if(f===rr){let l=Gt(e,u);a=Ya(l.value)??a,u=l.next;continue}if(f.startsWith(`${rr}=`)){a=Ya(f.slice(rr.length+1))??a;continue}if(f===_n){let l=Gt(e,u);c=$o(l.value)??c,u=l.next;continue}if(f.startsWith(`${_n}=`)){c=$o(f.slice(_n.length+1))??c;continue}f!==ya&&!f.startsWith("-")&&n===void 0&&(n=f)}}return{runner:gr(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:i,...a!==void 0?{cap:a}:{},...c!==void 0?{slot:c}:{}}}s(_r,"parseHookArgv");function hr(e,t=Qa){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}s(hr,"buildCollectorUrl");function At(e=c_()){return u_(e,".ev-ai",ec)}s(At,"homeManifestPath");function nc(e,t){return{...e,...t}}s(nc,"mergeManifestOverlay");function Xa(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(Xa,"hasUnsafeCollectorUrlChars");function Sr(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?f_.has(t.hostname):!1}catch{return!1}}s(Sr,"isAllowedCollectorUrl");function Vo(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(Vo,"extractOrgTokenFromCollectorUrl");function ze(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!Sr(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Vo(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Wo.test(n))return`org token must match ${Wo.source}`;if(Xa(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(Xa(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}s(ze,"collectorUrlProblem");function it(e){return new URL(e).toString()}s(it,"normalizeCollectorUrl");function rc(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?hr(n):""}s(rc,"resolveCollectorUrl");function Wt(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(Wt,"redactCollectorUrlForLog");function oc(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=hr(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=ze(n);return r?{problem:r}:{url:it(n)}}s(oc,"collectorUrlFromArgv");var p_="CLAUDE_PLUGIN_OPTION_COLLECTOR_URL",m_="COLLECTOR_URL",qa="collector_url_override",g_=[p_,m_];function __(e){let t;for(let n of g_){let r=e[n]?.trim();if(!r)continue;let o=ze(r);if(o){t??={problem:o,envName:n};continue}return{url:it(r),envName:n}}return t??{}}s(__,"collectorUrlFromPluginOption");function Za(e){if(typeof e!="string")return{};let t=e.trim();if(!t)return{};let n=ze(t);return n?{problem:n}:{url:it(t)}}s(Za,"candidateFromUnknown");function sc(e){let t=[],n=Za(e.homeConfig?.[qa]);if(n.problem&&t.push({label:qa,problem:n.problem}),n.url)return{url:n.url,source:"home_override",warnings:t};let r=oc(_r(e.argv));if(r.problem&&t.push({label:"--url/--token",problem:r.problem}),r.url)return{url:r.url,source:"argv",warnings:t};let o=__(e.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=Za(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?rc(c):"";if(u){let f=ze(u);if(f)t.push({label:"manifest collector_url",problem:f});else return{url:it(u),source:e.manifestSource,warnings:t}}return{source:"none",warnings:t}}s(sc,"selectCollectorUrl");function bt(e){if(ze(e))return;let t;try{t=new URL(e)}catch{return}let n=Vo(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 a_("sha256").update(a).digest("hex").slice(0,32)}s(bt,"scopeIdForCollectorUrl");var at=2,ic="node_modules/@ev-ai/agent-hook/dist/hook.mjs",Ae="ev-ai-agent-hook";function h_(e){let t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}s(h_,"hookBinaryBasenameFromPath");function Er(e){let t=h_(e);return t===Ae||t===`${Ae}.exe`}s(Er,"isHookBinaryPath");var ac="https://cdn.ev-ai.ai/agent-hook";var zo=`current/${Ae}`,Jo=`.ev-ai/agent-hook/${Ae}`,cc=5e3,uc=5e3,Yo=3e3;var yr=3e3,lc=1500,fc=4*1024,Xo=256*1024,S_=4*1024,dc=32*1024,me="1.3.11",Rr=`@ev-ai/agent-hook@${me}`,pc="ev-ai runtime report";var mc={claude:"CLAUDE_PLUGIN_ROOT",cursor:"CURSOR_PLUGIN_ROOT",codex:"PLUGIN_ROOT"};import{chmodSync as xu,cpSync as Ou,existsSync as ft,mkdirSync as Rs,readFileSync as bS,rmSync as Mr,symlinkSync as kS,writeFileSync as xS}from"node:fs";import{homedir as Ye}from"node:os";import{dirname as Cs,isAbsolute as OS,join as z,relative as Iu,resolve as bu,sep as IS}from"node:path";import{fileURLToPath as TS}from"node:url";import{existsSync as E_,readdirSync as gc}from"node:fs";import{homedir as Cr}from"node:os";import{join as _e}from"node:path";function _c(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return _e(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}s(_c,"claudeManagedSettingsDir");function qo(e=process.platform){let t=_c(e),n=[_e(t,"managed-settings.json")],r=_e(t,"managed-settings.d");try{if(!E_(r))return n;let o=gc(r).filter(i=>i.endsWith(".json")&&!i.startsWith(".")).sort().map(i=>_e(r,i));n.push(...o)}catch{}return n}s(qo,"listClaudeManagedSettingsFiles");function Cn(e=process.platform,t=Cr()){return{serverManaged:_e(t,".claude","remote-settings.json"),fileBased:qo(e)}}s(Cn,"claudeManagedSettingsSources");function y_(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return _e(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}s(y_,"cursorEnterpriseSettingsDir");function R_(e=process.platform,t=Cr()){let n=[_e(y_(e),"hooks.json")],r=_e(t,".cursor","managed");try{for(let o of gc(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(_e(r,o.name,"hooks.json"))}catch{}return n}s(R_,"listCursorManagedSettingsFiles");function C_(e=process.platform,t=Cr()){let n=e==="win32"?_e(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[_e(n,"requirements.toml")];return e!=="win32"&&r.push(_e(n,"managed_config.toml")),r.push(_e(t,".codex","managed_config.toml"),_e(n,"config.toml")),r}s(C_,"listCodexManagedSettingsFiles");function Ar(e,t=process.platform,n=Cr()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=Cn(t,n);return[r,...o]}case"cursor":return R_(t,n);default:return C_(t,n)}}s(Ar,"managedSettingsFiles");import{createHash as Zc,randomBytes as Nh}from"node:crypto";import{existsSync as Qc,mkdirSync as ds,readFileSync as eu,unlinkSync as tu,writeFileSync as nu}from"node:fs";import{homedir as wr}from"node:os";import{dirname as Nr,join as ps,resolve as vh}from"node:path";var A_=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com","claude@anthropic.com","agent@cursor.local"]),b_=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function fe(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||b_.has(n)||r.includes("[bot]")||A_.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),i=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(i.endsWith("bot")||i.includes("[bot]"))return!0}return!1}s(fe,"isBotOperatorIdentity");import{homedir as Zo}from"node:os";import{join as x_}from"node:path";function hc(e=Zo()){return x_(e,".claude.json")}s(hc,"claudeUserConfigPath");function kt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(kt,"trimString");function Sc(e=Zo()){let n=Z(hc(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=kt(n.emailAddress),o=kt(n.fullName)??kt(n.displayName),i=kt(n.accountUuid),a=r??i;return!a||fe(o,r)?null:{git_user_name:null,git_user_email:null,platform_login:a,identity_source:"claude_oauth"}}s(Sc,"readClaudeOperatorIdentity");function Ec(e=Zo()){let n=Z(hc(e),{}).oauthAccount;if(!n||typeof n!="object")return null;let r=kt(n.emailAddress),o=kt(n.fullName)??kt(n.displayName);return fe(o,r)?null:r?.toLowerCase()??null}s(Ec,"readClaudeAccountKey");import{existsSync as T_,readFileSync as P_}from"node:fs";import{hostname as Cc,release as w_,userInfo as N_,version as v_}from"node:os";import*as ge from"node:os";import{performance as Qo}from"node:perf_hooks";var O_=1024*1024,I_=128;function br(e){return Math.round(e/O_)}s(br,"mb");function An(e,t){let n=10**t;return Math.round(e*n)/n}s(An,"round");function yc(e=process.platform){try{let t=Qo.now(),n={},r=0,o=0,i=e!=="win32";for(let{times:u}of ge.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(ge.uptime()),n.mem_free_mb=br(ge.freemem()),e==="linux"&&typeof process.availableMemory=="function"&&(n.mem_avail_mb=br(process.availableMemory())),e!=="win32"){let[u,f,l]=ge.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=Qo.nodeTiming?.bootstrapComplete;return typeof c=="number"&&c>0&&(n.node_boot_ms=An(c,1)),n.sample_us=Math.round((Qo.now()-t)*1e3),n}catch{return}}s(yc,"sampleSys");function Rc(){try{let e=ge.cpus(),t={},n=typeof ge.availableParallelism=="function"?ge.availableParallelism():e.length;n>0&&(t.cpu_count=n);let r=e[0]?.model.trim().slice(0,I_);r&&(t.cpu_model=r);let o=ge.totalmem();t.mem_total_mb=br(o);let i=typeof process.constrainedMemory=="function"?process.constrainedMemory():0;return typeof i=="number"&&i>0&&i<o&&(t.mem_limit_mb=br(i)),t.uptime_h=An(ge.uptime()/3600,1),t}catch{return{}}}s(Rc,"hostSpecs");function Vt(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(Vt,"isTruthyFlag");function Ac(e=process.env){return Vt(Q("CURSOR_SANDBOX",e))}s(Ac,"isCursorSandboxProcess");var L_=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function M_(e){return L_.some(t=>!!Q(t,e))}s(M_,"hasManagedCiMarker");function H_(e){if(Q("KUBERNETES_SERVICE_HOST",e)||Vt(Q("REMOTE_CONTAINERS",e))||Vt(Q("DEVCONTAINER",e)))return!0;try{if(T_("/.dockerenv")||P_("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}s(H_,"hasContainerMarker");function bc(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!Q(t,e))}s(bc,"hasIdeExtensionHostMarker");function U_(e,t=process.platform){return bc(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!Q(n,e)):!1}s(U_,"hasLocalIdeHostMarker");function D_(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}s(D_,"isBackgroundComposerSessionId");function F_(e){return e==="linux"}s(F_,"isLinuxPlatform");function Q(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return D(e)}s(Q,"readContextEnv");function $_(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!j_(Q("CURSOR_VERSION",n))}s($_,"isCursorCloudHostFingerprint");function j_(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(j_,"trimEnvLocal");function es(e){if(D_(e.sessionId))return!0;let t=e.hostname??Cc(),n=e.osUser??xc(e.env);return $_(t,n,e.env)}s(es,"hasCursorCloudExclusiveEvidence");function B_(e){return Vt(Q("CURSOR_AGENT",e.env))?!0:es(e)}s(B_,"hasCursorCloudEvidence");function K_(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(Q("TERM",e)??Q("TERM_PROGRAM",e))||(Q("SSH_TTY",e)??Q("SSH_CONNECTION",e))||(Q("__CFBundleIdentifier",e)??Q("XPC_SERVICE_NAME",e))||bc(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!Q(t,e))||Q("SESSIONNAME",e))}s(K_,"hasLocalSessionMarker");function kr(e={}){let t=e.env;if(Q("GITHUB_ACTIONS",t))return"github_actions";if(Vt(Q("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!U_(t,n)&&B_(e)&&(Vt(Q("CURSOR_AGENT",t))||F_(n)))return"cursor_cloud";if(Q("CODESPACES",t)||Q("CODESPACE_NAME",t))return"codespaces";if(Q("GITLAB_CI",t))return"gitlab_ci";if(M_(t))return"managed";let r=Q("CI",t);return r&&r!=="false"&&r!=="0"?"managed":H_(t)?"container":K_(t)?"interactive":"unknown"}s(kr,"detectContext");async function kc(){return await se("systemd-detect-virt",[],1e3)}s(kc,"detectVirt");function xc(e=process.env,t=N_){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(xc,"resolveHostUsername");var G_=32;function W_(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase().replace(/[^a-z0-9._-]/g,"").slice(0,G_);return t.length>0?t:null}s(W_,"sanitizeOsPlatform");function V_(){try{return[v_(),w_()].filter(Boolean).join(" ").trim()}catch{return""}}s(V_,"windowsVersion");async function Oc(e=!1){let t=W_(process.platform),n="";if(process.platform==="darwin")n=await se("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:a}=await import("node:fs"),c=a("/etc/os-release","utf8"),u=c.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],f=c.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];n=u??f??""}catch{n=await se("lsb_release",["-sd"],1e3).then(a=>a.replace(/^"|"$/g,""))}n||(n=await se("uname",["-r"],1e3))}else process.platform==="win32"?n=V_():n=await se("ver",[],1e3);let r=xc(),o=(process.env.SHELL??"").split(/[/\\]/).pop()??"",i="";try{i=await se("tty",[],500),i.includes("not a tty")&&(i="")}catch{i=""}return{os:t,os_version:n||null,user:r||null,shell:o||null,tty:i||null,...e?Rc():{}}}s(Oc,"hostEnv");function ts(){return Cc()}s(ts,"hostName");import{randomBytes as X_}from"node:crypto";import{appendFileSync as q_,mkdirSync as Z_,readdirSync as Q_,readFileSync as ss,renameSync as Mc,statSync as xn,unlinkSync as Fc}from"node:fs";import{homedir as ct,tmpdir as eh}from"node:os";import{dirname as os,join as xt}from"node:path";var Pc="EV_AI_PERF_L",ns="EV_AI_PERF_H",bn="EV_AI_RUN_ID",z_="EV_AI_HOOK_PERF";var J_=/^[a-z][a-z0-9_]{0,23}$/;var xr={origin:0,marks:{},values:{}},Or=!1;function wc(e=process.env){Or=e[z_]!=="0",xr.origin=performance.timeOrigin}s(wc,"startTimings");function kn(){return Or}s(kn,"timingsActive");function Je(e,t=performance.now()){Or&&(xr.marks[e]=t)}s(Je,"mark");function Nc(){return xr}s(Nc,"ownTimings");function vc(e){return Math.round(e*10)/10}s(vc,"round1");function Ic(e){return Object.entries(e).map(([t,n])=>`${t}=${vc(n)}`).join(",")}s(Ic,"entries");function Y_(e){return`${vc(e.origin)}|${Ic(e.marks)}|${Ic(e.values)}`}s(Y_,"serializeTimings");function Tc(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||!J_.test(o)||!(i>=0&&i<=36e5))return!1;t[o]=i}return Object.keys(t).length<=32}s(Tc,"parseEntries");function rs(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(!(!Tc(n,a.marks)||!Tc(r,a.values)))return a}s(rs,"parseTimings");function Lc(){return Or?Y_(xr):void 0}s(Lc,"serializeOwnTimings");var th="hooks-debug.log",nh=/^hooks-debug\.log\.\d+$/,rh=/^hooks-debug\.log(\.1)?\.send-\d+$/,Hc="ev-ai-agent-hooks.log",oh="EV_AI_HOOK_RUN_LOG",zt="unlimited",sh="off",is=1024*1024,ih=8*1024,Uc=is/2-ih,ah=10080*60*1e3,ch=1024*1024,uh="run-log-windows.json",lh=64*1024,as=/^[a-z0-9]{8}$/,Dc="abcdefghijklmnopqrstuvwxyz0123456789",fh=/[^A-Za-z0-9._:/+-]/g,dh=128,ut={info(){},error(){}},be=ut;function Tr(e=ct()){return xt(e,".ev-ai",th)}s(Tr,"fileLogPath");function $c(e){try{let t=JSON.parse(Kt(ss(xt(e,".ev-ai","config.json"),"utf8")));return Ot(t)?t:void 0}catch{return}}s($c,"readHomeConfig");function ph(e){return e?.debug===!0}s(ph,"debugFromHomeConfig");function cs(e,t=!1){return e.includes("--debug")||t}s(cs,"isHookDebugEnabled");function Ot(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(Ot,"isRecord");function mh(e,t){let n=e?.log_until;if(typeof n!="string")return;let r=[];if(n===zt)return{on:!0,source:"local_config",scopes:r,localUntil:n};if(n===sh)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(mh,"localRunLog");function gh(e){if(!Ot(e)||!Ot(e.config))return;let t=e.config.log_until;if(typeof t!="string")return;if(t===zt)return{until:t,untilMs:Number.POSITIVE_INFINITY};let n=Date.parse(t);return Number.isNaN(n)?void 0:{until:t,untilMs:n}}s(gh,"scopeUntilMs");function jc(e=ct(),t=process.env,n=Date.now()){return Bc(e,()=>$c(e),t,n)}s(jc,"readRunLogSwitch");function Bc(e,t,n,r){let o=n[oh]?.trim().toLowerCase();if(o&&Rt.has(o))return{on:!0,source:"env",scopes:[]};if(o&&fr.has(o))return{on:!1,source:"env",scopes:[]};let i=mh(t(),r);if(i)return i;let a=[];try{let c=xt(e,".ev-ai","agent-hook","hook-config.json"),u=xn(c);if(!u.isFile()||u.size>ch)return{on:!1,source:"remote",scopes:a};let f=JSON.parse(ss(c,"utf8"));if(Ot(f))for(let[l,p]of Object.entries(f)){let d=gh(p);d&&d.untilMs>r&&a.push({scopeId:l,...d})}}catch{}return{on:a.length>0,source:"remote",scopes:a}}s(Bc,"runLogSwitch");function Kc(e=ct()){return xt(e,".ev-ai","agent-hook",uh)}s(Kc,"runLogWindowsPath");function us(e=ct()){try{let t=Kc(e),n=xn(t);if(!n.isFile()||n.size>lh)return{};let r=JSON.parse(ss(t,"utf8")),o={};if(Ot(r))for(let[i,a]of Object.entries(r))typeof a=="string"&&(o[i]=a);return o}catch{return{}}}s(us,"readRunLogWindows");function ls(e,t=ct()){try{let n=us(t),r={...n};if(e(r),JSON.stringify(r)===JSON.stringify(n))return;le(Kc(t),`${JSON.stringify(r,null,2)}
|
|
18
|
+
`)}catch{}}s(ls,"updateRunLogWindows");function _h(e,t){ls(n=>{for(let r of t)n[r.scopeId]=r.until},e)}s(_h,"recordRunLogWindows");function hh(e){return e.replace(/[\r\n]/g," ")}s(hh,"oneLine");function Sh(e){try{if(xn(e).size<Uc)return;let t=`${e}.${process.pid}`;Mc(e,t);try{Mc(t,xn(t).size>=Uc?`${e}.1`:e)}catch{Fc(t)}}catch{}}s(Sh,"rotateIfFull");var Eh=/\bhttps?:\/\/[^\s'"<>`]+/gi;function yh(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname.replace(/\/[^/]+\/hook(?![\w-])/,"/***/hook")}`}catch{return"<url>"}}s(yh,"redactUrl");function Rh(e,t=ct()){let n=e.replace(Eh,yh);return t.length>1?n.replaceAll(t,"~"):n}s(Rh,"scrubForLog");function Ch(e,t){try{Z_(os(e),{recursive:!0}),Sh(e),q_(e,t,{encoding:"utf8",mode:384})}catch{}}s(Ch,"appendLine");function Pr(e=process.argv,t=Tr(),n,r){bh();let o=ct(),i,a=!1,c=s(()=>(a||(i=$c(o),a=!0),i),"readOnce"),u=cs(e,n??ph(c())),f=u||r!==void 0?void 0:Bc(o,c,process.env,Date.now());if(!u&&!(r??f?.on)){be=ut;return}f?.source==="remote"&&_h(o,f.scopes);let l=s((p,d)=>{Ch(t,`${new Date().toISOString()} ${p} ${Rh(hh(d),o)}
|
|
19
|
+
`)},"write");be={info(p){l("info",p)},error(p){l("error",p)}}}s(Pr,"initFileLogger");function Gc(){return be!==ut}s(Gc,"fileLoggerActive");var ue={info(e){be.info(e)},error(e){be.error(e)}},Ah=new Set(["post_failed","timeout"]),ce={},fs=!1;function bh(){ce={},fs=!1}s(bh,"resetRunState");function Wc(){return fs}s(Wc,"runLineWritten");function ee(e){if(be===ut)return;if(e.outcome===void 0){ce={...ce,...e};return}if(ce.outcome!==void 0&&Ah.has(ce.outcome)){ce.err===void 0&&e.err!==void 0&&(ce={...ce,err:e.err});return}let{runner:t,event:n,session:r,tool:o,ackMs:i}=ce;ce={runner:t,event:n,session:r,tool:o,ackMs:i,...e}}s(ee,"noteRun");function lt(e){let t=Ot(e)?e.cause:void 0;for(let n of[t,e])if(Ot(n)&&typeof n.code=="string"&&n.code!=="")return n.code;return e instanceof Error?e.name:typeof e}s(lt,"runErrorKind");var kh=4096;function xh(e){return(e.stack??"").split(`
|
|
20
|
+
`).map(t=>t.trim()).filter(t=>t.startsWith("at ")).join(" | ")}s(xh,"stackFrames");function On(e){try{return Oh(e).join(" ").slice(0,kh)}catch{return"err=unknown message=(unprintable)"}}s(On,"errorDetail");function Oh(e){let t=[`err=${lt(e)}`];if(!(e instanceof Error))return t.push(`message=${String(e)}`),t;t.push(`message=${e.message}`);let n=xh(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=${Ih(r)}`:`cause=${String(r)}`),r=r instanceof Error?r.cause:void 0;return t}s(Oh,"errorParts");function Ih(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(Ih,"causeText");function H(e,t,n=process.env){if(be===ut)return;let r=n[bn],o=r!==void 0&&as.test(r)?` run=${r}`:"";be.error(`failed where=${e}${o} ${On(t)}`)}s(H,"logFailure");function Th(){let e="";for(let t of X_(8))e+=Dc[t%Dc.length];return e}s(Th,"newRunId");function Vc(e=process.env){if(be===ut)return;let t=e[bn];if(t!==void 0&&as.test(t))return t;let n=Th();return e[bn]=n,n}s(Vc,"ensureRunId");function Ph(e){if(typeof e=="number")return Number.isInteger(e)?String(e):e.toFixed(1);let t=e.replace(fh,"_").slice(0,dh);return t===""?"_":t}s(Ph,"runValue");function Jt(e,t,n,r=process.env){if(be===ut)return;fs=!0;let o=r[bn],a=[["run",o!==void 0&&as.test(o)?o:void 0],["p",e],["start",new Date(performance.timeOrigin).toISOString()],["v",t],["runner",ce.runner],["event",ce.event],["tool",ce.tool],["session",ce.session],["outcome",ce.outcome??n],["ms",performance.now()],["ack_ms",ce.ackMs],["post_ms",ce.postMs],["http",ce.http],["err",ce.err]].filter(c=>c[1]!==void 0&&c[1]!=="").map(([c,u])=>`${c}=${Ph(u)}`);be.info(`run ${a.join(" ")}`)}s(Jt,"writeRunLine");function Ir(e,t){try{t-xn(e).mtimeMs>ah&&Fc(e)}catch{}}s(Ir,"unlinkIfStale");function zc(e=Date.now(),t=ct(),n=wh()){if(be!==ut)return;let r=Tr(t);Ir(r,e),Ir(`${r}.1`,e);try{for(let o of Q_(os(r)))(nh.test(o)||rh.test(o))&&Ir(xt(os(r),o),e)}catch{}Ir(n,e)}s(zc,"purgeStaleLog");function wh(e=process.platform){return e==="win32"?xt(eh(),Hc):xt("/tmp",Hc)}s(wh,"legacyLogPath");var Lh="installation.json",Mh="cloud-bootstrap.lock",Hh=6e4;function ru(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}s(ru,"platformAgentIdCacheKey");function Re(e=wr()){return ps(e,".ev-ai","agent-hook")}s(Re,"agentHookHome");function Uh(e=wr()){return ps(Re(e),Lh)}s(Uh,"installationStorePath");function ou(e){return ps(Nr(e),Mh)}s(ou,"cloudBootstrapLockPath");function su(){return Nh(8).toString("hex")}s(su,"randomInstallationId");function It(e){return Zc("sha256").update(e).digest("hex").slice(0,16)}s(It,"sha16");function K(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(K,"trimEnv");function iu(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}s(iu,"isValidInstallationId");function Dh(e=process.env){let t=K(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!iu(t)){R(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}s(Dh,"readInstallationIdEnvOverride");function au(e,t){return e&&iu(e)?e:(e&&R(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),Dh(t))}s(au,"resolvePinnedInstallationId");function Fh(e){return/^[0-9a-f]{16}$/.test(e)}s(Fh,"isEphemeralInstallationIdShape");function $h(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 It(`github_actions|${t}|${n}`)}if(K(e.CODESPACES)||K(e.CODESPACE_NAME)){let t=K(e.CODESPACE_NAME);if(t)return It(`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 It(`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 It(`gitlab|${t}|${n}`)}return null}s($h,"deriveEphemeralInstallationId");var jh="cursoragent@cursor.com";function Bh(e){let t=K(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===jh?null:t}s(Bh,"cursorCloudUserEmail");function Kh(e,t){return K(e.CURSOR_PROJECT_DIR)??K(e.CLAUDE_PROJECT_DIR)??t}s(Kh,"cursorCloudWorkspacePath");function Gh(e){return En(e).replace(/\.git$/i,"").toLowerCase()}s(Gh,"normalizeRemoteForSeed");async function Wh(e){let t=await se("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?Gh(t):e}s(Wh,"resolveRepoSeed");async function Vh(e){let t=K(await se("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!fe(null,t))return t;let n=K(await se("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!fe(null,n)?n:null}s(Vh,"readClaudeRemoteOperatorEmail");function zh(e,t){let n=Kh(e,t);return n?It(`cursor_cloud|${n}|${Bh(e)??""}`):null}s(zh,"deriveCursorCloudInstallationId");async function Jh(e,t,n=wr()){let r=Ec(n);if(r)return ue.info("claude_remote installation key=email"),It(`claude_remote/v2|${r}`);ue.info("claude_remote installation key=v1");let o=K(e.CLAUDE_PROJECT_DIR)??t;if(!o)return null;let i=await Wh(o),a=await Vh(o);return It(`claude_remote|${i}|${a??""}`)}s(Jh,"deriveClaudeRemoteInstallationId");function Jc(e,t){let n=au(e,t);if(n)return n;let r=$h(t);return r||su()}s(Jc,"chooseNewInstallationId");async function Yh(e){let n=await se("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||vh(e);return Zc("sha256").update(n).digest("hex").slice(0,16)}s(Yh,"computeRepoKey");function Xh(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(Xh,"readPlatformAgentIds");function qh(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=Xh(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(qh,"parseInstallationRecord");function Tt(e){if(Qc(e))try{return qh(eu(e,"utf8"))}catch{}}s(Tt,"readInstallationRecord");function ms(e){return Tt(e)}s(ms,"readInstallationStore");function cu(e,t,n){let r=Tt(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{le(e,`${JSON.stringify(o,null,2)}
|
|
21
|
+
`)}catch(i){let a=i instanceof Error?i.message:String(i);R(`WARN: operator identity cache write failed open: ${a}`),H("operator_identity_cache",i)}}s(cu,"writeOperatorIdentityCache");function uu(e,t=Date.now()){if(!e)return!0;if(Tt(e)?.operator_identity_hash)return!1;let n=ou(e);try{if(Qc(n)){let r=Number.NaN;try{r=Number(eu(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<Hh)return!1;try{tu(n)}catch{}}}catch{}try{return ds(Nr(n),{recursive:!0}),nu(n,`${t}
|
|
22
|
+
`,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(pu(r))return!1;let o=r instanceof Error?r.message:String(r);return R(`WARN: cloud bootstrap claim failed open: ${o}`),H("cloud_bootstrap_claim",r),!0}}s(uu,"tryClaimCloudIdentityBootstrap");function lu(e){if(e)try{tu(ou(e))}catch{}}s(lu,"releaseCloudIdentityBootstrapClaim");function fu(e,t){let r=Tt(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}s(fu,"readCachedPlatformAgentId");function du(e,t,n){if(!n)return;let r=Tt(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={...r,platform_agent_ids:{...r.platform_agent_ids,[t]:n}};try{le(e,`${JSON.stringify(o,null,2)}
|
|
23
|
+
`)}catch(i){let a=i instanceof Error?i.message:String(i);R(`WARN: platform_agent_id cache write failed open: ${a}`),H("platform_agent_id_cache",i)}}s(du,"writeCachedPlatformAgentId");function pu(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}s(pu,"isEexistError");function Zh(e,t){ds(Nr(e),{recursive:!0}),nu(e,`${JSON.stringify(t,null,2)}
|
|
24
|
+
`,{encoding:"utf8",flag:"wx"})}s(Zh,"writeInstallationRecordExclusive");function Yc(e,t){try{return Zh(e,t),t}catch(n){if(!pu(n))throw n;return Tt(e)}}s(Yc,"tryCreateInstallationRecord");function Xc(e,t){ds(Nr(e),{recursive:!0}),le(e,`${JSON.stringify(t,null,2)}
|
|
25
|
+
`)}s(Xc,"replaceInstallationRecord");function qc(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}s(qc,"newInstallationRecord");async function vr(e,t={}){let n=t.home??wr(),r=t.env??process.env,o=await Yh(e),i=Uh(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=kr(a),u=au(t.overrideId,r),f=c==="cursor_cloud"&&es(a)?zh(r,e):c==="claude_remote"?await Jh(r,e,n):null,l=Tt(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&&Fh(h.installation_id)&&f){let k={installation_id:f,...h.platform_agent_ids?{platform_agent_ids:h.platform_agent_ids}:{}};return Xc(i,k),{installationId:f,storePath:i,repoKey:o}}return{installationId:h.installation_id,storePath:i,repoKey:o}}let p=u??f??Jc(void 0,r),d=Yc(i,qc(p,u));if(d)return{installationId:d.installation_id,storePath:i,repoKey:o};let m=u??f??Jc(void 0,r),g=Yc(i,qc(m===p?su():m,u));if(g)return{installationId:g.installation_id,storePath:i,repoKey:o};throw new Error(`Failed to create installation record at ${i}`)}s(vr,"resolveOrCreateInstallationId");import{existsSync as hs,readFileSync as lS}from"node:fs";import{dirname as fS,isAbsolute as dS,join as pS,relative as mS}from"node:path";import{readFileSync as Qh,statSync as eS}from"node:fs";import{homedir as gs}from"node:os";import{join as tS}from"node:path";var nS="hook-config.json",rS=1440*60*1e3,oS=2048,sS=1024*1024;function Yt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(Yt,"isRecord");function mu(e=gs()){return tS(Re(e),nS)}s(mu,"hookConfigPath");function gu(e){let t=mu(e);try{let n=eS(t);if(!n.isFile()||n.size>sS)return;let r=JSON.parse(Qh(t,"utf8"));return Yt(r)?r:void 0}catch(n){return(n instanceof Error&&"code"in n?n.code:void 0)==="ENOENT"?null:void 0}}s(gu,"readStore");function iS(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===zt||!Number.isNaN(Date.parse(e.log_until)))&&(t.log_until=e.log_until),t}s(iS,"knownKeys");function _u(e,t=gs()){if(!e)return;let n=bt(e);if(!n)return;let r=gu(t),o=r?r[n]:void 0;if(!(!Yt(o)||!Yt(o.config)))return iS(o.config)}s(_u,"readHookConfig");function aS(e){let t=e.trim();if(t==="")return;let n;try{n=JSON.parse(t)}catch{return}if(!(!Yt(n)||!Yt(n.hook_config))&&!(Buffer.byteLength(JSON.stringify(n.hook_config),"utf8")>oS))return n.hook_config}s(aS,"hookConfigFromBody");function cS(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(!(Yt(i)&&JSON.stringify(i.config)===JSON.stringify(n)&&typeof i.fetched_at_ms=="number"&&i.fetched_at_ms<=r&&r-i.fetched_at_ms<rS))return o[t]={config:n,fetched_at_ms:r},o}s(cS,"nextStore");function hu(e,t,n=gs(),r=Date.now()){let o=aS(e),i=t?bt(t):void 0;if(o===void 0||!i)return"skipped";try{let a=gu(n);if(a===void 0)return ue.error("failed where=hook_config_read err=unreadable message=hook config store is not a readable JSON object"),"skipped";let c=cS(a??{},i,o,r);return c?(le(mu(n),`${JSON.stringify(c,null,2)}
|
|
26
|
+
`),Object.keys(o).length===0?"cleared":"written"):"unchanged"}catch(a){let c=a instanceof Error?a.message:String(a);return R(`WARN: hook config write failed open: ${c}`),H("hook_config_write",a),"failed"}}s(hu,"applyCollectorHookConfigResponse");var uS="EV_AI_HOOK_TELEMETRY";function Su(e){if(e===null||typeof e!="object")return;let t=e.telemetry;return typeof t=="boolean"?t:void 0}s(Su,"telemetryFromHomeConfig");function Eu(e,t,n=process.env){let r=n[uS]?.trim().toLowerCase();return r&&Rt.has(r)?{enabled:!0,source:"env"}:r&&fr.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(Eu,"resolveTelemetry");function yu(e){for(let t of mr){let n=pS(e,t);if(hs(n))return n}}s(yu,"firstExistingManifest");async function gS(e=process.cwd(),t){let n=t??await We(e);return yu(n)??yu(e)}s(gS,"findRepoManifestPath");async function _S(e,t){let n=t??await We(fS(e)),r=mS(n,e);if(r.startsWith("..")||dS(r))return!1;let o=await Ie("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(R(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}s(_S,"isManifestGitTracked");function _s(e){let t=lS(e,"utf8");return Te(Kt(t),{})}s(_s,"loadRepoManifestFromFile");function hS(){return{schema_version:at,mcp_servers:[]}}s(hS,"defaultSharedManifest");function SS(e,t,n,r){!t||!n||(e.capture_hook_input==="full"&&r.has("capture_hook_input")&&(R(`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")&&(R(`WARN: ignoring debug=true in git-tracked manifest ${t}; set debug on ~/.ev-ai/config.json`),delete e.debug))}s(SS,"stripTrackedUnsafeFields");function ES(e){let t=sc({argv:e.argv,env:process.env,homeConfig:e.homeConfig,manifest:e.manifest,manifestSource:e.manifestSource});for(let r of t.warnings){R(`WARN: ignoring ${r.label}: ${r.problem}`);let o=r.label.replace(/\s+/g,"_"),i=r.problem.replace(/\/[^/\s]+\/hook\b/g,"/***/hook");ue.error(`collector ignored label=${o} message=${i}`)}let n=t.url??"";return ue.info(`collector source=${t.source} url=${n?Wt(n):"(none)"}`),n}s(ES,"collectorUrlFromLoaded");function yS(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return e}s(yS,"recordOrUndefined");async function Ru(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await Ko(e),o=D("EV_AI_HOOK_MANIFEST"),i=o&&hs(o)?o:void 0,a=i?void 0:hs(At())?At():void 0,c=i?void 0:await gS(e,n),u=a?_s(a):void 0,f=c?_s(c):void 0,l=Su(i?Z(At(),{}):u),p,d,m,g=new Set;if(i){p=_s(i),d=i,m=i;for(let x of Object.keys(p))g.add(x)}else if(u&&f){p=nc(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=hS();delete p.installation_id;let h=m?await _S(m,n):!1;SS(p,m,h,g);let{installationId:y,storePath:k,repoKey:P}=await vr(n,{sessionId:t.sessionId}),w=u??yS(Z(At(),null)),O=ES({argv:t.argv??process.argv,homeConfig:w,manifest:i?p:f,manifestSource:i?"manifest_override":"manifest"});return{manifestPath:d??k,manifest:p,installationId:y,installationStorePath:k,repoKey:P,collectorUrl:O,hookConfig:_u(O),...l!==void 0?{localTelemetry:l}:{},platformAgentId:p.platform_agent_id??"",gitRoot:n,inGitRepo:r}}s(Ru,"loadManifest");function Cu(e){return{schema_version:at,...e?{collector_url:e}:{},mcp_servers:[]}}s(Cu,"createDefaultSharedManifest");var RS=["darwin-arm64","darwin-x64","linux-arm64","linux-x64","windows-x64","windows-arm64"];function CS(e){return e==="windows-x64"||e==="windows-arm64"}s(CS,"isWindowsSlug");function Ss(e=process.platform,t=process.arch){if(e==="darwin")return t==="arm64"?"darwin-arm64":t==="x64"?"darwin-x64":void 0;if(e==="linux")return t==="arm64"?"linux-arm64":t==="x64"?"linux-x64":void 0;if(e==="win32")return t==="x64"?"windows-x64":t==="arm64"?"windows-arm64":void 0}s(Ss,"resolvePlatformSlug");function Au(e=process.platform,t=process.arch){let n=Ss(e,t);if(!n)throw new Error(`Unsupported platform ${e}-${t}. Supported: ${RS.join(", ")}.`);return n}s(Au,"assertSupportedPlatform");function AS(e){return CS(e)?`${Ae}.exe`:Ae}s(AS,"hookBinaryFileName");function Es(e){return`compile-out/bin/${e}/${AS(e)}`}s(Es,"compiledBinaryRelativePath");function PS(e,t){let n=e.collectorUrl?.trim();if(!n)throw new Error(`${t} requires --url <https://hooks.ev-ai.ai/{orgToken}/hook>`);let r=ze(n);if(r)throw new Error(`collector URL rejected: ${r}`);return it(n)}s(PS,"requireCollectorUrl");function wS(e){let t=e.collectorUrl?.trim();if(!t)return;let n=ze(t);if(n)throw new Error(`collector URL rejected: ${n}`);return it(t)}s(wS,"optionalCollectorUrl");function NS(e){return PS(e,"install")}s(NS,"requireInstallCollectorUrl");function Tu(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url")}return t}s(Tu,"parseConfigureArgs");function Pu(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(r==="--url"){let o=e[n+1];o&&!o.startsWith("--")&&(t.collectorUrl=o,n+=1);continue}if(r==="--collector-url")throw new Error("--collector-url was renamed to --url");if(r==="--update")throw new Error("--update was removed; use the `update` command instead of `install --update`");if(r==="--delivery"){let o=e[n+1];(o==="npx"||o==="binary"||o==="local")&&(t.delivery=o,n+=1);continue}if(r==="--force"){t.force=!0;continue}if(r==="--no-claude"){t.skipClaude=!0;continue}if(r==="--no-cursor"){t.skipCursor=!0;continue}if(r==="--no-codex"){t.skipCodex=!0;continue}}return t}s(Pu,"parseInstallArgs");function wu(e=process.execPath){return Nu(e)?"binary":"npx"}s(wu,"defaultHookDelivery");function vS(){return z(Ye(),".ev-ai","agent-hook")}s(vS,"agentHookBinaryHome");function LS(e=Ye()){return z(e,".ev-ai","agent-hook",zo)}s(LS,"globalHookBinaryPath");function MS(){let e=Cs(TS(import.meta.url)),t=z(e,"hook.mjs");return ft(t)?t:z(e,"..","dist","hook.mjs")}s(MS,"resolveBundledHookPath");function Nu(e=process.execPath){return Er(e)}s(Nu,"isCompiledHookBinary");function vu(e,t){let n=Iu(bu(e),bu(t));return!n.startsWith("..")&&!OS(n)}s(vu,"isUnderRoot");function Hr(e){return e.split(IS).join("/")}s(Hr,"toPosixPath");function HS(e){return`node "$(git rev-parse --show-toplevel)/${Hr(e)}"`}s(HS,"gitRootRelativeNodeCommand");function US(e){return`"$(git rev-parse --show-toplevel)/${Hr(e)}"`}s(US,"gitRootRelativeBinaryCommand");function DS(e){return z(e,Jo)}s(DS,"projectHookBinaryPath");function Lu(e,t){let n=DS(e);Rs(Cs(n),{recursive:!0}),Ou(t,n,{force:!0});try{xu(n,493)}catch{}return n}s(Lu,"pinHookBinaryIntoProject");function FS(e){let t=z(vS(),"current");try{Mr(t,{recursive:!0,force:!0})}catch{}kS(e,t,process.platform==="win32"?"junction":"dir")}s(FS,"refreshCurrentSymlink");function Mu(e,t=me,n=Ye()){let r=z(n,".ev-ai","agent-hook",t),o=z(r,Ae);Rs(r,{recursive:!0}),Ou(e,o,{force:!0});try{xu(o,493)}catch{}return FS(r),z(n,".ev-ai","agent-hook",zo)}s(Mu,"pinHookBinary");function Hu(e){let t=Ss();if(!t)return;let n=[z(e,Es(t)),z(e,"packages","agent-hook",Es(t))];for(let r of n)if(ft(r)&&vu(e,r))return r}s(Hu,"resolveDevBundledBinary");function $S(e=Ye()){let t=LS(e);return ft(t)?t:void 0}s($S,"resolveGlobalBinary");function jS(e,t=Ye()){let n=$S(t);return n||(Nu()?Mu(process.execPath,me,t):Hu(e))}s(jS,"resolveBinarySource");function BS(e,t=Ye()){let n=Hu(e);if(!n)throw new Error(`update requires a locally compiled binary \u2014 run this package\u2019s build:hook-binary script first.
|
|
27
|
+
To install a released binary instead: curl -fsSL https://cdn.ev-ai.ai/agent-hook/install.sh | sh`);let r=Mu(n,me,t),o=Lu(e,n);return{sourcePath:n,projectPath:o,globalPath:r}}s(BS,"refreshPinnedBinariesFromCompileOut");function ku(e){let t=[z(e,"packages","agent-hook","dist","hook.mjs"),z(e,ic)],n=MS();ft(n)&&vu(e,n)&&t.unshift(n);for(let r of t){if(!ft(r))continue;let o=Hr(Iu(e,r));return{command:HS(o),hookPath:o,strategy:"dev_mjs"}}}s(ku,"resolveDevMjsHook");function KS(e){return e==="SessionStart"||e==="sessionStart"}s(KS,"isSessionStartEvent");function GS(e){return e.replace(/\s+--prefer-offline\b/g,"")}s(GS,"withoutPreferOffline");function Lr(e,t){return KS(e)?GS(t):t}s(Lr,"commandForEvent");function WS(e=Rr){return`npx -y --prefer-offline ${e}`}s(WS,"npxHookCommand");function VS(e,t=Ye(),n=wu()){if(n==="npx")return{command:WS(),hookPath:Rr,strategy:"npx"};if(n==="local"){let i=ku(e);if(i)return i;throw new Error("local delivery requires packages/agent-hook/dist/hook.mjs (or node_modules/@ev-ai/agent-hook/dist/hook.mjs) under the git root \u2014 run yarn workspace @ev-ai/agent-hook build first")}let r=jS(e,t);if(r){Lu(e,r);let i=Hr(Jo);return{command:US(i),hookPath:i,strategy:"project_binary"}}let o=ku(e);if(o)return o;throw new Error(`ev-ai-agent-hook binary not found. Install from CDN:
|
|
28
|
+
curl -fsSL ${ac}/install.sh | sh
|
|
27
29
|
Or use npx delivery:
|
|
28
|
-
npx ${
|
|
29
|
-
`,"utf8")}function Ge(e){if(rt(e))try{return JSON.parse(L_(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}function oh(e,t){let n=kc(t.collectorUrl),r={...e,schema_version:e?.schema_version??n.schema_version};return t.collectorUrl!==void 0?r.collector_url=t.collectorUrl:r.collector_url=e?.collector_url??n.collector_url,delete r.repo_ingest_token,delete r.installation_id,r.mcp_servers??=n.mcp_servers,r}function sh(e){return(e.schema_version??nt)===nt&&e.collector_url===void 0&&(e.mcp_servers?.length??0)===0&&e.platform_agent_id===void 0&&e.capture_hook_input===void 0&&e.debug===void 0&&e.repo_ingest_token===void 0}function jc(e,t){let n=V(e,Yn),r=Ge(n),o=oh(r,t);return t.collectorUrl!==void 0||rt(n)||!sh(o)?(ot(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}function jo(e){if(e===null||typeof e!="object")return!1;let t=e,n=String(t.CLAUDE_CODE_ENABLE_TELEMETRY??"").toLowerCase();return n==="1"||n==="true"?!0:Object.keys(t).some(r=>r.startsWith("OTEL_"))}function ih(e){if(jo(process.env))return!0;let t=Ke();return[...Io(),V(t,".claude","settings.json"),V(t,".claude","remote-settings.json"),V(e,".claude","settings.json"),V(e,".claude","settings.local.json")].some(r=>{try{let o=Ge(r);return o?jo(o.env):!1}catch{return!1}})}function ah(e){try{let t=Ge(V(e,".claude","settings.json"));return t?jo(t.env):!1}catch{return!1}}function Bc(e){return Array.isArray(e)?e:[]}function gr(e){let t=[],n=r=>!!r&&typeof r=="object"&&$c(r.command);for(let r of Bc(e)){if(!r||typeof r!="object"){t.push(r);continue}let o=Array.isArray(r.hooks)?r.hooks:[],s=o.filter(i=>!n(i));if(!(s.length===0&&o.some(n))){if(s.length!==o.length){t.push({...r,hooks:s});continue}t.push(r)}}return t}function Kc(e,t){return[...gr(e),...t]}function Vo(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!$c(t.command)):[]}function ch(e,t){return[...Vo(e),{command:t}]}function uh(e){return typeof e=="string"?[e]:e}function lh(e){let t=(n="")=>({hooks:uh(e).map(r=>({type:"command",command:dr(n,r)}))});return{SessionStart:[t("SessionStart")],UserPromptExpansion:[t()],UserPromptSubmit:[t()],PreToolUse:[t()],PostToolUse:[t()],PostToolUseFailure:[t()],PermissionDenied:[t()],Stop:[t()],StopFailure:[t()],SessionEnd:[t()],SubagentStart:[t()],SubagentStop:[t()]}}function fh(e){let t=typeof e=="string"?{command:e}:e,n=(r="")=>({hooks:[{type:"command",command:dr(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:dr(r,t.commandWindows)},statusMessage:Ha}]});return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}var dh=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],ph=["afterShellExecution","afterFileEdit"];function mh(e,t=ph){let n={...e};for(let r of t){if(!(r in n))continue;let o=Vo(n[r]);o.length===0?delete n[r]:n[r]=o}return n}function gh(e,t,n={}){let r=V(e,".claude/settings.json"),o=Go(t,"claude"),s=Ge(r)??{};if(ih(e)&&!n.force){if(s.hooks&&typeof s.hooks=="object"){let u={...s.hooks};for(let d of Object.keys(u))u[d]=gr(u[d]),Bc(u[d]).length===0&&delete u[d];Object.keys(u).length===0?delete s.hooks:s.hooks=u,ot(r,s)}return!1}let a=s.hooks&&typeof s.hooks=="object"?s.hooks:{},c=lh(o),l={...a};for(let[u,d]of Object.entries(c))l[u]=Kc(a[u],d);return s.hooks=l,ot(r,s),!0}function _h(e,t){let n=V(e,".cursor/hooks.json"),r=Go(t,"cursor"),o=Ge(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=mh({...s});for(let a of dh)i[a]=ch(i[a],dr(a,r));ot(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:i})}function hh(e,t){let n=V(e,".codex/hooks.json"),r=Go(t,"codex"),o=Ge(n)??{},s=o.hooks&&typeof o.hooks=="object"?o.hooks:{},i=fh(r),a={...s};for(let[c,l]of Object.entries(i))a[c]=Kc(s[c],l);ot(n,{...o,hooks:a})}function Sh(e){let t=V(e,".claude/settings.json"),n=Ge(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1;for(let s of Object.keys(r)){let i=r[s],a=gr(i);JSON.stringify(i)!==JSON.stringify(a)&&(o=!0),a.length===0?delete r[s]:r[s]=a}o&&(Object.keys(r).length===0?delete n.hooks:n.hooks=r,ot(t,n),E(`Removed ev-ai hooks from ${t}`))}function Eh(e){let t=V(e,".cursor/hooks.json"),n=Ge(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=Vo(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks"&&a!=="version").length===0){pr(t,{force:!0}),E(`Removed ${t}`);return}ot(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function yh(e){let t=V(e,".codex/hooks.json"),n=Ge(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,s=0;for(let i of Object.keys(r)){let a=r[i],c=gr(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:(r[i]=c,s+=c.length)}if(o){if(s===0&&Object.keys(r).length===0&&Object.keys(n).filter(a=>a!=="hooks").length===0){pr(t,{force:!0}),E(`Removed ${t}`);return}ot(t,{...n,hooks:r}),E(`Removed ev-ai hooks from ${t}`)}}function Wo(e=process.platform,t=process.arch,n={}){if(e==="win32")throw new Error("Windows install is not supported yet. Use macOS/Linux, or wait for phase-2 native commands.");(n.requireBinaryArch??!0)&&xc(e,t)}async function Gc(e={}){let t=K_(e);e.collectorUrl=t;let n=e.skipClaude===!0,r=e.skipCursor===!0,o=e.skipCodex===!0;if(n&&r&&o)throw new Error("at least one runner must be wired; refuse --no-claude --no-cursor --no-codex together");let s=e.delivery??Mc();Wo(process.platform,process.arch,{requireBinaryArch:s==="binary"});let i=e.cwd??process.cwd(),a=await Fe(i),{command:c,hookPath:l,strategy:u}=rh(a,Ke(),s),{installationId:d,storePath:f}=await ur(a,{overrideId:e.installationId}),{manifestPath:p,wrote:g}=jc(a,e),S=[];return n?E("Skipped Claude hook \u2014 --no-claude"):gh(a,c,{force:e.force})?(S.push("Claude"),e.force&&ah(a)&&E("Forced Claude hook despite project native OTEL \u2014 expect duplicate session/tool events")):E("Skipped Claude hook \u2014 native OTEL telemetry already enabled (avoids duplicate events); pass --force to wire anyway"),r?E("Skipped Cursor hook \u2014 --no-cursor"):(_h(a,c),S.push("Cursor")),o?E("Skipped Codex hook \u2014 --no-codex"):(hh(a,c),S.push("Codex")),E(`Installed hook (${u}) at ${l}`),E(`Installation identity ${d} at ${f}`),g&&p?E(`Shared manifest written to ${p}`):E("Using package default collector config (no shared manifest file needed)"),E(S.length>0?`Wired ${S.join(", ")} hooks in ${a} (commands include --runner)`:`No runner hooks wired in ${a} (Claude skipped by OTEL; Cursor/Codex excluded via flags)`),u==="npx"?E("Hook commands use npx and may be committed; teammates need Node on PATH only (no install step, no env vars when collector_url is in the shared manifest)."):u==="project_binary"?E("Hook commands are git-root-relative and may be committed; each collaborator runs install once to populate .ev-ai/agent-hook/ (gitignored)."):u==="dev_mjs"&&E("Hook commands use node + monorepo packages/agent-hook/dist/hook.mjs (local delivery; rebuild with yarn workspace @ev-ai/agent-hook build)."),g&&p&&e.collectorUrl&&E("Shared manifest includes collector_url \u2014 commit it with hook configs so teammates post without env vars."),{gitRoot:a,hookPath:l,manifestPath:p,installationStorePath:f,strategy:u}}async function Vc(e=process.cwd()){Wo(process.platform,process.arch,{requireBinaryArch:!0});let t=await Fe(e),{projectPath:n,globalPath:r}=Q_(t);E(`Refreshed ${r}`),E(`Refreshed ${n}`),E("Hook configs and shared manifest left unchanged")}async function Wc(e={}){let t=B_(e);e.collectorUrl=t,Wo(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await Fe(n),{manifestPath:o,wrote:s}=jc(r,e);if(t!==void 0&&(!o||!s))throw new Error("configure failed to write shared collector manifest");return s&&o?E(`Wrote ${o}`):t===void 0&&E("No --url given and no shared manifest yet \u2014 pass --url <\u2026/{orgToken}/hook> to write collector destination."),E("Manifest only \u2014 enable ev-ai marketplace plugins. Do not also run file-wiring install for the same events."),{gitRoot:r,manifestPath:o}}function zc(e){for(let t of[()=>Sh(e),()=>Eh(e),()=>yh(e)])try{t()}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: strip skipped a hook file: ${r}`)}}async function Jc(e=process.cwd()){let t=await Fe(e);return zc(t),E("Stripped ev-ai file-wired hooks; shared collector manifest left in place."),E("Next: enable ev-ai marketplace plugins, then restart runners."),{gitRoot:t}}async function Yc(e=process.cwd()){let t=await Fe(e);zc(t);for(let n of Xn){let r=V(t,n);if(rt(r))try{pr(r,{force:!0}),E(`Removed ${r}`)}catch(o){let s=o instanceof Error?o.message:String(o);E(`WARN: uninstall could not remove ${r}: ${s}`)}}}import{existsSync as YE,mkdirSync as XE,readdirSync as qE,readFileSync as ZE,unlinkSync as Zu,writeFileSync as QE}from"node:fs";import{homedir as Qu}from"node:os";import{join as as}from"node:path";import{existsSync as wh}from"node:fs";import{existsSync as Rh}from"node:fs";import{homedir as qc}from"node:os";import{join as Ch}from"node:path";function Zc(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}var Ah={claude:{shared:{skillRoots:[".claude/skills"],dirs:[{dir:".claude/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".claude/commands",kind:"COMMAND",extensions:[".md"]},{dir:".claude/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["CLAUDE.md"],["CLAUDE.local.md"],[".claude/CLAUDE.md"]],settings:[".claude/settings.json",".claude/settings.local.json",".claude/hooks.json"]},homeOnly:{mcpJson:[".claude.json"],plugins:"claude",managed:"claude"},projectOnly:{mcpJson:[".mcp.json","mcp.json"]}},cursor:{shared:{skillRoots:[".cursor/skills"],dirs:[{dir:".cursor/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".cursor/commands",kind:"COMMAND",extensions:[".md"]},{dir:".cursor/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[["AGENTS.md"]],settings:[".cursor/hooks.json",".cursor/sandbox.json",".cursor/permissions.json"],mcpJson:[".cursor/mcp.json"]},homeOnly:{skillRoots:[".cursor/skills-cursor"],memory:[[".cursor/AGENTS.md"]],settings:[".cursor/cli-config.json"],plugins:"cursor",managed:"cursor"},projectOnly:{skillRoots:[".agents/skills"],settings:[".cursor/cli.json"]}},codex:{shared:{skillRoots:[".agents/skills",".codex/skills"],dirs:[{dir:".codex/agents",kind:"SUBAGENT",extensions:[".toml",".md"]},{dir:".codex/prompts",kind:"COMMAND",extensions:[".md"]},{dir:".codex/rules",kind:"RULE",extensions:[".md",".rules"]}],memory:[["AGENTS.override.md","AGENTS.md"]],settings:[".codex/hooks.json",".codex/config.toml"],mcpToml:[".codex/config.toml"]},homeOnly:{memory:[[".codex/AGENTS.override.md",".codex/AGENTS.md"]],managed:"codex"}}};function Xc(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}function bh(e,t={}){let{shared:n}=e;return{skillRoots:[...n.skillRoots,...t.skillRoots??[]],dirs:n.dirs,memory:[...n.memory,...t.memory??[]],settings:[...n.settings,...t.settings??[]],mcpJson:Xc(n.mcpJson,t.mcpJson),mcpToml:Xc(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}function Qc(e){return Object.fromEntries(Object.entries(Ah).map(([t,n])=>[t,bh(n,n[e])]))}var vt=Qc("homeOnly"),it=Qc("projectOnly");function kh(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}function xh(e,t){return kh(e).some(n=>Rh(Ch(t,n)))}function eu(e,t){for(let n of e)if(xh(n,t))return!0;return!1}function st(e){return[...new Set(e)]}function at(e){let t=[],n=[],r=[],o=[],s=[],i=[],a=[];for(let c of e){t.push(...c.skillRoots);for(let l of c.dirs)l.kind==="SUBAGENT"?n.push(l.dir):l.kind==="COMMAND"?r.push(l.dir):o.push(l.dir);s.push(...c.memory.flat()),i.push(...c.settings),a.push(...c.mcpJson??[],...c.mcpToml??[])}return{skills:st(t),subagents:st(n),commands:st(r),rules:st(o),memory:st(s),settings:st(i),mcp:st(a)}}function Oh(e,t=qc(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...sr(o.managed,n,t));return st(r)}var ct=at(Object.values(vt));function tu(e=qc(),t=process.platform){return Oh(Object.values(vt),e,t)}import{existsSync as Ih}from"node:fs";import{resolve as zo}from"node:path";function ye(e){return zo(e).replaceAll("\\","/").replace(/\/$/,"")}function _t(e,t){let n=new Set(t),r=[];for(let o of e)n.delete(o)&&r.push(o);for(let o of[...n].sort())r.push(o);return r}function _r(e,t){if(!e)return t;let n=`${e}/`,r=[],o=[];for(let s of t)s===e||s.startsWith(n)?r.push(s):o.push(s);return r.length===0?t:[...r,...o]}var Th=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function on(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!Th.test(t)?null:t}function Mt(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let s=ye(o);n.has(s)||(n.add(s),r.push(s))}return r}function Ph(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}function Pe(e,t,n,r=Ih){for(let o of e)for(let s of t){let i=ye(zo(o,s)),a=zo(o,s,n).replaceAll("\\","/");if(Ph(i,a)&&r(a))return a}return null}var ru=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,ou=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,Nh=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,nu=new Set(["applications","app","bin","boot","data","dev","etc","home","lib","media","mnt","node_modules","opt","pkg","private","proc","projects","repos","run","sbin","src","srv","sys","tmp","usr","users","var","volumes","workspace","workspaces"]),vh=/^[a-z][a-z0-9-]{1,63}$/,Mh=[".cursor/skills",".claude/skills",".agents/skills"],Lh=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],Hh=_t(Mh,at(Object.values(it)).skills),Uh=_t(Lh,at(Object.values(vt)).skills),Dh=new Set(["read","read_file","view"]),Fh=new Set(["bash","shell","zsh"]);function Jo(e){let t=e.replace(/\\/g,"/");return ru.exec(t)?.[1]??null}function $h(e){let t=e.replace(/\\/g,"/"),r=ou.exec(t)?.[1];return r?r.toLowerCase():null}function jh(e){return Jo(e)??$h(e)}function Bh(e){for(let t of["path","file_path","target_file"]){let n=e[t];if(typeof n=="string"&&n.length>0)return n}return null}function hr(e){return typeof e=="string"?hr(Se(e,null)):!e||typeof e!="object"?null:Bh(e)}function su(e){if(typeof e=="string")return su(Se(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}function Yo(e){let t=su(e.tool_input);if(t)return t;let n=pt(e.command);return n.length>0?n:null}function Kh(e){let t=e.replace(/\\/g,"/"),n=ru.exec(t);if(n?.[1])return n[1];let o=ou.exec(t)?.[1];return o?o.toLowerCase():null}function Gh(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function Xo(e){let t=hr(e.tool_input)??pt(e.file_path);return t.length>0?t:null}function sn(e,t,n){let r=Gh(e).toLowerCase();if(Dh.has(r)){let o=Xo(e);return o?t(o):null}if(Fh.has(r)){let o=Yo(e);return o?n(o):null}return null}function iu(e){return sn(e,jh,Kh)}function Vh(e){let t=new Set,n=[];for(let r of e.matchAll(Nh)){let o=r[1]?.toLowerCase();!o||t.has(o)||Wh(o)||(t.add(o),n.push(o))}return n}function Wh(e){let t=e.split("/")[0];return nu.has(e)||t!==void 0&&nu.has(t)}function au(e){let t=e.skillId.toLowerCase();if(!vh.test(t))return null;let n=e.exists??wh,r=`${t}/SKILL.md`,o=Pe(Mt(e.launchCwd,e.gitRoot),Hh,r,n);return o!==null?o:e.home?Pe([ye(e.home)],Uh,r,n):null}function zh(e){return pt(e.prompt)}function cu(e){let t=L(e,"command_name");if(t){let r=L(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=zh(e);return n?Vh(n):[]}var ns=Qe(lt(),1);import{existsSync as yE}from"node:fs";var St={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function cn(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function EE(e){if(!e)return"";let t=Xt(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return cn(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return cn(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?cn(o[1]):cn(t)}async function br(e=process.cwd()){let t=await Ae("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,s]=await Promise.all([Ae("git",["remote","get-url","origin"],2e3,{cwd:e}),Ae("git",["branch","--show-current"],2e3,{cwd:e}),Ae("git",["rev-parse","HEAD"],2e3,{cwd:e}),Ae("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?Xt(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:s.ok?s.stdout.length>0:null}}async function vu(e,t,n,r=process.cwd(),o,s,i){if(t)return t;let a=St[n];if(!a)return"";let c=rc(n,e.scope_path,i);if(s){let g=fc(s,c);if(g)return g}let l=o??await br(r),u=l?.remote?EE(l.remote):"";if(u||(u=cn(process.env.GITHUB_REPOSITORY??"")),!u)return"";let d=e.scope_path??"",f=d?`${d}/`:"",p=`${u}:${f}${a}`;return s&&dc(s,c,p),p}var RE=[".cursor/rules",".claude/rules",".codex/rules"],CE=at(Object.values(it)).rules;function AE(e){return _t(_r(e?St[e]:void 0,RE),CE)}var bE=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function Mu(e){let t=on(e.relativePath);if(!t)return null;let n=e.exists??yE,r=Mt(e.launchCwd,e.gitRoot),o=AE(e.runnerPlatform),s=Pe(r,o,t,n);if(s!==null)return s;if(!t.includes("/")){let i=Pe(r,["."],t,n);if(i!==null)return i}return e.home?Pe([ye(e.home)],o,t,n):null}function kE(e){let t=e.replace(/\\/g,"/"),r=bE.exec(t)?.[1];return r?(0,ns.nativeKeyForRulePath)(r):null}function Lu(e){return sn(e,ns.nativeKeyForRulePath,kE)}function Hu(e){return e.replace(/\.(mdc|md|rules)$/i,"")}function Uu(e){let t=e.attachments;if(!Array.isArray(t))return[];let n=new Set,r=[];for(let o of t){if(!o||typeof o!="object"||Array.isArray(o))continue;let s=o;if(s.type!=="rule")continue;let i=typeof s.file_path=="string"?s.file_path:"",a=on(i);!a||n.has(a)||(n.add(a),r.push(a))}return r}var rs=Qe(lt(),1);import{existsSync as xE}from"node:fs";var OE=[".cursor/commands",".claude/commands",".codex/prompts"],IE=at(Object.values(it)).commands;function TE(e){return _t(_r(e?St[e]:void 0,OE),IE)}var PE=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function Du(e){let t=on(e.commandId);if(!t)return null;let n=e.exists??xE,r=`${t}.md`,o=TE(e.runnerPlatform),s=Pe(Mt(e.launchCwd,e.gitRoot),o,r,n);return s!==null?s:e.home?Pe([ye(e.home)],o,r,n):null}function wE(e){let t=e.replace(/\\/g,"/"),r=PE.exec(t)?.[1];return r?(0,rs.nativeKeyForCommandPath)(r):null}function Fu(e){return sn(e,rs.nativeKeyForCommandPath,wE)}var kr=Qe(lt(),1);function $u(e,t){if(L(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function NE(){return!!(M("CURSOR_VERSION")??M("CURSOR_PROJECT_DIR"))}function ju(e,t,n){return e!=="claude"&&e!=="codex"?!1:$u(t,n)?!0:NE()}var vE=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function un(e,t,n,r){return $u(e,t)?"cursor":qn(r)?r:qn(n)?n:L(e,"turn_id")?"codex":L(e,"session_id")||vE.has(t.toLowerCase())?"claude":"unknown"}function xr(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function ME(e){switch(e){case"sessionstart":return"session_start";case"stop":case"sessionend":case"stopfailure":return"session_end";case"pretooluse":case"posttooluse":case"posttoolusefailure":case"permissiondenied":case"beforemcpexecution":case"beforeshellexecution":case"aftershellexecution":case"beforereadfile":case"afterfileedit":case"subagentstart":case"subagentstop":return"tool_invoked";case"beforesubmitprompt":case"userpromptexpansion":case"userpromptsubmit":return"skill_invoked";default:return""}}function Bu(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}function Ku(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}function Gu(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function ln(e){return L(e,"session_id")||L(e,"conversation_id")}function os(e){return L(e,"prompt.id")||L(e,"prompt_id")||L(e,"generation_id")||L(e,"turn_id")}function ss(e){return L(e,"hook_event_name")||L(e,"event")}function Vu(e,t,n){let r=ln(e),o=os(e),s=ss(e),i=L(e,"source"),a=un(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:i,runnerPlatform:a}}var LE=["session_start","session_end","tool_invoked","skill_invoked"];function HE(e){return LE.includes(e)}function is(e,t){return e&&HE(e)?e:ME(t.toLowerCase())}var UE={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function Or(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function Wu(e,t=""){let n=L(e,"tool_name")||L(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!Or(n)&&(n=`MCP:${n}`):n=UE[r]??null;let o=e.tool_input,i=(o&&typeof o=="object"?pt(o.skill)||pt(o.skill_name):"")||L(e,"skill_name")||null,a=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;i??=iu(a);let c=Lu(a),l=Fu(a);return{toolName:n,skillName:i,ruleName:c,commandName:l}}var DE=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function zu(e){for(let t of["subagent_type","agent_type"]){let n=L(e,t);if(n&&DE.test(n))return n}return null}function Ju(e){let t=$e(e,"duration_ms");if(typeof t=="number")return t;let n=$e(e,"duration");return typeof n=="number"?n:null}var FE="error",$E="interrupted",jE="permission_denied",BE=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function fn(e){return BE.test(e)?e:null}function KE(e){for(let t of["failure_type","error_type"]){let n=fn(L(e,t));if(n)return n}return null}function Yu(e,t){return $e(e,"is_interrupt")===!0?$E:t.toLowerCase()==="permissiondenied"?jE:KE(e)??FE}function Xu(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}function GE(e,t){return Xu(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}function VE(e,t){return Xu(t,n=>(0,kr.mcpServerNameMatchesToolSegment)(n,e))}function WE(e,t){let n=null,r=0;for(let s of t)if(s)for(let i of(0,kr.mcpServerToolSegmentForms)(s)){let a=`${i}__`;e.length>a.length&&e.slice(0,a.length).toLowerCase()===a.toLowerCase()&&i.length>r&&(n={mcpServer:s,mcpTool:e.slice(a.length)},r=i.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:VE(o[1],t)??o[1],mcpTool:o[2]}}function zE(e,t){if(/^mcp__/i.test(e))return WE(e.slice(5),t);if(/^MCP:/i.test(e)){let n=e.slice(4);if(!n)return{mcpServer:null,mcpTool:null};let r=n.indexOf(":");if(r>0)return{mcpServer:n.slice(0,r),mcpTool:n.slice(r+1)||null};let o=n.indexOf("__");return o>0?{mcpServer:n.slice(0,o),mcpTool:n.slice(o+2)||null}:{mcpServer:GE(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}function JE(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}function qu(e,t=[],n=""){let r=e?zE(e,t):{mcpServer:null,mcpTool:null},o=fn(n.trim());if(!o)return r;let s=r.mcpTool;return!s&&e&&!Or(e)&&(s=e),s&&(s=JE(s,o)),{mcpServer:o,mcpTool:s}}var el=3e4,ey="claims",ty=!0,ny=100,ry=new Set(["sessionstart","sessionend","stopfailure"]),oy=["tool_name","tool","command","file_path","url"];function sy(e=Qu()){return as(ge(e),ey)}function tl(e,t){try{let n=ZE(e,"utf8").split(`
|
|
30
|
-
`,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}function
|
|
31
|
-
`,{encoding:"utf8",flag:"wx"})}catch(o){if(
|
|
32
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);
|
|
33
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);
|
|
30
|
+
npx ${Rr} install`)}s(VS,"resolveHookCommand");function Uu(e){return typeof e!="string"?!1:e.includes("@ev-ai/agent-hook")||e.includes("agent-hook/dist/hook")||e.includes(".ev-ai/agent-hook")||e.includes(Ae)||/(?:^|[\s/"'])ev-ai-agent-hook(?:$|[\s"'])/.test(e)}s(Uu,"isEvAiHookCommand");function As(e,t){return`${e.replace(/\s+--runner(?:=|\s+)\S+/g,"").trimEnd()} --runner ${t}`}s(As,"withRunnerFlag");function dt(e,t){Rs(Cs(e),{recursive:!0}),xS(e,`${JSON.stringify(t,null,2)}
|
|
31
|
+
`,"utf8")}s(dt,"writeJson");function Xe(e){if(ft(e))try{return JSON.parse(bS(e,"utf8"))}catch(t){throw t instanceof SyntaxError?new Error(`Invalid JSON in ${e} \u2014 fix or remove the file`,{cause:t}):t}}s(Xe,"readJson");function zS(e,t){let n=Cu(t.collectorUrl),r={...e,schema_version:e?.schema_version??n.schema_version};return t.collectorUrl!==void 0?r.collector_url=t.collectorUrl:r.collector_url=e?.collector_url??n.collector_url,delete r.repo_ingest_token,delete r.installation_id,r.mcp_servers??=n.mcp_servers,r}s(zS,"mergeManifestForInstall");function JS(e){return(e.schema_version??at)===at&&e.collector_url===void 0&&(e.mcp_servers?.length??0)===0&&e.platform_agent_id===void 0&&e.capture_hook_input===void 0&&e.debug===void 0&&e.repo_ingest_token===void 0}s(JS,"isDefaultSharedManifest");function Du(e,t){let n=z(e,pr),r=Xe(n),o=zS(r,t);return t.collectorUrl!==void 0||ft(n)||!JS(o)?(dt(n,o),{manifestPath:n,wrote:!0}):{manifestPath:void 0,wrote:!1}}s(Du,"upsertSharedManifest");function ys(e){if(e===null||typeof e!="object")return!1;let t=e,n=String(t.CLAUDE_CODE_ENABLE_TELEMETRY??"").toLowerCase();return n==="1"||n==="true"?!0:Object.keys(t).some(r=>r.startsWith("OTEL_"))}s(ys,"envHasOtel");function YS(e){if(ys(process.env))return!0;let t=Ye();return[...qo(),z(t,".claude","settings.json"),z(t,".claude","remote-settings.json"),z(e,".claude","settings.json"),z(e,".claude","settings.local.json")].some(r=>{try{let o=Xe(r);return o?ys(o.env):!1}catch{return!1}})}s(YS,"claudeOtelEnabled");function XS(e){try{let t=Xe(z(e,".claude","settings.json"));return t?ys(t.env):!1}catch{return!1}}s(XS,"projectClaudeOtelEnabled");function Fu(e){return Array.isArray(e)?e:[]}s(Fu,"asMatcherGroups");function Ur(e){let t=[],n=s(r=>!!r&&typeof r=="object"&&Uu(r.command),"isOwnedHook");for(let r of Fu(e)){if(!r||typeof r!="object"){t.push(r);continue}let o=Array.isArray(r.hooks)?r.hooks:[],i=o.filter(a=>!n(a));if(!(i.length===0&&o.some(n))){if(i.length!==o.length){t.push({...r,hooks:i});continue}t.push(r)}}return t}s(Ur,"stripEvAiMatcherGroups");function $u(e,t){return[...Ur(e),...t]}s($u,"mergeMatcherHookEvents");function bs(e){return Array.isArray(e)?e.filter(t=>!t||typeof t!="object"?!0:!Uu(t.command)):[]}s(bs,"stripEvAiCursorHooks");function qS(e,t){return[...bs(e),{command:t}]}s(qS,"mergeCursorEventHooks");function ZS(e){return typeof e=="string"?[e]:e}s(ZS,"toCommandList");function QS(e){let t=s((n="")=>({hooks:ZS(e).map(r=>({type:"command",command:Lr(n,r)}))}),"commandHook");return{SessionStart:[t("SessionStart")],UserPromptExpansion:[t()],UserPromptSubmit:[t()],PreToolUse:[t()],PostToolUse:[t()],PostToolUseFailure:[t()],PermissionDenied:[t()],Stop:[t()],StopFailure:[t()],SessionEnd:[t()],SubagentStart:[t()],SubagentStop:[t()]}}s(QS,"desiredClaudeHookGroups");function eE(e){let t=typeof e=="string"?{command:e}:e,n=s((r="")=>({hooks:[{type:"command",command:Lr(r,t.command),...t.commandWindows===void 0?{}:{commandWindows:Lr(r,t.commandWindows)},statusMessage:pc}]}),"commandHook");return{SessionStart:[n("SessionStart")],UserPromptSubmit:[n()],PreToolUse:[n()],PostToolUse:[n()],Stop:[n()],SubagentStart:[n()],SubagentStop:[n()]}}s(eE,"desiredCodexHookGroups");var tE=["sessionStart","beforeSubmitPrompt","preToolUse","postToolUse","postToolUseFailure","beforeShellExecution","beforeReadFile","beforeMCPExecution","subagentStart","subagentStop","stop"],nE=["afterShellExecution","afterFileEdit"];function rE(e,t=nE){let n={...e};for(let r of t){if(!(r in n))continue;let o=bs(n[r]);o.length===0?delete n[r]:n[r]=o}return n}s(rE,"stripRetiredCursorEvAiEvents");function oE(e,t,n={}){let r=z(e,".claude/settings.json"),o=As(t,"claude"),i=Xe(r)??{};if(YS(e)&&!n.force){if(i.hooks&&typeof i.hooks=="object"){let l={...i.hooks};for(let p of Object.keys(l))l[p]=Ur(l[p]),Fu(l[p]).length===0&&delete l[p];Object.keys(l).length===0?delete i.hooks:i.hooks=l,dt(r,i)}return!1}let c=i.hooks&&typeof i.hooks=="object"?i.hooks:{},u=QS(o),f={...c};for(let[l,p]of Object.entries(u))f[l]=$u(c[l],p);return i.hooks=f,dt(r,i),!0}s(oE,"updateClaudeSettings");function sE(e,t){let n=z(e,".cursor/hooks.json"),r=As(t,"cursor"),o=Xe(n)??{},i=o.hooks&&typeof o.hooks=="object"?o.hooks:{},a=rE({...i});for(let c of tE)a[c]=qS(a[c],Lr(c,r));dt(n,{...o,version:typeof o.version=="number"?o.version:1,hooks:a})}s(sE,"updateCursorHooks");function iE(e,t){let n=z(e,".codex/hooks.json"),r=As(t,"codex"),o=Xe(n)??{},i=o.hooks&&typeof o.hooks=="object"?o.hooks:{},a=eE(r),c={...i};for(let[u,f]of Object.entries(a))c[u]=$u(i[u],f);dt(n,{...o,hooks:c})}s(iE,"updateCodexHooks");function aE(e){let t=z(e,".claude/settings.json"),n=Xe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1;for(let i of Object.keys(r)){let a=r[i],c=Ur(a);JSON.stringify(a)!==JSON.stringify(c)&&(o=!0),c.length===0?delete r[i]:r[i]=c}o&&(Object.keys(r).length===0?delete n.hooks:n.hooks=r,dt(t,n),R(`Removed ev-ai hooks from ${t}`))}s(aE,"stripEvAiFromClaudeSettings");function cE(e){let t=z(e,".cursor/hooks.json"),n=Xe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,i=0;for(let a of Object.keys(r)){let c=r[a],u=bs(c);JSON.stringify(c)!==JSON.stringify(u)&&(o=!0),u.length===0?delete r[a]:(r[a]=u,i+=u.length)}if(o){if(i===0&&Object.keys(r).length===0&&Object.keys(n).filter(c=>c!=="hooks"&&c!=="version").length===0){Mr(t,{force:!0}),R(`Removed ${t}`);return}dt(t,{...n,hooks:r}),R(`Removed ev-ai hooks from ${t}`)}}s(cE,"stripEvAiFromCursorHooks");function uE(e){let t=z(e,".codex/hooks.json"),n=Xe(t);if(!n?.hooks||typeof n.hooks!="object")return;let r={...n.hooks},o=!1,i=0;for(let a of Object.keys(r)){let c=r[a],u=Ur(c);JSON.stringify(c)!==JSON.stringify(u)&&(o=!0),u.length===0?delete r[a]:(r[a]=u,i+=u.length)}if(o){if(i===0&&Object.keys(r).length===0&&Object.keys(n).filter(c=>c!=="hooks").length===0){Mr(t,{force:!0}),R(`Removed ${t}`);return}dt(t,{...n,hooks:r}),R(`Removed ev-ai hooks from ${t}`)}}s(uE,"stripEvAiFromCodexHooks");function ks(e=process.platform,t=process.arch,n={}){if(e==="win32")throw new Error("Windows install is not supported yet. Use macOS/Linux, or wait for phase-2 native commands.");(n.requireBinaryArch??!0)&&Au(e,t)}s(ks,"assertInstallSupported");async function ju(e={}){let t=NS(e);e.collectorUrl=t;let n=e.skipClaude===!0,r=e.skipCursor===!0,o=e.skipCodex===!0;if(n&&r&&o)throw new Error("at least one runner must be wired; refuse --no-claude --no-cursor --no-codex together");let i=e.delivery??wu();ks(process.platform,process.arch,{requireBinaryArch:i==="binary"});let a=e.cwd??process.cwd(),c=await We(a),{command:u,hookPath:f,strategy:l}=VS(c,Ye(),i),{installationId:p,storePath:d}=await vr(c,{overrideId:e.installationId}),{manifestPath:m,wrote:g}=Du(c,e),h=[];return n?R("Skipped Claude hook \u2014 --no-claude"):oE(c,u,{force:e.force})?(h.push("Claude"),e.force&&XS(c)&&R("Forced Claude hook despite project native OTEL \u2014 expect duplicate session/tool events")):R("Skipped Claude hook \u2014 native OTEL telemetry already enabled (avoids duplicate events); pass --force to wire anyway"),r?R("Skipped Cursor hook \u2014 --no-cursor"):(sE(c,u),h.push("Cursor")),o?R("Skipped Codex hook \u2014 --no-codex"):(iE(c,u),h.push("Codex")),R(`Installed hook (${l}) at ${f}`),R(`Installation identity ${p} at ${d}`),g&&m?R(`Shared manifest written to ${m}`):R("Using package default collector config (no shared manifest file needed)"),R(h.length>0?`Wired ${h.join(", ")} hooks in ${c} (commands include --runner)`:`No runner hooks wired in ${c} (Claude skipped by OTEL; Cursor/Codex excluded via flags)`),l==="npx"?R("Hook commands use npx and may be committed; teammates need Node on PATH only (no install step, no env vars when collector_url is in the shared manifest)."):l==="project_binary"?R("Hook commands are git-root-relative and may be committed; each collaborator runs install once to populate .ev-ai/agent-hook/ (gitignored)."):l==="dev_mjs"&&R("Hook commands use node + monorepo packages/agent-hook/dist/hook.mjs (local delivery; rebuild with yarn workspace @ev-ai/agent-hook build)."),g&&m&&e.collectorUrl&&R("Shared manifest includes collector_url \u2014 commit it with hook configs so teammates post without env vars."),{gitRoot:c,hookPath:f,manifestPath:m,installationStorePath:d,strategy:l}}s(ju,"installAgentHook");async function Bu(e=process.cwd()){ks(process.platform,process.arch,{requireBinaryArch:!0});let t=await We(e),{projectPath:n,globalPath:r}=BS(t);R(`Refreshed ${r}`),R(`Refreshed ${n}`),R("Hook configs and shared manifest left unchanged")}s(Bu,"updateAgentHook");async function Ku(e={}){let t=wS(e);e.collectorUrl=t,ks(process.platform,process.arch,{requireBinaryArch:!1});let n=e.cwd??process.cwd(),r=await We(n),{manifestPath:o,wrote:i}=Du(r,e);if(t!==void 0&&(!o||!i))throw new Error("configure failed to write shared collector manifest");return i&&o?R(`Wrote ${o}`):t===void 0&&R("No --url given and no shared manifest yet \u2014 pass --url <\u2026/{orgToken}/hook> to write collector destination."),R("Manifest only \u2014 enable ev-ai marketplace plugins. Do not also run file-wiring install for the same events."),{gitRoot:r,manifestPath:o}}s(Ku,"configureAgentHook");function Gu(e){for(let t of[()=>aE(e),()=>cE(e),()=>uE(e)])try{t()}catch(n){let r=n instanceof Error?n.message:String(n);R(`WARN: strip skipped a hook file: ${r}`)}}s(Gu,"stripFileWiredEvAiHooks");async function Wu(e=process.cwd()){let t=await We(e);return Gu(t),R("Stripped ev-ai file-wired hooks; shared collector manifest left in place."),R("Next: enable ev-ai marketplace plugins, then restart runners."),{gitRoot:t}}s(Wu,"migrateToPlugin");async function Vu(e=process.cwd()){let t=await We(e);Gu(t);for(let n of mr){let r=z(t,n);if(ft(r))try{Mr(r,{force:!0}),R(`Removed ${r}`)}catch(o){let i=o instanceof Error?o.message:String(o);R(`WARN: uninstall could not remove ${r}: ${i}`)}}}s(Vu,"uninstallAgentHook");import{existsSync as DR,mkdirSync as FR,readdirSync as $R,readFileSync as jR,unlinkSync as Yl,writeFileSync as BR}from"node:fs";import{homedir as Xl}from"node:os";import{join as Fs}from"node:path";import{existsSync as yE}from"node:fs";import{existsSync as lE}from"node:fs";import{homedir as Ju}from"node:os";import{join as fE}from"node:path";function Yu(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}s(Yu,"hookParsableSettings");var dE={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 zu(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}s(zu,"concatOptional");function pE(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:zu(n.mcpJson,t.mcpJson),mcpToml:zu(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}s(pE,"layoutForScope");function Xu(e){return Object.fromEntries(Object.entries(dE).map(([t,n])=>[t,pE(n,n[e])]))}s(Xu,"layoutsForScope");var Xt=Xu("homeOnly"),mt=Xu("projectOnly");function mE(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}s(mE,"layoutRelativePaths");function gE(e,t){return mE(e).some(n=>lE(fE(t,n)))}s(gE,"layoutHasAnyEntry");function qu(e,t){for(let n of e)if(gE(n,t))return!0;return!1}s(qu,"anyLayoutHasAnyEntry");function pt(e){return[...new Set(e)]}s(pt,"uniqueRels");function gt(e){let t=[],n=[],r=[],o=[],i=[],a=[],c=[];for(let u of e){t.push(...u.skillRoots);for(let f of u.dirs)f.kind==="SUBAGENT"?n.push(f.dir):f.kind==="COMMAND"?r.push(f.dir):o.push(f.dir);i.push(...u.memory.flat()),a.push(...u.settings),c.push(...u.mcpJson??[],...u.mcpToml??[])}return{skills:pt(t),subagents:pt(n),commands:pt(r),rules:pt(o),memory:pt(i),settings:pt(a),mcp:pt(c)}}s(gt,"userScopePathsFromLayouts");function _E(e,t=Ju(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...Ar(o.managed,n,t));return pt(r)}s(_E,"managedSettingsFromLayouts");var _t=gt(Object.values(Xt));function Zu(e=Ju(),t=process.platform){return _E(Object.values(Xt),e,t)}s(Zu,"userScopeManagedSettings");import{existsSync as hE}from"node:fs";import{resolve as xs}from"node:path";function ke(e){return xs(e).replaceAll("\\","/").replace(/\/$/,"")}s(ke,"posixAbs");function Pt(e,t){let n=new Set(t),r=[];for(let o of e)n.delete(o)&&r.push(o);for(let o of[...n].sort())r.push(o);return r}s(Pt,"uniqueOrderedRoots");function Dr(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(Dr,"preferMarkerDirRoots");var SE=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function In(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!SE.test(t)?null:t}s(In,"sanitizeComponentRelativePath");function qt(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let i=ke(o);n.has(i)||(n.add(i),r.push(i))}return r}s(qt,"projectAnchors");function EE(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}s(EE,"isInside");function He(e,t,n,r=hE){for(let o of e)for(let i of t){let a=ke(xs(o,i)),c=xs(o,i,n).replaceAll("\\","/");if(EE(a,c)&&r(c))return c}return null}s(He,"firstExistingUnderRoots");var el=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,tl=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,RE=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,Qu=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"]),CE=/^[a-z][a-z0-9-]{1,63}$/,AE=[".cursor/skills",".claude/skills",".agents/skills"],bE=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],kE=Pt(AE,gt(Object.values(mt)).skills),xE=Pt(bE,gt(Object.values(Xt)).skills),OE=new Set(["read","read_file","view"]),IE=new Set(["bash","shell","zsh"]);function Os(e){let t=e.replace(/\\/g,"/");return el.exec(t)?.[1]??null}s(Os,"skillIdFromSkillMdPath");function TE(e){let t=e.replace(/\\/g,"/"),r=tl.exec(t)?.[1];return r?r.toLowerCase():null}s(TE,"skillIdFromCodexCommandPath");function PE(e){return Os(e)??TE(e)}s(PE,"skillIdFromReferencedPath");function wE(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(wE,"pathFromToolInputRecord");function Fr(e){return typeof e=="string"?Fr(Te(e,null)):!e||typeof e!="object"?null:wE(e)}s(Fr,"pathFromToolInput");function nl(e){if(typeof e=="string")return nl(Te(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}s(nl,"commandFromToolInput");function Is(e){let t=nl(e.tool_input);if(t)return t;let n=Ct(e.command);return n.length>0?n:null}s(Is,"commandFromHookInput");function NE(e){let t=e.replace(/\\/g,"/"),n=el.exec(t);if(n?.[1])return n[1];let o=tl.exec(t)?.[1];return o?o.toLowerCase():null}s(NE,"skillIdFromShellCommand");function vE(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}s(vE,"toolNameFromHookInput");function Ts(e){let t=Fr(e.tool_input)??Ct(e.file_path);return t.length>0?t:null}s(Ts,"filePathFromHookInput");function Tn(e,t,n){let r=vE(e).toLowerCase();if(OE.has(r)){let o=Ts(e);return o?t(o):null}if(IE.has(r)){let o=Is(e);return o?n(o):null}return null}s(Tn,"nameFromReadOrShellHookInput");function rl(e){return Tn(e,PE,NE)}s(rl,"skillNameFromReadHookInput");function LE(e){let t=new Set,n=[];for(let r of e.matchAll(RE)){let o=r[1]?.toLowerCase();!o||t.has(o)||ME(o)||(t.add(o),n.push(o))}return n}s(LE,"extractSlashSkillNames");function ME(e){let t=e.split("/")[0];return Qu.has(e)||t!==void 0&&Qu.has(t)}s(ME,"isDeniedSlashId");function ol(e){let t=e.skillId.toLowerCase();if(!CE.test(t))return null;let n=e.exists??yE,r=`${t}/SKILL.md`,o=He(qt(e.launchCwd,e.gitRoot),kE,r,n);return o!==null?o:e.home?He([ke(e.home)],xE,r,n):null}s(ol,"resolveSkillMdPath");function HE(e){return Ct(e.prompt)}s(HE,"promptFromHookInput");function sl(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=HE(e);return n?LE(n):[]}s(sl,"skillNamesFromHookInput");var Ms=ot(St(),1);import{existsSync as uR}from"node:fs";var Nt={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function wn(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}s(wn,"normalizePathSlug");function cR(e){if(!e)return"";let t=En(e).replace(/\.git$/i,""),n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return wn(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return wn(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?wn(o[1]):wn(t)}s(cR,"normalizeGitRemoteToSlug");async function Vr(e=process.cwd()){let t=await Ie("git",["rev-parse","--is-inside-work-tree"],2e3,{cwd:e});if(!t.ok||t.stdout!=="true")return null;let[n,r,o,i]=await Promise.all([Ie("git",["remote","get-url","origin"],2e3,{cwd:e}),Ie("git",["branch","--show-current"],2e3,{cwd:e}),Ie("git",["rev-parse","HEAD"],2e3,{cwd:e}),Ie("git",["status","--porcelain"],2e3,{cwd:e})]);return{remote:n.ok?En(n.stdout):null,branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:i.ok?i.stdout.length>0:null}}s(Vr,"gitSnapshot");async function Pl(e,t,n,r=process.cwd(),o,i,a){if(t)return t;let c=Nt[n];if(!c)return"";let u=ru(n,e.scope_path,a);if(i){let g=fu(i,u);if(g)return g}let f=o??await Vr(r),l=f?.remote?cR(f.remote):"";if(l||(l=wn(process.env.GITHUB_REPOSITORY??"")),!l)return"";let p=e.scope_path??"",d=p?`${p}/`:"",m=`${l}:${d}${c}`;return i&&du(i,u,m),m}s(Pl,"derivePlatformAgentId");var lR=[".cursor/rules",".claude/rules",".codex/rules"],fR=gt(Object.values(mt)).rules;function dR(e){return Pt(Dr(e?Nt[e]:void 0,lR),fR)}s(dR,"ruleRootsForRunner");var pR=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function wl(e){let t=In(e.relativePath);if(!t)return null;let n=e.exists??uR,r=qt(e.launchCwd,e.gitRoot),o=dR(e.runnerPlatform),i=He(r,o,t,n);if(i!==null)return i;if(!t.includes("/")){let a=He(r,["."],t,n);if(a!==null)return a}return e.home?He([ke(e.home)],o,t,n):null}s(wl,"resolveRuleMdPath");function mR(e){let t=e.replace(/\\/g,"/"),r=pR.exec(t)?.[1];return r?(0,Ms.nativeKeyForRulePath)(r):null}s(mR,"ruleNameFromShellCommand");function Nl(e){return Tn(e,Ms.nativeKeyForRulePath,mR)}s(Nl,"ruleNameFromReadHookInput");function vl(e){return e.replace(/\.(mdc|md|rules)$/i,"")}s(vl,"stripRuleExtension");function Ll(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=In(a);!c||n.has(c)||(n.add(c),r.push(c))}return r}s(Ll,"ruleAttachmentPathsFromHookInput");var Hs=ot(St(),1);import{existsSync as gR}from"node:fs";var _R=[".cursor/commands",".claude/commands",".codex/prompts"],hR=gt(Object.values(mt)).commands;function SR(e){return Pt(Dr(e?Nt[e]:void 0,_R),hR)}s(SR,"commandRootsForRunner");var ER=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function Ml(e){let t=In(e.commandId);if(!t)return null;let n=e.exists??gR,r=`${t}.md`,o=SR(e.runnerPlatform),i=He(qt(e.launchCwd,e.gitRoot),o,r,n);return i!==null?i:e.home?He([ke(e.home)],o,r,n):null}s(Ml,"resolveCommandMdPath");function yR(e){let t=e.replace(/\\/g,"/"),r=ER.exec(t)?.[1];return r?(0,Hs.nativeKeyForCommandPath)(r):null}s(yR,"commandNameFromShellCommand");function Hl(e){return Tn(e,Hs.nativeKeyForCommandPath,yR)}s(Hl,"commandNameFromReadHookInput");var zr=ot(St(),1);function Ul(e,t){if($(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}s(Ul,"cursorShapedPayload");function RR(){return!!(D("CURSOR_VERSION")??D("CURSOR_PROJECT_DIR"))}s(RR,"isCursorHostEnv");function Dl(e,t,n){return e!=="claude"&&e!=="codex"?!1:Ul(t,n)?!0:RR()}s(Dl,"shouldSuppressForeignRunnerOnCursorHost");var CR=new Set(["sessionstart","sessionend","stop","stopfailure","pretooluse","posttooluse","posttoolusefailure","permissiondenied","subagentstart","subagentstop","userpromptexpansion","userpromptsubmit"]);function en(e,t,n,r){return Ul(e,t)?"cursor":gr(r)?r:gr(n)?n:$(e,"turn_id")?"codex":$(e,"session_id")||CR.has(t.toLowerCase())?"claude":"unknown"}s(en,"detectRunnerPlatform");function Jr(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}s(Jr,"isInProcessEvent");function AR(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(AR,"mapRunnerEventToInternal");function Fl(e){let t=e.toLowerCase();return t==="userpromptsubmit"||t==="beforesubmitprompt"}s(Fl,"isPromptSubmitRunnerEvent");function $l(e,t){return e.toLowerCase()==="userpromptsubmit"&&t==="claude"}s($l,"suppressesSlashIds");function jl(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}s(jl,"toolSuccessFromRunnerEvent");function tn(e){return $(e,"session_id")||$(e,"conversation_id")}s(tn,"sessionIdFromHookInput");function Us(e){return $(e,"prompt.id")||$(e,"prompt_id")||$(e,"generation_id")||$(e,"turn_id")}s(Us,"turnIdFromHookInput");function Ds(e){return $(e,"hook_event_name")||$(e,"event")}s(Ds,"runnerEventFromHookInput");function Bl(e,t,n){let r=tn(e),o=Us(e),i=Ds(e),a=$(e,"source"),c=en(e,i,t,n);return{sessionId:r,turnId:o,runnerEvent:i,hookSource:a,runnerPlatform:c}}s(Bl,"normalizeHookFields");var bR=["session_start","session_end","tool_invoked","skill_invoked"];function kR(e){return bR.includes(e)}s(kR,"isKnownInternalEvent");function Yr(e,t){return e&&kR(e)?e:AR(t.toLowerCase())}s(Yr,"resolveInternalEvent");var xR={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function Xr(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}s(Xr,"isMcpShapedToolName");function Kl(e,t=""){let n=$(e,"tool_name")||$(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!Xr(n)&&(n=`MCP:${n}`):n=xR[r]??null;let o=e.tool_input,a=(o&&typeof o=="object"?Ct(o.skill)||Ct(o.skill_name):"")||$(e,"skill_name")||null,c=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;a??=rl(c);let u=Nl(c),f=Hl(c);return{toolName:n,skillName:a,ruleName:u,commandName:f}}s(Kl,"extractToolNames");var OR=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function Gl(e){for(let t of["subagent_type","agent_type"]){let n=$(e,t);if(n&&OR.test(n))return n}return null}s(Gl,"extractSubagentType");function Wl(e){let t=Ve(e,"duration_ms");if(typeof t=="number")return t;let n=Ve(e,"duration");return typeof n=="number"?n:null}s(Wl,"extractDurationMs");var IR="error",TR="interrupted",PR="permission_denied",wR=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function Nn(e){return wR.test(e)?e:null}s(Nn,"categoricalValue");function NR(e){for(let t of["failure_type","error_type"]){let n=Nn($(e,t));if(n)return n}return null}s(NR,"structuredFailureClass");function Vl(e,t){return Ve(e,"is_interrupt")===!0?TR:t.toLowerCase()==="permissiondenied"?PR:NR(e)??IR}s(Vl,"extractFailureClass");function zl(e,t){let n=null;for(let r of e)r&&t(r)&&(n===null||r.length>n.length)&&(n=r);return n}s(zl,"longestDeclaredServer");function vR(e,t){return zl(t,n=>e===n||e.startsWith(`${n}_`)||e.startsWith(`${n}-`))}s(vR,"matchDeclaredMcpServer");function LR(e,t){return zl(t,n=>(0,zr.mcpServerNameMatchesToolSegment)(n,e))}s(LR,"matchDeclaredMcpServerSegment");function MR(e,t){let n=null,r=0;for(let i of t)if(i)for(let a of(0,zr.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:LR(o[1],t)??o[1],mcpTool:o[2]}}s(MR,"parseClaudeMcpNames");function HR(e,t){if(/^mcp__/i.test(e))return MR(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:vR(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}s(HR,"parseMcpNamesFromToolName");function UR(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}s(UR,"stripEncodedMcpServerPrefix");function Jl(e,t=[],n=""){let r=e?HR(e,t):{mcpServer:null,mcpTool:null},o=Nn(n.trim());if(!o)return r;let i=r.mcpTool;return!i&&e&&!Xr(e)&&(i=e),i&&(i=UR(i,o)),{mcpServer:o,mcpTool:i}}s(Jl,"extractMcpNames");var ql=3e4,KR="claims",GR=!0,WR=100,VR=new Set(["sessionstart","sessionend","stopfailure"]),zR=["tool_name","tool","command","file_path","url"];function JR(e=Xl()){return Fs(Re(e),KR)}s(JR,"eventClaimDir");function Zl(e,t){try{let n=jR(e,"utf8").split(`
|
|
32
|
+
`,1)[0]??"";return t-Number(n.trim())}catch{return Number.NaN}}s(Zl,"claimAgeMs");function YR(e){let t=[];for(let n of zR){let r=$(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":yn(t.join("\0"))}s(YR,"callFingerprintFromHookInput");function XR(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=VR.has(n);if(!c&&!u)return;let f=e.runnerPlatform.trim()||"unknown";return yn(`${f}|${t}|${n}|${r}|${o}|${a}|${i}`)}s(XR,"eventClaimKey");function qR(e,t=Date.now()){let n;try{n=$R(e)}catch{return}let r=0;for(let o of n){if(r>=WR)break;r+=1;let i=Fs(e,o),a=Zl(i,t);if(!(!Number.isFinite(a)||a<ql))try{Yl(i)}catch{}}}s(qR,"pruneStaleEventClaims");function ZR(e,t,n=Date.now()){let r=Fs(t,e);try{if(DR(r)){let o=Zl(r,n);if(Number.isFinite(o)&&o>=0&&o<ql)return!1;try{Yl(r)}catch(i){if(!(i instanceof Error&&"code"in i&&i.code==="ENOENT"))return H("event_claim_steal",i),!0}}}catch{}try{FR(t,{recursive:!0}),BR(r,`${n}
|
|
33
|
+
`,{encoding:"utf8",flag:"wx"})}catch(o){if(hn(o))return!1;let i=o instanceof Error?o.message:String(o);return R(`WARN: event claim failed open: ${i}`),H("event_claim",o),!0}return qR(t,n),!0}s(ZR,"tryClaimHookEvent");function QR(e,t,n){let r=tn(e),o=Us(e),i=$(e,"tool_use_id"),a=$(e,"subagent_id")||$(e,"agent_id"),c=en(e,t,void 0,n),u=YR(e);return{runnerPlatform:c,sessionId:r,runnerEvent:t,turnId:o,toolUseId:i,subagentId:a,callFingerprint:u}}s(QR,"identityFromHookInput");function Ql(e,t,n,r=Xl(),o=Date.now()){if(!GR)return!0;let i=XR(QR(e,t,n));if(!i)return!0;let a=ZR(i,JR(r),o);return!a&&D("EV_AI_HOOK_DEBUG")&&R(`DEBUG: duplicate hook event suppressed (claim ${i.slice(0,8)}\u2026)`),a}s(Ql,"claimHookEvent");import{mkdirSync as eC,readFileSync as $s,statSync as rf,unlinkSync as of,writeFileSync as js}from"node:fs";import{homedir as sf}from"node:os";function af(e){return e==="session_start"||e==="session_end"}s(af,"isCapExemptEvent");var qr=new Set,ef=!1;function Bs(e=sf()){return wa(e)}s(Bs,"hookSlotDir");function Ks(e,t=sf(),n=process.platform){if(e!==void 0)return e>0?e:sr(n);let r=Z(At(t),{});return tc(r)??sr(n)}s(Ks,"maxConcurrentHookProcesses");function vn(e){return cr(e.pid,e.acquiredAtMs)}s(vn,"slotContent");function cf(e){try{let t=rf(e);return t.isFile()&&t.size<=Fo?$s(e,"utf8"):void 0}catch{return}}s(cf,"readSlotText");function Gs(e,t=Bs()){if(!e)return;let n=ar(t,e.index),r={path:n,pid:process.pid,acquiredAtMs:e.acquiredAtMs},o=cf(n);if(o===vn(r))return Zr(r);if(o===cr(process.ppid,e.acquiredAtMs))try{return js(n,vn(r),{encoding:"utf8",mode:384}),Zr(r)}catch{return}}s(Gs,"adoptHookSlot");function uf(e,t){if(e.path){qr.delete(e);try{cf(e.path)===vn(e)&&js(e.path,cr(t,e.acquiredAtMs),{encoding:"utf8",mode:384})}catch{}}}s(uf,"handOffHookSlot");function lf(e,t=Date.now()){let n,r;try{let o=rf(e);if(!o.isFile())return!1;r=o.mtimeMs,n=o.size<=Fo?$s(e,"utf8"):""}catch{return!1}return va(n,r,t)}s(lf,"isSlotHeld");function ff(e,t=Bs(),n=Date.now){for(let r=0;r<e;r+=1)if(!lf(ar(t,r),n()))return!0;return e<=0}s(ff,"hasFreeHookSlot");function df(e){return{pid:process.pid,acquiredAtMs:e}}s(df,"noopSlot");function tf(e,t){let n=e instanceof Error?e.message:String(e);return R(`WARN: hook process slot failed open: ${n}`),H("slot",e),df(t)}s(tf,"failOpen");function Zr(e){return qr.add(e),ef||(ef=!0,process.once("exit",()=>{for(let t of[...qr])Qr(t)})),e}s(Zr,"hold");function nf(e){try{return js(e.path,vn(e),{encoding:"utf8",flag:"wx",mode:384}),!0}catch(t){if(hn(t))return!1;throw t}}s(nf,"tryCreateSlot");function pf(e,t=Bs(),n=Date.now){if(e<=0)return df(n());try{eC(t,{recursive:!0})}catch(i){return tf(i,n())}let r,o=0;for(let i=0;i<e;i+=1)try{let a={path:ar(t,i),pid:process.pid,acquiredAtMs:n()};if(nf(a))return Zr(a);if(lf(a.path,n())){o+=1;continue}try{of(a.path)}catch(c){if(!Bt(c))throw c}if(a.acquiredAtMs=n(),nf(a))return Zr(a);o+=1}catch(a){r??=a}return r!==void 0&&o>0&&H("slot",r),r===void 0||o>0?null:tf(r,n())}s(pf,"tryAcquireHookSlot");function Qr(e,t=Date.now()){if(qr.delete(e),!(!e.path||t-e.acquiredAtMs>=ir-Sn))try{$s(e.path,"utf8")===vn(e)&&of(e.path)}catch{}}s(Qr,"releaseHookSlot");function Ws(e){D("EV_AI_HOOK_DEBUG")&&R(`DEBUG: hook process cap reached (${e}/${e}); event dropped`)}s(Ws,"logHookCapReached");import{closeSync as tC,writeSync as nC}from"node:fs";function mf(e=process.env){let t=e[Uo];if(delete e[Uo],t===void 0)return;let n=Number.parseInt(t,10);if(!(!Number.isInteger(n)||n<3)){try{nC(n,Ra)}catch{}try{tC(n)}catch{}}}s(mf,"signalLauncherReady");function Vs(e=process.env){let t=e[_a];if(t)return{launcherVersion:t,hookSource:e[ha]??"",fallbackReason:e[Sa],launcherScope:e[Ea]}}s(Vs,"readLauncherContext");function gf(e,t){return(e?bt(e):void 0)===t}s(gf,"launcherScopeMatch");import{readFileSync as rC,statSync as oC}from"node:fs";import{homedir as sC}from"node:os";import{join as iC}from"node:path";var aC="perf-prev.json",cC=512,uC=1440*60*1e3,lC=12e4,fC=50,Ln={},_f=!1;function Js(e){return Math.round(e*10)/10}s(Js,"round1");function De(e,t){if(!kn())return t();let n=performance.now();return t().finally(()=>{Ln[e]=Js(performance.now()-n)})}s(De,"span");function dC(){for(let e of Object.keys(Ln))delete Ln[e]}s(dC,"clearSpans");function Sf(){if(!kn())return;let e=Lc();e&&(process.env[ns]=e)}s(Sf,"handOffHookTimings");function hf(e,t){if(!e)return;let n=t-e.origin;return n>=-fC&&n<=lC?e:void 0}s(hf,"trusted");function pC(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(pC,"isPrevPost");function Ef(e=sC()){return iC(Re(e),aC)}s(Ef,"perfPrevPath");function mC(e,t){if(!_f){_f=!0;try{let n=Ef(t);if(oC(n).size>cC)return;let r=JSON.parse(rC(n,"utf8"));return!pC(r)||e-r.at>uC?void 0:{at:r.at,post_ms:r.post_ms}}catch{return}}}s(mC,"takePrevPost");function Ys(e,t){if(!kn())return;let n={at:Date.now(),post_ms:Math.max(0,Math.round(e))};try{le(Ef(t),JSON.stringify(n))}catch{}}s(Ys,"recordPostDuration");function zs(e,t,n,r,o=n.marks){let i=Math.max(0,n.origin-r);e[t]=Js(i);for(let[a,c]of Object.entries(o))e[a]=Js(i+c)}s(zs,"addProcess");function yf(e,t=process.env,n,r=!1){let o=r?yc():void 0;if(!kn())return o?{sys:o}:void 0;let i=Nc(),a="w0"in i.marks?"w":"h",c=a==="w"?hf(rs(t[ns]),i.origin):void 0,u=hf(rs(t[Pc]),(c??i).origin),f=u?"l":c?"h":a,l=(u??c??i).origin,p={};u&&zs(p,"l",u,l),c&&zs(p,"h",c,l),zs(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(Ln).length>0&&(d.spans={...Ln},dC());let m=mC(Date.now(),n);return m&&(d.prev=m),o&&(d.sys=o),d}s(yf,"buildPerf");import{realpathSync as lI}from"node:fs";import{homedir as fI}from"node:os";var W=ot(St(),1);import{existsSync as gC,readFileSync as _C}from"node:fs";import{homedir as Rf}from"node:os";import{join as hC}from"node:path";var SC="cloud-cache.json",EC=1440*60*1e3,yC=900*1e3;function RC(e=Rf()){return hC(Re(e),SC)}s(RC,"cloudCachePath");function CC(e){if(!gC(e))return;let t=Te(_C(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(CC,"readCloudCache");function AC(e,t){try{le(e,`${JSON.stringify(t)}
|
|
34
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);R(`WARN: cloud cache write failed open: ${r}`),H("cloud_cache",n)}}s(AC,"writeCloudCache");function bC(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?yC:EC;return n-e.probed_at<r}s(bC,"isCacheValid");async function kC(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(kC,"probeAws");async function xC(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(xC,"probeGcp");async function OC(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(OC,"probeAzure");async function IC(e){let t=await Promise.allSettled([kC(e),xC(e),OC(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}s(IC,"runCloudProbes");async function Cf(e,t){if(e==="interactive")return null;let n=t?.home??Rf(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),i=RC(n),a=CC(i);if(bC(a,e,o))return a.result;let c=await IC(r);return AC(i,{context:e,probed_at:o,result:c}),c}s(Cf,"probeCloud");var xf=ot(St(),1);import{existsSync as bf}from"node:fs";import{homedir as kf}from"node:os";import{join as Mn,resolve as Xs,sep as Af}from"node:path";function eo(e,t,n){if(!bf(e))return;let r=Z(e,{});for(let[o,i]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:i})}s(eo,"readMcpServers");function TC(e,t,n){if(!bf(e))return;let r=Z(e,{}),o=Xs(t),i=null;for(let c of Object.keys(r.projects??{})){let u=Xs(c);(o===u||o.startsWith(u.endsWith(Af)?u:u+Af))&&(i===null||u.length>Xs(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(TC,"readClaudeProjectMcpServers");function Of(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"?(eo(Mn(r,".claude.json"),{source:"claude_json_user"},o),TC(Mn(r,".claude.json"),t,o)):n==="cursor"&&eo(Mn(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),eo(Mn(t,".mcp.json"),{source:"mcp_json"},o),eo(Mn(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}s(Of,"collectMcpServers");async function qs(e,t=process.cwd(),n="claude",r=kf()){return[...Of(e,t,n,r).values()].map(o=>o.declared)}s(qs,"mcpDeclared");function If(e,t,n=process.cwd(),r="claude",o=kf()){let i=Of(t,n,r,o),a=i.get(e);if(a!==void 0)return a.config??null;for(let[c,u]of i)if((0,xf.mcpServerNameMatchesToolSegment)(c,e))return u.config??null;return null}s(If,"mcpServerConfig");var PC=["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"],wC=["CURSOR_PROJECT_DIR"],NC=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function vC(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)NC.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}s(vC,"stripUrlUserinfo");function Tf(e=process.env){let t=PC.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:vC(e[r]??"")}:{name:r,present:!1}),n=wC.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}s(Tf,"readEnvVars");import{homedir as aA}from"node:os";import{homedir as Nf}from"node:os";import{join as Pf}from"node:path";var LC="https://api.openai.com/auth";function nn(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(nn,"trimString");function vf(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}s(vf,"asJsonObject");function MC(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 vf(r)}catch{return null}}s(MC,"decodeJwtPayload");function wf(e,t,n){return nn(e[n])??nn(t?.[n])}s(wf,"claim");function HC(e=process.env,t=Nf()){let n=nn(e.CODEX_HOME)??Pf(t,".codex");return Pf(n,"auth.json")}s(HC,"codexAuthPath");function Lf(e=process.env,t=Nf()){let n=Z(HC(e,t),{}),r=nn(n.auth_mode);if(r!==null&&r!=="chatgpt"||r===null&&nn(n.OPENAI_API_KEY))return null;let o=nn(n.tokens?.id_token);if(!o)return null;let i=MC(o);if(!i)return null;let a=vf(i[LC]),c=wf(i,a,"name"),u=wf(i,a,"email");return!u||fe(c,u)?null:{git_user_name:null,git_user_email:null,platform_login:u,identity_source:"codex_oauth"}}s(Lf,"readCodexOperatorIdentity");import{homedir as ro}from"node:os";import{join as Qe}from"node:path";import{join as UC}from"node:path";var DC="cursor-ide-identity.json",FC=840*60*1e3;function Hf(e){return UC(Re(e),DC)}s(Hf,"cursorIdeIdentityCachePath");function Mf(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Mf,"nullableString");function Uf(e){let t=Z(e,{}),n=t.read_at_ms,r=t.db_path;if(!(typeof n!="number"||!Number.isFinite(n)||typeof r!="string"))return{read_at_ms:n,db_path:r,email:Mf(t.email),auth_id:Mf(t.auth_id)}}s(Uf,"readCursorIdeIdentityCache");function Df(e,t,n){if(e?.db_path!==t)return!1;let r=n-e.read_at_ms;return r>=0&&r<FC}s(Df,"isCursorIdeIdentityCacheFresh");function Ff(e,t){try{le(e,`${JSON.stringify(t)}
|
|
35
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);R(`WARN: cursor IDE identity cache write failed open: ${r}`),H("cursor_identity_cache",n)}}s(Ff,"writeCursorIdeIdentityCache");import{execFileSync as $C}from"node:child_process";import{existsSync as jC}from"node:fs";import{createRequire as BC}from"node:module";import{pathToFileURL as KC}from"node:url";var jf=BC(import.meta.url),to=`
|
|
34
36
|
SELECT key, value
|
|
35
37
|
FROM ItemTable
|
|
36
38
|
WHERE key LIKE 'cursorAuth/%'
|
|
37
39
|
AND key NOT LIKE '%Token%'
|
|
38
40
|
AND key NOT LIKE '%token%'
|
|
39
41
|
ORDER BY key
|
|
40
|
-
`.trim(),
|
|
41
|
-
`)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let
|
|
42
|
-
`);return
|
|
43
|
-
`)){let o=r.trim();if(!o)continue;let s=o.indexOf(" ");if(s<=0)continue;let i=o.slice(0,s).toLowerCase(),a=o.slice(s+1).trim();a&&(i==="user.name"?t=a:i==="user.email"&&(n=a))}return{git_user_name:t,git_user_email:n,platform_login:null}}async function xR(e,t=ne){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return kR(n)}function OR(e=process.env){let t=j(e.GIT_AUTHOR_NAME),n=j(e.GIT_AUTHOR_EMAIL);if(t||n)return{git_user_name:t,git_user_email:n,platform_login:null,identity_source:"git_env"};let r=j(e.GIT_COMMITTER_NAME),o=j(e.GIT_COMMITTER_EMAIL);if(r||o)return{git_user_name:r,git_user_email:o,platform_login:null,identity_source:"git_env"};let s=j(e.EMAIL);return s?{git_user_name:null,git_user_email:s,platform_login:null,identity_source:"git_env"}:null}function Ye(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}function IR(e=process.env){let t=j(e.EV_AI_HOOK_OPERATOR_EMAIL),n=j(e.EV_AI_HOOK_OPERATOR_LOGIN),r=Ye(j(e.EV_AI_HOOK_OPERATOR_NAME),t,"configured",t??n);if(r)return r;let o=j(e.GITHUB_ACTOR)??j(e.GITHUB_TRIGGERING_ACTOR)??j(e.GITHUB_USER),s=Ye(o,null,"github",o);if(s)return s;let i=j(e.GITLAB_USER_LOGIN),a=j(e.GITLAB_USER_EMAIL),c=Ye(j(e.GITLAB_USER_NAME)??i,a,"gitlab",a??i);if(c)return c;let l=j(e.BUILD_REQUESTEDFOREMAIL),u=Ye(j(e.BUILD_REQUESTEDFOR),l,"azure_devops",l??j(e.BUILD_REQUESTEDFORID));if(u)return u;let d=j(e.BUILDKITE_BUILD_CREATOR_EMAIL),f=Ye(j(e.BUILDKITE_BUILD_CREATOR),d,"buildkite",d);if(f)return f;let p=j(e.BUILD_USER_EMAIL)??j(e.CHANGE_AUTHOR_EMAIL),g=Ye(j(e.BUILD_USER)??j(e.CHANGE_AUTHOR),p,"jenkins",p??j(e.BUILD_USER_ID));if(g)return g;let S=j(e.CIRCLE_USERNAME),A=Ye(S,null,"circleci",S);if(A)return A;let b=j(e.CODEBUILD_INITIATOR),I=Ye(b,null,"codebuild",b);if(I)return I;let P=j(e.DRONE_COMMIT_AUTHOR_EMAIL),T=j(e.DRONE_COMMIT_AUTHOR),O=Ye(T??j(e.DRONE_COMMIT_AUTHOR_NAME),P,"drone",P??T);if(O)return O;if(of(e.CLAUDE_CODE_REMOTE)||of(e.CURSOR_AGENT)){let K=j(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:K&&!me(null,K)?K:null,identity_source:"cloud"}}return null}function ks(e){return!!((e.git_user_name??e.git_user_email)&&!me(e.git_user_name,e.git_user_email))}function j(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function of(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function TR(e,t,n){return e==="claude"?$l(t):e==="cursor"?nf(t,n):e==="codex"?Vl(n,t):null}async function xs(e,t=ne,n=process.env,r={}){let o=await xR(e,t),s=OR(n),i=ks(o)?o:s&&ks(s)?s:null,a=TR(r.runnerPlatform,r.home??AR(),n);if(a)return{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:a.platform_login,identity_source:a.identity_source};let c=IR(n);return c?.platform_login?{git_user_name:i?.git_user_name??null,git_user_email:i?.git_user_email??null,platform_login:c.platform_login,identity_source:c.identity_source}:i?{...i,platform_login:null,identity_source:ks(o)?"git_config":"git_env"}:c||(o.git_user_name||o.git_user_email?{...o,identity_source:"git_config"}:s||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}async function Os(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??ne,s=e.env??process.env,i=await xs(t,o,s,{runnerPlatform:e.runnerPlatform,home:e.home}),a=bR(i.git_user_name,i.git_user_email,i.identity_source,i.platform_login),l=(n?Mo(n):void 0)?.operator_identity_hash;if(!(r||l!==void 0&&l!==a||!l))return{commit:()=>{}};let p=n;return{operator:i,commit:()=>{p&&cc(p,a,Wn())}}}function Is(e){return e?!Mo(e)?.operator_identity_hash:!0}function sf(e){return!0}import{existsSync as Vb,readFileSync as Wb}from"node:fs";import{homedir as Pp}from"node:os";import{join as Kt,resolve as zb}from"node:path";import{basename as Ub,join as Bt}from"node:path";import{dirname as _f,resolve as Br}from"node:path";import{existsSync as PR}from"node:fs";import{homedir as uf}from"node:os";import{relative as lf,resolve as ve,sep as ft}from"node:path";var wR=["session_id","conversation_id","turn_id","generation_id","prompt.id","prompt_id","hook_event_name","event","source","status","stop_reason","reason","tool_name","tool","tool_use_id","skill_name","command_name","expansion_type","command_source","permission_mode","model","model_id","agent_id","agent_type","subagent_id","subagent_type","subagent_model","is_parallel_worker","effort","effort.level","duration_ms","duration","sandbox","failure_type","is_interrupt"],NR=["prompt","tool_input","tool_response","last_assistant_message","command"],vR=new Set;function MR(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return vR}}function vs(e){let t=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Zt.has(t.toLowerCase()):e?.collect_prompt===!0}function Fr(e,t){let n=ff(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=M("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?Zt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}function ff(e){return M("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||Ho(process.argv,e.debug===!0)||M("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}function LR(e){let t={};for(let n of wR){let r=$e(e,n);r!==void 0&&(t[n]=r)}return t}function $r(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=ve(e),r=ve(t),o=lf(r,n);return!o||o==="."?".":o.startsWith(`..${ft}`)||o===".."||ve(r,o)!==n?null:o.split(ft).join("/")}function df(e,t){let n=lf(ve(t),ve(e)).split(ft).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}function pf(e){return typeof e!="string"||e.length===0?null:ve(e).split(ft).join("/")}function HR(){let e=M("CURSOR_PROJECT_DIR");if(!e)return null;let t=ve(e);return PR(t)?t.split(ft).join("/"):null}function Ps(e,t){return $r(e,t)!==null}function UR(e,t){let n=ve(t??uf(),".cursor").split(ft).join("/");return Ps(e,n)}function DR(e,t,n){return t!==null&&Ps(e,t)?!0:t!==null&&UR(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&Ps(e,n.gitRoot)?!0:t===null}function mf(e,t){let n=pf(e.cwd);if(n!==null)return n;let r=ve(process.cwd()).split(ft).join("/"),o=HR();return DR(r,o,t)?r:o??r}function Ms(e,t={}){return mf(e,t)}function Ls(e,t=uf()){let n=ve(t).split(ft).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function af(e,t,n){let r=pf(n.launchCwd)??mf(t,n);e.cwd=Ls(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?$r(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}var gf="\u2026[truncated]\u2026",ws=Buffer.byteLength(gf,"utf8"),FR=8;function Sn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function cf(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}function $R(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(n.length-t).toString("utf8")}function jR(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=ws)return cf(e,t);let r=t-ws,o=Math.ceil(r/2),s=Math.floor(r/2);return`${cf(e,o)}${gf}${$R(e,s)}`}function Ns(e,t,n){if(typeof e=="string"){n.push({path:t,value:e,bytes:Buffer.byteLength(e,"utf8")});return}if(Array.isArray(e)){e.forEach((r,o)=>{Ns(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||Ns(o,[...t,r],n)}function BR(e,t,n){let r=e;for(let s=0;s<t.length-1;s++){let i=t[s];if(i===void 0)return;r=(Array.isArray(r),r[i])}let o=t[t.length-1];if(!(o===void 0||r===null||typeof r!="object")){if(Array.isArray(r)){r[o]=n;return}r[o]=n}}var KR=256;function GR(e,t,n){let r=n,o=Math.max(n,e[0]?.bytes??n);for(;r<o;){let s=Math.ceil((r+o)/2),i=0;for(let a of e)a.bytes>s&&(i+=a.bytes-s);i>=t?r=s:o=s-1}return r}function VR(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let s=Sn(e);if(s<=t)return;let i=[];Ns(e,[],i),i.sort((u,d)=>d.bytes-u.bytes);let a=i.filter(u=>u.bytes>n);if(a.length===0)return;let c=GR(a,s-t,n),l=Math.max(n,Math.min(c,r-1));if(l>=r)return;r=l;for(let u of a)u.bytes>r&&BR(e,u.path,jR(u.value,r))}}function WR(e,t){let n=Math.max(0,t-KR),r=Object.keys(e).filter(s=>!s.startsWith("_")).map(s=>({key:s,bytes:Sn(e[s])})).sort((s,i)=>i.bytes-s.bytes),o=[];for(let{key:s}of r){if(Sn(e)<=n)break;delete e[s],o.push(s)}o.length>0&&(e._dropped_keys=o.slice(0,10))}function Ts(e,t){let n=Sn(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,VR(r,t,ws+FR),Sn(r)>t&&WR(r,t),r}function zR(e,t,n){if(!(n.promptCapture??vs()))return;let r=MR(n.runnerEvent);for(let o of NR){if(r.has(o))continue;let s=t[o];s!==void 0&&(e[o]=s)}}function jr(e,t,n={}){let r=ff(t);if(r==="full"){let s={...e};return delete s.cwd,delete s.transcript_path,af(s,e,n),Ts(s,Oo)}let o=LR(e);return af(o,e,n),r==="content"?(zR(o,e,n),Ts(o,Oo)):Ts(o,Ma)}function JR(e){return typeof e=="string"&&e.length>0}function Hs(e){let t=Br(e.home),n=Br(e.launchCwd),r=e.gitRoot?Br(e.gitRoot):null,o=new Set,s=[],i=null;e.inGitRepo&&JR(e.remote)&&r!==null&&r!==t&&(i=r,o.add(r)),n!==t&&!o.has(n)&&(s.push({scope:"cwd",dir:n}),o.add(n)),i!==null&&s.push({scope:"repo",dir:i});let a=null,c=r!==null&&$r(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&c){let l=_f(r);for(;;){let u=Br(l);if(u===t)break;let d=_f(u);if(d===u)break;if(e.hasProjectSpec(u)){s.push({scope:"parent",dir:u}),a=df(u,n);break}l=d}}return{anchors:s,parentRel:a}}import{existsSync as hf,readdirSync as YR,realpathSync as XR}from"node:fs";import{basename as qR,dirname as ZR,relative as QR,resolve as eC,sep as tC}from"node:path";var Us=400,Kr=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??et}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=eC(t).split(tC).join("/");return Ls(r,this.home)}let n=QR(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${Z(ZR(t))}/${qR(t)}`:n}claimFile(t){try{let n=XR(t);return this.seenRealpaths.has(n)?!1:(this.seenRealpaths.add(n),!0)}catch{return this.seenRealpaths.has(t)?!1:(this.seenRealpaths.add(t),!0)}}get atGlobalCap(){return this.truncated||this.components.length>=this.maxEntries}get pluginBudgetSpent(){return this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0}readEntries(t){if(!hf(t))return[];try{return YR(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(hf(t))return q(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),s=t-(this.pluginExpandRemaining??0);return{result:o,expanded:s}}finally{this.pluginExpandRemaining=r}}};import{existsSync as ti,readFileSync as bA,statSync as kA}from"node:fs";import{basename as Nd,join as Rt,relative as ni}from"node:path";var Id=Qe(Od());var CA=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],Td=CA.map(e=>Id.default.matcher(e,{dot:!0}));function AA(e){return e===""?!1:Td.some(t=>t(`${e}/`))}function Pd(e,t){if(t==="")return!1;if(e==="")return AA(t);let n=e.replace(/\/+$/,"");return Td.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}var ri=100*1024,xA=4;function OA(e){return e.length<=ri?e:`${e.slice(0,ri-1)}\u2026`}function IA(e){try{let t=bA(e),n=t.toString("utf8");return{hash:Z(t),length:t.length,text:OA(n)}}catch{return null}}var wd={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function TA(e){return e in wd?wd[e]:"UNSPECIFIED"}function $t(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=IA(t.absolutePath);if(!n)return!1;let r=t.name??Nd(t.absolutePath).replace(/\.(md|mdc|toml)$/i,""),o={kind:t.kind,name:r,path:e.componentPath(t.absolutePath),text:n.text,content_hash:n.hash,content_length:n.length,origin:t.origin,enabled:t.enabled},s=TA(t.kind);return s&&(o.trigger=s),t.attributes&&(o.attributes=t.attributes),e.push(o)}function PA(e,t,n){let r=ni(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?Nd(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function Ct(e,t){let{dir:n,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c}=t;oi(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:s,nested:i,extensions:a,skipDirs:c})}function oi(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u}=t;if(!(o>xA))for(let d of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(d.isDirectory()&&Pd(n.replace(/\\/g,"/"),ni(n,Rt(r,d.name)).replace(/\\/g,"/"))||d.isDirectory()&&u?.includes(Rt(r,d.name)))continue;if(c){if(!d.isDirectory())continue;let g=Rt(r,d.name,c);if(ti(g)){let S=ni(n,Rt(r,d.name)).replace(/\\/g,"/");$t(e,{absolutePath:g,kind:s,origin:i,enabled:a,name:S||d.name});continue}oi(e,{walkRoot:n,currentDir:Rt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(d.isDirectory()){oi(e,{walkRoot:n,currentDir:Rt(r,d.name),depth:o+1,kind:s,origin:i,enabled:a,nested:c,extensions:l,skipDirs:u});continue}if(!d.isFile()||!l)continue;let f=d.name.toLowerCase();if(!l.some(g=>f.endsWith(g)))continue;let p=Rt(r,d.name);$t(e,{absolutePath:p,kind:s,origin:i,enabled:a,name:PA(n,p,!0)})}}function vd(e){for(let t of e)if(ti(t))try{if(kA(t).size>0)return t}catch{continue}return e.find(t=>ti(t))}import{existsSync as ib,readFileSync as ab}from"node:fs";var Xr=Qe(lt(),1);var wA="<omitted>",NA=["package_name","package_spec","package_version","package_version_source"],Md=100,Ld=120,qr=[{raw:"tools",attr:"tools"},{raw:"autoApprove",attr:"auto_approve"},{raw:"auto_approve",attr:"auto_approve"},{raw:"alwaysAllow",attr:"always_allow"},{raw:"always_allow",attr:"always_allow"},{raw:"enabledTools",attr:"enabled_tools"},{raw:"enabled_tools",attr:"enabled_tools"},{raw:"disabledTools",attr:"disabled_tools"},{raw:"disabled_tools",attr:"disabled_tools"}],Hd=new Set(qr.map(e=>e.attr)),vA=["enabled","disabled"],MA=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],LA=new Set(["type","command","url","args","env","envVars","headers",...vA,...MA,...qr.map(e=>e.raw)]),HA=new Set(["transport","command_or_url","args","env_var_names","headers_present","auth","bearer_token_env_var","default_tools_approval_mode","env_http_header_names",...NA,...Hd,...[...Hd].map(e=>`${e}_truncated`)]);function Ud(e,t){for(let n of t)LA.has(n)||HA.has(n)||(e[n]=wA)}var UA=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,DA=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,FA=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,$A=/^bearer(?:\s+|$)/i;function Zr(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Dd(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function si(e){if(Array.isArray(e)){let n=[];for(let r of e){if(typeof r!="string"||r.length===0)continue;let o=r.split("=",1)[0]?.trim();o&&n.push(o)}return n}let t=Zr(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function At(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function jA(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,Xr.launchContainsCredentials)({kind:"url",url:e})||(0,Xr.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=kn([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,Xr.launchContainsCredentials)({kind:"url",url:r}):!0)}function Fd(e,t,n){jA(t,n)&&(e.launch_had_credentials=!0)}function BA(e){return FA.test(e)||$A.test(e)?"<redacted>":e.includes("://")?At(e):e}function $d(e){if(/^https?:\/\//i.test(e))return At(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${$d(e.slice(t+1))}`:BA(e)}function KA(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return UA.test(t)||DA.test(t)}function kn(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(KA(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push($d(r))}return t}function GA(e){let t=Dd(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Ld?r.slice(0,Ld):r))].sort();if(n.length!==0)return n.length>Md?{names:n.slice(0,Md),truncated:!0}:{names:n,truncated:!1}}function VA(e){let t=Zr(e);if(!t)return{headers:[],envVars:[]};let n=[],r=[];for(let[o,s]of Object.entries(t))o.length>0&&n.push(o),typeof s=="string"&&s.length>0&&r.push(s);return{headers:n,envVars:r}}function jd(e,t){let n=new Set;for(let{raw:r,attr:o}of qr){if(n.has(o)||!(r in t))continue;let s=t[r];if(o==="auto_approve"&&typeof s=="boolean"){e.auto_approve=s,n.add(o);continue}let i=GA(s);i&&(e[o]=i.names,i.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function Bd(e,t){let n=Zr(e),r={transport:t};if(!n)return r;Ud(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,s=typeof n.url=="string"?n.url:void 0,i=typeof n.serverUrl=="string"?n.serverUrl:void 0,a=o??s??i,c=Dd(n.args);a&&(r.command_or_url=At(a));let l=kn(c);l.length>0&&(r.args=l),Fd(r,a,c);let u=VA(n.env_http_headers),d=[...new Set([...si(n.env),...si(n.envVars),...si(n.env_vars),...u.envVars,...typeof n.bearer_token_env_var=="string"&&n.bearer_token_env_var.length>0?[n.bearer_token_env_var]:[]])].sort();d.length>0&&(r.env_var_names=d),u.headers.length>0&&(r.env_http_header_names=[...new Set(u.headers)].sort());for(let S of["headers","http_headers","env_http_headers"])if(n[S]!==void 0&&n[S]!==null){r.headers_present=!0;break}let f=typeof n.auth=="string"?n.auth:void 0;f&&(r.auth=f);let p=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;p&&(r.bearer_token_env_var=p);let g=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return g&&(r.default_tools_approval_mode=g),jd(r,n),r}function Kd(e){let t=Zr(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function ci(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return Z(JSON.stringify({name:e,attributes:r,enabled:n}))}function jt(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function bn(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*\\[([^\\]]*)\\]`,"m").exec(e);return n?.[1]?[...n[1].matchAll(/"([^"]*)"|'([^']*)'/g)].map(r=>r[1]??r[2]??"").filter(r=>r.length>0):[]}function ai(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function ii(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=jt(n[1]);return r.length>0?r:void 0}function WA(e,t){let n=[],r=i=>{for(let a of i.split(/[,\n]/)){let c=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(a);c?.[1]&&n.push([c[1],jt(c[2]??"")])}},o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let s=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
|
|
44
|
-
${e}`);return
|
|
45
|
-
`)){let
|
|
46
|
-
`)){let
|
|
47
|
-
${e}`);if(
|
|
48
|
-
`)){let
|
|
49
|
-
`);return eb("sha512").update(t).digest("hex").slice(0,16)}function rb(e){let t=process.platform==="win32"?xn(M("LOCALAPPDATA")??e,"npm-cache"):xn(e,".npm"),n=M("npm_config_cache")??M("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}function Xd(e){return typeof e=="string"&&e.length>0&&e.length<=He.PACKAGE_FIELD_MAX?e:null}function ob(e,t,n){let r=nb(e);for(let o of rb(n)){let s=xn(o,"_npx",r),i=q(xn(s,"node_modules",...t.split("/"),"package.json"),{}),a=Xd(i.version);if(a!==null)return a;let c=q(xn(s,"package-lock.json"),{}),l=Xd(c.packages?.[`node_modules/${t}`]?.version);if(l!==null)return l}return null}function sb(e){return e.length<=He.PACKAGE_FIELD_MAX?e:`${e.slice(0,He.PACKAGE_FIELD_MAX-1)}\u2026`}function ui(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,He.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let s=(0,He.packageNameFromSpec)(o);return s===null?null:{package_name:s,package_spec:sb(o),...tb(o,ob(r,s,n))}}function qd(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=Qr(e.trim());return n===void 0?null:ui(n,r,t)}function eo(e,t){if(!e||typeof e!="object"||Array.isArray(e))return null;let n=e,r=Array.isArray(n.args)?n.args.filter(o=>typeof o=="string"):[];return ui(typeof n.command=="string"?n.command:null,r,t)}function Zd(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:ui(jt(n[1]??""),bn(e,"args"),t)}function cb(e){if(!e||typeof e!="object"||Array.isArray(e))return"unknown";let t=e;return typeof t.type=="string"&&t.type.length>0?t.type:typeof t.url=="string"?"http":typeof t.command=="string"?"stdio":"unknown"}function Qd(e,t,n){if(!e.claimFile(t))return;let o=e.readJson(t,{})?.mcpServers;if(!o||typeof o!="object")return;let s=e.componentPath(t);for(let[i,a]of Object.entries(o)){if(e.truncated)return;let c=cb(a),l=Bd(a,c);Object.assign(l,eo(a,e.home)??{});let u=Kd(a);e.push({kind:"MCP_SERVER",name:i,path:s,content_hash:ci(i,l,u),origin:n,enabled:u,attributes:l})}}function ep(e,t,n){if(!ib(t)||!e.claimFile(t))return;let r;try{r=ab(t,"utf8")}catch{return}let o=e.componentPath(t),s=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,i;for(;(i=s.exec(r))!==null;){if(e.truncated)return;let a=i[1]??i[2]??i[3];if(!a)continue;let c=r.slice(i.index+i[0].length),l=c.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),u=l===-1?c:c.slice(0,l),d="unknown";/^\s*url\s*=/m.test(u)?d="http":/^\s*command\s*=/m.test(u)&&(d="stdio");let f=Vd(u,d);Object.assign(f,Zd(u,e.home)??{});let p=Gd(u);e.push({kind:"MCP_SERVER",name:a,path:o,content_hash:ci(a,f,p),origin:n,enabled:p,attributes:f})}}import{existsSync as fb,readdirSync as db}from"node:fs";import{join as fe}from"node:path";function ub(e){if(e.prompt||e.type==="prompt")return"prompt";let t=e.command??e.bash??e.powershell??"";return/\bnpx\b/i.test(t)?"npx":/\.(sh|bash|zsh|js|mjs|cjs|ts|py)(\s|$|"|')/i.test(t)||/^(\.\/|~\/|\/|[A-Za-z]:[\\/])/.test(t.trim())?"script":"inline"}function lb(e){return Array.isArray(e.hooks)&&e.hooks.length>0?e.hooks:[{type:e.type,command:e.command,bash:e.bash,powershell:e.powershell,prompt:e.prompt}]}function li(e,t,n,r){let o=e.componentPath(t);for(let[s,i]of Object.entries(n))if(!(!Array.isArray(i)||e.truncated))for(let a of i){if(!a||typeof a!="object"||e.truncated)continue;let c=a;for(let l of lb(c)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??c.powershell??"",d=ub({type:l.type??c.type,command:l.command??c.command,bash:l.bash??c.bash,powershell:l.powershell??c.powershell,prompt:l.prompt??c.prompt}),f=typeof c.matcher=="string"?c.matcher:"",p=Z(u),g=f?`${s}:${f}:${d}:${p}`:`${s}:${d}:${p}`,S=`${s}|${f}|${d}|${u}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:Z(S),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:s,...f?{matcher:f}:{},action_kind:d,action_hash:p,...d!=="prompt"&&u.trim()?{command:Jd(u,e.home)}:{}}})}}}function fi(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||li(e,t,r.hooks,n)}var tp=50;function On(e,t,n,r){if(!fb(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(tp,()=>{Ct(e,{dir:fe(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Ct(e,{dir:fe(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Ct(e,{dir:fe(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});fi(e,fe(t,"hooks","hooks.json"),n),fi(e,fe(t,"hooks.json"),n);let i=e.components.length-o,a=s>=tp;return{componentCount:i,expandTruncated:a}}function In(e,t){e.push({kind:"PLUGIN",name:t.pluginKey,path:t.rowPath,content_hash:t.contentHash,origin:"user",enabled:t.enabled,attributes:{...t.marketplace?{marketplace:t.marketplace}:{},...t.version?{version:t.version}:{},scope:t.scope,component_count:t.componentCount,...t.expandTruncated?{expand_truncated:!0}:{}}})}function di(e){let t=e?.enabledPlugins;if(typeof t!="object"||t===null||Array.isArray(t))return{};let n={};for(let[r,o]of Object.entries(t))typeof o=="boolean"&&(n[r]=o);return n}function pb(e){let t=di(e.readJson(fe(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=tn(process.platform,e.home),o=e.readJson(n,{}),s={};if(o&&Object.keys(o).length>0)s=di(o);else for(let i of r)Object.assign(s,di(e.readJson(i,{})));return{...t,...s}}function np(e){let t=fe(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=pb(e),s=e.componentPath(t);for(let[i,a]of Object.entries(r)){if(e.truncated)return;let c=Array.isArray(a)?a:[a],l=c[0]??{},u=o[i]===!0,d=i.includes("@")?i.split("@").slice(1).join("@"):"",f=typeof l.version=="string"?l.version:"",p=typeof l.scope=="string"?l.scope:"user",g=`plugin:${i}`,S=0,A=!1;for(let b of c)if(typeof b.installPath=="string"&&b.installPath.length>0){let I=On(e,b.installPath,g,u);S+=I.componentCount,A=A||I.expandTruncated}In(e,{pluginKey:i,rowPath:s,enabled:u,scope:p,version:f||void 0,marketplace:d||void 0,componentCount:S,expandTruncated:A,contentHash:Z(`${i}|${f}|${p}|${u}|${S}`)})}}function mb(e){let t=e,n="";try{let r=db(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=fe(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),s=o[o.length-1];s&&(t=fe(e,s),n=s)}}catch{}return{installPath:t,version:n}}var gb=/^\d+$/;function _b(e){let t=e.filter(n=>!gb.test(n.pluginId));return t.length>0?t:e}function rp(e){let t=[{base:fe(e.home,".cursor/plugins/local"),scope:"local"},{base:fe(e.home,".cursor/plugins/cache"),scope:"cache"}];for(let{base:n,scope:r}of t)if(!e.truncated)for(let o of e.readEntries(n)){if(!o.isDirectory()||e.truncated)continue;if(r==="local"){let a=o.name,c=fe(n,o.name),l=`plugin:${a}`,{componentCount:u,expandTruncated:d}=On(e,c,l,!0);In(e,{pluginKey:a,rowPath:e.componentPath(c),enabled:!0,scope:"local",componentCount:u,expandTruncated:d,contentHash:Z(`${a}|local|${u}`)});continue}let s=o.name,i=[];for(let a of e.readEntries(fe(n,s))){if(!a.isDirectory())continue;let c=fe(n,s,a.name),{installPath:l,version:u}=mb(c);i.push({pluginId:a.name,installPath:l,version:u})}for(let a of _b(i)){if(e.truncated)break;let c=`${a.pluginId}@${s}`,l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=On(e,a.installPath,l,!0);In(e,{pluginKey:c,rowPath:e.componentPath(a.installPath),enabled:!0,scope:"cache",version:a.version||void 0,marketplace:s,componentCount:u,expandTruncated:d,contentHash:Z(`${c}|${a.version}|${u}`)})}}}import{existsSync as Eb}from"node:fs";var hb=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,pi="<path>",Sb=new RegExp(`${pi}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function to(e){let t=e.replace(hb,pi).replace(Sb,pi);return t.length>200?`${t.slice(0,200)}...`:t}var op=200,sp=200,mi=16*1024,ip=6,yb=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),Rb=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),Cb=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),Ab=new Set(["permissions"]),bb={claude:yb,cursor_sandbox:Rb,cursor_permissions:Cb,cursor_cli:Ab},kb=new Set(["allow","deny","ask"]);function dt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function no(e){return e.replace(/\\/g,"/")}function gi(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>gi(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${gi(t[r])}`).join(",")}}`}function xb(e){return Z(`${gi(e)}|settings1`)}function fp(e){let t=no(e);if(t.endsWith(".claude/settings.json")||t.endsWith(".claude/settings.local.json"))return"claude";if(t.endsWith(".cursor/sandbox.json"))return"cursor_sandbox";if(t.endsWith(".cursor/permissions.json"))return"cursor_permissions";if(t.endsWith(".cursor/cli-config.json")||t.endsWith(".cursor/cli.json"))return"cursor_cli"}function dp(e,t){if(e!=="claude")return{};let n=no(t);return n.endsWith("/.claude/remote-settings.json")?{profile:"claude",managedSource:"server"}:n.includes("/managed-settings.d/")&&n.endsWith(".json")?{profile:"claude",managedSource:"file_dropin"}:n.endsWith("/managed-settings.json")?{profile:"claude",managedSource:"file"}:{profile:"claude"}}function pp(e){let t=no(e).replace(/\/+$/,"");return t.length<=1?"":t}function mp(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}function Ob(e,t){let n=no(e);if(n==="~"||n.startsWith("~/"))return n;let r=pp(t);if(!r)return n;let o=n.slice(0,r.length);if(!(mp(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let i=n.slice(r.length);return i===""?"~":i.startsWith("/")?`~${i}`:n}var ap=new Map;function Ib(e){let t=ap.get(e);if(t!==void 0)return t;let n=pp(e),r=null;if(n){let o=n.split("/").map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,mp(e)?"gi":"g")}return ap.set(e,r),r}function Tb(e,t){let n=Ib(t);return n?e.replace(n,"~"):e}function cp(e,t){return e.length<=sp?e:(t.truncated=!0,e.slice(0,sp))}function gp(e,t){return e.length<=op?e:(t.truncated=!0,e.slice(0,op))}function re(e,t,n,r){if(typeof e=="string"){if(t==="path")return cp(Ob(e,n),r);let o=t==="rule"?to(e):e;return cp(Tb(o,n),r)}if(typeof e=="number"||typeof e=="boolean"||e===null)return typeof e=="number"&&!Number.isFinite(e)?void 0:e;if(Array.isArray(e)){let o=gp(e,r),s=[];for(let i of o){let a=re(i,t,n,r);a!==void 0&&s.push(a)}return s}if(dt(e)){let o={};for(let[s,i]of Object.entries(e)){let a=re(i,t,n,r);a!==void 0&&(o[s]=a)}return o}}function up(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i="plain";kb.has(o)?i="rule":o==="additionalDirectories"&&(i="path");let a=re(s,i,t,n);a!==void 0&&(r[o]=a)}return r}function Pb(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){if(o==="files"&&Array.isArray(s)){let a=gp(s,n);r[o]=a.map(c=>{if(!dt(c))return re(c,"plain",t,n);let l={};for(let[u,d]of Object.entries(c)){let p=re(d,u==="path"?"path":"plain",t,n);p!==void 0&&(l[u]=p)}return l});continue}let i=re(s,"plain",t,n);i!==void 0&&(r[o]=i)}return r}function wb(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let a=re(s,o==="allowUnixSockets"?"path":"plain",t,n);a!==void 0&&(r[o]=a)}return r}function Nb(e,t,n){if(!dt(e))return re(e,"plain",t,n);let r={};for(let[o,s]of Object.entries(e)){let i;o==="excludedCommands"?i=re(s,"rule",t,n):o==="filesystem"?i=re(s,"path",t,n):o==="network"?i=wb(s,t,n):o==="credentials"?i=Pb(s,t,n):i=re(s,"plain",t,n),i!==void 0&&(r[o]=i)}return r}function vb(e,t,n,r,o){return n==="claude"?e==="permissions"?up(t,r,o):e==="sandbox"?Nb(t,r,o):re(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?re(t,"path",r,o):re(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?re(t,"rule",r,o):re(t,"plain",r,o):e==="permissions"?up(t,r,o):re(t,"plain",r,o)}function Tn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function _i(e,t){return e?`${e}.${t}`:t}function hi(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let s=e[o];s!==null&&typeof s=="object"&&(t+1>=ip?(e.splice(o,1),r.add(n)):hi(s,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,s]of Object.entries(e))s!==null&&typeof s=="object"&&(t+1>=ip?(delete e[o],r.add(_i(n,o))):hi(s,t+1,_i(n,o),r))}function _p(e,t,n){if(Array.isArray(e)){e.length>0&&n.push({path:t,items:e,bytes:Tn(e)});return}if(!(e===null||typeof e!="object"))for(let[r,o]of Object.entries(e))_p(o,_i(t,r),n)}function Mb(e,t,n){let r=Tn(e);if(r<=mi)return;t.truncated=!0;let o=[];for(_p(e,"",o);r>mi;){let s;for(let c of o)c.items.length>0&&(!s||c.bytes>s.bytes)&&(s=c);if(!s)break;let i=s.items.pop(),a=Tn(i)+(s.items.length>0?1:0);s.bytes-=a,r-=a,n.add(s.path)}for(;Tn(e)>mi;){let s,i=-1;for(let[a,c]of Object.entries(e)){let l=Tn(c);l>i&&(s=a,i=l)}if(s===void 0)break;delete e[s],n.add(s)}}function Lb(e,t,n){let r=bb[t],o={truncated:!1},s={},i=[];for(let c of Object.keys(e)){if(!r.has(c)){i.push(c);continue}let l=vb(c,e[c],t,n,o);l!==void 0&&(s[c]=l)}i.sort();let a=new Set;return hi(s,1,"",a),a.size>0&&(o.truncated=!0),Mb(s,o,a),{settings:s,keys_omitted:i,truncated:o.truncated,trimmed_paths:[...a].sort()}}function lp(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:xb(t.attributes),attributes:t.attributes};e.push(n)}function Si(e,t,n,r){if(!e.claimFile(t)||!Eb(t))return;let o=_a(t);if(!o.ok||!dt(o.value)){if(r.profile){let l=!o.ok&&o.reason==="read"?"read_error":"parse_error",u={profile:r.profile,[l]:!0};r.managedSource&&(u.managed_source=r.managedSource),lp(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}return}let s=o.value,i=s.hooks;if(dt(i)&&li(e,t,i,n),!r.profile)return;let a=Lb(s,r.profile,e.home),c={profile:r.profile,settings:a.settings,keys_omitted:a.keys_omitted};a.truncated&&(c.truncated=!0),a.trimmed_paths.length>0&&(c.trimmed_paths=a.trimmed_paths),r.managedSource&&(c.managed_source=r.managedSource),lp(e,{kind:r.kind,absPath:t,origin:n,attributes:c})}import{existsSync as Hb}from"node:fs";import{join as Ue}from"node:path";var hp=".claude/skills/synced",Sp=".claude/plugins/synced";function Ep(e){return[Ue(e,hp),Ue(e,Sp)]}function ro(e){return typeof e=="string"&&e.length>0?e:void 0}function yp(e){let t=Ue(e.home,hp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ue(t,n.name),o=e.readJson(Ue(r,"manifest.json"),{}),s=new Map((o?.skills??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let a=Ue(r,i.name,"SKILL.md");if(!i.isDirectory()||!Hb(a))continue;let c=s.get(i.name),l=ro(c?.source),u=ro(c?.creatorType);$t(e,{absolutePath:a,kind:"SKILL",origin:"user",enabled:!0,name:i.name,attributes:{scope:"synced",...l?{source:l}:{},...u?{creator_type:u}:{}}})}}}function Rp(e){let t=Ue(e.home,Sp);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ue(t,n.name),o=e.readJson(Ue(r,"manifest.json"),{}),s=new Map((o?.plugins??[]).flatMap(i=>i.name?[[i.name,i]]:[]));for(let i of e.readEntries(r)){if(e.truncated)return;if(!i.isDirectory()||i.name.startsWith("."))continue;let a=s.get(i.name),c=ro(a?.marketplaceName),l=ro(a?.version),u=c?`${i.name}@${c}`:i.name,d=Ue(r,i.name),{componentCount:f,expandTruncated:p}=On(e,d,`plugin:${u}`,!0);In(e,{pluginKey:u,rowPath:e.componentPath(d),enabled:!0,scope:"synced",version:l,marketplace:c,componentCount:f,expandTruncated:p,contentHash:Z(`${u}|${l??""}|synced|${f}`)})}}}function Db(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:s}=t;for(let i of n.skillRoots)Ct(e,{dir:Bt(r,i),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:Ep(e.home)});for(let i of n.dirs)Ct(e,{dir:Bt(r,i.dir),kind:i.kind,origin:o,enabled:!0,extensions:i.extensions});for(let i of n.memory){let a=vd(i.map(c=>Bt(r,c)));a&&$t(e,{absolutePath:a,kind:"MEMORY",origin:o,enabled:!0,name:Ub(a)})}for(let i of Zc(n))Si(e,Bt(r,i),o,{kind:"SETTINGS",profile:fp(i)});for(let i of n.mcpJson??[])Qd(e,Bt(r,i),o);for(let i of n.mcpToml??[])ep(e,Bt(r,i),o);if(s){if(n.managed){for(let i of sr(n.managed,process.platform,e.home))if(i.toLowerCase().endsWith(".json")){let a=dp(n.managed,i);Si(e,i,o,{kind:"MANAGED_SETTINGS",...a})}}n.plugins==="claude"?(np(e),Rp(e),yp(e)):n.plugins==="cursor"&&rp(e)}}function Cp(e,t){try{let n=new Kr(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)Db(n,{layout:r,levelDir:t.levelDir,origin:t.origin,includeMachineWide:t.includeMachineWide});return{scopeRef:t.scopeRef,anchor:t.levelDir,components:n.components,truncated:n.truncated}}catch{return}}function Ei(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let c=Cp(t,{layouts:Object.values(vt),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:et,scopeRef:""});c&&(r.user=c)}let s=n.inGitRepo===!0,i=null,a=n.launchCwd;if(a!==void 0){let c=Object.values(it),l=Hs({launchCwd:a,gitRoot:n.gitRoot,inGitRepo:s,remote:n.remote,home:t,hasProjectSpec:u=>eu(c,u)});i=l.parentRel;for(let u of l.anchors){let d=bs(u.dir);if(o!==void 0&&!o(u.scope,d))continue;let f=Cp(t,{layouts:c,levelDir:u.dir,origin:u.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:Us,scopeRef:d});f&&(r[u.scope]=f)}r.parent||(i=null)}return{scopes:r,parentRel:i,cwdInGitRepo:s}}function yi(e,t,n={}){let r=n.truncated===!0,o=hn(e),s=new Set(e.map(u=>Re(u.path,u.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let a=[],c=t;for(let u of e){let d=Re(u.path,u.name);c[d]!==Dr(u)&&a.push(u)}let l=[];if(!r){for(let u of Object.keys(c))if(!s.has(u)){let d=rf(u);d&&l.push(d)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:a,removed:l,unchanged:a.length===0&&l.length===0}}var bp=2*1024*1024,Fb=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function Ri(e,t,n){let r=new Set(t.map(s=>Re(s.path,s.name))),o=[];for(let s of e)s.text!==void 0&&(n.has(s.content_hash)||r.has(Re(s.path,s.name))||o.push(s));return o}function Ci(e,t,n){let r=new Set(e);for(let s of t)r.add(s);let o=new Set(n.map(s=>s.content_hash));return[...r].filter(s=>o.has(s))}function Ap(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function kp(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function Ai(e,t=bp){let n=[],r=[];for(let u of e)Fb.has(u.kind)?n.push(u):r.push(u);r.sort((u,d)=>(u.text?.length??0)-(d.text?.length??0));let o=[...n,...r],s=[],i=2,a=0,c=0,l=[];for(let u of o){let d=s.length>0?1:0,f=Ap(u)+d;if(i+f<=t){s.push(u),i+=f,u.text!==void 0&&l.push(u.content_hash);continue}if(u.text!==void 0){let p=kp(u),g=Ap(p)+d;if(i+g<=t){s.push(p),i+=g,a+=1;continue}}c+=1}return{components:s,textDeferredCount:a,droppedCount:c,textHashesSent:l}}function bi(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:kp(n))}var $b=["user","cwd","repo","parent"];function ki(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,s=[];for(let T of $b){let O=t.scopes[T];if(!O)continue;let K=n(T,O.scopeRef),D=K.components,x=yi(O.components,D,{forceFull:D===void 0,truncated:O.truncated}),N=new Set(K.textHashes),H=Ri(O.components,x.upserts,N),m=bi([...x.upserts,...H],N);s.push({scope:T,walk:O,delta:x,outgoing:m,outgoingKeys:new Set(m.map(k=>Re(k.path,k.name))),deliveredTextHashes:N,cachedComponents:D})}let i=s.flatMap(T=>T.outgoing),a=Ai(i,o),c=new Set(a.components.map(T=>Re(T.path,T.name))),l=[],u=[],d=[],f=[],p=[],g=[],S=[];for(let T of s){let{scope:O,walk:K,delta:D}=T;g.push(...K.components),l.push(O);let x=a.components.filter(k=>T.outgoingKeys.has(Re(k.path,k.name))),N=[...T.outgoingKeys].some(k=>!c.has(k)),H=D.truncated||N;H?d.push(O):D.full&&u.push(O),f.push(...x),!D.full&&!H&&p.push(...D.removed);let m=D.full?{}:{...T.cachedComponents??{}};if(!H)for(let k of D.removed)delete m[Re(k.path,k.name)];for(let k of x)m[Re(k.path,k.name)]=Dr(k);S.push({scope:O,scopeRef:K.scopeRef,components:m,textHashes:Ci(T.deliveredTextHashes,x.filter(k=>k.text!==void 0).map(k=>k.content_hash),K.components),collectedAtMs:r,included:x.length>0||D.removed.length>0&&!H||D.full})}let A={user_spec_hash:hn(g),user_spec_count:g.length,user_spec_truncated:d.length>0};l.length>0&&(A.user_spec_scopes=l,A.user_spec_full_scopes=u,A.user_spec_truncated_scopes=d,A.user_spec_cwd_in_git_repo=t.cwdInGitRepo),u.length>0&&u.length===l.length&&(A.user_spec_full=!0),f.length>0&&(A.user_spec=f),p.length>0&&(A.user_spec_removed=p),a.textDeferredCount>0&&(A.user_spec_text_deferred=a.textDeferredCount);let b=t.scopes.cwd;b&&(A.user_spec_cwd_scope_ref=b.scopeRef);let I=t.scopes.repo;I&&(A.user_spec_repo_scope_ref=I.scopeRef);let P=t.scopes.parent;return P&&(A.user_spec_parent_scope_ref=P.scopeRef,t.parentRel&&(A.user_spec_parent_rel=t.parentRel)),{fields:A,scopes:S}}var oo={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function xi(e){return e==="cwd"||e==="repo"||e==="parent"}function Pn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Oi(e){return!Pn(e)||!Pn(e.components)||!Object.values(e.components).every(t=>typeof t=="string")||!Array.isArray(e.text_hashes)||!e.text_hashes.every(t=>typeof t=="string")?!1:typeof e.collected_at_ms=="number"&&Number.isFinite(e.collected_at_ms)}function xp(e){return jb(e)}function Op(e){return Bb(e)}function Ip(e){return Kb(e)}function jb(e){if(!Pn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function Bb(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Tp(e,t){if(!Pn(e))return;let n=e[t];return Oi(n)?n:void 0}function Kb(e){if(!Pn(e))return{};let t={};for(let[n,r]of Object.entries(e))Oi(r)&&(t[n]=r);return t}function Ii(e,t=20){let n=[];for(let[r,o]of Object.entries(e))Oi(o)&&n.push([r,o]);return n.sort((r,o)=>o[1].collected_at_ms-r[1].collected_at_ms),Object.fromEntries(n.slice(0,t))}var Jb=["allow","deny","ask"];function io(e){let t=q(e,{}),n=[];for(let r of Jb)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:to(o),mode:r});return{model:t.model??"",permissionKeys:n}}function Yb(e){let{serverManaged:t,fileBased:n}=tn(process.platform,e),r=io(t);if(r.model||r.permissionKeys.length>0)return r;let o="",s=[];for(let i of n){let a=io(i);a.model&&(o=a.model),s.push(...a.permissionKeys)}return{model:o,permissionKeys:s}}function Xb(e){let t=new Set,n=[];for(let r of e){let o=`${r.mode}\0${r.key}`;t.has(o)||(t.add(o),n.push(r))}return n}var qb=10,Zb="self-config-cache.json",wp=5;function Gt(){return M("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function Qb(){return M("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}var ek={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function tk(e,t=ne){let n=ek[e];if(!n||n.length===0)return null;let r=async o=>{let s=n[o];if(s===void 0)return null;let a=((await t(s,["--version"],2e3)).split(`
|
|
50
|
-
`)[0]??"").trim();return
|
|
51
|
-
`);return
|
|
52
|
-
`)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: self-config cache write failed open: ${r}`)}}function ik(e,t,n){if(t==="user")return{components:xp(e.user_spec_components),textHashes:Op(e.user_spec_text_hashes)};if(!xi(t))return{components:void 0,textHashes:[]};let r=Tp(e[oo[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}function ak(e,t,n,r){let o={...e,send_count:n};for(let s of Object.keys(t)){let i=t[s];i.entries!==void 0&&(o[s]=i.hash)}if(r){o.user_spec_layout_version=wp,r.home&&(o.user_spec_collected_at_ms=r.home.collectedAtMs,r.home.included&&(o.user_spec=r.hash,o.user_spec_components=r.home.components),o.user_spec_text_hashes=r.home.textHashes);for(let s of r.project){if(!xi(s.scope))continue;let i=oo[s.scope],a=Ip(o[i]),c=a[s.scopeRef];a[s.scopeRef]={components:s.included?s.components:c?.components??{},text_hashes:s.textHashes,collected_at_ms:s.collectedAtMs},o[i]=Ii(a)}}return o}async function Np(e,t=process.cwd(),n=Pp(),r={}){let o=e==="claude",s=r.gitRoot??t,i=await tk(e),a="",c=[];if(o){let H=Yb(n),m=io(Kt(n,".claude/settings.json")),k=io(Kt(t,".claude/settings.local.json"));a=H.model||k.model||m.model,c=Xb([...H.permissionKeys,...m.permissionKeys,...k.permissionKeys]).slice(0,200)}let l={present:!1,size:0},u=H=>{let m=[],k=!1;for(let U of H){let de=ha(Kt(n,U));if(m=m.concat(de.entries),k=k||de.truncated,m.length>=et){m=m.slice(0,et),k=!0;break}}return{entries:m,truncated:k}},d=nk(n),f=ok(d),p=f[e]??{},g=(p.send_count??0)+1,S=g>0&&g%qb===0,A=H=>S?void 0:p[H],b=u(ct.skills),I=u(ct.subagents),P=u(ct.commands),T=u(ct.rules),O={skills:so(b.entries,A("skills"),b.truncated),subagents:so(I.entries,A("subagents"),I.truncated),commands:so(P.entries,A("commands"),P.truncated),rules:so(T.entries,A("rules"),T.truncated)},K={runner_platform:e,config_scope:"user",cli_version:i,claude_version:o?i:null,model:o&&a||null,permission_keys:c,user_scope:{skills:O.skills,subagents:O.subagents,commands:O.commands,rules:O.rules,memory:Ti(n,ct.memory),settings:Ti(n,ct.settings,tu(n)),mcp:Ti(n,ct.mcp)},local_settings:o?Ro(Kt(t,".claude/settings.local.json")):l},D=null,x=r.nowMs??Date.now();if(!Gt()){let H=p.user_spec_layout_version!==wp,m=Ei(e,n,{launchCwd:Qb()?void 0:r.launchCwd,gitRoot:s,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(m.scopes).length>0){let k=ki({collected:m,cacheFor:(U,de)=>H?{components:void 0,textHashes:[]}:ik(p,U,de),nowMs:x});Object.assign(K,k.fields),D={hash:k.fields.user_spec_hash,home:k.scopes.find(U=>U.scope==="user")??null,project:k.scopes.filter(U=>U.scope!=="user")}}}let N=ak(p,O,g,D);return{config:K,commit:()=>{f[e]=N,sk(d,f)}}}import{homedir as Ok}from"node:os";import{join as Lp}from"node:path";function bt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{join as ao}from"node:path";function ck(e){return ao(e,".ev-ai","agent-hook","js","signed-v1")}function uk(e){return ao(ck(e),"scopes")}function vp(e,t){return ao(uk(e),t)}function Mp(e){return ao(e,"attempts")}function Pi(e){return String(e).padStart(10,"0")}var lk=/^(\d{10})$/,fk=/^(\d{10})\.done$/,dk=/^[0-9a-f]{128}$/,pk=64,Fp=["check_ms","download_ms","install_ms","total_ms"],mk=36e5;async function $p(e,t,n=!1){let r=Mp(t),o=await Yi(e,r),s=new Map,i=new Map,a=Hp(o,lk),c=Hp(o,fk),l=async f=>{let p=await Dp(e,Lp(r,gk(f)));return p&&s.set(f,{record:hk(p.value),mtimeMs:p.mtimeMs}),p!==void 0},u=async f=>{let p=Sk((await Dp(e,Lp(r,_k(f))))?.value);return p&&i.set(f,p),p!==void 0};if(!n)return await Promise.all([...a.map(l),...c.map(u)]),{claims:s,dones:i};await Promise.all([Up(a,l),Up(c,u)]);let d=wn(s);return d<wn(i)&&c.includes(d)&&await u(d),{claims:s,dones:i}}function Hp(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}async function Up(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}function wn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}function jp(e){if(e.record!=="empty"&&e.record.started_at){let t=Date.parse(e.record.started_at);if(Number.isFinite(t))return t}return e.mtimeMs}function Bp(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of Fp){let r=e[n];r!==void 0&&(t[n]=r)}return t}function gk(e){return Pi(e)}function _k(e){return`${Pi(e)}.done`}async function Dp(e,t){let n;try{n=await e.stat(t)}catch(o){if(Ot(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>go)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>go?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}function hk(e){if(!bt(e))return"empty";let t={};return typeof e.started_at=="string"&&(t.started_at=e.started_at),(e.owner==="bootstrap"||e.owner==="refresh")&&(t.owner=e.owner),e.resync===!0&&(t.resync=!0),t}function Sk(e){if(!bt(e))return;let t=e;if(typeof t.finished_at!="string"||typeof t.outcome!="string"||typeof t.interval_s!="number"||!Number.isFinite(t.interval_s))return;let n=yk(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...Ek(t)}}function Ek(e){let t={};typeof e.started_at=="string"&&Number.isFinite(Date.parse(e.started_at))&&(t.started_at=e.started_at);for(let n of Fp){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=mk&&(t[n]=r)}return t}function yk(e){if(!bt(e))return;let t=e;if(t.kind==="bundled")return t.why==="server"||t.why==="bootstrap_failed"?{kind:"bundled",why:t.why}:void 0;if(t.kind==="cached"&&typeof t.digest=="string"&&dk.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&Rk(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}function Rk(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==pk||t.toString("base64")!==e))return t.toString("hex")}function kk(e){return e==="bootstrap"?3e3:6e4}function xk(e,t){let n=wn(e.claims);if(n===0)return;let r=wn(e.dones),o=e.claims.get(n),s=e.dones.get(n);if(o&&!s){let a=jp(o),c=o.record==="empty"?void 0:o.record.owner,l=kk(c)+3e4;if(t-a>l)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:Kp(e.dones.get(r)?.selection)}}if(r===0)return;let i=e.dones.get(r);if(i)return{n:r,latest_claim:n,outcome:i.outcome,finished_at:i.finished_at,selection_version:Kp(i.selection),...Bp(i)}}async function Gp(e,t,n){try{let r=await $p(Xi(),vp(e,t),!0);return xk(r,n)}catch{return}}function Kp(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}function Ik(e=process.env){if(Object.values(Ua).some(n=>e[n]))return"plugin";let t=e.npm_lifecycle_script?.trim().split(/\s+/)[0]?.replace(/^["']|["']$/g,"");return e.npm_lifecycle_event==="npx"&&t===Ee?"npx":null}async function Vp(e=Ok()){let t=ms()?.launcherScope;if(!t)return{};let n=await Gp(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}function Vt(e,t,n){let r={installation_id:n.installationId};n.platformAgentId&&(r.platform_agent_id=n.platformAgentId),n.sessionId&&(r.session_id=n.sessionId),n.turnId&&(r.turn_id=n.turnId);let o={schema_version:nt,event:e,timestamp:Wn(),session_id:n.sessionId||null,turn_id:n.turnId||null,installation_id:n.installationId,platform:n.runnerPlatform,platform_agent_id:n.platformAgentId||null,runner_event:n.runnerEvent||null,agent_hook_version:Be,hook_delivery:Ik(),host_arch:process.arch,node_version:process.version,policy_version:null,policy_capabilities:[],...n.promptCaptureSource!==void 0?{prompt_capture_source:n.promptCaptureSource}:{},...n.telemetry!==void 0?{telemetry_source:n.telemetry.source}:{},correlation:r,payload:t},s=ms();return s&&(o.launcher_version=s.launcherVersion,o.hook_source=s.hookSource,o.hook_fallback_reason=s.fallbackReason??null,o.launcher_scope_match=hl(n.collectorUrl,s.launcherScope)),e==="session_start"&&(n.launcher_scope&&(o.launcher_scope=n.launcher_scope),n.launcher_attempt&&(o.launcher_attempt=n.launcher_attempt)),o}import{existsSync as Wp}from"node:fs";import{spawn as zp}from"node:child_process";import{fileURLToPath as Pk}from"node:url";import{gzipSync as Tk}from"node:zlib";function wi(e){return M("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<La?{body:e}:{body:Tk(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}function co(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}function Ni(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}var Nn="__post",vn="__work";async function wk(e,t,n={}){if(Gt())return e;let r=await xs(n.gitRoot??process.cwd(),ne,process.env,{runnerPlatform:t,home:n.home}),o=bt(e.self_config)?e.self_config:{};return{...e,self_config:{...o,runner_platform:typeof o.runner_platform=="string"?o.runner_platform:t,operator:r}}}function Nk(e,t){let n=bt(e.payload)?Object.keys(e.payload):[],r=e.correlation&&typeof e.correlation=="object"?Object.keys(e.correlation):[];return JSON.stringify({event:e.event,schema_version:e.schema_version,agent_hook_version:e.agent_hook_version,host_arch:e.host_arch,node_version:e.node_version,build_ms:e.build_ms,body_bytes:t,correlation_keys:r,payload_keys:n})}function Jp(e){switch(e){case"session_start":return wa;case"session_end":return Na;case"tool_invoked":case"skill_invoked":return xo;default:return xo}}function vk(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
|
|
53
|
-
|
|
54
|
-
`);if(
|
|
55
|
-
`,g=M("EV_AI_HOOK_DEBUG");g==="full"?E(`DEBUG envelope=${f}`):g==="1"&&E(`DEBUG summary=${Nk(u,Ni(p))}`);let S=process.argv.includes(vn),A=M("EV_AI_HOOK_SYNC")==="1";return xr(n.runnerEvent,n.runnerPlatform)||S||A?Hk(e,p,o):(await Uk(e,p,o),!1)}import{createReadStream as Dk}from"node:fs";import{stat as Fk}from"node:fs/promises";import{basename as $k,resolve as jk}from"node:path";import{createInterface as Bk}from"node:readline";var Kk=1024*1024;function Gk(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&$k(t).endsWith(".jsonl")}async function em(e){if(!e||!Gk(e))return null;try{let t=jk(e),n=await Fk(t);if(!n.isFile())return null;let r=Math.max(0,n.size-Kk),o=[],s=Bk({input:Dk(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let i of s)i.length!==0&&o.push(i);r>0&&o.length>0&&o.shift();for(let i=o.length-1;i>=0;i--){let a=o[i];if(a)try{let c=JSON.parse(a);if(c.type!=="assistant")continue;let l=c.message;if(!l||typeof l!="object")continue;let u=l.model;if(typeof u=="string"&&u.length>0)return u}catch{continue}}return null}catch{return null}}function lo(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:Fr(e.manifest.manifest,e.manifest.hookConfig),telemetry:rm(e)}}function rm(e){return Ec(e.manifest.localTelemetry,e.manifest.hookConfig)}function Ln(e,t){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{}}}function Mi(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:vs(e.manifest.hookConfig)}}async function om(e){let t=Date.now();await nx(e);let{gitRoot:n}=e.manifest;await Hi(e,n);let r=Mi(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:jr(e.hookInput,e.manifest.manifest,r),envelopeFields:lo(e),launchCwd:Ms(e.hookInput,r),home:Wk()}}function tm(e){try{return ye(Vk(e))}catch{return null}}function sm(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function nm(e,t){let n=e.replaceAll("\\","/");if(!sm(n))return null;let r=ye(e),o=ye(t),s=tm(e)??r,i=tm(t)??o;return s.startsWith(`${i}/`)?s.slice(i.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}function im(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),s=nm(e,t)??(sm(r)?null:r),i=nm(e,n);return{repositorySourcePath:s,userSourcePath:i}}function vi(e,t,n,r,o){return am(e,im(n,t.gitRoot,t.home),r,o)}function am(e,{repositorySourcePath:t,userSourcePath:n},r,o){let s=t??n,i=s===null?null:o(s),a=i!==null&&s!==null?zk({installableKind:r,sourcePath:s,nativeKey:i,inRepository:t!==null,platformAgentId:e.platformAgentId,installationId:e.manifest.installationId}):void 0;return{sourcePath:s,nativeKey:i,componentReference:a}}function zk(e){try{let t=e.inRepository?Xk(e.platformAgentId,e.sourcePath):(0,B.installationRootExternalKey)(e.installationId,(0,B.userConfigRootFromPath)(e.sourcePath));return t?(0,B.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}function cm(e){let t=e.policyFindings;return t===void 0||t.length===0?{}:{policy_findings:t,...e.policyJudgeSpawnMs!==void 0?{policy_judge_spawn_ms:e.policyJudgeSpawnMs}:{}}}function Li(e,t,n){return Wt("tool_invoked",{...n,...cm(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,Vt,e.manifest.collectorUrl,t.buildStartedAtMs,Ln(e,t.home))}function Jk(e){return Ku(e.runnerEvent,e.runnerPlatform)?[]:cu(e.hookInput)}function Yk(e,t){return Li(e,t,{})}var um=new Set([...Object.values(St),".github"]);function Xk(e,t){let n=e.indexOf(":");if(n<=0)return null;let r=e.slice(0,n),o=t.replaceAll("\\","/").split("/").filter(Boolean),s=o.findIndex(i=>um.has(i));return s<0?null:`${r}:${o.slice(0,s+1).join("/")}`}var lm=".codex/config.toml",qk=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",lm]]);function Zk(e,t,n,r,o,s,i){if(e===null||t===null||!(i!==null||/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||/^MCP:.+__.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`))return;let c=s.find(S=>S.name.toLowerCase()===t.toLowerCase()),l=c?qk.get(c.source):o==="codex"?lm:void 0,u=c?.sourcePath??l;if((c?.scope==="user"||l!==void 0)&&u)try{let S=(0,B.userConfigRootFromPath)(u);return(0,B.buildComponentReference)({installationRootExternalKey:(0,B.installationRootExternalKey)(r,S),installableKind:B.ComponentKind.INTERFACE,sourcePath:u,nativeKey:c?.name??t})}catch{return}if(n===null)return;let f=n.indexOf(":");if(f<=0||f===n.length-1)return;let p=n.slice(f+1),g=p.replaceAll("\\","/").split("/").at(-1);if(!(g===void 0||!um.has(g)))try{return(0,B.buildComponentReference)({installationRootExternalKey:n,installableKind:B.ComponentKind.INTERFACE,sourcePath:p,nativeKey:t})}catch{return}}function Qk(...e){for(let t of e)if(t)return t;return null}function xt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return E(`WARN: ${n} failed open: ${r}`),t}function ex(e){let t={present:!1,size:0},n={hash:"",count:0};return{config:{runner_platform:e,config_scope:"user",cli_version:null,claude_version:null,model:null,permission_keys:[],user_scope:{skills:n,subagents:n,commands:n,rules:n,memory:t,settings:t,mcp:t},local_settings:t},commit:()=>{}}}function tx(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var kt=new Set,Mn=null;async function nx(e){if(Gt())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(kt.has(t))return;if(!Is(n)){kt.add(t);return}let r=rn({sessionId:e.sessionId,hostname:ar()});if(sf(r)){if(Mn){await Mn;return}Mn=(async()=>{if(kt.has(t)||!Is(n)){kt.add(t);return}if(!uc(n)){kt.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:i}=e.manifest,a=String(e.runnerPlatform),{operatorResolved:c,fields:l}=await fm(e,r,Ne("git",()=>br(i)),Ne("operator",()=>Os({gitRoot:i,installationStorePath:n,forceResend:!1,runnerPlatform:a}))),u={...l,self_config:tx(a,c.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await Wt("session_start",u,lo(e),Vt,e.manifest.collectorUrl,s,Ln(e)),o&&(c.commit(),kt.add(t))}finally{lc(n)}})().finally(()=>{Mn=null}),await Mn}}async function Hi(e,t,n){try{e.platformAgentId=await vu(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,n,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);E(`WARN: derivePlatformAgentId failed open: ${o}`)}}async function fm(e,t,n,r){let[o,s,i,a,c]=await Promise.allSettled([n,Ne("virt",()=>Va()),Ne("cloud",()=>wl(t)),Ne("host_env",()=>za(rm(e).enabled)),r]),l=xt(o,null,"gitSnapshot"),u=xt(s,"","detectVirt"),d=xt(i,null,"probeCloud"),f=xt(a,{},"hostEnv"),p=xt(c,{commit:()=>{}},"resolveOperatorForSend");return await Hi(e,e.manifest.gitRoot,l),{operatorResolved:p,fields:{identity:{host:ar(),context:t,virt:u||null,cloud:d,git:l},host_env:f,env_vars:Dl()}}}async function rx(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=rn({sessionId:e.sessionId,hostname:ar()}),o=String(e.runnerPlatform),s=Mi(e),i=Ms(e.hookInput,s),a=Ne("git",()=>br(n)),c=Vp().catch(()=>({})),l=Gt()?Promise.resolve({commit:()=>{}}):Ne("operator",()=>Os({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o})),u=fm(e,r,a,l),[d,f]=await Promise.allSettled([Ne("mcp_declared",()=>Rs(e.manifest.manifest,n,o)),a.catch(()=>null).then(K=>Ne("self_config",()=>Np(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:i,inGitRepo:e.manifest.inGitRepo,remote:K?.remote??null})))]),{operatorResolved:p,fields:g}=await u,S=xt(d,[],"mcpDeclared"),A=xt(f,ex(o),"selfConfig"),b=A.config,I=L(e.hookInput,"model");I&&(b.model=I);let P={...g,mcp:{declared:S},self_config:b,run_meta:{trigger:e.hookSource||"startup"},hook_input:jr(e.hookInput,e.manifest.manifest,{...s,launchCwd:i})},T=await c;await Wt("session_start",P,{...lo(e),...T},Vt,e.manifest.collectorUrl,t,Ln(e))&&(A.commit(),p.commit(),kt.add(e.manifest.installationId))}async function ox(e){let t=Date.now(),[,n]=await Promise.all([Hi(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?em(L(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=Qk(L(e.hookInput,"status"),L(e.hookInput,"stop_reason"),L(e.hookInput,"reason"),fn(L(e.hookInput,"error")),r==="stop"?$e(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),s=jr(e.hookInput,e.manifest.manifest,Mi(e));n&&(s.model=n),r!=="stopfailure"&&Fr(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&s.last_assistant_message===void 0&&(s.last_assistant_message=""),await Wt("session_end",{status:o,...n?{model:n}:{},hook_input:s},lo(e),Vt,e.manifest.collectorUrl,t,Ln(e))}async function sx(e){let t=Jk(e),n=Uu(e.hookInput),r=Bu(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&Fr(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let s=await om(e);await Promise.all([o?Yk(e,s):void 0,t.length===0?void 0:ix(e,s,t),n.length===0?void 0:ax(e,s,n)])}function dm(e,t,n,r){let o=r??au({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),s=vi(e,t,o,B.ComponentKind.SKILL,B.nativeKeyForSkillPath);if(s.sourcePath!==null&&Jo(s.sourcePath)?.toLowerCase()===n.toLowerCase())return s.componentReference===void 0?{}:{componentReference:s.componentReference};let i=r??Du({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),a=vi(e,t,i,B.ComponentKind.COMMAND,B.nativeKeyForCommandPath);return a.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:a.nativeKey,...a.componentReference===void 0?{}:{componentReference:a.componentReference}}}function ix(e,t,n){let r=hr(e.hookInput.tool_input);return Promise.all(n.map(o=>{let s=dm(e,t,o,r);return Li(e,t,{tool_name:"Skill",skill_name:o,...s.commandName===void 0?{}:{command_name:s.commandName},...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}function ax(e,t,n){return Promise.all(n.map(r=>{let o=Mu({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),s=vi(e,t,o,B.ComponentKind.RULE,B.nativeKeyForRulePath),i=s.nativeKey??Hu(r);return Li(e,t,{tool_name:"Rule",rule_name:i,...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}var cx=[{kind:B.ComponentKind.SKILL,nativeKeyFn:B.nativeKeyForSkillPath},{kind:B.ComponentKind.RULE,nativeKeyFn:B.nativeKeyForRulePath},{kind:B.ComponentKind.COMMAND,nativeKeyFn:B.nativeKeyForCommandPath}];function ux(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Xo(e.hookInput);if(r===null)return n.skillName===null?{}:dm(e,t,n.skillName,null);let o=im(r,t.gitRoot,t.home);for(let s of cx){let i=am(e,o,s.kind,s.nativeKeyFn);if(i.nativeKey!==null)return{...i.componentReference===void 0?{}:{componentReference:i.componentReference},...s.kind===B.ComponentKind.RULE?{ruleName:i.nativeKey}:{},...s.kind===B.ComponentKind.COMMAND?{commandName:i.nativeKey}:{}}}return{}}var lx=/mcp/i;function fx(e,t,n,r){let o=lx.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let s=o?qd(t,n):eo(r.declaredConfig,n);return s===null?{}:Object.fromEntries(Object.entries(s).filter(i=>typeof i[1]=="string").map(([i,a])=>[`mcp_${i}`,a]))}async function dx(e){let t=await om(e),n=Wu(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,s=Yo(e.hookInput),i=Yd(s,t.home),a=Ju(e.hookInput),c=Gu(e.runnerEvent),l=c===!1?Yu(e.hookInput,e.runnerEvent):null,u=fn(L(e.hookInput,"mcp_server_name")),d=u!==null||r!==null&&Or(r)?await Rs(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(()=>[]):[],{mcpServer:f,mcpTool:p}=qu(r,d.map(K=>K.name),u??""),g=Zk(r,f,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),d,u),S=g===void 0?ux(e,t,n):{},A=f===null?null:Ul(f,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),b=fx(e,s,t.home,{hasMcpIdentity:!!f||!!p,declaredConfig:A}),I=g??S.componentReference,P=S.ruleName??n.ruleName,T=S.commandName??n.commandName,O=zu(e.hookInput);await Wt("tool_invoked",{tool_name:r,skill_name:o,...P?{rule_name:P}:{},...T?{command_name:T}:{},success:c,duration_ms:a,...i?{executable:i}:{},...l?{failure_reason:l}:{},...f?{mcp_server:f}:{},...p?{mcp_tool:p}:{},...b,...I?{component_reference:I}:{},...O?{subagent_type:O}:{},...cm(e),hook_input:t.hookInput},t.envelopeFields,Vt,e.manifest.collectorUrl,t.buildStartedAtMs,Ln(e,t.home))}async function pm(e){switch(ze("w3"),e.internalEvent){case"session_start":await rx(e);return;case"session_end":await ox(e);return;case"skill_invoked":await sx(e);return;case"tool_invoked":await dx(e);return;default:return}}import{mkdirSync as px,readdirSync as mx,readFileSync as gx,statSync as mm,unlinkSync as _x,writeFileSync as hx}from"node:fs";import{homedir as fo}from"node:os";import{join as Ui}from"node:path";var Sx="turns",gm=1440*60*1e3,Ex=100,yx=new Set(["stop","stopfailure","sessionend"]);function Di(e=fo()){return Ui(ge(e),Sx)}function _m(e,t){return Ui(e,qt(t))}function Rx(e,t=Date.now()){let n;try{n=mx(e)}catch{return}let r=0;for(let o of n){if(r>=Ex)return;r+=1;try{let s=Ui(e,o);t-mm(s).mtimeMs>gm&&_x(s)}catch{}}}function Cx(e,t,n=fo()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let s=Di(n);px(s,{recursive:!0}),hx(_m(s,r),o,"utf8")}catch{}}function Ax(e,t=fo()){let n=e.trim();if(!n)return"";try{let r=_m(Di(t),n);return Date.now()-mm(r).mtimeMs>gm?"":gx(r,"utf8").trim()}catch{return""}}function hm(e,t,n,r=fo()){let o=t.trim(),s=yx.has(n.trim().toLowerCase());return s&&Rx(Di(r)),o?(Cx(e,o,r),o):s?Ax(e,r):""}async function bx(e,t,n){let r=t??await zn(nr),o=Se(r,{}),s=await bc(process.cwd(),{sessionId:ln(o)});if(ze("w2"),!s)return;let i=Vu(o,s.manifest.platform,n),a=is(e,i.runnerEvent);if(!a){E(`WARN: unknown hook event '${i.runnerEvent}'; skipping telemetry`);return}let c={hookInput:o,sessionId:i.sessionId,turnId:hm(i.sessionId,i.turnId,i.runnerEvent),runnerEvent:i.runnerEvent,runnerPlatform:i.runnerPlatform,hookSource:i.hookSource,internalEvent:a,manifest:s,platformAgentId:s.platformAgentId};await pm(c)}function kx(e,t=!1){if(M("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,s=un(r,o,void 0,n.runner);return xr(o,s)?!0:t}function Sm(e,t){let n=Zn(e),r=Se(t,{}),o=n.event??ss(r);return Ka()||ju(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}function ym(e){return ul(is(e.parsed.event,e.runnerEvent))}async function Em(e,t,n){let{parsed:r}=e,o=n??ds(r.slot);if(!o&&!ym(e)){let s=fs(r.cap),i=gl(s);if(!i){ps(s);return}o=i}try{await bx(r.event,t,r.runner)}finally{o&&Pr(o)}}async function Rm(e=process.argv.slice(2)){if(fr(e),Rl(),ze(e[0]===vn?"w0":"h0"),_l(),M("EV_AI_HOOK_JUDGE")==="1"){try{await zn(nr)}catch{}return Eo(),0}if(e[0]===Nn){try{await uo(Qt)}catch{}return 0}if(e[0]===vn){try{let n=await Qt();ze("w1");let r=Sm(e.slice(1),n);if(!r)return 0;await Em(r,n)}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: detached work failed open: ${r}`)}return 0}let t;try{let n=await zn(nr);ze("h1");let r=Sm(e,n);if(!r)return 0;let{parsed:o,hookInput:s,runnerEvent:i}=r;if(t=ds(o.slot),!nl(s,i,o.runner))return 0;if(ze("h2"),kx(r))await Em(r,n,t);else{let a=t||ym(r)?void 0:fs(o.cap);if(a===void 0||pl(a)){ze("h3"),Ol();let c=await Qp(n,e);t&&c?.pid!==void 0&&fl(t,c.pid)}else ps(a)}}catch(n){let r=n instanceof Error?n.message:String(n);E(`WARN: hook failed open: ${r}`)}finally{t&&Pr(t),Eo()}return 0}function po(){E("Usage: ev-ai-agent-hook <configure|install|migrate-to-plugin|update|uninstall|--version>"),E(" configure [--url <\u2026/{orgToken}/hook>]"),E(" (manifest only \u2014 pair with marketplace plugins)"),E(" install --url <\u2026/{orgToken}/hook>"),E(" [--delivery npx|binary|local] [--force]"),E(" [--no-claude] [--no-cursor] [--no-codex]"),E(" (fallback: merge hooks into .claude / .cursor / .codex configs)"),E(" (writes collector_url to shared manifest; hook commands use --runner only)"),E(" migrate-to-plugin"),E(" (strip ev-ai file hooks; keep collector manifest)"),E(" update (refresh binary pins from a local build; leaves hook configs alone)"),E(" uninstall"),E("Hook mode: --runner <platform> [--url <\u2026/hook>|--token <orgToken>] [event]"),E(" (--url/--token optional overrides; else collector_url from manifest)")}function Cm(e){return e.includes("--help")||e.includes("-h")}async function Px(e=process.argv.slice(2)){fr(e);let[t,...n]=e;if(t===Nn){try{await uo(Qt)}catch{}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${Be}
|
|
56
|
-
|
|
42
|
+
`.trim(),Zs=new Map;function $f(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($f,"asText");function Bf(e){return e.toLowerCase().includes("token")}s(Bf,"isTokenKey");function Kf(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=$f(r.key),i=$f(r.value);o&&i&&!Bf(o)&&t.set(o,i)}return t}s(Kf,"rowsToMap");function GC(e){let t=KC(e);return t.search="mode=ro&immutable=1",t.href}s(GC,"sqliteReadonlyUri");function WC(e){try{let t=jf("bun:sqlite");if(typeof t.Database!="function")return null;let n=new t.Database(e,{readonly:!0,create:!1});try{let r=n.query?.(to)??n.prepare(to);return Kf(r.all?.())}finally{n.close?.()}}catch{return null}}s(WC,"readViaBunSqlite");function VC(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(VC,"withSqliteExperimentalWarningSuppressed");function zC(e){try{return VC(()=>{let t=jf("node:sqlite");if(typeof t.DatabaseSync!="function")return null;let n=new t.DatabaseSync(e,{readOnly:!0});try{return Kf(n.prepare(to).all?.())}finally{n.close?.()}})}catch{return null}}s(zC,"readViaNodeSqlite");function JC(e){let t=new Map;for(let n of e.split(`
|
|
43
|
+
`)){let r=n.trimEnd();if(!r)continue;let o=r.indexOf(" ");if(o<=0)continue;let i=r.slice(0,o).trim(),a=r.slice(o+1).trim();i&&a&&!Bf(i)&&t.set(i,a)}return t}s(JC,"parseCliTable");function YC(e){try{let t=$C("sqlite3",["-noheader","-batch","-separator"," ",e,to],{encoding:"utf8",timeout:2e3,maxBuffer:65536,windowsHide:!0,stdio:["ignore","pipe","ignore"]});return JC(t)}catch{return null}}s(YC,"readViaSqliteCli");function Gf(e){let t=Zs.get(e);if(t)return t;if(!jC(e)){let o=new Map;return Zs.set(e,o),o}let n=GC(e),r=WC(n)??YC(n)??zC(n)??new Map;return Zs.set(e,r),r}s(Gf,"readCursorAuthItems");var XC="cursorAuth/cachedEmail",qC="cursorAuth/stripeMembershipAuthId";function no(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(no,"trimEnv");function ZC(e=ro(),t=process.platform,n=process.env){let r=no(n.VSCODE_PORTABLE);if(r)return Qe(r,"user-data");let o=no(n.VSCODE_APPDATA);if(o)return Qe(o,"Cursor");switch(t){case"darwin":return Qe(e,"Library","Application Support","Cursor");case"win32":return Qe(no(n.APPDATA)??Qe(e,"AppData","Roaming"),"Cursor");default:return Qe(no(n.XDG_CONFIG_HOME)??Qe(e,".config"),"Cursor")}}s(ZC,"cursorUserDataDir");function QC(e=ro()){return Qe(e,".cursor","cli-config.json")}s(QC,"cursorCliConfigPath");function eA(e=ro(),t=process.platform,n=process.env){return Qe(ZC(e,t,n),"User","globalStorage","state.vscdb")}s(eA,"cursorIdeStateDbPath");function Hn(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}s(Hn,"trimString");function tA(e){return typeof e.userId=="number"&&Number.isFinite(e.userId)?String(e.userId):Hn(e.userId)}s(tA,"numericUserId");function nA(e){return Hn(e.email)??Hn(e.authId)??tA(e)}s(nA,"platformLogin");function Qs(e){let t=Hn(e.email),n=Hn(e.displayName),r=nA(e);return!r||fe(n,t)?null:{git_user_name:null,git_user_email:null,platform_login:r,identity_source:"cursor_oauth"}}s(Qs,"identityFromAuth");function rA(e){let n=Z(QC(e),{}).authInfo;return!n||typeof n!="object"?null:Qs(n)}s(rA,"readCliOperatorIdentity");function oA(e,t,n){let r=eA(e,process.platform,t),o=Hf(e),i=Uf(o);if(Df(i,r,n))return Qs({email:i?.email,authId:i?.auth_id});let a=Gf(r),c=a.get(XC)??null,u=a.get(qC)??null;return Ff(o,{read_at_ms:n,db_path:r,email:c,auth_id:u}),Qs({email:c,authId:u})}s(oA,"readIdeOperatorIdentity");function Wf(e=ro(),t=process.env,n=Date.now()){return rA(e)??oA(e,t,n)}s(Wf,"readCursorOperatorIdentity");import{createHash as sA}from"node:crypto";import{resolve as iA}from"node:path";function te(e){return sA("sha256").update(e).digest("hex").slice(0,16)}s(te,"sha16");function ei(e){return te(iA(e))}s(ei,"dirScopeRef");function xe(e,t){return`${e}\0${t}`}s(xe,"componentKey");function oo(e){return e.enabled===!1?`${e.content_hash}:disabled`:e.content_hash}s(oo,"componentDeltaHash");function Vf(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}s(Vf,"parseComponentKey");function Un(e){let n=[...e].sort((r,o)=>{let i=r.path.localeCompare(o.path);return i!==0?i:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
|
|
44
|
+
`);return te(n)}s(Un,"hashUserSpec");function cA(e,t,n="git_config",r=null){return te(`${e??""}|${t??""}|${r??""}|${n}`)}s(cA,"hashOperatorIdentity");function uA(e){let t=null,n=null;for(let r of e.split(`
|
|
45
|
+
`)){let o=r.trim();if(!o)continue;let i=o.indexOf(" ");if(i<=0)continue;let a=o.slice(0,i).toLowerCase(),c=o.slice(i+1).trim();c&&(a==="user.name"?t=c:a==="user.email"&&(n=c))}return{git_user_name:t,git_user_email:n,platform_login:null}}s(uA,"parseGitUserConfig");async function lA(e,t=se){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return uA(n)}s(lA,"readGitOperatorIdentity");function fA(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(fA,"readGitEnvOperatorIdentity");function et(e,t,n,r=null){return!e&&!t&&!r?null:{git_user_name:e,git_user_email:t,platform_login:r,identity_source:n}}s(et,"actorIdentity");function dA(e=process.env,t){let n=G(e.EV_AI_HOOK_OPERATOR_EMAIL),r=G(e.EV_AI_HOOK_OPERATOR_LOGIN),o=et(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=et(i,null,"github",i);if(a)return a;let c=G(e.GITLAB_USER_LOGIN),u=G(e.GITLAB_USER_EMAIL),f=et(G(e.GITLAB_USER_NAME)??c,u,"gitlab",u??c);if(f)return f;let l=G(e.BUILD_REQUESTEDFOREMAIL),p=et(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=et(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=et(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),k=et(y,null,"circleci",y);if(k)return k;let P=G(e.CODEBUILD_INITIATOR),w=et(P,null,"codebuild",P);if(w)return w;let O=G(e.DRONE_COMMIT_AUTHOR_EMAIL),x=G(e.DRONE_COMMIT_AUTHOR),L=et(x??G(e.DRONE_COMMIT_AUTHOR_NAME),O,"drone",O??x);if(L)return L;if(zf(e.CLAUDE_CODE_REMOTE)||zf(e.CURSOR_AGENT)||t!==void 0&&pA.has(t)){let v=G(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:null,platform_login:v&&!fe(null,v)?v:null,identity_source:"cloud"}}return null}s(dA,"readCloudOperatorIdentity");var pA=new Set(["cursor_cloud","claude_remote"]);function ti(e){return!!((e.git_user_name??e.git_user_email)&&!fe(e.git_user_name,e.git_user_email))}s(ti,"isHumanOperator");function G(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}s(G,"trimEnv");function zf(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}s(zf,"isTruthyEnv");function mA(e,t,n){return e==="claude"?Sc(t):e==="cursor"?Wf(t,n):e==="codex"?Lf(n,t):null}s(mA,"readRunnerOperatorIdentity");async function ni(e,t=se,n=process.env,r={}){let o=await lA(e,t),i=fA(n),a=ti(o)?o:i&&ti(i)?i:null,c=mA(r.runnerPlatform,r.home??aA(),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=dA(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:ti(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(ni,"resolveOperatorIdentity");async function ri(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??se,i=e.env??process.env,a=await ni(t,o,i,{runnerPlatform:e.runnerPlatform,home:e.home,context:e.context}),c=cA(a.git_user_name,a.git_user_email,a.identity_source,a.platform_login),f=(n?ms(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&&cu(m,c,lr())},"commit")}}s(ri,"resolveOperatorForSend");function oi(e){return e?!ms(e)?.operator_identity_hash:!0}s(oi,"operatorIdentityNeverSent");var gA=new Set(["claude","codex"]);function Jf(e,t){return!(t!==void 0&&gA.has(t))}s(Jf,"shouldBootstrapCloudIdentity");import{existsSync as wx,readFileSync as Nx}from"node:fs";import{homedir as Sm}from"node:os";import{join as un,resolve as vx}from"node:path";import{basename as Ax,join as cn}from"node:path";import{dirname as od,resolve as co}from"node:path";import{existsSync as _A}from"node:fs";import{homedir as qf}from"node:os";import{relative as Zf,resolve as Fe,sep as Et}from"node:path";var hA=["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"],SA=["prompt","tool_input","tool_response","last_assistant_message","command"],EA=new Set;function yA(e){switch(e?.toLowerCase()){case"beforemcpexecution":return new Set(["command"]);case"stopfailure":return new Set(["last_assistant_message"]);default:return EA}}s(yA,"excludedContentKeys");function ui(e){let t=D("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return t!==void 0&&t!==""?Rt.has(t.toLowerCase()):e?.collect_prompt===!0}s(ui,"isPromptCaptureEnabled");function so(e,t){let n=Qf(e);if(n==="allowlist")return"off";if(n==="full")return"full";let r=D("EV_AI_HOOK_CAPTURE_PROMPT")?.trim();return r!==void 0&&r!==""?Rt.has(r.toLowerCase())?"env":"off":t?.collect_prompt===!0?"config":"off"}s(so,"promptCaptureSource");function Qf(e){return D("EV_AI_HOOK_CAPTURE_CONTENT")?.toLowerCase()==="off"||e.capture_hook_input==="allowlist"?"allowlist":e.capture_hook_input==="full"||cs(process.argv,e.debug===!0)||D("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"?"full":"content"}s(Qf,"hookInputCaptureMode");function RA(e){let t={};for(let n of hA){let r=Ve(e,n);r!==void 0&&(t[n]=r)}return t}s(RA,"allowlistedHookInput");function io(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Fe(e),r=Fe(t),o=Zf(r,n);return!o||o==="."?".":o.startsWith(`..${Et}`)||o===".."||Fe(r,o)!==n?null:o.split(Et).join("/")}s(io,"cwdRelativeToGitRoot");function ed(e,t){let n=Zf(Fe(t),Fe(e)).split(Et).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}s(ed,"specDirRelativeToCwd");function td(e){return typeof e!="string"||e.length===0?null:Fe(e).split(Et).join("/")}s(td,"absoluteCwdForSend");function CA(){let e=D("CURSOR_PROJECT_DIR");if(!e)return null;let t=Fe(e);return _A(t)?t.split(Et).join("/"):null}s(CA,"cursorProjectDirAbs");function ii(e,t){return io(e,t)!==null}s(ii,"isPathInside");function AA(e,t){let n=Fe(t??qf(),".cursor").split(Et).join("/");return ii(e,n)}s(AA,"isCursorUserHookLaunch");function bA(e,t,n){return t!==null&&ii(e,t)?!0:t!==null&&AA(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&ii(e,n.gitRoot)?!0:t===null}s(bA,"shouldKeepProcessCwd");function nd(e,t){let n=td(e.cwd);if(n!==null)return n;let r=Fe(process.cwd()).split(Et).join("/"),o=CA();return bA(r,o,t)?r:o??r}s(nd,"resolvedCwdForSend");function li(e,t={}){return nd(e,t)}s(li,"resolveLaunchCwd");function fi(e,t=qf()){let n=Fe(t).split(Et).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}s(fi,"tildeHomeCwd");function Yf(e,t,n){let r=td(n.launchCwd)??nd(t,n);e.cwd=fi(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?io(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}s(Yf,"attachCwdFields");var rd="\u2026[truncated]\u2026",ai=Buffer.byteLength(rd,"utf8"),kA=8;function Dn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Dn,"jsonByteLength");function Xf(e,t){if(t<=0)return"";let n=Buffer.from(e,"utf8");return n.length<=t?e:n.subarray(0,t).toString("utf8")}s(Xf,"utf8Head");function xA(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(xA,"utf8Tail");function OA(e,t){if(Buffer.byteLength(e,"utf8")<=t)return e;if(t<=ai)return Xf(e,t);let r=t-ai,o=Math.ceil(r/2),i=Math.floor(r/2);return`${Xf(e,o)}${rd}${xA(e,i)}`}s(OA,"truncateHeadTail");function ci(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)=>{ci(r,[...t,o],n)});return}if(e!==null&&typeof e=="object")for(let[r,o]of Object.entries(e))t.length===0&&r.startsWith("_")||ci(o,[...t,r],n)}s(ci,"collectStrings");function IA(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(IA,"setAtPath");var TA=256;function PA(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(PA,"stringBudgetFor");function wA(e,t,n){let r=Number.POSITIVE_INFINITY;for(let o=0;o<6;o++){let i=Dn(e);if(i<=t)return;let a=[];ci(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=PA(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&&IA(e,l.path,OA(l.value,r))}}s(wA,"clampStringsToBudget");function NA(e,t){let n=Math.max(0,t-TA),r=Object.keys(e).filter(i=>!i.startsWith("_")).map(i=>({key:i,bytes:Dn(e[i])})).sort((i,a)=>a.bytes-i.bytes),o=[];for(let{key:i}of r){if(Dn(e)<=n)break;delete e[i],o.push(i)}o.length>0&&(e._dropped_keys=o.slice(0,10))}s(NA,"dropLargestKeys");function si(e,t){let n=Dn(e);if(n<=t)return e;let r=structuredClone(e);return r._truncated=!0,r._original_bytes=n,wA(r,t,ai+kA),Dn(r)>t&&NA(r,t),r}s(si,"fitWithinByteLimit");function vA(e,t,n){if(!(n.promptCapture??ui()))return;let r=yA(n.runnerEvent);for(let o of SA){if(r.has(o))continue;let i=t[o];i!==void 0&&(e[o]=i)}}s(vA,"attachContentFields");function ao(e,t,n={}){let r=Qf(t);if(r==="full"){let i={...e};return delete i.cwd,delete i.transcript_path,Yf(i,e,n),si(i,Xo)}let o=RA(e);return Yf(o,e,n),r==="content"?(vA(o,e,n),si(o,Xo)):si(o,fc)}s(ao,"sanitizeHookInput");function LA(e){return typeof e=="string"&&e.length>0}s(LA,"hasOrigin");function di(e){let t=co(e.home),n=co(e.launchCwd),r=e.gitRoot?co(e.gitRoot):null,o=new Set,i=[],a=null;e.inGitRepo&&LA(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&&io(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&u){let f=od(r);for(;;){let l=co(f);if(l===t)break;let p=od(l);if(p===l)break;if(e.hasProjectSpec(l)){i.push({scope:"parent",dir:l}),c=ed(l,n);break}f=p}}return{anchors:i,parentRel:c}}s(di,"resolveProjectAnchors");import{existsSync as sd,readdirSync as MA,realpathSync as HA}from"node:fs";import{basename as UA,dirname as DA,relative as FA,resolve as $A,sep as jA}from"node:path";var pi=400,uo=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??st}static{s(this,"UserSpecContext")}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=$A(t).split(jA).join("/");return fi(r,this.home)}let n=FA(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${te(DA(t))}/${UA(t)}`:n}claimFile(t){try{let n=HA(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(!sd(t))return[];try{return MA(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(sd(t))return Z(t,n)}push(t){return this.components.length>=this.maxEntries?(this.truncated=!0,!1):this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0?!1:(this.pluginExpandRemaining!==void 0&&(this.pluginExpandRemaining-=1),this.components.push(t),!0)}withPluginExpandCap(t,n){let r=this.pluginExpandRemaining;this.pluginExpandRemaining=t;try{let o=n(),i=t-(this.pluginExpandRemaining??0);return{result:o,expanded:i}}finally{this.pluginExpandRemaining=r}}};import{existsSync as wi,readFileSync as lk,statSync as fk}from"node:fs";import{basename as yp,join as Mt,relative as Ni}from"node:path";var _p=ot(gp());var ck=["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/.trash/**","**/.claude/cache/**","**/.codex/skills/.system/**","**/vendor/**","**/.yarn/**","**/coverage/**","**/.next/**"],hp=ck.map(e=>_p.default.matcher(e,{dot:!0}));function uk(e){return e===""?!1:hp.some(t=>t(`${e}/`))}s(uk,"isExcludedDirPath");function Sp(e,t){if(t==="")return!1;if(e==="")return uk(t);let n=e.replace(/\/+$/,"");return hp.some(r=>r(`${n}/${t}/`)&&!r(`${n}/`))}s(Sp,"isExcludedDirBelow");var vi=100*1024,dk=4;function pk(e){return e.length<=vi?e:`${e.slice(0,vi-1)}\u2026`}s(pk,"truncateContentText");function mk(e){try{let t=lk(e),n=t.toString("utf8");return{hash:te(t),length:t.length,text:pk(n)}}catch{return null}}s(mk,"readFileMeta");var Ep={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function gk(e){return e in Ep?Ep[e]:"UNSPECIFIED"}s(gk,"triggerForKind");function sn(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=mk(t.absolutePath);if(!n)return!1;let r=t.name??yp(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=gk(t.kind);return i&&(o.trigger=i),t.attributes&&(o.attributes=t.attributes),e.push(o)}s(sn,"addFile");function _k(e,t,n){let r=Ni(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?yp(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}s(_k,"nameFromWalkRoot");function Ht(e,t){let{dir:n,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u}=t;Li(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:i,nested:a,extensions:c,skipDirs:u})}s(Ht,"walkComponentDir");function Li(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l}=t;if(!(o>dk))for(let p of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(p.isDirectory()&&Sp(n.replace(/\\/g,"/"),Ni(n,Mt(r,p.name)).replace(/\\/g,"/"))||p.isDirectory()&&l?.includes(Mt(r,p.name)))continue;if(u){if(!p.isDirectory())continue;let g=Mt(r,p.name,u);if(wi(g)){let h=Ni(n,Mt(r,p.name)).replace(/\\/g,"/");sn(e,{absolutePath:g,kind:i,origin:a,enabled:c,name:h||p.name});continue}Li(e,{walkRoot:n,currentDir:Mt(r,p.name),depth:o+1,kind:i,origin:a,enabled:c,nested:u,extensions:f,skipDirs:l});continue}if(p.isDirectory()){Li(e,{walkRoot:n,currentDir:Mt(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=Mt(r,p.name);sn(e,{absolutePath:m,kind:i,origin:a,enabled:c,name:_k(n,m,!0)})}}s(Li,"walkRecursive");function Rp(e){for(let t of e)if(wi(t))try{if(fk(t).size>0)return t}catch{continue}return e.find(t=>wi(t))}s(Rp,"firstExistingFile");import{existsSync as Vk,readFileSync as zk}from"node:fs";var ho=ot(St(),1);var hk="<omitted>",Sk=["package_name","package_spec","package_version","package_version_source"],Cp=100,Ap=120,So=[{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"}],bp=new Set(So.map(e=>e.attr)),Ek=["enabled","disabled"],yk=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],Rk=new Set(["type","command","url","args","env","envVars","headers",...Ek,...yk,...So.map(e=>e.raw)]),Ck=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",...Sk,...bp,...[...bp].map(e=>`${e}_truncated`)]);function kp(e,t){for(let n of t)Rk.has(n)||Ck.has(n)||(e[n]=hk)}s(kp,"addOmittedKeys");var Ak=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,bk=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,kk=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,xk=/^bearer(?:\s+|$)/i;function Eo(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}s(Eo,"asRecord");function xp(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}s(xp,"stringList");function Mi(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(Mi,"envNamesFromValue");function Ut(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}s(Ut,"redactCommandOrUrl");function Ok(e,t){if(e!==void 0&&/^https?:\/\//i.test(e)&&(0,ho.launchContainsCredentials)({kind:"url",url:e})||(0,ho.launchContainsCredentials)({kind:"command",command:e??"",arguments:t}))return!0;let n=Wn([...t]);return t.some((r,o)=>n[o]===r?!1:/^https?:\/\//i.test(r)?(0,ho.launchContainsCredentials)({kind:"url",url:r}):!0)}s(Ok,"rawLaunchHadCredentials");function Op(e,t,n){Ok(t,n)&&(e.launch_had_credentials=!0)}s(Op,"markLaunchCredentials");function Ik(e){return kk.test(e)||xk.test(e)?"<redacted>":e.includes("://")?Ut(e):e}s(Ik,"redactSecretShapedValue");function Ip(e){if(/^https?:\/\//i.test(e))return Ut(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Ip(e.slice(t+1))}`:Ik(e)}s(Ip,"redactArg");function Tk(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return Ak.test(t)||bk.test(t)}s(Tk,"authArgKey");function Wn(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(Tk(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Ip(r))}return t}s(Wn,"redactArgs");function Pk(e){let t=xp(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Ap?r.slice(0,Ap):r))].sort();if(n.length!==0)return n.length>Cp?{names:n.slice(0,Cp),truncated:!0}:{names:n,truncated:!1}}s(Pk,"toolNameList");function wk(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(wk,"envHeaderNames");function Tp(e,t){let n=new Set;for(let{raw:r,attr:o}of So){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=Pk(i);a&&(e[o]=a.names,a.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}s(Tp,"applyToolListAttributes");function Pp(e,t){let n=Eo(e),r={transport:t};if(!n)return r;kp(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=xp(n.args);c&&(r.command_or_url=Ut(c));let f=Wn(u);f.length>0&&(r.args=f),Op(r,c,u);let l=wk(n.env_http_headers),p=[...new Set([...Mi(n.env),...Mi(n.envVars),...Mi(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),Tp(r,n),r}s(Pp,"sanitizeMcpServerAttributes");function wp(e){let t=Eo(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}s(wp,"mcpServerEnabledFromJson");function Di(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return te(JSON.stringify({name:e,attributes:r,enabled:n}))}s(Di,"hashSanitizedMcpAttributes");function an(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}s(an,"parseTomlQuoted");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):[]}s(Gn,"parseTomlPlainStringArray");function Ui(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}s(Ui,"parseTomlBoolean");function Hi(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=an(n[1]);return r.length>0?r:void 0}s(Hi,"parseTomlScalarString");function Nk(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],an(u[2]??"")])}},"collect"),o=new RegExp(`^\\s*${t}\\s*=\\s*\\{([^}]*)\\}`,"m").exec(e);o?.[1]&&r(o[1]);let i=new RegExp(`(?:^|\\n)\\[[^\\]]*\\.${t}\\]\\s*\\n([\\s\\S]*?)(?=\\n\\[|$)`).exec(`
|
|
46
|
+
${e}`);return i?.[1]&&r(i[1]),n}s(Nk,"parseTomlMap");function Np(e){return Ui(e,"enabled")===!1?!1:Ui(e,"disabled")!==!0}s(Np,"mcpServerEnabledFromToml");function vk(e,t){let n={};for(let{raw:r,attr:o}of So){if(o==="auto_approve"){let a=Ui(t,r);if(a!==void 0){n[r]=a;continue}}let i=Gn(t,r);i.length>0&&(n[r]=i)}Tp(e,n)}s(vk,"applyToolListsFromToml");var Lk=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,Mk=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function Hk(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
|
|
47
|
+
`)){let i=Lk.exec(o);i?.[1]&&t.add(i[1])}for(let o of e.matchAll(Mk))o[1]&&t.add(o[1]);return[...t]}s(Hk,"tomlDeclaredKeys");function vp(e,t){let n={transport:t};kp(n,Hk(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),i=r?an(r[1]??""):void 0,a=o?an(o[1]??""):void 0,c=i!==void 0&&i.length>0?i:a,u=Gn(e,"args");c&&(n.command_or_url=Ut(c));let f=Wn(u);f.length>0&&(n.args=f),Op(n,c,u);let l=new Set;for(let k of e.split(`
|
|
48
|
+
`)){let P=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);P?.[1]&&l.add(P[1])}let p=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(p?.[1])for(let k of p[1].split(",")){let P=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);P?.[1]&&l.add(P[1])}let d=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
|
|
49
|
+
${e}`);if(d?.[1])for(let k of d[1].split(`
|
|
50
|
+
`)){let P=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(k);P?.[1]&&l.add(P[1])}for(let k of Gn(e,"env_vars"))l.add(k);let m=Nk(e,"env_http_headers");for(let[,k]of m)k.length>0&&l.add(k);let g=Hi(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(([k])=>k))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let h=Hi(e,"auth");h&&(n.auth=h);let y=Hi(e,"default_tools_approval_mode");return y&&(n.default_tools_approval_mode=y),vk(n,e),n}s(vp,"parseTomlMcpSection");var Be=ot(St(),1);import{createHash as $k}from"node:crypto";import{join as Vn}from"node:path";var Uk=300,Dk=256;function Lp(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(Lp,"rewriteHomePrefix");function yo(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(yo,"tokenizeCommand");function Mp(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}s(Mp,"capLength");function Fk(e){return Mp(e,Uk)}s(Fk,"capCommand");function Hp(e,t){let n=Lp(e.trim(),t),r=yo(n);if(r.length===0)return"";let[o,...i]=r,a=Ut(o),c=Wn(i);return Fk([a,...c].join(" "))}s(Hp,"sanitizeHookCommand");function Up(e,t){if(typeof e!="string")return null;let n=Lp(e.trim(),t),r=yo(n)[0];if(!r)return null;let o=Ut(r);return o.length===0?null:Mp(o,Dk)}s(Up,"executableFromCommand");function jk(e,t){if(t!==null)return{package_version:t,package_version_source:"npx_cache"};let n=(0,Be.pinnedPackageVersionFromSpec)(e);return n===void 0?{}:{package_version:n,package_version_source:"declared_pin"}}s(jk,"packageVersionFields");function Bk(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
|
|
51
|
+
`);return $k("sha512").update(t).digest("hex").slice(0,16)}s(Bk,"npxCacheKey");function Kk(e){let t=process.platform==="win32"?Vn(D("LOCALAPPDATA")??e,"npm-cache"):Vn(e,".npm"),n=D("npm_config_cache")??D("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}s(Kk,"npmCacheRoots");function Dp(e){return typeof e=="string"&&e.length>0&&e.length<=Be.PACKAGE_FIELD_MAX?e:null}s(Dp,"usableVersion");function Gk(e,t,n){let r=Bk(e);for(let o of Kk(n)){let i=Vn(o,"_npx",r),a=Z(Vn(i,"node_modules",...t.split("/"),"package.json"),{}),c=Dp(a.version);if(c!==null)return c;let u=Z(Vn(i,"package-lock.json"),{}),f=Dp(u.packages?.[`node_modules/${t}`]?.version);if(f!==null)return f}return null}s(Gk,"installedVersion");function Wk(e){return e.length<=Be.PACKAGE_FIELD_MAX?e:`${e.slice(0,Be.PACKAGE_FIELD_MAX-1)}\u2026`}s(Wk,"capField");function Fi(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=(0,Be.npxPackageSpecs)(e,t??[]),o=r[0];if(o===void 0)return null;let i=(0,Be.packageNameFromSpec)(o);return i===null?null:{package_name:i,package_spec:Wk(o),...jk(o,Gk(r,i,n))}}s(Fi,"resolveNpxPackage");function Fp(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=yo(e.trim());return n===void 0?null:Fi(n,r,t)}s(Fp,"resolveNpxPackageFromCommand");function Ro(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 Fi(typeof n.command=="string"?n.command:null,r,t)}s(Ro,"npxPackageFromMcpConfig");function $p(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:Fi(an(n[1]??""),Gn(e,"args"),t)}s($p,"npxPackageFromTomlSection");function Jk(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(Jk,"mcpTransport");function jp(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=Jk(c),f=Pp(c,u);Object.assign(f,Ro(c,e.home)??{});let l=wp(c);e.push({kind:"MCP_SERVER",name:a,path:i,content_hash:Di(a,f,l),origin:n,enabled:l,attributes:f})}}s(jp,"collectMcpJson");function Bp(e,t,n){if(!Vk(t)||!e.claimFile(t))return;let r;try{r=zk(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=vp(l,p);Object.assign(d,$p(l,e.home)??{});let m=Np(l);e.push({kind:"MCP_SERVER",name:c,path:o,content_hash:Di(c,d,m),origin:n,enabled:m,attributes:d})}}s(Bp,"collectCodexMcpToml");import{existsSync as qk,readdirSync as Zk}from"node:fs";import{join as Se}from"node:path";function Yk(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(Yk,"classifyActionKind");function Xk(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(Xk,"normalizeHookActions");function $i(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 Xk(u)){if(e.truncated)return;let l=f.command??f.bash??f.prompt??f.powershell??u.powershell??"",p=Yk({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=te(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:te(h),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:i,...d?{matcher:d}:{},action_kind:p,action_hash:m,...p!=="prompt"&&l.trim()?{command:Hp(l,e.home)}:{}}})}}}s($i,"collectHooksFromObject");function ji(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||$i(e,t,r.hooks,n)}s(ji,"collectHooksFile");var Kp=50;function zn(e,t,n,r){if(!qk(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:i}=e.withPluginExpandCap(Kp,()=>{Ht(e,{dir:Se(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Ht(e,{dir:Se(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Ht(e,{dir:Se(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});ji(e,Se(t,"hooks","hooks.json"),n),ji(e,Se(t,"hooks.json"),n);let a=e.components.length-o,c=i>=Kp;return{componentCount:a,expandTruncated:c}}s(zn,"expandPluginTree");function Jn(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(Jn,"addPluginRow");function Bi(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(Bi,"readEnabledPlugins");function Qk(e){let t=Bi(e.readJson(Se(e.home,".claude/settings.json"),{})),{serverManaged:n,fileBased:r}=Cn(process.platform,e.home),o=e.readJson(n,{}),i={};if(o&&Object.keys(o).length>0)i=Bi(o);else for(let a of r)Object.assign(i,Bi(e.readJson(a,{})));return{...t,...i}}s(Qk,"resolveClaudeEnabledPlugins");function Gp(e){let t=Se(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},o=Qk(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 k of u)if(typeof k.installPath=="string"&&k.installPath.length>0){let P=zn(e,k.installPath,g,l);h+=P.componentCount,y=y||P.expandTruncated}Jn(e,{pluginKey:a,rowPath:i,enabled:l,scope:m,version:d||void 0,marketplace:p||void 0,componentCount:h,expandTruncated:y,contentHash:te(`${a}|${d}|${m}|${l}|${h}`)})}}s(Gp,"collectClaudePlugins");function ex(e){let t=e,n="";try{let r=Zk(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=Se(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),i=o[o.length-1];i&&(t=Se(e,i),n=i)}}catch{}return{installPath:t,version:n}}s(ex,"pickVersionDir");var tx=/^\d+$/;function nx(e){let t=e.filter(n=>!tx.test(n.pluginId));return t.length>0?t:e}s(nx,"dedupeCursorCachePlugins");function Wp(e){let t=[{base:Se(e.home,".cursor/plugins/local"),scope:"local"},{base:Se(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=Se(n,o.name),f=`plugin:${c}`,{componentCount:l,expandTruncated:p}=zn(e,u,f,!0);Jn(e,{pluginKey:c,rowPath:e.componentPath(u),enabled:!0,scope:"local",componentCount:l,expandTruncated:p,contentHash:te(`${c}|local|${l}`)});continue}let i=o.name,a=[];for(let c of e.readEntries(Se(n,i))){if(!c.isDirectory())continue;let u=Se(n,i,c.name),{installPath:f,version:l}=ex(u);a.push({pluginId:c.name,installPath:f,version:l})}for(let c of nx(a)){if(e.truncated)break;let u=`${c.pluginId}@${i}`,f=`plugin:${u}`,{componentCount:l,expandTruncated:p}=zn(e,c.installPath,f,!0);Jn(e,{pluginKey:u,rowPath:e.componentPath(c.installPath),enabled:!0,scope:"cache",version:c.version||void 0,marketplace:i,componentCount:l,expandTruncated:p,contentHash:te(`${u}|${c.version}|${l}`)})}}}s(Wp,"collectCursorPlugins");import{existsSync as sx}from"node:fs";var rx=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,Ki="<path>",ox=new RegExp(`${Ki}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function Co(e){let t=e.replace(rx,Ki).replace(ox,Ki);return t.length>200?`${t.slice(0,200)}...`:t}s(Co,"redactPermissionKey");var Vp=200,zp=200,Gi=16*1024,Jp=6,ix=new Set(["permissions","sandbox","enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers","disableAllHooks","disableAutoMode","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","strictPluginOnlyCustomization","disableSideloadFlags","forceLoginMethod","forceLoginOrgUUID"]),ax=new Set(["type","additionalReadwritePaths","additionalReadonlyPaths","disableTmpWrite","enableSharedBuildCache","networkPolicy"]),cx=new Set(["terminalAllowlist","mcpAllowlist","autoRun"]),ux=new Set(["permissions"]),lx={claude:ix,cursor_sandbox:ax,cursor_permissions:cx,cursor_cli:ux},fx=new Set(["allow","deny","ask"]);function yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(yt,"isRecord");function Ao(e){return e.replace(/\\/g,"/")}s(Ao,"posixPath");function Wi(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Wi(r)).join(",")}]`;let t=e;return`{${Object.keys(t).filter(r=>t[r]!==void 0).sort().map(r=>`${JSON.stringify(r)}:${Wi(t[r])}`).join(",")}}`}s(Wi,"canonicalJson");function dx(e){return te(`${Wi(e)}|settings1`)}s(dx,"hashSettingsAttributes");function Qp(e){let t=Ao(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(Qp,"settingsProfileFor");function em(e,t){if(e!=="claude")return{};let n=Ao(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(em,"managedSettingsMeta");function tm(e){let t=Ao(e).replace(/\/+$/,"");return t.length<=1?"":t}s(tm,"homePosix");function nm(e){return/^[A-Za-z]:/.test(e)||e.includes("\\")}s(nm,"isWindowsHome");function px(e,t){let n=Ao(e);if(n==="~"||n.startsWith("~/"))return n;let r=tm(t);if(!r)return n;let o=n.slice(0,r.length);if(!(nm(t)?o.toLowerCase()===r.toLowerCase():o===r))return n;let a=n.slice(r.length);return a===""?"~":a.startsWith("/")?`~${a}`:n}s(px,"tildePath");var Yp=new Map;function mx(e){let t=Yp.get(e);if(t!==void 0)return t;let n=tm(e),r=null;if(n){let o=n.split("/").map(i=>i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("[\\\\/]+");r=new RegExp(`(?<![\\w.-])${o}(?![\\w.-])`,nm(e)?"gi":"g")}return Yp.set(e,r),r}s(mx,"homeTextPattern");function gx(e,t){let n=mx(t);return n?e.replace(n,"~"):e}s(gx,"tildeHomeInText");function Xp(e,t){return e.length<=zp?e:(t.truncated=!0,e.slice(0,zp))}s(Xp,"capString");function rm(e,t){return e.length<=Vp?e:(t.truncated=!0,e.slice(0,Vp))}s(rm,"capArray");function ie(e,t,n,r){if(typeof e=="string"){if(t==="path")return Xp(px(e,n),r);let o=t==="rule"?Co(e):e;return Xp(gx(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=rm(e,r),i=[];for(let a of o){let c=ie(a,t,n,r);c!==void 0&&i.push(c)}return i}if(yt(e)){let o={};for(let[i,a]of Object.entries(e)){let c=ie(a,t,n,r);c!==void 0&&(o[i]=c)}return o}}s(ie,"transformValue");function qp(e,t,n){if(!yt(e))return ie(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a="plain";fx.has(o)?a="rule":o==="additionalDirectories"&&(a="path");let c=ie(i,a,t,n);c!==void 0&&(r[o]=c)}return r}s(qp,"transformPermissions");function _x(e,t,n){if(!yt(e))return ie(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){if(o==="files"&&Array.isArray(i)){let c=rm(i,n);r[o]=c.map(u=>{if(!yt(u))return ie(u,"plain",t,n);let f={};for(let[l,p]of Object.entries(u)){let m=ie(p,l==="path"?"path":"plain",t,n);m!==void 0&&(f[l]=m)}return f});continue}let a=ie(i,"plain",t,n);a!==void 0&&(r[o]=a)}return r}s(_x,"transformCredentials");function hx(e,t,n){if(!yt(e))return ie(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let c=ie(i,o==="allowUnixSockets"?"path":"plain",t,n);c!==void 0&&(r[o]=c)}return r}s(hx,"transformNetwork");function Sx(e,t,n){if(!yt(e))return ie(e,"plain",t,n);let r={};for(let[o,i]of Object.entries(e)){let a;o==="excludedCommands"?a=ie(i,"rule",t,n):o==="filesystem"?a=ie(i,"path",t,n):o==="network"?a=hx(i,t,n):o==="credentials"?a=_x(i,t,n):a=ie(i,"plain",t,n),a!==void 0&&(r[o]=a)}return r}s(Sx,"transformSandbox");function Ex(e,t,n,r,o){return n==="claude"?e==="permissions"?qp(t,r,o):e==="sandbox"?Sx(t,r,o):ie(t,"plain",r,o):n==="cursor_sandbox"?e==="additionalReadwritePaths"||e==="additionalReadonlyPaths"?ie(t,"path",r,o):ie(t,"plain",r,o):n==="cursor_permissions"?e==="terminalAllowlist"||e==="mcpAllowlist"?ie(t,"rule",r,o):ie(t,"plain",r,o):e==="permissions"?qp(t,r,o):ie(t,"plain",r,o)}s(Ex,"transformByProfile");function Yn(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(Yn,"jsonBytes");function Vi(e,t){return e?`${e}.${t}`:t}s(Vi,"childPath");function zi(e,t,n,r){if(Array.isArray(e)){for(let o=e.length-1;o>=0;o-=1){let i=e[o];i!==null&&typeof i=="object"&&(t+1>=Jp?(e.splice(o,1),r.add(n)):zi(i,t+1,n,r))}return}if(!(e===null||typeof e!="object"))for(let[o,i]of Object.entries(e))i!==null&&typeof i=="object"&&(t+1>=Jp?(delete e[o],r.add(Vi(n,o))):zi(i,t+1,Vi(n,o),r))}s(zi,"pruneDepth");function om(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))om(o,Vi(t,r),n)}s(om,"collectTrimCandidates");function yx(e,t,n){let r=Yn(e);if(r<=Gi)return;t.truncated=!0;let o=[];for(om(e,"",o);r>Gi;){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=Yn(a)+(i.items.length>0?1:0);i.bytes-=c,r-=c,n.add(i.path)}for(;Yn(e)>Gi;){let i,a=-1;for(let[c,u]of Object.entries(e)){let f=Yn(u);f>a&&(i=c,a=f)}if(i===void 0)break;delete e[i],n.add(i)}}s(yx,"fitSettingsJson");function Rx(e,t,n){let r=lx[t],o={truncated:!1},i={},a=[];for(let u of Object.keys(e)){if(!r.has(u)){a.push(u);continue}let f=Ex(u,e[u],t,n,o);f!==void 0&&(i[u]=f)}a.sort();let c=new Set;return zi(i,1,"",c),c.size>0&&(o.truncated=!0),yx(i,o,c),{settings:i,keys_omitted:a,truncated:o.truncated,trimmed_paths:[...c].sort()}}s(Rx,"extractSettingsPosture");function Zp(e,t){let n={kind:t.kind,name:"settings",path:e.componentPath(t.absPath),origin:t.origin,enabled:!0,content_hash:dx(t.attributes),attributes:t.attributes};e.push(n)}s(Zp,"pushPostureRow");function Ji(e,t,n,r){if(!e.claimFile(t)||!sx(t))return;let o=za(t);if(!o.ok||!yt(o.value)){if(r.profile){let f=!o.ok&&o.reason==="read"?"read_error":"parse_error",l={profile:r.profile,[f]:!0};r.managedSource&&(l.managed_source=r.managedSource),Zp(e,{kind:r.kind,absPath:t,origin:n,attributes:l})}return}let i=o.value,a=i.hooks;if(yt(a)&&$i(e,t,a,n),!r.profile)return;let c=Rx(i,r.profile,e.home),u={profile:r.profile,settings:c.settings,keys_omitted:c.keys_omitted};c.truncated&&(u.truncated=!0),c.trimmed_paths.length>0&&(u.trimmed_paths=c.trimmed_paths),r.managedSource&&(u.managed_source=r.managedSource),Zp(e,{kind:r.kind,absPath:t,origin:n,attributes:u})}s(Ji,"collectSettingsFile");import{existsSync as Cx}from"node:fs";import{join as Ke}from"node:path";var sm=".claude/skills/synced",im=".claude/plugins/synced";function am(e){return[Ke(e,sm),Ke(e,im)]}s(am,"claudeSyncedDirs");function bo(e){return typeof e=="string"&&e.length>0?e:void 0}s(bo,"stringField");function cm(e){let t=Ke(e.home,sm);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ke(t,n.name),o=e.readJson(Ke(r,"manifest.json"),{}),i=new Map((o?.skills??[]).flatMap(a=>a.name?[[a.name,a]]:[]));for(let a of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}let c=Ke(r,a.name,"SKILL.md");if(!a.isDirectory()||!Cx(c))continue;let u=i.get(a.name),f=bo(u?.source),l=bo(u?.creatorType);sn(e,{absolutePath:c,kind:"SKILL",origin:"user",enabled:!0,name:a.name,attributes:{scope:"synced",...f?{source:f}:{},...l?{creator_type:l}:{}}})}}}s(cm,"collectClaudeSyncedSkills");function um(e){let t=Ke(e.home,im);for(let n of e.readEntries(t)){if(!n.isDirectory()||n.name.startsWith("."))continue;let r=Ke(t,n.name),o=e.readJson(Ke(r,"manifest.json"),{}),i=new Map((o?.plugins??[]).flatMap(a=>a.name?[[a.name,a]]:[]));for(let a of e.readEntries(r)){if(e.truncated)return;if(!a.isDirectory()||a.name.startsWith("."))continue;let c=i.get(a.name),u=bo(c?.marketplaceName),f=bo(c?.version),l=u?`${a.name}@${u}`:a.name,p=Ke(r,a.name),{componentCount:d,expandTruncated:m}=zn(e,p,`plugin:${l}`,!0);Jn(e,{pluginKey:l,rowPath:e.componentPath(p),enabled:!0,scope:"synced",version:f,marketplace:u,componentCount:d,expandTruncated:m,contentHash:te(`${l}|${f??""}|synced|${d}`)})}}}s(um,"collectClaudeSyncedPlugins");function bx(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:i}=t;for(let a of n.skillRoots)Ht(e,{dir:cn(r,a),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md",skipDirs:am(e.home)});for(let a of n.dirs)Ht(e,{dir:cn(r,a.dir),kind:a.kind,origin:o,enabled:!0,extensions:a.extensions});for(let a of n.memory){let c=Rp(a.map(u=>cn(r,u)));c&&sn(e,{absolutePath:c,kind:"MEMORY",origin:o,enabled:!0,name:Ax(c)})}for(let a of Yu(n))Ji(e,cn(r,a),o,{kind:"SETTINGS",profile:Qp(a)});for(let a of n.mcpJson??[])jp(e,cn(r,a),o);for(let a of n.mcpToml??[])Bp(e,cn(r,a),o);if(i){if(n.managed){for(let a of Ar(n.managed,process.platform,e.home))if(a.toLowerCase().endsWith(".json")){let c=em(n.managed,a);Ji(e,a,o,{kind:"MANAGED_SETTINGS",...c})}}n.plugins==="claude"?(Gp(e),um(e),cm(e)):n.plugins==="cursor"&&Wp(e)}}s(bx,"walkPlatformLayout");function lm(e,t){try{let n=new uo(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)bx(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){H("user_spec_scope",n);return}}s(lm,"walkScope");function Yi(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let u=lm(t,{layouts:Object.values(Xt),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:st,scopeRef:""});u&&(r.user=u)}let i=n.inGitRepo===!0,a=null,c=n.launchCwd;if(c!==void 0){let u=Object.values(mt),f=di({launchCwd:c,gitRoot:n.gitRoot,inGitRepo:i,remote:n.remote,home:t,hasProjectSpec:s(l=>qu(u,l),"hasProjectSpec")});a=f.parentRel;for(let l of f.anchors){let p=ei(l.dir);if(o!==void 0&&!o(l.scope,p))continue;let d=lm(t,{layouts:u,levelDir:l.dir,origin:l.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:pi,scopeRef:p});d&&(r[l.scope]=d)}r.parent||(a=null)}return{scopes:r,parentRel:a,cwdInGitRepo:i}}s(Yi,"collectUserSpec");function Xi(e,t,n={}){let r=n.truncated===!0,o=Un(e),i=new Set(e.map(l=>xe(l.path,l.name)));if(n.forceFull===!0||t===void 0)return{hash:o,count:e.length,truncated:r,full:!0,upserts:e,removed:[],unchanged:!1};let c=[],u=t;for(let l of e){let p=xe(l.path,l.name);u[p]!==oo(l)&&c.push(l)}let f=[];if(!r){for(let l of Object.keys(u))if(!i.has(l)){let p=Vf(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(Xi,"diffUserSpec");var dm=2*1024*1024,kx=new Set(["HOOK","MCP_SERVER","PLUGIN","SETTINGS","MANAGED_SETTINGS"]);function qi(e,t,n){let r=new Set(t.map(i=>xe(i.path,i.name))),o=[];for(let i of e)i.text!==void 0&&(n.has(i.content_hash)||r.has(xe(i.path,i.name))||o.push(i));return o}s(qi,"collectPendingTextBodies");function Zi(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(Zi,"pruneDeliveredTextHashes");function fm(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}s(fm,"jsonSize");function pm(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}s(pm,"withoutText");function Qi(e,t=dm){let n=[],r=[];for(let l of e)kx.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=fm(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=pm(l),g=fm(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(Qi,"fitUserSpecWithinBudget");function ea(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:pm(n))}s(ea,"stripAlreadyDeliveredText");var xx=["user","cwd","repo","parent"];function ta(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,i=[];for(let O of xx){let x=t.scopes[O];if(!x)continue;let L=n(O,x.scopeRef),v=L.components,I=Xi(x.components,v,{forceFull:v===void 0,truncated:x.truncated}),N=new Set(L.textHashes),F=qi(x.components,I.upserts,N),_=ea([...I.upserts,...F],N);i.push({scope:O,walk:x,delta:I,outgoing:_,outgoingKeys:new Set(_.map(T=>xe(T.path,T.name))),deliveredTextHashes:N,cachedComponents:v})}let a=i.flatMap(O=>O.outgoing),c=Qi(a,o),u=new Set(c.components.map(O=>xe(O.path,O.name))),f=[],l=[],p=[],d=[],m=[],g=[],h=[];for(let O of i){let{scope:x,walk:L,delta:v}=O;g.push(...L.components),f.push(x);let I=c.components.filter(T=>O.outgoingKeys.has(xe(T.path,T.name))),N=[...O.outgoingKeys].some(T=>!u.has(T)),F=v.truncated||N;F?p.push(x):v.full&&l.push(x),d.push(...I),!v.full&&!F&&m.push(...v.removed);let _=v.full?{}:{...O.cachedComponents??{}};if(!F)for(let T of v.removed)delete _[xe(T.path,T.name)];for(let T of I)_[xe(T.path,T.name)]=oo(T);h.push({scope:x,scopeRef:L.scopeRef,components:_,textHashes:Zi(O.deliveredTextHashes,I.filter(T=>T.text!==void 0).map(T=>T.content_hash),L.components),collectedAtMs:r,included:I.length>0||v.removed.length>0&&!F||v.full})}let y={user_spec_hash:Un(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 k=t.scopes.cwd;k&&(y.user_spec_cwd_scope_ref=k.scopeRef);let P=t.scopes.repo;P&&(y.user_spec_repo_scope_ref=P.scopeRef);let w=t.scopes.parent;return w&&(y.user_spec_parent_scope_ref=w.scopeRef,t.parentRel&&(y.user_spec_parent_rel=t.parentRel)),{fields:y,scopes:h}}s(ta,"buildUserSpecSend");var ko={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function na(e){return e==="cwd"||e==="repo"||e==="parent"}s(na,"isProjectSpecScope");function Xn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}s(Xn,"isPlainObject");function ra(e){return!Xn(e)||!Xn(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(ra,"isDirScopeCacheEntry");function mm(e){return Ox(e)}s(mm,"readStringHashMap");function gm(e){return Ix(e)}s(gm,"readStringArray");function _m(e){return Tx(e)}s(_m,"cloneDirScopeMap");function Ox(e){if(!Xn(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}s(Ox,"readComponentHashMap");function Ix(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}s(Ix,"readTextHashes");function hm(e,t){if(!Xn(e))return;let n=e[t];return ra(n)?n:void 0}s(hm,"readDirScopeCacheEntry");function Tx(e){if(!Xn(e))return{};let t={};for(let[n,r]of Object.entries(e))ra(r)&&(t[n]=r);return t}s(Tx,"readDirScopeCacheMap");function oa(e,t=20){let n=[];for(let[r,o]of Object.entries(e))ra(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(oa,"boundDirScopeCache");var Lx=["allow","deny","ask"];function Oo(e){let t=Z(e,{}),n=[];for(let r of Lx)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:Co(o),mode:r});return{model:t.model??"",permissionKeys:n}}s(Oo,"readClaudeSettings");function Mx(e){let{serverManaged:t,fileBased:n}=Cn(process.platform,e),r=Oo(t);if(r.model||r.permissionKeys.length>0)return r;let o="",i=[];for(let a of n){let c=Oo(a);c.model&&(o=c.model),i.push(...c.permissionKeys)}return{model:o,permissionKeys:i}}s(Mx,"readClaudeManagedSettings");function Hx(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(Hx,"dedupePermissionKeys");var Ux=10,Dx="self-config-cache.json",Em=5;function ln(){return D("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}s(ln,"isUserSpecDisabled");function Fx(){return D("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}s(Fx,"isCwdSpecDisabled");var $x={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function jx(e,t=se){let n=$x[e];if(!n||n.length===0)return null;let r=s(async o=>{let i=n[o];if(i===void 0)return null;let c=((await t(i,["--version"],2e3)).split(`
|
|
52
|
+
`)[0]??"").trim();return c||r(o+1)},"tryNext");return r(0)}s(jx,"resolveCliVersion");function Bx(e=Sm()){return un(e,".ev-ai","agent-hook",Dx)}s(Bx,"selfConfigCachePath");function Kx(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
|
|
53
|
+
`);return te(n)}s(Kx,"hashConfigEntries");function xo(e,t,n=!1){let r=Kx(e),o=e.length;return t===r?n?{hash:r,count:o,truncated:n}:{hash:r,count:o}:n?{hash:r,count:o,entries:e,truncated:n}:{hash:r,count:o,entries:e}}s(xo,"buildHashedList");function sa(e,t,n=[]){let r=0,o=!1,i=new Set;for(let a of[...t.map(c=>un(e,c)),...n]){let c=vx(a);if(i.has(c))continue;i.add(c);let u=Go(a);u.present&&(o=!0,r+=u.size)}return o?{present:!0,size:r}:{present:!1,size:0}}s(sa,"filePresenceUnion");function Gx(e){return wx(e)?Te(Nx(e,"utf8"),{}):{}}s(Gx,"readSelfConfigCache");function Wx(e,t){try{le(e,`${JSON.stringify(t)}
|
|
54
|
+
`)}catch(n){let r=n instanceof Error?n.message:String(n);R(`WARN: self-config cache write failed open: ${r}`),H("self_config_cache",n)}}s(Wx,"writeSelfConfigCache");function Vx(e,t,n){if(t==="user")return{components:mm(e.user_spec_components),textHashes:gm(e.user_spec_text_hashes)};if(!na(t))return{components:void 0,textHashes:[]};let r=hm(e[ko[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}s(Vx,"cacheSliceFor");function zx(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=Em,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(!na(i.scope))continue;let a=ko[i.scope],c=_m(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]=oa(c)}}return o}s(zx,"nextPlatformSelfConfigCache");async function ym(e,t=process.cwd(),n=Sm(),r={}){let o=e==="claude",i=r.gitRoot??t,a=await jx(e),c="",u=[];if(o){let F=Mx(n),_=Oo(un(n,".claude/settings.json")),T=Oo(un(t,".claude/settings.local.json"));c=F.model||T.model||_.model,u=Hx([...F.permissionKeys,..._.permissionKeys,...T.permissionKeys]).slice(0,200)}let f={present:!1,size:0},l=s(F=>{let _=[],T=!1;for(let j of F){let Ee=Ja(un(n,j));if(_=_.concat(Ee.entries),T=T||Ee.truncated,_.length>=st){_=_.slice(0,st),T=!0;break}}return{entries:_,truncated:T}},"listScopeWithMeta"),p=Bx(n),d=Gx(p),m=d[e]??{},g=(m.send_count??0)+1,h=g>0&&g%Ux===0,y=s(F=>h?void 0:m[F],"cachedHash"),k=l(_t.skills),P=l(_t.subagents),w=l(_t.commands),O=l(_t.rules),x={skills:xo(k.entries,y("skills"),k.truncated),subagents:xo(P.entries,y("subagents"),P.truncated),commands:xo(w.entries,y("commands"),w.truncated),rules:xo(O.entries,y("rules"),O.truncated)},L={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:sa(n,_t.memory),settings:sa(n,_t.settings,Zu(n)),mcp:sa(n,_t.mcp)},local_settings:o?Go(un(t,".claude/settings.local.json")):f},v=null,I=r.nowMs??Date.now();if(!ln()){let F=m.user_spec_layout_version!==Em,_=Yi(e,n,{launchCwd:Fx()?void 0:r.launchCwd,gitRoot:i,inGitRepo:r.inGitRepo,remote:r.remote});if(Object.keys(_.scopes).length>0){let T=ta({collected:_,cacheFor:s((j,Ee)=>F?{components:void 0,textHashes:[]}:Vx(m,j,Ee),"cacheFor"),nowMs:I});Object.assign(L,T.fields),v={hash:T.fields.user_spec_hash,home:T.scopes.find(j=>j.scope==="user")??null,project:T.scopes.filter(j=>j.scope!=="user")}}}let N=zx(m,x,g,v);return{config:L,commit:s(()=>{d[e]=N,Wx(p,d)},"commit")}}s(ym,"selfConfig");import{homedir as pO}from"node:os";import{join as Am}from"node:path";function Dt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}s(Dt,"isRecord");import{join as Io}from"node:path";function Jx(e){return Io(e,".ev-ai","agent-hook","js","signed-v1")}s(Jx,"jsRoot");function Yx(e){return Io(Jx(e),"scopes")}s(Yx,"scopesRoot");function Rm(e,t){return Io(Yx(e),t)}s(Rm,"scopeDir");function Cm(e){return Io(e,"attempts")}s(Cm,"attemptsDir");function ia(e){return String(e).padStart(10,"0")}s(ia,"padAttempt");var Xx=/^(\d{10})$/,qx=/^(\d{10})\.done$/,Zx=/^[0-9a-f]{128}$/,Qx=64,Om=["check_ms","download_ms","install_ms","total_ms"],eO=36e5;async function Im(e,t,n=!1){let r=Cm(t),o=await ka(e,r),i=new Map,a=new Map,c=bm(o,Xx),u=bm(o,qx),f=s(async d=>{let m=await xm(e,Am(r,tO(d)));return m&&i.set(d,{record:rO(m.value),mtimeMs:m.mtimeMs}),m!==void 0},"readClaimAt"),l=s(async d=>{let m=oO((await xm(e,Am(r,nO(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([km(c,f),km(u,l)]);let p=qn(i);return p<qn(a)&&u.includes(p)&&await l(p),{claims:i,dones:a}}s(Im,"scanAttempts");function bm(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}s(bm,"attemptNumbers");async function km(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}s(km,"firstFromTop");function qn(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}s(qn,"maxKey");function Tm(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(Tm,"claimStartMs");function Pm(e){let t={};e.started_at!==void 0&&(t.started_at=e.started_at);for(let n of Om){let r=e[n];r!==void 0&&(t[n]=r)}return t}s(Pm,"pickTimings");function tO(e){return ia(e)}s(tO,"claimFileName");function nO(e){return`${ia(e)}.done`}s(nO,"doneFileName");async function xm(e,t){let n;try{n=await e.stat(t)}catch(o){if(Bt(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>Do)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>Do?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}s(xm,"readRecord");function rO(e){if(!Dt(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(rO,"parseClaim");function oO(e){if(!Dt(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=iO(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n,...sO(t)}}s(oO,"parseDoneRecord");function sO(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 Om){let r=e[n];typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&r<=eO&&(t[n]=r)}return t}s(sO,"parseTimings");function iO(e){if(!Dt(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"&&Zx.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.sha512=="string"&&aO(t.sha512)===t.digest)return{kind:"cached",digest:t.digest,version:t.version,sha512:t.sha512}}s(iO,"parseSelection");function aO(e){if(e.length===0||!/^[A-Za-z0-9+/]+=*$/.test(e))return;let t=Buffer.from(e,"base64");if(!(t.byteLength!==Qx||t.toString("base64")!==e))return t.toString("hex")}s(aO,"canonicalSha512Hex");function fO(e){return e==="bootstrap"?3e3:6e4}s(fO,"ownerBudgetMs");function dO(e,t){let n=qn(e.claims);if(n===0)return;let r=qn(e.dones),o=e.claims.get(n),i=e.dones.get(n);if(o&&!i){let c=Tm(o),u=o.record==="empty"?void 0:o.record.owner,f=fO(u)+3e4;if(t-c>f)return{n,latest_claim:n,outcome:"incomplete",finished_at:null,selection_version:wm(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:wm(a.selection),...Pm(a)}}s(dO,"latestAttemptReport");async function Nm(e,t,n){try{let r=await Im(xa(),Rm(e,t),!0);return dO(r,n)}catch{return}}s(Nm,"readLatestAttemptReport");function wm(e){return e?.kind==="cached"&&typeof e.version=="string"?e.version:null}s(wm,"selectionVersion");function mO(e=process.env){if(Object.values(mc).some(n=>e[n]))return"plugin";let t=e.npm_lifecycle_script?.trim().split(/\s+/)[0]?.replace(/^["']|["']$/g,"");return e.npm_lifecycle_event==="npx"&&t===Ae?"npx":null}s(mO,"hookDelivery");async function vm(e=pO()){let t=Vs()?.launcherScope;if(!t)return{};let n=await Nm(e,t,Date.now());return n?{launcher_scope:t,launcher_attempt:n}:{launcher_scope:t}}s(vm,"readSessionStartLauncherFields");function fn(e,t,n){let r={installation_id:n.installationId};n.platformAgentId&&(r.platform_agent_id=n.platformAgentId),n.sessionId&&(r.session_id=n.sessionId),n.turnId&&(r.turn_id=n.turnId);let o={schema_version:at,event:e,timestamp:lr(),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:me,hook_delivery:mO(),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=Vs();return i&&(o.launcher_version=i.launcherVersion,o.hook_source=i.hookSource,o.hook_fallback_reason=i.fallbackReason??null,o.launcher_scope_match=gf(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(fn,"buildEnvelope");import{existsSync as Fm}from"node:fs";import{spawn as $m}from"node:child_process";import{fileURLToPath as vO}from"node:url";import{gzipSync as gO}from"node:zlib";function aa(e){return D("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<dc?{body:e}:{body:gO(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}s(aa,"gzipBodyIfLarge");function To(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}s(To,"collectorPostHeaders");function ca(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}s(ca,"postBodyByteLength");var Ft=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 Lm(e,t){for(let n of[t,t.toUpperCase()]){let r=e[n]?.trim();if(r)return{name:n,value:r}}}s(Lm,"envValue");function Po(e){let t=e.toLowerCase().replace(/\.$/,"");return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}s(Po,"bareHost");function _O(e){let t=Po(e);return t==="localhost"||t.endsWith(".localhost")||t==="::1"||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t)}s(_O,"isLoopbackHost");function hO(e,t){let n=Po(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(hO,"noProxyMatches");function SO(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(SO,"parseProxyUrl");function Hm(e,t=process.env,n){if(e.protocol!=="https:"&&e.protocol!=="http:"||_O(e.hostname))return;let r=Lm(t,`${e.protocol.slice(0,-1)}_proxy`);if(!r)return;let o=Lm(t,"no_proxy");if(o&&hO(e,o.value))return;let i=SO(r.value);return n?.(i?`${e.host} via proxy ${i.protocol}//${i.host}`:`ignoring ${r.name}: not an http(s) URL`),i}s(Hm,"proxyForUrl");function Mm(e){try{return decodeURIComponent(e)}catch{return e}}s(Mm,"decodeUserinfo");function Um(e){if(!e.username&&!e.password)return;let t=`${Mm(e.username)}:${Mm(e.password)}`;return`Basic ${Buffer.from(t,"utf8").toString("base64")}`}s(Um,"proxyAuthorization");var EO=16*1024;async function yO(e,t,n){let[r,o]=await Promise.all([import("node:net"),import("node:tls")]),i=Po(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",P),d.setTimeout(0),d.removeListener("data",w),!0),"settle"),y=s(O=>{h()&&(d.destroy(),f(O))},"fail"),k=s(O=>{h()&&u(O)},"succeed"),P=s(()=>{y(l?.reason)},"onAbort");function w(O){g=Buffer.concat([g,O]);let x=g.indexOf(`\r
|
|
55
|
+
\r
|
|
56
|
+
`);if(x<0){g.length>EO&&y(new Ft("EPROXY_CONNECT","proxy CONNECT reply too large"));return}let L=Number(/^HTTP\/1\.[01] (\d{3})/.exec(g.toString("latin1",0,x))?.[1]??0);if(L<200||L>299){y(new Ft(L===407?"EPROXY_AUTH":"EPROXY_CONNECT",`proxy answered CONNECT with HTTP ${L||"garbage"}`,L||void 0));return}d.removeListener("data",w),d.pause(),x+4<g.length&&d.unshift(g.subarray(x+4));let v=Po(e.hostname);k(o.connect({socket:d,host:v,servername:c(v),ca:n.ca}))}s(w,"onData"),d.on("error",O=>{let x=O!==null&&typeof O=="object"&&"code"in O&&typeof O.code=="string"?O.code:"error";y(new Ft("EPROXY_UNREACHABLE",`proxy connection failed (${x})`))}),d.on("close",()=>{y(new Ft("EPROXY_UNREACHABLE","proxy closed the connection"))}),p!==void 0&&d.setTimeout(p,()=>{y(new Ft("EPROXY_TIMEOUT","proxy did not answer in time"))}),l?.addEventListener("abort",P,{once:!0}),d.once(t.protocol==="https:"?"secureConnect":"connect",()=>{if(e.protocol!=="https:"){k(d);return}let O=`${e.hostname}:${e.port||"443"}`,x=Um(t);d.on("data",w),d.write(`CONNECT ${O} HTTP/1.1\r
|
|
57
|
+
Host: ${O}\r
|
|
58
|
+
${x?`Proxy-Authorization: ${x}\r
|
|
59
|
+
`:""}\r
|
|
60
|
+
`)})})}s(yO,"openProxySocket");async function RO(e,t,n,r){let o=await import("node:http"),i=await yO(e,t,n),a=e.protocol==="https:",c=Um(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(RO,"requestViaProxy");var CO=new Set([101,103,204,205,304]);function AO(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(AO,"requestBody");function bO(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(bO,"codingsToUndo");function kO(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(kO,"decoderFor");async function xO(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(CO.has(n))return e.resume(),new Response(null,r);let o=await import("node:stream"),i=e,a=bO(t.get("content-encoding"));if(a){let c=await import("node:zlib"),u=a.map(f=>kO(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(xO,"toResponse");function OO(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=AO(n.body),new Headers(n.headers).forEach((y,k)=>{u[k]=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}),RO(e,t,{method:n.method,headers:u,signal:o,ca:r},y=>{p=y,y.once("close",d),xO(y).then(k=>m(()=>i(k)),k=>{y.destroy(),g(k)})}).then(y=>{if(f){y.destroy();return}l=y,y.on("error",g),y.end(c)},g)})}s(OO,"fetchOnce");var IO=new Set([301,302,303,307,308]),TO=20,PO=["content-type","content-encoding","content-language","content-location","content-length"];function wO(e,t){try{return new URL(e,t)}catch{return}}s(wO,"resolveLocation");async function NO(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 OO(u,f,p,r.ca):await fetch(u,p),m=d.headers.get("location");if(o==="manual"||!IO.has(d.status)||m===null)return d;await d.body?.cancel();let g=wO(m,u),h=o==="error"?"unexpected redirect":l>=TO?"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 k of PO)i.delete(k)}g.origin!==u.origin&&(i.delete("authorization"),i.delete("cookie")),u=g,f=Hm(u,r.env??process.env,r.debug)}}s(NO,"fetchViaProxy");function Dm(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=Hm(o,r,n);return i?NO(o,i,t,{env:r,debug:n}):fetch(e,t)}s(Dm,"fetchWithEnvProxy");var dn="__post",pn="__work";async function LO(e,t,n={}){if(ln())return e;let r=await ni(n.gitRoot??process.cwd(),se,process.env,{runnerPlatform:t,home:n.home,context:n.context}),o=Dt(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(LO,"attachOperatorIdentity");function MO(e,t){let n=Dt(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(MO,"debugEnvelopeSummary");function jm(e){switch(e){case"session_start":return cc;case"session_end":return uc;case"tool_invoked":case"skill_invoked":return Yo;default:return Yo}}s(jm,"timeoutForEvent");function HO(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
|
|
61
|
+
${n}`}s(HO,"frameDetachedPostStdin");function Bm(e,t=[],n=process.execPath,r=import.meta.url,o=Fm){if(Er(n))return{command:n,args:[e,...t]};let i=vO(r);return o(i)?{command:n,args:[i,e,...t]}:{command:n,args:[e,...t]}}s(Bm,"resolveSelfReexecCommand");function UO(e=process.execPath,t=import.meta.url,n=Fm){let r=process.argv.includes("--debug")?["--debug"]:[];return Bm(dn,r,e,t,n)}s(UO,"resolveSelfPostCommand");function DO(e){let t=e.indexOf(`
|
|
62
|
+
`);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(DO,"parseDetachedPostStdin");function FO(e){D("EV_AI_HOOK_DEBUG")&&R(`DEBUG: ${e}`)}s(FO,"debugProxy");var Km=s((e,t)=>Dm(e,t,FO),"collectorFetch");function Gm(e){D("EV_AI_HOOK_DEBUG")&&R(`DEBUG: send fail ${On(e)}`)}s(Gm,"debugFailedPost");async function Wm(e,t){if(!(!e.ok||typeof e.text!="function"))try{let n=await e.text();hu(n,t)}catch(n){H("collector_response",n)}}s(Wm,"applyCollectorHttpResponse");function Vm(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(Vm,"errorParts");var zm=1e3;function Jm(e,t){let n=e instanceof Error&&e.name==="TimeoutError"?"timeout":"post_failed";ee({outcome:n,postMs:t,err:lt(e)})}s(Jm,"noteFailedPost");async function wo(e,t=Km){try{let n=await e(),r=DO(n);if(!r){ue.error("send fail code=bad-frame message=detached post stdin was not framed"),ee({outcome:"post_failed",err:"bad-frame"});return}let{meta:o,body:i}=r,a=aa(i),c=To(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,zm).replace(/[\n\r]/g,"");ue.error(`send fail http=${f.status} code=${f.status} body=${p}`),ee({outcome:"post_failed",postMs:l,http:f.status});return}ue.info(`send ok http=${f.status}`),ee({outcome:"posted",postMs:l,http:f.status}),await Wm(f,o.url)}catch(f){let l=Vm(f);ue.error(`send fail code=${l.code??"(none)"} ${On(f)}`),Gm(f),Jm(f,performance.now()-u)}}catch(n){H("post",n),ee({outcome:"error",err:lt(n)})}finally{Jt("post",me,"error")}}s(wo,"runDetachedPoster");async function $O(e,t,n,r=Km){let o=jm(e),i=aa(t),a=To(i.contentEncoding),c=ca(i.body);R(`POST event=${e} url=${Wt(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{}R(`POST gzip rejected http=${l.status} \u2014 retrying uncompressed`),l=await r(n,{method:"POST",headers:To(),body:t,signal:AbortSignal.timeout(o)})}let p=Date.now()-u,d=performance.now()-f;if(Ys(d),l.ok)return R(`POST outcome=ok elapsed_ms=${p} http=${l.status}`),ue.info(`send ok http=${l.status}`),ee({outcome:"posted",postMs:d,http:l.status}),await Wm(l,n),!0;let m=(await l.text()).slice(0,zm).replace(/[\n\r]/g,"");return R(`POST outcome=fail elapsed_ms=${p} http=${l.status} body=${m}`),ue.error(`send fail http=${l.status} code=${l.status} body=${m}`),ee({outcome:"post_failed",postMs:d,http:l.status}),!1}catch(l){let p=Date.now()-u,d=performance.now()-f;Ys(d);let m=Vm(l);return R(`POST outcome=fail elapsed_ms=${p} http=000 body=${m.message}`),ue.error(`send fail http=0 code=${m.code??"(none)"} ${On(l)}`),Gm(l),Jm(l,d),!1}}s($O,"postCollector");async function Ym(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=>{H(i,u)}),a.stdin.on("error",u=>{H(`${i}_stdin`,u)});let c=!1;return await new Promise(u=>{let f=setTimeout(()=>{if(!c){R(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`),ue.error(`failed where=${i} err=timeout message=stdin handoff timed out`);try{a.stdin.destroy()}catch{}}u()},lc),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 R(`WARN: ${o} spawn failed open: ${c}`),H(i,a),null}}s(Ym,"spawnDetachedStdinChild");async function jO(e,t,n,r=$m,o=UO){let i=jm(e),a=HO(n,i,t),{command:c,args:u}=o();return Ym(c,u,a,r,"detached post")}s(jO,"postCollectorDetached");async function Xm(e,t,n=$m,r=Bm){let{command:o,args:i}=r(pn,t);return Ym(o,i,e,n,"detached work")}s(Xm,"runHookDetached");async function mn(e,t,n,r,o,i,a,c){if(!o)return R("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),ue.error("send fail code=missing message=collector URL missing"),ee({outcome:"no_collector",err:"missing"}),!1;if(!Sr(o))return R(`WARN: collector URL blocked (https required): ${Wt(o)}`),ue.error("send fail code=blocked message=collector URL blocked"),ee({outcome:"no_collector",err:"blocked"}),!1;let u=performance.now(),f=await LO(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=yf({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}
|
|
63
|
+
`,y=D("EV_AI_HOOK_DEBUG");y==="full"?R(`DEBUG envelope=${m}`):y==="1"&&R(`DEBUG summary=${MO(p,ca(h))}`);let k=process.argv.includes(pn),P=D("EV_AI_HOOK_SYNC")==="1";if(!(Jr(n.runnerEvent,n.runnerPlatform)||k||P)){let O=await jO(e,h,o);return ee(O?.pid!==void 0?{outcome:"handed_off"}:{outcome:"post_failed",err:"spawn"}),!1}return $O(e,h,o)}s(mn,"emitAndPost");import{closeSync as BO,fstatSync as KO,linkSync as GO,openSync as WO,readdirSync as VO,readSync as zO,renameSync as JO,unlinkSync as rg}from"node:fs";import{homedir as YO}from"node:os";import{basename as XO,dirname as qO}from"node:path";var qm=is,Zm=2*1024*1024,ZO=Buffer.byteLength(',"run_log":',"utf8");function Qm(e){let t=`${e}.send-${process.pid}`;try{return JO(e,t),{path:e,taken:t}}catch(n){return n.code==="ENOENT"?"missing":"busy"}}s(Qm,"take");function eg(e){return typeof e=="object"}s(eg,"isTaken");function QO(e){let t=`${XO(e)}.`;try{return VO(qO(e)).some(n=>n.startsWith(t)&&/\.send-\d+$/.test(n))}catch{return!1}}s(QO,"anyTakenLog");function eI(e){try{GO(e.taken,e.path),rg(e.taken)}catch{}}s(eI,"putBack");function tI(e){try{rg(e)}catch{}}s(tI,"unlinkQuiet");function tg(e,t){let n;try{n=WO(e,"r");let r=KO(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=zO(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{BO(n)}catch{}}}s(tg,"readTail");function nI(e){let t=e.indexOf(10);return t===-1?e:e.subarray(t+1)}s(nI,"fromFirstWholeLine");function ng(e,t,n){ls(r=>{r[t]===n&&delete r[t]},e)}s(ng,"forgetWindow");function og(e,t=YO(),n=process.env,r=Date.now()){try{let o=e?bt(e):void 0;if(!o||Gc())return;let i=us(t)[o];if(i===void 0||i===zt)return;let a=Date.parse(i);if(Number.isNaN(a)||a>r)return;let c=jc(t,n,r);if(c.on||c.source!=="remote")return;let u=Tr(t),f=Qm(u),l=Qm(`${u}.1`),p=eg(f)?f:void 0,d=eg(l)?l:void 0,m=[d,p].filter(N=>N!==void 0),g=s(()=>{for(let N of m)eI(N)},"putAllBack"),h=p?tg(p.taken,qm):void 0,y=d?tg(d.taken,qm-(h?.tail.length??0)):void 0,k=(h?.size??0)+(y?.size??0);if(k===0){g(),f!=="busy"&&l!=="busy"&&!QO(u)&&ng(t,o,i);return}let P=Buffer.concat([y?.tail??Buffer.alloc(0),h?.tail??Buffer.alloc(0)]),w=P.length<k,O=w?nI(P):P,x={log_until:i,text:O.toString("utf8"),bytes:O.length,bytes_total:k,truncated:w},L=ZO+Buffer.byteLength(JSON.stringify(x),"utf8"),v=!1,I=!1;return{attach(N){if(N+L>Zm){R(`run log deferred: body=${N} run_log=${L} over ${Zm}`);return}return v=!0,x},settle(N){if(!I){if(I=!0,!(v&&N)){g();return}for(let F of m)tI(F.taken);ng(t,o,i)}}}}catch(o){R(`WARN: run log upload failed open: ${o instanceof Error?o.message:String(o)}`);return}}s(og,"prepareRunLogUpload");import{createReadStream as rI}from"node:fs";import{stat as oI}from"node:fs/promises";import{basename as sI,resolve as iI}from"node:path";import{createInterface as aI}from"node:readline";var cI=1024*1024;function uI(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&sI(t).endsWith(".jsonl")}s(uI,"isSafeClaudeTranscriptPath");async function sg(e){if(!e||!uI(e))return null;try{let t=iI(e),n=await oI(t);if(!n.isFile())return null;let r=Math.max(0,n.size-cI),o=[],i=aI({input:rI(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(sg,"lastAssistantModelFromTranscript");function No(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent,promptCaptureSource:so(e.manifest.manifest,e.manifest.hookConfig),telemetry:cg(e)}}s(No,"envelopeFieldsFromContext");function cg(e){return Eu(e.manifest.localTelemetry,e.manifest.hookConfig)}s(cg,"telemetryFor");function la(e){return kr({sessionId:e.sessionId,hostname:ts()})}s(la,"runnerContextOf");function Qn(e,t,n=la(e)){return{gitRoot:e.manifest.gitRoot,...t?{home:t}:{},context:n}}s(Qn,"operatorContextFrom");function fa(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo,runnerEvent:e.runnerEvent,promptCapture:ui(e.manifest.hookConfig)}}s(fa,"hookInputSanitizeOptions");async function ug(e){let t=Date.now();await RI(e);let{gitRoot:n}=e.manifest;await pa(e,n);let r=fa(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:ao(e.hookInput,e.manifest.manifest,r),envelopeFields:No(e),launchCwd:li(e.hookInput,r),home:fI()}}s(ug,"prepareDerivedInvoke");function ig(e){try{return ke(lI(e))}catch{return null}}s(ig,"tryRealpath");function lg(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}s(lg,"isAbsolutePath");function ag(e,t){let n=e.replaceAll("\\","/");if(!lg(n))return null;let r=ke(e),o=ke(t),i=ig(e)??r,a=ig(t)??o;return i.startsWith(`${a}/`)?i.slice(a.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}s(ag,"relativeToAnchor");function fg(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),i=ag(e,t)??(lg(r)?null:r),a=ag(e,n);return{repositorySourcePath:i,userSourcePath:a}}s(fg,"sourcePathsFromResolvedFile");function ua(e,t,n,r,o){return dg(e,fg(n,t.gitRoot,t.home),r,o)}s(ua,"exactFileComponentFromResolvedPath");function dg(e,{repositorySourcePath:t,userSourcePath:n},r,o){let i=t??n,a=i===null?null:o(i),c=a!==null&&i!==null?dI({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(dg,"exactFileComponent");function dI(e){try{let t=e.inRepository?gI(e.platformAgentId,e.sourcePath):(0,W.installationRootExternalKey)(e.installationId,(0,W.userConfigRootFromPath)(e.sourcePath));return t?(0,W.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}s(dI,"tryExactFileComponentReference");function pg(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(pg,"policyPayload");function da(e,t,n){return mn("tool_invoked",{...n,...pg(e),success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,fn,e.manifest.collectorUrl,t.buildStartedAtMs,Qn(e,t.home))}s(da,"postDerivedToolInvoked");function pI(e){return $l(e.runnerEvent,e.runnerPlatform)?[]:sl(e.hookInput)}s(pI,"slashIdsFromHookInput");function mI(e,t){return da(e,t,{})}s(mI,"postPromptSubmitted");var mg=new Set([...Object.values(Nt),".github"]);function gI(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=>mg.has(a));return i<0?null:`${r}:${o.slice(0,i+1).join("/")}`}s(gI,"repositoryConfigRootExternalKey");var gg=".codex/config.toml",_I=new Map([["claude_json_user",".claude.json"],["cursor_mcp_user",".cursor/mcp.json"],["codex_toml_user",gg]]);function hI(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?_I.get(u.source):o==="codex"?gg:void 0,l=u?.sourcePath??f;if((u?.scope==="user"||f!==void 0)&&l)try{let h=(0,W.userConfigRootFromPath)(l);return(0,W.buildComponentReference)({installationRootExternalKey:(0,W.installationRootExternalKey)(r,h),installableKind:W.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||!mg.has(g)))try{return(0,W.buildComponentReference)({installationRootExternalKey:n,installableKind:W.ComponentKind.INTERFACE,sourcePath:m,nativeKey:t})}catch{return}}s(hI,"exactMcpComponentReference");function SI(...e){for(let t of e)if(t)return t;return null}s(SI,"firstNonEmpty");function jt(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return R(`WARN: ${n} failed open: ${r}`),H(n,e.reason),t}s(jt,"settledOr");function EI(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(EI,"emptySelfConfigResult");function yI(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}s(yI,"cloudBootstrapSelfConfig");var $t=new Set,Zn=null;async function RI(e){if(ln())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if($t.has(t))return;if(!oi(n)){$t.add(t);return}let r=String(e.runnerPlatform),o=la(e);if(Jf(o,r)){if(Zn){await Zn;return}Zn=(async()=>{if($t.has(t)||!oi(n)){$t.add(t);return}if(!uu(n)){$t.add(t);return}let i=!1;try{let a=Date.now(),{gitRoot:c}=e.manifest,{operatorResolved:u,fields:f}=await _g(e,o,De("git",()=>Vr(c)),De("operator",()=>ri({gitRoot:c,installationStorePath:n,forceResend:!1,runnerPlatform:r,context:o}))),l={...f,self_config:yI(r,u.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};i=!!await mn("session_start",l,No(e),fn,e.manifest.collectorUrl,a,Qn(e,void 0,o)),i&&(u.commit(),$t.add(t))}finally{lu(n)}})().finally(()=>{Zn=null}),await Zn}}s(RI,"maybeBootstrapCloudIdentity");async function pa(e,t,n){try{e.platformAgentId=await Pl(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);R(`WARN: derivePlatformAgentId failed open: ${o}`),H("platform_agent_id",r)}}s(pa,"resolvePlatformAgentId");async function _g(e,t,n,r){let[o,i,a,c,u]=await Promise.allSettled([n,De("virt",()=>kc()),De("cloud",()=>Cf(t)),De("host_env",()=>Oc(cg(e).enabled)),r]),f=jt(o,null,"gitSnapshot"),l=jt(i,"","detectVirt"),p=jt(a,null,"probeCloud"),d=jt(c,{},"hostEnv"),m=jt(u,{commit:s(()=>{},"commit")},"resolveOperatorForSend");return await pa(e,e.manifest.gitRoot,f),{operatorResolved:m,fields:{identity:{host:ts(),context:t,virt:l||null,cloud:p,git:f},host_env:d,env_vars:Tf()}}}s(_g,"collectIdentityPayload");async function CI(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=la(e),o=String(e.runnerPlatform),i=fa(e),a=li(e.hookInput,i),c=De("git",()=>Vr(n)),u=vm().catch(v=>(H("launcher_fields",v),{})),f=ln()?Promise.resolve({commit:s(()=>{},"commit")}):De("operator",()=>ri({gitRoot:n,installationStorePath:e.manifest.installationStorePath,forceResend:!1,runnerPlatform:o,context:r})),l=_g(e,r,c,f),[p,d]=await Promise.allSettled([De("mcp_declared",()=>qs(e.manifest.manifest,n,o)),c.catch(()=>null).then(v=>De("self_config",()=>ym(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:a,inGitRepo:e.manifest.inGitRepo,remote:v?.remote??null})))]),{operatorResolved:m,fields:g}=await l,h=jt(p,[],"mcpDeclared"),y=jt(d,EI(o),"selfConfig"),k=y.config,P=$(e.hookInput,"model");P&&(k.model=P);let w={...g,mcp:{declared:h},self_config:k,run_meta:{trigger:e.hookSource||"startup"},hook_input:ao(e.hookInput,e.manifest.manifest,{...i,launchCwd:a})},O=await u,x=og(e.manifest.collectorUrl),L=!1;try{L=await mn("session_start",w,{...No(e),...O},fn,e.manifest.collectorUrl,t,Qn(e,void 0,r),x)}finally{x?.settle(L)}L&&(y.commit(),m.commit(),$t.add(e.manifest.installationId))}s(CI,"handleSessionStart");async function AI(e){let t=Date.now(),[,n]=await Promise.all([pa(e,e.manifest.gitRoot),e.runnerPlatform==="claude"?sg($(e.hookInput,"transcript_path")):null]),r=e.runnerEvent.toLowerCase(),o=SI($(e.hookInput,"status"),$(e.hookInput,"stop_reason"),$(e.hookInput,"reason"),Nn($(e.hookInput,"error")),r==="stop"?Ve(e.hookInput,"is_interrupt")===!0?"interrupted":"completed":""),i=ao(e.hookInput,e.manifest.manifest,fa(e));n&&(i.model=n),r!=="stopfailure"&&so(e.manifest.manifest,e.manifest.hookConfig)!=="off"&&i.last_assistant_message===void 0&&(i.last_assistant_message=""),await mn("session_end",{status:o,...n?{model:n}:{},hook_input:i},No(e),fn,e.manifest.collectorUrl,t,Qn(e))}s(AI,"handleSessionEnd");async function bI(e){let t=pI(e),n=Ll(e.hookInput),r=Fl(e.runnerEvent),o=r&&t.length===0&&n.length===0;if(t.length===0&&n.length===0&&!r||o&&so(e.manifest.manifest,e.manifest.hookConfig)==="off")return;let i=await ug(e);await Promise.all([o?mI(e,i):void 0,t.length===0?void 0:kI(e,i,t),n.length===0?void 0:xI(e,i,n)])}s(bI,"handleSkillInvoked");function hg(e,t,n,r){let o=r??ol({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),i=ua(e,t,o,W.ComponentKind.SKILL,W.nativeKeyForSkillPath);if(i.sourcePath!==null&&Os(i.sourcePath)?.toLowerCase()===n.toLowerCase())return i.componentReference===void 0?{}:{componentReference:i.componentReference};let a=r??Ml({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),c=ua(e,t,a,W.ComponentKind.COMMAND,W.nativeKeyForCommandPath);return c.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:c.nativeKey,...c.componentReference===void 0?{}:{componentReference:c.componentReference}}}s(hg,"slashComponentIdentity");function kI(e,t,n){let r=Fr(e.hookInput.tool_input);return Promise.all(n.map(o=>{let i=hg(e,t,o,r);return da(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(kI,"postSkillInvokes");function xI(e,t,n){return Promise.all(n.map(r=>{let o=wl({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),i=ua(e,t,o,W.ComponentKind.RULE,W.nativeKeyForRulePath),a=i.nativeKey??vl(r);return da(e,t,{tool_name:"Rule",rule_name:a,...i.componentReference===void 0?{}:{component_reference:i.componentReference}})}))}s(xI,"postRuleInvokes");var OI=[{kind:W.ComponentKind.SKILL,nativeKeyFn:W.nativeKeyForSkillPath},{kind:W.ComponentKind.RULE,nativeKeyFn:W.nativeKeyForRulePath},{kind:W.ComponentKind.COMMAND,nativeKeyFn:W.nativeKeyForCommandPath}];function II(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Ts(e.hookInput);if(r===null)return n.skillName===null?{}:hg(e,t,n.skillName,null);let o=fg(r,t.gitRoot,t.home);for(let i of OI){let a=dg(e,o,i.kind,i.nativeKeyFn);if(a.nativeKey!==null)return{...a.componentReference===void 0?{}:{componentReference:a.componentReference},...i.kind===W.ComponentKind.RULE?{ruleName:a.nativeKey}:{},...i.kind===W.ComponentKind.COMMAND?{commandName:a.nativeKey}:{}}}return{}}s(II,"toolComponentIdentity");var TI=/mcp/i;function PI(e,t,n,r){let o=TI.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let i=o?Fp(t,n):Ro(r.declaredConfig,n);return i===null?{}:Object.fromEntries(Object.entries(i).filter(a=>typeof a[1]=="string").map(([a,c])=>[`mcp_${a}`,c]))}s(PI,"mcpPackageFields");async function wI(e){let t=await ug(e),n=Kl(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,i=Is(e.hookInput),a=Up(i,t.home),c=Wl(e.hookInput),u=jl(e.runnerEvent),f=u===!1?Vl(e.hookInput,e.runnerEvent):null,l=Nn($(e.hookInput,"mcp_server_name")),p=l!==null||r!==null&&Xr(r)?await qs(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(L=>(H("mcpDeclared",L),[])):[],{mcpServer:d,mcpTool:m}=Jl(r,p.map(L=>L.name),l??""),g=hI(r,d,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),p,l),h=g===void 0?II(e,t,n):{},y=d===null?null:If(d,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),k=PI(e,i,t.home,{hasMcpIdentity:!!d||!!m,declaredConfig:y}),P=g??h.componentReference,w=h.ruleName??n.ruleName,O=h.commandName??n.commandName,x=Gl(e.hookInput);await mn("tool_invoked",{tool_name:r,skill_name:o,...w?{rule_name:w}:{},...O?{command_name:O}:{},success:u,duration_ms:c,...a?{executable:a}:{},...f?{failure_reason:f}:{},...d?{mcp_server:d}:{},...m?{mcp_tool:m}:{},...k,...P?{component_reference:P}:{},...x?{subagent_type:x}:{},...pg(e),hook_input:t.hookInput},t.envelopeFields,fn,e.manifest.collectorUrl,t.buildStartedAtMs,Qn(e,t.home))}s(wI,"handleToolInvoked");async function Sg(e){switch(Je("w3"),e.internalEvent){case"session_start":await CI(e);return;case"session_end":await AI(e);return;case"skill_invoked":await bI(e);return;case"tool_invoked":await wI(e);return;default:return}}s(Sg,"dispatchInternalEvent");import{mkdirSync as NI,readdirSync as vI,readFileSync as LI,statSync as Eg,unlinkSync as MI,writeFileSync as HI}from"node:fs";import{homedir as vo}from"node:os";import{join as ma}from"node:path";var UI="turns",yg=1440*60*1e3,DI=100,FI=new Set(["stop","stopfailure","sessionend"]);function ga(e=vo()){return ma(Re(e),UI)}s(ga,"sessionTurnDir");function Rg(e,t){return ma(e,yn(t))}s(Rg,"sessionTurnPath");function $I(e,t=Date.now()){let n;try{n=vI(e)}catch{return}let r=0;for(let o of n){if(r>=DI)return;r+=1;try{let i=ma(e,o);t-Eg(i).mtimeMs>yg&&MI(i)}catch{}}}s($I,"pruneStaleSessionTurns");function jI(e,t,n=vo()){let r=e.trim(),o=t.trim();if(!(!r||!o))try{let i=ga(n);NI(i,{recursive:!0}),HI(Rg(i,r),o,"utf8")}catch{}}s(jI,"rememberSessionTurn");function BI(e,t=vo()){let n=e.trim();if(!n)return"";try{let r=Rg(ga(t),n);return Date.now()-Eg(r).mtimeMs>yg?"":LI(r,"utf8").trim()}catch{return""}}s(BI,"recallSessionTurn");function Cg(e,t,n,r=vo()){let o=t.trim(),i=FI.has(n.trim().toLowerCase());return i&&$I(ga(r)),o?(jI(e,o,r),o):i?BI(e,r):""}s(Cg,"resolveTurnId");function xg(e){let t=Te(e,{});return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}s(xg,"parseHookInput");async function KI(e,t,n){let r=t??await dr(yr),o=xg(r),i=await Ru(process.cwd(),{sessionId:tn(o)});if(Je("w2"),!i){ee({outcome:"no_manifest"});return}let a=Bl(o,i.manifest.platform,n),c=Yr(e,a.runnerEvent);if(!c){R(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`),ee({outcome:"unknown_event"});return}ee({runner:a.runnerPlatform,event:c,session:a.sessionId});let u={hookInput:o,sessionId:a.sessionId,turnId:Cg(a.sessionId,a.turnId,a.runnerEvent),runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:c,manifest:i,platformAgentId:i.platformAgentId};await Sg(u)}s(KI,"runHook");function GI(e,t=!1){if(D("EV_AI_HOOK_SYNC")==="1")return!0;let{parsed:n,hookInput:r,runnerEvent:o}=e,i=en(r,o,void 0,n.runner);return Jr(o,i)?!0:t}s(GI,"shouldRunHookInProcess");function Ag(e,t){let n=_r(e),r=xg(t),o=n.event??Ds(r);return Ac()||Dl(n.runner,r,o)?null:{parsed:n,hookInput:r,runnerEvent:o}}s(Ag,"preflight");function Og(e){return af(Yr(e.parsed.event,e.runnerEvent))}s(Og,"isCapExempt");async function bg(e,t,n){let{parsed:r}=e,o=n??Gs(r.slot);if(!o&&!Og(e)){let i=Ks(r.cap),a=pf(i);if(!a){Ws(i),ee({outcome:"cap_dropped"});return}o=a}try{await KI(r.event,t,r.runner)}finally{o&&Qr(o)}}s(bg,"runHookInSlot");var Lo,gn=!1,WI=500;function VI(){let e=s(()=>{process.exit(0)},"exitNow");setTimeout(e,WI);try{process.stdout.write('{"continue":true}',e)}catch{e()}}s(VI,"ackThenExit");function Ig(e,t){let n=e[0]===pn?"w":e[0]===dn?"post":"h";Lo=void 0,gn=!1;let r=s(a=>c=>{try{H(a,c),Wc()||(ee({outcome:"error",err:lt(c)}),Jt(Lo??n,me,"error"))}catch{}if(t){if(n==="h"&&!gn){gn=!0,VI();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(Ig,"installCrashLogging");async function Tg(e=process.argv.slice(2),t=!1){if(t||Pr(e),wc(),Lo=void 0,gn=!1,Je(e[0]===pn?"w0":"h0"),mf(),D("EV_AI_HOOK_JUDGE")==="1"){try{await dr(yr)}catch{}return Bo(),gn=!0,0}if(e[0]===dn){try{await wo(Rn)}catch{}return 0}if(e[0]===pn){let i=!1;try{let a=await Rn();Je("w1");let c=Ag(e.slice(1),a);if(!c)return ee({outcome:"suppressed"}),0;kg(c),i=Yr(c.parsed.event,c.runnerEvent)==="session_start",await bg(c,a)}catch(a){let c=a instanceof Error?a.message:String(a);R(`WARN: detached work failed open: ${c}`),H("work",a),ee({outcome:"error",err:lt(a)})}finally{Jt("w",me,"no_post"),i&&zc()}return 0}let n,r="error",o=!1;try{Vc();let i=await dr(yr);Je("h1");let a=Ag(e,i);if(!a)return r="suppressed",0;kg(a);let{parsed:c,hookInput:u,runnerEvent:f}=a;if(n=Gs(c.slot),!Ql(u,f,c.runner))return r="duplicate",0;if(Je("h2"),GI(a))o=!0,Lo="inproc",r="no_post",await bg(a,i,n);else{let l=n||Og(a)?void 0:Ks(c.cap);if(l===void 0||ff(l)){Je("h3"),Sf();let p=await Xm(i,e);n&&p?.pid!==void 0&&uf(n,p.pid),p?.pid!==void 0?r="handed_off":(r="error",ee({err:"spawn"}))}else Ws(l),r="cap_dropped"}}catch(i){let a=i instanceof Error?i.message:String(i);R(`WARN: hook failed open: ${a}`),H("hook",i),r="error",ee({outcome:"error",err:lt(i)})}finally{n&&Qr(n),Bo(),gn=!0,ee({ackMs:performance.now()}),Jt(o?"inproc":"h",me,r)}return 0}s(Tg,"main");function kg({parsed:e,hookInput:t,runnerEvent:n}){ee({runner:en(t,n,void 0,e.runner),event:n,session:tn(t),tool:typeof t.tool_name=="string"?t.tool_name:void 0})}s(kg,"noteInvocation");function Mo(){R("Usage: ev-ai-agent-hook <configure|install|migrate-to-plugin|update|uninstall|--version>"),R(" configure [--url <\u2026/{orgToken}/hook>]"),R(" (manifest only \u2014 pair with marketplace plugins)"),R(" install --url <\u2026/{orgToken}/hook>"),R(" [--delivery npx|binary|local] [--force]"),R(" [--no-claude] [--no-cursor] [--no-codex]"),R(" (fallback: merge hooks into .claude / .cursor / .codex configs)"),R(" (writes collector_url to shared manifest; hook commands use --runner only)"),R(" migrate-to-plugin"),R(" (strip ev-ai file hooks; keep collector manifest)"),R(" update (refresh binary pins from a local build; leaves hook configs alone)"),R(" uninstall"),R("Hook mode: --runner <platform> [--url <\u2026/hook>|--token <orgToken>] [event]"),R(" (--url/--token optional overrides; else collector_url from manifest)")}s(Mo,"printHelp");var qI=new Set(["configure","install","migrate-to-plugin","update","uninstall","help","--help","-h","--version","-V"]);function ZI(e){let[t]=e;return t!==void 0&&!qI.has(t)}s(ZI,"isHookModeArgv");function Pg(e){return e.includes("--help")||e.includes("-h")}s(Pg,"wantsHelp");async function QI(e=process.argv.slice(2)){Pr(e);let[t,...n]=e;if(t===dn){try{await wo(Rn)}catch(r){H("post",r)}return 0}return t==="--version"||t==="-V"?(process.stdout.write(`${me}
|
|
64
|
+
`),0):t==="configure"?Pg(n)?(Mo(),0):(await Ku(Tu(n)),0):t==="install"?Pg(n)?(Mo(),0):(await ju(Pu(n)),0):t==="migrate-to-plugin"?(await Wu(),0):t==="update"?(await Bu(),0):t==="uninstall"?(await Vu(),0):t==="help"||t==="--help"||t==="-h"?(Mo(),0):t===void 0?(Mo(),1):Tg(e,!0)}s(QI,"main");function eT(e,t,n=zI){if(!t)return!1;try{return e===XI(JI(t)).href?!0:n(YI(e))===n(t)}catch{return!1}}s(eT,"isCliEntrypoint");if(eT(import.meta.url,process.argv[1])&&process.env.VITEST===void 0){let e=process.argv.slice(2);ZI(e)&&Ig(e,!0),QI(e).then(t=>{process.exit(t)}).catch(t=>{H("entry",t);let n=t instanceof Error?t.message:String(t);R(n),process.exit(1)})}export{eT as isCliEntrypoint,ZI as isHookModeArgv,QI as main};
|