cc-safety-net 2.4.11 → 2.4.13

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.11",
5
+ "version": "2.4.13",
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.11",
3
+ "version": "2.4.13",
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{ye,P,be,Xe,c,o,xe,L,V,et,d,p}from"../chunks/index-mzkasrgh.js";import{Q}from"../chunks/index-rr4ytenf.js";import{he,D}from"../chunks/index-jtfqeraz.js";var E="cc-safety-net",x="Operate CC Safety Net: explain blocks, rules, integrations, diagnostics",w="Help me with CC Safety Net.";function f(e){e.registerCommand(E,{description:x,handler:async(n,l)=>{e.sendUserMessage(N(n),l.isIdle()?void 0:{deliverAs:"followUp"})}})}function N(e){return`${Q.slice(Q.indexOf("# CC Safety Net")).trimEnd()}
1
+ import{ye,P,A,be,Xe,c,o,xe,L,q,et,d,p}from"../chunks/index-av9c301x.js";import{ee}from"../chunks/index-pm924a1e.js";import{he,N}from"../chunks/index-fjkkpma1.js";var E="cc-safety-net",x="Operate CC Safety Net: explain blocks, rules, integrations, diagnostics",b="Help me with CC Safety Net.";function f(e){e.registerCommand(E,{description:x,handler:async(n,l)=>{e.sendUserMessage(I(n),l.isIdle()?void 0:{deliverAs:"followUp"})}})}function I(e){return`${ee.slice(ee.indexOf("# CC Safety Net")).trimEnd()}
2
2
 
3
3
  ## User request
4
4
 
5
- ${e.trim()||w}`}function g(e,n={}){return{malformed:!0,denial:P(n),cwd:e}}function T(e,n={}){return(l,t)=>{try{return I(l,t,e,n)}catch(i){return console.error("CC Safety Net error:",i),e.block(P())}}}function I(e,n,l,t){let i=c();if(l.cancelled?.(n))return l.block(P());let r=l.extract(e,n,i.paths);if(!r)return l.allow;let s=()=>l.getSessionId(e,n);if("malformed"in r)return he(i,r.denial,s,{agent:l.agent,toolName:r.denial.toolName,cwd:r.cwd}),l.block(r.denial);let m=(a,y)=>{let C=ye(a,{includeEvidence:y});return C?l.block(C):l.allow};try{let a=D(i,r,{guard:{auditAllowed:xe(i.env),policyOptions:t.policyOptions,dependencies:t.guardDependencies},audit:{agent:l.agent,getSessionId:s}});return m(a,!0)}catch(a){if(!(a instanceof p))throw a;if(L(o.debug,i.env))console.error(`CC Safety Net debug: ${l.debugLabel} analysis failed: ${Xe(a.cause)}`);return m(a.evaluation,l.includeEvidenceOnError(r))}}var b=new Map([["bash","posix"]]),R={agent:"pi",debugLabel:"pi tool_call",extract:(e,n,l)=>A(e,n,l),getSessionId:(e,n)=>n.sessionManager.getSessionId(),allow:void 0,block:(e)=>k(e),includeEvidenceOnError:(e)=>e.route.kind==="command"};function v(e){e.on("tool_call",O)}var O=S();function S(e={}){return T(R,e)}function A(e,n,l){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 u(n);let i=typeof n.cwd==="string"&&n.cwd.trim()!==""?et(".",[n.cwd],l):void 0;if(!i)return u(n,t.toolName);let r=b.get(t.toolName);if(!t.input||typeof t.input!=="object")return r?u(n,t.toolName):void 0;if(!r)return d(t.toolName,t.input,{kind:V(t.toolName)},{configCwd:i,executionCwd:i},null);let s=t.input.command;if(typeof s!=="string"||s.trim()==="")return u(n,t.toolName);return d(t.toolName,t.input,{kind:"command",shell:r},{configCwd:i,executionCwd:i},s)}function u(e,n){return g(typeof e.cwd==="string"&&e.cwd.trim()?e.cwd:null,{toolName:n})}function k(e){return{block:!0,reason:be(e)}}function M(e){v(e),f(e)}export{M as default};
5
+ ${e.trim()||b}`}function g(e,n={}){return{malformed:!0,denial:P(n),cwd:e}}function T(e,n){return{malformed:!0,denial:A(e,n),cwd:e.cwd}}function y(e,n={}){return(l,t)=>{try{return D(l,t,e,n)}catch(i){return console.error("CC Safety Net error:",i),e.block(P())}}}function D(e,n,l,t){let i=c();if(l.cancelled?.(n))return l.block(P());let r=l.extract(e,n,i.paths);if(!r)return l.allow;let s=()=>l.getSessionId(e,n);if("malformed"in r)return he(i,r.denial,s,{agent:l.agent,toolName:r.denial.toolName,cwd:r.cwd}),l.block(r.denial);let m=(a,w)=>{let C=ye(a,{includeEvidence:w});return C?l.block(C):l.allow};try{let a=N(i,r,{guard:{auditAllowed:xe(i.env),policyOptions:t.policyOptions,dependencies:t.guardDependencies},audit:{agent:l.agent,getSessionId:s}});return m(a,!0)}catch(a){if(!(a instanceof p))throw a;if(L(o.debug,i.env))console.error(`CC Safety Net debug: ${l.debugLabel} analysis failed: ${Xe(a.cause)}`);return m(a.evaluation,l.includeEvidenceOnError(r))}}var R=new Map([["bash","posix"],["powershell","powershell"]]),O={agent:"pi",debugLabel:"pi tool_call",extract:(e,n,l)=>M(e,n,l),getSessionId:(e,n)=>n.sessionManager.getSessionId(),allow:void 0,block:(e)=>_(e),includeEvidenceOnError:(e)=>e.route.kind==="command"};function v(e){e.on("tool_call",S)}var S=k();function k(e={}){return y(O,e)}function M(e,n,l){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 u(n);if(typeof n.cwd!=="string"||n.cwd.trim()==="")return u(n,t.toolName);let i=et(".",[n.cwd],l);if(!i)return T({directory:"session",problem:"unusable",cwd:n.cwd},{toolName:t.toolName});let r=R.get(t.toolName);if(!t.input||typeof t.input!=="object")return r?u(n,t.toolName):void 0;if(!r)return d(t.toolName,t.input,{kind:q(t.toolName)},{configCwd:i,executionCwd:i},null);let s=t.input.command;if(typeof s!=="string"||s.trim()==="")return u(n,t.toolName);return d(t.toolName,t.input,{kind:"command",shell:r},{configCwd:i,executionCwd:i},s)}function u(e,n){return g(typeof e.cwd==="string"&&e.cwd.trim()?e.cwd:null,{toolName:n})}function _(e){return{block:!0,reason:be(e)}}function H(e){v(e),f(e)}export{H as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-safety-net",
3
- "version": "2.4.11",
3
+ "version": "2.4.13",
4
4
  "description": "A coding agent CLI hook - block destructive commands and secret file access",
5
5
  "keywords": [
6
6
  "amp",
@@ -60,10 +60,11 @@
60
60
  "verify:repository-plugin": "bun run scripts/verify-repository-plugin.ts",
61
61
  "verify:coverage": "bun run scripts/verify-coverage.ts",
62
62
  "clean": "rm -rf dist",
63
- "check": "bun run lint && bun run format:check && bun run typecheck && bun run knip && bun run check-duplicates && bun run test:coverage && bun run verify:coverage",
63
+ "check": "bun run lint && bun run lint:comments && bun run format:check && bun run typecheck && bun run knip && bun run check-duplicates && bun run test:coverage && bun run verify:coverage",
64
64
  "check:ci": "bun run check",
65
65
  "lint": "oxlint src tests scripts knip.ts",
66
66
  "lint:ci": "bun run lint && bun run format:check",
67
+ "lint:comments": "bun scripts/check-comments.ts",
67
68
  "typecheck": "tsc --noEmit && tsc -p tsconfig.gui.json --noEmit",
68
69
  "knip": "knip-bun --production",
69
70
  "check-duplicates": "jscpd src tests --threshold 0 --exit-code 1 --no-tips --reporters ai --ignore '**/*.svg' --ignore-pattern 'import\\s[\\s\\S]*?from\\s[^;]*;'",
@@ -87,6 +88,7 @@
87
88
  "jscpd": "^5.0.14",
88
89
  "knip": "^6.32.0",
89
90
  "lefthook": "^2.1.10",
91
+ "oxc-parser": "0.142.0",
90
92
  "oxfmt": "0.70.0",
91
93
  "oxlint": "1.85.0",
92
94
  "oxlint-tsgolint": "7.0.2002",
@@ -121,5 +123,5 @@
121
123
  "./dist/pi/index.js"
122
124
  ]
123
125
  },
124
- "gitHead": "bbade36ac6314a1bce762aa94948a6dc1a35e8ae"
126
+ "gitHead": "d31cf9c598fd230d29ea924df0e15b50e960be82"
125
127
  }