cc-safety-net 2.6.11 → 2.6.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.
- package/dist/amp/cc-safety-net/index.ts +43 -44
- package/dist/api.js +1 -1
- package/dist/bin/hook.js +43 -44
- package/dist/chunks/{index-6hppa0dh.js → index-e25d8rb4.js} +2 -2
- package/dist/chunks/index-q29jqk43.js +2 -0
- package/dist/chunks/index-rdxjms22.js +49 -0
- package/dist/chunks/{index-21n2w3y1.js → index-ry0wwdk0.js} +2 -2
- package/dist/chunks/{index-5ht7pdm3.js → index-wkjncmhg.js} +2 -2
- package/dist/chunks/index-x95aj0ja.js +4 -0
- package/dist/chunks/index-z5fwe2yq.js +2 -0
- package/dist/cli.js +128 -167
- package/dist/deepseek-harness/index.js +1 -1
- package/dist/index.js +4 -4
- package/dist/openclaw/cc-safety-net/index.js +43 -44
- 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 -2
- package/dist/chunks/index-1wd9cpbg.js +0 -2
- package/dist/chunks/index-7h15fjs7.js +0 -4
- package/dist/chunks/index-babcfevy.js +0 -50
- package/dist/chunks/index-n6djve2j.js +0 -2
package/dist/pi/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import"../chunks/index-
|
|
1
|
+
import"../chunks/index-rdxjms22.js";import{ht}from"../chunks/index-e25d8rb4.js";import{oe}from"../chunks/index-wkjncmhg.js";import"../chunks/index-q29jqk43.js";import"../chunks/index-x95aj0ja.js";var o="cc-safety-net",r="Operate CC Safety Net: explain blocks, rules, integrations, diagnostics",s="Help me with CC Safety Net.";function t(e){e.registerCommand(o,{description:r,handler:async(n,i)=>{e.sendUserMessage(a(n),i.isIdle()?void 0:{deliverAs:"followUp"})}})}function a(e){return`${oe.slice(oe.indexOf("# CC Safety Net")).trimEnd()}
|
|
2
2
|
|
|
3
3
|
## User request
|
|
4
4
|
|
|
5
|
-
${e.trim()||s}`}function m(e){
|
|
5
|
+
${e.trim()||s}`}function m(e){ht(e),t(e)}export{m as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-safety-net",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.13",
|
|
4
4
|
"description": "A coding agent CLI hook - block destructive commands and secret file access",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"amp",
|
|
@@ -135,5 +135,5 @@
|
|
|
135
135
|
"./dist/pi/index.js"
|
|
136
136
|
]
|
|
137
137
|
},
|
|
138
|
-
"gitHead": "
|
|
138
|
+
"gitHead": "4fd49ef94fa9a34ce5dd690f6e964d3bdf49888d"
|
|
139
139
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Re,N,_,yt,c,n,Te,S,f}from"./index-babcfevy.js";import{ke,G}from"./index-7h15fjs7.js";function j(t,o={}){return{malformed:!0,denial:N(o),cwd:t}}function de(t,o){return{malformed:!0,denial:_(t,o),cwd:t.cwd}}function Ee(t,o={}){return(e,i)=>{try{return m(e,i,t,o)}catch(a){return console.error("CC Safety Net error:",a),t.block(N())}}}function m(t,o,e,i){let a=c();if(e.cancelled?.(o))return e.block(N());let l=e.extract(t,o,a.paths);if(!l)return e.allow;let d=()=>e.getSessionId(t,o);if("malformed"in l)return ke(a,l.denial,d,{agent:e.agent,toolName:l.denial.toolName,cwd:l.cwd}),e.block(l.denial);let u=(r,p)=>{let s=Re(r,{includeEvidence:p});return s?e.block(s):e.allow};try{let r=G(a,l,{guard:{auditAllowed:Te(a.env),policyOptions:i.policyOptions,dependencies:i.guardDependencies},audit:{agent:e.agent,getSessionId:d}});return u(r,!0)}catch(r){if(!(r instanceof f))throw r;if(S(n.debug,a.env))console.error(`CC Safety Net debug: ${e.debugLabel} analysis failed: ${yt(r.cause)}`);return u(r.evaluation,e.includeEvidenceOnError(l))}}
|
|
2
|
-
export{j,de,Ee};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a,s,J,m,Le,u,He,b,f,q}from"./index-babcfevy.js";import{appendFileSync as ne,mkdirSync as re}from"node:fs";import{isAbsolute as ie,join as S}from"node:path";import{lstatSync as F,readdirSync as P,readFileSync as j,rmdirSync as V,statSync as D,unlinkSync as B,utimesSync as X,writeFileSync as z}from"node:fs";import{join as g}from"node:path";function oe(t,e={}){return He(u(t,e),t.home).policy.audit.retention_days}var A=86400000,Y=".last-prune",Z=/^\d{4}-\d{2}$/,Q=/^((\d{4}-\d{2})-\d{2})-.+\.jsonl$/,C=(t)=>Math.floor(t/A);function K(t,e,r=()=>new Date){try{let n=r().getTime();if(!D(e,{throwIfNoEntry:!1})?.isDirectory())return;let o=g(e,Y),c=D(o,{throwIfNoEntry:!1})?.mtimeMs;if(c!==void 0&&C(c)===C(n))return;let i=n-oe(t)*A,d=new Date(n).toISOString().slice(0,7);for(let l of v(e)){if(l.isDirectory()){W(g(e,l.name),i,d);continue}if(l.isFile()&&l.name.endsWith(".jsonl"))ee(g(e,l.name),i)}z(o,"",{mode:384}),X(o,n/1000,n/1000)}catch{}}function W(t,e,r){for(let n of v(t)){if(!n.isDirectory()||!Z.test(n.name))continue;let o=g(t,n.name);for(let c of v(o)){if(!c.isFile())continue;let i=Q.exec(c.name);if(!i||i[2]!==n.name)continue;let d=Date.parse(`${i[1]}T00:00:00.000Z`)+A;if(!Number.isFinite(d)||d>=e)continue;O(g(o,c.name))}if(n.name!==r)L(o)}L(t)}function ee(t,e){try{let r=F(t);if(r.mtimeMs>=e)return;let n=j(t,"utf-8").split(`
|
|
2
|
-
`).filter((o)=>o.trim()).map(te);if(n.length===0)return;if(n.some((o)=>o===void 0||o>=e))return;if(F(t).mtimeMs!==r.mtimeMs)return;O(t)}catch{}}function te(t){try{let e=JSON.parse(t).ts,r=typeof e==="string"?Date.parse(e):Number.NaN;return Number.isFinite(r)?r:void 0}catch{return}}function v(t){try{return P(t,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function O(t){try{B(t)}catch{}}function L(t){try{V(t)}catch{}}var ae="2.6.11",ce=1e4,de=2000,ue=256,se=32768;function le(t){let e=t.trim();if(!e)return null;let r=e.replace(/[^A-Za-z0-9_.-]+/g,"_");if(r=r.replace(/^[._-]+|[._-]+$/g,"").slice(0,128),!r||r==="."||r==="..")return null;return r}function me(t){return(t??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function I(t,e,r,n,o,c,i={}){let d=le(e);if(!d)return;let l=U(t);if(!l)return;try{let y=(i.now??(()=>new Date))().toISOString(),_=p(J(r),i.failureStage?Number.POSITIVE_INFINITY:ce),N=p(J(n),de),h=i.toolName?p(J(i.toolName),ue):void 0,E=c===null?void 0:p(J(c),se),w=S(l,me(E?.value??null),y.slice(0,7));re(w,{recursive:!0,mode:448});let R=S(w,`${y.slice(0,10)}-${d}.jsonl`),H={ts:y,id:(i.createId??Le)(),v:ae,sessionId:d,decision:i.decision??"deny",agent:i.agent,shape:i.shape,level:i.level,configFallback:i.configFallback,toolName:h?.value,command:_.value,segment:N.value,..._.truncated||N.truncated||h?.truncated||E?.truncated?{truncated:!0}:{},reason:o,ruleId:i.ruleId,intent:i.intent,failureStage:i.failureStage,errorCode:i.errorCode,cwd:E?.value??null};ne(R,`${JSON.stringify(H)}
|
|
3
|
-
`,{encoding:"utf-8",mode:384}),K(t,l,i.now)}catch{}}function p(t,e){return{value:t.slice(0,e),truncated:t.length>e}}function et(t){let e=t.env.get("CC_SAFETY_NET_AUDIT_HOME");if(t.env.get("NODE_ENV")==="test"&&!e)return null;let r=e||t.home;return r&&ie(r)?r:null}function U(t){let e=et(t);return e?S(e,".cc-safety-net","logs"):null}function k(t,e,r,n=!0,o){if(e.decision.kind==="allow"){if(!r||t.route.kind!=="command")return;let d=T(t);return{decision:"allow",command:d,segment:d,reason:"allowed",cwd:t.context.executionCwd,toolName:t.toolName,level:e.level,...e.configFallback?{configFallback:!0}:{}}}let c=e.decision.evidence,i=c?.command??(n?T(t):"");return{decision:"deny",command:i,segment:c?.segment??i,reason:e.decision.reason,cwd:t.context.executionCwd,toolName:t.toolName,level:e.level,...e.configFallback?{configFallback:!0}:{},ruleId:e.decision.ruleId,intent:e.decision.intent,failureStage:o?.stage,errorCode:o?.errorCode}}function T(t){return"command"in t?t.command??"":""}function x(t,e,r,n){if(!e)return;let o;try{o=r()}catch{return}if(typeof o!=="string"||!o.trim())return;I(t,o,e.command,e.segment,e.reason,e.cwd,{decision:e.decision,agent:n.agent,shape:n.shape,level:e.level,configFallback:e.configFallback,toolName:e.toolName,ruleId:e.ruleId,intent:e.intent,failureStage:e.failureStage,errorCode:e.errorCode})}function ke(t,e,r,n){let o;try{o=r()}catch{return}if(typeof o!=="string"||!o.trim())return;I(t,o,e.command??"",e.segment??e.command??"",e.reason,n.cwd??null,{decision:"deny",agent:n.agent,shape:n.shape,toolName:n.toolName??e.toolName,ruleId:e.ruleId,intent:e.intent})}function G(t,e,r){try{let n=q(e,{environment:t,...r.guard});return M(t,e,n,r),n}catch(n){if(!(n instanceof f))throw n;throw M(t,e,n.evaluation,r,!(n.cause instanceof m),{stage:n.stage,errorCode:fe(n.cause)}),n}}function M(t,e,r,n,o=!0,c){x(t,k(r.promotedInvocation??e,r,n.guard?.auditAllowed??!1,o,c),n.audit.getSessionId,{agent:n.audit.agent,shape:n.audit.shape})}function fe(t){if(t instanceof s)return a[t.kind].errorCode;if(t instanceof m)return"tool-input-limit";if(t instanceof b)return"structural-shell-syntax-limit";return"unexpected-error"}
|
|
4
|
-
export{oe,K,et,U,ke,G};
|