cc-safety-net 2.0.6 → 2.0.7
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/README.md +35 -96
- package/dist/amp/cc-safety-net.ts +53 -53
- package/dist/bin/cc-safety-net.js +124 -129
- package/dist/chunks/index-4pw6zr4t.js +64 -0
- package/dist/index.js +1 -1
- package/dist/openclaw/cc-safety-net/index.js +51 -51
- package/dist/openclaw/cc-safety-net/openclaw.plugin.json +1 -1
- package/dist/openclaw/cc-safety-net/package.json +1 -1
- package/dist/pi/index.js +2 -2
- package/package.json +2 -3
- package/dist/chunks/index-3a1zwkma.js +0 -64
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as B}from"./chunks/index-25nh5wqs.js";import{$ as O,M as
|
|
1
|
+
import{a as B}from"./chunks/index-25nh5wqs.js";import{$ as O,M as W,N as F,O as z,P as L,Z as x,_ as M,jb as _,ma as N,nb as b,ua as k}from"./chunks/index-4pw6zr4t.js";import{accessSync as h,constants as R,statSync as w}from"node:fs";import{resolve as T}from"node:path";var P="cc-safety-net";function X(q){let Q=new Set(q??[]),J={},K={description:"Manage CC Safety Net rulebooks",template:B.slice(B.indexOf("## Workflow"))};if(!Q.has(P))J[P]=K;return J}var C=new Set(["powershell","pwsh"]),s=new Set(["bash","dash","ksh","sh","zsh"]);function A(q={}){return async({directory:Q,homeDir:J})=>{let K=T(Q),$;return{config:async(Z)=>{$=Z;let H=X(),j=Z.command??{};Z.command={...H,...j}},"tool.execute.before":async(Z,H)=>{let j=(V,g,m=K)=>{W(V,()=>Z.sessionID,{agent:"opencode",toolName:g,cwd:m,homeDir:J}),S(V)};if(typeof Z.tool!=="string"||Z.tool.trim()==="")j(z());let Y=H.args,y;try{y=O(Y)}catch(V){if(!(V instanceof x))throw V;j(z({toolName:Z.tool}),Z.tool)}let D=p($?.shell),E=c(Z.tool,D),G=u(K,Y);if(!I(K)||!G)return j(z({command:y,toolName:Z.tool}),Z.tool);let f={configCwd:K,executionCwd:G},v=k(Z.tool,Y,E,f,y??null);try{let V=b(v,{guard:{auditAllowed:N(),dependencies:q},audit:{agent:"opencode",homeDir:J,getSessionId:()=>Z.sessionID}});U(V,V.stage!=="config-state")}catch(V){if(!(V instanceof _))throw V;if(V.stage==="policy-protection"||V.stage==="config-load"||V.stage==="secret-protection")throw V.cause;U(V.evaluation,!0);return}}}}}function p(q,Q=process.platform,J=process.env.SHELL){if(typeof q!=="string"&&Q==="win32")return"powershell";let K=typeof q==="string"?q:J;if(typeof K!=="string")return"auto";let $=K.trim().split(/[\\/]/).at(-1)?.toLowerCase().replace(/\.exe$/,"");if(!$)return"auto";if(C.has($))return"powershell";if(s.has($))return"posix";return"auto"}function c(q,Q){if(q==="bash")return{kind:"command",shell:Q};return{kind:M(q)}}function u(q,Q){if(!Q||typeof Q!=="object"||Array.isArray(Q))return q;if(!Object.hasOwn(Q,"workdir"))return q;let J=Q.workdir;if(typeof J!=="string"||J.trim()==="")return null;let K=process.platform==="win32"?a(J):J,$=T(q,K);return I($)?$:null}function a(q){return q.replace(/^\/([a-zA-Z]):(?:[\\/]|$)/,(J,K)=>`${K.toUpperCase()}:/`).replace(/^\/([a-zA-Z])(?:[\\/]|$)/,(J,K)=>`${K.toUpperCase()}:/`).replace(/^\/cygdrive\/([a-zA-Z])(?:[\\/]|$)/,(J,K)=>`${K.toUpperCase()}:/`).replace(/^\/mnt\/([a-zA-Z])(?:[\\/]|$)/,(J,K)=>`${K.toUpperCase()}:/`)}function I(q){try{if(!w(q).isDirectory())return!1;return h(q,R.R_OK|R.X_OK),!0}catch{return!1}}function U(q,Q){let J=F(q,{includeEvidence:Q});if(J)S(J)}function S(q){throw Error(L(q))}var zq=A();export{zq as CCSafetyNetPlugin};
|