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.
@@ -2,7 +2,7 @@
2
2
  "id": "cc-safety-net",
3
3
  "name": "CC Safety Net",
4
4
  "description": "Block destructive commands and secret-file access before OpenClaw runs a tool.",
5
- "version": "2.4.0",
5
+ "version": "2.4.2",
6
6
  "activation": {
7
7
  "onStartup": true
8
8
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-safety-net",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Block destructive commands and secret-file access before OpenClaw runs a tool.",
5
5
  "type": "module",
6
6
  "openclaw": {
package/dist/pi/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import{Ce,j,Se,it,l,i,xe,_,ce,at,u,p}from"../chunks/index-chc1n91k.js";import{te}from"../chunks/index-n0tze7vr.js";import{we,F}from"../chunks/index-ver1bgty.js";var g="cc-safety-net",P="Operate CC Safety Net: explain blocks, rules, integrations, diagnostics",y="Help me with CC Safety Net.";function c(e){e.registerCommand(g,{description:P,handler:async(n,r)=>{e.sendUserMessage(T(n),r.isIdle()?void 0:{deliverAs:"followUp"})}})}function T(e){return`${te.slice(te.indexOf("# CC Safety Net")).trimEnd()}
1
+ import{ye,A,ve,Xe,l,o,be,R,ae,et,u,p}from"../chunks/index-pmd634p1.js";import{X}from"../chunks/index-409cdnva.js";import{he,O}from"../chunks/index-jfmgn339.js";var y="cc-safety-net",E="Operate CC Safety Net: explain blocks, rules, integrations, diagnostics",x="Help me with CC Safety Net.";function f(e){e.registerCommand(y,{description:E,handler:async(n,i)=>{e.sendUserMessage(w(n),i.isIdle()?void 0:{deliverAs:"followUp"})}})}function w(e){return`${X.slice(X.indexOf("# CC Safety Net")).trimEnd()}
2
2
 
3
3
  ## User request
4
4
 
5
- ${e.trim()||y}`}var v=new Map([["bash","posix"]]);function C(e){e.on("tool_call",w)}var w=N();function N(e={}){return(n,r)=>{try{return E(n,r,e)}catch(o){return console.error("CC Safety Net error:",o),m(j())}}}function E(e,n,r){let o=l(),t=h(e,n,o.paths);if(!t)return;if("malformed"in t)return we(o,t.denial,()=>n.sessionManager.getSessionId(),{agent:"pi",toolName:t.denial.toolName,cwd:t.cwd}),m(t.denial);try{let a=F(o,t,{guard:{auditAllowed:xe(o.env),policyOptions:r.policyOptions,dependencies:r.guardDependencies},audit:{agent:"pi",getSessionId:()=>n.sessionManager.getSessionId()}});return f(a,!0)}catch(a){if(!(a instanceof p))throw a;if(_(i.debug,o.env))console.error(`CC Safety Net debug: pi tool_call analysis failed: ${it(a.cause)}`);return f(a.evaluation,t.route.kind==="command")}}function h(e,n,r){if(!e||typeof e!=="object")return;let o=e;if(o.type!==void 0&&o.type!=="tool_call")return;if(typeof o.toolName!=="string"||o.toolName.trim()==="")return d(n);let t=typeof n.cwd==="string"&&n.cwd.trim()!==""?at(".",[n.cwd],r):void 0;if(!t)return d(n,o.toolName);let a=v.get(o.toolName);if(!o.input||typeof o.input!=="object")return a?d(n,o.toolName):void 0;if(!a)return u(o.toolName,o.input,{kind:ce(o.toolName)},{configCwd:t,executionCwd:t},null);let s=o.input.command;if(typeof s!=="string"||s.trim()==="")return d(n,o.toolName);return u(o.toolName,o.input,{kind:"command",shell:a},{configCwd:t,executionCwd:t},s)}function d(e,n){return{malformed:!0,denial:j({toolName:n}),cwd:typeof e.cwd==="string"&&e.cwd.trim()?e.cwd:null}}function f(e,n){let r=Ce(e,{includeEvidence:n});return r?m(r):void 0}function m(e){return{block:!0,reason:Se(e)}}function A(e){C(e),c(e)}export{A as default};
5
+ ${e.trim()||x}`}function g(e,n={}){return{malformed:!0,denial:A(n),cwd:e}}function P(e,n={}){return(i,t)=>{try{return N(i,t,e,n)}catch(r){return console.error("CC Safety Net error:",r),e.block(A())}}}function N(e,n,i,t){let r=l();if(i.cancelled?.(n))return i.block(A());let a=i.extract(e,n,r.paths);if(!a)return i.allow;let s=()=>i.getSessionId(e,n);if("malformed"in a)return he(r,a.denial,s,{agent:i.agent,toolName:a.denial.toolName,cwd:a.cwd}),i.block(a.denial);let m=(d,v)=>{let C=ye(d,{includeEvidence:v});return C?i.block(C):i.allow};try{let d=O(r,a,{guard:{auditAllowed:be(r.env),policyOptions:t.policyOptions,dependencies:t.guardDependencies},audit:{agent:i.agent,getSessionId:s}});return m(d,!0)}catch(d){if(!(d instanceof p))throw d;if(R(o.debug,r.env))console.error(`CC Safety Net debug: ${i.debugLabel} analysis failed: ${Xe(d.cause)}`);return m(d.evaluation,i.includeEvidenceOnError(a))}}var I=new Map([["bash","posix"]]),b={agent:"pi",debugLabel:"pi tool_call",extract:(e,n,i)=>k(e,n,i),getSessionId:(e,n)=>n.sessionManager.getSessionId(),allow:void 0,block:(e)=>M(e),includeEvidenceOnError:(e)=>e.route.kind==="command"};function T(e){e.on("tool_call",S)}var S=D();function D(e={}){return P(b,e)}function k(e,n,i){if(!e||typeof e!=="object")return;let t=e;if(t.type!==void 0&&t.type!=="tool_call")return;if(typeof t.toolName!=="string"||t.toolName.trim()==="")return c(n);let r=typeof n.cwd==="string"&&n.cwd.trim()!==""?et(".",[n.cwd],i):void 0;if(!r)return c(n,t.toolName);let a=I.get(t.toolName);if(!t.input||typeof t.input!=="object")return a?c(n,t.toolName):void 0;if(!a)return u(t.toolName,t.input,{kind:ae(t.toolName)},{configCwd:r,executionCwd:r},null);let s=t.input.command;if(typeof s!=="string"||s.trim()==="")return c(n,t.toolName);return u(t.toolName,t.input,{kind:"command",shell:a},{configCwd:r,executionCwd:r},s)}function c(e,n){return g(typeof e.cwd==="string"&&e.cwd.trim()?e.cwd:null,{toolName:n})}function M(e){return{block:!0,reason:ve(e)}}function _(e){T(e),f(e)}export{_ as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-safety-net",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "A coding agent CLI hook - block destructive commands and secret file access",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,7 +39,6 @@
39
39
  "knip": "knip-bun --production",
40
40
  "check-duplicates": "bunx jscpd src tests --no-tips --exit-code 1 --reporters ai --ignore '**/*.svg' --ignore 'src/gui/frontend/**' --ignore-pattern 'import\\s[\\s\\S]*?from\\s[^;]*;'",
41
41
  "test": "bun test",
42
- "test:e2e": "bun test tests/e2e",
43
42
  "test:e2e:stability": "bun test tests/e2e --randomize --rerun-each 3",
44
43
  "test:e2e:live": "CC_SAFETY_NET_E2E_LIVE=1 bun test tests/e2e-live",
45
44
  "test:coverage": "AGENT=1 bun test tests --path-ignore-patterns 'tests/e2e-live/**' --coverage --coverage-reporter=text --coverage-reporter=lcov",
@@ -105,5 +104,5 @@
105
104
  "grok",
106
105
  "grok-build"
107
106
  ],
108
- "gitHead": "7622a12456f8332648164207235cd9d0df37a15c"
107
+ "gitHead": "de195b0e91f24b2c06554f719d4089d725b22809"
109
108
  }