@systemfsoftware/omp-claude-compat 1.1.4 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CommandExecutor-DYErWuMr.js +1 -0
- package/dist/dist-DO_QG0qW.js +18 -0
- package/dist/esm-DBTIrgAu.js +55 -0
- package/dist/hook-dispatcher.executor-B6Jon79H.js +3 -0
- package/dist/index.js +1 -1493
- package/dist/inject-instructions.executor-C0s4_7XL.js +3 -0
- package/dist/runtime-CMq7fttJ.js +1 -0
- package/package.json +17 -11
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{A as e,An as t,B as n,C as r,D as i,Dn as a,E as o,En as s,F as c,H as l,I as u,Mn as d,Mt as f,N as p,Nn as m,O as ee,On as h,P as g,Pt as _,S as te,St as v,T as y,U as b,V as x,b as S,bt as C,jn as w,k as T,kn as ne,mt as re,pt as ie,r as E,s as D,w as O,wn as k,xt as A,y as j,z as M,zt as ae}from"./esm-DBTIrgAu.js";import{f as oe,l as se,o as ce,p as le,s as ue,t as de,u as fe}from"./CommandExecutor-DYErWuMr.js";import{a as N,d as pe,i as P,o as F,r as I,s as L}from"./dist-DO_QG0qW.js";import{homedir as R}from"node:os";o({code:r,stdout:y,stderr:y});var z=class extends i()(`Block`,{reason:y}){},B=class extends i()(`Allow`,{}){},V=class extends i()(`Warning`,{message:y}){};T(z,B,V);var H=class extends i()(`Blocked`,{reason:y}){},U=class extends i()(`Continue`,{warning:g(y),updatedInput:g(O({key:y,value:e}))}){};T(H,U);const W=p(u(o({decision:g(y),reason:g(y),hookSpecificOutput:g(o({permissionDecision:g(y),permissionDecisionReason:g(y),updatedInput:g(O({key:y,value:e}))}))}))),me=o({type:te(`command`),command:y,async:g(S),timeout:g(r)}),G=o({matcher:g(y),hooks:j(me)}),K=o({PreToolUse:c(j(G),{exact:!0,default:()=>[]}),PostToolUse:c(j(G),{exact:!0,default:()=>[]}),UserPromptSubmit:c(j(G),{exact:!0,default:()=>[]}),Stop:c(j(G),{exact:!0,default:()=>[]}),SessionStart:c(j(G),{exact:!0,default:()=>[]}),SessionEnd:c(j(G),{exact:!0,default:()=>[]})}),he=p(T(o({hooks:K,disableAllHooks:g(S)}),o({...K.fields,disableAllHooks:g(S)})));function ge(e){return w(he(e),e=>{if(`hooks`in e)return e;let{disableAllHooks:t,...n}=e;return{hooks:n,disableAllHooks:t}})}const _e=[`PreToolUse`,`PostToolUse`,`UserPromptSubmit`,`SessionStart`,`SessionEnd`,`Stop`];function ve(e){let t={hooks:{PreToolUse:[],PostToolUse:[],UserPromptSubmit:[],SessionStart:[],SessionEnd:[],Stop:[]}};for(let n of e){for(let e of _e)t.hooks[e]=(t.hooks[e]??[]).concat(Array.from(n.hooks[e]));n.disableAllHooks!==void 0&&(t.disableAllHooks=n.disableAllHooks)}return t}function q(e){return e.disableAllHooks===!0}var ye=class extends ee()(`HookVerdictError`,{raw:y}){},J=class extends i()(`ExitBlock`,{}){},Y=class extends i()(`ExitParse`,{}){},X=class extends i()(`ExitOther`,{}){};T(J,Y,X);const be=e=>l(e).pipe(b(2,()=>new J({})),b(0,()=>new Y({})),n(()=>new X({}))),xe=(e,t)=>l(e.trim()).pipe(b(``,()=>`Blocked by ${t} hook`),n(e=>e)),Se=(e,t)=>l(e.hookSpecificOutput?.permissionDecision??e.decision).pipe(b(`deny`,()=>new z({reason:e.hookSpecificOutput?.permissionDecisionReason??`Blocked by ${t} hook`})),b(`block`,()=>new z({reason:e.reason??`Blocked by ${t} hook`})),n(()=>new B({}))),Ce=e=>l(e.trim()).pipe(b(``,()=>new B({})),n(e=>new V({message:e}))),we=(e,n)=>l(be(e.code)).pipe(x(`ExitBlock`,()=>m(new z({reason:xe(e.stderr,n)}))),x(`ExitParse`,()=>d(W(e.stdout),{onLeft:()=>t(new ye({raw:e.stdout})),onRight:e=>m(Se(e,n))})),x(`ExitOther`,()=>m(Ce(e.stderr))),M);function Te(e,t){let n=e.replace(/"\$OMP_PROJECT_DIR"|'\$OMP_PROJECT_DIR'/g,JSON.stringify(t)).replace(/"\$\{OMP_PROJECT_DIR\}"|'\$\{OMP_PROJECT_DIR\}'/g,JSON.stringify(t)).replace(/"\$CLAUDE_PROJECT_DIR"|'\$CLAUDE_PROJECT_DIR'/g,JSON.stringify(t)).replace(/"\$\{CLAUDE_PROJECT_DIR\}"|'\$\{CLAUDE_PROJECT_DIR\}'/g,JSON.stringify(t)).replace(/\$OMP_PROJECT_DIR|\$\{OMP_PROJECT_DIR\}/g,JSON.stringify(t)).replace(/\$CLAUDE_PROJECT_DIR|\$\{CLAUDE_PROJECT_DIR\}/g,JSON.stringify(t)).trim();return{cmd:`sh`,args:[`-c`,n.startsWith(`"`)&&n.endsWith(`"`)?n.slice(1,-1):n]}}const Z=C(`loadSettingsFile`)(function*(t){let n=yield*(yield*pe).readFileString(t).pipe(ie(()=>_(``)));if(n===``)return null;let r=p(u(O({key:y,value:e})))(n);if(h(r))return null;let i=r.right,a=ge(i);return h(a)?null:a.right}),Ee=C(`loadSettings`)(function*(e){let t=[`${R()}/.claude/settings.json`,`${e}/.claude/settings.json`,`${e}/.claude/settings.local.json`,`/etc/claude-code/managed-settings.json`];return yield*De(t)}),De=C(`loadSettingsWithPaths`)(function*(e){let t=[];for(let n of e){let e=yield*Z(n);e!==null&&t.push(e)}return t.length===0?null:ve(t)}),Q=C(`runHookScript`)(function*(e,t,n,r){let i=yield*de,{cmd:a,args:o}=Te(e,n),s=JSON.stringify(t),c=se(a,...o).pipe(le(n),ce({OMP_PROJECT_DIR:n,CLAUDE_PROJECT_DIR:n}),ue(s),oe(`pipe`),fe(`pipe`));return yield*f(v(function*(){let e=yield*i.start(c),t=yield*e.stdout.pipe(E(),D),n=yield*e.stderr.pipe(E(),D),r=yield*e.exitCode;return{code:typeof r==`number`?r:Number(r),stdout:t,stderr:n}})).pipe(ae(r),re(`TimeoutException`,()=>_({code:-1,stdout:``,stderr:`timeout after ${r}ms`})))}),$=C(`runHooksForEvent`)(function*(e,t,n,r,i){let o=r.cwd,c,u=!1,f=n;for(let n of e)if(P(t,n.matcher))for(let e of n.hooks){let t=(e.timeout??10)*1e3;if(e.async){yield*A(Q(e.command,f,o,t));continue}let n=yield*Q(e.command,f,o,t),r=l(l(d(we(n,i),{onLeft:e=>l(e).pipe(x(`HookVerdictError`,e=>new V({message:`Hook exited 0 but produced invalid JSON: ${e.raw.slice(0,200)}`})),M),onRight:e=>e})).pipe(x(`Block`,e=>new H({reason:e.reason})),x(`Warning`,e=>new U({warning:e.message})),x(`Allow`,()=>{let e=W(n.stdout);return new U({updatedInput:ne(e)?e.right.hookSpecificOutput?.updatedInput:void 0})}),M)).pipe(x(`Blocked`,e=>a({block:!0,reason:e.reason})),x(`Continue`,e=>(e.warning!==void 0&&c===void 0&&(c=e.warning),e.updatedInput!==void 0&&(f={...f,...e.updatedInput},u=!0),s())),M);if(k(r))return r.value}return{...u?{updatedInput:f}:{},...c===void 0?{}:{warning:c}}}),Oe=C(`runPreToolUseHooks`)(function*(e,t,n){if(q(e))return;let r=F(t.toolName),i=L(()=>n.sessionManager.getSessionId()),a={...i,tool_name:r,tool_input:N(r,t.input),tool_call_id:t.toolCallId},o=I(t.toolName,t.input);if(o!==void 0&&o.length>0){let r={...i,tool_name:`Bash`,tool_input:{command:o},tool_call_id:t.toolCallId},a=yield*$(e.hooks.PreToolUse,`Bash`,r,n,`PreToolUse`);if(a.block)return a.reason===void 0?{block:!0}:{block:!0,reason:a.reason}}let s=yield*$(e.hooks.PreToolUse,r,a,n,`PreToolUse`);if(s.block)return s.reason===void 0?{block:!0}:{block:!0,reason:s.reason};if(s.updatedInput&&typeof s.updatedInput==`object`&&`tool_input`in s.updatedInput&&s.updatedInput.tool_input&&typeof s.updatedInput.tool_input==`object`){let e=s.updatedInput.tool_input;for(let[n,r]of Object.entries(e))t.input[n]=r}}),ke=C(`runPostToolUseHooks`)(function*(e,t,n){let r=F(t.toolName);if(q(e))return;let i={...L(()=>n.sessionManager.getSessionId()),tool_name:r,tool_input:N(r,t.input),tool_call_id:t.toolCallId,output:t.content,is_error:t.isError??!1};return yield*$(e.hooks.PostToolUse,r,i,n,`PostToolUse`)}),Ae=C(`runUserPromptSubmitHooks`)(function*(e,t,n){let r=e.hooks.UserPromptSubmit;if(q(e)||r.length===0)return;let i=n.cwd,a=``,o={...L(()=>n.sessionManager.getSessionId()),prompt:t.text,source:t.source};for(let e of r)for(let t of e.hooks){let e=yield*Q(t.command,o,i,(t.timeout??10)*1e3);if(e.code!==0)continue;let n=e.stdout.trim();n.length>0&&(a+=(a.length>0?`
|
|
2
|
+
|
|
3
|
+
`:``)+n)}if(a.length===0)return;let s={text:`${a}\n\n${t.text}`};return t.images!==void 0&&(s.images=t.images),s}),je=C(`runSessionStartHooks`)(function*(e,t,n){if(q(e))return;let r=e.hooks.SessionStart;if(r.length===0)return;let i=n.cwd,a={...L(()=>n.sessionManager.getSessionId()),reason:t};for(let e of r)if(!(e.matcher&&!P(t,e.matcher)))for(let t of e.hooks){let e=(t.timeout??10)*1e3;if(t.async){yield*A(Q(t.command,a,i,e));continue}yield*Q(t.command,a,i,e)}}),Me=C(`runLifecycleHooks`)(function*(e,t){if(e.length===0)return;let n=t.cwd,r={...L(()=>t.sessionManager.getSessionId())};for(let t of e)for(let e of t.hooks){let t=(e.timeout??10)*1e3;e.async?yield*A(Q(e.command,r,n,t)):yield*Q(e.command,r,n,t)}});export{Ee as loadSettings,Me as runLifecycleHooks,ke as runPostToolUseHooks,Oe as runPreToolUseHooks,je as runSessionStartHooks,Ae as runUserPromptSubmitHooks};
|