@ev-ai/agent-hook 1.0.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hook.mjs CHANGED
@@ -1,27 +1,28 @@
1
1
  import { createRequire as __createRequire } from 'node:module';
2
2
  const require = __createRequire(import.meta.url);
3
3
 
4
- var mo=Object.create;var Yt=Object.defineProperty;var go=Object.getOwnPropertyDescriptor;var _o=Object.getOwnPropertyNames;var ho=Object.getPrototypeOf,Eo=Object.prototype.hasOwnProperty;var Xt=(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 So=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ro=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _o(t))!Eo.call(e,o)&&o!==n&&Yt(e,o,{get:()=>t[o],enumerable:!(r=go(t,o))||r.enumerable});return e};var Io=(e,t,n)=>(n=e!=null?mo(ho(e)):{},Ro(t||!e||!e.__esModule?Yt(n,"default",{value:e,enumerable:!0}):n,e));var lr=So(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.ComponentKind=void 0;L.userConfigRootFromPath=fi;L.installationRootExternalKey=pi;L.normalizeRepositoryRelativePath=ar;L.nativeKeyForSkillPath=mi;L.serializeComponentIdentity=cr;L.buildComponentReference=_i;L.validateComponentReference=hi;var si=Xt("node:crypto"),ii=Xt("node:path"),ai="cmp1_",ci=/^cmp1_[A-Za-z0-9_-]{43}$/,li=["/skills/","/skills-cursor/"],ui=[".cursor",".claude",".codex"],di={".claude.json":".claude",".agents":".codex"};L.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE"};function fi(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>ui.includes(o));return n||(t.map(o=>di[o]).find(o=>o!==void 0)??"unknown")}function pi(e,t){return`runtime-install:${e}/${t}`}function we(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function ar(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=ii.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return we(n,"sourcePath")}function mi(e){let t=e.replaceAll("\\","/");for(let n of li){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function gi(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function cr(e){let t=[we(e.installationRootExternalKey,"installationRootExternalKey"),we(e.installableKind,"installableKind"),ar(e.sourcePath),we(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(gi).join("|")}`,"utf8")}function _i(e){let t=(0,si.createHash)("sha256").update(cr(e)).digest("base64url");return`${ai}${t}`}function hi(e){return ci.test(e)}});import{existsSync as vo,readFileSync as wo}from"node:fs";import{hostname as rn,userInfo as bo}from"node:os";import{randomBytes as yo}from"node:crypto";import{existsSync as Je,mkdirSync as Co,readdirSync as Ao,readFileSync as To,renameSync as Zt,statSync as en,unlinkSync as qt,writeFileSync as Oo}from"node:fs";import{basename as ko,dirname as Qt,join as tn,relative as xo}from"node:path";function _(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
5
- `)}function G(e,t){Co(Qt(e),{recursive:!0});let n=tn(Qt(e),`.${ko(e)}.${process.pid}.${yo(4).toString("hex")}.tmp`);try{Oo(n,t,"utf8");try{Zt(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){qt(e),Zt(n,e);return}throw r}}catch(r){try{qt(n)}catch{}throw r}}function Ie(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}function nn(){process.stdout.write('{"continue":true}')}function A(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function Ye(){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 Xe(e){return new Promise(t=>{let n="",r=!1,o=a=>{r||(r=!0,clearTimeout(s),t(a||"{}"))},s=setTimeout(()=>{o(n)},e);if(process.stdin.isTTY){o("{}");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",a=>{n+=a}),process.stdin.on("end",()=>{o(n)}),process.stdin.on("error",()=>{o(n)}),process.stdin.resume()})}async function P(e,t,n=3e3,r={}){let{execFile:o}=await import("node:child_process"),{promisify:s}=await import("node:util"),a=s(o);try{let{stdout:i}=await a(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:i.trim()}}catch(i){let c=i,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 T(e,t,n=3e3,r={}){let o=await P(e,t,n,r);return o.ok?o.stdout:""}async function Ze(e=process.cwd()){let t=await P("git",["rev-parse","--show-toplevel"],2e3,{cwd:e});if(t.ok&&t.stdout)return{root:t.stdout,inGitRepo:!0};if(A("EV_AI_HOOK_DEBUG")){let r=t.ok?"empty stdout":t.spawnFailed?"spawn failed":`exit ${String(t.code??"unknown")}`;_(`DEBUG: git rev-parse --show-toplevel failed (${r}) cwd=${e}`)}let n=A("CURSOR_PROJECT_DIR")??A("CLAUDE_PROJECT_DIR");if(n&&Je(n)){let r=await P("git",["rev-parse","--show-toplevel"],2e3,{cwd:n});return r.ok&&r.stdout?{root:r.stdout,inGitRepo:!0}:{root:n,inGitRepo:!1}}return{root:e,inGitRepo:!1}}async function qe(e=process.cwd()){return(await Ze(e)).root}function b(e,t){try{return JSON.parse(e)}catch{return t}}var We=new Map;function q(e,t){let n=We.get(e);if(n!==void 0)return n;try{let r=b(To(e,"utf8"),t);return We.set(e,r),r}catch{return We.set(e,t),t}}function z(e){return typeof e=="string"?e:""}function V(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 p(e,t){let n=V(e,t);return typeof n=="string"?n:""}var H=500;function ie(e,t=2){if(!Je(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,a)=>{if(a>t||r)return;let i;try{i=Ao(s,{withFileTypes:!0})}catch{return}for(let c of i){if(r)return;let l=tn(s,c.name);if(c.isDirectory()){o(l,a+1);continue}if(c.isFile()){try{n.push({name:xo(e,l),size:en(l).size})}catch{continue}if(n.length>=H){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function ae(e){return Je(e)?{present:!0,size:en(e).size}:{present:!1,size:0}}function Q(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function Qe(e=process.env){return Q(y("CURSOR_SANDBOX",e))}var No=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function Uo(e){return No.some(t=>!!y(t,e))}function Po(e){if(y("KUBERNETES_SERVICE_HOST",e)||Q(y("REMOTE_CONTAINERS",e))||Q(y("DEVCONTAINER",e)))return!0;try{if(vo("/.dockerenv")||wo("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function on(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!y(t,e))}function Lo(e,t=process.platform){return on(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!y(n,e)):!1}function Mo(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function Do(e){return e==="linux"}function y(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return A(e)}function Ho(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Fo(y("CURSOR_VERSION",n))}function Fo(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function et(e){if(Mo(e.sessionId))return!0;let t=e.hostname??rn(),n=e.osUser??sn(e.env);return Ho(t,n,e.env)}function $o(e){return Q(y("CURSOR_AGENT",e.env))?!0:et(e)}function Bo(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(y("TERM",e)??y("TERM_PROGRAM",e))||(y("SSH_TTY",e)??y("SSH_CONNECTION",e))||(y("__CFBundleIdentifier",e)??y("XPC_SERVICE_NAME",e))||on(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!y(t,e))||y("SESSIONNAME",e))}function ce(e={}){let t=e.env;if(y("GITHUB_ACTIONS",t))return"github_actions";if(Q(y("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!Lo(t,n)&&$o(e)&&(Q(y("CURSOR_AGENT",t))||Do(n)))return"cursor_cloud";if(y("CODESPACES",t)||y("CODESPACE_NAME",t))return"codespaces";if(y("GITLAB_CI",t))return"gitlab_ci";if(Uo(t))return"managed";let r=y("CI",t);return r&&r!=="false"&&r!=="0"?"managed":Po(t)?"container":Bo(t)?"interactive":"unknown"}async function tt(){return await T("systemd-detect-virt",[],1e3)}function sn(e=process.env,t=bo){for(let n of["USER","LOGNAME","USERNAME"]){let r=e[n];if(typeof r=="string"){let o=r.trim();if(o.length>0)return o}}try{return t().username??""}catch{return""}}async function nt(){let e=process.platform==="darwin"?"Darwin":process.platform==="win32"?"Windows_NT":"Linux",t="";if(process.platform==="darwin")t=await T("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:s}=await import("node:fs"),a=s("/etc/os-release","utf8"),i=a.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],c=a.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];t=i??c??""}catch{t=await T("lsb_release",["-sd"],1e3).then(s=>s.replace(/^"|"$/g,""))}t||(t=await T("uname",["-r"],1e3))}else t=await T("ver",[],1e3);let n=sn(),r=(process.env.SHELL??"").split(/[/\\]/).pop()??"",o="";try{o=await T("tty",[],500),o.includes("not a tty")&&(o="")}catch{o=""}return{os:e,os_version:t||null,user:n||null,shell:r||null,tty:o||null}}function le(){return rn()}var Ko="https://hooks.ev-ai.ai";function ye(e,t=Ko){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}var an=".claude/ev-ai-runtime-report.json";var Ce="ev-ai-agent-hook";var Xc=`current/${Ce}`,Zc=`.ev-ai/agent-hook/${Ce}`,cn=5e3,ln=5e3,rt=3e3;var ot=3e3,un=1500,dn=4*1024,fn=32*1024,Go=4*1024,st="1.0.9",qc=`@ev-ai/agent-hook@${st}`;var pn=["claude","cursor","codex"];import{createHash as $s}from"node:crypto";import{existsSync as Bs,mkdirSync as Ks,readdirSync as Gs,readFileSync as Qn,unlinkSync as er,writeFileSync as js}from"node:fs";import{homedir as tr}from"node:os";import{join as _t}from"node:path";import{createHash as En,randomBytes as Vo}from"node:crypto";import{existsSync as Sn,mkdirSync as it,readFileSync as Rn,unlinkSync as In,writeFileSync as yn}from"node:fs";import{homedir as at}from"node:os";import{dirname as Ae,join as ct,resolve as Wo}from"node:path";var jo=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),zo=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function W(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||zo.has(n)||r.includes("[bot]")||jo.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),s=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(s.endsWith("bot")||s.includes("[bot]"))return!0}return!1}var Jo="installation.json",Yo="cloud-bootstrap.lock",Xo=6e4;function Cn(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function ue(e=at()){return ct(e,".ev-ai","agent-hook")}function Zo(e=at()){return ct(ue(e),Jo)}function An(e){return ct(Ae(e),Yo)}function Tn(){return Vo(8).toString("hex")}function ee(e){return En("sha256").update(e).digest("hex").slice(0,16)}function S(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function On(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function qo(e=process.env){let t=S(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!On(t)){_(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}function kn(e,t){return e&&On(e)?e:(e&&_(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),qo(t))}function Qo(e){return/^[0-9a-f]{16}$/.test(e)}function es(e=process.env){if(S(e.GITHUB_ACTIONS)){let t=S(e.GITHUB_REPOSITORY_ID)??S(e.GITHUB_REPOSITORY),n=S(e.GITHUB_ACTOR)??S(e.GITHUB_TRIGGERING_ACTOR)??S(e.GITHUB_USER);if(t&&n)return ee(`github_actions|${t}|${n}`)}if(S(e.CODESPACES)||S(e.CODESPACE_NAME)){let t=S(e.CODESPACE_NAME);if(t)return ee(`codespaces|${t}`);let n=S(e.GITHUB_REPOSITORY_ID)??S(e.GITHUB_REPOSITORY),r=S(e.GITHUB_USER)??S(e.GITHUB_ACTOR);if(n&&r)return ee(`codespaces|${n}|${r}`)}if(S(e.GITLAB_CI)){let t=S(e.CI_PROJECT_ID)??S(e.CI_PROJECT_PATH),n=S(e.GITLAB_USER_LOGIN)??S(e.GITLAB_USER_EMAIL)??S(e.GITLAB_USER_NAME);if(t&&n)return ee(`gitlab|${t}|${n}`)}return null}var ts="cursoragent@cursor.com";function ns(e){let t=S(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===ts?null:t}function rs(e,t){return S(e.CURSOR_PROJECT_DIR)??S(e.CLAUDE_PROJECT_DIR)??t}function os(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1").replace(/\.git$/i,"").toLowerCase()}async function ss(e){let t=await T("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?os(t):e}async function is(e){let t=S(await T("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!W(null,t))return t;let n=S(await T("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!W(null,n)?n:null}function as(e,t){let n=rs(e,t);return n?ee(`cursor_cloud|${n}|${ns(e)??""}`):null}async function cs(e,t){let n=S(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await ss(n),o=await is(n);return ee(`claude_remote|${r}|${o??""}`)}function mn(e,t){let n=kn(e,t);if(n)return n;let r=es(t);return r||Tn()}async function ls(e){let n=await T("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||Wo(e);return En("sha256").update(n).digest("hex").slice(0,16)}function us(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 ds(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=us(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 J(e){if(Sn(e))try{return ds(Rn(e,"utf8"))}catch{}}function lt(e){return J(e)}function xn(e,t,n){let r=J(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{G(e,`${JSON.stringify(o,null,2)}
6
- `)}catch(s){let a=s instanceof Error?s.message:String(s);_(`WARN: operator identity cache write failed open: ${a}`)}}function vn(e,t=Date.now()){if(!e)return!0;if(J(e)?.operator_identity_hash)return!1;let n=An(e);try{if(Sn(n)){let r=Number.NaN;try{r=Number(Rn(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<Xo)return!1;try{In(n)}catch{}}}catch{}try{return it(Ae(n),{recursive:!0}),yn(n,`${t}
7
- `,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(Un(r))return!1;let o=r instanceof Error?r.message:String(r);return _(`WARN: cloud bootstrap claim failed open: ${o}`),!0}}function wn(e){if(e)try{In(An(e))}catch{}}function bn(e,t){let r=J(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}function Nn(e,t,n){if(!n)return;let r=J(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={installation_id:r.installation_id,platform_agent_ids:{...r.platform_agent_ids,[t]:n},...r.operator_identity_hash?{operator_identity_hash:r.operator_identity_hash}:{},...r.operator_identity_sent_at?{operator_identity_sent_at:r.operator_identity_sent_at}:{}};try{G(e,`${JSON.stringify(o,null,2)}
8
- `)}catch(s){let a=s instanceof Error?s.message:String(s);_(`WARN: platform_agent_id cache write failed open: ${a}`)}}function Un(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}function fs(e,t){it(Ae(e),{recursive:!0}),yn(e,`${JSON.stringify(t,null,2)}
9
- `,{encoding:"utf8",flag:"wx"})}function gn(e,t){try{return fs(e,t),t}catch(n){if(!Un(n))throw n;return J(e)}}function _n(e,t){it(Ae(e),{recursive:!0}),G(e,`${JSON.stringify(t,null,2)}
10
- `)}function hn(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}async function Pn(e,t={}){let n=t.home??at(),r=t.env??process.env,o=await ls(e),s=Zo(n),a={sessionId:t.sessionId,hostname:S(r.HOSTNAME)??void 0,osUser:S(r.USER)??S(r.LOGNAME)??S(r.USERNAME)??void 0,env:r},i=ce(a),c=kn(t.overrideId,r),l=i==="cursor_cloud"&&et(a)?as(r,e):i==="claude_remote"?await cs(r,e):null,u=J(s);if(u){let E=u;if(c&&c===u.installation_id&&u.pinned!==!0&&(E={...u,pinned:!0},_n(s,E)),!!l&&l!==E.installation_id&&!c&&E.pinned!==!0&&Qo(E.installation_id)&&l){let I={installation_id:l,...E.platform_agent_ids?{platform_agent_ids:E.platform_agent_ids}:{}};return _n(s,I),{installationId:l,storePath:s,repoKey:o}}return{installationId:E.installation_id,storePath:s,repoKey:o}}let d=c??l??mn(void 0,r),m=gn(s,hn(d,c));if(m)return{installationId:m.installation_id,storePath:s,repoKey:o};let f=c??l??mn(void 0,r),g=gn(s,hn(f===d?Tn():f,c));if(g)return{installationId:g.installation_id,storePath:s,repoKey:o};throw new Error(`Failed to create installation record at ${s}`)}var ps=new Set(["localhost","127.0.0.1","[::1]","::1"]),Ln=/^[A-Za-z0-9._~-]+$/;function Mn(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 Te(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?ps.has(t.hostname):!1}catch{return!1}}function Dn(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!Te(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=ms(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Ln.test(n))return`org token must match ${Ln.source} (got: ${n})`;if(Mn(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(Mn(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function Hn(e){return new URL(e).toString()}function ms(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.length>0?r:void 0}return}catch{return}}function ut(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 Fn(e){if(e.collector_url)return e.collector_url;let t=e.repo_ingest_token?.trim();return t?ye(t):""}var $n=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Bn=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,gs=/(?:^|\s)\/([a-z][a-z0-9-]{1,63})\b/gi,_s=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"]),hs=new Set(["read","read_file","view"]),Es=new Set(["bash","shell","zsh"]);function Ss(e){let t=e.replace(/\\/g,"/");return $n.exec(t)?.[1]??null}function Rs(e){let t=e.replace(/\\/g,"/"),r=Bn.exec(t)?.[1];return r?r.toLowerCase():null}function dt(e){return Ss(e)??Rs(e)}function Is(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 Oe(e){if(typeof e=="string")try{let t=JSON.parse(e);return Oe(t)}catch{return null}return!e||typeof e!="object"?null:Is(e)}function ys(e){if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}function Cs(e){let t=e.replace(/\\/g,"/"),n=$n.exec(t);if(n?.[1])return n[1];let o=Bn.exec(t)?.[1];return o?o.toLowerCase():null}function As(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function Kn(e){let t=As(e).toLowerCase();if(hs.has(t)){let n=Oe(e.tool_input)??z(e.file_path),r=n?dt(n):null;if(r)return r}if(Es.has(t)){let n=ys(e.tool_input)??z(e.command);return n?Cs(n):null}return null}function Ts(e){let t=new Set,n=[];for(let r of e.matchAll(gs)){let o=r[1]?.toLowerCase();!o||t.has(o)||_s.has(o)||(t.add(o),n.push(o))}return n}function Os(e){return z(e.prompt)}function Gn(e){let t=p(e,"command_name");if(t){let r=p(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=Os(e);return n?Ts(n):[]}function ft(e){return e!==void 0&&pn.includes(e)}function ke(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function xe(e){let t,n,r,o,s;for(let a=0;a<e.length;a++){let i=e[a];if(i!==void 0){if(i==="--runner"){let c=ke(e,a);t=c.value,a=c.next;continue}if(i.startsWith("--runner=")){t=i.slice(9);continue}if(i==="--url"){let c=ke(e,a);c.value&&(r=c.value),a=c.next;continue}if(i.startsWith("--url=")){r=i.slice(6);continue}if(i==="--token"){let c=ke(e,a);c.value&&(o=c.value),a=c.next;continue}if(i.startsWith("--token=")){o=i.slice(8);continue}if(i==="--base-url"){let c=ke(e,a);c.value&&(s=c.value),a=c.next;continue}if(i.startsWith("--base-url=")){s=i.slice(11);continue}!i.startsWith("-")&&n===void 0&&(n=i)}}return{runner:ft(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s}}function pt(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=ye(o,e.baseUrl?.trim()??void 0))}if(!n)return;let r=Dn(n);if(r){_(`WARN: ignoring --url/--token collector override: ${r}`);return}return Hn(n)}function jn(e,t){if(p(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function ks(){return!!(A("CURSOR_VERSION")??A("CURSOR_PROJECT_DIR"))}function mt(e,t,n){return e!=="claude"&&e!=="codex"?!1:jn(t,n)?!0:ks()}function de(e,t,n,r){if(jn(e,t))return"cursor";if(ft(r))return r;let o=p(e,"conversation_id"),s=p(e,"turn_id"),a=p(e,"session_id"),i=t.toLowerCase(),c="unknown";return o||t===i&&t!==""?c="cursor":s?c="codex":(a||i==="sessionstart"||i==="sessionend"||i==="stop"||i==="stopfailure"||i==="pretooluse"||i==="posttooluse"||i==="posttoolusefailure"||i==="permissiondenied"||i==="subagentstart"||i==="subagentstop"||i==="userpromptexpansion")&&(c="claude"),ft(n)&&(c=n),c}function ve(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function xs(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 zn(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function Vn(e,t,n){let r=p(e,"session_id")||p(e,"conversation_id"),o=p(e,"prompt.id")||p(e,"prompt_id")||p(e,"generation_id")||p(e,"turn_id"),s=p(e,"hook_event_name")||p(e,"event"),a=p(e,"source"),i=de(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:a,runnerPlatform:i}}var vs=["session_start","session_end","tool_invoked","skill_invoked"];function ws(e){return vs.includes(e)}function Wn(e,t){return e&&ws(e)?e:xs(t.toLowerCase())}var bs={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function Ns(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function Jn(e,t=""){let n=p(e,"tool_name")||p(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!Ns(n)&&(n=`MCP:${n}`):n=bs[r]??null;let o=e.tool_input,a=(o&&typeof o=="object"?z(o.skill)||z(o.skill_name):"")||p(e,"skill_name")||null,i=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;return a??=Kn(i),{toolName:n,skillName:a}}var Us=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function Yn(e){for(let t of["subagent_type","agent_type"]){let n=p(e,t);if(n&&Us.test(n))return n}return null}function Xn(e){let t=V(e,"duration_ms");if(typeof t=="number")return t;let n=V(e,"duration");return typeof n=="number"?n:null}var Ps="error",Ls="interrupted",Ms="permission_denied",Ds=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function gt(e){return Ds.test(e)?e:null}function Hs(e){for(let t of["failure_type","error_type"]){let n=gt(p(e,t));if(n)return n}return null}function Zn(e,t){return V(e,"is_interrupt")===!0?Ls:t.toLowerCase()==="permissiondenied"?Ms:Hs(e)??Ps}function Fs(e,t){let n=null;for(let r of t)r&&(e===r||e.startsWith(`${r}_`)||e.startsWith(`${r}-`))&&(n===null||r.length>n.length)&&(n=r);return n}function qn(e,t=[]){if(!e)return{mcpServer:null,mcpTool:null};let n=/^mcp__(.+?)__(.+)$/i.exec(e);if(n?.[1]&&n[2])return{mcpServer:n[1],mcpTool:n[2]};if(/^MCP:/i.test(e)){let r=e.slice(4);if(!r)return{mcpServer:null,mcpTool:null};let o=r.indexOf(":");if(o>0)return{mcpServer:r.slice(0,o),mcpTool:r.slice(o+1)||null};let s=r.indexOf("__");return s>0?{mcpServer:r.slice(0,s),mcpTool:r.slice(s+2)||null}:{mcpServer:Fs(r,t),mcpTool:r}}return{mcpServer:null,mcpTool:null}}var nr=3e4,zs="claims",Vs=!0,Ws=100,Js=new Set(["sessionstart","sessionend","stopfailure"]),Ys=["tool_name","tool","command","file_path","url"];function Xs(e=tr()){return _t(ue(e),zs)}function rr(e){let t=e.split(`
11
- `,1)[0]??"";return Number(t.trim())}function or(e){return $s("sha256").update(e).digest("hex").slice(0,32)}function Zs(e){let t=[];for(let n of Ys){let r=p(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":or(t.join("\0"))}function qs(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),s=e.subagentId?.trim()??"",a=e.callFingerprint?.trim()??"",i=!!(o||r||s),c=Js.has(n);if(!i&&!c)return;let l=e.runnerPlatform.trim()||"unknown";return or(`${l}|${t}|${n}|${r}|${o}|${a}|${s}`)}function Qs(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}function ei(e,t){return _t(e,t)}function ti(e,t=Date.now()){let n;try{n=Gs(e)}catch{return}let r=0;for(let o of n){if(r>=Ws)break;r+=1;let s=_t(e,o),a=Number.NaN;try{a=rr(Qn(s,"utf8"))}catch{continue}let i=t-a;if(!(!Number.isFinite(i)||i<0||i<nr))try{er(s)}catch{}}}function ni(e,t,n=Date.now()){let r=ei(t,e);try{if(Bs(r)){let o=Number.NaN;try{o=rr(Qn(r,"utf8"))}catch{}let s=n-o;if(Number.isFinite(s)&&s>=0&&s<nr)return!1;try{er(r)}catch{}}}catch{}try{Ks(t,{recursive:!0}),js(r,`${n}
12
- `,{encoding:"utf8",flag:"wx"})}catch(o){if(Qs(o))return!1;let s=o instanceof Error?o.message:String(o);return _(`WARN: event claim failed open: ${s}`),!0}return ti(t,n),!0}function ri(e,t,n){let r=p(e,"session_id")||p(e,"conversation_id"),o=p(e,"prompt.id")||p(e,"prompt_id")||p(e,"generation_id")||p(e,"turn_id"),s=p(e,"tool_use_id"),a=p(e,"subagent_id")||p(e,"agent_id"),i=de(e,t,void 0,n),c=Zs(e);return{runnerPlatform:i,sessionId:r,runnerEvent:t,turnId:o,toolUseId:s,subagentId:a,callFingerprint:c}}function sr(e,t,n,r=tr(),o=Date.now()){if(!Vs)return!0;let s=qs(ri(e,t,n));if(!s)return!0;let a=ni(s,Xs(r),o);return!a&&A("EV_AI_HOOK_DEBUG")&&_(`DEBUG: duplicate hook event suppressed (claim ${s.slice(0,8)}\u2026)`),a}import{homedir as Cc}from"node:os";var ht={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function fe(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function oi(e){if(!e)return"";let t=e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1");t=t.replace(/\.git$/i,"");let n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return fe(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return fe(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?fe(o[1]):fe(t)}async function pe(e=process.cwd()){let t=await P("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([P("git",["remote","get-url","origin"],2e3,{cwd:e}),P("git",["branch","--show-current"],2e3,{cwd:e}),P("git",["rev-parse","HEAD"],2e3,{cwd:e}),P("git",["status","--porcelain"],2e3,{cwd:e})]),a=n.ok?n.stdout:null;return{remote:a===null?null:a.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1"),branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:s.ok?s.stdout.length>0:null}}async function ir(e,t,n,r=process.cwd(),o,s,a){if(t)return t;let i=ht[n];if(!i)return"";let c=Cn(n,e.scope_path,a);if(s){let g=bn(s,c);if(g)return g}let l=o??await pe(r),u=l?.remote?oi(l.remote):"";if(u||(u=fe(process.env.GITHUB_REPOSITORY??"")),!u)return"";let d=e.scope_path??"",m=d?`${d}/`:"",f=`${u}:${m}${i}`;return s&&Nn(s,c,f),f}var k=Io(lr(),1);import{existsSync as Ei,readFileSync as Si}from"node:fs";import{homedir as ur}from"node:os";import{join as Ri}from"node:path";var Ii="cloud-cache.json",yi=1440*60*1e3,Ci=900*1e3;function Ai(e=ur()){return Ri(ue(e),Ii)}function Ti(e){if(!Ei(e))return;let t=b(Si(e,"utf8"),{});if(!(typeof t.context!="string"||typeof t.probed_at!="number"||t.result!==null&&t.result!==void 0&&typeof t.result!="object"))return{context:t.context,probed_at:t.probed_at,result:t.result??null}}function Oi(e,t){try{G(e,`${JSON.stringify(t)}
13
- `)}catch(n){let r=n instanceof Error?n.message:String(n);_(`WARN: cloud cache write failed open: ${r}`)}}function ki(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?Ci:yi;return n-e.probed_at<r}async function xi(e){let t=await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"60"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=(await t.text()).trim();if(!n)return;let r={"X-aws-ec2-metadata-token":n},[o,s]=await Promise.all([fetch("http://169.254.169.254/latest/meta-data/placement/region",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{}),fetch("http://169.254.169.254/latest/meta-data/instance-id",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{})]);if(!o?.ok&&!s?.ok)return;let a=o?.ok?(await o.text()).trim():"",i=s?.ok?(await s.text()).trim():"";if(!(!a&&!i))return{provider:"aws",region:a,instance_id:i}}async function vi(e){let t=await fetch("http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true",{headers:{"Metadata-Flavor":"Google"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=typeof n.zone=="string"?n.zone.split("/").pop()??"":"",o=n.id===void 0?"":String(n.id);if(!(!r&&!o))return{provider:"gcp",region:r,instance_id:o}}async function wi(e){let t=await fetch("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{headers:{Metadata:"true"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=n.compute?.location??"",o=n.compute?.vmId??"";if(!(!r&&!o))return{provider:"azure",region:r,instance_id:o}}async function bi(e){let t=await Promise.allSettled([xi(e),vi(e),wi(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}async function Et(e,t){if(e==="interactive")return null;let n=t?.home??ur(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),s=Ai(n),a=Ti(s);if(ki(a,e,o))return a.result;let i=await bi(r);return Oi(s,{context:e,probed_at:o,result:i}),i}import{existsSync as Ni}from"node:fs";import{homedir as Ui}from"node:os";import{join as be}from"node:path";function Ne(e,t,n){if(!Ni(e))return;let r=q(e,{});for(let o of Object.keys(r.mcpServers??{}))n.set(o,{name:o,...t})}async function St(e,t=process.cwd(),n="claude",r=Ui()){let o=new Map;for(let s of e.mcp_servers??[])s.name&&o.set(s.name,{name:s.name,source:"manifest"});return n==="claude"?Ne(be(r,".claude.json"),{source:"claude_json_user"},o):n==="cursor"&&Ne(be(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),Ne(be(t,".mcp.json"),{source:"mcp_json"},o),Ne(be(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),[...o.values()]}var Pi=["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"],Li=["CURSOR_PROJECT_DIR"],Mi=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function Di(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)Mi.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}function Rt(e=process.env){let t=Pi.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:Di(e[r]??"")}:{name:r,present:!1}),n=Li.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}import{createHash as Hi}from"node:crypto";function O(e){return Hi("sha256").update(e).digest("hex").slice(0,16)}function $(e,t){return`${e}\0${t}`}function dr(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}function It(e){let n=[...e].sort((r,o)=>{let s=r.path.localeCompare(o.path);return s!==0?s:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
14
- `);return O(n)}function Fi(e,t,n="git_config",r=null){return O(`${e??""}|${t??""}|${r??""}|${n}`)}function $i(e){let t=null,n=null;for(let r of e.split(`
15
- `)){let o=r.trim();if(!o)continue;let s=o.indexOf(" ");if(s<=0)continue;let a=o.slice(0,s).toLowerCase(),i=o.slice(s+1).trim();i&&(a==="user.name"?t=i:a==="user.email"&&(n=i))}return{git_user_name:t,git_user_email:n,platform_login:null}}async function Bi(e,t=T){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return $i(n)}function Ki(e=process.env){let t=h(e.GIT_AUTHOR_NAME),n=h(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=h(e.GIT_COMMITTER_NAME),o=h(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=h(e.EMAIL);return s?{git_user_name:null,git_user_email:s,platform_login:null,identity_source:"git_env"}:null}function B(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 Gi(e=process.env){let t=B(h(e.EV_AI_HOOK_OPERATOR_NAME),h(e.EV_AI_HOOK_OPERATOR_EMAIL),"configured",h(e.EV_AI_HOOK_OPERATOR_LOGIN));if(t)return t;let n=h(e.GITHUB_ACTOR)??h(e.GITHUB_TRIGGERING_ACTOR)??h(e.GITHUB_USER),r=B(n,null,"github",n);if(r)return r;let o=h(e.GITLAB_USER_LOGIN),s=B(h(e.GITLAB_USER_NAME)??o,h(e.GITLAB_USER_EMAIL),"gitlab",o);if(s)return s;let a=B(h(e.BUILD_REQUESTEDFOR),h(e.BUILD_REQUESTEDFOREMAIL),"azure_devops",h(e.BUILD_REQUESTEDFORID));if(a)return a;let i=h(e.BUILDKITE_BUILD_CREATOR_EMAIL),c=B(h(e.BUILDKITE_BUILD_CREATOR),i,"buildkite",i);if(c)return c;let l=B(h(e.BUILD_USER)??h(e.CHANGE_AUTHOR),h(e.BUILD_USER_EMAIL)??h(e.CHANGE_AUTHOR_EMAIL),"jenkins",h(e.BUILD_USER_ID));if(l)return l;let u=h(e.CIRCLE_USERNAME),d=B(u,null,"circleci",u);if(d)return d;let m=h(e.CODEBUILD_INITIATOR),f=B(m,null,"codebuild",m);if(f)return f;let g=B(h(e.DRONE_COMMIT_AUTHOR)??h(e.DRONE_COMMIT_AUTHOR_NAME),h(e.DRONE_COMMIT_AUTHOR_EMAIL),"drone",h(e.DRONE_COMMIT_AUTHOR));if(g)return g;if(pr(e.CLAUDE_CODE_REMOTE)||pr(e.CURSOR_AGENT)){let E=h(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:E&&!W(null,E)?E:null,platform_login:null,identity_source:"cloud"}}return null}function fr(e){return!!((e.git_user_name??e.git_user_email)&&!W(e.git_user_name,e.git_user_email))}function h(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function pr(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}async function ji(e,t=T,n=process.env){let r=await Bi(e,t);if(fr(r))return{...r,identity_source:"git_config"};let o=Ki(n);if(o&&fr(o))return o;let s=Gi(n);return s||(r.git_user_name||r.git_user_email?{...r,identity_source:"git_config"}:o||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}async function Ue(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??T,s=e.env??process.env,a=await ji(t,o,s),i=Fi(a.git_user_name,a.git_user_email,a.identity_source,a.platform_login),l=(n?lt(n):void 0)?.operator_identity_hash;if(!(r||l!==void 0&&l!==i||!l))return{commit:()=>{}};let f=n;return{operator:a,commit:()=>{f&&xn(f,i,Ie())}}}function yt(e){return e?!lt(e)?.operator_identity_hash:!0}function mr(e){return!0}import{existsSync as Da,readFileSync as Ha}from"node:fs";import{homedir as Vr}from"node:os";import{join as M}from"node:path";import{basename as La,join as ne,resolve as Fr}from"node:path";import{existsSync as gr,readdirSync as zi}from"node:fs";import{basename as Vi,dirname as Wi,relative as Ji}from"node:path";var me=class{constructor(t,n=""){this.home=t;this.pathPrefix=n}components=[];truncated=!1;pluginExpandRemaining;homeRel(t){let n=Ji(this.home,t).replace(/\\/g,"/"),r=!n||n.startsWith("..")?`external/${O(Wi(t))}/${Vi(t)}`:n;return this.pathPrefix?`${this.pathPrefix}${r}`:r}get atGlobalCap(){return this.truncated||this.components.length>=H}get pluginBudgetSpent(){return this.pluginExpandRemaining!==void 0&&this.pluginExpandRemaining<=0}readEntries(t){if(!gr(t))return[];try{return zi(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if(gr(t))return q(t,n)}push(t){return this.components.length>=H?(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 Ct,readFileSync as Yi,statSync as Xi}from"node:fs";import{basename as hr,join as ge,relative as Er}from"node:path";var At=2e4,Zi=4;function qi(e){return e.length<=At?e:`${e.slice(0,At-1)}\u2026`}function Qi(e){try{let t=Yi(e),n=t.toString("utf8");return{hash:O(t),length:t.length,text:qi(n)}}catch{return null}}var _r={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function ea(e){return e in _r?_r[e]:"UNSPECIFIED"}function Pe(e,t){let n=Qi(t.absolutePath);if(!n)return!1;let r=t.name??hr(t.absolutePath).replace(/\.(md|mdc|toml)$/i,""),o={kind:t.kind,name:r,path:e.homeRel(t.absolutePath),text:n.text,content_hash:n.hash,content_length:n.length,origin:t.origin,enabled:t.enabled},s=ea(t.kind);return s&&(o.trigger=s),e.push(o)}function ta(e,t,n){let r=Er(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?hr(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function Y(e,t){let{dir:n,kind:r,origin:o,enabled:s,nested:a,extensions:i}=t;Tt(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:s,nested:a,extensions:i})}function Tt(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:s,origin:a,enabled:i,nested:c,extensions:l}=t;if(!(o>Zi))for(let u of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(c){if(!u.isDirectory())continue;let f=ge(r,u.name,c);if(Ct(f)){let g=Er(n,ge(r,u.name)).replace(/\\/g,"/");Pe(e,{absolutePath:f,kind:s,origin:a,enabled:i,name:g||u.name});continue}Tt(e,{walkRoot:n,currentDir:ge(r,u.name),depth:o+1,kind:s,origin:a,enabled:i,nested:c,extensions:l});continue}if(u.isDirectory()){Tt(e,{walkRoot:n,currentDir:ge(r,u.name),depth:o+1,kind:s,origin:a,enabled:i,nested:c,extensions:l});continue}if(!u.isFile()||!l)continue;let d=u.name.toLowerCase();if(!l.some(f=>d.endsWith(f)))continue;let m=ge(r,u.name);Pe(e,{absolutePath:m,kind:s,origin:a,enabled:i,name:ta(n,m,!0)})}}function Sr(e){for(let t of e)if(Ct(t))try{if(Xi(t).size>0)return t}catch{continue}return e.find(t=>Ct(t))}var na="<omitted>",Rr=100,Ir=120,Me=[{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"}],yr=new Set(Me.map(e=>e.attr)),ra=["enabled","disabled"],oa=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],sa=new Set(["type","command","url","args","env","envVars","headers",...ra,...oa,...Me.map(e=>e.raw)]),ia=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",...yr,...[...yr].map(e=>`${e}_truncated`)]);function Cr(e,t){for(let n of t)sa.has(n)||ia.has(n)||(e[n]=na)}var aa=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,ca=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,la=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,ua=/^bearer(?:\s+|$)/i;function De(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Ar(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Ot(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=De(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function te(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function da(e){return la.test(e)||ua.test(e)?"<redacted>":e.includes("://")?te(e):e}function Tr(e){if(/^https?:\/\//i.test(e))return te(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Tr(e.slice(t+1))}`:da(e)}function fa(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return aa.test(t)||ca.test(t)}function He(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(fa(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Tr(r))}return t}function pa(e){let t=Ar(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Ir?r.slice(0,Ir):r))].sort();if(n.length!==0)return n.length>Rr?{names:n.slice(0,Rr),truncated:!0}:{names:n,truncated:!1}}function ma(e){let t=De(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 Or(e,t){let n=new Set;for(let{raw:r,attr:o}of Me){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 a=pa(s);a&&(e[o]=a.names,a.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function kr(e,t){let n=De(e),r={transport:t};if(!n)return r;Cr(r,Object.keys(n));let o=typeof n.command=="string"?n.command:void 0,s=typeof n.url=="string"?n.url:void 0,a=typeof n.serverUrl=="string"?n.serverUrl:void 0,i=o??s??a;i&&(r.command_or_url=te(i));let c=He(Ar(n.args));c.length>0&&(r.args=c);let l=ma(n.env_http_headers),u=[...new Set([...Ot(n.env),...Ot(n.envVars),...Ot(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();u.length>0&&(r.env_var_names=u),l.headers.length>0&&(r.env_http_header_names=[...new Set(l.headers)].sort());for(let g of["headers","http_headers","env_http_headers"])if(n[g]!==void 0&&n[g]!==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 f=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return f&&(r.default_tools_approval_mode=f),Or(r,n),r}function xr(e){let t=De(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function vt(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return O(JSON.stringify({name:e,attributes:r,enabled:n}))}function Le(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function wt(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 ga(e,t){return He(wt(e,t))}function xt(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function kt(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=Le(n[1]);return r.length>0?r:void 0}function _a(e,t){let n=[],r=a=>{for(let i of a.split(/[,\n]/)){let c=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(i);c?.[1]&&n.push([c[1],Le(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(`
16
- ${e}`);return s?.[1]&&r(s[1]),n}function vr(e){return xt(e,"enabled")===!1?!1:xt(e,"disabled")!==!0}function ha(e,t){let n={};for(let{raw:r,attr:o}of Me){if(o==="auto_approve"){let a=xt(t,r);if(a!==void 0){n[r]=a;continue}}let s=wt(t,r);s.length>0&&(n[r]=s)}Or(e,n)}var Ea=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,Sa=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function Ra(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
17
- `)){let s=Ea.exec(o);s?.[1]&&t.add(s[1])}for(let o of e.matchAll(Sa))o[1]&&t.add(o[1]);return[...t]}function wr(e,t){let n={transport:t};Cr(n,Ra(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),s=r?Le(r[1]??""):void 0,a=o?Le(o[1]??""):void 0,i=s!==void 0&&s.length>0?s:a;i&&(n.command_or_url=te(i));let c=ga(e,"args");c.length>0&&(n.args=c);let l=new Set;for(let R of e.split(`
18
- `)){let I=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(R);I?.[1]&&l.add(I[1])}let u=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(u?.[1])for(let R of u[1].split(",")){let I=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(R);I?.[1]&&l.add(I[1])}let d=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
19
- ${e}`);if(d?.[1])for(let R of d[1].split(`
20
- `)){let I=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(R);I?.[1]&&l.add(I[1])}for(let R of wt(e,"env_vars"))l.add(R);let m=_a(e,"env_http_headers");for(let[,R]of m)R.length>0&&l.add(R);let f=kt(e,"bearer_token_env_var");f&&(l.add(f),n.bearer_token_env_var=f),l.size>0&&(n.env_var_names=[...l].sort()),m.length>0&&(n.env_http_header_names=[...new Set(m.map(([R])=>R))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let g=kt(e,"auth");g&&(n.auth=g);let E=kt(e,"default_tools_approval_mode");return E&&(n.default_tools_approval_mode=E),ha(n,e),n}var br=300;function Ia(e,t){if(!t)return e;let n=[...new Set([t,t.replace(/\\/g,"/")])].filter(o=>o.length>1),r=e;for(let o of n)r=r.split(o).join("~");return r}function ya(e){let t=[],n="",r=null;for(let o of e){if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(/\s/.test(o)){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}function Ca(e){return e.length<=br?e:`${e.slice(0,br-1)}\u2026`}function Nr(e,t){let n=Ia(e.trim(),t),r=ya(n);if(r.length===0)return"";let[o,...s]=r,a=te(o),i=He(s);return Ca([a,...i].join(" "))}function Aa(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 Ta(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 Oa(e,t,n,r){let o=e.homeRel(t);for(let[s,a]of Object.entries(n))if(!(!Array.isArray(a)||e.truncated))for(let i of a){if(!i||typeof i!="object"||e.truncated)continue;let c=i;for(let l of Ta(c)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??c.powershell??"",d=Aa({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}),m=typeof c.matcher=="string"?c.matcher:"",f=O(u),g=m?`${s}:${m}:${d}:${f}`:`${s}:${d}:${f}`,E=`${s}|${m}|${d}|${u}|attrs2`;e.push({kind:"HOOK",name:g,path:o,content_hash:O(E),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:s,...m?{matcher:m}:{},action_kind:d,action_hash:f,...d!=="prompt"&&u.trim()?{command:Nr(u,e.home)}:{}}})}}}function _e(e,t,n){let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||Oa(e,t,r.hooks,n)}var Ur={claude:{skillRoots:[".claude/skills"],dirs:[{dir:".claude/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".claude/commands",kind:"COMMAND",extensions:[".md"]}],memory:[".claude/CLAUDE.md"],hooks:[".claude/settings.json"],mcpJson:[".claude.json"],plugins:"claude"},cursor:{skillRoots:[".cursor/skills",".cursor/skills-cursor"],dirs:[{dir:".cursor/agents",kind:"SUBAGENT",extensions:[".md"]},{dir:".cursor/commands",kind:"COMMAND",extensions:[".md"]},{dir:".cursor/rules",kind:"RULE",extensions:[".mdc",".md"]}],memory:[".cursor/AGENTS.md"],hooks:[".cursor/hooks.json"],mcpJson:[".cursor/mcp.json"],plugins:"cursor"},codex:{skillRoots:[".agents/skills",".codex/skills"],dirs:[{dir:".codex/agents",kind:"SUBAGENT",extensions:[".toml",".md"]},{dir:".codex/prompts",kind:"COMMAND",extensions:[".md"]}],memory:[".codex/AGENTS.override.md",".codex/AGENTS.md"],hooks:[".codex/hooks.json"],mcpToml:[".codex/config.toml"]}};import{existsSync as ka,readFileSync as xa}from"node:fs";function va(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 Pr(e,t,n){let o=e.readJson(t,{})?.mcpServers;if(!o||typeof o!="object")return;let s=e.homeRel(t);for(let[a,i]of Object.entries(o)){if(e.truncated)return;let c=va(i),l=kr(i,c),u=xr(i);e.push({kind:"MCP_SERVER",name:a,path:s,content_hash:vt(a,l,u),origin:n,enabled:u,attributes:l})}}function Lr(e,t,n){if(!ka(t))return;let r;try{r=xa(t,"utf8")}catch{return}let o=e.homeRel(t),s=/^\[mcp_servers(?:\.(\w+)|\."([^"]+)"|\.'([^']+)')\]\s*$/gm,a;for(;(a=s.exec(r))!==null;){if(e.truncated)return;let i=a[1]??a[2]??a[3];if(!i)continue;let c=r.slice(a.index+a[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 m=wr(u,d),f=vr(u);e.push({kind:"MCP_SERVER",name:i,path:o,content_hash:vt(i,m,f),origin:n,enabled:f,attributes:m})}}import{existsSync as wa,readdirSync as ba}from"node:fs";import{join as x}from"node:path";var Mr=50;function bt(e,t,n,r){if(!wa(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(Mr,()=>{Y(e,{dir:x(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),Y(e,{dir:x(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),Y(e,{dir:x(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});_e(e,x(t,"hooks","hooks.json"),n),_e(e,x(t,"hooks.json"),n);let a=e.components.length-o,i=s>=Mr;return{componentCount:a,expandTruncated:i}}function Nt(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 Dr(e){let t=x(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},s=e.readJson(x(e.home,".claude/settings.json"),{})?.enabledPlugins??{},a=e.homeRel(t);for(let[i,c]of Object.entries(r)){if(e.truncated)return;let l=Array.isArray(c)?c:[c],u=l[0]??{},d=s[i]===!0,m=i.includes("@")?i.split("@").slice(1).join("@"):"",f=typeof u.version=="string"?u.version:"",g=typeof u.scope=="string"?u.scope:"user",E=`plugin:${i}`,R=0,I=!1;for(let N of l)if(typeof N.installPath=="string"&&N.installPath.length>0){let j=bt(e,N.installPath,E,d);R+=j.componentCount,I=I||j.expandTruncated}Nt(e,{pluginKey:i,rowPath:a,enabled:d,scope:g,version:f||void 0,marketplace:m||void 0,componentCount:R,expandTruncated:I,contentHash:O(`${i}|${f}|${g}|${d}|${R}`)})}}function Na(e){let t=e,n="";try{let r=ba(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=x(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),s=o[o.length-1];s&&(t=x(e,s),n=s)}}catch{}return{installPath:t,version:n}}var Ua=/^\d+$/;function Pa(e){let t=e.filter(n=>!Ua.test(n.pluginId));return t.length>0?t:e}function Hr(e){let t=[{base:x(e.home,".cursor/plugins/local"),scope:"local"},{base:x(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 i=o.name,c=x(n,o.name),l=`plugin:${i}`,{componentCount:u,expandTruncated:d}=bt(e,c,l,!0);Nt(e,{pluginKey:i,rowPath:e.homeRel(c),enabled:!0,scope:"local",componentCount:u,expandTruncated:d,contentHash:O(`${i}|local|${u}`)});continue}let s=o.name,a=[];for(let i of e.readEntries(x(n,s))){if(!i.isDirectory())continue;let c=x(n,s,i.name),{installPath:l,version:u}=Na(c);a.push({pluginId:i.name,installPath:l,version:u})}for(let i of Pa(a)){if(e.truncated)break;let c=`${i.pluginId}@${s}`,l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=bt(e,i.installPath,l,!0);Nt(e,{pluginKey:c,rowPath:e.homeRel(i.installPath),enabled:!0,scope:"cache",version:i.version||void 0,marketplace:s,componentCount:u,expandTruncated:d,contentHash:O(`${c}|${i.version}|${u}`)})}}}function $r(e,t,n,r){let o=Ur[t];if(!o)return;let s=e.home;for(let i of o.skillRoots)Y(e,{dir:ne(s,i),kind:"SKILL",origin:n,enabled:!0,nested:"SKILL.md"});for(let i of o.dirs)Y(e,{dir:ne(s,i.dir),kind:i.kind,origin:n,enabled:!0,extensions:i.extensions});let a=Sr(o.memory.map(i=>ne(s,i)));a&&Pe(e,{absolutePath:a,kind:"MEMORY",origin:n,enabled:!0,name:La(a)});for(let i of o.hooks)_e(e,ne(s,i),n);for(let i of o.mcpJson??[])Pr(e,ne(s,i),n);for(let i of o.mcpToml??[])Lr(e,ne(s,i),n);r&&(o.plugins==="claude"?Dr(e):o.plugins==="cursor"&&Hr(e))}function Ut(e,t,n){let r=new me(t);if($r(r,e,"user",!0),n===void 0||Fr(n)===Fr(t))return{components:r.components,truncated:r.truncated};let s=new me(n,"cwd/");$r(s,e,"cwd",!1);let a=[...r.components,...s.components],i=r.truncated||s.truncated||a.length>H;return{components:a.slice(0,H),truncated:i}}function Pt(e,t,n={}){let r=n.truncated===!0,o=It(e),s=new Set(e.map(u=>$(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 i=[],c=t;for(let u of e){let d=$(u.path,u.name);c[d]!==u.content_hash&&i.push(u)}let l=[];if(!r){for(let u of Object.keys(c))if(!s.has(u)){let d=dr(u);d&&l.push(d)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:i,removed:l,unchanged:i.length===0&&l.length===0}}var Kr=3e5,Ma=new Set(["HOOK","MCP_SERVER","PLUGIN"]);function Lt(e,t,n){let r=new Set(t.map(s=>$(s.path,s.name))),o=[];for(let s of e)s.text!==void 0&&(n.has(s.content_hash)||r.has($(s.path,s.name))||o.push(s));return o}function Mt(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 Br(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Gr(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function Dt(e,t=Kr){let n=[],r=[];for(let u of e)Ma.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=[],a=2,i=0,c=0,l=[];for(let u of o){let d=s.length>0?1:0,m=Br(u)+d;if(a+m<=t){s.push(u),a+=m,u.text!==void 0&&l.push(u.content_hash);continue}if(u.text!==void 0){let f=Gr(u),g=Br(f)+d;if(a+g<=t){s.push(f),a+=g,i+=1;continue}}c+=1}return{components:s,textDeferredCount:i,droppedCount:c,textHashesSent:l}}function Ht(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:Gr(n))}var Fa={claude:{skills:".claude/skills",subagents:".claude/agents",commands:".claude/commands",memory:".claude/CLAUDE.md",settings:".claude/settings.json"},cursor:{skills:[".cursor/skills",".cursor/skills-cursor"],subagents:".cursor/agents",commands:".cursor/commands",rules:".cursor/rules",mcp:".cursor/mcp.json"},codex:{skills:[".agents/skills",".codex/skills"],subagents:".codex/agents",commands:".codex/prompts",memory:".codex/AGENTS.md",settings:".codex/config.toml"}},$a=200,jr=200,Ba=["allow","deny","ask"],Ka=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,Ft="<path>",Ga=new RegExp(`${Ft}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function ja(e){let t=e.replace(Ka,Ft).replace(Ga,Ft);return t.length>jr?`${t.slice(0,jr)}...`:t}function zr(e){let t=q(e,{}),n=[];for(let r of Ba)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:ja(o),mode:r});return{model:t.model??"",permissionKeys:n}}var za=10,Va=840*60*1e3,Wa="self-config-cache.json";function $t(){return A("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function Ja(e,t=Date.now()){return e===void 0||!Number.isFinite(e)?!0:t-e>=Va}var Ya={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function Xa(e,t=T){let n=Ya[e];if(!n||n.length===0)return null;let r=async o=>{let s=n[o];if(s===void 0)return null;let i=((await t(s,["--version"],2e3)).split(`
21
- `)[0]??"").trim();return i||r(o+1)};return r(0)}function Za(e=Vr()){return M(e,".ev-ai","agent-hook",Wa)}function qa(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
22
- `);return O(n)}function Fe(e,t,n=!1){let r=qa(e),o=e.length;return t===r?n?{hash:r,count:o,truncated:n}:{hash:r,count:o}:n?{hash:r,count:o,entries:e,truncated:n}:{hash:r,count:o,entries:e}}function Qa(e){return Da(e)?b(Ha(e,"utf8"),{}):{}}function ec(e,t){try{G(e,`${JSON.stringify(t)}
23
- `)}catch(n){let r=n instanceof Error?n.message:String(n);_(`WARN: self-config cache write failed open: ${r}`)}}function tc(e,t,n,r){let o={...e,send_count:n};for(let s of Object.keys(t)){let a=t[s];a.entries!==void 0&&(o[s]=a.hash)}return r&&(o.user_spec_collected_at_ms=r.collectedAtMs,r.included&&(o.user_spec=r.hash,o.user_spec_components=r.componentHashes),o.user_spec_text_hashes=r.textHashes),o}async function Wr(e,t=process.cwd(),n=Vr(),r={}){let o=e==="claude",s=r.gitRoot??t,a=await Xa(e),i="",c=[];if(o){let U=zr(M(n,".claude/settings.json")),F=zr(M(t,".claude/settings.local.json"));i=F.model||U.model,c=[...U.permissionKeys,...F.permissionKeys].slice(0,$a)}let l=Fa[e]??{},u={present:!1,size:0},d=U=>{let F=Array.isArray(U)?U:U?[U]:[],C=[],K=!1;for(let je of F){let w=ie(M(n,je));if(C=C.concat(w.entries),K=K||w.truncated,C.length>=H){C=C.slice(0,H),K=!0;break}}return{entries:C,truncated:K}},m=Za(n),f=Qa(m),g=f[e]??{},E=(g.send_count??0)+1,R=E>0&&E%za===0,I=U=>R?void 0:g[U],N=d(l.skills),j=l.subagents?ie(M(n,l.subagents)):{entries:[],truncated:!1},Ge=l.commands?ie(M(n,l.commands)):{entries:[],truncated:!1},zt=l.rules?ie(M(n,l.rules)):{entries:[],truncated:!1},se={skills:Fe(N.entries,I("skills"),N.truncated),subagents:Fe(j.entries,I("subagents"),j.truncated),commands:Fe(Ge.entries,I("commands"),Ge.truncated),rules:Fe(zt.entries,I("rules"),zt.truncated)},v={runner_platform:e,config_scope:"user",cli_version:a,claude_version:o?a:null,model:o&&i||null,permission_keys:c,user_scope:{skills:se.skills,subagents:se.subagents,commands:se.commands,rules:se.rules,memory:l.memory?ae(M(n,l.memory)):u,settings:l.settings?ae(M(n,l.settings)):u,mcp:l.mcp?ae(M(n,l.mcp)):u},local_settings:o?ae(M(t,".claude/settings.local.json")):u},Vt=null,Wt=()=>{},Jt=r.nowMs??Date.now();if(!$t()&&Ja(g.user_spec_collected_at_ms,Jt)){let U=g.user_spec_collected_at_ms!==void 0,F=Ut(e,n),C=Pt(F.components,g.user_spec_components,{forceFull:!g.user_spec_components,truncated:F.truncated}),K=new Set(g.user_spec_text_hashes??[]),je=Lt(F.components,C.upserts,K),w=Dt(Ht([...C.upserts,...je],K));v.user_spec_hash=C.hash,v.user_spec_count=C.count,v.user_spec_truncated=C.truncated||w.droppedCount>0,(w.components.length>0||C.removed.length>0||C.full)&&(C.full&&(v.user_spec_full=!0),w.components.length>0&&(v.user_spec=w.components),C.removed.length>0&&!v.user_spec_truncated&&(v.user_spec_removed=C.removed),w.textDeferredCount>0&&(v.user_spec_text_deferred=w.textDeferredCount));let ze=C.full?{}:{...g.user_spec_components??{}};if(!v.user_spec_truncated)for(let Z of C.removed)delete ze[$(Z.path,Z.name)];for(let Z of w.components)ze[$(Z.path,Z.name)]=Z.content_hash;Vt={hash:C.hash,componentHashes:ze,textHashes:Mt(K,w.textHashesSent,F.components),included:w.components.length>0||C.removed.length>0&&!v.user_spec_truncated||C.full,collectedAtMs:Jt};let Ve=await Ue({gitRoot:s,installationStorePath:r.installationStorePath,forceResend:U});Ve.operator&&(v.operator=Ve.operator),Wt=Ve.commit}let po=tc(g,se,E,Vt);return{config:v,commit:()=>{f[e]=po,ec(m,f),Wt()}}}function re(e,t,n){let r={installation_id:n.installationId};return n.platformAgentId&&(r.platform_agent_id=n.platformAgentId),n.sessionId&&(r.session_id=n.sessionId),n.turnId&&(r.turn_id=n.turnId),{schema_version:2,event:e,timestamp:Ie(),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:st,host_arch:process.arch,node_version:process.version,correlation:r,payload:t}}import{existsSync as Jr}from"node:fs";import{spawn as Yr}from"node:child_process";import{basename as nc}from"node:path";import{fileURLToPath as rc}from"node:url";var Kt="__post",$e="__work";function oc(e,t){let n=e.payload,r=n&&typeof n=="object"&&!Array.isArray(n)?Object.keys(n):[],o=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:o,payload_keys:r})}function Xr(e){switch(e){case"session_start":return cn;case"session_end":return ln;case"tool_invoked":case"skill_invoked":return rt;default:return rt}}function sc(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
24
- ${n}`}function Zr(e,t=[],n=process.execPath,r=import.meta.url,o=Jr){if(nc(n)===Ce)return{command:n,args:[e,...t]};let s=rc(r);return o(s)?{command:n,args:[s,e,...t]}:{command:n,args:[e,...t]}}function ic(e=process.execPath,t=import.meta.url,n=Jr){return Zr(Kt,[],e,t,n)}function ac(e){let t=e.indexOf(`
25
- `);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}async function qr(e,t=fetch){let n=await e(),r=ac(n);if(!r)return;let{meta:o,body:s}=r,a={"Content-Type":"application/json"};try{await t(o.url,{method:"POST",headers:a,body:s,signal:AbortSignal.timeout(Number(o.timeoutMs))})}catch{}}async function cc(e,t,n){let r=Xr(e);_(`POST event=${e} url=${ut(n)} size=${t.length} platform=${process.platform}`);let o={"Content-Type":"application/json"},s=Date.now();try{let a=await fetch(n,{method:"POST",headers:o,body:t,signal:AbortSignal.timeout(r)}),i=Date.now()-s;if(a.ok)return _(`POST outcome=ok elapsed_ms=${i} http=${a.status}`),!0;let c=(await a.text()).slice(0,200).replace(/[\n\r]/g,"");return _(`POST outcome=fail elapsed_ms=${i} http=${a.status} body=${c}`),!1}catch(a){let i=Date.now()-s,c=a instanceof Error?a.message:String(a);return _(`POST outcome=fail elapsed_ms=${i} http=000 body=${c}`),!1}}async function Qr(e,t,n,r,o){try{let s=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});s.on("error",()=>{}),s.stdin.on("error",()=>{});let a=!1;return await new Promise(i=>{let c=setTimeout(()=>{if(!a){_(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`);try{s.stdin.destroy()}catch{}}i()},un),l=()=>{a=!0,clearTimeout(c),i()};s.stdin.end(n,()=>l()),s.stdin.once("error",()=>l())}),s.unref(),s}catch(s){let a=s instanceof Error?s.message:String(s);return _(`WARN: ${o} spawn failed open: ${a}`),null}}async function lc(e,t,n,r=Yr,o=ic){let s=Xr(e),a=sc(n,s,t),{command:i,args:c}=o();return Qr(i,c,a,r,"detached post")}async function eo(e,t,n=Yr,r=Zr){let{command:o,args:s}=r($e,t);return Qr(o,s,e,n,"detached work")}async function oe(e,t,n,r,o,s){if(!o)return _("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),!1;if(!Te(o))return _(`WARN: collector URL blocked (https required): ${ut(o)}`),!1;let a=r(e,t,n);s!==void 0&&(a.build_ms=Math.max(0,Date.now()-s));let i=`${JSON.stringify(a)}
26
- `,c=A("EV_AI_HOOK_DEBUG");c==="full"?_(`DEBUG envelope=${JSON.stringify(a)}`):c==="1"&&_(`DEBUG summary=${oc(a,Buffer.byteLength(i,"utf8"))}`);let l=process.argv.includes($e),u=A("EV_AI_HOOK_SYNC")==="1";return ve(n.runnerEvent,n.runnerPlatform)||l||u?cc(e,i,o):(await lc(e,i,o),!1)}import{relative as uc,resolve as Be,sep as Gt}from"node:path";var dc=["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"];function fc(e){return e.capture_hook_input==="full"?!0:e.capture_hook_input==="allowlist"?!1:A("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"}function pc(e){let t={};for(let n of dc){let r=V(e,n);r!==void 0&&(t[n]=r)}return t}function mc(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=Be(e),r=Be(t),o=uc(r,n);return!o||o==="."?".":o.startsWith(`..${Gt}`)||o===".."||Be(r,o)!==n?null:o.split(Gt).join("/")}function gc(e){return typeof e!="string"||e.length===0?null:Be(e).split(Gt).join("/")}function to(e,t,n){let r=gc(t.cwd);r!==null&&(e.cwd=r);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?mc(t.cwd,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}function no(e,t){let n=JSON.stringify(e),r=Buffer.byteLength(n,"utf8");if(r<=t)return e;let o=Object.entries(e).filter(([a,i])=>!a.startsWith("_")&&(typeof i=="string"||typeof i=="number"||typeof i=="boolean")).sort((a,i)=>Buffer.byteLength(JSON.stringify(a[1]),"utf8")-Buffer.byteLength(JSON.stringify(i[1]),"utf8")),s={_truncated:!0,_original_bytes:r};for(let[a,i]of o){let c={...s,[a]:i};if(Buffer.byteLength(JSON.stringify(c),"utf8")>t)break;s[a]=i}return s}function he(e,t,n={}){if(fc(t)){let o={...e};return delete o.cwd,delete o.transcript_path,to(o,e,n),no(o,fn)}let r=pc(e);return to(r,e,n),no(r,dn)}import{createReadStream as _c}from"node:fs";import{stat as hc}from"node:fs/promises";import{basename as Ec,resolve as Sc}from"node:path";import{createInterface as Rc}from"node:readline";var Ic=1024*1024;function yc(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&Ec(t).endsWith(".jsonl")}async function ro(e){if(!e||!yc(e))return null;try{let t=Sc(e),n=await hc(t);if(!n.isFile())return null;let r=Math.max(0,n.size-Ic),o=[],s=Rc({input:_c(t,{encoding:"utf8",start:r}),crlfDelay:1/0});for await(let a of s)a.length!==0&&o.push(a);r>0&&o.length>0&&o.shift();for(let a=o.length-1;a>=0;a--){let i=o[a];if(i)try{let c=JSON.parse(i);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 Se(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent}}function Ke(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo}}var Ac=new Set([...Object.values(ht),".github"]);function Tc(e,t,n,r,o,s){if(e===null||t===null||!(/^mcp__.+?__.+$/i.test(e)||/^MCP:[^:]+:.+$/i.test(e)||e.toLowerCase()===`mcp:${t.toLowerCase()}`))return;let i=s.find(f=>f.name.toLowerCase()===t.toLowerCase()),c=i?.sourcePath??(i?.source==="claude_json_user"?".claude.json":i?.source==="cursor_mcp_user"?".cursor/mcp.json":i?.source==="codex_toml_user"||i===void 0&&o==="codex"?".codex/config.toml":void 0);if((i?.scope==="user"||i?.source==="claude_json_user"||i?.source==="cursor_mcp_user"||i?.source==="codex_toml_user"||i===void 0&&o==="codex")&&c)try{let f=(0,k.userConfigRootFromPath)(c);return(0,k.buildComponentReference)({installationRootExternalKey:(0,k.installationRootExternalKey)(r,f),installableKind:k.ComponentKind.INTERFACE,sourcePath:c,nativeKey:i?.name??t})}catch{return}if(n===null)return;let u=n.indexOf(":");if(u<=0||u===n.length-1)return;let d=n.slice(u+1),m=d.replaceAll("\\","/").split("/").at(-1);if(!(m===void 0||!Ac.has(m)))try{return(0,k.buildComponentReference)({installationRootExternalKey:n,installableKind:k.ComponentKind.INTERFACE,sourcePath:d,nativeKey:t})}catch{return}}function Oc(...e){for(let t of e)if(t)return t;return null}function D(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return _(`WARN: ${n} failed open: ${r}`),t}function kc(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 xc(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var X=new Set,Ee=null;async function oo(e){if($t())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(X.has(t))return;if(!yt(n)){X.add(t);return}let r=ce({sessionId:e.sessionId,hostname:le()});if(mr(r)){if(Ee){await Ee;return}Ee=(async()=>{if(X.has(t)||!yt(n)){X.add(t);return}if(!vn(n)){X.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:a}=e.manifest,i=String(e.runnerPlatform),[c,l,u,d,m]=await Promise.allSettled([pe(a),tt(),Et(r),nt(),Ue({gitRoot:a,installationStorePath:n,forceResend:!1})]),f=D(c,null,"gitSnapshot"),g=D(l,"","detectVirt"),E=D(u,null,"probeCloud"),R=D(d,{},"hostEnv"),I=D(m,{commit:()=>{}},"resolveOperatorForSend");await Re(e,a,f);let N={identity:{host:le(),context:r,virt:g||null,cloud:E,git:f},host_env:R,env_vars:Rt(),self_config:xc(i,I.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await oe("session_start",N,Se(e),re,e.manifest.collectorUrl,s),o&&(I.commit(),X.add(t))}finally{wn(n)}})().finally(()=>{Ee=null}),await Ee}}async function Re(e,t,n){try{let r=n===void 0?await pe(t):n;e.platformAgentId=await ir(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,r,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);_(`WARN: derivePlatformAgentId failed open: ${o}`)}}async function vc(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=ce({sessionId:e.sessionId,hostname:le()}),o=String(e.runnerPlatform),[s,a,i,c,l,u]=await Promise.allSettled([pe(n),tt(),Et(r),nt(),St(e.manifest.manifest,n,o),Wr(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n})]),d=D(s,null,"gitSnapshot"),m=D(a,"","detectVirt"),f=D(i,null,"probeCloud"),g=D(c,{},"hostEnv"),E=D(l,[],"mcpDeclared"),R=D(u,kc(o),"selfConfig"),I=R.config;await Re(e,n,d);let N=p(e.hookInput,"model");N&&(I.model=N);let j={identity:{host:le(),context:r,virt:m||null,cloud:f,git:d},host_env:g,env_vars:Rt(),mcp:{declared:E},self_config:I,run_meta:{trigger:e.hookSource||"startup"},hook_input:he(e.hookInput,e.manifest.manifest,Ke(e))};await oe("session_start",j,Se(e),re,e.manifest.collectorUrl,t)&&(R.commit(),X.add(e.manifest.installationId))}async function wc(e){let t=Date.now(),{gitRoot:n}=e.manifest;await Re(e,n);let r=Oc(p(e.hookInput,"status"),p(e.hookInput,"stop_reason"),p(e.hookInput,"reason"),gt(p(e.hookInput,"error"))),o=e.runnerPlatform==="claude"?await ro(p(e.hookInput,"transcript_path")):null,s=he(e.hookInput,e.manifest.manifest,Ke(e));o&&(s.model=o),await oe("session_end",{status:r,...o?{model:o}:{},hook_input:s},Se(e),re,e.manifest.collectorUrl,t)}async function bc(e){let t=Date.now(),n=Gn(e.hookInput);if(n.length===0)return;await oo(e);let{gitRoot:r}=e.manifest;await Re(e,r);let o=he(e.hookInput,e.manifest.manifest,Ke(e)),s=Se(e),a=Oe(e.hookInput.tool_input),i=r.replaceAll("\\","/").replace(/\/$/,""),c=a?.replaceAll("\\","/"),l=c===void 0?null:c.startsWith(`${i}/`)?c.slice(i.length+1):c.startsWith("/")?null:c,u=Cc().replaceAll("\\","/").replace(/\/$/,""),d=c?.startsWith(`${u}/`)===!0?c.slice(u.length+1):null;await Promise.all(n.map(m=>{let f;if((l!==null||d!==null)&&dt(l??d??"")?.toLowerCase()===m.toLowerCase()){let g=l??d,E=g===null?null:(0,k.nativeKeyForSkillPath)(g);if(E!==null)try{let R=l!==null?e.platformAgentId:(0,k.installationRootExternalKey)(e.manifest.installationId,(0,k.userConfigRootFromPath)(g));R&&(f=(0,k.buildComponentReference)({installationRootExternalKey:R,installableKind:k.ComponentKind.SKILL,sourcePath:g,nativeKey:E}))}catch{f=void 0}}return oe("tool_invoked",{tool_name:"Skill",skill_name:m,...f===void 0?{}:{component_reference:f},success:null,duration_ms:null,hook_input:o},s,re,e.manifest.collectorUrl,t)}))}async function Nc(e){let t=Date.now();await oo(e);let{gitRoot:n}=e.manifest;await Re(e,n);let{toolName:r,skillName:o}=Jn(e.hookInput,e.runnerEvent),s=Xn(e.hookInput),a=zn(e.runnerEvent),i=a===!1?Zn(e.hookInput,e.runnerEvent):null,c=await St(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform)).catch(()=>[]),{mcpServer:l,mcpTool:u}=qn(r,c.map(f=>f.name)),d=Tc(r,l,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),c),m=Yn(e.hookInput);await oe("tool_invoked",{tool_name:r,skill_name:o,success:a,duration_ms:s,...i?{failure_reason:i}:{},...l?{mcp_server:l}:{},...u?{mcp_tool:u}:{},...d?{component_reference:d}:{},...m?{subagent_type:m}:{},hook_input:he(e.hookInput,e.manifest.manifest,Ke(e))},Se(e),re,e.manifest.collectorUrl,t)}async function so(e){switch(e.internalEvent){case"session_start":await vc(e);return;case"session_end":await wc(e);return;case"skill_invoked":await bc(e);return;case"tool_invoked":await Nc(e);return;default:return}}function io(e){return e!=="session_start"&&e!=="session_end"&&e!=="tool_invoked"&&e!=="skill_invoked"&&e!==""}import{existsSync as jt,readFileSync as Uc}from"node:fs";import{dirname as Pc,join as ao,relative as Lc}from"node:path";var co=[an,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"];async function Mc(e=process.cwd(),t){let n=A("EV_AI_HOOK_MANIFEST");if(n&&jt(n))return n;let r=t??await qe(e);for(let o of co){let s=ao(r,o);if(jt(s))return s}for(let o of co){let s=ao(e,o);if(jt(s))return s}}async function Dc(e,t){let n=t??await qe(Pc(e)),r=Lc(n,e),o=await P("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(_(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}function Hc(e){let t=Uc(e,"utf8");return b(t,{})}function Fc(){return{schema_version:2,mcp_servers:[]}}async function lo(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await Ze(e),o=await Mc(e,n),s=o?Hc(o):Fc();delete s.installation_id;let a=o?await Dc(o,n):!1;s.capture_hook_input==="full"&&o&&a&&(_(`WARN: ignoring capture_hook_input=full in git-tracked manifest ${o}; use EV_AI_HOOK_CAPTURE_FULL_INPUT=1 or an untracked operator manifest`),delete s.capture_hook_input);let{installationId:i,storePath:c,repoKey:l}=await Pn(n,{sessionId:t.sessionId});return{manifestPath:o??c,manifest:s,installationId:i,installationStorePath:c,repoKey:l,collectorUrl:Fn(s),platformAgentId:s.platform_agent_id??"",gitRoot:n,inGitRepo:r}}async function uo(e,t,n,r){let o=t??await Xe(ot),s=b(o,{}),a=p(s,"session_id")||p(s,"conversation_id"),i=await lo(process.cwd(),{sessionId:a});if(!i)return;r&&(i.collectorUrl=r);let c=Vn(s,i.manifest.platform,n),l=Wn(e,c.runnerEvent);if(!l){_(`WARN: unknown hook event '${c.runnerEvent}'; skipping telemetry`);return}let u={hookInput:s,sessionId:c.sessionId,turnId:c.turnId,runnerEvent:c.runnerEvent,runnerPlatform:c.runnerPlatform,hookSource:c.hookSource,internalEvent:l,manifest:i,platformAgentId:i.platformAgentId};if(io(l)){_(`WARN: unsupported internal event '${l}'`);return}await so(u)}function $c(e,t){if(A("EV_AI_HOOK_SYNC")==="1")return!0;let n=xe(e),r=b(t,{}),o=n.event??(p(r,"hook_event_name")||p(r,"event")),s=de(r,o,void 0,n.runner);return ve(o,s)}async function fo(e=process.argv.slice(2)){if(e[0]===Kt){try{await qr(Ye)}catch{}return 0}if(e[0]===$e){try{let t=xe(e.slice(1)),n=await Ye(),r=b(n,{}),o=t.event??(p(r,"hook_event_name")||p(r,"event"));if(Qe()||mt(t.runner,r,o))return 0;await uo(t.event,n,t.runner,pt(t))}catch(t){let n=t instanceof Error?t.message:String(t);_(`WARN: detached work failed open: ${n}`)}return 0}try{let t=await Xe(ot),n=xe(e),r=pt(n),o=b(t,{}),s=n.event??(p(o,"hook_event_name")||p(o,"event"));if(Qe()||mt(n.runner,o,s)||!sr(o,s,n.runner))return 0;$c(e,t)?await uo(n.event,t,n.runner,r):await eo(t,e)}catch(t){let n=t instanceof Error?t.message:String(t);_(`WARN: hook failed open: ${n}`)}finally{nn()}return 0}fo().then(e=>{process.exit(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);process.stderr.write(`[ev-ai-agent-hook] ${t}
4
+ var Ys=Object.create;var jn=Object.defineProperty;var Xs=Object.getOwnPropertyDescriptor;var Zs=Object.getOwnPropertyNames;var qs=Object.getPrototypeOf,Qs=Object.prototype.hasOwnProperty;var Gn=(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 ei=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ti=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zs(t))!Qs.call(e,o)&&o!==n&&jn(e,o,{get:()=>t[o],enumerable:!(r=Xs(t,o))||r.enumerable});return e};var It=(e,t,n)=>(n=e!=null?Ys(qs(e)):{},ti(t||!e||!e.__esModule?jn(n,"default",{value:e,enumerable:!0}):n,e));var qe=ei(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.ComponentKind=void 0;K.userConfigRootFromPath=Dc;K.installationRootExternalKey=Fc;K.normalizeRepositoryRelativePath=Yr;K.nativeKeyForSkillPath=Hc;K.nativeKeyForRulePath=Kc;K.nativeKeyForCommandPath=$c;K.serializeComponentIdentity=Zr;K.buildComponentReference=jc;K.validateComponentReference=Gc;var vc=Gn("node:crypto"),Tc=Gn("node:path"),Pc="cmp1_",wc=/^cmp1_[A-Za-z0-9_-]{43}$/,bc=["/skills/","/skills-cursor/"],Mc=/(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i,Nc=/(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i,Uc=[".cursor",".claude",".codex"],Lc={".claude.json":".claude",".agents":".codex"};K.ComponentKind={SKILL:"SKILL",INTERFACE:"INTERFACE",RULE:"RULE",COMMAND:"COMMAND"};function Dc(e){let t=e.replaceAll("\\","/").split("/").filter(Boolean),n=t.find(o=>Uc.includes(o));return n||(t.map(o=>Lc[o]).find(o=>o!==void 0)??"unknown")}function Fc(e,t){return`runtime-install:${e}/${t}`}function Ze(e,t){if(e.length===0)throw new Error(`${t} is required`);return e}function Yr(e){let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:\//.test(t))throw new Error("sourcePath must be repository-relative");let n=Tc.posix.normalize(t).replace(/^\.\//,"");if(n==="."||n===".."||n.startsWith("../"))throw new Error("sourcePath must be repository-relative");return Ze(n,"sourcePath")}function Hc(e){let t=e.replaceAll("\\","/");for(let n of bc){let r=t.split(n)[1]?.split("/")[0];if(r&&r.length>0)return r}return null}function Xr(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 Kc(e){return Xr(e,Mc,/\.(mdc|md|rules)$/i)}function $c(e){return Xr(e,Nc,/\.(md|mdc|toml)$/i)}function Bc(e){return`${Buffer.byteLength(e,"utf8")}:${e}`}function Zr(e){let t=[Ze(e.installationRootExternalKey,"installationRootExternalKey"),Ze(e.installableKind,"installableKind"),Yr(e.sourcePath),Ze(e.nativeKey,"nativeKey")];return Buffer.from(`1|${t.map(Bc).join("|")}`,"utf8")}function jc(e){let t=(0,vc.createHash)("sha256").update(Zr(e)).digest("base64url");return`${Pc}${t}`}function Gc(e){return wc.test(e)}});import{existsSync as li,readFileSync as ui}from"node:fs";import{hostname as qn,userInfo as di}from"node:os";import{randomBytes as ni}from"node:crypto";import{existsSync as kt,mkdirSync as ri,readdirSync as oi,readFileSync as si,renameSync as zn,statSync as Jn,unlinkSync as Wn,writeFileSync as ii}from"node:fs";import{basename as ci,dirname as Vn,join as Yn,relative as ai}from"node:path";function h(e){process.stderr.write(`[ev-ai-agent-hook] ${e}
5
+ `)}function Q(e,t){ri(Vn(e),{recursive:!0});let n=Yn(Vn(e),`.${ci(e)}.${process.pid}.${ni(4).toString("hex")}.tmp`);try{ii(n,t,"utf8");try{zn(n,e)}catch(r){let o=r instanceof Error&&"code"in r?r.code:void 0;if(o==="EEXIST"||o==="EPERM"||o==="EACCES"){Wn(e),zn(n,e);return}throw r}}catch(r){try{Wn(n)}catch{}throw r}}function Be(){return new Date().toISOString().replace(/\.\d{3}Z$/,"Z")}function Xn(){process.stdout.write('{"continue":true}')}function I(e){let t=process.env[e];return t===void 0||t===""?void 0:t}async function xt(){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 Ot(e){return new Promise(t=>{let n="",r=!1,o=i=>{r||(r=!0,clearTimeout(s),t(i||"{}"))},s=setTimeout(()=>{o(n)},e);if(process.stdin.isTTY){o("{}");return}process.stdin.setEncoding("utf8"),process.stdin.on("data",i=>{n+=i}),process.stdin.on("end",()=>{o(n)}),process.stdin.on("error",()=>{o(n)}),process.stdin.resume()})}async function G(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:c}=await i(e,t,{timeout:n,windowsHide:!0,maxBuffer:1048576,cwd:r.cwd});return{ok:!0,stdout:c.trim()}}catch(c){let a=c,l=typeof a.code=="number"?a.code:typeof a.status=="number"?a.status:void 0;return{ok:!1,code:l,spawnFailed:l===void 0}}}async function T(e,t,n=3e3,r={}){let o=await G(e,t,n,r);return o.ok?o.stdout:""}async function vt(e=process.cwd()){let t=await G("git",["rev-parse","--show-toplevel"],2e3,{cwd:e});if(t.ok&&t.stdout)return{root:t.stdout,inGitRepo:!0};if(I("EV_AI_HOOK_DEBUG")){let r=t.ok?"empty stdout":t.spawnFailed?"spawn failed":`exit ${String(t.code??"unknown")}`;h(`DEBUG: git rev-parse --show-toplevel failed (${r}) cwd=${e}`)}let n=I("CURSOR_PROJECT_DIR")??I("CLAUDE_PROJECT_DIR");if(n&&kt(n)){let r=await G("git",["rev-parse","--show-toplevel"],2e3,{cwd:n});return r.ok&&r.stdout?{root:r.stdout,inGitRepo:!0}:{root:n,inGitRepo:!1}}return{root:e,inGitRepo:!1}}async function Tt(e=process.cwd()){return(await vt(e)).root}function M(e,t){try{return JSON.parse(e)}catch{return t}}var At=new Map;function W(e,t){let n=At.get(e);if(n!==void 0)return n;try{let r=M(si(e,"utf8"),t);return At.set(e,r),r}catch{return At.set(e,t),t}}function ie(e){return typeof e=="string"?e:""}function ce(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 m(e,t){let n=ce(e,t);return typeof n=="string"?n:""}var ee=500;function Zn(e,t=2){if(!kt(e))return{entries:[],truncated:!1};let n=[],r=!1,o=(s,i)=>{if(i>t||r)return;let c;try{c=oi(s,{withFileTypes:!0})}catch{return}for(let a of c){if(r)return;let l=Yn(s,a.name);if(a.isDirectory()){o(l,i+1);continue}if(a.isFile()){try{n.push({name:ai(e,l),size:Jn(l).size})}catch{continue}if(n.length>=ee){r=!0;return}}}};return o(e,1),{entries:n,truncated:r}}function Pt(e){return kt(e)?{present:!0,size:Jn(e).size}:{present:!1,size:0}}function ge(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}function wt(e=process.env){return ge(k("CURSOR_SANDBOX",e))}var pi=["CIRCLECI","BUILDKITE","TF_BUILD","JENKINS_URL","JENKINS_HOME","CODEBUILD_BUILD_ID","DRONE","DRONE_BUILD_NUMBER","TEAMCITY_VERSION","TRAVIS","APPVEYOR","BITBUCKET_BUILD_NUMBER"];function fi(e){return pi.some(t=>!!k(t,e))}function mi(e){if(k("KUBERNETES_SERVICE_HOST",e)||ge(k("REMOTE_CONTAINERS",e))||ge(k("DEVCONTAINER",e)))return!0;try{if(li("/.dockerenv")||ui("/proc/1/environ","utf8").includes("container="))return!0}catch{}return!1}function Qn(e){return["VSCODE_PID","VSCODE_IPC_HOOK","CURSOR_EXTENSION_HOST_ROLE","CURSOR_WORKSPACE_LABEL"].some(t=>!!k(t,e))}function gi(e,t=process.platform){return Qn(e)?t==="darwin"||t==="win32"?!0:["__CFBundleIdentifier","DISPLAY","WAYLAND_DISPLAY","SESSIONNAME"].some(n=>!!k(n,e)):!1}function _i(e){return e===void 0?!1:e.trim().toLowerCase().startsWith("bc-")}function hi(e){return e==="linux"}function k(e,t){if(t){let n=t[e];return n===void 0||n===""?void 0:n}return I(e)}function Si(e,t,n){return e.trim().toLowerCase()==="cursor"&&t.trim().toLowerCase()==="ubuntu"&&!!Ei(k("CURSOR_VERSION",n))}function Ei(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function bt(e){if(_i(e.sessionId))return!0;let t=e.hostname??qn(),n=e.osUser??er(e.env);return Si(t,n,e.env)}function Ri(e){return ge(k("CURSOR_AGENT",e.env))?!0:bt(e)}function yi(e){return!!(process.stdin.isTTY||process.stdout.isTTY||(k("TERM",e)??k("TERM_PROGRAM",e))||(k("SSH_TTY",e)??k("SSH_CONNECTION",e))||(k("__CFBundleIdentifier",e)??k("XPC_SERVICE_NAME",e))||Qn(e)||["DISPLAY","WAYLAND_DISPLAY","XDG_SESSION_TYPE","DBUS_SESSION_BUS_ADDRESS"].some(t=>!!k(t,e))||k("SESSIONNAME",e))}function ke(e={}){let t=e.env;if(k("GITHUB_ACTIONS",t))return"github_actions";if(ge(k("CLAUDE_CODE_REMOTE",t)))return"claude_remote";let n=e.platform??process.platform;if(!gi(t,n)&&Ri(e)&&(ge(k("CURSOR_AGENT",t))||hi(n)))return"cursor_cloud";if(k("CODESPACES",t)||k("CODESPACE_NAME",t))return"codespaces";if(k("GITLAB_CI",t))return"gitlab_ci";if(fi(t))return"managed";let r=k("CI",t);return r&&r!=="false"&&r!=="0"?"managed":mi(t)?"container":yi(t)?"interactive":"unknown"}async function Mt(){return await T("systemd-detect-virt",[],1e3)}function er(e=process.env,t=di){for(let n of["USER","LOGNAME","USERNAME"]){let r=e[n];if(typeof r=="string"){let o=r.trim();if(o.length>0)return o}}try{return t().username??""}catch{return""}}async function Nt(){let e=process.platform==="darwin"?"Darwin":process.platform==="win32"?"Windows_NT":"Linux",t="";if(process.platform==="darwin")t=await T("sw_vers",["-productVersion"],1e3);else if(process.platform==="linux"){try{let{readFileSync:s}=await import("node:fs"),i=s("/etc/os-release","utf8"),c=i.match(/^PRETTY_NAME="?([^"\n]+)"?/m)?.[1],a=i.match(/^VERSION_ID="?([^"\n]+)"?/m)?.[1];t=c??a??""}catch{t=await T("lsb_release",["-sd"],1e3).then(s=>s.replace(/^"|"$/g,""))}t||(t=await T("uname",["-r"],1e3))}else t=await T("ver",[],1e3);let n=er(),r=(process.env.SHELL??"").split(/[/\\]/).pop()??"",o="";try{o=await T("tty",[],500),o.includes("not a tty")&&(o="")}catch{o=""}return{os:e,os_version:t||null,user:n||null,shell:r||null,tty:o||null}}function xe(){return qn()}var Ci="https://hooks.ev-ai.ai";function je(e,t=Ci){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}var tr=".claude/ev-ai-runtime-report.json";var Ge="ev-ai-agent-hook";var np=`current/${Ge}`,rp=`.ev-ai/agent-hook/${Ge}`,nr=5e3,rr=5e3,Ut=3e3;var Lt=3e3,or=1500,sr=4*1024,ir=32*1024,Ii=4*1024,cr=32*1024,Dt="1.1.0",op=`@ev-ai/agent-hook@${Dt}`;var ar=["claude","cursor","codex"];import{createHash as ya}from"node:crypto";import{existsSync as Ca,mkdirSync as Ia,readdirSync as Aa,readFileSync as yo,unlinkSync as Co,writeFileSync as ka}from"node:fs";import{homedir as Io}from"node:os";import{join as rn}from"node:path";import{createHash as fr,randomBytes as xi}from"node:crypto";import{existsSync as mr,mkdirSync as Ft,readFileSync as gr,unlinkSync as _r,writeFileSync as hr}from"node:fs";import{homedir as Ht}from"node:os";import{dirname as ze,join as Kt,resolve as Oi}from"node:path";var Ai=new Set(["action@github.com","noreply@github.com","noreply@anthropic.com","cursoragent@cursor.com"]),ki=new Set(["github-actions","github actions","dependabot","renovate","cursoragent","cursor agent"]);function ae(e,t){let n=(e??"").trim().toLowerCase(),r=(t??"").trim().toLowerCase();if(!n&&!r)return!1;if(n.includes("[bot]")||ki.has(n)||r.includes("[bot]")||Ai.has(r))return!0;if(r.endsWith("@users.noreply.github.com")){let o=r.slice(0,r.indexOf("@")),s=o.includes("+")?o.slice(o.indexOf("+")+1):o;if(s.endsWith("bot")||s.includes("[bot]"))return!0}return!1}var vi="installation.json",Ti="cloud-bootstrap.lock",Pi=6e4;function Sr(e,t,n){let r=`${e}:${t??""}`;return n?`${n}:${r}`:r}function Oe(e=Ht()){return Kt(e,".ev-ai","agent-hook")}function wi(e=Ht()){return Kt(Oe(e),vi)}function Er(e){return Kt(ze(e),Ti)}function Rr(){return xi(8).toString("hex")}function _e(e){return fr("sha256").update(e).digest("hex").slice(0,16)}function y(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function yr(e){return/^[A-Za-z0-9._-]{8,64}$/.test(e)}function bi(e=process.env){let t=y(e.EV_AI_HOOK_INSTALLATION_ID);if(t){if(!yr(t)){h(`WARN: ignoring EV_AI_HOOK_INSTALLATION_ID (expected 8\u201364 chars [A-Za-z0-9._-], got length ${t.length})`);return}return t}}function Cr(e,t){return e&&yr(e)?e:(e&&h(`WARN: ignoring installation id override (expected 8\u201364 chars [A-Za-z0-9._-], got length ${e.length})`),bi(t))}function Mi(e){return/^[0-9a-f]{16}$/.test(e)}function Ni(e=process.env){if(y(e.GITHUB_ACTIONS)){let t=y(e.GITHUB_REPOSITORY_ID)??y(e.GITHUB_REPOSITORY),n=y(e.GITHUB_ACTOR)??y(e.GITHUB_TRIGGERING_ACTOR)??y(e.GITHUB_USER);if(t&&n)return _e(`github_actions|${t}|${n}`)}if(y(e.CODESPACES)||y(e.CODESPACE_NAME)){let t=y(e.CODESPACE_NAME);if(t)return _e(`codespaces|${t}`);let n=y(e.GITHUB_REPOSITORY_ID)??y(e.GITHUB_REPOSITORY),r=y(e.GITHUB_USER)??y(e.GITHUB_ACTOR);if(n&&r)return _e(`codespaces|${n}|${r}`)}if(y(e.GITLAB_CI)){let t=y(e.CI_PROJECT_ID)??y(e.CI_PROJECT_PATH),n=y(e.GITLAB_USER_LOGIN)??y(e.GITLAB_USER_EMAIL)??y(e.GITLAB_USER_NAME);if(t&&n)return _e(`gitlab|${t}|${n}`)}return null}var Ui="cursoragent@cursor.com";function Li(e){let t=y(e.CURSOR_USER_EMAIL);return!t||t.toLowerCase()===Ui?null:t}function Di(e,t){return y(e.CURSOR_PROJECT_DIR)??y(e.CLAUDE_PROJECT_DIR)??t}function Fi(e){return e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1").replace(/\.git$/i,"").toLowerCase()}async function Hi(e){let t=await T("git",["config","--get","remote.origin.url"],2e3,{cwd:e});return t?Fi(t):e}async function Ki(e){let t=y(await T("git",["config","--local","--get","user.email"],2e3,{cwd:e})||void 0);if(t&&!ae(null,t))return t;let n=y(await T("git",["log","-1","--format=%ae"],2e3,{cwd:e})||void 0);return n&&!ae(null,n)?n:null}function $i(e,t){let n=Di(e,t);return n?_e(`cursor_cloud|${n}|${Li(e)??""}`):null}async function Bi(e,t){let n=y(e.CLAUDE_PROJECT_DIR)??t;if(!n)return null;let r=await Hi(n),o=await Ki(n);return _e(`claude_remote|${r}|${o??""}`)}function lr(e,t){let n=Cr(e,t);if(n)return n;let r=Ni(t);return r||Rr()}async function ji(e){let n=await T("git",["config","--get","remote.origin.url"],2e3,{cwd:e})||Oi(e);return fr("sha256").update(n).digest("hex").slice(0,16)}function Gi(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 zi(e){try{let t=JSON.parse(e);if(typeof t.installation_id!="string"||t.installation_id.length===0)return;let n=Gi(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 le(e){if(mr(e))try{return zi(gr(e,"utf8"))}catch{}}function $t(e){return le(e)}function Ir(e,t,n){let r=le(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{Q(e,`${JSON.stringify(o,null,2)}
6
+ `)}catch(s){let i=s instanceof Error?s.message:String(s);h(`WARN: operator identity cache write failed open: ${i}`)}}function Ar(e,t=Date.now()){if(!e)return!0;if(le(e)?.operator_identity_hash)return!1;let n=Er(e);try{if(mr(n)){let r=Number.NaN;try{r=Number(gr(n,"utf8").trim())}catch{}let o=t-r;if(Number.isFinite(o)&&o>=0&&o<Pi)return!1;try{_r(n)}catch{}}}catch{}try{return Ft(ze(n),{recursive:!0}),hr(n,`${t}
7
+ `,{encoding:"utf8",flag:"wx"}),!0}catch(r){if(vr(r))return!1;let o=r instanceof Error?r.message:String(r);return h(`WARN: cloud bootstrap claim failed open: ${o}`),!0}}function kr(e){if(e)try{_r(Er(e))}catch{}}function xr(e,t){let r=le(e)?.platform_agent_ids?.[t];return typeof r=="string"&&r.length>0?r:void 0}function Or(e,t,n){if(!n)return;let r=le(e);if(!r||r.platform_agent_ids?.[t]===n)return;let o={installation_id:r.installation_id,platform_agent_ids:{...r.platform_agent_ids,[t]:n},...r.operator_identity_hash?{operator_identity_hash:r.operator_identity_hash}:{},...r.operator_identity_sent_at?{operator_identity_sent_at:r.operator_identity_sent_at}:{}};try{Q(e,`${JSON.stringify(o,null,2)}
8
+ `)}catch(s){let i=s instanceof Error?s.message:String(s);h(`WARN: platform_agent_id cache write failed open: ${i}`)}}function vr(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}function Wi(e,t){Ft(ze(e),{recursive:!0}),hr(e,`${JSON.stringify(t,null,2)}
9
+ `,{encoding:"utf8",flag:"wx"})}function ur(e,t){try{return Wi(e,t),t}catch(n){if(!vr(n))throw n;return le(e)}}function dr(e,t){Ft(ze(e),{recursive:!0}),Q(e,`${JSON.stringify(t,null,2)}
10
+ `)}function pr(e,t){return{installation_id:e,...t&&t===e?{pinned:!0}:{}}}async function Tr(e,t={}){let n=t.home??Ht(),r=t.env??process.env,o=await ji(e),s=wi(n),i={sessionId:t.sessionId,hostname:y(r.HOSTNAME)??void 0,osUser:y(r.USER)??y(r.LOGNAME)??y(r.USERNAME)??void 0,env:r},c=ke(i),a=Cr(t.overrideId,r),l=c==="cursor_cloud"&&bt(i)?$i(r,e):c==="claude_remote"?await Bi(r,e):null,u=le(s);if(u){let S=u;if(a&&a===u.installation_id&&u.pinned!==!0&&(S={...u,pinned:!0},dr(s,S)),!!l&&l!==S.installation_id&&!a&&S.pinned!==!0&&Mi(S.installation_id)&&l){let A={installation_id:l,...S.platform_agent_ids?{platform_agent_ids:S.platform_agent_ids}:{}};return dr(s,A),{installationId:l,storePath:s,repoKey:o}}return{installationId:S.installation_id,storePath:s,repoKey:o}}let d=a??l??lr(void 0,r),f=ur(s,pr(d,a));if(f)return{installationId:f.installation_id,storePath:s,repoKey:o};let p=a??l??lr(void 0,r),g=ur(s,pr(p===d?Rr():p,a));if(g)return{installationId:g.installation_id,storePath:s,repoKey:o};throw new Error(`Failed to create installation record at ${s}`)}var Vi=new Set(["localhost","127.0.0.1","[::1]","::1"]),Pr=/^[A-Za-z0-9._~-]+$/;function wr(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 We(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?Vi.has(t.hostname):!1}catch{return!1}}function br(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!We(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=Ji(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!Pr.test(n))return`org token must match ${Pr.source} (got: ${n})`;if(wr(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(wr(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function Mr(e){return new URL(e).toString()}function Ji(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.length>0?r:void 0}return}catch{return}}function Bt(e){try{let t=new URL(e),n=t.pathname.split("/").filter(r=>r.length>0);return n.length>=2&&n[n.length-1]==="hook"&&(n[n.length-2]="***",t.pathname=`/${n.join("/")}`),t.toString()}catch{return"<invalid-url>"}}function Nr(e){if(e.collector_url)return e.collector_url;let t=e.repo_ingest_token?.trim();return t?je(t):""}import{existsSync as dc}from"node:fs";import{existsSync as tc}from"node:fs";import{homedir as Dr}from"node:os";import{join as nc}from"node:path";import{existsSync as Yi,readdirSync as Ur}from"node:fs";import{homedir as Ve}from"node:os";import{join as D}from"node:path";function Xi(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/ClaudeCode";case"win32":return D(process.env.ProgramFiles??"C:\\Program Files","ClaudeCode");default:return"/etc/claude-code"}}function Zi(e=process.platform){let t=Xi(e),n=[D(t,"managed-settings.json")],r=D(t,"managed-settings.d");try{if(!Yi(r))return n;let o=Ur(r).filter(s=>s.endsWith(".json")&&!s.startsWith(".")).sort().map(s=>D(r,s));n.push(...o)}catch{}return n}function jt(e=process.platform,t=Ve()){return{serverManaged:D(t,".claude","remote-settings.json"),fileBased:Zi(e)}}function qi(e=process.platform){switch(e){case"darwin":return"/Library/Application Support/Cursor";case"win32":return D(process.env.ProgramData??"C:\\ProgramData","Cursor");default:return"/etc/cursor"}}function Qi(e=process.platform,t=Ve()){let n=[D(qi(e),"hooks.json")],r=D(t,".cursor","managed");try{for(let o of Ur(r,{withFileTypes:!0}))!o.isDirectory()||o.name.startsWith(".")||n.push(D(r,o.name,"hooks.json"))}catch{}return n}function ec(e=process.platform,t=Ve()){let n=e==="win32"?D(process.env.ProgramData??"C:\\ProgramData","OpenAI","Codex"):"/etc/codex",r=[D(n,"requirements.toml")];return e!=="win32"&&r.push(D(n,"managed_config.toml")),r.push(D(t,".codex","managed_config.toml"),D(n,"config.toml")),r}function Je(e,t=process.platform,n=Ve()){switch(e){case"claude":{let{serverManaged:r,fileBased:o}=jt(t,n);return[r,...o]}case"cursor":return Qi(t,n);default:return ec(t,n)}}function Fr(e){return e.settings.filter(t=>t.toLowerCase().endsWith(".json"))}var rc={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/cli-config.json"],mcpJson:[".cursor/mcp.json"]},homeOnly:{skillRoots:[".cursor/skills-cursor"],memory:[[".cursor/AGENTS.md"]],plugins:"cursor",managed:"cursor"},projectOnly:{skillRoots:[".agents/skills"]}},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 Lr(e,t){if(!(!e&&!t))return[...e??[],...t??[]]}function oc(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:Lr(n.mcpJson,t.mcpJson),mcpToml:Lr(n.mcpToml,t.mcpToml),plugins:t.plugins??n.plugins,managed:t.managed??n.managed}}function Hr(e){return Object.fromEntries(Object.entries(rc).map(([t,n])=>[t,oc(n,n[e])]))}var he=Hr("homeOnly"),ne=Hr("projectOnly");function sc(e){return[...e.skillRoots,...e.dirs.map(t=>t.dir),...e.memory.flat(),...e.settings,...e.mcpJson??[],...e.mcpToml??[]]}function ic(e,t){return sc(e).some(n=>tc(nc(t,n)))}function Kr(e,t){for(let n of e)if(ic(n,t))return!0;return!1}function te(e){return[...new Set(e)]}function re(e){let t=[],n=[],r=[],o=[],s=[],i=[],c=[];for(let a of e){t.push(...a.skillRoots);for(let l of a.dirs)l.kind==="SUBAGENT"?n.push(l.dir):l.kind==="COMMAND"?r.push(l.dir):o.push(l.dir);s.push(...a.memory.flat()),i.push(...a.settings),c.push(...a.mcpJson??[],...a.mcpToml??[])}return{skills:te(t),subagents:te(n),commands:te(r),rules:te(o),memory:te(s),settings:te(i),mcp:te(c)}}function cc(e,t=Dr(),n=process.platform){let r=[];for(let o of e)o.managed&&r.push(...Je(o.managed,n,t));return te(r)}var oe=re(Object.values(he));function $r(e=Dr(),t=process.platform){return cc(Object.values(he),e,t)}import{existsSync as ac}from"node:fs";import{resolve as Gt}from"node:path";function $(e){return Gt(e).replaceAll("\\","/").replace(/\/$/,"")}function ue(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 Ye(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 lc=/^(?!\.)[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*$/;function ve(e){let t=e.replaceAll("\\","/").replace(/^\.\//,"");return!t||t.startsWith("/")||/^[A-Za-z]:\//.test(t)||t.split("/").includes("..")||!lc.test(t)?null:t}function Se(e,t){let n=new Set,r=[];for(let o of[e,t]){if(!o)continue;let s=$(o);n.has(s)||(n.add(s),r.push(s))}return r}function uc(e,t){let n=`${e}/`;return t===e||t.startsWith(n)}function V(e,t,n,r=ac){for(let o of e)for(let s of t){let i=$(Gt(o,s)),c=Gt(o,s,n).replaceAll("\\","/");if(uc(i,c)&&r(c))return c}return null}var jr=/(?:^|\/|[\s"'=(])(?:\.cursor\/|\.claude\/|\.agents\/)skills(?:-cursor)?\/([^/]+)\/SKILL\.md/i,Gr=/(?:^|\/|[\s"'=(])\.codex\/commands\/([^/]+)\.md\b/i,pc=/(?:^|\s)\/([a-z][a-z0-9-]{1,63}(?:\/[a-z][a-z0-9-]{1,63}){0,5})\b/gi,Br=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"]),fc=/^[a-z][a-z0-9-]{1,63}$/,mc=[".cursor/skills",".claude/skills",".agents/skills"],gc=[".cursor/skills",".cursor/skills-cursor",".claude/skills",".agents/skills"],_c=ue(mc,re(Object.values(ne)).skills),hc=ue(gc,re(Object.values(he)).skills),Sc=new Set(["read","read_file","view"]),Ec=new Set(["bash","shell","zsh"]);function zt(e){let t=e.replace(/\\/g,"/");return jr.exec(t)?.[1]??null}function Rc(e){let t=e.replace(/\\/g,"/"),r=Gr.exec(t)?.[1];return r?r.toLowerCase():null}function yc(e){return zt(e)??Rc(e)}function Cc(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 Xe(e){return typeof e=="string"?Xe(M(e,null)):!e||typeof e!="object"?null:Cc(e)}function zr(e){if(typeof e=="string")return zr(M(e,null));if(!e||typeof e!="object")return null;let t=e.command;return typeof t=="string"&&t.length>0?t:null}function Wt(e){let t=zr(e.tool_input);if(t)return t;let n=ie(e.command);return n.length>0?n:null}function Ic(e){let t=e.replace(/\\/g,"/"),n=jr.exec(t);if(n?.[1])return n[1];let o=Gr.exec(t)?.[1];return o?o.toLowerCase():null}function Ac(e){return typeof e.tool_name=="string"?e.tool_name:typeof e.tool=="string"?e.tool:""}function Vt(e){let t=Xe(e.tool_input)??ie(e.file_path);return t.length>0?t:null}function Te(e,t,n){let r=Ac(e).toLowerCase();if(Sc.has(r)){let o=Vt(e);return o?t(o):null}if(Ec.has(r)){let o=Wt(e);return o?n(o):null}return null}function Wr(e){return Te(e,yc,Ic)}function kc(e){let t=new Set,n=[];for(let r of e.matchAll(pc)){let o=r[1]?.toLowerCase();!o||t.has(o)||xc(o)||(t.add(o),n.push(o))}return n}function xc(e){let t=e.split("/")[0];return Br.has(e)||t!==void 0&&Br.has(t)}function Vr(e){let t=e.skillId.toLowerCase();if(!fc.test(t))return null;let n=e.exists??dc,r=`${t}/SKILL.md`,o=V(Se(e.launchCwd,e.gitRoot),_c,r,n);return o!==null?o:e.home?V([$(e.home)],hc,r,n):null}function Oc(e){return ie(e.prompt)}function Jr(e){let t=m(e,"command_name");if(t){let r=m(e,"expansion_type");if(r&&r!=="slash_command")return[];let o=t.replace(/^\//,"").toLowerCase();return o?[o]:[]}let n=Oc(e);return n?kc(n):[]}var Jt=It(qe(),1);import{existsSync as Wc}from"node:fs";var de={claude:".claude",cursor:".cursor",codex:".codex",opencode:".opencode"};function Pe(e){let n=e.replace(/^\/+|\/+$/g,"").toLowerCase().split("/").filter(Boolean);return n.length<2?"":n.join("/")}function zc(e){if(!e)return"";let t=e.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1");t=t.replace(/\.git$/i,"");let n=t.match(/^git@[^:]+:(.+)$/);if(n?.[1])return Pe(n[1]);let r=t.match(/^ssh:\/\/[^/]+\/(.+)$/i);if(r?.[1])return Pe(r[1]);t=t.replace(/^https:\/\//i,""),t=t.replace(/^http:\/\//i,""),t=t.replace(/^ssh:\/\//i,"");let o=t.match(/^[^/]+\/(.+)$/);return o?.[1]?Pe(o[1]):Pe(t)}async function we(e=process.cwd()){let t=await G("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([G("git",["remote","get-url","origin"],2e3,{cwd:e}),G("git",["branch","--show-current"],2e3,{cwd:e}),G("git",["rev-parse","HEAD"],2e3,{cwd:e}),G("git",["status","--porcelain"],2e3,{cwd:e})]),i=n.ok?n.stdout:null;return{remote:i===null?null:i.replace(/^([a-z]+:\/\/)[^/@]+@/i,"$1"),branch:r.ok?r.stdout:null,head:o.ok?o.stdout:null,dirty:s.ok?s.stdout.length>0:null}}async function qr(e,t,n,r=process.cwd(),o,s,i){if(t)return t;let c=de[n];if(!c)return"";let a=Sr(n,e.scope_path,i);if(s){let g=xr(s,a);if(g)return g}let l=o??await we(r),u=l?.remote?zc(l.remote):"";if(u||(u=Pe(process.env.GITHUB_REPOSITORY??"")),!u)return"";let d=e.scope_path??"",f=d?`${d}/`:"",p=`${u}:${f}${c}`;return s&&Or(s,a,p),p}var Vc=[".cursor/rules",".claude/rules",".codex/rules"],Jc=re(Object.values(ne)).rules;function Yc(e){return ue(Ye(e?de[e]:void 0,Vc),Jc)}var Xc=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/rules\/[^'"\s]+?\.(?:mdc|md|rules))\b/i;function Qr(e){let t=ve(e.relativePath);if(!t)return null;let n=e.exists??Wc,r=Se(e.launchCwd,e.gitRoot),o=Yc(e.runnerPlatform),s=V(r,o,t,n);if(s!==null)return s;if(!t.includes("/")){let i=V(r,["."],t,n);if(i!==null)return i}return e.home?V([$(e.home)],o,t,n):null}function Zc(e){let t=e.replace(/\\/g,"/"),r=Xc.exec(t)?.[1];return r?(0,Jt.nativeKeyForRulePath)(r):null}function eo(e){return Te(e,Jt.nativeKeyForRulePath,Zc)}function to(e){return e.replace(/\.(mdc|md|rules)$/i,"")}function no(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:"",c=ve(i);!c||n.has(c)||(n.add(c),r.push(c))}return r}var Yt=It(qe(),1);import{existsSync as qc}from"node:fs";var Qc=[".cursor/commands",".claude/commands",".codex/prompts"],ea=re(Object.values(ne)).commands;function ta(e){return ue(Ye(e?de[e]:void 0,Qc),ea)}var na=/(?:^|\/|[\s"'=(])((?:\.cursor|\.claude|\.codex)\/(?:commands|prompts)\/[^'"\s]+?\.(?:md|mdc))\b/i;function ro(e){let t=ve(e.commandId);if(!t)return null;let n=e.exists??qc,r=`${t}.md`,o=ta(e.runnerPlatform),s=V(Se(e.launchCwd,e.gitRoot),o,r,n);return s!==null?s:e.home?V([$(e.home)],o,r,n):null}function ra(e){let t=e.replace(/\\/g,"/"),r=na.exec(t)?.[1];return r?(0,Yt.nativeKeyForCommandPath)(r):null}function oo(e){return Te(e,Yt.nativeKeyForCommandPath,ra)}import{existsSync as io}from"node:fs";import{homedir as co}from"node:os";import{join as be,resolve as Xt,sep as so}from"node:path";function Zt(e){return[...new Set([e,e.replaceAll(/[^A-Za-z0-9_-]/g,"_"),e.replaceAll(/[^A-Za-z0-9_-]+/g,"_")])]}function qt(e,t){let n=t.toLowerCase();return Zt(e).some(r=>r.toLowerCase()===n)}function Qe(e,t,n){if(!io(e))return;let r=W(e,{});for(let[o,s]of Object.entries(r.mcpServers??{}))n.set(o,{declared:{name:o,...t},config:s})}function oa(e,t,n){if(!io(e))return;let r=W(e,{}),o=Xt(t),s=null;for(let c of Object.keys(r.projects??{})){let a=Xt(c);(o===a||o.startsWith(a.endsWith(so)?a:a+so))&&(s===null||a.length>Xt(s).length)&&(s=c)}if(s===null)return;let i=r.projects?.[s]?.mcpServers??{};for(let[c,a]of Object.entries(i))n.set(c,{declared:{name:c,source:"claude_json_project",sourcePath:".claude.json",scope:"user"},config:a})}function ao(e,t,n,r){let o=new Map;for(let s of e.mcp_servers??[])s.name&&o.set(s.name,{declared:{name:s.name,source:"manifest"}});return n==="claude"?(Qe(be(r,".claude.json"),{source:"claude_json_user"},o),oa(be(r,".claude.json"),t,o)):n==="cursor"&&Qe(be(r,".cursor/mcp.json"),{source:"cursor_mcp_user"},o),Qe(be(t,".mcp.json"),{source:"mcp_json"},o),Qe(be(t,".cursor/mcp.json"),{source:"cursor_mcp"},o),o}async function Qt(e,t=process.cwd(),n="claude",r=co()){return[...ao(e,t,n,r).values()].map(o=>o.declared)}function lo(e,t,n=process.cwd(),r="claude",o=co()){let s=ao(t,n,r,o),i=s.get(e);if(i!==void 0)return i.config??null;for(let[c,a]of s)if(qt(c,e))return a.config??null;return null}function en(e){return e!==void 0&&ar.includes(e)}function et(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function tt(e){let t,n,r,o,s;for(let i=0;i<e.length;i++){let c=e[i];if(c!==void 0){if(c==="--runner"){let a=et(e,i);t=a.value,i=a.next;continue}if(c.startsWith("--runner=")){t=c.slice(9);continue}if(c==="--url"){let a=et(e,i);a.value&&(r=a.value),i=a.next;continue}if(c.startsWith("--url=")){r=c.slice(6);continue}if(c==="--token"){let a=et(e,i);a.value&&(o=a.value),i=a.next;continue}if(c.startsWith("--token=")){o=c.slice(8);continue}if(c==="--base-url"){let a=et(e,i);a.value&&(s=a.value),i=a.next;continue}if(c.startsWith("--base-url=")){s=c.slice(11);continue}!c.startsWith("-")&&n===void 0&&(n=c)}}return{runner:en(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:s}}function tn(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=je(o,e.baseUrl?.trim()??void 0))}if(!n)return;let r=br(n);if(r){h(`WARN: ignoring --url/--token collector override: ${r}`);return}return Mr(n)}function uo(e,t){if(m(e,"conversation_id"))return!0;if(t==="")return!1;let n=t[0];return n?.toLowerCase()===n}function sa(){return!!(I("CURSOR_VERSION")??I("CURSOR_PROJECT_DIR"))}function nn(e,t,n){return e!=="claude"&&e!=="codex"?!1:uo(t,n)?!0:sa()}function Me(e,t,n,r){if(uo(e,t))return"cursor";if(en(r))return r;let o=m(e,"conversation_id"),s=m(e,"turn_id"),i=m(e,"session_id"),c=t.toLowerCase(),a="unknown";return o||t===c&&t!==""?a="cursor":s?a="codex":(i||c==="sessionstart"||c==="sessionend"||c==="stop"||c==="stopfailure"||c==="pretooluse"||c==="posttooluse"||c==="posttoolusefailure"||c==="permissiondenied"||c==="subagentstart"||c==="subagentstop"||c==="userpromptexpansion")&&(a="claude"),en(n)&&(a=n),a}function nt(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function ia(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 po(e){let t=e.toLowerCase();return t==="posttooluse"?!0:t==="posttoolusefailure"||t==="permissiondenied"?!1:null}function fo(e,t,n){let r=m(e,"session_id")||m(e,"conversation_id"),o=m(e,"prompt.id")||m(e,"prompt_id")||m(e,"generation_id")||m(e,"turn_id"),s=m(e,"hook_event_name")||m(e,"event"),i=m(e,"source"),c=Me(e,s,t,n);return{sessionId:r,turnId:o,runnerEvent:s,hookSource:i,runnerPlatform:c}}var ca=["session_start","session_end","tool_invoked","skill_invoked"];function aa(e){return ca.includes(e)}function mo(e,t){return e&&aa(e)?e:ia(t.toLowerCase())}var la={beforeshellexecution:"Shell",aftershellexecution:"Shell",beforereadfile:"Read",afterfileedit:"Write"};function go(e){return/^mcp__/i.test(e)||/^MCP:/i.test(e)}function _o(e,t=""){let n=m(e,"tool_name")||m(e,"tool")||null,r=t.toLowerCase();n?r==="beforemcpexecution"&&!go(n)&&(n=`MCP:${n}`):n=la[r]??null;let o=e.tool_input,i=(o&&typeof o=="object"?ie(o.skill)||ie(o.skill_name):"")||m(e,"skill_name")||null,c=n&&e.tool_name!==n&&e.tool!==n?{...e,tool_name:n}:e;i??=Wr(c);let a=eo(c),l=oo(c);return{toolName:n,skillName:i,ruleName:a,commandName:l}}var ua=/^[A-Za-z][A-Za-z0-9_.:-]{0,63}$/;function ho(e){for(let t of["subagent_type","agent_type"]){let n=m(e,t);if(n&&ua.test(n))return n}return null}function So(e){let t=ce(e,"duration_ms");if(typeof t=="number")return t;let n=ce(e,"duration");return typeof n=="number"?n:null}var da="error",pa="interrupted",fa="permission_denied",ma=/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/;function Ne(e){return ma.test(e)?e:null}function ga(e){for(let t of["failure_type","error_type"]){let n=Ne(m(e,t));if(n)return n}return null}function Eo(e,t){return ce(e,"is_interrupt")===!0?pa:t.toLowerCase()==="permissiondenied"?fa:ga(e)??da}function _a(e,t){let n=null;for(let r of t)r&&(e===r||e.startsWith(`${r}_`)||e.startsWith(`${r}-`))&&(n===null||r.length>n.length)&&(n=r);return n}function ha(e,t){let n=null;for(let r of t)!r||!qt(r,e)||(n===null||r.length>n.length)&&(n=r);return n}function Sa(e,t){let n=null,r=0;for(let s of t)if(s)for(let i of Zt(s)){let c=`${i}__`;e.length>c.length&&e.slice(0,c.length).toLowerCase()===c.toLowerCase()&&i.length>r&&(n={mcpServer:s,mcpTool:e.slice(c.length)},r=i.length)}if(n!==null)return n;let o=/^(.+?)__(.+)$/.exec(e);return!o?.[1]||!o[2]?{mcpServer:null,mcpTool:null}:{mcpServer:ha(o[1],t)??o[1],mcpTool:o[2]}}function Ea(e,t){if(/^mcp__/i.test(e))return Sa(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:_a(n,t),mcpTool:n}}return{mcpServer:null,mcpTool:null}}function Ra(e,t){let n=`${t}__`;return e.length>n.length&&e.toLowerCase().startsWith(n.toLowerCase())?e.slice(n.length):e}function Ro(e,t=[],n=""){let r=e?Ea(e,t):{mcpServer:null,mcpTool:null},o=Ne(n.trim());if(!o)return r;let s=r.mcpTool;return!s&&e&&!go(e)&&(s=e),s&&(s=Ra(s,o)),{mcpServer:o,mcpTool:s}}var Ao=3e4,xa="claims",Oa=!0,va=100,Ta=new Set(["sessionstart","sessionend","stopfailure"]),Pa=["tool_name","tool","command","file_path","url"];function wa(e=Io()){return rn(Oe(e),xa)}function ko(e){let t=e.split(`
11
+ `,1)[0]??"";return Number(t.trim())}function xo(e){return ya("sha256").update(e).digest("hex").slice(0,32)}function ba(e){let t=[];for(let n of Pa){let r=m(e,n).trim();r&&t.push(`${n}=${r}`)}return t.length===0?"":xo(t.join("\0"))}function Ma(e){let t=e.sessionId.trim();if(!t)return;let n=e.runnerEvent.trim().toLowerCase(),r=e.turnId.trim(),o=e.toolUseId.trim(),s=e.subagentId?.trim()??"",i=e.callFingerprint?.trim()??"",c=!!(o||r||s),a=Ta.has(n);if(!c&&!a)return;let l=e.runnerPlatform.trim()||"unknown";return xo(`${l}|${t}|${n}|${r}|${o}|${i}|${s}`)}function Na(e){return e instanceof Error&&"code"in e&&e.code==="EEXIST"}function Ua(e,t){return rn(e,t)}function La(e,t=Date.now()){let n;try{n=Aa(e)}catch{return}let r=0;for(let o of n){if(r>=va)break;r+=1;let s=rn(e,o),i=Number.NaN;try{i=ko(yo(s,"utf8"))}catch{continue}let c=t-i;if(!(!Number.isFinite(c)||c<0||c<Ao))try{Co(s)}catch{}}}function Da(e,t,n=Date.now()){let r=Ua(t,e);try{if(Ca(r)){let o=Number.NaN;try{o=ko(yo(r,"utf8"))}catch{}let s=n-o;if(Number.isFinite(s)&&s>=0&&s<Ao)return!1;try{Co(r)}catch{}}}catch{}try{Ia(t,{recursive:!0}),ka(r,`${n}
12
+ `,{encoding:"utf8",flag:"wx"})}catch(o){if(Na(o))return!1;let s=o instanceof Error?o.message:String(o);return h(`WARN: event claim failed open: ${s}`),!0}return La(t,n),!0}function Fa(e,t,n){let r=m(e,"session_id")||m(e,"conversation_id"),o=m(e,"prompt.id")||m(e,"prompt_id")||m(e,"generation_id")||m(e,"turn_id"),s=m(e,"tool_use_id"),i=m(e,"subagent_id")||m(e,"agent_id"),c=Me(e,t,void 0,n),a=ba(e);return{runnerPlatform:c,sessionId:r,runnerEvent:t,turnId:o,toolUseId:s,subagentId:i,callFingerprint:a}}function Oo(e,t,n,r=Io(),o=Date.now()){if(!Oa)return!0;let s=Ma(Fa(e,t,n));if(!s)return!0;let i=Da(s,wa(r),o);return!i&&I("EV_AI_HOOK_DEBUG")&&h(`DEBUG: duplicate hook event suppressed (claim ${s.slice(0,8)}\u2026)`),i}import{realpathSync as Rd}from"node:fs";import{homedir as yd}from"node:os";var C=It(qe(),1);import{existsSync as Ha,readFileSync as Ka}from"node:fs";import{homedir as vo}from"node:os";import{join as $a}from"node:path";var Ba="cloud-cache.json",ja=1440*60*1e3,Ga=900*1e3;function za(e=vo()){return $a(Oe(e),Ba)}function Wa(e){if(!Ha(e))return;let t=M(Ka(e,"utf8"),{});if(!(typeof t.context!="string"||typeof t.probed_at!="number"||t.result!==null&&t.result!==void 0&&typeof t.result!="object"))return{context:t.context,probed_at:t.probed_at,result:t.result??null}}function Va(e,t){try{Q(e,`${JSON.stringify(t)}
13
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);h(`WARN: cloud cache write failed open: ${r}`)}}function Ja(e,t,n){if(!e||e.context!==t)return!1;let r=e.result===null?Ga:ja;return n-e.probed_at<r}async function Ya(e){let t=await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"60"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=(await t.text()).trim();if(!n)return;let r={"X-aws-ec2-metadata-token":n},[o,s]=await Promise.all([fetch("http://169.254.169.254/latest/meta-data/placement/region",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{}),fetch("http://169.254.169.254/latest/meta-data/instance-id",{headers:r,signal:AbortSignal.timeout(e)}).catch(()=>{})]);if(!o?.ok&&!s?.ok)return;let i=o?.ok?(await o.text()).trim():"",c=s?.ok?(await s.text()).trim():"";if(!(!i&&!c))return{provider:"aws",region:i,instance_id:c}}async function Xa(e){let t=await fetch("http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true",{headers:{"Metadata-Flavor":"Google"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=typeof n.zone=="string"?n.zone.split("/").pop()??"":"",o=n.id===void 0?"":String(n.id);if(!(!r&&!o))return{provider:"gcp",region:r,instance_id:o}}async function Za(e){let t=await fetch("http://169.254.169.254/metadata/instance?api-version=2021-02-01",{headers:{Metadata:"true"},signal:AbortSignal.timeout(e)}).catch(()=>{});if(!t?.ok)return;let n=await t.json(),r=n.compute?.location??"",o=n.compute?.vmId??"";if(!(!r&&!o))return{provider:"azure",region:r,instance_id:o}}async function qa(e){let t=await Promise.allSettled([Ya(e),Xa(e),Za(e)]);for(let n of t)if(n.status==="fulfilled"&&n.value)return n.value;return null}async function on(e,t){if(e==="interactive")return null;let n=t?.home??vo(),r=t?.timeoutMs??1e3,o=t?.nowMs??Date.now(),s=za(n),i=Wa(s);if(Ja(i,e,o))return i.result;let c=await qa(r);return Va(s,{context:e,probed_at:o,result:c}),c}var Qa=["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"],el=["CURSOR_PROJECT_DIR"],tl=new Set(["key","api-key","api_key","apikey","token","sig","signature","access_token","password","pwd","secret","client_secret"]);function nl(e){try{let t=new URL(e);(t.username||t.password)&&(t.username="",t.password="");for(let[n]of t.searchParams)tl.has(n.toLowerCase())&&t.searchParams.set(n,"[redacted]");return t.toString()}catch{return e}}function sn(e=process.env){let t=Qa.map(r=>Object.prototype.hasOwnProperty.call(e,r)?{name:r,present:!0,value:nl(e[r]??"")}:{name:r,present:!1}),n=el.map(r=>({name:r,present:Object.prototype.hasOwnProperty.call(e,r)&&!!e[r]}));return[...t,...n]}import{createHash as rl}from"node:crypto";import{resolve as ol}from"node:path";function v(e){return rl("sha256").update(e).digest("hex").slice(0,16)}function cn(e){return v(ol(e))}function B(e,t){return`${e}\0${t}`}function To(e){let t=e.indexOf("\0");return t<=0?null:{path:e.slice(0,t),name:e.slice(t+1)}}function Ue(e){let n=[...e].sort((r,o)=>{let s=r.path.localeCompare(o.path);return s!==0?s:r.name.localeCompare(o.name)}).map(r=>`${r.path}|${r.name}|${r.content_hash}`).join(`
14
+ `);return v(n)}function sl(e,t,n="git_config",r=null){return v(`${e??""}|${t??""}|${r??""}|${n}`)}function il(e){let t=null,n=null;for(let r of e.split(`
15
+ `)){let o=r.trim();if(!o)continue;let s=o.indexOf(" ");if(s<=0)continue;let i=o.slice(0,s).toLowerCase(),c=o.slice(s+1).trim();c&&(i==="user.name"?t=c:i==="user.email"&&(n=c))}return{git_user_name:t,git_user_email:n,platform_login:null}}async function cl(e,t=T){let n=await t("git",["config","--get-regexp","^user\\.(name|email)$"],2e3,{cwd:e});return il(n)}function al(e=process.env){let t=R(e.GIT_AUTHOR_NAME),n=R(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=R(e.GIT_COMMITTER_NAME),o=R(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=R(e.EMAIL);return s?{git_user_name:null,git_user_email:s,platform_login:null,identity_source:"git_env"}:null}function Y(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 ll(e=process.env){let t=Y(R(e.EV_AI_HOOK_OPERATOR_NAME),R(e.EV_AI_HOOK_OPERATOR_EMAIL),"configured",R(e.EV_AI_HOOK_OPERATOR_LOGIN));if(t)return t;let n=R(e.GITHUB_ACTOR)??R(e.GITHUB_TRIGGERING_ACTOR)??R(e.GITHUB_USER),r=Y(n,null,"github",n);if(r)return r;let o=R(e.GITLAB_USER_LOGIN),s=Y(R(e.GITLAB_USER_NAME)??o,R(e.GITLAB_USER_EMAIL),"gitlab",o);if(s)return s;let i=Y(R(e.BUILD_REQUESTEDFOR),R(e.BUILD_REQUESTEDFOREMAIL),"azure_devops",R(e.BUILD_REQUESTEDFORID));if(i)return i;let c=R(e.BUILDKITE_BUILD_CREATOR_EMAIL),a=Y(R(e.BUILDKITE_BUILD_CREATOR),c,"buildkite",c);if(a)return a;let l=Y(R(e.BUILD_USER)??R(e.CHANGE_AUTHOR),R(e.BUILD_USER_EMAIL)??R(e.CHANGE_AUTHOR_EMAIL),"jenkins",R(e.BUILD_USER_ID));if(l)return l;let u=R(e.CIRCLE_USERNAME),d=Y(u,null,"circleci",u);if(d)return d;let f=R(e.CODEBUILD_INITIATOR),p=Y(f,null,"codebuild",f);if(p)return p;let g=Y(R(e.DRONE_COMMIT_AUTHOR)??R(e.DRONE_COMMIT_AUTHOR_NAME),R(e.DRONE_COMMIT_AUTHOR_EMAIL),"drone",R(e.DRONE_COMMIT_AUTHOR));if(g)return g;if(wo(e.CLAUDE_CODE_REMOTE)||wo(e.CURSOR_AGENT)){let S=R(e.CURSOR_USER_EMAIL);return{git_user_name:null,git_user_email:S&&!ae(null,S)?S:null,platform_login:null,identity_source:"cloud"}}return null}function Po(e){return!!((e.git_user_name??e.git_user_email)&&!ae(e.git_user_name,e.git_user_email))}function R(e){if(e===void 0)return null;let t=e.trim();return t.length>0?t:null}function wo(e){if(e===void 0||e==="")return!1;let t=e.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="no"}async function ul(e,t=T,n=process.env){let r=await cl(e,t);if(Po(r))return{...r,identity_source:"git_config"};let o=al(n);if(o&&Po(o))return o;let s=ll(n);return s||(r.git_user_name||r.git_user_email?{...r,identity_source:"git_config"}:o||{git_user_name:null,git_user_email:null,platform_login:null,identity_source:"git_config"})}async function rt(e){let{gitRoot:t,installationStorePath:n,forceResend:r}=e,o=e.exec??T,s=e.env??process.env,i=await ul(t,o,s),c=sl(i.git_user_name,i.git_user_email,i.identity_source,i.platform_login),l=(n?$t(n):void 0)?.operator_identity_hash;if(!(r||l!==void 0&&l!==c||!l))return{commit:()=>{}};let p=n;return{operator:i,commit:()=>{p&&Ir(p,c,Be())}}}function an(e){return e?!$t(e)?.operator_identity_hash:!0}function bo(e){return!0}import{existsSync as Nu,readFileSync as Uu}from"node:fs";import{homedir as Is}from"node:os";import{join as Ce,resolve as Lu}from"node:path";import{basename as Ou,join as ye}from"node:path";import{dirname as Ko,resolve as it}from"node:path";import{existsSync as dl}from"node:fs";import{homedir as Uo}from"node:os";import{relative as Lo,resolve as J,sep as se}from"node:path";var pl=["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"];function fl(e){return e.capture_hook_input==="full"?!0:e.capture_hook_input==="allowlist"?!1:I("EV_AI_HOOK_CAPTURE_FULL_INPUT")==="1"}function ml(e){let t={};for(let n of pl){let r=ce(e,n);r!==void 0&&(t[n]=r)}return t}function ot(e,t){if(typeof e!="string"||e.length===0||!t)return null;let n=J(e),r=J(t),o=Lo(r,n);return!o||o==="."?".":o.startsWith(`..${se}`)||o===".."||J(r,o)!==n?null:o.split(se).join("/")}function Do(e,t){let n=Lo(J(t),J(e)).split(se).join("/");return!n||n==="."?null:n===".."||n.startsWith("../")&&n.split("/").every(r=>r==="..")?n:null}function Fo(e){return typeof e!="string"||e.length===0?null:J(e).split(se).join("/")}function gl(){let e=I("CURSOR_PROJECT_DIR");if(!e)return null;let t=J(e);return dl(t)?t.split(se).join("/"):null}function ln(e,t){return ot(e,t)!==null}function _l(e,t){let n=J(t??Uo(),".cursor").split(se).join("/");return ln(e,n)}function hl(e,t,n){return t!==null&&ln(e,t)?!0:t!==null&&_l(e,n.home)?!1:n.inGitRepo===!0&&n.gitRoot!==void 0&&ln(e,n.gitRoot)?!0:t===null}function Ho(e,t){let n=Fo(e.cwd);if(n!==null)return n;let r=J(process.cwd()).split(se).join("/"),o=gl();return hl(r,o,t)?r:o??r}function un(e,t={}){return Ho(e,t)}function dn(e,t=Uo()){let n=J(t).split(se).join("/").replace(/\/$/,"");return n.length<=1?e:e===n?"~":e.startsWith(`${n}/`)?`~${e.slice(n.length)}`:e}function Mo(e,t,n){let r=Fo(n.launchCwd)??Ho(t,n);e.cwd=dn(r,n.home);let o=n.inGitRepo===!0&&n.gitRoot!==void 0?ot(r,n.gitRoot):null;o!==null&&(e.cwd_relative=o)}function No(e,t){let n=JSON.stringify(e),r=Buffer.byteLength(n,"utf8");if(r<=t)return e;let o=Object.entries(e).filter(([i,c])=>!i.startsWith("_")&&(typeof c=="string"||typeof c=="number"||typeof c=="boolean")).sort((i,c)=>Buffer.byteLength(JSON.stringify(i[1]),"utf8")-Buffer.byteLength(JSON.stringify(c[1]),"utf8")),s={_truncated:!0,_original_bytes:r};for(let[i,c]of o){let a={...s,[i]:c};if(Buffer.byteLength(JSON.stringify(a),"utf8")>t)break;s[i]=c}return s}function st(e,t,n={}){if(fl(t)){let o={...e};return delete o.cwd,delete o.transcript_path,Mo(o,e,n),No(o,ir)}let r=ml(e);return Mo(r,e,n),No(r,sr)}function Sl(e){return typeof e=="string"&&e.length>0}function pn(e){let t=it(e.home),n=it(e.launchCwd),r=e.gitRoot?it(e.gitRoot):null,o=new Set,s=[],i=null;e.inGitRepo&&Sl(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 c=null,a=r!==null&&ot(n,r)!==null;if(e.inGitRepo&&r!==null&&r!==t&&a){let l=Ko(r);for(;;){let u=it(l);if(u===t)break;let d=Ko(u);if(d===u)break;if(e.hasProjectSpec(u)){s.push({scope:"parent",dir:u}),c=Do(u,n);break}l=d}}return{anchors:s,parentRel:c}}import{existsSync as $o,readdirSync as El,realpathSync as Rl}from"node:fs";import{basename as yl,dirname as Cl,relative as Il,resolve as Al,sep as kl}from"node:path";var fn=400,ct=class{constructor(t,n={}){this.home=t;this.pathMode=n.pathMode??"home-relative",this.maxEntries=n.maxEntries??ee}components=[];truncated=!1;pathMode;maxEntries;pluginExpandRemaining;seenRealpaths=new Set;componentPath(t){if(this.pathMode==="tilde"){let r=Al(t).split(kl).join("/");return dn(r,this.home)}let n=Il(this.home,t).replace(/\\/g,"/");return!n||n.startsWith("..")?`external/${v(Cl(t))}/${yl(t)}`:n}claimFile(t){try{let n=Rl(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(!$o(t))return[];try{return El(t,{withFileTypes:!0})}catch{return[]}}readJson(t,n){if($o(t))return W(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 mn,readFileSync as xl,statSync as Ol}from"node:fs";import{basename as jo,join as Le,relative as Go}from"node:path";var gn=100*1024,vl=4;function Tl(e){return e.length<=gn?e:`${e.slice(0,gn-1)}\u2026`}function Pl(e){try{let t=xl(e),n=t.toString("utf8");return{hash:v(t),length:t.length,text:Tl(n)}}catch{return null}}var Bo={HOOK:"EVENT",COMMAND:"EXPLICIT_INVOCATION",MEMORY:void 0,MCP_SERVER:void 0,PLUGIN:void 0,SKILL:"UNSPECIFIED",RULE:"UNSPECIFIED",SUBAGENT:"UNSPECIFIED"};function wl(e){return e in Bo?Bo[e]:"UNSPECIFIED"}function at(e,t){if(!e.claimFile(t.absolutePath))return!1;let n=Pl(t.absolutePath);if(!n)return!1;let r=t.name??jo(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=wl(t.kind);return s&&(o.trigger=s),e.push(o)}function bl(e,t,n){let r=Go(e,t).replace(/\\/g,"/");return!r||r.startsWith("..")?jo(t).replace(/\.(md|mdc|toml)$/i,""):n?r.replace(/\.(md|mdc|toml)$/i,""):r}function pe(e,t){let{dir:n,kind:r,origin:o,enabled:s,nested:i,extensions:c}=t;_n(e,{walkRoot:n,currentDir:n,depth:0,kind:r,origin:o,enabled:s,nested:i,extensions:c})}function _n(e,t){let{walkRoot:n,currentDir:r,depth:o,kind:s,origin:i,enabled:c,nested:a,extensions:l}=t;if(!(o>vl))for(let u of e.readEntries(r)){if(e.atGlobalCap){e.truncated=!0;return}if(e.pluginBudgetSpent)return;if(a){if(!u.isDirectory())continue;let p=Le(r,u.name,a);if(mn(p)){let g=Go(n,Le(r,u.name)).replace(/\\/g,"/");at(e,{absolutePath:p,kind:s,origin:i,enabled:c,name:g||u.name});continue}_n(e,{walkRoot:n,currentDir:Le(r,u.name),depth:o+1,kind:s,origin:i,enabled:c,nested:a,extensions:l});continue}if(u.isDirectory()){_n(e,{walkRoot:n,currentDir:Le(r,u.name),depth:o+1,kind:s,origin:i,enabled:c,nested:a,extensions:l});continue}if(!u.isFile()||!l)continue;let d=u.name.toLowerCase();if(!l.some(p=>d.endsWith(p)))continue;let f=Le(r,u.name);at(e,{absolutePath:f,kind:s,origin:i,enabled:c,name:bl(n,f,!0)})}}function zo(e){for(let t of e)if(mn(t))try{if(Ol(t).size>0)return t}catch{continue}return e.find(t=>mn(t))}var Ml="<omitted>",Nl=["package_name","package_spec","package_version","package_version_source"],Wo=100,Vo=120,lt=[{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"}],Jo=new Set(lt.map(e=>e.attr)),Ul=["enabled","disabled"],Ll=["serverUrl","auth","bearer_token_env_var","default_tools_approval_mode","defaultToolsApprovalMode","env_vars","env_http_headers","http_headers"],Dl=new Set(["type","command","url","args","env","envVars","headers",...Ul,...Ll,...lt.map(e=>e.raw)]),Fl=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",...Nl,...Jo,...[...Jo].map(e=>`${e}_truncated`)]);function Yo(e,t){for(let n of t)Dl.has(n)||Fl.has(n)||(e[n]=Ml)}var Hl=/^(authorization|auth|api[-_]?key|access[-_]?token|refresh[-_]?token|secret|password|passwd|token|bearer|client[-_]?secret|client[-_]?id|private[-_]?key|signing[-_]?key)$/i,Kl=/(?:^|[-_])(secret|password|passwd|token|api[-_]?key|private[-_]?key|signing[-_]?key|client[-_]?secret|client[-_]?id)(?:[-_]|$)/i,$l=/^(sk-|ghp_|gho_|github_pat_|xox[baprs]-|AKIA|ASIA|AIza|ya29\.)/,Bl=/^bearer(?:\s+|$)/i;function ut(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function Xo(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function hn(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=ut(e);return t?Object.keys(t).filter(n=>n.length>0):[]}function fe(e){try{let t=new URL(e);return`${t.origin}${t.pathname}`}catch{return e}}function jl(e){return $l.test(e)||Bl.test(e)?"<redacted>":e.includes("://")?fe(e):e}function Zo(e){if(/^https?:\/\//i.test(e))return fe(e);let t=e.indexOf("=");return t>0?`${e.slice(0,t+1)}${Zo(e.slice(t+1))}`:jl(e)}function Gl(e){let t=e.replace(/^-+/,"").split("=",1)[0]??"";return Hl.test(t)||Kl.test(t)}function dt(e){let t=[],n=!1;for(let r of e){if(n){t.push("<redacted>"),n=!1;continue}if(Gl(r)){t.push("<redacted>"),n=!r.includes("=");continue}t.push(Zo(r))}return t}function zl(e){let t=Xo(e);if(t.length===0)return;let n=[...new Set(t.map(r=>r.length>Vo?r.slice(0,Vo):r))].sort();if(n.length!==0)return n.length>Wo?{names:n.slice(0,Wo),truncated:!0}:{names:n,truncated:!1}}function Wl(e){let t=ut(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 qo(e,t){let n=new Set;for(let{raw:r,attr:o}of lt){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=zl(s);i&&(e[o]=i.names,i.truncated&&(e[`${o}_truncated`]=!0),n.add(o))}}function Qo(e,t){let n=ut(e),r={transport:t};if(!n)return r;Yo(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,c=o??s??i;c&&(r.command_or_url=fe(c));let a=dt(Xo(n.args));a.length>0&&(r.args=a);let l=Wl(n.env_http_headers),u=[...new Set([...hn(n.env),...hn(n.envVars),...hn(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();u.length>0&&(r.env_var_names=u),l.headers.length>0&&(r.env_http_header_names=[...new Set(l.headers)].sort());for(let g of["headers","http_headers","env_http_headers"])if(n[g]!==void 0&&n[g]!==null){r.headers_present=!0;break}let d=typeof n.auth=="string"?n.auth:void 0;d&&(r.auth=d);let f=typeof n.bearer_token_env_var=="string"?n.bearer_token_env_var:void 0;f&&(r.bearer_token_env_var=f);let p=typeof n.default_tools_approval_mode=="string"?n.default_tools_approval_mode:typeof n.defaultToolsApprovalMode=="string"?n.defaultToolsApprovalMode:void 0;return p&&(r.default_tools_approval_mode=p),qo(r,n),r}function es(e){let t=ut(e);return t?t.enabled===!1?!1:t.disabled!==!0:!0}function Rn(e,t,n=!0){let r=Object.keys(t).sort().map(o=>[o,t[o]??null]);return v(JSON.stringify({name:e,attributes:r,enabled:n}))}function Ee(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}function De(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 Vl(e,t){return dt(De(e,t))}function En(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(true|false)\\s*$`,"m").exec(e);if(n?.[1])return n[1]==="true"}function Sn(e,t){let n=new RegExp(`^\\s*${t}\\s*=\\s*(.+)$`,"m").exec(e);if(!n?.[1])return;let r=Ee(n[1]);return r.length>0?r:void 0}function Jl(e,t){let n=[],r=i=>{for(let c of i.split(/[,\n]/)){let a=/^\s*"?([A-Za-z_][A-Za-z0-9_-]*)"?\s*=\s*(.+?)\s*$/.exec(c);a?.[1]&&n.push([a[1],Ee(a[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(`
16
+ ${e}`);return s?.[1]&&r(s[1]),n}function ts(e){return En(e,"enabled")===!1?!1:En(e,"disabled")!==!0}function Yl(e,t){let n={};for(let{raw:r,attr:o}of lt){if(o==="auto_approve"){let i=En(t,r);if(i!==void 0){n[r]=i;continue}}let s=De(t,r);s.length>0&&(n[r]=s)}qo(e,n)}var Xl=/^\s*([A-Za-z_][A-Za-z0-9_-]*)\s*[.=]/,Zl=/^\[[^\]]*\.([A-Za-z_][A-Za-z0-9_-]*)\]\s*$/gm;function ql(e){let t=new Set,n=e.search(/^\[/m),r=n===-1?e:e.slice(0,n);for(let o of r.split(`
17
+ `)){let s=Xl.exec(o);s?.[1]&&t.add(s[1])}for(let o of e.matchAll(Zl))o[1]&&t.add(o[1]);return[...t]}function ns(e,t){let n={transport:t};Yo(n,ql(e));let r=/^\s*command\s*=\s*(.+)$/m.exec(e),o=/^\s*url\s*=\s*(.+)$/m.exec(e),s=r?Ee(r[1]??""):void 0,i=o?Ee(o[1]??""):void 0,c=s!==void 0&&s.length>0?s:i;c&&(n.command_or_url=fe(c));let a=Vl(e,"args");a.length>0&&(n.args=a);let l=new Set;for(let _ of e.split(`
18
+ `)){let A=/^\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(_);A?.[1]&&l.add(A[1])}let u=/^\s*env\s*=\s*\{([^}]*)\}/m.exec(e);if(u?.[1])for(let _ of u[1].split(",")){let A=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(_);A?.[1]&&l.add(A[1])}let d=/(?:^|\n)\[[^\]]*env\]\s*\n([\s\S]*?)(?=\n\[|$)/.exec(`
19
+ ${e}`);if(d?.[1])for(let _ of d[1].split(`
20
+ `)){let A=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(_);A?.[1]&&l.add(A[1])}for(let _ of De(e,"env_vars"))l.add(_);let f=Jl(e,"env_http_headers");for(let[,_]of f)_.length>0&&l.add(_);let p=Sn(e,"bearer_token_env_var");p&&(l.add(p),n.bearer_token_env_var=p),l.size>0&&(n.env_var_names=[...l].sort()),f.length>0&&(n.env_http_header_names=[...new Set(f.map(([_])=>_))].sort()),(/^\s*(?:http_|env_http_)?headers\s*=/m.test(e)||/(?:^|\n)\[[^\]]*headers\]\s*(?:\n|$)/.test(e))&&(n.headers_present=!0);let g=Sn(e,"auth");g&&(n.auth=g);let S=Sn(e,"default_tools_approval_mode");return S&&(n.default_tools_approval_mode=S),Yl(n,e),n}var Ql=300,eu=256;function rs(e,t){if(!t)return e;let n=[...new Set([t,t.replace(/\\/g,"/")])].filter(o=>o.length>1),r=e;for(let o of n)r=r.split(o).join("~");return r}function pt(e){let t=[],n="",r=null;for(let o of e){if(r){o===r?r=null:n+=o;continue}if(o==='"'||o==="'"){r=o;continue}if(/\s/.test(o)){n.length>0&&(t.push(n),n="");continue}n+=o}return n.length>0&&t.push(n),t}function os(e,t){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function tu(e){return os(e,Ql)}function ss(e,t){let n=rs(e.trim(),t),r=pt(n);if(r.length===0)return"";let[o,...s]=r,i=fe(o),c=dt(s);return tu([i,...c].join(" "))}function is(e,t){if(typeof e!="string")return null;let n=rs(e.trim(),t),r=pt(n)[0];if(!r)return null;let o=fe(r);return o.length===0?null:os(o,eu)}function nu(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 ru(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 ou(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 c of i){if(!c||typeof c!="object"||e.truncated)continue;let a=c;for(let l of ru(a)){if(e.truncated)return;let u=l.command??l.bash??l.prompt??l.powershell??a.powershell??"",d=nu({type:l.type??a.type,command:l.command??a.command,bash:l.bash??a.bash,powershell:l.powershell??a.powershell,prompt:l.prompt??a.prompt}),f=typeof a.matcher=="string"?a.matcher:"",p=v(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:v(S),origin:r,enabled:!0,trigger:"EVENT",attributes:{event:s,...f?{matcher:f}:{},action_kind:d,action_hash:p,...d!=="prompt"&&u.trim()?{command:ss(u,e.home)}:{}}})}}}function Re(e,t,n){if(!e.claimFile(t))return;let r=e.readJson(t,{});!r?.hooks||typeof r.hooks!="object"||ou(e,t,r.hooks,n)}import{existsSync as Eu,readFileSync as Ru}from"node:fs";import{createHash as su}from"node:crypto";import{join as Fe}from"node:path";var ft=128,iu=/^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/,cu=new Set(["-p","--package"]),au=new Set(["-c","--call"]),lu=new Set(["--registry","--userconfig","--globalconfig","--prefix","--cache","--node-options","--workspace","-w","--loglevel"]),uu=new Set(["-y","--yes","-n","--no","-q","-s","--quiet","--silent","--offline","--prefer-offline","--prefer-online","--ignore-existing","--ignore-scripts","--legacy-peer-deps","--foreground-scripts"]),du=/^--no-/;function pu(e){return uu.has(e)||du.test(e)}function fu(e){let n=(e.replace(/\\/g,"/").split("/").pop()??"").replace(/\.(cmd|exe|bat|ps1)$/i,"").toLowerCase();return n==="npx"?"npx":n==="npm"?"npm":null}function yn(e){if(e.length===0||e.length>ft)return null;let t=e.lastIndexOf("@"),n=t>0?e.slice(0,t):e;return iu.test(n)?n:null}function mu(e,t){let n=fu(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 c=r[i]??"";if(c==="--"){s=r[i+1]??null;break}if(!c.startsWith("-")){s=c;break}let a=c.indexOf("="),l=a===-1?c:c.slice(0,a);if(au.has(l))return[];if(cu.has(l)){let u=a===-1?r[i+1]:c.slice(a+1);u!==void 0&&u.length>0&&o.push(u),a===-1&&(i+=1);continue}if(!(a!==-1||pu(l))){if(lu.has(l)){i+=1;continue}return[]}}return o.length>0?o.every(i=>yn(i)!==null)?o:[]:s===null||yn(s)===null?[]:[s]}function gu(e){let t=[...e].sort((n,r)=>n.localeCompare(r,"en")).join(`
21
+ `);return su("sha512").update(t).digest("hex").slice(0,16)}function _u(e){let t=process.platform==="win32"?Fe(I("LOCALAPPDATA")??e,"npm-cache"):Fe(e,".npm"),n=I("npm_config_cache")??I("NPM_CONFIG_CACHE");return n===void 0||n===t?[t]:[n,t]}function cs(e){return typeof e=="string"&&e.length>0&&e.length<=ft?e:null}function hu(e,t,n){let r=gu(e);for(let o of _u(n)){let s=Fe(o,"_npx",r),i=W(Fe(s,"node_modules",...t.split("/"),"package.json"),{}),c=cs(i.version);if(c!==null)return c;let a=W(Fe(s,"package-lock.json"),{}),l=cs(a.packages?.[`node_modules/${t}`]?.version);if(l!==null)return l}return null}function Su(e){return e.length<=ft?e:`${e.slice(0,ft-1)}\u2026`}function Cn(e,t,n){if(typeof e!="string"||e.length===0)return null;let r=mu(e,t??[]),o=r[0];if(o===void 0)return null;let s=yn(o);if(s===null)return null;let i=hu(r,s,n);return{package_name:s,package_spec:Su(o),...i===null?{}:{package_version:i,package_version_source:"npx_cache"}}}function as(e,t){if(typeof e!="string"||e.length===0)return null;let[n,...r]=pt(e.trim());return n===void 0?null:Cn(n,r,t)}function mt(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 Cn(typeof n.command=="string"?n.command:null,r,t)}function ls(e,t){let n=/^\s*command\s*=\s*(.+)$/m.exec(e);return n===null?null:Cn(Ee(n[1]??""),De(e,"args"),t)}function yu(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 us(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,c]of Object.entries(o)){if(e.truncated)return;let a=yu(c),l=Qo(c,a);Object.assign(l,mt(c,e.home)??{});let u=es(c);e.push({kind:"MCP_SERVER",name:i,path:s,content_hash:Rn(i,l,u),origin:n,enabled:u,attributes:l})}}function ds(e,t,n){if(!Eu(t)||!e.claimFile(t))return;let r;try{r=Ru(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 c=i[1]??i[2]??i[3];if(!c)continue;let a=r.slice(i.index+i[0].length),l=a.search(/^\[mcp_servers(?:\.(?:\w+|"[^"]+"|'[^']+'))\]\s*$/m),u=l===-1?a:a.slice(0,l),d="unknown";/^\s*url\s*=/m.test(u)?d="http":/^\s*command\s*=/m.test(u)&&(d="stdio");let f=ns(u,d);Object.assign(f,ls(u,e.home)??{});let p=ts(u);e.push({kind:"MCP_SERVER",name:c,path:o,content_hash:Rn(c,f,p),origin:n,enabled:p,attributes:f})}}import{existsSync as Cu,readdirSync as Iu}from"node:fs";import{join as F}from"node:path";var ps=50;function In(e,t,n,r){if(!Cu(t))return{componentCount:0,expandTruncated:!1};let o=e.components.length,{expanded:s}=e.withPluginExpandCap(ps,()=>{pe(e,{dir:F(t,"skills"),kind:"SKILL",origin:n,enabled:r,nested:"SKILL.md"}),pe(e,{dir:F(t,"commands"),kind:"COMMAND",origin:n,enabled:r,extensions:[".md"]}),pe(e,{dir:F(t,"agents"),kind:"SUBAGENT",origin:n,enabled:r,extensions:[".md"]})});Re(e,F(t,"hooks","hooks.json"),n),Re(e,F(t,"hooks.json"),n);let i=e.components.length-o,c=s>=ps;return{componentCount:i,expandTruncated:c}}function An(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 fs(e){let t=F(e.home,".claude/plugins/installed_plugins.json"),n=e.readJson(t,{});if(!n)return;let r=n.plugins??{},s=e.readJson(F(e.home,".claude/settings.json"),{})?.enabledPlugins??{},i=e.componentPath(t);for(let[c,a]of Object.entries(r)){if(e.truncated)return;let l=Array.isArray(a)?a:[a],u=l[0]??{},d=s[c]===!0,f=c.includes("@")?c.split("@").slice(1).join("@"):"",p=typeof u.version=="string"?u.version:"",g=typeof u.scope=="string"?u.scope:"user",S=`plugin:${c}`,_=0,A=!1;for(let P of l)if(typeof P.installPath=="string"&&P.installPath.length>0){let N=In(e,P.installPath,S,d);_+=N.componentCount,A=A||N.expandTruncated}An(e,{pluginKey:c,rowPath:i,enabled:d,scope:g,version:p||void 0,marketplace:f||void 0,componentCount:_,expandTruncated:A,contentHash:v(`${c}|${p}|${g}|${d}|${_}`)})}}function Au(e){let t=e,n="";try{let r=Iu(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>o.name);if(r.length===1&&r[0])t=F(e,r[0]),n=r[0];else if(r.length>1){let o=[...r].sort(),s=o[o.length-1];s&&(t=F(e,s),n=s)}}catch{}return{installPath:t,version:n}}var ku=/^\d+$/;function xu(e){let t=e.filter(n=>!ku.test(n.pluginId));return t.length>0?t:e}function ms(e){let t=[{base:F(e.home,".cursor/plugins/local"),scope:"local"},{base:F(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,a=F(n,o.name),l=`plugin:${c}`,{componentCount:u,expandTruncated:d}=In(e,a,l,!0);An(e,{pluginKey:c,rowPath:e.componentPath(a),enabled:!0,scope:"local",componentCount:u,expandTruncated:d,contentHash:v(`${c}|local|${u}`)});continue}let s=o.name,i=[];for(let c of e.readEntries(F(n,s))){if(!c.isDirectory())continue;let a=F(n,s,c.name),{installPath:l,version:u}=Au(a);i.push({pluginId:c.name,installPath:l,version:u})}for(let c of xu(i)){if(e.truncated)break;let a=`${c.pluginId}@${s}`,l=`plugin:${a}`,{componentCount:u,expandTruncated:d}=In(e,c.installPath,l,!0);An(e,{pluginKey:a,rowPath:e.componentPath(c.installPath),enabled:!0,scope:"cache",version:c.version||void 0,marketplace:s,componentCount:u,expandTruncated:d,contentHash:v(`${a}|${c.version}|${u}`)})}}}function vu(e,t){let{layout:n,levelDir:r,origin:o,includeMachineWide:s}=t;for(let i of n.skillRoots)pe(e,{dir:ye(r,i),kind:"SKILL",origin:o,enabled:!0,nested:"SKILL.md"});for(let i of n.dirs)pe(e,{dir:ye(r,i.dir),kind:i.kind,origin:o,enabled:!0,extensions:i.extensions});for(let i of n.memory){let c=zo(i.map(a=>ye(r,a)));c&&at(e,{absolutePath:c,kind:"MEMORY",origin:o,enabled:!0,name:Ou(c)})}for(let i of Fr(n))Re(e,ye(r,i),o);for(let i of n.mcpJson??[])us(e,ye(r,i),o);for(let i of n.mcpToml??[])ds(e,ye(r,i),o);if(s){if(n.managed)for(let i of Je(n.managed,process.platform,e.home))i.toLowerCase().endsWith(".json")&&Re(e,i,o);n.plugins==="claude"?fs(e):n.plugins==="cursor"&&ms(e)}}function gs(e,t){try{let n=new ct(e,{pathMode:t.pathMode,maxEntries:t.maxEntries});for(let r of t.layouts)vu(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 kn(e,t,n={}){let r={},o=n.shouldWalk;if(o===void 0||o("user","")){let a=gs(t,{layouts:Object.values(he),levelDir:t,origin:"user",includeMachineWide:!0,pathMode:"home-relative",maxEntries:ee,scopeRef:""});a&&(r.user=a)}let s=n.inGitRepo===!0,i=null,c=n.launchCwd;if(c!==void 0){let a=Object.values(ne),l=pn({launchCwd:c,gitRoot:n.gitRoot,inGitRepo:s,remote:n.remote,home:t,hasProjectSpec:u=>Kr(a,u)});i=l.parentRel;for(let u of l.anchors){let d=cn(u.dir);if(o!==void 0&&!o(u.scope,d))continue;let f=gs(t,{layouts:a,levelDir:u.dir,origin:u.scope,includeMachineWide:!1,pathMode:"tilde",maxEntries:fn,scopeRef:d});f&&(r[u.scope]=f)}r.parent||(i=null)}return{scopes:r,parentRel:i,cwdInGitRepo:s}}function xn(e,t,n={}){let r=n.truncated===!0,o=Ue(e),s=new Set(e.map(u=>B(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 c=[],a=t;for(let u of e){let d=B(u.path,u.name);a[d]!==u.content_hash&&c.push(u)}let l=[];if(!r){for(let u of Object.keys(a))if(!s.has(u)){let d=To(u);d&&l.push(d)}}return{hash:o,count:e.length,truncated:r,full:!1,upserts:c,removed:l,unchanged:c.length===0&&l.length===0}}var hs=2*1024*1024,Tu=new Set(["HOOK","MCP_SERVER","PLUGIN"]);function On(e,t,n){let r=new Set(t.map(s=>B(s.path,s.name))),o=[];for(let s of e)s.text!==void 0&&(n.has(s.content_hash)||r.has(B(s.path,s.name))||o.push(s));return o}function vn(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 _s(e){return Buffer.byteLength(JSON.stringify(e),"utf8")}function Ss(e){if(e.text===void 0)return e;let{text:t,...n}=e;return n}function Tn(e,t=hs){let n=[],r=[];for(let u of e)Tu.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,c=0,a=0,l=[];for(let u of o){let d=s.length>0?1:0,f=_s(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=Ss(u),g=_s(p)+d;if(i+g<=t){s.push(p),i+=g,c+=1;continue}}a+=1}return{components:s,textDeferredCount:c,droppedCount:a,textHashesSent:l}}function Pn(e,t){return t.size===0?e:e.map(n=>n.text===void 0||!t.has(n.content_hash)?n:Ss(n))}var Pu=["user","cwd","repo","parent"];function wn(e){let{collected:t,cacheFor:n,nowMs:r,maxBytes:o}=e,s=[];for(let x of Pu){let O=t.scopes[x];if(!O)continue;let U=n(x,O.scopeRef),w=U.components,H=xn(O.components,w,{forceFull:w===void 0,truncated:O.truncated}),X=new Set(U.textHashes),Z=On(O.components,H.upserts,X),b=Pn([...H.upserts,...Z],X);s.push({scope:x,walk:O,delta:H,outgoing:b,outgoingKeys:new Set(b.map(E=>B(E.path,E.name))),deliveredTextHashes:X,cachedComponents:w})}let i=s.flatMap(x=>x.outgoing),c=Tn(i,o),a=new Set(c.components.map(x=>B(x.path,x.name))),l=[],u=[],d=[],f=[],p=[],g=[],S=[];for(let x of s){let{scope:O,walk:U,delta:w}=x;g.push(...U.components),l.push(O);let H=c.components.filter(E=>x.outgoingKeys.has(B(E.path,E.name))),X=[...x.outgoingKeys].some(E=>!a.has(E)),Z=w.truncated||X;Z?d.push(O):w.full&&u.push(O),f.push(...H),!w.full&&!Z&&p.push(...w.removed);let b=w.full?{}:{...x.cachedComponents??{}};if(!Z)for(let E of w.removed)delete b[B(E.path,E.name)];for(let E of H)b[B(E.path,E.name)]=E.content_hash;S.push({scope:O,scopeRef:U.scopeRef,components:b,textHashes:vn(x.deliveredTextHashes,H.filter(E=>E.text!==void 0).map(E=>E.content_hash),U.components),collectedAtMs:r,included:H.length>0||w.removed.length>0&&!Z||w.full})}let _={user_spec_hash:Ue(g),user_spec_count:g.length,user_spec_truncated:d.length>0};l.length>0&&(_.user_spec_scopes=l,_.user_spec_full_scopes=u,_.user_spec_truncated_scopes=d,_.user_spec_cwd_in_git_repo=t.cwdInGitRepo),u.length>0&&u.length===l.length&&(_.user_spec_full=!0),f.length>0&&(_.user_spec=f),p.length>0&&(_.user_spec_removed=p),c.textDeferredCount>0&&(_.user_spec_text_deferred=c.textDeferredCount);let A=t.scopes.cwd;A&&(_.user_spec_cwd_scope_ref=A.scopeRef);let P=t.scopes.repo;P&&(_.user_spec_repo_scope_ref=P.scopeRef);let N=t.scopes.parent;return N&&(_.user_spec_parent_scope_ref=N.scopeRef,t.parentRel&&(_.user_spec_parent_rel=t.parentRel)),{fields:_,scopes:S}}var Ke={cwd:"cwd_spec",repo:"repo_spec",parent:"parent_spec"};function gt(e){return e==="cwd"||e==="repo"||e==="parent"}function He(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function bn(e){return!He(e)||!He(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 Es(e){return wu(e)}function Rs(e){return bu(e)}function ys(e){return Mu(e)}function wu(e){if(!He(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return t}function bu(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Mn(e,t){if(!He(e))return;let n=e[t];return bn(n)?n:void 0}function Mu(e){if(!He(e))return{};let t={};for(let[n,r]of Object.entries(e))bn(r)&&(t[n]=r);return t}function Nn(e,t=20){let n=[];for(let[r,o]of Object.entries(e))bn(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 Du=200,Cs=200,Fu=["allow","deny","ask"],Hu=/(?<=^|[\s(,=:])(?:~|[A-Za-z]:)?[\\/][^\s,)]+/g,Ln="<path>",Ku=new RegExp(`${Ln}(?:\\s+[A-Za-z.][^\\s,)]*[\\\\/][^\\s,)]*)+`,"g");function $u(e){let t=e.replace(Hu,Ln).replace(Ku,Ln);return t.length>Cs?`${t.slice(0,Cs)}...`:t}function ht(e){let t=W(e,{}),n=[];for(let r of Fu)for(let o of t.permissions?.[r]??[])typeof o=="string"&&o.length>0&&n.push({key:$u(o),mode:r});return{model:t.model??"",permissionKeys:n}}function Bu(e){let{serverManaged:t,fileBased:n}=jt(process.platform,e),r=ht(t);if(r.model||r.permissionKeys.length>0)return r;let o="",s=[];for(let i of n){let c=ht(i);c.model&&(o=c.model),s.push(...c.permissionKeys)}return{model:o,permissionKeys:s}}function ju(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 Gu=10,zu=840*60*1e3,Wu="self-config-cache.json",As=2;function Dn(){return I("EV_AI_HOOK_USER_SPEC")?.toLowerCase()==="off"}function Vu(){return I("EV_AI_HOOK_CWD_SPEC")?.toLowerCase()==="off"}function Ju(e,t=Date.now()){return e===void 0||!Number.isFinite(e)?!0:t-e>=zu}var Yu={claude:["claude"],cursor:["agent","cursor-agent"],codex:["codex"]};async function Xu(e,t=T){let n=Yu[e];if(!n||n.length===0)return null;let r=async o=>{let s=n[o];if(s===void 0)return null;let c=((await t(s,["--version"],2e3)).split(`
22
+ `)[0]??"").trim();return c||r(o+1)};return r(0)}function Zu(e=Is()){return Ce(e,".ev-ai","agent-hook",Wu)}function qu(e){let n=[...e].sort((r,o)=>r.name.localeCompare(o.name)).map(r=>`${r.name}:${r.size}`).join(`
23
+ `);return v(n)}function _t(e,t,n=!1){let r=qu(e),o=e.length;return t===r?n?{hash:r,count:o,truncated:n}:{hash:r,count:o}:n?{hash:r,count:o,entries:e,truncated:n}:{hash:r,count:o,entries:e}}function Un(e,t,n=[]){let r=0,o=!1,s=new Set;for(let i of[...t.map(c=>Ce(e,c)),...n]){let c=Lu(i);if(s.has(c))continue;s.add(c);let a=Pt(i);a.present&&(o=!0,r+=a.size)}return o?{present:!0,size:r}:{present:!1,size:0}}function Qu(e){return Nu(e)?M(Uu(e,"utf8"),{}):{}}function ed(e,t){try{Q(e,`${JSON.stringify(t)}
24
+ `)}catch(n){let r=n instanceof Error?n.message:String(n);h(`WARN: self-config cache write failed open: ${r}`)}}function td(e,t,n){if(t==="user")return e.user_spec_collected_at_ms;if(gt(t))return Mn(e[Ke[t]],n)?.collected_at_ms}function nd(e,t,n){if(t==="user")return{components:Es(e.user_spec_components),textHashes:Rs(e.user_spec_text_hashes)};if(!gt(t))return{components:void 0,textHashes:[]};let r=Mn(e[Ke[t]],n);return r?{components:r.components,textHashes:r.text_hashes}:{components:void 0,textHashes:[]}}function rd(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=As,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(!gt(s.scope))continue;let i=Ke[s.scope],c=ys(o[i]),a=c[s.scopeRef];c[s.scopeRef]={components:s.included?s.components:a?.components??{},text_hashes:s.textHashes,collected_at_ms:s.collectedAtMs},o[i]=Nn(c)}}return o}async function ks(e,t=process.cwd(),n=Is(),r={}){let o=e==="claude",s=r.gitRoot??t,i=await Xu(e),c="",a=[];if(o){let b=Bu(n),E=ht(Ce(n,".claude/settings.json")),L=ht(Ce(t,".claude/settings.local.json"));c=b.model||L.model||E.model,a=ju([...b.permissionKeys,...E.permissionKeys,...L.permissionKeys]).slice(0,Du)}let l={present:!1,size:0},u=b=>{let E=[],L=!1;for(let j of b){let q=Zn(Ce(n,j));if(E=E.concat(q.entries),L=L||q.truncated,E.length>=ee){E=E.slice(0,ee),L=!0;break}}return{entries:E,truncated:L}},d=Zu(n),f=Qu(d),p=f[e]??{},g=(p.send_count??0)+1,S=g>0&&g%Gu===0,_=b=>S?void 0:p[b],A=u(oe.skills),P=u(oe.subagents),N=u(oe.commands),x=u(oe.rules),O={skills:_t(A.entries,_("skills"),A.truncated),subagents:_t(P.entries,_("subagents"),P.truncated),commands:_t(N.entries,_("commands"),N.truncated),rules:_t(x.entries,_("rules"),x.truncated)},U={runner_platform:e,config_scope:"user",cli_version:i,claude_version:o?i:null,model:o&&c||null,permission_keys:a,user_scope:{skills:O.skills,subagents:O.subagents,commands:O.commands,rules:O.rules,memory:Un(n,oe.memory),settings:Un(n,oe.settings,$r(n)),mcp:Un(n,oe.mcp)},local_settings:o?Pt(Ce(t,".claude/settings.local.json")):l},w=null,H=()=>{},X=r.nowMs??Date.now();if(!Dn()){let b=p.user_spec_layout_version!==As,E=kn(e,n,{launchCwd:Vu()?void 0:r.launchCwd,gitRoot:s,inGitRepo:r.inGitRepo,remote:r.remote,shouldWalk:(L,j)=>b||Ju(td(p,L,j),X)});if(Object.keys(E.scopes).length>0){let L=wn({collected:E,cacheFor:(j,q)=>b?{components:void 0,textHashes:[]}:nd(p,j,q),nowMs:X});if(Object.assign(U,L.fields),w={hash:L.fields.user_spec_hash,home:L.scopes.find(j=>j.scope==="user")??null,project:L.scopes.filter(j=>j.scope!=="user")},E.scopes.user){let j=p.user_spec_collected_at_ms!==void 0,q=await rt({gitRoot:s,installationStorePath:r.installationStorePath,forceResend:j});q.operator&&(U.operator=q.operator),H=q.commit}}}let Z=rd(p,O,g,w);return{config:U,commit:()=>{f[e]=Z,ed(d,f),H()}}}function Ie(e,t,n){let r={installation_id:n.installationId};return n.platformAgentId&&(r.platform_agent_id=n.platformAgentId),n.sessionId&&(r.session_id=n.sessionId),n.turnId&&(r.turn_id=n.turnId),{schema_version:2,event:e,timestamp:Be(),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:Dt,host_arch:process.arch,node_version:process.version,correlation:r,payload:t}}import{existsSync as Os}from"node:fs";import{spawn as vs}from"node:child_process";import{basename as sd}from"node:path";import{fileURLToPath as id}from"node:url";import{gzipSync as od}from"node:zlib";function Hn(e){return I("EV_AI_HOOK_COMPRESS")==="off"?{body:e}:Buffer.byteLength(e,"utf8")<cr?{body:e}:{body:od(Buffer.from(e,"utf8")),contentEncoding:"gzip"}}function St(e){let t={"Content-Type":"application/json"};return e!==void 0&&(t["Content-Encoding"]=e),t}function xs(e){return typeof e=="string"?Buffer.byteLength(e,"utf8"):e.length}var Kn="__post",Et="__work";function cd(e,t){let n=e.payload,r=n&&typeof n=="object"&&!Array.isArray(n)?Object.keys(n):[],o=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:o,payload_keys:r})}function Ts(e){switch(e){case"session_start":return nr;case"session_end":return rr;case"tool_invoked":case"skill_invoked":return Ut;default:return Ut}}function ad(e,t,n){return`${JSON.stringify({url:e,timeoutMs:t})}
25
+ ${n}`}function Ps(e,t=[],n=process.execPath,r=import.meta.url,o=Os){if(sd(n)===Ge)return{command:n,args:[e,...t]};let s=id(r);return o(s)?{command:n,args:[s,e,...t]}:{command:n,args:[e,...t]}}function ld(e=process.execPath,t=import.meta.url,n=Os){return Ps(Kn,[],e,t,n)}function ud(e){let t=e.indexOf(`
26
+ `);if(t<0)return null;let n;try{n=JSON.parse(e.slice(0,t))}catch{return null}return{meta:n,body:e.slice(t+1)}}async function ws(e,t=fetch){let n=await e(),r=ud(n);if(!r)return;let{meta:o,body:s}=r,i=Hn(s),c=St(i.contentEncoding);try{await t(o.url,{method:"POST",headers:c,body:i.body,signal:AbortSignal.timeout(Number(o.timeoutMs))})}catch{}}async function dd(e,t,n,r=fetch){let o=Ts(e),s=Hn(t),i=St(s.contentEncoding),c=xs(s.body);h(`POST event=${e} url=${Bt(n)} size=${c} encoding=${s.contentEncoding??"identity"} platform=${process.platform}`);let a=Date.now();try{let l=await r(n,{method:"POST",headers:i,body:s.body,signal:AbortSignal.timeout(o)});if(!l.ok&&s.contentEncoding==="gzip"&&(l.status===400||l.status===415)){try{await l.text()}catch{}h(`POST gzip rejected http=${l.status} \u2014 retrying uncompressed`),l=await r(n,{method:"POST",headers:St(),body:t,signal:AbortSignal.timeout(o)})}let u=Date.now()-a;if(l.ok)return h(`POST outcome=ok elapsed_ms=${u} http=${l.status}`),!0;let d=(await l.text()).slice(0,200).replace(/[\n\r]/g,"");return h(`POST outcome=fail elapsed_ms=${u} http=${l.status} body=${d}`),!1}catch(l){let u=Date.now()-a,d=l instanceof Error?l.message:String(l);return h(`POST outcome=fail elapsed_ms=${u} http=000 body=${d}`),!1}}async function bs(e,t,n,r,o){try{let s=r(e,t,{detached:!0,stdio:["pipe","ignore","ignore"],windowsHide:!0});s.on("error",()=>{}),s.stdin.on("error",()=>{});let i=!1;return await new Promise(c=>{let a=setTimeout(()=>{if(!i){h(`WARN: ${o} stdin handoff timed out \u2014 continuing fail-open`);try{s.stdin.destroy()}catch{}}c()},or),l=()=>{i=!0,clearTimeout(a),c()};s.stdin.end(n,()=>l()),s.stdin.once("error",()=>l())}),s.unref(),s}catch(s){let i=s instanceof Error?s.message:String(s);return h(`WARN: ${o} spawn failed open: ${i}`),null}}async function pd(e,t,n,r=vs,o=ld){let s=Ts(e),i=ad(n,s,t),{command:c,args:a}=o();return bs(c,a,i,r,"detached post")}async function Ms(e,t,n=vs,r=Ps){let{command:o,args:s}=r(Et,t);return bs(o,s,e,n,"detached work")}async function Ae(e,t,n,r,o,s){if(!o)return h("WARN: collector URL missing \u2014 pass --url on the hook command or set collector_url in manifest"),!1;if(!We(o))return h(`WARN: collector URL blocked (https required): ${Bt(o)}`),!1;let i=r(e,t,n);s!==void 0&&(i.build_ms=Math.max(0,Date.now()-s));let c=`${JSON.stringify(i)}
27
+ `,a=I("EV_AI_HOOK_DEBUG");a==="full"?h(`DEBUG envelope=${JSON.stringify(i)}`):a==="1"&&h(`DEBUG summary=${cd(i,Buffer.byteLength(c,"utf8"))}`);let l=process.argv.includes(Et),u=I("EV_AI_HOOK_SYNC")==="1";return nt(n.runnerEvent,n.runnerPlatform)||l||u?dd(e,c,o):(await pd(e,c,o),!1)}import{createReadStream as fd}from"node:fs";import{stat as md}from"node:fs/promises";import{basename as gd,resolve as _d}from"node:path";import{createInterface as hd}from"node:readline";var Sd=1024*1024;function Ed(e){let t=e.replace(/\\/g,"/");return t.includes("/.claude/projects/")&&gd(t).endsWith(".jsonl")}async function Ns(e){if(!e||!Ed(e))return null;try{let t=_d(e),n=await md(t);if(!n.isFile())return null;let r=Math.max(0,n.size-Sd),o=[],s=hd({input:fd(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 c=o[i];if(c)try{let a=JSON.parse(c);if(a.type!=="assistant")continue;let l=a.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 yt(e){return{sessionId:e.sessionId,turnId:e.turnId,installationId:e.manifest.installationId,runnerPlatform:e.runnerPlatform,platformAgentId:e.platformAgentId,runnerEvent:e.runnerEvent}}function $n(e){return{gitRoot:e.manifest.gitRoot,inGitRepo:e.manifest.inGitRepo}}async function Ds(e){let t=Date.now();await Td(e);let{gitRoot:n}=e.manifest;await Ct(e,n);let r=$n(e);return{buildStartedAtMs:t,gitRoot:n,hookInput:st(e.hookInput,e.manifest.manifest,r),envelopeFields:yt(e),launchCwd:un(e.hookInput,r),home:yd()}}function Us(e){try{return $(Rd(e))}catch{return null}}function Fs(e){return e.startsWith("/")||/^[A-Za-z]:\//.test(e)}function Ls(e,t){let n=e.replaceAll("\\","/");if(!Fs(n))return null;let r=$(e),o=$(t),s=Us(e)??r,i=Us(t)??o;return s.startsWith(`${i}/`)?s.slice(i.length+1):r.startsWith(`${o}/`)?r.slice(o.length+1):null}function Cd(e,t,n){if(!e)return{repositorySourcePath:null,userSourcePath:null};let r=e.replaceAll("\\","/"),s=Ls(e,t)??(Fs(r)?null:r),i=Ls(e,n);return{repositorySourcePath:s,userSourcePath:i}}function Rt(e,t,n,r,o,s){let{repositorySourcePath:i,userSourcePath:c}=Cd(e,t,n),a=i??c,l=a===null?null:o(a),u=l!==null&&a!==null?Id({installableKind:r,sourcePath:a,nativeKey:l,inRepository:i!==null,platformAgentId:s.platformAgentId,installationId:s.manifest.installationId}):void 0;return{sourcePath:a,nativeKey:l,componentReference:u}}function Id(e){try{let t=e.inRepository?Ad(e.platformAgentId,e.sourcePath):(0,C.installationRootExternalKey)(e.installationId,(0,C.userConfigRootFromPath)(e.sourcePath));return t?(0,C.buildComponentReference)({installationRootExternalKey:t,installableKind:e.installableKind,sourcePath:e.sourcePath,nativeKey:e.nativeKey}):void 0}catch{return}}function Hs(e,t,n){return Ae("tool_invoked",{...n,success:null,duration_ms:null,hook_input:t.hookInput},t.envelopeFields,Ie,e.manifest.collectorUrl,t.buildStartedAtMs)}var Ks=new Set([...Object.values(de),".github"]);function Ad(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=>Ks.has(i));return s<0?null:`${r}:${o.slice(0,s+1).join("/")}`}function kd(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 a=s.find(g=>g.name.toLowerCase()===t.toLowerCase()),l=a?.sourcePath??(a?.source==="claude_json_user"?".claude.json":a?.source==="cursor_mcp_user"?".cursor/mcp.json":a?.source==="codex_toml_user"||a===void 0&&o==="codex"?".codex/config.toml":void 0);if((a?.scope==="user"||a?.source==="claude_json_user"||a?.source==="cursor_mcp_user"||a?.source==="codex_toml_user"||a===void 0&&o==="codex")&&l)try{let g=(0,C.userConfigRootFromPath)(l);return(0,C.buildComponentReference)({installationRootExternalKey:(0,C.installationRootExternalKey)(r,g),installableKind:C.ComponentKind.INTERFACE,sourcePath:l,nativeKey:a?.name??t})}catch{return}if(n===null)return;let d=n.indexOf(":");if(d<=0||d===n.length-1)return;let f=n.slice(d+1),p=f.replaceAll("\\","/").split("/").at(-1);if(!(p===void 0||!Ks.has(p)))try{return(0,C.buildComponentReference)({installationRootExternalKey:n,installableKind:C.ComponentKind.INTERFACE,sourcePath:f,nativeKey:t})}catch{return}}function xd(...e){for(let t of e)if(t)return t;return null}function z(e,t,n){if(e.status==="fulfilled")return e.value;let r=e.reason instanceof Error?e.reason.message:String(e.reason);return h(`WARN: ${n} failed open: ${r}`),t}function Od(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 vd(e,t){return{runner_platform:e,config_scope:"user",...t?{operator:t}:{}}}var me=new Set,$e=null;async function Td(e){if(Dn())return;let t=e.manifest.installationId,n=e.manifest.installationStorePath;if(me.has(t))return;if(!an(n)){me.add(t);return}let r=ke({sessionId:e.sessionId,hostname:xe()});if(bo(r)){if($e){await $e;return}$e=(async()=>{if(me.has(t)||!an(n)){me.add(t);return}if(!Ar(n)){me.add(t);return}let o=!1;try{let s=Date.now(),{gitRoot:i}=e.manifest,c=String(e.runnerPlatform),[a,l,u,d,f]=await Promise.allSettled([we(i),Mt(),on(r),Nt(),rt({gitRoot:i,installationStorePath:n,forceResend:!1})]),p=z(a,null,"gitSnapshot"),g=z(l,"","detectVirt"),S=z(u,null,"probeCloud"),_=z(d,{},"hostEnv"),A=z(f,{commit:()=>{}},"resolveOperatorForSend");await Ct(e,i,p);let P={identity:{host:xe(),context:r,virt:g||null,cloud:S,git:p},host_env:_,env_vars:sn(),self_config:vd(c,A.operator),run_meta:{trigger:"cloud_identity_bootstrap"}};o=!!await Ae("session_start",P,yt(e),Ie,e.manifest.collectorUrl,s),o&&(A.commit(),me.add(t))}finally{kr(n)}})().finally(()=>{$e=null}),await $e}}async function Ct(e,t,n){try{let r=n===void 0?await we(t):n;e.platformAgentId=await qr(e.manifest.manifest,e.platformAgentId,String(e.runnerPlatform),t,r,e.manifest.installationStorePath,e.manifest.repoKey)}catch(r){let o=r instanceof Error?r.message:String(r);h(`WARN: derivePlatformAgentId failed open: ${o}`)}}async function Pd(e){let t=Date.now(),{gitRoot:n}=e.manifest,r=ke({sessionId:e.sessionId,hostname:xe()}),o=String(e.runnerPlatform),s=$n(e),i=un(e.hookInput,s),c=we(n),[a,l,u,d,f,p]=await Promise.allSettled([c,Mt(),on(r),Nt(),Qt(e.manifest.manifest,n,o),c.catch(()=>null).then(H=>ks(o,n,void 0,{installationStorePath:e.manifest.installationStorePath,gitRoot:n,launchCwd:i,inGitRepo:e.manifest.inGitRepo,remote:H?.remote??null}))]),g=z(a,null,"gitSnapshot"),S=z(l,"","detectVirt"),_=z(u,null,"probeCloud"),A=z(d,{},"hostEnv"),P=z(f,[],"mcpDeclared"),N=z(p,Od(o),"selfConfig"),x=N.config;await Ct(e,n,g);let O=m(e.hookInput,"model");O&&(x.model=O);let U={identity:{host:xe(),context:r,virt:S||null,cloud:_,git:g},host_env:A,env_vars:sn(),mcp:{declared:P},self_config:x,run_meta:{trigger:e.hookSource||"startup"},hook_input:st(e.hookInput,e.manifest.manifest,{...s,launchCwd:i})};await Ae("session_start",U,yt(e),Ie,e.manifest.collectorUrl,t)&&(N.commit(),me.add(e.manifest.installationId))}async function wd(e){let t=Date.now(),{gitRoot:n}=e.manifest;await Ct(e,n);let r=xd(m(e.hookInput,"status"),m(e.hookInput,"stop_reason"),m(e.hookInput,"reason"),Ne(m(e.hookInput,"error"))),o=e.runnerPlatform==="claude"?await Ns(m(e.hookInput,"transcript_path")):null,s=st(e.hookInput,e.manifest.manifest,$n(e));o&&(s.model=o),await Ae("session_end",{status:r,...o?{model:o}:{},hook_input:s},yt(e),Ie,e.manifest.collectorUrl,t)}function $s(e,t,n,r){let o=r??Vr({skillId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home}),s=Rt(o,t.gitRoot,t.home,C.ComponentKind.SKILL,C.nativeKeyForSkillPath,e);if(s.sourcePath!==null&&zt(s.sourcePath)?.toLowerCase()===n.toLowerCase())return s.componentReference===void 0?{}:{componentReference:s.componentReference};let i=r??ro({commandId:n,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),c=Rt(i,t.gitRoot,t.home,C.ComponentKind.COMMAND,C.nativeKeyForCommandPath,e);return c.nativeKey?.toLowerCase()!==n.toLowerCase()?{}:{commandName:c.nativeKey,...c.componentReference===void 0?{}:{componentReference:c.componentReference}}}function bd(e,t,n){let r=Xe(e.hookInput.tool_input);return Promise.all(n.map(o=>{let s=$s(e,t,o,r);return Hs(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 Md(e,t,n){return Promise.all(n.map(r=>{let o=Qr({relativePath:r,launchCwd:t.launchCwd,gitRoot:t.gitRoot,home:t.home,runnerPlatform:e.runnerPlatform}),s=Rt(o,t.gitRoot,t.home,C.ComponentKind.RULE,C.nativeKeyForRulePath,e),i=s.nativeKey??to(r);return Hs(e,t,{tool_name:"Rule",rule_name:i,...s.componentReference===void 0?{}:{component_reference:s.componentReference}})}))}var Nd=[{kind:C.ComponentKind.SKILL,nativeKeyFn:C.nativeKeyForSkillPath},{kind:C.ComponentKind.RULE,nativeKeyFn:C.nativeKeyForRulePath},{kind:C.ComponentKind.COMMAND,nativeKeyFn:C.nativeKeyForCommandPath}];function Ud(e,t,n){if(n.skillName===null&&n.ruleName===null&&n.commandName===null)return{};let r=Vt(e.hookInput);if(r===null)return n.skillName===null?{}:$s(e,t,n.skillName,null);for(let o of Nd){let s=Rt(r,t.gitRoot,t.home,o.kind,o.nativeKeyFn,e);if(s.nativeKey!==null)return{...s.componentReference===void 0?{}:{componentReference:s.componentReference},...o.kind===C.ComponentKind.RULE?{ruleName:s.nativeKey}:{},...o.kind===C.ComponentKind.COMMAND?{commandName:s.nativeKey}:{}}}return{}}var Ld=/mcp/i;function Dd(e,t,n,r){let o=Ld.test(e.runnerEvent);if(!r.hasMcpIdentity&&!o)return{};let s=o?as(t,n):mt(r.declaredConfig,n);return s===null?{}:Object.fromEntries(Object.entries(s).filter(i=>typeof i[1]=="string").map(([i,c])=>[`mcp_${i}`,c]))}async function Fd(e){let t=await Ds(e),n=_o(e.hookInput,e.runnerEvent),{toolName:r,skillName:o}=n,s=Wt(e.hookInput),i=is(s,t.home),c=So(e.hookInput),a=po(e.runnerEvent),l=a===!1?Eo(e.hookInput,e.runnerEvent):null,u=await Qt(e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home).catch(()=>[]),d=Ne(m(e.hookInput,"mcp_server_name")),{mcpServer:f,mcpTool:p}=Ro(r,u.map(U=>U.name),d??""),g=kd(r,f,e.platformAgentId,e.manifest.installationId,String(e.runnerPlatform),u,d),S=g===void 0?Ud(e,t,n):{},_=f===null?null:lo(f,e.manifest.manifest,e.manifest.gitRoot,String(e.runnerPlatform),t.home),A=Dd(e,s,t.home,{hasMcpIdentity:!!f||!!p,declaredConfig:_}),P=g??S.componentReference,N=S.ruleName??n.ruleName,x=S.commandName??n.commandName,O=ho(e.hookInput);await Ae("tool_invoked",{tool_name:r,skill_name:o,...N?{rule_name:N}:{},...x?{command_name:x}:{},success:a,duration_ms:c,...i?{executable:i}:{},...l?{failure_reason:l}:{},...f?{mcp_server:f}:{},...p?{mcp_tool:p}:{},...A,...P?{component_reference:P}:{},...O?{subagent_type:O}:{},hook_input:t.hookInput},t.envelopeFields,Ie,e.manifest.collectorUrl,t.buildStartedAtMs)}async function Bs(e){switch(e.internalEvent){case"session_start":await Pd(e);return;case"session_end":await wd(e);return;case"skill_invoked":{let t=Jr(e.hookInput),n=no(e.hookInput);if(t.length===0&&n.length===0)return;let r=await Ds(e);await Promise.all([t.length===0?void 0:bd(e,r,t),n.length===0?void 0:Md(e,r,n)]);return}case"tool_invoked":await Fd(e);return;default:return}}function js(e){return e!=="session_start"&&e!=="session_end"&&e!=="tool_invoked"&&e!=="skill_invoked"&&e!==""}import{existsSync as Bn,readFileSync as Hd}from"node:fs";import{dirname as Kd,join as Gs,relative as $d}from"node:path";var zs=[tr,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"];async function Bd(e=process.cwd(),t){let n=I("EV_AI_HOOK_MANIFEST");if(n&&Bn(n))return n;let r=t??await Tt(e);for(let o of zs){let s=Gs(r,o);if(Bn(s))return s}for(let o of zs){let s=Gs(e,o);if(Bn(s))return s}}async function jd(e,t){let n=t??await Tt(Kd(e)),r=$d(n,e),o=await G("git",["ls-files","--error-unmatch",r],2e3,{cwd:n});return o.ok?!0:o.code===1?!1:(h(`WARN: git ls-files failed for manifest ${e} (code=${String(o.code)}); treating as tracked`),!0)}function Gd(e){let t=Hd(e,"utf8");return M(t,{})}function zd(){return{schema_version:2,mcp_servers:[]}}async function Ws(e=process.cwd(),t={}){let{root:n,inGitRepo:r}=await vt(e),o=await Bd(e,n),s=o?Gd(o):zd();delete s.installation_id;let i=o?await jd(o,n):!1;s.capture_hook_input==="full"&&o&&i&&(h(`WARN: ignoring capture_hook_input=full in git-tracked manifest ${o}; use EV_AI_HOOK_CAPTURE_FULL_INPUT=1 or an untracked operator manifest`),delete s.capture_hook_input);let{installationId:c,storePath:a,repoKey:l}=await Tr(n,{sessionId:t.sessionId});return{manifestPath:o??a,manifest:s,installationId:c,installationStorePath:a,repoKey:l,collectorUrl:Nr(s),platformAgentId:s.platform_agent_id??"",gitRoot:n,inGitRepo:r}}async function Vs(e,t,n,r){let o=t??await Ot(Lt),s=M(o,{}),i=m(s,"session_id")||m(s,"conversation_id"),c=await Ws(process.cwd(),{sessionId:i});if(!c)return;r&&(c.collectorUrl=r);let a=fo(s,c.manifest.platform,n),l=mo(e,a.runnerEvent);if(!l){h(`WARN: unknown hook event '${a.runnerEvent}'; skipping telemetry`);return}let u={hookInput:s,sessionId:a.sessionId,turnId:a.turnId,runnerEvent:a.runnerEvent,runnerPlatform:a.runnerPlatform,hookSource:a.hookSource,internalEvent:l,manifest:c,platformAgentId:c.platformAgentId};if(js(l)){h(`WARN: unsupported internal event '${l}'`);return}await Bs(u)}function Wd(e,t){if(I("EV_AI_HOOK_SYNC")==="1")return!0;let n=tt(e),r=M(t,{}),o=n.event??(m(r,"hook_event_name")||m(r,"event")),s=Me(r,o,void 0,n.runner);return nt(o,s)}async function Js(e=process.argv.slice(2)){if(e[0]===Kn){try{await ws(xt)}catch{}return 0}if(e[0]===Et){try{let t=tt(e.slice(1)),n=await xt(),r=M(n,{}),o=t.event??(m(r,"hook_event_name")||m(r,"event"));if(wt()||nn(t.runner,r,o))return 0;await Vs(t.event,n,t.runner,tn(t))}catch(t){let n=t instanceof Error?t.message:String(t);h(`WARN: detached work failed open: ${n}`)}return 0}try{let t=await Ot(Lt),n=tt(e),r=tn(n),o=M(t,{}),s=n.event??(m(o,"hook_event_name")||m(o,"event"));if(wt()||nn(n.runner,o,s)||!Oo(o,s,n.runner))return 0;Wd(e,t)?await Vs(n.event,t,n.runner,r):await Ms(t,e)}catch(t){let n=t instanceof Error?t.message:String(t);h(`WARN: hook failed open: ${n}`)}finally{Xn()}return 0}Js().then(e=>{process.exit(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);process.stderr.write(`[ev-ai-agent-hook] ${t}
27
28
  `),process.exit(1)});
@@ -9,7 +9,8 @@ var PROJECT_HOOK_BINARY_RELATIVE = `.ev-ai/agent-hook/${HOOK_BINARY_NAME}`;
9
9
  var HOOK_INPUT_ALLOWLIST_MAX_BYTES = 4 * 1024;
10
10
  var HOOK_INPUT_FULL_MAX_BYTES = 32 * 1024;
11
11
  var HOOK_INPUT_MCP_MAX_BYTES = 4 * 1024;
12
- var PACKAGE_VERSION = "1.0.9";
12
+ var GZIP_MIN_BYTES = 32 * 1024;
13
+ var PACKAGE_VERSION = "1.1.0";
13
14
  var NPX_PACKAGE_SPEC = `@ev-ai/agent-hook@${PACKAGE_VERSION}`;
14
15
  var HOOK_STATUS_MESSAGE = "ev-ai runtime report";
15
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ev-ai/agent-hook",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "Cross-runner runtime telemetry hook for Claude Code, Cursor, and Codex",
5
5
  "type": "module",
6
6
  "bin": {