cc-safety-net 2.4.0 → 2.4.2

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/index.js CHANGED
@@ -1 +1 @@
1
- import{Ce,j,Se,l,xe,f,ce,oe,de,u,p}from"./chunks/index-chc1n91k.js";import{te}from"./chunks/index-n0tze7vr.js";import{we,F}from"./chunks/index-ver1bgty.js";import{resolve as h}from"node:path";function w(){return{"cc-safety-net":{description:"Operate CC Safety Net: explain blocks, rules, integrations, diagnostics",template:te.slice(te.indexOf("# CC Safety Net"))}}}var T=new Set(["powershell","pwsh"]),A=new Set(["bash","dash","ksh","sh","zsh"]);function v(o={}){return async({directory:r,homeDir:t})=>{let n=h(r),a;return{config:async(i)=>{a=i;let c=w(),s=i.command??{};i.command={...c,...s}},"tool.execute.before":async(i,c)=>{let s=t===void 0?l():{...l(),home:t},m=(e,R,S=n)=>{we(s,e,()=>i.sessionID,{agent:"opencode",toolName:R,cwd:S}),E(e)};if(typeof i.tool!=="string"||i.tool.trim()==="")m(j());let d=c.args,g;try{g=oe(d)}catch(e){if(!(e instanceof f))throw e;m(j({toolName:i.tool}),i.tool)}let D=I(a?.shell),x=b(i.tool,D),C=N(n,d);if(!de(n)||!C)return m(j({command:g,toolName:i.tool}),i.tool);let P={configCwd:n,executionCwd:C},k=u(i.tool,d,x,P,g??null);try{let e=F(s,k,{guard:{auditAllowed:xe(s.env),dependencies:o},audit:{agent:"opencode",getSessionId:()=>i.sessionID}});y(e,!0)}catch(e){if(!(e instanceof p))throw e;if(e.stage==="policy-protection"||e.stage==="config-load"||e.stage==="secret-protection")throw e.cause;y(e.evaluation,!0);return}}}}}function I(o,r=process.platform,t=process.env.SHELL){if(typeof o!=="string"&&r==="win32")return"powershell";let n=typeof o==="string"?o:t;if(typeof n!=="string")return"auto";let a=n.trim().split(/[\\/]/).at(-1)?.toLowerCase().replace(/\.exe$/,"");if(!a)return"auto";if(T.has(a))return"powershell";if(A.has(a))return"posix";return"auto"}function b(o,r){if(o==="bash")return{kind:"command",shell:r};return{kind:ce(o)}}function N(o,r){if(!r||typeof r!=="object"||Array.isArray(r))return o;if(!Object.hasOwn(r,"workdir"))return o;let t=r.workdir;if(typeof t!=="string"||t.trim()==="")return null;let n=process.platform==="win32"?O(t):t,a=h(o,n);return de(a)?a:null}function O(o){return o.replace(/^\/([a-zA-Z]):(?:[\\/]|$)/,(t,n)=>`${n.toUpperCase()}:/`).replace(/^\/([a-zA-Z])(?:[\\/]|$)/,(t,n)=>`${n.toUpperCase()}:/`).replace(/^\/cygdrive\/([a-zA-Z])(?:[\\/]|$)/,(t,n)=>`${n.toUpperCase()}:/`).replace(/^\/mnt\/([a-zA-Z])(?:[\\/]|$)/,(t,n)=>`${n.toUpperCase()}:/`)}function y(o,r){let t=Ce(o,{includeEvidence:r});if(t)E(t)}function E(o){throw Error(Se(o))}var Q=v();export{Q as CCSafetyNetPlugin};
1
+ import{ye,A,ve,l,be,f,ae,te,le,u,p}from"./chunks/index-pmd634p1.js";import{X}from"./chunks/index-409cdnva.js";import{he,O}from"./chunks/index-jfmgn339.js";import{resolve as h}from"node:path";function y(){return{"cc-safety-net":{description:"Operate CC Safety Net: explain blocks, rules, integrations, diagnostics",template:X.slice(X.indexOf("# CC Safety Net"))}}}var I=new Set(["powershell","pwsh"]),R=new Set(["bash","dash","ksh","sh","zsh"]);function E(e={}){return async({directory:t,homeDir:i})=>{let o=h(t),a;return{config:async(r)=>{a=r;let c=y(),s=r.command??{};r.command={...c,...s}},"tool.execute.before":async(r,c)=>{let s=i===void 0?l():{...l(),home:i},d=(n,S,D=o)=>{he(s,n,()=>r.sessionID,{agent:"opencode",toolName:S,cwd:D}),v(n)};if(typeof r.tool!=="string"||r.tool.trim()==="")d(A());let m=c.args,g;try{g=te(m)}catch(n){if(!(n instanceof f))throw n;d(A({toolName:r.tool}),r.tool)}let x=N(a?.shell),T=b(r.tool,x),C=L(o,m);if(!le(o)||!C)return d(A({command:g,toolName:r.tool}),r.tool);let P={configCwd:o,executionCwd:C},k=u(r.tool,m,T,P,g??null);try{let n=O(s,k,{guard:{auditAllowed:be(s.env),dependencies:e},audit:{agent:"opencode",getSessionId:()=>r.sessionID}});w(n)}catch(n){if(!(n instanceof p))throw n;if(n.stage==="policy-protection"||n.stage==="config-load"||n.stage==="secret-protection")throw n.cause;w(n.evaluation);return}}}}}function N(e,t=process.platform,i=process.env.SHELL){if(typeof e!=="string"&&t==="win32")return"powershell";let o=typeof e==="string"?e:i;if(typeof o!=="string")return"auto";let a=o.trim().split(/[\\/]/).at(-1)?.toLowerCase().replace(/\.exe$/,"");if(!a)return"auto";if(I.has(a))return"powershell";if(R.has(a))return"posix";return"auto"}function b(e,t){if(e==="bash")return{kind:"command",shell:t};return{kind:ae(e)}}function L(e,t){if(!t||typeof t!=="object"||Array.isArray(t))return e;if(!Object.hasOwn(t,"workdir"))return e;let i=t.workdir;if(typeof i!=="string"||i.trim()==="")return null;let o=process.platform==="win32"?_(i):i,a=h(e,o);return le(a)?a:null}function _(e){return e.replace(/^\/([a-zA-Z]):(?:[\\/]|$)/,(i,o)=>`${o.toUpperCase()}:/`).replace(/^\/([a-zA-Z])(?:[\\/]|$)/,(i,o)=>`${o.toUpperCase()}:/`).replace(/^\/cygdrive\/([a-zA-Z])(?:[\\/]|$)/,(i,o)=>`${o.toUpperCase()}:/`).replace(/^\/mnt\/([a-zA-Z])(?:[\\/]|$)/,(i,o)=>`${o.toUpperCase()}:/`)}function w(e){let t=ye(e,{includeEvidence:!0});if(t)v(t)}function v(e){throw Error(ve(e))}var V=E();export{V as CCSafetyNetPlugin};