cc-safety-net 2.6.16 → 2.6.18

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,2 @@
1
+ import{Ie,Z,G,P,X,c,Oe,m,x,ae,ye,l,f}from"./index-1p1q38x4.js";import{ie}from"./index-fpxp8rvc.js";import{Ae,H}from"./index-8m4sxbp8.js";import{join as v,resolve as y}from"node:path";function Fe(){return{"cc-safety-net":{description:"Operate CC Safety Net: explain blocks, rules, integrations, diagnostics",template:ie.slice(ie.indexOf("# CC Safety Net"))}}}var O=new Set(["powershell","pwsh"]),k=new Set(["fish","nu"]),Xe="bash",Te="shell";function yt(n={}){return async({directory:t,homeDir:a})=>{let e=y(t),o;return{config:async(i)=>{o=i;let s=Fe(),d=i.command??{};i.command={...s,...d}},"tool.execute.before":async(i,s)=>{Qe({configCwd:e,homeDir:a,tool:i.tool,sessionID:i.sessionID,toolInput:s.args,route:S(i.tool,et(o?.shell)),guardDependencies:n})}}}}function Qe({configCwd:n,homeDir:t,expandHomeWorkdir:a=!1,tool:e,sessionID:o,toolInput:i,route:s,guardDependencies:d={}}){let C=t===void 0?c():{...c(),home:t},u=(r,D,T=n)=>{Ae(C,r,()=>o,{agent:"opencode",toolName:D,cwd:T}),h(r)};if(typeof e!=="string"||e.trim()==="")u(G());let p;try{p=ae(i)}catch(r){if(!(r instanceof m))throw r;u(Z({toolName:e}),e)}if(!ye(n)){u(P({directory:"session",problem:"unusable",cwd:n},{command:p,toolName:e}),e);return}let g=N(n,i,a?C.home:void 0);if(g===null){u(G({command:p,toolName:e}),e);return}if(typeof g!=="string"){u(P(g,{command:p,toolName:e}),e,g.cwd);return}let E=l(e,i,s,{configCwd:n,executionCwd:g},p??null);try{let r=H(C,E,{guard:{auditAllowed:Oe(C.env),dependencies:d},audit:{agent:"opencode",getSessionId:()=>o}});w(r)}catch(r){if(!(r instanceof f))throw r;if(r.stage==="policy-protection"||r.stage==="config-load"||r.stage==="secret-protection")throw r.cause;w(r.evaluation);return}}function et(n,t=process.platform,a=process.env.SHELL){let o=(typeof n==="string"?n:a)?.trim().split(/[\\/]/).at(-1)?.toLowerCase().replace(/\.exe$/,"");if(typeof n!=="string"&&t==="win32"&&(!o||k.has(o)))return"powershell";if(!o)return"auto";if(O.has(o))return"powershell";return o==="cmd"?"auto":"posix"}function S(n,t){if(n===Xe)return{kind:"command",shell:t};return{kind:x(n)}}function N(n,t,a){if(!t||typeof t!=="object"||Array.isArray(t))return n;if(!Object.hasOwn(t,"workdir"))return n;let e=t.workdir;if(typeof e!=="string"||e.trim()==="")return null;let o=process.platform==="win32"?_(e):e,i=o.startsWith("~/")||process.platform==="win32"&&o.startsWith("~\\"),s=a===void 0?o:o==="~"?a:i?v(a,o.slice(2)):o,d=y(n,s);return ye(d)?d:{directory:"requested",problem:"unusable",cwd:e}}function _(n){return n.replace(/^\/([a-zA-Z]):(?:[\\/]|$)/,(a,e)=>`${e.toUpperCase()}:/`).replace(/^\/([a-zA-Z])(?:[\\/]|$)/,(a,e)=>`${e.toUpperCase()}:/`).replace(/^\/cygdrive\/([a-zA-Z])(?:[\\/]|$)/,(a,e)=>`${e.toUpperCase()}:/`).replace(/^\/mnt\/([a-zA-Z])(?:[\\/]|$)/,(a,e)=>`${e.toUpperCase()}:/`)}function w(n){let t=Ie(n,{includeEvidence:!0});if(t)h(t)}function h(n){throw Error(X(n))}
2
+ export{Fe,Xe,Te,yt,Qe,et};