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/amp/cc-safety-net/index.ts +42 -45
- package/dist/api.js +1 -1
- package/dist/bin/hook.js +40 -43
- package/dist/chunks/index-409cdnva.js +2 -0
- package/dist/chunks/index-jfmgn339.js +4 -0
- package/dist/chunks/index-pmd634p1.js +45 -0
- package/dist/cli.js +143 -152
- package/dist/index.js +1 -1
- package/dist/openclaw/cc-safety-net/index.js +42 -45
- 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-chc1n91k.js +0 -48
- package/dist/chunks/index-n0tze7vr.js +0 -2
- package/dist/chunks/index-ver1bgty.js +0 -4
package/dist/pi/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
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()||
|
|
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.
|
|
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": "
|
|
107
|
+
"gitHead": "de195b0e91f24b2c06554f719d4089d725b22809"
|
|
109
108
|
}
|