@systemfsoftware/omp-claude-compat 1.6.2 → 1.7.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/LICENSE +203 -21
- package/dist/{Cause-BpHZgZuR.js → Cause-DsRZwSYW.js} +1 -1
- package/dist/Effect-C1HfHpDW.js +14 -0
- package/dist/{Exit-BhYZ1Mg3.js → Exit-DWkYikJN.js} +1 -1
- package/dist/core-CG9iBVjE.js +13 -0
- package/dist/dist-CJoMkiK8.js +26 -0
- package/dist/hook-dispatcher.executor-B43vD5qz.js +8 -0
- package/dist/{hook-dispatcher.handler-DoauiNPI.js → hook-dispatcher.handler-W-5FqY16.js} +1 -1
- package/dist/hook-runtime.state-CI_DEJtD.js +1 -0
- package/dist/index.js +1 -1
- package/dist/{inject-instructions.executor-RzZpGK-N.js → inject-instructions.executor-C5AgD0Hh.js} +1 -1
- package/dist/{inject-instructions.handler-B7iXvfzB.js → inject-instructions.handler-CT6g_sFm.js} +1 -1
- package/package.json +26 -20
- package/dist/Effect-fMAnbW-8.js +0 -14
- package/dist/core-C1FEy4nD.js +0 -13
- package/dist/dist-opjiVExE.js +0 -26
- package/dist/hook-dispatcher.executor-VKMzdbhh.js +0 -8
- package/dist/hook-runtime.state-DnCEYjpv.js +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{$s as e,Ai as t,Ds as n,Ec as r,El as i,Fs as a,Hs as o,Js as s,Ks as c,Ls as l,Oo as u,Po as d,Ps as f,Rs as p,Tc as ee,Tl as m,Ts as te,Ys as h,bo as ne,ia as re,jo as ie,ko as ae,oa as g,qs as _,tc as v,wl as y,ws as oe,xi as se,yi as ce,zs as b}from"./core-C1FEy4nD.js";import{$ as le,B as ue,C as x,Dn as de,E as fe,I as S,Mn as pe,O as C,P as me,R as he,T as ge,_t as _e,a as ve,dt as ye,f as be,fn as xe,ft as Se,j as Ce,jn as we,k as Te,o as Ee,ot as De,q as Oe,rt as ke,ut as Ae,x as je}from"./Effect-fMAnbW-8.js";import{f as Me,m as Ne}from"./Cause-BpHZgZuR.js";import{$ as w,A as Pe,B as T,D as Fe,F as Ie,G as E,H as Le,J as Re,K as D,L as ze,M as Be,O as Ve,Q as O,T as He,U as Ue,V as We,W as k,X as A,Y as j,Z as Ge,a as Ke,at as qe,bt as Je,c as Ye,ct as Xe,et as M,i as Ze,it as N,j as Qe,k as $e,l as et,m as tt,nt,o as rt,ot as it,q as P,r as at,rt as ot,s as st,st as ct,tt as lt,u as F,z as I}from"./dist-opjiVExE.js";import{homedir as L}from"node:os";const ut={[Symbol.for(`@effect/matcher/Matcher`)]:{_input:m,_filters:m,_remaining:m,_result:m,_provided:m,_return:m},_tag:`ValueMatcher`,add(e){return this.value._tag===`Right`?this:e._tag===`When`&&e.guard(this.provided)===!0||e._tag===`Not`&&e.guard(this.provided)===!1?dt(this.provided,v(e.evaluate(this.provided))):this},pipe(){return ee(this,arguments)}};function dt(e,t){let n=Object.create(ut);return n.provided=e,n.value=t,n}const ft=(e,t)=>({_tag:`When`,guard:e,evaluate:t}),pt=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=e.map(pt),n=t.length;return e=>{if(!Array.isArray(e))return!1;for(let r=0;r<n;r++)if(t[r](e[r])===!1)return!1;return!0}}else if(typeof e==`object`&&e){let t=Object.entries(e).map(([e,t])=>[e,pt(t)]),n=t.length;return e=>{if(typeof e!=`object`||!e)return!1;for(let r=0;r<n;r++){let[n,i]=t[r];if(!(n in e)||i(e[n])===!1)return!1}return!0}}return t=>t===e},mt=e=>dt(e,h(e)),ht=(e,t)=>n=>n.add(ft(pt(e),t)),gt=(e=>(...t)=>{let n=t[t.length-1],r=t.slice(0,-1),i=r.length===1?t=>t!=null&&t[e]===r[0]:t=>t!=null&&r.includes(t[e]);return e=>e.add(ft(i,n))})(`_tag`),_t=e=>t=>{let n=vt(t);return c(n)?n._tag===`Right`?n.right:e(n.left):t=>{let r=n(t);return r._tag===`Right`?r.right:e(r.left)}},vt=e=>{if(e._tag===`ValueMatcher`)return e.value;let t=e.cases.length;if(t===1){let t=e.cases[0];return e=>t._tag===`When`&&t.guard(e)===!0||t._tag===`Not`&&t.guard(e)===!1?v(t.evaluate(e)):h(e)}return n=>{for(let r=0;r<t;r++){let t=e.cases[r];if(t._tag===`When`&&t.guard(n)===!0||t._tag===`Not`&&t.guard(n)===!1)return v(t.evaluate(n))}return h(n)}},yt=`effect/Match/exhaustive: absurd`,bt=e=>{let t=vt(e);if(c(t)){if(t._tag===`Right`)return t.right;throw Error(yt)}return e=>{let n=t(e);if(n._tag===`Right`)return n.right;throw Error(yt)}},R=mt,z=ht,B=gt,xt=_t,V=bt,St=`PreToolUse.PostToolUse.PostToolUseFailure.PostToolBatch.UserPromptSubmit.UserPromptExpansion.SessionStart.SessionEnd.Stop.StopFailure.PreCompact.PostCompact.PermissionRequest.PermissionDenied.SubagentStart.SubagentStop.MessageDisplay.Notification.Setup.TaskCreated.TaskCompleted.TeammateIdle.InstructionsLoaded.ConfigChange.CwdChanged.FileChanged.WorktreeCreate.WorktreeRemove.Elicitation.ElicitationResult`.split(`.`),Ct=[`PreToolUse`,`PostToolUse`,`PostToolUseFailure`,`UserPromptSubmit`,`SessionStart`,`SessionEnd`,`Stop`,`PreCompact`,`PostCompact`],wt={PermissionRequest:"OMP emits `tool_approval_requested`, but the event exists to allow or deny and OMP ignores the handler return. Express approval policy through OMP native approval configuration instead.",PermissionDenied:"OMP emits `tool_approval_resolved` with `approved: false`, which reports a manual decline by the user — the case Claude Code explicitly excludes, since this event fires only for auto-classifier denials.",SubagentStart:"OMP emits `agent_start`, but its payload carries no agent identity and it fires for the main agent turn loop too, so a bridge would fabricate subagent events that never happened.",SubagentStop:'OMP emits `agent_end` with the same identity gap, so a "subagent stopped" hook would fire on every main-agent turn end.',MessageDisplay:"The event exists to rewrite what Claude Code renders via `displayContent`; OMP `message_update` / `message_end` expose no equivalent control over rendering.",PostToolBatch:`OMP dispatches tool calls individually and exposes no end-of-batch signal.`,UserPromptExpansion:"OMP has no signal for a typed command expanding before it reaches the model; its `input` event fires after expansion would already have happened.",StopFailure:`OMP exposes no signal distinguishing a failed stop from an ordinary one.`,Notification:`Notifications are OMP-side UI; no extension event is emitted when one is raised.`,Setup:`OMP has no first-run setup lifecycle event.`,TaskCreated:`The OMP todo surface emits no per-task creation event to extensions.`,TaskCompleted:`The OMP todo surface emits no per-task completion event to extensions.`,TeammateIdle:`OMP has no teammate concept and emits no idle signal for one.`,InstructionsLoaded:`OMP loads instruction files without emitting an extension event.`,ConfigChange:`OMP does not notify extensions when its configuration changes.`,CwdChanged:`OMP exposes no working-directory change event.`,FileChanged:`OMP has no file-watch surface exposed to extensions.`,WorktreeCreate:`OMP emits no worktree lifecycle events.`,WorktreeRemove:`OMP emits no worktree lifecycle events.`,Elicitation:`MCP elicitation is not surfaced to OMP extensions.`,ElicitationResult:`MCP elicitation is not surfaced to OMP extensions.`},Tt=[`PreToolUse`,`PostToolUse`,`PostToolUseFailure`,`PermissionRequest`,`PermissionDenied`],Et={PreCompact:"OMP `session_before_compact` does not say whether the compaction was manual or automatic, so a `trigger` matcher cannot be evaluated.",PostCompact:"OMP `session_compact` reports only whether an extension requested the compaction, not whether it was manual or automatic, so a `trigger` matcher cannot be evaluated.",SessionEnd:"OMP `session_shutdown` fires on process exit and carries no reason, so a `reason` matcher cannot be evaluated."},Dt={SessionStart:{startup:{_tag:`Reachable`},compact:{_tag:`Reachable`},fork:{_tag:`Reachable`},resume:{_tag:`Partial`,reason:'covers a mid-session resume, which arrives as `session_switch` with `reason: "resume"`. A cold start under `--resume` never emits that signal — it reaches extensions through a bare `session_start` — so it presents as `startup` and a resume-scoped hook does not run there.'},clear:{_tag:`Unreachable`,reason:`OMP emits no signal when a session is cleared.`}}},Ot=j(D({type:We(`command`),command:E,args:w(I(E)),async:w(T),asyncRewake:w(T),shell:w(We(`bash`,`powershell`)),timeout:w(Ue),if:w(E),statusMessage:w(E),once:w(T)}),D({type:We(`http`,`mcp_tool`,`prompt`,`agent`)})),H=D({matcher:w(E),hooks:I(Ot)}),kt=D({PreToolUse:M(I(H),{exact:!0,default:()=>[]}),PostToolUse:M(I(H),{exact:!0,default:()=>[]}),PostToolUseFailure:M(I(H),{exact:!0,default:()=>[]}),UserPromptSubmit:M(I(H),{exact:!0,default:()=>[]}),Stop:M(I(H),{exact:!0,default:()=>[]}),SessionStart:M(I(H),{exact:!0,default:()=>[]}),SessionEnd:M(I(H),{exact:!0,default:()=>[]}),PreCompact:M(I(H),{exact:!0,default:()=>[]}),PostCompact:M(I(H),{exact:!0,default:()=>[]})}),At=D({hooks:kt,disableAllHooks:w(T)}),U=D({event:E,reason:E}),jt=D({unrecognized:I(U),notCarried:I(U),matcherNotEvaluable:I(U),matcherOutOfReach:I(U),shadowed:I(U),disabled:I(U)}),Mt=O(j(At,nt(D({...kt.fields,disableAllHooks:w(T),hooks:w(Le)}),At,{strict:!0,decode:({disableAllHooks:e,...t})=>Xe(e===void 0?{hooks:t}:{hooks:t,disableAllHooks:e}),encode:(e,t,n)=>ct(new ot(n,e,`Decode-only`))}))),Nt=Ct,Pt=N(k({key:E,value:A})),Ft=[],It=N(I(D({matcher:w(E),hooks:M(I(D({type:w(E)})),{exact:!0,default:()=>[]})})));function Lt(e){return l(Pt(e),e=>p(Pt(e.hooks),{onNone:()=>({namespace:e,outer:e,isWrapped:!1}),onSome:t=>({namespace:t,outer:e,isWrapped:!0})}))}const W=e=>e.replaceAll(/[\p{Cc}\p{Cf}]/gu,`�`),Rt={unrecognized:[],notCarried:[],matcherNotEvaluable:[],matcherOutOfReach:[],shadowed:[],disabled:[]},zt=St,Bt=wt,Vt=Et,Ht=Tt,Ut=Dt,Wt=e=>n(It(e),()=>Ft).flatMap(e=>e.matcher===void 0?[]:[e.matcher]),Gt=e=>Wt(e).length>0,Kt=e=>R(e).pipe(B(`Reachable`,()=>b()),B(`Partial`,e=>o(e.reason)),B(`Unreachable`,e=>o(e.reason)),V);function qt(e){return p(Lt(e),{onNone:()=>Rt,onSome:({isWrapped:e,namespace:t,outer:n})=>{let r=[],i=[],a=[],o=[],s=[];for(let n of Object.keys(t)){if(!e&&n===`disableAllHooks`)continue;let s=Bt[n];if(s!==void 0){i.push({event:W(n),reason:s});continue}if(!zt.includes(n)){r.push({event:W(n),reason:`not in this bridge's catalog (Claude Code hooks reference 2026-07-28)`});continue}let c=Vt[n];c!==void 0&&Gt(t[n])&&a.push({event:W(n),reason:c});let l=Ut[n];l!==void 0&&o.push(...Wt(t[n]).flatMap(e=>{let t=l[e];return t===void 0?[]:p(Kt(t),{onNone:()=>[],onSome:t=>[{event:`${W(n)} (matcher "${W(e)}")`,reason:t}]})}))}if(e)for(let e of Object.keys(n))zt.includes(e)&&s.push({event:W(e),reason:"ignored: this file wraps its hooks under `hooks`, so a group repeated at the top level is never read"});return{unrecognized:r,notCarried:i,matcherNotEvaluable:a,matcherOutOfReach:o,shadowed:s,disabled:[]}}})}function Jt(e){let t=e.find(e=>!e.managed&&e.settings.disableAllHooks===!0);if(t===void 0)return[];let n=`switched off by \`disableAllHooks\` in ${W(t.label)}`;return e.filter(e=>!e.managed).flatMap(e=>Nt.filter(t=>e.settings.hooks[t].length>0).map(e=>({event:e,reason:n})))}function Yt(e){return p(Lt(e),{onNone:()=>[],onSome:({namespace:e})=>{let t=new Set;for(let r of Nt){let i=n(It(e[r]),()=>Ft);for(let e of i)for(let n of e.hooks)n.type!==void 0&&n.type!==`command`&&t.add(W(n.type))}return Array.from(t)}})}function Xt(e){let t={PreToolUse:[],PostToolUse:[],PostToolUseFailure:[],UserPromptSubmit:[],SessionStart:[],SessionEnd:[],Stop:[],PreCompact:[],PostCompact:[]};if(e.some(e=>e.managed&&e.settings.disableAllHooks===!0))return{hooks:t};let n=e.some(e=>!e.managed&&e.settings.disableAllHooks===!0);for(let r of e)if(!(n&&!r.managed))for(let e of Nt)t[e]=t[e].concat(Array.from(r.settings.hooks[e]));return{hooks:t}}function Zt(e){return R(e).pipe(B(`Merge`,({sources:e})=>Xt(e)),B(`Coverage`,({json:e})=>qt(e)),B(`DisabledCoverage`,({sources:e})=>Jt(e)),B(`UnsupportedHookTypes`,({json:e})=>Yt(e)),B(`MatcherUnreadable`,({event:e})=>Vt[e]!==void 0),B(`IfEvaluatingEvent`,({event:e})=>Ht.includes(e)),V)}function G(e,t){return qe(t)(Zt(e))}const Qt=`/etc/claude-code/managed-settings.json`,K=(e,t)=>[`${e}/.claude/settings.json`,`${t}/.claude/settings.json`,`${t}/.claude/settings.local.json`,Qt];var $t=class extends g(`CollectSettingsGapsExecutorDeps`)(){};const q=e=>e.filter((t,n)=>e.findIndex(e=>e.event===t.event)===n),en=x(`collectSettingsGapsWithPaths`)(function*(e){let t=yield*tt,n=[],r=[],i=[],a=[],o=[],s=[],c=[],l=[];for(let u of e){let e=yield*t.readFileString(u).pipe(Oe(()=>``));if(e===``)continue;let d=O(lt(k({key:E,value:A})))(e);if(_(d)){l.push(u);continue}let f=G({_tag:`Coverage`,json:d.right},jt);n.push(...f.unrecognized),r.push(...f.notCarried),i.push(...f.matcherNotEvaluable),a.push(...f.matcherOutOfReach),o.push(...f.shadowed),c.push(...G({_tag:`UnsupportedHookTypes`,json:d.right},I(E)));let p=Mt(d.right);_(p)?l.push(u):s.push({settings:p.right,managed:u===Qt,label:u})}return{coverage:{unrecognized:q(n),notCarried:q(r),matcherNotEvaluable:q(i),matcherOutOfReach:q(a),shadowed:q(o),disabled:q(G({_tag:`DisabledCoverage`,sources:s},I(U)))},unsupportedHookTypes:Array.from(new Set(c)),malformedFiles:Array.from(new Set(l))}});var tn=class extends g(`LoadSettingsExecutorDeps`)(){};const nn=x(`loadSettingsFile`)(function*(e){let t=yield*(yield*tt).readFileString(e).pipe(Oe(()=>``));if(t===``)return null;let n=O(lt(k({key:E,value:A})))(t);if(_(n))return null;let r=n.right,i=Mt(r);return _(i)?null:i.right}),J=x(`loadSettingsWithPaths`)(function*(e,t=Qt){let n=[];for(let r of e){let e=yield*nn(r);e!==null&&n.push({settings:e,managed:r===t})}return n.length===0?null:G({_tag:`Merge`,sources:n},At)}),rn=Symbol.for(`@effect/platform/CommandExecutor`),an=Symbol.for(`@effect/platform/Process`),on=Je(),sn=Je(),cn=re(`@effect/platform/CommandExecutor`),ln=e=>{let t=t=>Ie(S(e(t),e=>e.stdout)),n=(e,n)=>{let r=new TextDecoder(n);return Be(Ve(t(e),u(e=>r.decode(e))))};return{[rn]:rn,start:e,exitCode:t=>ke(je(e(t),e=>e.exitCode)),stream:t,string:(t,n=`utf-8`)=>{let r=new TextDecoder(n);return i(e(t),je(e=>Pe(e.stdout,un)),S(e=>r.decode(e)),ke)},lines:(e,t=`utf-8`)=>i(n(e,t),Qe,S(d)),streamLines:n}},un=ze(new Uint8Array,(e,t)=>ie(t,e,(e,t)=>{let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n})),dn=Symbol.for(`@effect/platform/Command`),fn=y(2,(e,n)=>{switch(e._tag){case`StandardCommand`:return Y({...e,env:t(e.env,se(Object.entries(n).filter(([e])=>e!==void 0)))});case`PipedCommand`:return bn(fn(e.left,n),fn(e.right,n))}}),pn=y(2,(e,t)=>Sn(e,Fe(ae(new TextEncoder().encode(t))))),mn=e=>Array.from(hn(e)),hn=e=>{switch(e._tag){case`StandardCommand`:return ae(e);case`PipedCommand`:return ne(hn(e.left),hn(e.right))}},gn={[dn]:dn,pipe(){return ee(this,arguments)},...r},_n={...gn,_tag:`StandardCommand`,toJSON(){return{_id:`@effect/platform/Command`,_tag:this._tag,command:this.command,args:this.args,env:Object.fromEntries(this.env),cwd:this.cwd.toJSON(),shell:this.shell,gid:this.gid.toJSON(),uid:this.uid.toJSON()}}},Y=e=>Object.assign(Object.create(_n),e),vn={...gn,_tag:`PipedCommand`,toJSON(){return{_id:`@effect/platform/Command`,_tag:this._tag,left:this.left.toJSON(),right:this.right.toJSON()}}},X=e=>Object.assign(Object.create(vn),e),yn=(e,...t)=>Y({command:e,args:t,env:ce(),cwd:b(),shell:!1,stdin:`pipe`,stdout:`pipe`,stderr:`pipe`,gid:b(),uid:b()}),bn=y(2,(e,t)=>X({left:e,right:t})),xn=y(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return Y({...e,stderr:t});case`PipedCommand`:return X({...e,right:xn(e.right,t)})}}),Sn=y(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return Y({...e,stdin:t});case`PipedCommand`:return X({...e,left:Sn(e.left,t)})}}),Cn=y(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return Y({...e,stdout:t});case`PipedCommand`:return X({...e,right:Cn(e.right,t)})}}),wn=y(2,(e,t)=>{switch(e._tag){case`StandardCommand`:return Y({...e,cwd:o(t)});case`PipedCommand`:return bn(wn(e.left,t),wn(e.right,t))}}),Tn=fn,En=pn,Dn=mn,On=yn,kn=xn,An=Sn,jn=Cn,Mn=wn,Nn=cn,Pn=an,Fn=on,In=sn,Ln=ln,Rn=(e,t,r)=>fe(e,t).pipe(je(e=>xe(e)),Se(r.deadline),S(e=>n(e,r.onDeadline))),zn={UserPromptSubmit:30},Bn=(e,t)=>(e??zn[t]??600)*1e3,Vn=24e3,Hn=(e,t,n)=>{let r=Bn(e,t);return!n||r<=Vn?{timeoutMs:r,capNote:``}:{timeoutMs:Vn,capNote:` (capped from ${r}ms by the extension handler budget)`}},Un={sh:[`sh`,`-c`],bash:[`bash`,`-c`],powershell:[`powershell`,`-Command`]},Wn=it(lt(k({key:E,value:A})));var Gn=class extends g(`RunHookScriptExecutorDeps`)(){};const Z=x(`runHookScript`)(function*(e,t,n,r,i=!0){let a=yield*Nn,{timeoutMs:o,capNote:s}=Hn(e.timeout,r,i),c=Wn(t),[l,u]=Un[e.shell??`sh`],d=(e.args===void 0?On(l,u,e.command):On(e.command,...e.args)).pipe(Mn(n),Tn({OMP_PROJECT_DIR:n,CLAUDE_PROJECT_DIR:n}),En(c),jn(`pipe`),kn(`pipe`)),f=yield*Gn;return yield*Rn(ke(_e(e=>C(function*(){let t=yield*a.start(d);yield*ve(()=>Ce(t.kill(`SIGKILL`)).pipe(ye(2e3),Te));let[n,r,i]=yield*e(Ee([t.stdout.pipe(He(),$e),t.stderr.pipe(He(),$e),t.exitCode.pipe(S(Number),Oe(()=>-1))],{concurrency:`unbounded`}));return{code:i,stdout:n,stderr:r}}))).pipe(Ae(t=>me(`hook ${e.command} failed`,t))),f,{deadline:o,onDeadline:()=>({code:-1,stdout:``,stderr:`timeout after ${o}ms${s}`})})}),Kn=D({code:Ue,stdout:E,stderr:E});var qn=class extends P()(`Block`,{reason:E}){},Jn=class extends P()(`Allow`,{updatedInput:w(k({key:E,value:A}))}){},Yn=class extends P()(`Warning`,{message:E}){};j(qn,Jn,Yn);var Xn=class extends P()(`Blocked`,{reason:E}){},Zn=class extends P()(`Continue`,{warning:w(E),updatedInput:w(k({key:E,value:A}))}){};j(Xn,Zn);const Qn=D({decision:w(E),reason:w(E),hookSpecificOutput:w(D({permissionDecision:w(E),permissionDecisionReason:w(E),updatedInput:w(k({key:E,value:A})),additionalContext:w(E)}))}),$n=O(nt(E,Qn,{strict:!0,decode:e=>he(Ge(lt(Qn))(e),e=>e.issue),encode:(e,t,n)=>ct(new ot(n,e,`Decode-only: hook stdout is never encoded`))})),er=Symbol.for(`@systemfsoftware/omp-claude-compat/InterpretHookCommand`);var tr=class extends P()(`InterpretHookCommand`,{result:Kn,event:E}){[er]=er};const nr=Symbol.for(`@systemfsoftware/omp-claude-compat/HookVerdictError`);var rr=class extends Re()(`HookVerdictError`,{raw:E}){[nr]=nr};const Q=Symbol.for(`@systemfsoftware/omp-claude-compat/ExitKind`);var ir=class extends P()(`ExitBlock`,{}){[Q]=Q},ar=class extends P()(`ExitDecisionJson`,{}){[Q]=Q},or=class extends P()(`ExitNoDecision`,{}){[Q]=Q},sr=class extends P()(`ExitOther`,{}){[Q]=Q};j(ir,ar,or,sr);const cr=e=>a(e=>e.startsWith(`{`))(e.trim()),lr=e=>R(cr(e)).pipe(B(`Some`,()=>new ar({})),B(`None`,()=>new or({})),V),ur={0:e=>lr(e.stdout),2:()=>new ir({})},dr=e=>R(te(ur[e.code])).pipe(B(`Some`,t=>t.value(e)),B(`None`,()=>new sr({})),V),fr=e=>a(e=>e!==``)(e.trim()),pr=(e,t)=>R(fr(e)).pipe(B(`Some`,e=>e.value),B(`None`,()=>`Blocked by ${t} hook`),V),mr={deny:(e,t)=>e.hookSpecificOutput?.permissionDecisionReason??`Blocked by ${t} hook`,block:(e,t)=>e.reason??`Blocked by ${t} hook`},hr=(e,t)=>R(te(e.hookSpecificOutput?.permissionDecision??e.decision).pipe(oe(e=>mr[e]))).pipe(B(`Some`,n=>new qn({reason:n.value(e,t)})),B(`None`,()=>new Jn({updatedInput:e.hookSpecificOutput?.updatedInput})),V),gr=e=>R(fr(e)).pipe(B(`Some`,e=>new Yn({message:e.value})),B(`None`,()=>new Jn({})),V),_r=t=>R(dr(t.result)).pipe(B(`ExitBlock`,()=>v(new qn({reason:pr(t.result.stderr,t.event)}))),B(`ExitNoDecision`,()=>v(new Jn({}))),B(`ExitDecisionJson`,()=>e($n(t.result.stdout),{onLeft:()=>h(new rr({raw:t.result.stdout})),onRight:e=>v(hr(e,t.event))})),B(`ExitOther`,()=>v(gr(t.result.stderr))),V),vr={},yr=N(k({key:E,value:A})),br=we([]);g(`@systemfsoftware/omp-claude-compat/AsyncHookContextState`)();function xr(e){let t=e.trim();t.length!==0&&le(pe(br,e=>e.length>=64?[...e.slice(1),t]:[...e,t]))}function Sr(){return le(de(br,[]))}var Cr=class extends g(`SuperviseForkExecutorDeps`)(){};const wr=(e,t,n)=>e.pipe(ue({onSuccess:e=>{let t=$n(e.stdout);if(s(t)){let e=t.right.hookSpecificOutput?.additionalContext;e!==void 0&&xr(e)}},onFailure:e=>{Me(e)||t.ui.notify(`Background hook failed: ${n}: ${Ne(e).split(`
|
|
2
|
-
`)[0]}`,`error`)}}));var Tr=class extends g(`RunHooksForEventExecutorDeps`)(){};const Er=x(`runHooksForEventUnbounded`)(function*(t,r,i,a,s){let c=a.cwd,l=n(yr(i.tool_input),()=>vr),u,d=i,p=G({_tag:`MatcherUnreadable`,event:s},T);for(let n of t)if(!(p&&n.matcher!==void 0)&&rt(r,n.matcher))for(let t of n.hooks){if(t.type!==`command`||t.if!==void 0&&(!G({_tag:`IfEvaluatingEvent`,event:s},T)||!st(t.if,r,l,c)))continue;if(t.async===!0||t.asyncRewake===!0){yield*ge(wr(Z(t,d,c,s,!1),a,t.command));continue}let n=e(_r(new tr({result:yield*Z(t,d,c,s),event:s})),{onLeft:e=>R(e).pipe(B(`HookVerdictError`,e=>new Yn({message:`Hook exited 0 but produced invalid JSON: ${e.raw.slice(0,200)}`})),V),onRight:e=>e}),i=R(n).pipe(B(`Block`,e=>new Xn({reason:e.reason})),B(`Warning`,e=>new Zn({warning:e.message})),B(`Allow`,e=>new Zn({updatedInput:e.updatedInput})),V),p=R(i).pipe(B(`Blocked`,e=>o({block:!0,reason:e.reason})),B(`Continue`,e=>(e.warning!==void 0&&u===void 0&&(u=e.warning),e.updatedInput!==void 0&&(d={...d,...e.updatedInput}),b())),V);if(f(p))return p.value}return{...d===i?{}:{updatedInput:d},...u===void 0?{}:{warning:u}}}),$=x(`runHooksForEvent`)(function*(e,t,n,r,i){return yield*Er(e,t,n,r,i).pipe(ye(26e3),be(`TimeoutException`,()=>De({})))});var Dr=class extends g(`RunLifecycleHooksExecutorDeps`)(){};const Or=x(`runLifecycleHooks`)(function*(e,t,n){if(e.length===0)return;let r=t.cwd,i={...F(()=>t.sessionManager.getSessionId())},a=G({_tag:`MatcherUnreadable`,event:n},T);for(let o of e)if(!(a&&o.matcher!==void 0))for(let e of o.hooks)e.type===`command`&&e.if===void 0&&(e.async===!0||e.asyncRewake===!0?yield*ge(wr(Z(e,i,r,n,!1),t,e.command)):yield*Z(e,i,r,n))});var kr=class extends g(`RunPostToolUseFailureHooksExecutorDeps`)(){};const Ar=N(I(D({text:w(E)}))),jr=N(E),Mr=e=>p(Ar(e),{onSome:e=>e.flatMap(e=>e.text===void 0?[]:[e.text]).join(`
|
|
3
|
-
`),onNone:()=>n(jr(e),()=>``)}),Nr=x(`runPostToolUseFailureHooks`)(function*(e,t,r){let i=et(t.toolName),a=Ye(i,n(yr(t.input),()=>vr)),o={...F(()=>r.sessionManager.getSessionId()),tool_name:i,tool_input:a,tool_use_id:t.toolCallId,error:Mr(t.content)},s=yield*$(e.hooks.PostToolUseFailure,i,o,r,`PostToolUseFailure`);return s.block===!0?s.reason===void 0?{}:{warning:s.reason}:s});var Pr=class extends g(`RunPostToolUseHooksExecutorDeps`)(){};const Fr=x(`runPostToolUseHooks`)(function*(e,t,r){let i=et(t.toolName),a=F(()=>r.sessionManager.getSessionId()),o=Ye(i,n(yr(t.input),()=>vr)),s=Ze(i,o),c=s.length===0?[o]:s.map(e=>({...o,file_path:e})),l,u={};for(let n of c){let o={...a,tool_name:i,tool_input:n,tool_call_id:t.toolCallId,output:t.content,is_error:t.isError??!1},s=yield*$(e.hooks.PostToolUse,i,o,r,`PostToolUse`);if(s.block===!0)return s;l===void 0&&(l=s.warning),u=s}return l===void 0?u:{...u,warning:l}});var Ir=class extends g(`RunPreCompactHooksExecutorDeps`)(){};const Lr=x(`runPreCompactHooks`)(function*(e,t){let n={...F(()=>t.sessionManager.getSessionId())};return yield*$(e.hooks.PreCompact,``,n,t,`PreCompact`)});var Rr=class extends g(`RunPreToolUseHooksExecutorDeps`)(){};const zr=x(`runPreToolUseHooks`)(function*(e,t,r){let i=et(t.toolName),a=F(()=>r.sessionManager.getSessionId()),o=n(yr(t.input),()=>vr),s=Ye(i,o),c=Ke(t.toolName,o);if(c!==void 0&&c.length>0){let n={...a,tool_name:`Bash`,tool_input:{command:c},tool_call_id:t.toolCallId},i=yield*$(e.hooks.PreToolUse,`Bash`,n,r,`PreToolUse`);if(i.block===!0)return i.reason===void 0?{block:!0}:{block:!0,reason:i.reason}}let l=Ze(i,s),u=l.length===0?[s]:l.map(e=>({...s,file_path:e})),d={};for(let n of u){let o={...a,tool_name:i,tool_input:n,tool_call_id:t.toolCallId},s=yield*$(e.hooks.PreToolUse,i,o,r,`PreToolUse`);if(s.block===!0)return s.reason===void 0?{block:!0}:{block:!0,reason:s.reason};d=s}let f=u.length===1?d.updatedInput?.tool_input:void 0;Object.assign(t.input,at(o,f))});var Br=class extends g(`RunSessionStartHooksExecutorDeps`)(){};const Vr=x(`runSessionStartHooks`)(function*(e,t,n){let r=e.hooks.SessionStart;if(r.length===0)return;let i=n.cwd,a={...F(()=>n.sessionManager.getSessionId()),reason:t};for(let e of r)if(!(e.matcher!==void 0&&!rt(t,e.matcher))){for(let t of e.hooks)if(t.type===`command`&&t.if===void 0){if(t.async===!0||t.asyncRewake===!0){yield*ge(wr(Z(t,a,i,`SessionStart`,!1),n,t.command));continue}yield*Z(t,a,i,`SessionStart`)}}});var Hr=class extends g(`RunSessionSwitchHooksExecutorDeps`)(){};const Ur=x(`runSessionSwitchHooks`)(function*(e,t,n){(t===`resume`||t===`fork`)&&(yield*Vr(e,t,n))});var Wr=class extends g(`RunToolResultHooksExecutorDeps`)(){};const Gr=x(`runToolResultHooks`)(function*(e,t,n){return t.isError===!0?yield*Nr(e,t,n):yield*Fr(e,t,n)}),Kr=[`/`,`!`,`->`,`=>`,`$ `,`$ `,`$
|
|
4
|
-
`,`$\r`,`$$ `,`$$ `,`$$
|
|
5
|
-
`,`$$\r`],qr=e=>Kr.some(t=>`${e.trimStart()} `.startsWith(t));var Jr=class extends g(`RunUserPromptSubmitHooksExecutorDeps`)(){};const Yr=x(`runUserPromptSubmitHooks`)(function*(t,n,r){let i=t.hooks.UserPromptSubmit,a=r.cwd,o=qr(n.text),s=R(o).pipe(z(!0,()=>[]),z(!1,()=>Sr()),V),c=[],l={...F(()=>r.sessionManager.getSessionId()),prompt:n.text,source:n.source};for(let t of i)for(let n of t.hooks){if(n.type!==`command`||n.if!==void 0)continue;let t=yield*Z(n,l,a,`UserPromptSubmit`),i=e(_r(new tr({result:t,event:`UserPromptSubmit`})),{onLeft:()=>void 0,onRight:e=>R(e).pipe(B(`Block`,e=>e.reason),xt(()=>void 0))});if(i!==void 0)return r.ui.notify(`Prompt blocked by UserPromptSubmit hook: ${i}`,`error`),{handled:!0};if(t.code!==0)continue;let o=t.stdout.trim();o.length>0&&c.push(o)}return R(o).pipe(z(!0,()=>void 0),z(!1,()=>{let e=[...s,...c].join(`
|
|
6
|
-
|
|
7
|
-
`);if(e.length===0)return;let t={text:`${e}\n\n${n.text}`};return n.images!==void 0&&(t.images=n.images),t}),V)});var Xr=class extends g(`HookDispatcherExecutorDeps`)(){};const Zr=e=>C(function*(){return yield*R(e).pipe(B(`ToolCall`,({event:e,ctx:t})=>C(function*(){let n=yield*J(K(L(),t.cwd));if(n)return yield*zr(n,e,t)})),B(`ToolResult`,({event:e,ctx:t})=>C(function*(){let n=yield*J(K(L(),t.cwd));if(!n)return;let r=yield*Gr(n,e,t);if(r.block===!0)return{isError:!0,content:[{type:`text`,text:r.reason??`Blocked by PostToolUse hook`}]};if(r.warning!==void 0)return{content:[...e.content,{type:`text`,text:r.warning}],isError:e.isError}})),B(`Prompt`,({event:e,ctx:t})=>C(function*(){let n=yield*J(K(L(),t.cwd));if(n)return yield*Yr(n,e,t)})),B(`SessionStart`,({reason:e,ctx:t})=>C(function*(){let n=yield*en(K(L(),t.cwd)),r=[...n.coverage.unrecognized.map(e=>` ${e.event}: ${e.reason}`),...n.coverage.notCarried.map(e=>` ${e.event}: not carried by this bridge — ${e.reason}`),...n.coverage.matcherNotEvaluable.map(e=>` ${e.event}: hook skipped, matcher not evaluable — ${e.reason}`),...n.coverage.matcherOutOfReach.map(e=>` ${e.event}: ${e.reason}`),...n.coverage.shadowed.map(e=>` ${e.event}: ${e.reason}`),...n.coverage.disabled.map(e=>` ${e.event}: ${e.reason}`)];r.length>0&&t.ui.notify(`Hook coverage — configured hooks this bridge will not run:\n${r.join(`
|
|
8
|
-
`)}`,`warning`),n.unsupportedHookTypes.length>0&&t.ui.notify(`Skipping hook(s) this bridge cannot run yet: type ${n.unsupportedHookTypes.join(`, `)}`,`warning`),n.malformedFiles.length>0&&t.ui.notify(`Hooks are NOT running from malformed settings file(s): ${n.malformedFiles.join(`, `)}`,`error`);let i=yield*J(K(L(),t.cwd));i&&(yield*Vr(i,e,t))})),B(`SessionCompact`,({ctx:e})=>C(function*(){let t=yield*J(K(L(),e.cwd));t&&(yield*Vr(t,`compact`,e),yield*Or(t.hooks.PostCompact,e,`PostCompact`))})),B(`PreCompact`,({ctx:e})=>C(function*(){let t=yield*J(K(L(),e.cwd));if(!t)return;let n=yield*Lr(t,e);if(n.block===!0)return e.ui.notify(`Compaction cancelled by a PreCompact hook: ${n.reason??`no reason given`}`,`warning`),{cancel:!0}})),B(`SessionSwitch`,({reason:e,ctx:t})=>C(function*(){let n=yield*J(K(L(),t.cwd));n&&(yield*Ur(n,e,t))})),B(`SessionShutdown`,({ctx:e})=>C(function*(){let t=yield*J(K(L(),e.cwd));t&&(yield*Or(t.hooks.SessionEnd,e,`SessionEnd`))})),B(`SessionStop`,({ctx:e})=>C(function*(){let t=yield*J(K(L(),e.cwd));t&&(yield*Or(t.hooks.Stop,e,`Stop`))})),V)});export{$t as C,tn as S,In as _,Hr as a,Dn as b,Ir as c,Dr as d,Tr as f,Fn as g,Nn as h,Wr as i,Pr as l,Gn as m,Zr as n,Br as o,Cr as p,Jr as r,Rr as s,Xr as t,kr as u,Pn as v,An as x,Ln as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Cs as e,Ds as t,Ec as n,El as r,Er as i,Hs as a,Io as o,Kt as s,Lr as c,Rs as l,Sl as u,Tc as d,Tl as ee,Ts as f,Ui as te,mr as ne,mt as re,vn as ie,wr as ae,yn as oe,zs as se}from"./core-C1FEy4nD.js";import{$t as ce,Bt as le,Fn as ue,G as p,H as de,Ht as m,I as h,It as g,Jt as fe,K as pe,Lt as me,O as he,Qt as ge,Rt as _e,St as ve,T as ye,Tn as be,U as xe,Xt as Se,Yt as Ce,Zt as we,_n as Te,an as Ee,at as De,c as Oe,ct as _,en as ke,g as Ae,gn as je,ht as Me,in as Ne,k as Pe,l as v,lt as Fe,mt as Ie,n as y,nn as Le,on as Re,ot as b,p as ze,pn as Be,r as x,rn as Ve,rt as He,sn as Ue,st as S,tn as C,tt as w,v as T,vt as We,wt as E,x as D,xn as Ge,yt as Ke,zt as O}from"./Effect-fMAnbW-8.js";import{i as qe,p as Je}from"./Exit-BhYZ1Mg3.js";import{A as Ye,C as k,E as Xe,F as A,I as Ze,N as Qe,P as $e,R as et,S as tt,_ as nt,_t as rt,b as it,d as at,dt as j,f as ot,ft as st,g as M,gt as N,h as P,ht as ct,lt,m as F,mt as ut,n as dt,p as ft,pt,t as mt,ut as ht,v as gt,vt as I,w as _t,x as vt,y as yt,yt as L}from"./dist-opjiVExE.js";import{C as bt,S as xt,_ as St,a as Ct,b as R,c as wt,d as Tt,f as Et,g as Dt,h as Ot,i as kt,l as At,m as jt,o as Mt,p as Nt,r as Pt,s as Ft,t as It,u as Lt,v as z,x as B,y as Rt}from"./hook-dispatcher.executor-VKMzdbhh.js";import{t as zt}from"./inject-instructions.executor-RzZpGK-N.js";import*as Bt from"node:os";import*as Vt from"node:crypto";import*as V from"node:path";import*as H from"node:fs";import*as U from"node:child_process";function W(e,t){return ie(e.runtimeEffect,e=>c(n=>(n.setFiberRefs(e.fiberRefs),n.currentRuntimeFlags=e.runtimeFlags,ne(t,e.context))))}const Ht={...ue,[Be]:Be,pipe(){return d(this,arguments)},commit(){return this.runtimeEffect}},Ut=(e,t)=>{t??=Ce();let n=Ee(Ge()),r,a=ae(()=>{if(!r){let a=new be;r=ge(i(Te(fe(e,t),n),e=>{o.cachedRuntime=e}),{scope:n,scheduler:a}),a.flush()}return oe(r.await)}),o=Object.assign(Object.create(Ht),{memoMap:t,scope:n,runtimeEffect:a,cachedRuntime:void 0,runtime(){return o.cachedRuntime===void 0?C(o.runtimeEffect):Promise.resolve(o.cachedRuntime)},dispose(){return C(o.disposeEffect)},disposeEffect:ae(()=>(o.runtimeEffect=re(`ManagedRuntime disposed`),o.cachedRuntime=void 0,je(o.scope,s))),runFork(e,t){return o.cachedRuntime===void 0?ge(W(o,e),t):we(o.cachedRuntime)(e,t)},runSyncExit(e){return o.cachedRuntime===void 0?Ue(W(o,e)):Re(o.cachedRuntime)(e)},runSync(e){return o.cachedRuntime===void 0?Ee(W(o,e)):Ne(o.cachedRuntime)(e)},runPromiseExit(e,t){return o.cachedRuntime===void 0?Ve(W(o,e),t):Le(o.cachedRuntime)(e,t)},runCallback(e,t){return o.cachedRuntime===void 0?ce(Se)(W(o,e),t):ce(o.cachedRuntime)(e,t)},runPromise(e,t){return o.cachedRuntime===void 0?C(W(o,e),t):ke(o.cachedRuntime)(e,t)}});return o},G=(e,t,n)=>(...r)=>v(i=>{try{e(...r,(e,n)=>{i(e?T(t?t(e,r):e):b(n))})}catch(e){i(n?T(n(e,r)):ze(e))}}),Wt=(e,t,n)=>Xe(Gt(e,t,n)),Gt=(e,t,n)=>pt(()=>Jt(e(),t,te(void 0),n)),Kt=(e,t,{encoding:n,endOnDone:r=!0}={},i=y)=>{let a=qt(e,n),o=r?v(t=>{`closed`in e&&e.closed?t(y):(e.once(`finish`,()=>t(y)),e.end())}):y;return{awaitRead:()=>y,emit:a,error:e=>E(o,t(e)),done:e=>E(o,i)}},qt=(e,t)=>n=>n.length===0?y:v(r=>{let i=n[Symbol.iterator](),a=i.next();function o(){let n=a;a=i.next();let s=e.write(n.value,t);a.done?r(y):s?o():e.once(`drain`,o)}o()}),Jt=(e,t,n,r)=>{if(!e.readable)return ut;let i=We(!1);function a(){i.unsafeOpen()}function s(e){n.current=qe(t(e)),i.unsafeOpen()}function c(){n.current=Je,i.unsafeOpen()}e.on(`readable`,a),e.on(`error`,s),e.on(`end`,c);let l=r?.chunkSize?Number(r.chunkSize):void 0;return ht(pt(function t(){let r=e.read(l);if(r===null)return n.current?st(n.current):(i.unsafeClose(),j(i.await,t));let a=[r];for(;;){if(r=e.read(l),r===null)return j(ct(o(a)),t);a.push(r)}}),_(()=>{e.off(`readable`,a),e.off(`error`,s),e.off(`end`,c),r?.closeOnDone!==!1&&`closed`in e&&!e.closed&&e.destroy()}))},Yt=(e,t,n)=>et(Xt(e,t,n)),Xt=(e,t,n)=>j(ve(_(()=>e()),le()),([e,r])=>lt(Zt(e,r,t),Kt(e,e=>_e(r,e),n,me(r,y)))),Zt=(e,t,n)=>S(()=>{function r(e){m(t,T(n(e)))}return e.on(`error`,r),Ae(g(t),_(()=>{e.removeListener(`error`,r)}))}),K=(e,t)=>(n,[r])=>{let i=`Unknown`;switch(n.code){case`ENOENT`:i=`NotFound`;break;case`EACCES`:i=`PermissionDenied`;break;case`EEXIST`:i=`AlreadyExists`;break;case`EISDIR`:i=`BadResource`;break;case`ENOTDIR`:i=`BadResource`;break;case`EBUSY`:i=`Busy`;break;case`ELOOP`:i=`BadResource`;break}return new k({reason:i,module:e,method:t,pathOrDescriptor:r,syscall:n.syscall,description:n.message,cause:n})},Qt=e=>typeof e==`string`?e:`pipe`,$t=e=>typeof e==`string`?e:`pipe`,q=e=>e instanceof globalThis.Error?e:new globalThis.Error(String(e)),J=(e,t,n)=>{let r=R(n).reduce((e,t)=>{let n=`${t.command} ${t.args.join(` `)}`;return e.length===0?n:`${e} | ${n}`},``);return K(`Command`,e)(t,[r])},en={[z]:z,...n,toJSON(){return{_id:`@effect/platform/CommandExecutor/Process`,pid:this.pid}}},Y=e=>n=>{switch(n._tag){case`StandardCommand`:{let i=D(le(),e=>v(r=>{let i=U.spawn(n.command,n.args,{stdio:[Qt(n.stdin),$t(n.stdout),$t(n.stderr)],cwd:t(n.cwd,u),shell:n.shell,env:{...process.env,...Object.fromEntries(n.env)},detached:process.platform!==`win32`});return i.on(`error`,e=>{r(T(J(`spawn`,e,n)))}),i.on(`exit`,(...t)=>{m(e,b(t))}),i.on(`spawn`,()=>{r(b([i,e]))}),_(()=>{i.kill(`SIGTERM`)})})),a=process.platform===`win32`?(e,t)=>v(t=>{U.exec(`taskkill /pid ${e.pid} /T /F`,e=>{t(e?T(J(`kill`,q(e),n)):y)})}):(e,t)=>Me({try:()=>process.kill(-e.pid,t),catch:e=>J(`kill`,q(e),n)}),o=(e,t)=>S(()=>e.kill(t)?y:T(J(`kill`,new globalThis.Error(`Failed to kill process`),n)));return r(l(n.cwd,{onNone:()=>y,onSome:t=>e.access(t)}),E(x(i,([e,t])=>D(O(t),n=>n?D(g(t),([t])=>t!==0&&t!==null?a(e,`SIGTERM`).pipe(Pe):y):a(e,`SIGTERM`).pipe(pe(()=>o(e,`SIGTERM`)),E(g(t)),Pe)))),h(([e,t])=>{let r=Ze;e.stdin!==null&&(r=Yt(()=>e.stdin,e=>J(`toWritable`,q(e),n)));let i=D(g(t),([e,t])=>e===null?T(J(`exitCode`,new globalThis.Error(`Process interrupted due to receipt of signal: ${t}`),n)):b(Dt(e))),s=xe(O(t)),c=(n=`SIGTERM`)=>a(e,n).pipe(pe(()=>o(e,n)),E(Oe(g(t)))),l=St(e.pid),u=Wt(()=>e.stderr,e=>J(`fromReadable(stderr)`,q(e),n)),d=Wt(()=>e.stdout,e=>J(`fromReadable(stdout)`,q(e),n));return typeof n.stdout!=`string`&&(d=Qe(d,n.stdout)),Object.assign(Object.create(en),{pid:l,exitCode:i,isRunning:s,kill:c,stdin:r,stderr:u,stdout:d})}),typeof n.stdin==`string`?ee:Fe(e=>ye(Ye(n.stdin,e.stdin))))}case`PipedCommand`:{let t=R(n);if(t.length===1)return r(t[0],Y(e));let i=t[0],a=t.slice(1),o=a.slice(0,a.length-1),s=a[a.length-1];return r(B(s,o.reduce((t,n)=>r(B(n,t),Y(e),h(e=>e.stdout),A),r(Y(e)(i),h(e=>e.stdout),A))),Y(e))}}},tn=N(Ot,r(F,h(e=>Rt(Y(e))))),X=e=>t=>new tt({module:`FileSystem`,method:e,cause:t}),nn=(()=>{let e=G(H.access,K(`FileSystem`,`access`),X(`access`));return(t,n)=>{let r=H.constants.F_OK;return n?.readable&&(r|=H.constants.R_OK),n?.writable&&(r|=H.constants.W_OK),e(t,r)}})(),rn=(()=>{let e=G(H.cp,K(`FileSystem`,`copy`),X(`copy`));return(t,n,r)=>e(t,n,{force:r?.overwrite??!1,preserveTimestamps:r?.preserveTimestamps??!1,recursive:!0})})(),an=(()=>{let e=G(H.copyFile,K(`FileSystem`,`copyFile`),X(`copyFile`));return(t,n)=>e(t,n)})(),on=(()=>{let e=G(H.chmod,K(`FileSystem`,`chmod`),X(`chmod`));return(t,n)=>e(t,n)})(),sn=(()=>{let e=G(H.chown,K(`FileSystem`,`chown`),X(`chown`));return(t,n,r)=>e(t,n,r)})(),cn=(()=>{let e=G(H.link,K(`FileSystem`,`link`),X(`link`));return(t,n)=>e(t,n)})(),ln=(()=>{let e=G(H.mkdir,K(`FileSystem`,`makeDirectory`),X(`makeDirectory`));return(t,n)=>e(t,{recursive:n?.recursive??!1,mode:n?.mode})})(),Z=e=>{let t=G(H.mkdtemp,K(`FileSystem`,e),X(e));return e=>S(()=>{let n=e?.prefix??``,r=typeof e?.directory==`string`?V.join(e.directory,`.`):Bt.tmpdir();return t(n?V.join(r,n):r+`/`)})},un=Z(`makeTempDirectory`),Q=e=>{let t=G(H.rm,K(`FileSystem`,e),X(e));return(e,n)=>t(e,{recursive:n?.recursive??!1,force:n?.force??!1})},dn=Q(`remove`),fn=(()=>{let e=Z(`makeTempDirectoryScoped`),t=Q(`makeTempDirectoryScoped`);return n=>x(e(n),e=>p(t(e,{recursive:!0})))})(),pn=e=>{let t=G(H.open,K(`FileSystem`,e),X(e)),n=G(H.close,K(`FileSystem`,e),X(e));return(e,i)=>r(x(t(e,i?.flag??`r`,i?.mode),e=>p(n(e))),h(e=>hn(ft(e),i?.flag?.startsWith(`a`)??!1)))},mn=pn(`open`),hn=(()=>{let e=e=>G(H.read,K(`FileSystem`,e),X(e)),t=e(`read`),n=e(`readAlloc`),r=G(H.fstat,K(`FileSystem`,`stat`),X(`stat`)),i=G(H.ftruncate,K(`FileSystem`,`truncate`),X(`truncate`)),o=G(H.fsync,K(`FileSystem`,`sync`),X(`sync`)),s=e=>G(H.write,K(`FileSystem`,e),X(e)),c=s(`write`),l=s(`writeAll`);class u{fd;append;[P];semaphore=Ke(1);position=0n;constructor(e,t){this.fd=e,this.append=t,this[P]=P}get stat(){return h(r(this.fd),wn)}get sync(){return o(this.fd)}seek(e,t){let n=M(e);return this.semaphore.withPermits(1)(_(()=>(t===`start`?this.position=n:t===`current`&&(this.position+=n),this.position)))}read(e){return this.semaphore.withPermits(1)(h(S(()=>t(this.fd,{buffer:e,position:this.position})),e=>{let t=M(e);return this.position+=t,t}))}readAlloc(e){let t=Number(e);return this.semaphore.withPermits(1)(D(_(()=>Buffer.allocUnsafeSlow(t)),e=>h(n(this.fd,{buffer:e,position:this.position}),n=>{if(n===0)return se();if(this.position+=BigInt(n),n===t)return a(e);let r=Buffer.allocUnsafeSlow(n);return e.copy(r,0,0,n),a(r)})))}truncate(e){return this.semaphore.withPermits(1)(h(i(this.fd,e?Number(e):void 0),()=>{if(!this.append){let t=BigInt(e??0);this.position>t&&(this.position=t)}}))}write(e){return this.semaphore.withPermits(1)(h(S(()=>c(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),e=>{let t=M(e);return this.append||(this.position+=t),t}))}writeAllChunk(e){return D(S(()=>l(this.fd,e,void 0,void 0,this.append?void 0:Number(this.position))),t=>t===0?T(new k({module:`FileSystem`,method:`writeAll`,reason:`WriteZero`,pathOrDescriptor:this.fd,description:`write returned 0 bytes written`})):(this.append||(this.position+=BigInt(t)),t<e.length?this.writeAllChunk(e.subarray(t)):y))}writeAll(e){return this.semaphore.withPermits(1)(this.writeAllChunk(e))}}return(e,t)=>new u(e,t)})(),gn=e=>{let t=Z(e),n=pn(e),i=e=>_(()=>Vt.randomBytes(e).toString(`hex`));return e=>r(ve(t(e),i(6)),h(([t,n])=>V.join(t,n+(e?.suffix??``))),Fe(e=>He(n(e,{flag:`w+`}))))},_n=gn(`makeTempFile`),vn=(()=>{let e=gn(`makeTempFileScoped`),t=Q(`makeTempFileScoped`);return n=>x(e(n),e=>p(t(V.dirname(e),{recursive:!0})))})(),yn=(e,t)=>Ie({try:()=>H.promises.readdir(e,t),catch:t=>K(`FileSystem`,`readDirectory`)(t,[e])}),bn=e=>v((t,n)=>{try{H.readFile(e,{signal:n},(n,r)=>{t(n?T(K(`FileSystem`,`readFile`)(n,[e])):b(r))})}catch(e){t(T(X(`readFile`)(e)))}}),xn=(()=>{let e=G(H.readlink,K(`FileSystem`,`readLink`),X(`readLink`));return t=>e(t)})(),Sn=(()=>{let e=G(H.realpath,K(`FileSystem`,`realPath`),X(`realPath`));return t=>e(t)})(),Cn=(()=>{let e=G(H.rename,K(`FileSystem`,`rename`),X(`rename`));return(t,n)=>e(t,n)})(),wn=e=>({type:e.isFile()?`File`:e.isDirectory()?`Directory`:e.isSymbolicLink()?`SymbolicLink`:e.isBlockDevice()?`BlockDevice`:e.isCharacterDevice()?`CharacterDevice`:e.isFIFO()?`FIFO`:e.isSocket()?`Socket`:`Unknown`,mtime:f(e.mtime),atime:f(e.atime),birthtime:f(e.birthtime),dev:e.dev,rdev:f(e.rdev),ino:f(e.ino),mode:e.mode,nlink:f(e.nlink),uid:f(e.uid),gid:f(e.gid),size:M(e.size),blksize:f(M(e.blksize)),blocks:f(e.blocks)}),$=(()=>{let e=G(H.stat,K(`FileSystem`,`stat`),X(`stat`));return t=>h(e(t),wn)})(),Tn=(()=>{let e=G(H.symlink,K(`FileSystem`,`symlink`),X(`symlink`));return(t,n)=>e(t,n)})(),En=(()=>{let e=G(H.truncate,K(`FileSystem`,`truncate`),X(`truncate`));return(t,n)=>e(t,n===void 0?void 0:Number(n))})(),Dn=(()=>{let e=G(H.utimes,K(`FileSystem`,`utime`),X(`utime`));return(t,n,r)=>e(t,n,r)})(),On=(e,t)=>_t(n=>x(_(()=>{let r=H.watch(e,{recursive:t?.recursive},(e,t)=>{if(t)switch(e){case`rename`:n.fromEffect(de($(t),{onSuccess:e=>b(gt({path:t})),onFailure:e=>e._tag===`SystemError`&&e.reason===`NotFound`?b(yt({path:t})):T(e)}));return;case`change`:n.single(it({path:t}));return}});return r.on(`error`,t=>{n.fail(new k({module:`FileSystem`,reason:`Unknown`,method:`watch`,pathOrDescriptor:e,cause:t}))}),r.on(`close`,()=>{n.end()}),r}),e=>_(()=>e.close()))),kn=(n,r,i)=>$(r).pipe(h(a=>n.pipe(e(e=>e.register(r,a,i)),t(()=>On(r,i)))),$e),An=(e,t,n)=>v((r,i)=>{try{H.writeFile(e,t,{signal:i,flag:n?.flag,mode:n?.mode},t=>{r(t?T(K(`FileSystem`,`writeFile`)(t,[e])):y)})}catch(e){r(T(X(`writeFile`)(e)))}}),jn=N(F,h(De(nt),e=>vt({access:nn,chmod:on,chown:sn,copy:rn,copyFile:an,link:cn,makeDirectory:ln,makeTempDirectory:un,makeTempDirectoryScoped:fn,makeTempFile:_n,makeTempFileScoped:vn,open:mn,readDirectory:yn,readFile:bn,readLink:xn,realPath:Sn,remove:dn,rename:Cn,stat:$,symlink:Tn,truncate:En,utimes:Dn,watch(t,n){return kn(e,t,n)},writeFile:An}))),Mn=tn,Nn=rt(L(It,w),L(xt,w),L(bt,w),L(jt,w),L(Et,w),L(Ft,w),L(At,w),L(Lt,w),L(kt,w),L(wt,w),L(Pt,w),L(Mt,w),L(Ct,w),L(Tt,w),L(Nt,w)),Pn=N(zt,he(function*(){return{fileSystem:yield*F,path:yield*at,tomlLoader:yield*mt}})),Fn=Mn.pipe(I(jn),I(ot)),In=Ut(Nn.pipe(I(Pn),I(dt),I(Fn)));export{Nn as HookScopeLive,Pn as InjectInstructionsDepsLive,In as default};
|