@ev-ai/agent-hook 1.1.7 → 1.2.1

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.
@@ -0,0 +1,5 @@
1
+ import{createHash as Ht}from"node:crypto";import{join as D}from"node:path";var kt=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/,wt=/^>=(\d+)(?:\.(\d+)(?:\.(\d+))?)?$/,Rt=/^v?(\d+)\.(\d+)\.(\d+)/;function Fe(e){let t=kt.exec(e);if(t)return{...pe(t),prerelease:t[4]?.split(".")}}function At(e,t){let n=Fe(e),r=Fe(t);if(!(!n||!r))return n.major!==r.major?n.major-r.major:n.minor!==r.minor?n.minor-r.minor:n.patch!==r.patch?n.patch-r.patch:vt(n.prerelease,r.prerelease)}function V(e,t){let n=At(e,t);return n!==void 0&&n>=0}function fe(e){let t=wt.exec(e.trim());return t?pe(t):void 0}function pe(e){return{major:Number(e[1]),minor:Number(e[2]??0),patch:Number(e[3]??0)}}function Ce(e,t){let n=fe(t),r=Rt.exec(e.trim()),o=r?pe(r):void 0;return!n||!o?!1:o.major!==n.major?o.major>n.major:o.minor!==n.minor?o.minor>n.minor:o.patch>=n.patch}function vt(e,t){if(e===void 0&&t===void 0)return 0;if(e===void 0)return 1;if(t===void 0)return-1;let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let o=e[r],c=t[r];if(o===void 0)return-1;if(c===void 0)return 1;let s=Ot(o,c);if(s!==0)return s}return 0}function Ot(e,t){let n=/^\d+$/.test(e),r=/^\d+$/.test(t);if(n&&r){let o=Number(e)-Number(t);return o<0?-1:o>0?1:0}return n?-1:r?1:e<t?-1:e>t?1:0}var Le="EV_AI_LAUNCHER_REFRESH_SCOPE",Ie="EV_AI_HOOK_UPDATE_TTL_MIN",yr=Buffer.from([1]);var br=1024*1024,xr=4*1024*1024,Sr=64*1024,kr=64*1024,wr=64*1024;var M=21600,me=604800,Ue=3e5,ge=4096,J=4*1024*1024;import{randomBytes as Et}from"node:crypto";import{basename as Pt,dirname as Mt,join as Te}from"node:path";import{open as De,mkdir as Nt,readFile as Ft,readdir as Ct,rename as Lt,stat as It,unlink as Ut,utimes as Tt}from"node:fs/promises";var K=new WeakMap;function he(e){if(e&&typeof e=="object"&&"code"in e)return e}function b(e){return he(e)?.code==="ENOENT"}function _e(e){return he(e)?.code==="EEXIST"}function Dt(e){let t=he(e)?.code;return t==="EPERM"||t==="EBUSY"||t==="EACCES"}async function R(e,t){try{return await e.readdir(t)}catch(n){if(b(n))return[];throw n}}async function ye(e,t){try{await e.unlink(t)}catch(n){if(!b(n))throw n}}async function z(e,t,n){let r=await e.open(t,"wx");try{await e.write(r,n),await e.fsync(r)}finally{await e.close(r)}}function be(){return Et(8).toString("hex")}function Be(e){return e.startsWith(".")}async function L(e,t,n){let r=Mt(t),o=be(),c=`.${Pt(t)}.`,s=Te(r,`${c}${o}`),a=()=>e.unlink(s).catch(()=>{});await z(e,s,n);try{await e.rename(s,t)}catch(i){if(!Dt(i))throw await a(),i;let u=Te(r,`${c}bad.${o}`);try{await e.rename(t,u)}catch(l){if(!b(l))throw await a(),l}await e.rename(s,t)}await e.fsyncDir(r)}function A(){return{async open(e,t){let n=await De(e,t),r={path:e};return K.set(r,n),r},async write(e,t){let n=He(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await He(e).sync()},async close(e){let t=K.get(e);K.delete(e),t&&await t.close()},rename:Lt,async readdir(e){return Ct(e)},readFile:Ft,async stat(e){let t=await It(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await Nt(e,t)},unlink:Ut,utimes:Tt,async fsyncDir(e){if(process.platform==="win32")return;let t=await De(e,"r");try{await t.sync()}finally{await t.close()}}}}function He(e){let t=K.get(e);if(!t)throw new Error("closed");return t}function g(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{join as I}from"node:path";function xe(e){return I(e,".ev-ai","agent-hook","js")}function Se(e){return I(xe(e),"scopes")}function x(e,t){return I(Se(e),t)}function v(e){return I(e,"attempts")}function G(e){return I(e,"scope.json")}function ke(e){return String(e).padStart(10,"0")}var U="@ev-ai/agent-hook";function S(e,t){return D(xe(e),t?"dev-artifacts":"artifacts")}function je(e,t){return D(e,t)}function O(e,t){return D(e,t,"hook.mjs")}function X(e,t){return D(e,t,"meta.json")}function Bt(e,t){return D(e,t,"health.json")}function N(e){return Ht("sha256").update(e).digest("hex")}async function H(e,t,n){try{let r=await e.stat(t);return r.size<=0||r.size>J?"bad":N(await e.readFile(t))===n?"ok":"bad"}catch(r){if(b(r))return"missing";throw r}}async function F(e,t,n,r,o,c=process.version){let[s,a,i]=await Promise.all([H(e,O(t,n),n),W(e,X(t,n)),$t(e,Bt(t,n))]);if(s==="missing")return{usable:!1,reason:"artifact_missing"};if(s==="bad"||!a)return{usable:!1,reason:"hash_mismatch"};if(!V(a.version,r))return{usable:!1,reason:"below_floor"};if(!Ce(c,a.node_engine))return{usable:!1,reason:"incompatible_node"};if(a.min_launcher_protocol>1)return{usable:!1,reason:"incompatible_protocol"};if(i?.quarantined_until){let u=Date.parse(i.quarantined_until);if(Number.isFinite(u)&&u>o)return{usable:!1,reason:"quarantined"}}return{usable:!0,meta:a,healthFails:i?.consecutive_startup_failures??0}}async function W(e,t){try{let n=await e.readFile(t);return jt(JSON.parse(n.toString("utf8")))}catch{return}}function jt(e){if(!g(e))return;let t=e;if(t.package===U&&!(typeof t.version!="string"||t.version.length===0)&&typeof t.node_engine=="string"&&!(typeof t.min_launcher_protocol!="number"||!Number.isInteger(t.min_launcher_protocol))&&!(typeof t.integrity!="string"||!t.integrity.startsWith("sha512-"))&&typeof t.installed_at=="string")return{package:U,version:t.version,node_engine:t.node_engine,min_launcher_protocol:t.min_launcher_protocol,integrity:t.integrity,installed_at:t.installed_at}}async function $t(e,t){try{let n=await e.readFile(t),r=JSON.parse(n.toString("utf8"));if(!g(r))return;let o=r.consecutive_startup_failures;if(typeof o!="number"||!Number.isInteger(o)||o<0)return;let c={consecutive_startup_failures:o};return typeof r.quarantined_until=="string"&&(c.quarantined_until=r.quarantined_until),c}catch{return}}import{join as $e}from"node:path";var Vt=/^(\d{10})$/,Jt=/^(\d{10})\.done$/,Kt=/^[0-9a-f]{64}$/i;function E(e){let t=e[Ie];if(t===void 0||t==="")return M;let n=Number(t);return!Number.isInteger(n)||n<=0?M:Math.min(Math.max(M,n*60),me)}async function y(e,t,n=!1){let r=v(t),o=await R(e,r),c=new Map,s=new Map,a=Ve(o,Vt),i=Ve(o,Jt),u=async f=>{let p=await Ke(e,$e(r,q(f)));return p&&c.set(f,{record:Gt(p.value),mtimeMs:p.mtimeMs}),p!==void 0},l=async f=>{let p=Xt((await Ke(e,$e(r,Q(f))))?.value);return p&&s.set(f,p),p!==void 0};if(!n)return await Promise.all([...a.map(u),...i.map(l)]),{claims:c,dones:s};await Promise.all([Je(a,u),Je(i,l)]);let d=k(c);return d<k(s)&&i.includes(d)&&await l(d),{claims:c,dones:s}}function Ve(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}async function Je(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}function k(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}function P(e,t,n){let r=k(e.claims),o=k(e.dones),c=r===0?{kind:"uninitialized"}:{kind:"bundled",why:"bootstrap_failed"},s;if(o>0){let p=e.dones.get(o);p&&(c=p.selection,s=p.outcome)}let a=r>0?e.claims.get(r):void 0,i=a?zt(a):void 0,u=r>0?e.dones.get(r):void 0,l=we(u?.interval_s,n),d=i!==void 0?i+l*1e3:void 0,f=i!==void 0&&i-t>Ue;return{latest:r,startMs:i,intervalS:l,deadlineMs:d,selection:c,lastOutcome:s,futureDated:f,highestDone:o}}function zt(e){if(e.record!=="empty"&&e.record.started_at){let t=Date.parse(e.record.started_at);if(Number.isFinite(t))return t}return e.mtimeMs}function q(e){return ke(e)}function Q(e){return`${ke(e)}.done`}function we(e,t){return typeof e!="number"||!Number.isFinite(e)||e<=0?Math.max(M,t):Math.min(Math.max(Math.floor(e),M,t),me)}async function Ke(e,t){let n;try{n=await e.stat(t)}catch(o){if(b(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>ge)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>ge?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}function Gt(e){if(!g(e))return"empty";let t={};return typeof e.started_at=="string"&&(t.started_at=e.started_at),(e.owner==="bootstrap"||e.owner==="refresh")&&(t.owner=e.owner),e.resync===!0&&(t.resync=!0),t}function Xt(e){if(!g(e))return;let t=e;if(typeof t.finished_at!="string"||typeof t.outcome!="string"||typeof t.interval_s!="number"||!Number.isFinite(t.interval_s))return;let n=Wt(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n}}function Wt(e){if(!g(e))return;let t=e;if(t.kind==="bundled")return t.why==="server"||t.why==="bootstrap_failed"?{kind:"bundled",why:t.why}:void 0;if(t.kind==="cached"&&typeof t.digest=="string"&&Kt.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.integrity=="string"&&t.integrity.startsWith("sha512-"))return{kind:"cached",digest:t.digest.toLowerCase(),version:t.version,integrity:t.integrity}}import{join as Y}from"node:path";var ze=/^https:\/\/registry\.npmjs\.org\/@ev-ai\/agent-hook\/-\/agent-hook-(\d+\.\d+\.\d+)\.tgz$/;async function Z(e,t,n){let r=v(t);await e.mkdir(r,{recursive:!0});let o=P(await y(e,t,!0),n.nowMs,n.ttlFloorS);return o.futureDated?Ge(e,t,{...n,resync:!0,n:o.latest+1}):o.deadlineMs!==void 0&&n.nowMs<o.deadlineMs?{kind:"too_soon",deadlineMs:o.deadlineMs,latest:o.latest}:Ge(e,t,{...n,n:o.latest+1})}var ee={kind:"bundled",why:"bootstrap_failed"};function te(e,t,n,r,o,c){return(s,a,i)=>Yt(e,t,{n:n.n,startedAtMs:n.startedAtMs,nowMs:r,budgetMs:o,intervalS:we(i,c),outcome:s,selection:a})}async function Yt(e,t,n){if(n.nowMs-n.startedAtMs>n.budgetMs+3e4)return{recorded:!1,why:"expired"};let r=await y(e,t);if(k(r.claims)>n.n)return{recorded:!1,why:"superseded"};if(r.dones.has(n.n))return{recorded:!1,why:"already_done"};let o={finished_at:new Date(n.nowMs).toISOString(),interval_s:n.intervalS,outcome:n.outcome,selection:n.selection};return await L(e,Y(v(t),Q(n.n)),JSON.stringify(o)),await Zt(e,t,n.n),{recorded:!0}}async function Zt(e,t,n){let r=await y(e,t),o=n-8,c=k(r.dones),s=v(t),a=new Set([...r.claims.keys(),...r.dones.keys()]);await Promise.all([...a].map(async i=>{i>=o||i!==c&&(await ye(e,Y(s,q(i))),await ye(e,Y(s,Q(i))))}))}async function Ge(e,t,n){if(n.n<1||n.n>9999999999)return{kind:"lost"};let r=v(t),o=Y(r,q(n.n)),c=new Date(n.nowMs).toISOString(),s=be(),a={started_at:c,nonce:s,owner:n.owner};n.resync&&(a.resync=!0);try{await z(e,o,JSON.stringify(a)),await e.fsyncDir(r)}catch(i){if(_e(i))return{kind:"lost"};throw i}return n.collectorRedacted!==void 0&&await en(e,t,n.collectorRedacted,n.dev===!0),k((await y(e,t)).claims)>n.n?{kind:"lost"}:n.resync?{kind:"resynced",n:n.n,startedAt:c}:{kind:"claimed",n:n.n,startedAt:c,startedAtMs:n.nowMs,nonce:s,owner:n.owner}}async function en(e,t,n,r){let o=G(t);try{await z(e,o,Buffer.from(JSON.stringify({collector:n,dev:r}),"utf8")),await e.fsyncDir(t)}catch(c){if(_e(c))return;throw c}}import Sn from"node:http";import kn from"node:https";import{URL as wn}from"node:url";import{createHash as tn}from"node:crypto";import{access as nn,readFile as rn,stat as on}from"node:fs/promises";import{homedir as sn}from"node:os";import{dirname as an,join as Re,parse as cn,resolve as Xe}from"node:path";var un="https://hooks.ev-ai.ai",dn=".claude/ev-ai-runtime-report.json",ln="config.json",fn=1024*1024,Ze=new Set(["localhost","127.0.0.1","[::1]","::1"]),pn=["claude","cursor","codex"],mn=[dn,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],We=/^[A-Za-z0-9._~-]+$/;function gn(e){return e!==void 0&&pn.includes(e)}function ne(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function hn(e){let t,n,r,o,c;for(let s=0;s<e.length;s++){let a=e[s];if(a!==void 0){if(a==="--runner"){let i=ne(e,s);t=i.value,s=i.next;continue}if(a.startsWith("--runner=")){t=a.slice(9);continue}if(a==="--url"){let i=ne(e,s);i.value&&(r=i.value),s=i.next;continue}if(a.startsWith("--url=")){r=a.slice(6);continue}if(a==="--token"){let i=ne(e,s);i.value&&(o=i.value),s=i.next;continue}if(a.startsWith("--token=")){o=a.slice(8);continue}if(a==="--base-url"){let i=ne(e,s);i.value&&(c=i.value),s=i.next;continue}if(a.startsWith("--base-url=")){c=a.slice(11);continue}!a.startsWith("-")&&n===void 0&&(n=a)}}return{runner:gn(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:c}}function et(e,t=un){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function Ae(e=sn()){return Re(e,".ev-ai",ln)}function _n(e,t){return{...e,...t}}function qe(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 tt(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?Ze.has(t.hostname):!1}catch{return!1}}function nt(e){try{let n=new URL(e).pathname.split("/").filter(r=>r.length>0);if(n.length>=2&&n[n.length-1]==="hook"){let r=n[n.length-2];return r&&r.length>0?r:void 0}return}catch{return}}function ve(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!tt(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=nt(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!We.test(n))return`org token must match ${We.source} (got: ${n})`;if(qe(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(qe(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function yn(e){return new URL(e).toString()}function Qe(e){if(e.collector_url)return e.collector_url;let t=e.repo_ingest_token,n=typeof t=="string"?t.trim():void 0;return n?et(n):""}function re(e){try{return Ze.has(new URL(e).hostname)}catch{return!1}}function rt(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 bn(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=et(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=ve(n);return r?{problem:r}:{url:yn(n)}}var Oe={access:nn,stat:on,readFile:(e,t)=>rn(e,t)};async function xn(e,t,n=Oe){let r=Xe(e),{root:o}=cn(r);for(;;){let s=Re(r,".git");try{let i=await n.stat(s);if(i.isDirectory()||i.isFile())return r}catch{}if(r===o)break;let a=an(r);if(a===r)break;r=a}let c=t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR;if(c)try{if((await n.stat(c)).isDirectory())return c}catch{}return Xe(e)}async function B(e,t=Oe){try{let n=await t.stat(e);if(!n.isFile()||n.size>fn)return;let r=await t.readFile(e,"utf8"),o=JSON.parse(r);return o===null||typeof o!="object"||Array.isArray(o)?void 0:o}catch{return}}async function Ye(e,t){return(await Promise.all(mn.map(async r=>{let o=Re(e,r);try{return await t.access(o),o}catch{return}}))).find(r=>r!==void 0)}async function ot(e){let t=e.fs??Oe,n=bn(hn(e.argv));if(n.url)return{url:n.url,source:"argv"};let r=e.env.EV_AI_HOOK_MANIFEST;if(r)try{await t.access(r);let d=await B(r,t),f=d?Qe(d):"";return f?{url:f,source:"manifest_override"}:{source:"none"}}catch{}let o=await xn(e.cwd,e.env,t),c=Ae(e.home),[s,a]=await Promise.all([B(c,t),Ye(o,t).then(async d=>d??Ye(e.cwd,t))]),i=a?await B(a,t):void 0,u;s&&i?u=_n(i,s):s?u=s:i&&(u=i);let l=u?Qe(u):"";return l?{url:l,source:"manifest"}:{source:"none"}}function it(e){if(ve(e))return;let t;try{t=new URL(e)}catch{return}let n=nt(e);if(!n)return;let o=t.pathname.split("/").filter(a=>a.length>0).slice(0,-2),c=o.length>0?`/${o.join("/")}`:"",s=`${t.origin}${c}/${n}`;return tn("sha256").update(s).digest("hex").slice(0,32)}function st(e){if(ve(e))return;let t;try{t=new URL(e)}catch{return}let n=t.pathname.split("/").filter(o=>o.length>0);if(n.length<2||n[n.length-1]!=="hook")return;n[n.length-1]="version";let r=new URL(t.origin);if(r.pathname=`/${n.join("/")}`,r.search="",r.hash="",r.username="",r.password="",!(r.username||r.password)&&r.origin===t.origin&&tt(r.toString()))return r.toString()}function oe(){return{getBounded:Rn}}function ie(e,t){return e==="timeout"||e==="network"?"failed:timeout":e==="http_3xx"?"failed:http_3xx":t}function Rn(e,t){let n;try{n=new wn(e)}catch{return Promise.resolve({ok:!1,reason:"origin_rejected"})}if(n.protocol==="http:"){if(!re(e))return Promise.resolve({ok:!1,reason:"origin_rejected"})}else if(n.protocol!=="https:")return Promise.resolve({ok:!1,reason:"origin_rejected"});let r=n.protocol==="http:"?Sn:kn;return new Promise(o=>{let c=!1,s=[],a=0,i=d=>{c||(c=!0,t.signal?.removeEventListener("abort",u),o(d))},u=()=>{l.destroy(),i({ok:!1,reason:"timeout"})},l=r.request(n,{method:"GET",agent:!1,timeout:t.timeoutMs},d=>{let f=d.statusCode??0;if(f>=300&&f<400){d.resume(),i({ok:!1,reason:"http_3xx"});return}let p=d.headers["content-length"];if(typeof p=="string"){let m=Number(p);if(Number.isFinite(m)&&m>t.maxBytes){d.destroy(),i({ok:!1,reason:"too_large"});return}}d.on("data",m=>{if(a+=m.length,a>t.maxBytes){d.destroy(),i({ok:!1,reason:"too_large"});return}s.push(m)}),d.on("end",()=>{i({ok:!0,response:{status:f,headers:d.headers,body:Buffer.concat(s)}})}),d.on("error",()=>{i({ok:!1,reason:"network"})})});if(l.on("timeout",()=>{l.destroy(),i({ok:!1,reason:"timeout"})}),l.on("error",()=>{i({ok:!1,reason:"network"})}),t.signal){if(t.signal.aborted){u();return}t.signal.addEventListener("abort",u,{once:!0})}l.end()})}async function j(e,t){return e.EV_AI_AUTO_UPDATE==="0"?!0:(await B(Ae(t)))?.auto_update===!1}function Ee(e){return!!e.CURSOR_SANDBOX}function se(e,t,n,r){return{source:"bundled",hookPath:e.bundledHookPath,fallbackReason:t,scopeId:n?.scopeId,dev:n?.dev,...r}}import{join as On}from"node:path";var at=/^[0-9a-f]{64}$/;async function ct(e,t,n,r,o,c){if(!at.test(n)||N(r)!==n)return{ok:!1,reason:"repair_failed"};let s=je(t,n);await e.mkdir(s,{recursive:!0}),await Pn(e,s,c);let a=O(t,n),i=X(t,n),u=await W(e,i);if(await H(e,a,n)==="ok"&&u){if(u.version!==o.version)return{ok:!1,reason:"metadata_conflict"};if(En(u,o))return{ok:!0}}let d={...o,installed_at:new Date(c).toISOString()};return await L(e,a,r),await L(e,i,JSON.stringify(d)),await H(e,a,n)!=="ok"?{ok:!1,reason:"repair_failed"}:{ok:!0}}async function ut(e,t,n,r){let c=(await R(e,t)).filter(a=>at.test(a)).slice(0,512);return(await Promise.all(c.map(async a=>{let i=await W(e,X(t,a));if(!(i?.version!==n||i?.integrity!==r))return await H(e,O(t,a),a)==="ok"?a:void 0}))).find(a=>a!==void 0)}function En(e,t){return e.package===t.package&&e.version===t.version&&e.node_engine===t.node_engine&&e.min_launcher_protocol===t.min_launcher_protocol&&e.integrity===t.integrity}async function Pn(e,t,n){let r=await R(e,t);await Promise.all(r.map(async o=>{if(!Be(o))return;let c=On(t,o);try{let s=await e.stat(c);n-s.mtimeMs>36e5&&await e.unlink(c)}catch(s){if(!b(s))throw s}}))}import{createHash as Bn}from"node:crypto";import{gunzip as jn}from"node:zlib";import{promisify as $n}from"node:util";var Nn=/^\d+\.\d+\.\d+$/,Fn=/^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):\d+\/@ev-ai\/agent-hook\/-\/agent-hook-(\d+\.\d+\.\d+)\.tgz$/;function ae(e,t){return{launcher:e,protocol:String(1),current:t,platform:`${process.platform}-${process.arch}`,node:process.version}}function Pe(e){if(!e.startsWith("sha512-"))return!1;let t=e.slice(7);if(t.length===0||!/^[A-Za-z0-9+/]+=*$/.test(t))return!1;let n=Buffer.from(t,"base64");return n.length!==64?!1:n.toString("base64")===t}function Cn(e,t){if(!g(e))return{ok:!1,reason:"failed:metadata_mismatch"};let n=e.hook_js;if(n===void 0)return{ok:!0,directive:{kind:"none"}};if(!g(n))return{ok:!1,reason:"failed:metadata_mismatch"};if(n.use_bundled===!0)return{ok:!0,directive:{kind:"bundled",intervalS:dt(n.check_interval_s)}};let r=n.version,o=n.url,c=n.format,s=n.integrity;if(typeof r!="string"||!Nn.test(r))return{ok:!1,reason:"failed:metadata_mismatch"};if(c!=="npm-tgz")return{ok:!1,reason:"failed:origin_rejected"};if(typeof o!="string")return{ok:!1,reason:"failed:origin_rejected"};let a=Ln(o,t);return a?a!==r?{ok:!1,reason:"failed:metadata_mismatch"}:typeof s!="string"||!Pe(s)?{ok:!1,reason:"failed:metadata_mismatch"}:{ok:!0,directive:{kind:"target",version:r,url:o,integrity:s,intervalS:dt(n.check_interval_s)}}:{ok:!1,reason:"failed:origin_rejected"}}async function lt(e,t,n,r,o,c){let s=In(e,t),a=await r.getBounded(s,{maxBytes:4096,timeoutMs:n,signal:c});if(!a.ok)return{ok:!1,reason:ie(a.reason,"failed:metadata_mismatch")};let{status:i,body:u}=a.response;if(i!==200)return{ok:!1,reason:`failed:http_${i}`};let l;try{l=JSON.parse(u.toString("utf8"))}catch{return{ok:!1,reason:"failed:metadata_mismatch"}}return Cn(l,o)}function Ln(e,t){let n=ze.exec(e);if(n?.[1])return n[1];if(t){let r=Fn.exec(e);if(r?.[1])return r[1]}}function dt(e){if(typeof e=="number"&&Number.isInteger(e)&&e>0)return e}function In(e,t){let n=new URL(e);for(let[r,o]of Object.entries(t))n.searchParams.set(r,o);return n.toString()}var Vn=$n(jn),C=512,Jn="package/package.json",Kn="package/dist/hook.mjs";function zn(e,t){if(!Pe(t))return!1;let n=Buffer.from(t.slice(7),"base64"),r=Bn("sha512").update(e).digest();return r.length===n.length&&r.equals(n)}async function Gn(e){return Vn(e,{maxOutputLength:16777216})}async function ft(e,t,n=Gn){if(!zn(e,t))return{ok:!1,reason:"failed:integrity_mismatch"};let r;try{r=await n(e)}catch{return{ok:!1,reason:"failed:extract_failed"}}return Xn(r)}function Xn(e){try{return Wn(e)}catch{return{ok:!1,reason:"failed:extract_failed"}}}function pt(e,t){if(!g(e))return;let n=e;if(n.name!==U||n.version!==t||typeof n.version!="string")return;let r=n.engines,o=g(r)?r.node:void 0;if(typeof o!="string"||!fe(o))return;let c=n.evAi;if(!g(c))return;let s=c.minLauncherProtocol;if(!(typeof s!="number"||!Number.isInteger(s)||s>1))return{package:U,version:n.version,node_engine:o,min_launcher_protocol:s}}function Wn(e){let t=0,n=0,r,o,c,s,a=0;for(;t+C<=e.length;){let i=e.subarray(t,t+C);if(t+=C,qn(i)){if(a+=1,a>=2)break;continue}if(a=0,!Qn(i)||!Yn(i))return{ok:!1,reason:"failed:extract_failed"};if(n+=1,n>1e3)return{ok:!1,reason:"failed:extract_failed"};let u=String.fromCharCode(i[156]??0),l=mt(i.subarray(124,136));if(l===void 0||l>8388608)return{ok:!1,reason:"failed:extract_failed"};let d=Zn(i),f=s??l,p=c??d;c=void 0,s=void 0;let m=t+f;if(m>e.length)return{ok:!1,reason:"failed:extract_failed"};let h=e.subarray(t,m);if(t+=er(f),u!=="5"){if(u==="x"){let w=nr(h);if(!w)return{ok:!1,reason:"failed:extract_failed"};c=w.path,s=w.size;continue}if(u!=="0"&&u!=="\0")return{ok:!1,reason:"failed:extract_failed"};if(!tr(p))return{ok:!1,reason:"failed:extract_failed"};if(p===Jn){if(r||f>65536)return{ok:!1,reason:"failed:extract_failed"};r=Buffer.from(h);continue}if(p===Kn){if(o||f>J)return{ok:!1,reason:"failed:extract_failed"};o=Buffer.from(h)}}}return!r||!o?{ok:!1,reason:"failed:extract_failed"}:{ok:!0,packageJson:r,hookMjs:o}}function qn(e){for(let t of e)if(t!==0)return!1;return!0}function Qn(e){let t=mt(e.subarray(148,156));if(t===void 0)return!1;let n=0;for(let r=0;r<C;r++)n+=r>=148&&r<156?32:e[r]??0;return n===t}function Yn(e){return e.subarray(257,262).toString("latin1")==="ustar"}function Zn(e){let t=Me(e.subarray(0,100)),n=Me(e.subarray(345,500));return n?`${n}/${t}`:t}function Me(e){let t=e.indexOf(0);return e.subarray(0,t===-1?e.length:t).toString("utf8")}function mt(e){if((e[0]??0)&128)return;let t=Me(e).trim();if(t.length===0)return 0;if(/^[0-7]+$/.test(t))return Number.parseInt(t,8)}function er(e){return Math.ceil(e/C)*C}function tr(e){return!e||e.startsWith("/")||e.includes("\\")||e.includes("\0")||e.split("/").some(n=>n==="..")?!1:e==="package"||e.startsWith("package/")}function nr(e){let t=e.toString("utf8"),n=0,r={};for(;n<t.length;){let o=t.indexOf(" ",n);if(o<0)return;let c=Number(t.slice(n,o));if(!Number.isInteger(c)||c<=0)return;let s=t.slice(n,n+c);if(!s.endsWith(`
2
+ `))return;let a=s.slice(o-n+1,s.length-1),i=a.indexOf("=");if(i<0)return;let u=a.slice(0,i),l=a.slice(i+1);if(u==="path"&&(r.path=l),u==="size"){let d=Number(l);if(!Number.isInteger(d)||d<0)return;r.size=d}n+=c}return r}async function ce(e,t,n,r,o,c){let s=st(e);return s?lt(s,t,n,r,o,c):{ok:!1,reason:"failed:origin_rejected"}}async function ue(e,t,n,r,o,c,s,a){if(!V(r.version,o))return{ok:!1,reason:"skipped:below_floor"};let i=await ut(e,n,r.version,r.integrity);if(i){let u=await F(e,n,i,o,c);if(u.usable)return{ok:!0,digest:i,reused:!0};if(u.reason==="quarantined")return{ok:!1,reason:"skipped:quarantined"}}return or(e,t,n,r,c,s,a)}async function or(e,t,n,r,o,c,s){let a=await t.getBounded(r.url,{maxBytes:4194304,timeoutMs:c,signal:s});if(!a.ok)return{ok:!1,reason:ie(a.reason,"failed:extract_failed")};if(a.response.status!==200)return{ok:!1,reason:`failed:http_${a.response.status}`};let i=await ft(a.response.body,r.integrity);if(!i.ok)return i;let u;try{u=JSON.parse(i.packageJson.toString("utf8"))}catch{return{ok:!1,reason:"failed:metadata_mismatch"}}let l=pt(u,r.version);if(!l)return{ok:!1,reason:"failed:metadata_mismatch"};let d=N(i.hookMjs),f=await ct(e,n,d,i.hookMjs,{...l,integrity:r.integrity},o);return f.ok?{ok:!0,digest:d,reused:!1}:{ok:!1,reason:`failed:${f.reason}`}}async function ar(e){let t=e.fs??A(),n=e.http??oe(),r=x(e.home,e.scope.scopeId),o=S(e.home,e.scope.dev),c=E(e.env),s=AbortSignal.timeout(3e3),a=await Z(t,r,{owner:"bootstrap",nowMs:e.nowMs,ttlFloorS:c,collectorRedacted:e.scope.collectorUrlRedacted,dev:e.scope.dev});if(a.kind!=="claimed"){let m=a.kind==="lost"||a.kind==="too_soon";return se(e,m?"bootstrap_in_progress":"bootstrap_failed",e.scope,{didBootstrap:!1})}let i=te(t,r,a,e.nowMs,3e3,c),u=async m=>(await i(m,ee),se(e,"bootstrap_failed",e.scope,{didBootstrap:!0}));if(s.aborted)return u("failed:bootstrap");let l=await ce(e.scope.collectorUrl,ae(e.bundledVersion,e.bundledVersion),1e3,n,e.scope.dev,s);if(!l.ok)return u(l.reason);let d=l.directive;if(d.kind==="none")return u("failed:bootstrap");if(d.kind==="bundled")return await i("bundled",{kind:"bundled",why:"server"},d.intervalS),se(e,"server",e.scope,{didBootstrap:!0});let f=await ue(t,n,o,d,e.bundledVersion,e.nowMs,2e3,s);if(!f.ok)return u(f.reason);let{digest:p}=f;return await i("updated",{kind:"cached",digest:p,version:d.version,integrity:d.integrity},d.intervalS),{source:"bootstrap",hookPath:O(o,p),scopeId:e.scope.scopeId,digest:p,dev:e.scope.dev,didBootstrap:!0}}async function de(e,t){let n=await ot({argv:e,env:t.env,cwd:t.cwd,home:t.home});if(!n.url)return;let r=it(n.url);if(!(!r||n.source==="none"))return{scopeId:r,collectorUrl:n.url,collectorUrlRedacted:rt(n.url),source:n.source,dev:re(n.url)}}async function dr(e,t,n,r,o){try{await lr(e,t,n,r,o)}catch{}return 0}async function lr(e,t,n,r,o){if(Ee(t)||await j(t,r))return;let c=t[Le],s=await de(e,{env:t,cwd:n,home:r});if(!s||!c||s.scopeId!==c)return;let a=o?.fs??A(),i=o?.http??oe(),u=o?.nowMs??Date.now(),l=E(t),d=x(r,s.scopeId),f=await Z(a,d,{owner:"refresh",nowMs:u,ttlFloorS:l,collectorRedacted:s.collectorUrlRedacted,dev:s.dev});if(f.kind!=="claimed")return;let p=te(a,d,f,u,6e4,l),m=o?.packageVersion??"",h=P(await y(a,d,!0),u,l).selection,w=h.kind==="uninitialized"?ee:h,Ne=AbortSignal.timeout(6e4),le=await ce(s.collectorUrl,ae(m,h.kind==="cached"?h.version:m),5e3,i,s.dev,Ne);if(!le.ok){await p(le.reason,w);return}let _=le.directive;if(_.kind==="none"){await p("no_directive",w);return}if(_.kind==="bundled"){await p("bundled",{kind:"bundled",why:"server"},_.intervalS);return}let $=await ue(a,i,S(r,s.dev),_,m,u,3e4,Ne);if(!$.ok){await p($.reason,w,_.intervalS);return}let xt=h.kind==="cached"&&h.version===_.version&&h.integrity===_.integrity,{digest:St}=$;await p(xt?$.reused?"current":"repaired":"updated",{kind:"cached",digest:St,version:_.version,integrity:_.integrity},_.intervalS)}function fr(e){return`${e.slice(0,4)}\u2026`}async function pr(e,t,n){let r=e.includes("--json"),o=e.includes("--all"),c=e.slice(1).filter(p=>p!=="--json"&&p!=="--all"),s=await de(c,t),a=await j(t.env,t.home),i=A(),u=await bt(t,n,s,i,a),l=await mr(i,t.home,s?.scopeId),d=o?await gr(t,n,i,a,l):[];if(r)return t.stdout.write(`${JSON.stringify({...u,otherScopes:d},null,2)}
3
+ `),0;let f=[`launcher ${n.version} protocol ${n.evAi.launcherProtocol} revision ${n.evAi.launcherRevision} bundled hook ${n.version}`];if(f.push(...yt(u)),o)for(let p of d)f.push(""),f.push(...yt(p));else f.push(`other scopes ${l.length} (status --all)`);return f.push(`auto-update ${a?"off":"on"}`),t.stdout.write(`${f.join(`
4
+ `)}
5
+ `),0}async function bt(e,t,n,r,o){let c=!o;if(o)return{..._t(n,c),selection:"bundled",fallbackReason:"kill_switch"};if(!n)return{selection:"bundled",fallbackReason:"no_collector_url",autoUpdate:c};let s=e.now(),a=await y(r,x(e.home,n.scopeId),!0),i=P(a,s,E(e.env)),u="bundled",l,d;if(i.selection.kind==="cached"){let f=S(e.home,n.dev),p=await F(r,f,i.selection.digest,t.version,s);p.usable?(u=`cached ${i.selection.version}`,d=`usable (protocol ${p.meta.min_launcher_protocol})`):l=p.reason}else i.selection.kind==="bundled"?l=i.selection.why:l="uninitialized";return{..._t(n,c),selection:u,fallbackReason:l,usable:d,lastAttempt:i.startMs!==void 0?new Date(i.startMs).toISOString():void 0,nextNotBefore:i.deadlineMs!==void 0?new Date(i.deadlineMs).toISOString():void 0,intervalS:i.intervalS,lastResult:i.lastOutcome}}function _t(e,t){return{scopeId:e?.scopeId,collectorUrlRedacted:e?.collectorUrlRedacted,urlSource:e?.source,autoUpdate:t}}function yt(e){let t=[];e.scopeId?t.push(`this repo scope ${fr(e.scopeId)} ${e.collectorUrlRedacted} (source: ${e.urlSource})`):t.push("this repo (no collector url)");let n=e.fallbackReason?` (${e.fallbackReason})`:e.usable?` ${e.usable}`:"";return t.push(` selection ${e.selection}${n}`),e.lastAttempt&&t.push(` schedule last attempt ${e.lastAttempt} next not before ${e.nextNotBefore} (interval ${Math.round((e.intervalS??0)/3600)} h)`),e.lastResult&&t.push(` last result ${e.lastResult}`),t}async function mr(e,t,n){return(await R(e,Se(t))).filter(r=>r!==n)}function gr(e,t,n,r,o){return Promise.all(o.map(async c=>{let s=await hr(n,x(e.home,c)),a={scopeId:c,collectorUrl:"",collectorUrlRedacted:s.collector??"",source:"manifest",dev:s.dev};return bt(e,t,a,n,r)}))}async function hr(e,t){try{let n=JSON.parse((await e.readFile(G(t))).toString("utf8"));if(g(n))return{collector:typeof n.collector=="string"?n.collector:void 0,dev:n.dev===!0}}catch{}return{dev:!1}}export{ar as bootstrap,dr as runRefresh,pr as runStatus};
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import{spawn as Bn}from"node:child_process";import{homedir as jn}from"node:os";import{fileURLToPath as Rt}from"node:url";import{createHash as zt}from"node:crypto";import{join as K}from"node:path";var Ct=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/,kt=/^>=(\d+)(?:\.(\d+)(?:\.(\d+))?)?$/,Nt=/^v?(\d+)\.(\d+)\.(\d+)/;function be(e){let t=Ct.exec(e);if(t)return{...X(t),prerelease:t[4]?.split(".")}}function Ot(e,t){let n=be(e),r=be(t);if(!(!n||!r))return n.major!==r.major?n.major-r.major:n.minor!==r.minor?n.minor-r.minor:n.patch!==r.patch?n.patch-r.patch:Tt(n.prerelease,r.prerelease)}function Ee(e,t){let n=Ot(e,t);return n!==void 0&&n>=0}function Lt(e){let t=kt.exec(e.trim());return t?X(t):void 0}function X(e){return{major:Number(e[1]),minor:Number(e[2]??0),patch:Number(e[3]??0)}}function we(e,t){let n=Lt(t),r=Nt.exec(e.trim()),o=r?X(r):void 0;return!n||!o?!1:o.major!==n.major?o.major>n.major:o.minor!==n.minor?o.minor>n.minor:o.patch>=n.patch}function Tt(e,t){if(e===void 0&&t===void 0)return 0;if(e===void 0)return 1;if(t===void 0)return-1;let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let o=e[r],c=t[r];if(o===void 0)return-1;if(c===void 0)return 1;let i=Ft(o,c);if(i!==0)return i}return 0}function Ft(e,t){let n=/^\d+$/.test(e),r=/^\d+$/.test(t);if(n&&r){let o=Number(e)-Number(t);return o<0?-1:o>0?1:0}return n?-1:r?1:e<t?-1:e>t?1:0}var q="EV_AI_LAUNCHER_VERSION",Q="EV_AI_LAUNCHER_PROTOCOL",Z="EV_AI_HOOK_SOURCE",M="EV_AI_HOOK_FALLBACK_REASON",U="EV_AI_LAUNCHER_SCOPE",ee="EV_AI_LAUNCHER_READY_FD",xe="EV_AI_LAUNCHER_REFRESH_SCOPE",Re="EV_AI_HOOK_UPDATE_TTL_MIN",Ae=Buffer.from([1]),Pe='{"continue":true}',Ce=3e3,ke=1024*1024,Ne=4*1024*1024,te=64*1024,ne=64*1024,D=64*1024,Oe=2e3,H=250,Le=8e3,re=14e3,Te=1e3,Fe=1e3,L=21600,oe=604800,Ie=3e5,ie=4096,Me=4*1024*1024,Ue=2,De=864e5;import{randomBytes as It}from"node:crypto";import{basename as Mt,dirname as Ut,join as He}from"node:path";import{open as Be,mkdir as Dt,readFile as Ht,readdir as Bt,rename as jt,stat as Vt,unlink as Kt,utimes as Jt}from"node:fs/promises";var B=new WeakMap;function Ve(e){if(e&&typeof e=="object"&&"code"in e)return e}function T(e){return Ve(e)?.code==="ENOENT"}function $t(e){let t=Ve(e)?.code;return t==="EPERM"||t==="EBUSY"||t==="EACCES"}async function Ke(e,t){try{return await e.readdir(t)}catch(n){if(T(n))return[];throw n}}async function Wt(e,t,n){let r=await e.open(t,"wx");try{await e.write(r,n),await e.fsync(r)}finally{await e.close(r)}}function Yt(){return It(8).toString("hex")}async function se(e,t,n){let r=Ut(t),o=Yt(),c=`.${Mt(t)}.`,i=He(r,`${c}${o}`),s=()=>e.unlink(i).catch(()=>{});await Wt(e,i,n);try{await e.rename(i,t)}catch(a){if(!$t(a))throw await s(),a;let u=He(r,`${c}bad.${o}`);try{await e.rename(t,u)}catch(d){if(!T(d))throw await s(),d}await e.rename(i,t)}await e.fsyncDir(r)}function j(){return{async open(e,t){let n=await Be(e,t),r={path:e};return B.set(r,n),r},async write(e,t){let n=je(e),r=typeof t=="string"?Buffer.from(t,"utf8"):t;await n.write(r)},async fsync(e){await je(e).sync()},async close(e){let t=B.get(e);B.delete(e),t&&await t.close()},rename:jt,async readdir(e){return Bt(e)},readFile:Ht,async stat(e){let t=await Vt(e);return{mtimeMs:t.mtimeMs,size:t.size,isDirectory:()=>t.isDirectory()}},async mkdir(e,t){await Dt(e,t)},unlink:Kt,utimes:Jt,async fsyncDir(e){if(process.platform==="win32")return;let t=await Be(e,"r");try{await t.sync()}finally{await t.close()}}}}function je(e){let t=B.get(e);if(!t)throw new Error("closed");return t}function x(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}import{join as V}from"node:path";function ae(e){return V(e,".ev-ai","agent-hook","js")}function Gt(e){return V(ae(e),"scopes")}function Je(e,t){return V(Gt(e),t)}function $e(e){return V(e,"attempts")}function ce(e){return String(e).padStart(10,"0")}var We="@ev-ai/agent-hook";function J(e,t){return K(ae(e),t?"dev-artifacts":"artifacts")}function de(e,t){return K(e,t,"hook.mjs")}function Xt(e,t){return K(e,t,"meta.json")}function le(e,t){return K(e,t,"health.json")}function qt(e){return zt("sha256").update(e).digest("hex")}async function Qt(e,t,n){try{let r=await e.stat(t);return r.size<=0||r.size>Me?"bad":qt(await e.readFile(t))===n?"ok":"bad"}catch(r){if(T(r))return"missing";throw r}}async function Ye(e,t,n,r,o,c=process.version){let[i,s,a]=await Promise.all([Qt(e,de(t,n),n),Zt(e,Xt(t,n)),fe(e,le(t,n))]);if(i==="missing")return{usable:!1,reason:"artifact_missing"};if(i==="bad"||!s)return{usable:!1,reason:"hash_mismatch"};if(!Ee(s.version,r))return{usable:!1,reason:"below_floor"};if(!we(c,s.node_engine))return{usable:!1,reason:"incompatible_node"};if(s.min_launcher_protocol>1)return{usable:!1,reason:"incompatible_protocol"};if(a?.quarantined_until){let u=Date.parse(a.quarantined_until);if(Number.isFinite(u)&&u>o)return{usable:!1,reason:"quarantined"}}return{usable:!0,meta:s,healthFails:a?.consecutive_startup_failures??0}}async function Zt(e,t){try{let n=await e.readFile(t);return en(JSON.parse(n.toString("utf8")))}catch{return}}function en(e){if(!x(e))return;let t=e;if(t.package===We&&!(typeof t.version!="string"||t.version.length===0)&&typeof t.node_engine=="string"&&!(typeof t.min_launcher_protocol!="number"||!Number.isInteger(t.min_launcher_protocol))&&!(typeof t.integrity!="string"||!t.integrity.startsWith("sha512-"))&&typeof t.installed_at=="string")return{package:We,version:t.version,node_engine:t.node_engine,min_launcher_protocol:t.min_launcher_protocol,integrity:t.integrity,installed_at:t.installed_at}}async function fe(e,t){try{let n=await e.readFile(t),r=JSON.parse(n.toString("utf8"));if(!x(r))return;let o=r.consecutive_startup_failures;if(typeof o!="number"||!Number.isInteger(o)||o<0)return;let c={consecutive_startup_failures:o};return typeof r.quarantined_until=="string"&&(c.quarantined_until=r.quarantined_until),c}catch{return}}import{createHash as tn}from"node:crypto";import{access as nn,readFile as rn,stat as on}from"node:fs/promises";import{homedir as sn}from"node:os";import{dirname as an,join as me,parse as cn,resolve as Ge}from"node:path";var un="https://hooks.ev-ai.ai",dn=".claude/ev-ai-runtime-report.json",ln="config.json",fn=1024*1024,Ze=new Set(["localhost","127.0.0.1","[::1]","::1"]),mn=["claude","cursor","codex"],pn=[dn,".cursor/ev-ai-runtime-report.json",".codex/ev-ai-runtime-report.json"],ze=/^[A-Za-z0-9._~-]+$/;function hn(e){return e!==void 0&&mn.includes(e)}function $(e,t){let n=e[t+1];return n&&!n.startsWith("--")?{value:n,next:t+1}:{next:t}}function pe(e){let t,n,r,o,c;for(let i=0;i<e.length;i++){let s=e[i];if(s!==void 0){if(s==="--runner"){let a=$(e,i);t=a.value,i=a.next;continue}if(s.startsWith("--runner=")){t=s.slice(9);continue}if(s==="--url"){let a=$(e,i);a.value&&(r=a.value),i=a.next;continue}if(s.startsWith("--url=")){r=s.slice(6);continue}if(s==="--token"){let a=$(e,i);a.value&&(o=a.value),i=a.next;continue}if(s.startsWith("--token=")){o=s.slice(8);continue}if(s==="--base-url"){let a=$(e,i);a.value&&(c=a.value),i=a.next;continue}if(s.startsWith("--base-url=")){c=s.slice(11);continue}!s.startsWith("-")&&n===void 0&&(n=s)}}return{runner:hn(t)?t:void 0,event:n,collectorUrl:r,orgToken:o,baseUrl:c}}function et(e,t=un){let n=t.replace(/\/+$/,""),r=e.trim();return`${n}/${r}/hook`}function he(e=sn()){return me(e,".ev-ai",ln)}function gn(e,t){return{...e,...t}}function Xe(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===127||n===39)return!0}return!1}function _n(e){try{let t=new URL(e);return t.protocol==="https:"?!0:t.protocol==="http:"?Ze.has(t.hostname):!1}catch{return!1}}function tt(e){try{let n=new URL(e).pathname.split("/").filter(r=>r.length>0);if(n.length>=2&&n[n.length-1]==="hook"){let r=n[n.length-2];return r&&r.length>0?r:void 0}return}catch{return}}function nt(e){let t;try{t=new URL(e)}catch{return`invalid URL (got: ${e})`}if(!_n(e))return`must be https (or http on localhost / 127.0.0.1 / ::1) (got: ${e})`;let n=tt(e);if(!n)return`must end with /{orgToken}/hook (got: ${e})`;if(!ze.test(n))return`org token must match ${ze.source} (got: ${n})`;if(Xe(e))return`must not contain whitespace, control characters, or single quotes (got: ${e})`;if(Xe(t.pathname))return`pathname must not contain whitespace, control characters, or single quotes (got: ${e})`}function yn(e){return new URL(e).toString()}function qe(e){if(e.collector_url)return e.collector_url;let t=e.repo_ingest_token,n=typeof t=="string"?t.trim():void 0;return n?et(n):""}function rt(e){try{return Ze.has(new URL(e).hostname)}catch{return!1}}function ot(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 Sn(e){let t=e.collectorUrl?.trim(),n;if(t)n=t;else{let o=e.orgToken?.trim();o&&(n=et(o,e.baseUrl?.trim()??void 0))}if(!n)return{};let r=nt(n);return r?{problem:r}:{url:yn(n)}}var ge={access:nn,stat:on,readFile:(e,t)=>rn(e,t)};async function vn(e,t,n=ge){let r=Ge(e),{root:o}=cn(r);for(;;){let i=me(r,".git");try{let a=await n.stat(i);if(a.isDirectory()||a.isFile())return r}catch{}if(r===o)break;let s=an(r);if(s===r)break;r=s}let c=t.CURSOR_PROJECT_DIR??t.CLAUDE_PROJECT_DIR;if(c)try{if((await n.stat(c)).isDirectory())return c}catch{}return Ge(e)}async function I(e,t=ge){try{let n=await t.stat(e);if(!n.isFile()||n.size>fn)return;let r=await t.readFile(e,"utf8"),o=JSON.parse(r);return o===null||typeof o!="object"||Array.isArray(o)?void 0:o}catch{return}}async function Qe(e,t){return(await Promise.all(pn.map(async r=>{let o=me(e,r);try{return await t.access(o),o}catch{return}}))).find(r=>r!==void 0)}async function it(e){let t=e.fs??ge,n=Sn(pe(e.argv));if(n.url)return{url:n.url,source:"argv"};let r=e.env.EV_AI_HOOK_MANIFEST;if(r)try{await t.access(r);let p=await I(r,t),l=p?qe(p):"";return l?{url:l,source:"manifest_override"}:{source:"none"}}catch{}let o=await vn(e.cwd,e.env,t),c=he(e.home),[i,s]=await Promise.all([I(c,t),Qe(o,t).then(async p=>p??Qe(e.cwd,t))]),a=s?await I(s,t):void 0,u;i&&a?u=gn(a,i):i?u=i:a&&(u=a);let d=u?qe(u):"";return d?{url:d,source:"manifest"}:{source:"none"}}function st(e){if(nt(e))return;let t;try{t=new URL(e)}catch{return}let n=tt(e);if(!n)return;let o=t.pathname.split("/").filter(s=>s.length>0).slice(0,-2),c=o.length>0?`/${o.join("/")}`:"",i=`${t.origin}${c}/${n}`;return tn("sha256").update(i).digest("hex").slice(0,32)}async function W(e,t){return e.EV_AI_AUTO_UPDATE==="0"?!0:(await I(he(t)))?.auto_update===!1}function F(e){return!!e.CURSOR_SANDBOX}async function at(e,t,n,r,o,c){if(F(c))return;let i=le(t,n),s=await fe(e,i),a=s?.consecutive_startup_failures??0;if(!r){a>0&&await se(e,i,JSON.stringify({consecutive_startup_failures:0}));return}let u={consecutive_startup_failures:a+1};a+1>=Ue?u.quarantined_until=new Date(o+De).toISOString():s?.quarantined_until&&(u.quarantined_until=s.quarantined_until),await se(e,i,JSON.stringify(u))}function bn(e,t){return new Promise(n=>{try{e.write(t,()=>n())}catch{n()}})}function ct(e){let t=e.now(),n=re,r=!1,o=Promise.resolve(),c,i=!1,s=[],a,u,d,p=()=>Math.max(0,t+n-e.now()),l=[],f=(h,v)=>{if(e.installProcessHandlers===!1)return;(e.on??((O,_)=>process.on(O,_)))(h,v),l.push({event:h,handler:v})},y=()=>{let h=e.off??((v,A)=>process.off(v,A));for(let{event:v,handler:A}of l)try{h(v,A)}catch{}l.length=0},b=h=>(r||(r=!0,o=bn(e.stdout,h??Pe)),o),S=h=>{if(c)try{c.kill(h)}catch{}},C=()=>{for(let h of s)try{h()}catch{}},w=()=>{i||(C(),S("SIGTERM"),u=e.setTimeout(()=>{S("SIGKILL")},H),b())},R=()=>{b().finally(()=>{e.exit(0)})},k=()=>{i||(C(),R())},N=()=>{a&&e.clearTimeout(a),d&&e.clearTimeout(d),a=e.setTimeout(w,p());let h=Math.max(0,t+n+Te-e.now());d=e.setTimeout(k,h)};N(),f("uncaughtException",R),f("unhandledRejection",R);for(let h of["SIGTERM","SIGINT"])f(h,()=>{S(h),R()});return{ackOnce:b,remainingMs:p,eventBudgetMs:()=>n,onEventClassified(h){let v=h?re:Le;v<n&&(n=v,N())},setChild(h){c=h},onAbort(h){s.push(h)},dispose(){i=!0,a&&e.clearTimeout(a),u&&e.clearTimeout(u),d&&e.clearTimeout(d),y()},waitForAckWrite(){return o}}}function En(e){let t=e.trim();if(t)try{let n=JSON.parse(t);return x(n)?n:void 0}catch{return}}function ut(e,t,n,r){if(!t||n!==0||r)return;let o=e.toString("utf8");if(En(o)!==void 0)return o.trim()}var dt=[q,Q,U,ee,Z,M];function _e(e){return Buffer.isBuffer(e)?e:Buffer.from(e)}function wn(e,t,n){let r={...e.env};return r[ee]="3",r[q]=n,r[Q]=String(1),r[Z]=t.source,t.fallbackReason?r[M]=t.fallbackReason:delete r[M],t.scopeId?r[U]=t.scopeId:delete r[U],r}function xn(e){let t=e.stdio[3];if(t&&typeof t=="object"&&"on"in t)return t}async function ye(e,t,n,r,o,c,i="live"){let s;try{s=o.spawn(o.execPath,[e.hookPath,...t],{cwd:o.cwd,env:wn(o,e,c),stdio:["pipe","pipe","pipe","pipe"],windowsHide:!0})}catch{return{outcome:"spawn_failed",ready:!1}}r.setChild(s);let a=!1,u=s.stdout,d=s.stderr,p=s.stdin,l=xn(s);if(!u||!d||!p){try{s.kill("SIGKILL")}catch{}return n.stopChildWrites(),r.setChild(void 0),{outcome:"spawn_failed",ready:!1}}i==="replay"?n.replayTo(p):n.attachChild(p);let f="pending",y=Buffer.alloc(0),b=!1,S=!1,C=!1,w=0,R=null,k=!1,N=_=>{if(b)return;if(y.length+_.length>te){y=Buffer.concat([y,_.subarray(0,te-y.length)]),b=!0;return}y=Buffer.concat([y,_])};u.on("data",_=>{N(_e(_))}),u.on("end",()=>{S=!0}),u.on("error",()=>{C=!0,S=!0}),d.on("data",_=>{if(w>=ne)return;let E=_e(_),m=ne-w,g=E.length>m?E.subarray(0,m):E;w+=g.length;try{o.stderr.write(g)}catch{}}),d.resume(),l?(l.on("data",_=>{f==="pending"&&_e(_).includes(Ae[0]??1)&&(f="byte")}),l.on("end",()=>{f==="pending"&&(f="eof")}),l.on("error",()=>{f==="pending"&&(f="error")})):f="error";let h=o.setTimeout(()=>{if(!(f!=="pending"||k))try{s.kill("SIGKILL")}catch{}},Oe);await new Promise(_=>{let E=!1,m=()=>{E||(E=!0,_())};s.once("exit",g=>{k=!0,R=g,m()}),s.once("error",()=>{a=!0,k=!0,m()})}),n.stopChildWrites(),o.clearTimeout(h);let v=Math.min(H,Math.max(0,r.remainingMs()));await new Promise(_=>{let E=()=>f!=="pending"&&S;if(E()){_();return}let m=o.setTimeout(()=>_(),v),g=()=>{E()&&(o.clearTimeout(m),_())};u.on("end",g),u.on("error",g),l?.on("end",g),l?.on("error",g),l?.on("data",g)}),u.removeAllListeners(),d.removeAllListeners(),l?.removeAllListeners();try{u.destroy()}catch{}try{d.destroy()}catch{}try{l?.destroy()}catch{}if(r.setChild(void 0),a)return{outcome:"spawn_failed",ready:!1};let A=f==="byte",O=ut(y,A,R,b||C);return O!==void 0?(await r.ackOnce(O),{outcome:"success",ready:!0}):f==="eof"?{outcome:"startup_failure",ready:!1}:{outcome:"runtime_failure",ready:A}}function Rn(e){let t=e.charAt(0);return t!==""&&t.toLowerCase()===t}function An(e,t){let n=e.toLowerCase();return n==="sessionend"||n==="stopfailure"||n==="subagentstop"?!0:n==="stop"&&t==="codex"}function lt(e,t,n){let r=n.EV_AI_HOOK_SYNC==="1";if(t===void 0||Buffer.byteLength(t,"utf8")>=D)return{isSessionStart:!1,isInProcess:r};let o=pe(e),c=o.event??"",i=o.runner??"";try{let s=JSON.parse(t);x(s)&&(!c&&typeof s.hook_event_name=="string"?c=s.hook_event_name:!c&&typeof s.event=="string"&&(c=s.event),!i&&(typeof s.conversation_id=="string"||Rn(c))&&(i="cursor"))}catch{}return{isSessionStart:c.toLowerCase()==="sessionstart",isInProcess:r||An(c,i)}}import{readFile as Pn}from"node:fs/promises";import{fileURLToPath as Cn}from"node:url";async function ft(e){let t=Cn(new URL("../package.json",e)),n=await Pn(t,"utf8"),r=JSON.parse(n);return{version:typeof r.version=="string"?r.version:"",evAi:{launcherProtocol:Se(r.evAi?.launcherProtocol),minLauncherProtocol:Se(r.evAi?.minLauncherProtocol),launcherRevision:Se(r.evAi?.launcherRevision)}}}function Se(e){return typeof e=="number"&&Number.isInteger(e)?e:0}var kn=new Set(["configure","install","migrate-to-plugin","update","uninstall","--version","-V","help","--help","-h"]);function Y(e){let t=e[0];return t==="status"?"status":t==="__refresh"?"refresh":t==="__work"||t==="__post"?"bundled_cli":t===void 0||kn.has(t)?"cli":"hook"}async function mt(e,t){let n=await it({argv:e,env:t.env,cwd:t.cwd,home:t.home});if(!n.url)return;let r=st(n.url);if(!(!r||n.source==="none"))return{scopeId:r,collectorUrl:n.url,collectorUrlRedacted:ot(n.url),source:n.source,dev:rt(n.url)}}import{join as pt}from"node:path";var Nn=/^(\d{10})$/,On=/^(\d{10})\.done$/,Ln=/^[0-9a-f]{64}$/i;function yt(e){let t=e[Re];if(t===void 0||t==="")return L;let n=Number(t);return!Number.isInteger(n)||n<=0?L:Math.min(Math.max(L,n*60),oe)}async function St(e,t,n=!1){let r=$e(t),o=await Ke(e,r),c=new Map,i=new Map,s=ht(o,Nn),a=ht(o,On),u=async l=>{let f=await _t(e,pt(r,Fn(l)));return f&&c.set(l,{record:Un(f.value),mtimeMs:f.mtimeMs}),f!==void 0},d=async l=>{let f=Dn((await _t(e,pt(r,In(l))))?.value);return f&&i.set(l,f),f!==void 0};if(!n)return await Promise.all([...s.map(u),...a.map(d)]),{claims:c,dones:i};await Promise.all([gt(s,u),gt(a,d)]);let p=G(c);return p<G(i)&&a.includes(p)&&await d(p),{claims:c,dones:i}}function ht(e,t){return e.flatMap(n=>{let r=t.exec(n);return r?[Number(r[1])]:[]})}async function gt(e,t){for(let n of[...e].sort((r,o)=>o-r))if(await t(n))return}function G(e){let t=0;for(let n of e.keys())n>t&&(t=n);return t}function vt(e,t,n){let r=G(e.claims),o=G(e.dones),c=r===0?{kind:"uninitialized"}:{kind:"bundled",why:"bootstrap_failed"},i;if(o>0){let f=e.dones.get(o);f&&(c=f.selection,i=f.outcome)}let s=r>0?e.claims.get(r):void 0,a=s?Tn(s):void 0,u=r>0?e.dones.get(r):void 0,d=Mn(u?.interval_s,n),p=a!==void 0?a+d*1e3:void 0,l=a!==void 0&&a-t>Ie;return{latest:r,startMs:a,intervalS:d,deadlineMs:p,selection:c,lastOutcome:i,futureDated:l,highestDone:o}}function Tn(e){if(e.record!=="empty"&&e.record.started_at){let t=Date.parse(e.record.started_at);if(Number.isFinite(t))return t}return e.mtimeMs}function Fn(e){return ce(e)}function In(e){return`${ce(e)}.done`}function Mn(e,t){return typeof e!="number"||!Number.isFinite(e)||e<=0?Math.max(L,t):Math.min(Math.max(Math.floor(e),L,t),oe)}async function _t(e,t){let n;try{n=await e.stat(t)}catch(o){if(T(o))return;throw o}let r=n.mtimeMs;if(n.size===0||n.size>ie)return{mtimeMs:r};try{let o=await e.readFile(t);return o.byteLength===0||o.byteLength>ie?{mtimeMs:r}:{mtimeMs:r,value:JSON.parse(o.toString("utf8"))}}catch{return{mtimeMs:r}}}function Un(e){if(!x(e))return"empty";let t={};return typeof e.started_at=="string"&&(t.started_at=e.started_at),(e.owner==="bootstrap"||e.owner==="refresh")&&(t.owner=e.owner),e.resync===!0&&(t.resync=!0),t}function Dn(e){if(!x(e))return;let t=e;if(typeof t.finished_at!="string"||typeof t.outcome!="string"||typeof t.interval_s!="number"||!Number.isFinite(t.interval_s))return;let n=Hn(t.selection);if(n)return{finished_at:t.finished_at,interval_s:t.interval_s,outcome:t.outcome,selection:n}}function Hn(e){if(!x(e))return;let t=e;if(t.kind==="bundled")return t.why==="server"||t.why==="bootstrap_failed"?{kind:"bundled",why:t.why}:void 0;if(t.kind==="cached"&&typeof t.digest=="string"&&Ln.test(t.digest)&&typeof t.version=="string"&&t.version.length>0&&typeof t.integrity=="string"&&t.integrity.startsWith("sha512-"))return{kind:"cached",digest:t.digest.toLowerCase(),version:t.version,integrity:t.integrity}}function z(e,t){return new URL(t,e.launcherUrl??import.meta.url)}function P(e,t,n,r){return{source:"bundled",hookPath:e.bundledHookPath,fallbackReason:t,scopeId:n?.scopeId,dev:n?.dev,...r}}async function bt(e,t,n){if(await W(t.env,t.home))return P(t,"kill_switch",n);if(!n)return P(t,"no_collector_url",n);let r=j(),o=yt(t.env),c=t.now(),i=Je(t.home,n.scopeId),s=vt(await St(r,i,!0),c,o),a={deadlineMs:s.deadlineMs,dev:n.dev};if(s.selection.kind==="cached"){let d=J(t.home,n.dev),p=await t.readPackageInfo().then(f=>f.version,()=>""),l=await Ye(r,d,s.selection.digest,p,c);return l.usable?{source:"cached",hookPath:de(d,s.selection.digest),scopeId:n.scopeId,digest:s.selection.digest,healthFails:l.healthFails,...a}:P(t,l.reason,n,a)}if(s.selection.kind==="bundled")return P(t,s.selection.why,n,a);if(F(t.env))return P(t,"sandboxed",n,a);let u=await ve(t);if(!u)return P(t,"bootstrap_failed",n,a);try{let d=await t.readPackageInfo();return await u.bootstrap({home:t.home,scope:n,bundledVersion:d.version,bundledHookPath:t.bundledHookPath,env:t.env,nowMs:c})}catch{return P(t,"bootstrap_failed",n,a)}}async function ve(e){try{return e.importUpdate?await e.importUpdate():await import(z(e,"./launcher-update.mjs").href)}catch{return}}function Et(e,t){let n=[],r=[],o=0,c=0,i="pending",s,a=!1,u=!1,d=!1,p=!1,l=!1,f=[],y=()=>{!p&&typeof e.pause=="function"&&(e.pause(),p=!0)},b=()=>{p&&typeof e.resume=="function"&&(e.resume(),p=!1)},S=()=>{a=!1,d=!1,u=!0,b()},C=()=>{if(!(l||i==="pending")){l=!0,t.clearTimeout(O);for(let m of f)m();f.length=0}},w=m=>{i==="pending"&&(i=m),C()},R=()=>{if(a&&s)try{s.end()}catch{a=!1}},k=m=>{if(i==="oversize")return;let g=c+m.length;if(g>Ne){w("oversize");return}r.push(m),c=g},N=m=>{if(!(!a||!s))try{if(!s.write(m)){if(s.destroyed||!s.writable){S();return}d=!0,y()}}catch{S()}},h=m=>{let g=Buffer.isBuffer(m)?m:Buffer.from(m);if(!(i==="truncated"||i==="complete")&&(k(g),!u)){if(a){N(g);return}n.push(g),o+=g.length,o>=ke&&y()}},v=()=>{R(),w("complete")},A=()=>{i==="pending"&&w("truncated")},O=t.setTimeout(()=>{i==="pending"&&(w("truncated"),R(),S())},Ce);"isTTY"in e&&!!e.isTTY?w("complete"):(e.on("data",h),e.on("end",v),e.on("error",A),typeof e.resume=="function"&&e.resume());let E=m=>{m.on("error",()=>{S()}),m.on("drain",()=>{!a||u||(d=!1,b())})};return{get state(){return i},get replayable(){return i==="complete"},get backlogBytes(){return o},get replayBytes(){return c},attachChild(m){s=m,u=!1,a=!0,d=!1,E(m);for(let g of n){if(!a)break;N(g)}if(n.length=0,o=0,d?y():b(),i!=="pending"){try{m.end()}catch{S()}a=!1}},replayTo(m){E(m);try{m.end(r.length>0?Buffer.concat(r,c):Buffer.alloc(0))}catch{}},stopChildWrites(){S()},dispose(){t.clearTimeout(O),e.off?.("data",h),e.off?.("end",v),e.off?.("error",A)},classifiableText(){if(!(i!=="complete"||c>=D))return Buffer.concat(r,c).toString("utf8")},whenSettled(){return l?Promise.resolve():new Promise(m=>{f.push(m)})}}}var At={version:"",evAi:{launcherProtocol:1,minLauncherProtocol:1,launcherRevision:1}};function Vn(e){return Rt(new URL("./hook.mjs",e))}function Kn(e){let t;return{stdin:process.stdin,stdout:process.stdout,stderr:process.stderr,env:process.env,cwd:process.cwd(),home:jn(),now:()=>Date.now(),spawn:Bn,exit:n=>{process.exit(n)},setTimeout,clearTimeout,bundledHookPath:Vn(e),execPath:process.execPath,select:bt,readPackageInfo:()=>t??=ft(e),launcherUrl:e}}async function wt(e){return e.importCli?e.importCli():import(z(e,"./cli.mjs").href)}async function Pt(e=process.argv.slice(2),t=Kn(import.meta.url)){let n=Y(e);if(n==="cli")try{return await(await wt(t)).main(e)}catch(i){let s=i instanceof Error?i.message:String(i);try{t.stderr.write(`[ev-ai-agent-hook] ${s}
4
+ `)}catch{}return 1}if(n==="bundled_cli")return(await wt(t)).main(e);if(n==="refresh"||n==="status")try{let i=await t.readPackageInfo().catch(()=>At),s=await ve(t);return s?n==="refresh"?await s.runRefresh(e.slice(1),t.env,t.cwd,t.home,{packageVersion:i.version}):await s.runStatus(e,t,i):0}catch{return 0}let r=()=>{},o=new Promise(i=>{r=i}),c={...t,exit:i=>{t.exit(i),r(i)}};return Promise.race([Jn(e,c),o])}async function Jn(e,t){let n=ct(t),r=Et(t.stdin,t),o,c=()=>o??=lt(e,r.classifiableText(),t.env);r.whenSettled().then(()=>n.onEventClassified(c().isInProcess));let i=!1,s=new Promise(d=>{n.onAbort(()=>{i=!0,d()})}),a=d=>Promise.race([d,s.then(()=>{})]),u=async d=>(await n.ackOnce(),n.dispose(),r.dispose(),d);try{let d=t.readPackageInfo().catch(()=>At),p;try{p=await a(mt(e,t))}catch{p=void 0}if(i)return u(0);let l;try{l=await a(t.select(e,t,p))}catch{l=P(t,"selection_error",p)}let f=await a(d);if(i||!l||!f)return u(0);let y=await ye(l,e,r,n,t,f.version,"live");if(y.outcome==="success"&&l.source==="cached"&&l.healthFails&&await xt(t,l,!1),y.outcome==="startup_failure"&&l.source!=="bundled"&&(await xt(t,l,!0),r.replayable&&n.remainingMs()>Fe)){let b=P(t,"startup_failure",p);await ye(b,e,r,n,t,f.version,"replay")}return await $n(e,t,l,p,r.replayable,c),u(0)}catch{return u(0)}}async function $n(e,t,n,r,o,c){if(!r||n.didBootstrap||!o||F(t.env)||n.deadlineMs!==void 0&&n.deadlineMs>t.now()||!c().isSessionStart||await W(t.env,t.home))return;let i={...t.env};for(let s of dt)delete i[s];i[xe]=r.scopeId;try{t.spawn(t.execPath,[Rt(z(t,"./launcher.mjs")),"__refresh",...e],{cwd:t.cwd,env:i,detached:!0,stdio:"ignore",windowsHide:!0}).unref()}catch{}}async function xt(e,t,n){t.digest&&await at(j(),J(e.home,t.dev===!0),t.digest,n,e.now(),e.env).catch(()=>{})}Pt().then(e=>{process.exit(e)}).catch(e=>{if(Y(process.argv.slice(2))==="cli"){let t=e instanceof Error?e.message:String(e);try{process.stderr.write(`[ev-ai-agent-hook] ${t}
5
+ `)}catch{}process.exit(1)}try{process.stdout.write('{"continue":true}')}catch{}process.exit(0)});
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/install/managed-hooks-snippet.ts
21
+ var managed_hooks_snippet_exports = {};
22
+ __export(managed_hooks_snippet_exports, {
23
+ buildCollectorUrl: () => buildCollectorUrl,
24
+ managedHooksSnippet: () => managedHooksSnippet
25
+ });
26
+ module.exports = __toCommonJS(managed_hooks_snippet_exports);
27
+
28
+ // src/config/collector-url-resolve.ts
29
+ var DEFAULT_COLLECTOR_BASE_URL = "https://hooks.ev-ai.ai";
30
+ var MAX_JSON_FILE_BYTES = 1024 * 1024;
31
+ function buildCollectorUrl(orgToken, baseUrl = DEFAULT_COLLECTOR_BASE_URL) {
32
+ const normalizedBase = baseUrl.replace(/\/+$/, "");
33
+ const token = orgToken.trim();
34
+ return `${normalizedBase}/${token}/hook`;
35
+ }
36
+
37
+ // src/shared/constants.ts
38
+ var HOOK_BINARY_NAME = "ev-ai-agent-hook";
39
+ var HOOK_CHECKSUMS_FILE = "SHA256SUMS";
40
+ var GLOBAL_HOOK_BINARY_RELATIVE = `current/${HOOK_BINARY_NAME}`;
41
+ var PROJECT_HOOK_BINARY_RELATIVE = `.ev-ai/agent-hook/${HOOK_BINARY_NAME}`;
42
+ var HOOK_INPUT_ALLOWLIST_MAX_BYTES = 4 * 1024;
43
+ var HOOK_INPUT_FULL_MAX_BYTES = 256 * 1024;
44
+ var HOOK_INPUT_MCP_MAX_BYTES = 4 * 1024;
45
+ var GZIP_MIN_BYTES = 32 * 1024;
46
+ var USER_SPEC_COOLDOWN_MS = 14 * 60 * 60 * 1e3;
47
+ var PACKAGE_VERSION = "1.2.1";
48
+ var NPX_PACKAGE_SPEC = `@ev-ai/agent-hook@${PACKAGE_VERSION}`;
49
+ var HOOK_STATUS_MESSAGE = "ev-ai runtime report";
50
+
51
+ // src/install/install.ts
52
+ function isSessionStartEvent(eventName) {
53
+ return eventName === "SessionStart" || eventName === "sessionStart";
54
+ }
55
+ function withoutPreferOffline(command) {
56
+ return command.replace(/\s+--prefer-offline\b/g, "");
57
+ }
58
+ function commandForEvent(eventName, command) {
59
+ return isSessionStartEvent(eventName) ? withoutPreferOffline(command) : command;
60
+ }
61
+ function npxHookCommand(packageSpec = NPX_PACKAGE_SPEC) {
62
+ return `npx -y --prefer-offline ${packageSpec}`;
63
+ }
64
+ function withRunnerFlag(command, runner) {
65
+ const stripped = command.replace(/\s+--runner(?:=|\s+)\S+/g, "").trimEnd();
66
+ return `${stripped} --runner ${runner}`;
67
+ }
68
+ var FLAG_VALUE = `(?:'[^']*'|"[^"]*"|\\S+)`;
69
+ function withUrlFlag(command, collectorUrl) {
70
+ const stripped = command.replace(new RegExp(`\\s+--url(?:=|\\s+)${FLAG_VALUE}`, "g"), "").replace(new RegExp(`\\s+--token(?:=|\\s+)${FLAG_VALUE}`, "g"), "").replace(new RegExp(`\\s+--base-url(?:=|\\s+)${FLAG_VALUE}`, "g"), "").trimEnd();
71
+ const quoted = collectorUrl.replace(/'/g, `'\\''`);
72
+ return `${stripped} --url '${quoted}'`;
73
+ }
74
+ function toCommandList(command) {
75
+ return typeof command === "string" ? [command] : command;
76
+ }
77
+ function desiredClaudeHookGroups(command) {
78
+ const commandHook = (eventName = "") => ({
79
+ hooks: toCommandList(command).map((entry) => ({
80
+ type: "command",
81
+ command: commandForEvent(eventName, entry)
82
+ }))
83
+ });
84
+ return {
85
+ SessionStart: [commandHook("SessionStart")],
86
+ // Slash skills bypass PreToolUse(Skill); UserPromptExpansion is the observable path.
87
+ UserPromptExpansion: [commandHook()],
88
+ // Prompt bodies (non-slash included). Slash skill ids still come from Expansion.
89
+ UserPromptSubmit: [commandHook()],
90
+ // All tools (replaces prior Skill-only matcher on reinstall).
91
+ PreToolUse: [commandHook()],
92
+ PostToolUse: [commandHook()],
93
+ PostToolUseFailure: [commandHook()],
94
+ // Denied-before-run tools never fire PostToolUseFailure.
95
+ PermissionDenied: [commandHook()],
96
+ Stop: [commandHook()],
97
+ // Turn ended due to API error (rate_limit / overloaded / …).
98
+ StopFailure: [commandHook()],
99
+ SessionEnd: [commandHook()],
100
+ SubagentStart: [commandHook()],
101
+ SubagentStop: [commandHook()]
102
+ };
103
+ }
104
+ function desiredCodexHookGroups(command) {
105
+ const spec = typeof command === "string" ? { command } : command;
106
+ const commandHook = (eventName = "") => ({
107
+ hooks: [
108
+ {
109
+ type: "command",
110
+ command: commandForEvent(eventName, spec.command),
111
+ ...spec.commandWindows === void 0 ? {} : { commandWindows: commandForEvent(eventName, spec.commandWindows) },
112
+ statusMessage: HOOK_STATUS_MESSAGE
113
+ }
114
+ ]
115
+ });
116
+ return {
117
+ SessionStart: [commandHook("SessionStart")],
118
+ // Slash / custom-prompt skill ids from prompt text (body never POSTed on allowlist).
119
+ UserPromptSubmit: [commandHook()],
120
+ PreToolUse: [commandHook()],
121
+ PostToolUse: [commandHook()],
122
+ Stop: [commandHook()]
123
+ };
124
+ }
125
+ var CURSOR_WIRED_HOOK_EVENTS = [
126
+ "sessionStart",
127
+ "beforeSubmitPrompt",
128
+ "preToolUse",
129
+ "postToolUse",
130
+ "postToolUseFailure",
131
+ "beforeShellExecution",
132
+ "beforeReadFile",
133
+ "beforeMCPExecution",
134
+ "subagentStart",
135
+ "subagentStop",
136
+ "stop"
137
+ ];
138
+
139
+ // src/install/plugin-hooks.ts
140
+ var PLUGIN_HOOK_PAYLOAD = "hook.mjs";
141
+ var PLUGIN_CHECKSUMS_FILE = HOOK_CHECKSUMS_FILE;
142
+ function buildClaudePluginHooks(command) {
143
+ return { hooks: desiredClaudeHookGroups(command) };
144
+ }
145
+ function buildCursorPluginHooks(command) {
146
+ const hooks = {};
147
+ for (const eventName of CURSOR_WIRED_HOOK_EVENTS) {
148
+ hooks[eventName] = toCommandList(command).map((entry) => ({
149
+ command: commandForEvent(eventName, entry)
150
+ }));
151
+ }
152
+ return { hooks };
153
+ }
154
+ function buildCodexPluginHooks(command) {
155
+ return { hooks: desiredCodexHookGroups(command) };
156
+ }
157
+ var PLUGIN_PAYLOAD_FILES = [
158
+ { source: "dist/hook.mjs", target: PLUGIN_HOOK_PAYLOAD, executable: false },
159
+ {
160
+ source: `compile-out/bin/${PLUGIN_CHECKSUMS_FILE}`,
161
+ target: PLUGIN_CHECKSUMS_FILE,
162
+ executable: false,
163
+ optional: true
164
+ }
165
+ ];
166
+
167
+ // src/install/managed-hooks-snippet.ts
168
+ function managedHooksSnippet(runner, collectorUrl) {
169
+ const command = withUrlFlag(withRunnerFlag(npxHookCommand(), runner), collectorUrl);
170
+ const doc = runner === "cursor" ? { version: 1, ...buildCursorPluginHooks(command) } : runner === "claude" ? buildClaudePluginHooks(command) : buildCodexPluginHooks(command);
171
+ return JSON.stringify(doc, null, 2);
172
+ }
173
+ // Annotate the CommonJS export names for ESM import in node:
174
+ 0 && (module.exports = {
175
+ buildCollectorUrl,
176
+ managedHooksSnippet
177
+ });
@@ -0,0 +1,3 @@
1
+ export type KnownRunner = 'claude' | 'cursor' | 'codex';
2
+ export function buildCollectorUrl(orgToken: string, baseUrl?: string): string;
3
+ export function managedHooksSnippet(runner: KnownRunner, collectorUrl: string): string;
@@ -0,0 +1,149 @@
1
+ // src/config/collector-url-resolve.ts
2
+ var DEFAULT_COLLECTOR_BASE_URL = "https://hooks.ev-ai.ai";
3
+ var MAX_JSON_FILE_BYTES = 1024 * 1024;
4
+ function buildCollectorUrl(orgToken, baseUrl = DEFAULT_COLLECTOR_BASE_URL) {
5
+ const normalizedBase = baseUrl.replace(/\/+$/, "");
6
+ const token = orgToken.trim();
7
+ return `${normalizedBase}/${token}/hook`;
8
+ }
9
+
10
+ // src/shared/constants.ts
11
+ var HOOK_BINARY_NAME = "ev-ai-agent-hook";
12
+ var HOOK_CHECKSUMS_FILE = "SHA256SUMS";
13
+ var GLOBAL_HOOK_BINARY_RELATIVE = `current/${HOOK_BINARY_NAME}`;
14
+ var PROJECT_HOOK_BINARY_RELATIVE = `.ev-ai/agent-hook/${HOOK_BINARY_NAME}`;
15
+ var HOOK_INPUT_ALLOWLIST_MAX_BYTES = 4 * 1024;
16
+ var HOOK_INPUT_FULL_MAX_BYTES = 256 * 1024;
17
+ var HOOK_INPUT_MCP_MAX_BYTES = 4 * 1024;
18
+ var GZIP_MIN_BYTES = 32 * 1024;
19
+ var USER_SPEC_COOLDOWN_MS = 14 * 60 * 60 * 1e3;
20
+ var PACKAGE_VERSION = "1.2.1";
21
+ var NPX_PACKAGE_SPEC = `@ev-ai/agent-hook@${PACKAGE_VERSION}`;
22
+ var HOOK_STATUS_MESSAGE = "ev-ai runtime report";
23
+
24
+ // src/install/install.ts
25
+ function isSessionStartEvent(eventName) {
26
+ return eventName === "SessionStart" || eventName === "sessionStart";
27
+ }
28
+ function withoutPreferOffline(command) {
29
+ return command.replace(/\s+--prefer-offline\b/g, "");
30
+ }
31
+ function commandForEvent(eventName, command) {
32
+ return isSessionStartEvent(eventName) ? withoutPreferOffline(command) : command;
33
+ }
34
+ function npxHookCommand(packageSpec = NPX_PACKAGE_SPEC) {
35
+ return `npx -y --prefer-offline ${packageSpec}`;
36
+ }
37
+ function withRunnerFlag(command, runner) {
38
+ const stripped = command.replace(/\s+--runner(?:=|\s+)\S+/g, "").trimEnd();
39
+ return `${stripped} --runner ${runner}`;
40
+ }
41
+ var FLAG_VALUE = `(?:'[^']*'|"[^"]*"|\\S+)`;
42
+ function withUrlFlag(command, collectorUrl) {
43
+ const stripped = command.replace(new RegExp(`\\s+--url(?:=|\\s+)${FLAG_VALUE}`, "g"), "").replace(new RegExp(`\\s+--token(?:=|\\s+)${FLAG_VALUE}`, "g"), "").replace(new RegExp(`\\s+--base-url(?:=|\\s+)${FLAG_VALUE}`, "g"), "").trimEnd();
44
+ const quoted = collectorUrl.replace(/'/g, `'\\''`);
45
+ return `${stripped} --url '${quoted}'`;
46
+ }
47
+ function toCommandList(command) {
48
+ return typeof command === "string" ? [command] : command;
49
+ }
50
+ function desiredClaudeHookGroups(command) {
51
+ const commandHook = (eventName = "") => ({
52
+ hooks: toCommandList(command).map((entry) => ({
53
+ type: "command",
54
+ command: commandForEvent(eventName, entry)
55
+ }))
56
+ });
57
+ return {
58
+ SessionStart: [commandHook("SessionStart")],
59
+ // Slash skills bypass PreToolUse(Skill); UserPromptExpansion is the observable path.
60
+ UserPromptExpansion: [commandHook()],
61
+ // Prompt bodies (non-slash included). Slash skill ids still come from Expansion.
62
+ UserPromptSubmit: [commandHook()],
63
+ // All tools (replaces prior Skill-only matcher on reinstall).
64
+ PreToolUse: [commandHook()],
65
+ PostToolUse: [commandHook()],
66
+ PostToolUseFailure: [commandHook()],
67
+ // Denied-before-run tools never fire PostToolUseFailure.
68
+ PermissionDenied: [commandHook()],
69
+ Stop: [commandHook()],
70
+ // Turn ended due to API error (rate_limit / overloaded / …).
71
+ StopFailure: [commandHook()],
72
+ SessionEnd: [commandHook()],
73
+ SubagentStart: [commandHook()],
74
+ SubagentStop: [commandHook()]
75
+ };
76
+ }
77
+ function desiredCodexHookGroups(command) {
78
+ const spec = typeof command === "string" ? { command } : command;
79
+ const commandHook = (eventName = "") => ({
80
+ hooks: [
81
+ {
82
+ type: "command",
83
+ command: commandForEvent(eventName, spec.command),
84
+ ...spec.commandWindows === void 0 ? {} : { commandWindows: commandForEvent(eventName, spec.commandWindows) },
85
+ statusMessage: HOOK_STATUS_MESSAGE
86
+ }
87
+ ]
88
+ });
89
+ return {
90
+ SessionStart: [commandHook("SessionStart")],
91
+ // Slash / custom-prompt skill ids from prompt text (body never POSTed on allowlist).
92
+ UserPromptSubmit: [commandHook()],
93
+ PreToolUse: [commandHook()],
94
+ PostToolUse: [commandHook()],
95
+ Stop: [commandHook()]
96
+ };
97
+ }
98
+ var CURSOR_WIRED_HOOK_EVENTS = [
99
+ "sessionStart",
100
+ "beforeSubmitPrompt",
101
+ "preToolUse",
102
+ "postToolUse",
103
+ "postToolUseFailure",
104
+ "beforeShellExecution",
105
+ "beforeReadFile",
106
+ "beforeMCPExecution",
107
+ "subagentStart",
108
+ "subagentStop",
109
+ "stop"
110
+ ];
111
+
112
+ // src/install/plugin-hooks.ts
113
+ var PLUGIN_HOOK_PAYLOAD = "hook.mjs";
114
+ var PLUGIN_CHECKSUMS_FILE = HOOK_CHECKSUMS_FILE;
115
+ function buildClaudePluginHooks(command) {
116
+ return { hooks: desiredClaudeHookGroups(command) };
117
+ }
118
+ function buildCursorPluginHooks(command) {
119
+ const hooks = {};
120
+ for (const eventName of CURSOR_WIRED_HOOK_EVENTS) {
121
+ hooks[eventName] = toCommandList(command).map((entry) => ({
122
+ command: commandForEvent(eventName, entry)
123
+ }));
124
+ }
125
+ return { hooks };
126
+ }
127
+ function buildCodexPluginHooks(command) {
128
+ return { hooks: desiredCodexHookGroups(command) };
129
+ }
130
+ var PLUGIN_PAYLOAD_FILES = [
131
+ { source: "dist/hook.mjs", target: PLUGIN_HOOK_PAYLOAD, executable: false },
132
+ {
133
+ source: `compile-out/bin/${PLUGIN_CHECKSUMS_FILE}`,
134
+ target: PLUGIN_CHECKSUMS_FILE,
135
+ executable: false,
136
+ optional: true
137
+ }
138
+ ];
139
+
140
+ // src/install/managed-hooks-snippet.ts
141
+ function managedHooksSnippet(runner, collectorUrl) {
142
+ const command = withUrlFlag(withRunnerFlag(npxHookCommand(), runner), collectorUrl);
143
+ const doc = runner === "cursor" ? { version: 1, ...buildCursorPluginHooks(command) } : runner === "claude" ? buildClaudePluginHooks(command) : buildCodexPluginHooks(command);
144
+ return JSON.stringify(doc, null, 2);
145
+ }
146
+ export {
147
+ buildCollectorUrl,
148
+ managedHooksSnippet
149
+ };
@@ -1,8 +1,11 @@
1
- // src/plugin-hooks.ts
1
+ // src/install/plugin-hooks.ts
2
2
  import { chmodSync, copyFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
 
5
- // src/constants.ts
5
+ // src/config/collector-url-resolve.ts
6
+ var MAX_JSON_FILE_BYTES = 1024 * 1024;
7
+
8
+ // src/shared/constants.ts
6
9
  var HOOK_BINARY_NAME = "ev-ai-agent-hook";
7
10
  var HOOK_CHECKSUMS_FILE = "SHA256SUMS";
8
11
  var GLOBAL_HOOK_BINARY_RELATIVE = `current/${HOOK_BINARY_NAME}`;
@@ -12,20 +15,32 @@ var HOOK_INPUT_FULL_MAX_BYTES = 256 * 1024;
12
15
  var HOOK_INPUT_MCP_MAX_BYTES = 4 * 1024;
13
16
  var GZIP_MIN_BYTES = 32 * 1024;
14
17
  var USER_SPEC_COOLDOWN_MS = 14 * 60 * 60 * 1e3;
15
- var PACKAGE_VERSION = "1.1.7";
18
+ var PACKAGE_VERSION = "1.2.1";
16
19
  var NPX_PACKAGE_SPEC = `@ev-ai/agent-hook@${PACKAGE_VERSION}`;
17
20
  var HOOK_STATUS_MESSAGE = "ev-ai runtime report";
18
21
 
19
- // src/install.ts
22
+ // src/install/install.ts
23
+ function isSessionStartEvent(eventName) {
24
+ return eventName === "SessionStart" || eventName === "sessionStart";
25
+ }
26
+ function withoutPreferOffline(command) {
27
+ return command.replace(/\s+--prefer-offline\b/g, "");
28
+ }
29
+ function commandForEvent(eventName, command) {
30
+ return isSessionStartEvent(eventName) ? withoutPreferOffline(command) : command;
31
+ }
20
32
  function toCommandList(command) {
21
33
  return typeof command === "string" ? [command] : command;
22
34
  }
23
35
  function desiredClaudeHookGroups(command) {
24
- const commandHook = () => ({
25
- hooks: toCommandList(command).map((entry) => ({ type: "command", command: entry }))
36
+ const commandHook = (eventName = "") => ({
37
+ hooks: toCommandList(command).map((entry) => ({
38
+ type: "command",
39
+ command: commandForEvent(eventName, entry)
40
+ }))
26
41
  });
27
42
  return {
28
- SessionStart: [commandHook()],
43
+ SessionStart: [commandHook("SessionStart")],
29
44
  // Slash skills bypass PreToolUse(Skill); UserPromptExpansion is the observable path.
30
45
  UserPromptExpansion: [commandHook()],
31
46
  // Prompt bodies (non-slash included). Slash skill ids still come from Expansion.
@@ -46,15 +61,18 @@ function desiredClaudeHookGroups(command) {
46
61
  }
47
62
  function desiredCodexHookGroups(command) {
48
63
  const spec = typeof command === "string" ? { command } : command;
49
- const entry = {
50
- type: "command",
51
- command: spec.command,
52
- ...spec.commandWindows === void 0 ? {} : { commandWindows: spec.commandWindows },
53
- statusMessage: HOOK_STATUS_MESSAGE
54
- };
55
- const commandHook = () => ({ hooks: [entry] });
64
+ const commandHook = (eventName = "") => ({
65
+ hooks: [
66
+ {
67
+ type: "command",
68
+ command: commandForEvent(eventName, spec.command),
69
+ ...spec.commandWindows === void 0 ? {} : { commandWindows: commandForEvent(eventName, spec.commandWindows) },
70
+ statusMessage: HOOK_STATUS_MESSAGE
71
+ }
72
+ ]
73
+ });
56
74
  return {
57
- SessionStart: [commandHook()],
75
+ SessionStart: [commandHook("SessionStart")],
58
76
  // Slash / custom-prompt skill ids from prompt text (body never POSTed on allowlist).
59
77
  UserPromptSubmit: [commandHook()],
60
78
  PreToolUse: [commandHook()],
@@ -76,9 +94,7 @@ var CURSOR_WIRED_HOOK_EVENTS = [
76
94
  "stop"
77
95
  ];
78
96
 
79
- // src/plugin-hooks.ts
80
- var PLUGIN_LAUNCHER_SH = "launcher.sh";
81
- var PLUGIN_LAUNCHER_PS1 = "launcher.ps1";
97
+ // src/install/plugin-hooks.ts
82
98
  var PLUGIN_HOOK_PAYLOAD = "hook.mjs";
83
99
  var PLUGIN_VERSION_FILE = "version";
84
100
  var PLUGIN_CHECKSUMS_FILE = HOOK_CHECKSUMS_FILE;
@@ -88,18 +104,18 @@ var PLUGIN_ROOT_VARIABLE = {
88
104
  codex: "PLUGIN_ROOT"
89
105
  };
90
106
  function pluginLauncherPosixCommand(runner) {
91
- return `"\${${PLUGIN_ROOT_VARIABLE[runner]}}/${PLUGIN_LAUNCHER_SH}" --runner ${runner} ; exit 0`;
107
+ return `node "\${${PLUGIN_ROOT_VARIABLE[runner]}}/${PLUGIN_HOOK_PAYLOAD}" --runner ${runner} ; exit 0`;
92
108
  }
93
109
  function pluginLauncherPowerShellCommand(runner) {
94
110
  const variable = PLUGIN_ROOT_VARIABLE[runner];
95
- return `powershell -NoProfile -NonInteractive -Command "& ([scriptblock]::Create((Get-Content -Raw -LiteralPath (Join-Path (Get-Item Env:${variable}).Value '${PLUGIN_LAUNCHER_PS1}')))) --runner ${runner}" ; exit 0`;
111
+ return `powershell -NoProfile -NonInteractive -Command "node (Join-Path (Get-Item Env:${variable}).Value '${PLUGIN_HOOK_PAYLOAD}') --runner ${runner}" ; exit 0`;
96
112
  }
97
113
  function pluginLauncherCommands(runner) {
98
114
  return [pluginLauncherPosixCommand(runner), pluginLauncherPowerShellCommand(runner)];
99
115
  }
100
116
  function pluginLauncherCodexCommand() {
101
117
  return {
102
- command: `sh -c '"\${PLUGIN_ROOT}/${PLUGIN_LAUNCHER_SH}" --runner codex; exit 0'`,
118
+ command: `sh -c 'node "\${PLUGIN_ROOT}/${PLUGIN_HOOK_PAYLOAD}" --runner codex; exit 0'`,
103
119
  commandWindows: pluginLauncherPowerShellCommand("codex")
104
120
  };
105
121
  }
@@ -107,10 +123,11 @@ function buildClaudePluginHooks(command) {
107
123
  return { hooks: desiredClaudeHookGroups(command) };
108
124
  }
109
125
  function buildCursorPluginHooks(command) {
110
- const commands = typeof command === "string" ? [command] : command;
111
126
  const hooks = {};
112
127
  for (const eventName of CURSOR_WIRED_HOOK_EVENTS) {
113
- hooks[eventName] = commands.map((entry) => ({ command: entry }));
128
+ hooks[eventName] = toCommandList(command).map((entry) => ({
129
+ command: commandForEvent(eventName, entry)
130
+ }));
114
131
  }
115
132
  return { hooks };
116
133
  }
@@ -133,8 +150,6 @@ function marketplacePluginHookPaths(marketplaceRoot) {
133
150
  }
134
151
  var PLUGIN_PAYLOAD_FILES = [
135
152
  { source: "dist/hook.mjs", target: PLUGIN_HOOK_PAYLOAD, executable: false },
136
- { source: `scripts/${PLUGIN_LAUNCHER_SH}`, target: PLUGIN_LAUNCHER_SH, executable: true },
137
- { source: `scripts/${PLUGIN_LAUNCHER_PS1}`, target: PLUGIN_LAUNCHER_PS1, executable: false },
138
153
  {
139
154
  source: `compile-out/bin/${PLUGIN_CHECKSUMS_FILE}`,
140
155
  target: PLUGIN_CHECKSUMS_FILE,
@@ -144,8 +159,6 @@ var PLUGIN_PAYLOAD_FILES = [
144
159
  ];
145
160
  var PLUGIN_REQUIRED_PAYLOAD_TARGETS = [
146
161
  PLUGIN_HOOK_PAYLOAD,
147
- PLUGIN_LAUNCHER_SH,
148
- PLUGIN_LAUNCHER_PS1,
149
162
  PLUGIN_VERSION_FILE
150
163
  ];
151
164
  function writeJson(path, value) {
@@ -202,8 +215,6 @@ export {
202
215
  MARKETPLACE_PLUGIN_NAME,
203
216
  PLUGIN_CHECKSUMS_FILE,
204
217
  PLUGIN_HOOK_PAYLOAD,
205
- PLUGIN_LAUNCHER_PS1,
206
- PLUGIN_LAUNCHER_SH,
207
218
  PLUGIN_PAYLOAD_FILES,
208
219
  PLUGIN_REQUIRED_PAYLOAD_TARGETS,
209
220
  PLUGIN_ROOT_VARIABLE,