@hasna/hooks 0.12.14 → 0.12.17
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 +1 -1
- package/bin/index.js +42 -3
- package/bin/native-safety-worker.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/codex-safety-check.d.ts +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -391,7 +391,7 @@ Codex is installed through npm, pass the platform package's native binary rather
|
|
|
391
391
|
than its JavaScript launcher. Executable ownership, permissions, ancestry and
|
|
392
392
|
bytes are checked. Supported protocol versions are 0.153.0, 0.154.0,
|
|
393
393
|
0.154.0-alpha.6.1, 0.155.0, 0.155.1, 0.156.1, 0.157.0, 0.157.1, 0.158.0, 0.159.0, 0.159.2,
|
|
394
|
-
0.159.3, 0.160.0 and 0.
|
|
394
|
+
0.159.3, 0.160.0, 0.160.1, 0.161.0, 0.162.0 and 0.162.1;
|
|
395
395
|
other versions refuse pending compatibility validation. Updating Codex can
|
|
396
396
|
therefore require a compatible Hooks release before native safety verification
|
|
397
397
|
and trust provisioning succeed. Keep existing hook definitions and trust intact
|
package/bin/index.js
CHANGED
|
@@ -39282,7 +39282,7 @@ var init_codex_safety_check = __esm(() => {
|
|
|
39282
39282
|
init_native_child_env();
|
|
39283
39283
|
init_native_safety2();
|
|
39284
39284
|
init_native_readiness();
|
|
39285
|
-
SUPPORTED_CODEX_SAFETY_VERSIONS = ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1", "codex-cli 0.161.0", "codex-cli 0.162.0"];
|
|
39285
|
+
SUPPORTED_CODEX_SAFETY_VERSIONS = ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1", "codex-cli 0.161.0", "codex-cli 0.162.0", "codex-cli 0.162.1"];
|
|
39286
39286
|
versions = new Set(SUPPORTED_CODEX_SAFETY_VERSIONS);
|
|
39287
39287
|
CodexSafetyError = class CodexSafetyError extends Error {
|
|
39288
39288
|
code;
|
|
@@ -48883,8 +48883,45 @@ var exports_registry_prerequisites = {};
|
|
|
48883
48883
|
__export(exports_registry_prerequisites, {
|
|
48884
48884
|
checkRegistryPrerequisites: () => checkRegistryPrerequisites
|
|
48885
48885
|
});
|
|
48886
|
+
async function diagnoseKeySchema(db, visibleColumns) {
|
|
48887
|
+
const [namespace] = await db.readOnlyAll(`
|
|
48888
|
+
SELECT current_schema() AS current_schema,
|
|
48889
|
+
current_setting('search_path') AS search_path,
|
|
48890
|
+
current_schemas(false)::text[] AS current_schemas,
|
|
48891
|
+
n.nspname AS resolved_schema,
|
|
48892
|
+
c.oid IS NOT NULL AS relation_resolved,
|
|
48893
|
+
COALESCE(has_schema_privilege(current_user, current_schema(), 'USAGE'), false) AS current_schema_usage,
|
|
48894
|
+
COALESCE(has_schema_privilege(current_user, n.oid, 'USAGE'), false) AS resolved_schema_usage,
|
|
48895
|
+
COALESCE(has_table_privilege(current_user, c.oid, 'SELECT'), false) AS resolved_table_select
|
|
48896
|
+
FROM (SELECT to_regclass('api_keys') AS oid) target
|
|
48897
|
+
LEFT JOIN pg_catalog.pg_class c ON c.oid = target.oid
|
|
48898
|
+
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
48899
|
+
`);
|
|
48900
|
+
if (!namespace)
|
|
48901
|
+
throw new Error("REGISTRY_SCHEMA_DIAGNOSTICS_UNAVAILABLE");
|
|
48902
|
+
const physical = await db.readOnlyAll(`
|
|
48903
|
+
SELECT attname AS column_name,
|
|
48904
|
+
has_column_privilege(current_user, attrelid, attnum, 'SELECT') AS selectable
|
|
48905
|
+
FROM pg_catalog.pg_attribute
|
|
48906
|
+
WHERE attrelid = to_regclass('api_keys') AND attnum > 0 AND NOT attisdropped
|
|
48907
|
+
AND attname = ANY(?::text[])
|
|
48908
|
+
`, [KEY_COLUMNS]);
|
|
48909
|
+
return {
|
|
48910
|
+
current_schema: namespace.current_schema,
|
|
48911
|
+
search_path: namespace.search_path,
|
|
48912
|
+
current_schemas: namespace.current_schemas,
|
|
48913
|
+
resolved_schema: namespace.resolved_schema,
|
|
48914
|
+
relation_resolved: namespace.relation_resolved,
|
|
48915
|
+
current_schema_usage: namespace.current_schema_usage,
|
|
48916
|
+
resolved_schema_usage: namespace.resolved_schema_usage,
|
|
48917
|
+
resolved_table_select: namespace.resolved_table_select,
|
|
48918
|
+
missing_visible_columns: KEY_COLUMNS.filter((column) => !visibleColumns.includes(column)),
|
|
48919
|
+
missing_physical_columns: namespace.relation_resolved ? KEY_COLUMNS.filter((column) => !physical.some((row) => row.column_name === column)) : null,
|
|
48920
|
+
unselectable_columns: namespace.relation_resolved ? KEY_COLUMNS.filter((column) => physical.some((row) => row.column_name === column && !row.selectable)) : null
|
|
48921
|
+
};
|
|
48922
|
+
}
|
|
48886
48923
|
async function checkRegistryPrerequisites() {
|
|
48887
|
-
const result = { ok: false, read_only: true, signing_configured: false, key_schema_ready: false, active_hooks_keys:
|
|
48924
|
+
const result = { ok: false, read_only: true, signing_configured: false, key_schema_ready: false, active_hooks_keys: null, active_hooks_keys_checked: false, registry_tables_present: 0, key_schema_diagnostics: null };
|
|
48888
48925
|
if (!hasRegistrySigningConfiguration())
|
|
48889
48926
|
return result;
|
|
48890
48927
|
resolveSigningSecret("hooks", process.env, process.env.HASNA_HOOKS_API_SIGNING_KEY !== undefined ? { envName: "HASNA_HOOKS_API_SIGNING_KEY" } : {});
|
|
@@ -48896,13 +48933,15 @@ async function checkRegistryPrerequisites() {
|
|
|
48896
48933
|
try {
|
|
48897
48934
|
const columns = await db.readOnlyAll("SELECT column_name FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'api_keys'");
|
|
48898
48935
|
result.key_schema_ready = KEY_COLUMNS.every((column) => columns.some((row) => row.column_name === column));
|
|
48936
|
+
result.key_schema_diagnostics = await diagnoseKeySchema(db, columns.map((row) => row.column_name));
|
|
48899
48937
|
const tables = await db.readOnlyAll("SELECT table_name FROM information_schema.tables WHERE table_schema = current_schema() AND table_name IN ('hooks_registry_versions','hooks_registry_selections','hooks_registry_legacy_imports')");
|
|
48900
48938
|
result.registry_tables_present = tables.length;
|
|
48901
48939
|
if (result.key_schema_ready) {
|
|
48902
48940
|
const counts = await db.readOnlyAll("SELECT COUNT(*)::integer AS count FROM api_keys WHERE app = 'hooks' AND revoked_at IS NULL AND (expires_at IS NULL OR expires_at > NOW())");
|
|
48903
48941
|
result.active_hooks_keys = counts[0]?.count ?? 0;
|
|
48942
|
+
result.active_hooks_keys_checked = true;
|
|
48904
48943
|
}
|
|
48905
|
-
result.ok = result.key_schema_ready && result.active_hooks_keys > 0;
|
|
48944
|
+
result.ok = result.key_schema_ready && result.active_hooks_keys !== null && result.active_hooks_keys > 0;
|
|
48906
48945
|
return result;
|
|
48907
48946
|
} finally {
|
|
48908
48947
|
await db.close();
|
|
@@ -24,4 +24,4 @@ var{defineProperty:H0,getOwnPropertyNames:V3,getOwnPropertyDescriptor:G3}=Object
|
|
|
24
24
|
`).replace(/%s/g,()=>H[K++]?.value??"")+(K<H.length?" "+H.slice(K).map((B)=>B.value).join(" "):"")}if(Y==="cat"){let X=Z.indexOf("<<");if(X<0)return null;let H=WZ(Z,X),K=Z.indexOf(`
|
|
25
25
|
`,X);if(!H||K<0)return null;let B=sZ(Z,K,[H]);if(B<0)return null;let M=Z.slice(K+1,B);return M.slice(0,M.lastIndexOf(H.delimiter)).replace(/\n$/,"")}return null}function h0(Z,J,$){for(let z of g0(Z).bodies){let Y=u0(z);if(Y===null)continue;let Q=o(Y,J+1,$.debug);if(Q.refused)return Q}return I}function o(Z,J=0,$=!1){if(typeof Z!=="string"||!Z.trim())return I;if(J>G6)return eZ.test(Z)?T("unclassifiable"):I;let{segments:z,trustworthy:Y}=d0(Z);if(!Y)return eZ.test(Z)?T("unclassifiable"):I;let Q=$,X=(H)=>o(H,J+1,Q);for(let H of j6(Z)){if(H.runsBody){let K=X(H.body);if(K.refused)return K}if(!H.quoted){let K=g0(H.body,"heredoc");if(!K.complete&&eZ.test(H.body))return T("unclassifiable");for(let B of K.bodies){let M=X(B);if(M.refused)return M}}}for(let H=0;H<z.length;H++){let K=z[H];for(let N of K.words){let R=g0(N.text);if(!R.complete&&eZ.test(N.text))return T("unclassifiable");for(let w of R.bodies){let g=X(w);if(g.refused)return g}}let B=h(K),M=K.words.map((N,R)=>({word:jZ(N.text),redirect:K.redirects.has(R)})),V=M.slice(0,B<0?M.length:B).map((N)=>N.word),G=B>=0?BZ(M[B].word.value):"";if(B<0||["export","declare","typeset","readonly","local"].includes(G)){if(Q=$3([...V,...M.slice(B+1).map((N)=>N.word)],Q),B<0)continue}let U=$3(V,Q),j=M.slice(B+1).filter((N)=>!N.redirect).map((N)=>N.word),F=M.slice(B+1).filter((N)=>N.redirect).map((N)=>N.word),E=M[B].word,k=BZ(E.value),m={depth:J,appendsArgs:!1,debug:U};if(B>0&&M[B-1].word.value==="function"){let N=j.filter((w)=>!["{","()","(",")"].includes(w.value)),R=m0(N,m);if(R.refused)return R;continue}if(H>0&&Y3(K.sepBefore)&&l0(k,j)){let N=z[H-1],R=U6(Z,N),w=R===null?null:u0(R);if(w!==null){let g=o(w,J+1,U);if(g.refused)return g}}let d=z[H+1];if(d&&/<\(\s*$/.test(d.sepBefore)&&(J0.has(k)||k==="source"||k===".")){let N=d.words[0].start-d.sepBefore.length+d.sepBefore.lastIndexOf("("),R=KZ(Z,N),w=R<0?null:u0(Z.slice(N+1,R-1));if(w!==null){let g=o(w,J+1,U);if(g.refused)return g}}let C=Q3(k,E,j,F,K.words.slice(0,B+1),m);if(C.refused)return C}return I}function U6(Z,J){let $=J.words[0],z=J.words[J.words.length-1];return $&&z?Z.slice($.start,z.end):null}function W6(Z){let J=BZ(Z.value);return/[$`]/.test(J)||J===""?void 0:J}function Q3(Z,J,$,z,Y,Q){let X=Q.depth,H=(K)=>o(K,X+1,Q.debug);if(J.opaque){let K=W6(J);if(K===void 0){let B=$.find((V)=>!V.value.startsWith("-")),M=Z0($,Q);if(!M.refused)return I;return M.rule!=="unclassifiable"||B!==void 0&&!B.opaque&&u5.has(B.value)?M:I}Z=K}if(Z==="gh")return Z0($,Q);if(J0.has(Z)){let K=s0($);if(K){let B=H(K.value);if(B.refused||!K.opaque)return B;return h0(K.raw,X,Q)}for(let B of z){let M=H(B.value);if(M.refused)return M;if(B.opaque){let V=h0(B.raw,X,Q);if(V.refused)return V}}return I}if(X6.has(Z)){let K=$.findIndex((M)=>M.value==="-c"||M.value==="--command"||/^-[A-Za-z]*c$/.test(M.value)),B=K>=0?$[K+1]:void 0;return B?H(B.value):w0($,Q)}if(Z==="eval"||Z==="watch"){let K=$;if(Z==="watch"){let M=0;while(M<$.length&&$[M].value.startsWith("-")){if($[M].value==="--"){M++;break}if(["-n","--interval","-q","--equexit"].includes($[M].value))M++;M++}K=$.slice(M)}let B=H(K.map((M)=>M.value).join(" "));if(B.refused)return B;for(let M of K){let V=h0(M.raw,X,Q);if(V.refused)return V}return I}if(Z==="env")return H(RZ([...Y.map((K)=>jZ(K.text).value),...$.map((K)=>K.value)]));if(Z==="ssh"){let K=0;for(;K<$.length;K++){let V=$[K].value;if(!V.startsWith("-"))break;if(M6.has(V))K++}let B=$.slice(K+1);if(B[0]?.value==="--")B.shift();let M=B.map((V)=>V.value).join(" ");return M?H(M):I}if(Z==="xargs"){let K=0,B=!1;for(;K<$.length;K++){let M=$[K].value;if(M==="--"){K++;break}if(!M.startsWith("-"))break;if(/^-I|^-i|^--replace/.test(M))B=!0;if(B6.has(M))K++}return m0($.slice(K),{depth:X,appendsArgs:!B,debug:Q.debug})}if(Z==="find"){for(let K=0;K<$.length;K++){if(!["-exec","-execdir","-ok","-okdir"].includes($[K].value))continue;let B=K+1;while(B<$.length&&$[B].value!==";"&&$[B].value!=="+")B++;let M=m0($.slice(K+1,B),Q);if(M.refused)return M;K=B}return I}if(K6.has(Z))return w0($,Q);if(H6.get(Z)?.includes($[0]?.value??""))return w0($.slice(1),Q);return I}function m0(Z,J){if(Z.length===0)return I;let $=BZ(Z[0].value);if($==="gh")return Z0(Z.slice(1),J);if(J0.has($)){let z=s0(Z.slice(1));return z?o(z.value,J.depth+1,J.debug):I}return Q3($,Z[0],Z.slice(1),[],[],J)}function w0(Z,J){let $=Z.findIndex((z)=>!z.opaque&&BZ(z.value)==="gh"&&(z.value==="gh"||z.value.includes("/")));return $>=0?Z0(Z.slice($+1),J):I}function s0(Z){for(let J=0;J<Z.length;J++){let $=Z[J].value;if($==="--")return;if(!$.startsWith("-")&&!$.startsWith("+"))return;if($==="-c"||/^-[A-Za-z]+$/.test($)&&$.includes("c"))return Z.slice(J+1).find((z)=>!z.value.startsWith("-")||z.value==="-");if(/^[-+][A-Za-z]*[oO]$/.test($))J++}return}function j6(Z){let J=[],$=0;for(;;){let z=Z.indexOf("<<",$);if(z<0)break;if($=z+2,Z[z+2]==="<"||z>0&&Z[z-1]==="<"){$=z+3;continue}let Y=WZ(Z,z);if(!Y)continue;let Q=Z.lastIndexOf(`
|
|
26
26
|
`,z)+1,X=Z.indexOf(`
|
|
27
|
-
`,z);if(X<0)continue;let H=sZ(Z,X,[Y]),K=H<0?Z.slice(X+1):Z.slice(X+1,H),B=H<0?K:K.slice(0,Math.max(0,K.lastIndexOf(Y.delimiter))).replace(/\n$/,""),M=Z.slice(Q,z)+" HEREDOC_OPERATOR "+Z.slice(Y.end,X);J.push({body:B,runsBody:N6(M),quoted:Y.quoted})}return J}function N6(Z){let{segments:J}=d0(Z),$=J.findIndex((H)=>H.words.some((K)=>K.text==="HEREDOC_OPERATOR"));if($<0)return!1;let z=(H)=>{let K=h(H);if(K<0)return{verb:"",args:[]};let B=H.words.slice(K+1).filter((M)=>M.text!=="HEREDOC_OPERATOR").map((M)=>jZ(M.text));return{verb:BZ(jZ(H.words[K].text).value),args:B}},{verb:Y,args:Q}=z(J[$]);if(Y==="ssh"||l0(Y,Q))return!0;if((Y==="source"||Y===".")&&["/dev/stdin","/dev/fd/0","/proc/self/fd/0"].includes(Q[0]?.value??""))return!0;let X=J[$+1];if(Y==="cat"&&X&&Y3(X.sepBefore)){let H=z(X);return H.verb==="ssh"||l0(H.verb,H.args)}return!1}var F6=/(?:^|[^A-Za-z0-9_.-])gh(?:$|[^A-Za-z0-9_.-])/;function X3(){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:p0}}}var _6=new Set(["Bash","Monitor"]);function K3(Z){if(Z?.hook_event_name!=="PreToolUse"||!_6.has(Z.tool_name??""))return{continue:!0};let J=GZ(Z);if(!J.trim())return{continue:!0};try{return o(J).refused?X3():{continue:!0}}catch{return F6.test(J)?X3():{continue:!0}}}function T6(Z){if(Z!=="trash-guard"&&Z!=="workspace-repos-guard")throw Error("Invalid safety capability")}function H3(Z,J){T6(Z);let $=Z,z=JSON.parse(J);if(!z||Array.isArray(z)||z.hook_event_name!=="PreToolUse"||typeof z.tool_name!=="string"||!z.tool_input||typeof z.tool_input!=="object"||Array.isArray(z.tool_input)||typeof z.cwd!=="string"||!n0.isAbsolute(z.cwd))throw Error("Invalid safety input");if(z.tool_name==="Bash"&&typeof z.tool_input.command!=="string")throw Error("Invalid shell input");if(z.tool_name==="Monitor"&&z.tool_input.command!==void 0&&typeof z.tool_input.command!=="string")throw Error("Invalid monitor input");let Y=z.hasna_execution;if(Y!==void 0&&(!Y||Object.keys(Y).sort().join()!=="agent,schema"||Y.schema!=="hasna.hooks.execution.v1"||typeof Y.agent!=="string"||!/^[A-Za-z0-9][A-Za-z0-9._:@-]{0,127}$/.test(Y.agent)))throw Error("Invalid execution capability");let Q=Y===void 0?void 0:{runtime:process.execPath,home:z0.homedir(),path:process.env.PATH,agent:Y.agent};if(Q&&(!n0.isAbsolute(Q.runtime)||!Q.path))throw Error("Invalid bound execution context");if(["apply_patch","ApplyPatch","functions.apply_patch"].includes(z.tool_name)){if(z.tool_input.command!==void 0&&z.tool_input.patch!==void 0&&z.tool_input.command!==z.tool_input.patch)throw Error("Conflicting patch aliases");let F=z.tool_input.command??z.tool_input.patch;if(typeof F!=="string")throw Error("Invalid patch input");z.tool_input={...z.tool_input,command:F,patch:F}}let X=z.tool_name==="Monitor",H=z.tool_name==="Bash"||X&&typeof z.tool_input.command==="string",K=X&&H?{...z,tool_name:"Bash"}:z,B=(F)=>({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:F}}),M=c2(K).output,V=K3(K),G=H&&bZ(K.tool_input.command,{home:z0.homedir(),cwd:z.cwd}).handoffHits.length>0,U=$==="trash-guard"&&(!X||H)?P2(K,{home:z0.homedir(),cwd:z.cwd,findTrash:hZ,inspectTrash:qZ,execution:Q}):{continue:!0};if(X&&U.hookSpecificOutput?.permissionDecision==="allow")U=B("[trash-guard] A deletion inside a Monitor command is refused; run it with the Bash tool, where it is redirected into trash.");let j=M.decision==="block"?B(M.reason):V.hookSpecificOutput?V:G?B("[workspace-repos-guard] Deletion under a protected repository checkout is refused."):U;return JSON.stringify({verdict:"continue"in j?null:j})}var I6=2,C6="0.12.
|
|
27
|
+
`,z);if(X<0)continue;let H=sZ(Z,X,[Y]),K=H<0?Z.slice(X+1):Z.slice(X+1,H),B=H<0?K:K.slice(0,Math.max(0,K.lastIndexOf(Y.delimiter))).replace(/\n$/,""),M=Z.slice(Q,z)+" HEREDOC_OPERATOR "+Z.slice(Y.end,X);J.push({body:B,runsBody:N6(M),quoted:Y.quoted})}return J}function N6(Z){let{segments:J}=d0(Z),$=J.findIndex((H)=>H.words.some((K)=>K.text==="HEREDOC_OPERATOR"));if($<0)return!1;let z=(H)=>{let K=h(H);if(K<0)return{verb:"",args:[]};let B=H.words.slice(K+1).filter((M)=>M.text!=="HEREDOC_OPERATOR").map((M)=>jZ(M.text));return{verb:BZ(jZ(H.words[K].text).value),args:B}},{verb:Y,args:Q}=z(J[$]);if(Y==="ssh"||l0(Y,Q))return!0;if((Y==="source"||Y===".")&&["/dev/stdin","/dev/fd/0","/proc/self/fd/0"].includes(Q[0]?.value??""))return!0;let X=J[$+1];if(Y==="cat"&&X&&Y3(X.sepBefore)){let H=z(X);return H.verb==="ssh"||l0(H.verb,H.args)}return!1}var F6=/(?:^|[^A-Za-z0-9_.-])gh(?:$|[^A-Za-z0-9_.-])/;function X3(){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:p0}}}var _6=new Set(["Bash","Monitor"]);function K3(Z){if(Z?.hook_event_name!=="PreToolUse"||!_6.has(Z.tool_name??""))return{continue:!0};let J=GZ(Z);if(!J.trim())return{continue:!0};try{return o(J).refused?X3():{continue:!0}}catch{return F6.test(J)?X3():{continue:!0}}}function T6(Z){if(Z!=="trash-guard"&&Z!=="workspace-repos-guard")throw Error("Invalid safety capability")}function H3(Z,J){T6(Z);let $=Z,z=JSON.parse(J);if(!z||Array.isArray(z)||z.hook_event_name!=="PreToolUse"||typeof z.tool_name!=="string"||!z.tool_input||typeof z.tool_input!=="object"||Array.isArray(z.tool_input)||typeof z.cwd!=="string"||!n0.isAbsolute(z.cwd))throw Error("Invalid safety input");if(z.tool_name==="Bash"&&typeof z.tool_input.command!=="string")throw Error("Invalid shell input");if(z.tool_name==="Monitor"&&z.tool_input.command!==void 0&&typeof z.tool_input.command!=="string")throw Error("Invalid monitor input");let Y=z.hasna_execution;if(Y!==void 0&&(!Y||Object.keys(Y).sort().join()!=="agent,schema"||Y.schema!=="hasna.hooks.execution.v1"||typeof Y.agent!=="string"||!/^[A-Za-z0-9][A-Za-z0-9._:@-]{0,127}$/.test(Y.agent)))throw Error("Invalid execution capability");let Q=Y===void 0?void 0:{runtime:process.execPath,home:z0.homedir(),path:process.env.PATH,agent:Y.agent};if(Q&&(!n0.isAbsolute(Q.runtime)||!Q.path))throw Error("Invalid bound execution context");if(["apply_patch","ApplyPatch","functions.apply_patch"].includes(z.tool_name)){if(z.tool_input.command!==void 0&&z.tool_input.patch!==void 0&&z.tool_input.command!==z.tool_input.patch)throw Error("Conflicting patch aliases");let F=z.tool_input.command??z.tool_input.patch;if(typeof F!=="string")throw Error("Invalid patch input");z.tool_input={...z.tool_input,command:F,patch:F}}let X=z.tool_name==="Monitor",H=z.tool_name==="Bash"||X&&typeof z.tool_input.command==="string",K=X&&H?{...z,tool_name:"Bash"}:z,B=(F)=>({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:F}}),M=c2(K).output,V=K3(K),G=H&&bZ(K.tool_input.command,{home:z0.homedir(),cwd:z.cwd}).handoffHits.length>0,U=$==="trash-guard"&&(!X||H)?P2(K,{home:z0.homedir(),cwd:z.cwd,findTrash:hZ,inspectTrash:qZ,execution:Q}):{continue:!0};if(X&&U.hookSpecificOutput?.permissionDecision==="allow")U=B("[trash-guard] A deletion inside a Monitor command is refused; run it with the Bash tool, where it is redirected into trash.");let j=M.decision==="block"?B(M.reason):V.hookSpecificOutput?V:G?B("[workspace-repos-guard] Deletion under a protected repository checkout is refused."):U;return JSON.stringify({verdict:"continue"in j?null:j})}var I6=2,C6="0.12.17";function D6(Z,J){return H3(Z,J)}
|
package/dist/index.js
CHANGED
|
@@ -46440,7 +46440,7 @@ async function verifyNativeSafetyCommand(command, home = homedir8(), guard = "tr
|
|
|
46440
46440
|
}
|
|
46441
46441
|
|
|
46442
46442
|
// src/lib/codex-safety-check.ts
|
|
46443
|
-
var SUPPORTED_CODEX_SAFETY_VERSIONS = ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1", "codex-cli 0.161.0", "codex-cli 0.162.0"];
|
|
46443
|
+
var SUPPORTED_CODEX_SAFETY_VERSIONS = ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1", "codex-cli 0.161.0", "codex-cli 0.162.0", "codex-cli 0.162.1"];
|
|
46444
46444
|
var versions = new Set(SUPPORTED_CODEX_SAFETY_VERSIONS);
|
|
46445
46445
|
|
|
46446
46446
|
class CodexSafetyError extends Error {
|
|
@@ -2,7 +2,7 @@ import { type NativeSafetyName } from "./native-safety.js";
|
|
|
2
2
|
import { verifyNativeSafetyCommand } from "../native-safety.js";
|
|
3
3
|
/** Exact `codex --version` outputs whose app-server protocol was measured
|
|
4
4
|
* against the real native binary. Anything else refuses as native_unsupported. */
|
|
5
|
-
export declare const SUPPORTED_CODEX_SAFETY_VERSIONS: readonly ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1", "codex-cli 0.161.0", "codex-cli 0.162.0"];
|
|
5
|
+
export declare const SUPPORTED_CODEX_SAFETY_VERSIONS: readonly ["codex-cli 0.153.0", "codex-cli 0.154.0", "codex-cli 0.154.0-alpha.6.1", "codex-cli 0.155.0", "codex-cli 0.155.1", "codex-cli 0.156.1", "codex-cli 0.157.0", "codex-cli 0.157.1", "codex-cli 0.158.0", "codex-cli 0.159.0", "codex-cli 0.159.2", "codex-cli 0.159.3", "codex-cli 0.160.0", "codex-cli 0.160.1", "codex-cli 0.161.0", "codex-cli 0.162.0", "codex-cli 0.162.1"];
|
|
6
6
|
export type CodexSafetyCode = "native_unavailable" | "native_unsafe_executable" | "native_executable_required" | "native_unsupported" | "native_failed" | "native_discovery_failed" | "hooks_disabled" | "guard_missing" | "guard_ambiguous" | "guard_definition_invalid" | "guard_disabled" | "guard_untrusted" | "guard_changed" | "guard_failed";
|
|
7
7
|
export declare class CodexSafetyError extends Error {
|
|
8
8
|
readonly code: CodexSafetyCode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/hooks",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.17",
|
|
4
4
|
"description": "Open source hooks library for AI coding agents - Install safety, quality, and automation hooks with a single command",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"chalk": "^5.3.0",
|
|
89
89
|
"commander": "^12.1.0",
|
|
90
90
|
"conf": "^13.0.1",
|
|
91
|
-
"fast-uri": "3.1.
|
|
91
|
+
"fast-uri": "3.1.8",
|
|
92
92
|
"ink": "^5.0.1",
|
|
93
93
|
"ink-select-input": "^6.0.0",
|
|
94
94
|
"ink-spinner": "^5.0.0",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
},
|
|
101
101
|
"overrides": {
|
|
102
102
|
"@modelcontextprotocol/sdk": "1.31.0",
|
|
103
|
-
"fast-uri": "3.1.
|
|
103
|
+
"fast-uri": "3.1.8",
|
|
104
104
|
"proxy-addr": "2.0.8"
|
|
105
105
|
},
|
|
106
106
|
"engines": {
|