failproofai 1.0.0-beta.2 → 1.0.0-beta.3
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +6 -6
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +15 -15
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +15 -15
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +10 -10
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/reminder/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page.js +1 -1
- package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +15 -15
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +15 -15
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +10 -10
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +30 -18
- package/.next/standalone/.next/server/app/policies/page.js +2 -2
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0id_xf7._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__19120tr._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1fwl2mz._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1myjm-d._.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_17k9e3w.js +4 -4
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02r5bgf._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0e8sjqm._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0lkzqax._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1ath6v_._.js → [root-of-the-server]__0ls0gsr._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0qucxyj._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__170799-._.js → [root-of-the-server]__0spkm68._.js} +11 -11
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0u02miy._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1psjybo._.js → [root-of-the-server]__10s_z4l._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0114ewg._.js → [root-of-the-server]__1j4u3yd._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0nb0syg._.js → [root-of-the-server]__1ky3im9._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1zqz4v8._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_html-to-image_es_index_0oy_-36.js → node_modules_html-to-image_es_index_0jfts82.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1ezd2jf._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1tnuifj._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +6 -6
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +32 -20
- package/.next/standalone/.next/static/chunks/{3s7myk_co0gbh.js → 01h6lfjz1_oie.js} +1 -1
- package/.next/standalone/.next/static/chunks/{03fmihek9n986.js → 06zgzyh3wv1ig.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0fi645si-uiiq.js → 0a7k_x4rp_97z.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2sbelanzvxvv0.js → 0cvd6bcdwchc_.js} +1 -1
- package/.next/standalone/.next/static/chunks/{18rvdw5v72364.js → 13-obgukzg_ke.js} +1 -1
- package/.next/standalone/.next/static/chunks/16p68cybetr31.js +1 -0
- package/.next/standalone/.next/static/chunks/{2j94uwkb4s3qr.js → 1h0_yaoq5f3yx.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3vs4ay36tjds_.js → 29g8ykjk6sx_8.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3hp8ulqknybil.js → 2rqm-klet_gbl.js} +1 -1
- package/.next/standalone/.next/static/chunks/{31feojxhjyjpl.js → 2uvyh8y0naofj.js} +1 -1
- package/.next/standalone/.next/static/chunks/31coz11ia5vc4.js +1 -0
- package/.next/standalone/.next/static/chunks/3p-n_j80zlzi3.js +6 -0
- package/.next/standalone/.next/static/chunks/3zdwnnthucs_1.css +2 -0
- package/.next/standalone/.next/static/chunks/{turbopack-1lsv92x7klwrn.js → turbopack-3diub4ctvn1n0.js} +1 -1
- package/.next/standalone/Cargo.lock +1992 -198
- package/.next/standalone/Cargo.toml +1 -1
- package/.next/standalone/app/actions/get-active-pauses.ts +16 -0
- package/.next/standalone/app/components/pause-notices.tsx +111 -0
- package/.next/standalone/app/policies/hooks-client.tsx +81 -6
- package/.next/standalone/crates/CLOUD_POLICIES.md +136 -0
- package/.next/standalone/crates/failproofaid/Cargo.toml +7 -0
- package/.next/standalone/crates/failproofaid/src/cloud_client.rs +484 -0
- package/.next/standalone/crates/failproofaid/src/cloud_policies.rs +921 -0
- package/.next/standalone/crates/failproofaid/src/main.rs +452 -3
- package/.next/standalone/crates/failproofaid/src/paths.rs +29 -0
- package/.next/standalone/crates/fpai-collect/Cargo.toml +43 -0
- package/.next/standalone/crates/fpai-collect/src/config.rs +412 -0
- package/.next/standalone/crates/fpai-collect/src/cursor.rs +520 -0
- package/.next/standalone/crates/fpai-collect/src/delivery.rs +472 -0
- package/.next/standalone/crates/fpai-collect/src/filetail.rs +484 -0
- package/.next/standalone/crates/fpai-collect/src/health.rs +369 -0
- package/.next/standalone/crates/fpai-collect/src/lib.rs +34 -0
- package/.next/standalone/crates/fpai-collect/src/redact.rs +516 -0
- package/.next/standalone/crates/fpai-collect/src/sources/claude/mod.rs +279 -0
- package/.next/standalone/crates/fpai-collect/src/sources/claude/transform.rs +619 -0
- package/.next/standalone/crates/fpai-collect/src/sources/codex/mod.rs +156 -0
- package/.next/standalone/crates/fpai-collect/src/sources/codex/transform.rs +715 -0
- package/.next/standalone/crates/fpai-collect/src/sources/copilot/mod.rs +158 -0
- package/.next/standalone/crates/fpai-collect/src/sources/copilot/transform.rs +512 -0
- package/.next/standalone/crates/fpai-collect/src/sources/goose/mod.rs +511 -0
- package/.next/standalone/crates/fpai-collect/src/sources/goose/transform.rs +586 -0
- package/.next/standalone/crates/fpai-collect/src/sources/hermes/mod.rs +318 -0
- package/.next/standalone/crates/fpai-collect/src/sources/hermes/transform.rs +579 -0
- package/.next/standalone/crates/fpai-collect/src/sources/hooks/mod.rs +310 -0
- package/.next/standalone/crates/fpai-collect/src/sources/hooks/transform.rs +448 -0
- package/.next/standalone/crates/fpai-collect/src/sources/mod.rs +23 -0
- package/.next/standalone/crates/fpai-collect/src/sources/openclaw/mod.rs +176 -0
- package/.next/standalone/crates/fpai-collect/src/sources/openclaw/transform.rs +500 -0
- package/.next/standalone/crates/fpai-collect/src/sources/opencode/mod.rs +315 -0
- package/.next/standalone/crates/fpai-collect/src/sources/opencode/transform.rs +493 -0
- package/.next/standalone/crates/fpai-collect/src/sources/pi/mod.rs +201 -0
- package/.next/standalone/crates/fpai-collect/src/sources/pi/transform.rs +533 -0
- package/.next/standalone/crates/fpai-collect/src/spool.rs +458 -0
- package/.next/standalone/crates/fpai-collect/src/sqlitepoll.rs +387 -0
- package/.next/standalone/crates/fpai-collect/src/supervisor.rs +423 -0
- package/.next/standalone/crates/fpai-collect/src/uploader.rs +600 -0
- package/.next/standalone/crates/fpai-collect/tests/claude_source.rs +738 -0
- package/.next/standalone/crates/fpai-collect/tests/claude_subagents.rs +393 -0
- package/.next/standalone/crates/fpai-collect/tests/codex_source.rs +975 -0
- package/.next/standalone/crates/fpai-collect/tests/config.rs +286 -0
- package/.next/standalone/crates/fpai-collect/tests/copilot_source.rs +1019 -0
- package/.next/standalone/crates/fpai-collect/tests/delivery.rs +281 -0
- package/.next/standalone/crates/fpai-collect/tests/goose_source.rs +1008 -0
- package/.next/standalone/crates/fpai-collect/tests/hermes_source.rs +1129 -0
- package/.next/standalone/crates/fpai-collect/tests/hooks_source.rs +621 -0
- package/.next/standalone/crates/fpai-collect/tests/openclaw_source.rs +854 -0
- package/.next/standalone/crates/fpai-collect/tests/opencode_source.rs +1478 -0
- package/.next/standalone/crates/fpai-collect/tests/pi_source.rs +1191 -0
- package/.next/standalone/crates/fpai-collect/tests/supervisor.rs +290 -0
- package/.next/standalone/crates/fpai-collect/tests/uploader.rs +506 -0
- package/.next/standalone/package.json +2 -2
- package/.next/standalone/server.js +1 -1
- package/bin/failproofai.mjs +129 -0
- package/dist/cli.mjs +2195 -770
- package/dist/worker.mjs +365 -52
- package/package.json +2 -2
- package/src/hooks/builtin-policies.ts +139 -0
- package/src/hooks/cloud-connection.ts +205 -0
- package/src/hooks/cloud-enrollment-cli.ts +227 -0
- package/src/hooks/cloud-enrollment.ts +173 -0
- package/src/hooks/cloud-managed-policies.ts +138 -0
- package/src/hooks/collector-config.ts +226 -0
- package/src/hooks/configure-wizard.ts +221 -5
- package/src/hooks/custom-hooks-loader.ts +69 -25
- package/src/hooks/daemon-client.ts +18 -0
- package/src/hooks/handler.ts +144 -6
- package/src/hooks/hook-activity-store.ts +50 -0
- package/src/hooks/loader-utils.ts +6 -4
- package/src/hooks/policy-types.ts +35 -0
- package/src/hooks/session-pause-cli.ts +157 -0
- package/src/hooks/session-pause.ts +236 -0
- package/src/hooks/tui.ts +115 -0
- package/.next/standalone/.next/static/chunks/0zbxssxh53n-3.js +0 -1
- package/.next/standalone/.next/static/chunks/2pujpnfx4pws6.css +0 -2
- package/.next/standalone/.next/static/chunks/33u59vf_8xpd-.js +0 -1
- package/.next/standalone/.next/static/chunks/40k1_v4os4cw6.js +0 -6
- /package/.next/standalone/.next/static/{NWAjs0tHFyzk97gRGG09r → pM1veX5Llx4YKEaiFc8Sf}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{NWAjs0tHFyzk97gRGG09r → pM1veX5Llx4YKEaiFc8Sf}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{NWAjs0tHFyzk97gRGG09r → pM1veX5Llx4YKEaiFc8Sf}/_ssgManifest.js +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module.exports=[22712,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(35112),e=a.i(38246),f=a.i(52562),g=a.i(89027),h=a.i(64831);let i=(0,h.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);var j=a.i(85650);let k=(0,h.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),l=(0,h.default)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),m=(0,h.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),n=(0,h.default)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),o=(0,h.default)("shield-x",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]),p=(0,h.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var q=a.i(74215),r=a.i(65967),s=a.i(5050);let t=(0,s.createServerReference)("4014f2941eec49a0f08c0b3ffc3e8f522f0f640300",s.callServer,void 0,s.findSourceMapURL,"getHookActivityAction"),u=(0,s.createServerReference)("6024da1919a986e7a15341dda8a5d950f5bc37997a",s.callServer,void 0,s.findSourceMapURL,"searchHookActivityAction"),v=(0,s.createServerReference)("003f4932d705f3ccddde9242c1c2ac111092655144",s.callServer,void 0,s.findSourceMapURL,"getHooksConfigAction"),w=(0,s.createServerReference)("601e1e96939e2fa4db2b7189c61574d8a12ed25712",s.callServer,void 0,s.findSourceMapURL,"toggleCustomPolicyAction"),x=(0,s.createServerReference)("60ed5b6ca5f7a41ed8472ec0ef40de9f3a5b07634e",s.callServer,void 0,s.findSourceMapURL,"togglePolicyAction"),y=(0,s.createServerReference)("60f5bea305ec0ef502b80cbbb7069573b015d84a55",s.callServer,void 0,s.findSourceMapURL,"installHooksWebAction"),z=(0,s.createServerReference)("60dfe6223418da45139b3dc40b047ce001e04dc9f8",s.callServer,void 0,s.findSourceMapURL,"removeHooksWebAction"),A=(0,s.createServerReference)("606f7b86f5f2a2d93ac690fd6fe988e980d4562054",s.callServer,void 0,s.findSourceMapURL,"updatePolicyParamsAction");var B=a.i(6236),C=a.i(10765),D=a.i(90619),E=a.i(95947),F=a.i(87256);let G={claude:{PreToolUse:"block",UserPromptSubmit:"block",PermissionRequest:"block",Stop:"block",SubagentStop:"block",PreCompact:"block",PostToolBatch:"block",ConfigChange:"block",UserPromptExpansion:"block",TaskCreated:"block",TaskCompleted:"block",TeammateIdle:"block",Elicitation:"block",ElicitationResult:"block",PostToolUse:"observe",PostToolUseFailure:"observe",SessionStart:"observe",Setup:"observe",SubagentStart:"observe",SessionEnd:"observe",StopFailure:"observe",PermissionDenied:"observe",Notification:"observe",InstructionsLoaded:"observe",CwdChanged:"observe",FileChanged:"observe",PostCompact:"observe",WorktreeRemove:"observe"},codex:{PreToolUse:"block",PermissionRequest:"block",UserPromptSubmit:"block",Stop:"block",SubagentStop:"block",PostToolUse:"observe",SessionStart:"observe",SubagentStart:"observe",PreCompact:"observe",PostCompact:"observe"},copilot:{PreToolUse:"block",Stop:"block",SubagentStop:"block",UserPromptSubmit:"block",PermissionRequest:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",PostToolUseFailure:"observe",PreCompact:"observe",Notification:"observe"},cursor:{PreToolUse:"block",Stop:"block",UserPromptSubmit:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"},opencode:{PreToolUse:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",UserPromptSubmit:"observe",PermissionRequest:"observe"},pi:{PreToolUse:"block",UserPromptSubmit:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",Stop:"observe"},hermes:{PreToolUse:"block",PostToolUse:"observe",SubagentStop:"observe",SessionStart:"observe",SessionEnd:"observe"},openclaw:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",SubagentStop:"observe",PreCompact:"observe"},factory:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PreCompact:"block",PostToolUse:"observe",SubagentStop:"observe",SessionStart:"observe",SessionEnd:"observe",Notification:"observe"},devin:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PermissionRequest:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"},antigravity:{PreToolUse:"block",Stop:"block",PostToolUse:"observe",UserPromptSubmit:"observe"},goose:{PreToolUse:"block",UserPromptSubmit:"observe",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"}};var H=a.i(40695);function I({sessionId:a,transcriptPath:c,integration:d,cwd:f}){if(!a)return(0,b.jsx)("span",{className:"text-muted-foreground",children:"\\u2014"});let g=a?a.slice(0,8):"—",h="codex"===d||(c?.includes("/.codex/")??!1),i="copilot"===d||(c?.includes("/.copilot/session-state/")??!1),j="cursor"===d||(c?.includes("/.cursor/")??!1),k="opencode"===d||(c?.includes("/.local/share/opencode/")??!1)||(c?.includes("/.opencode/")??!1),l="pi"===d||(c?.includes("/.pi/")??!1);if(h||i||j||k||l){let c,d=f?(c=/^([A-Za-z]):[\\/](.*)$/.exec(f))?c[1]+"--"+c[2].replace(/[\\/]/g,"-"):f.replace(/[\\/]/g,"-"):h?"codex":i?"copilot":j?"cursor":k?"opencode":"pi";return(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(d)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g})}let m=c?function(a){let b=a.replace(/\\/g,"/").split("/").filter(Boolean);if(b.length<2)return null;let c=b[b.length-2];return!c||c.startsWith(".")?null:c}(c):null;return m?(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(m)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g}):(0,b.jsx)("span",{className:"text-muted-foreground font-mono",children:g})}function J({decision:a}){return"deny"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-red-500/10 text-red-400 border border-red-500/20",children:[(0,b.jsx)(o,{className:"h-3 w-3"}),"Deny"]}):"instruct"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[(0,b.jsx)(m,{className:"h-3 w-3"}),"Instruct"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(0,b.jsx)(n,{className:"h-3 w-3"}),"Allow"]})}function K({eventType:a}){return(0,b.jsx)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium bg-muted text-muted-foreground border border-border/50",children:a})}function L({integration:a}){if(!a)return null;let c=(0,F.getCliLabel)(a),d=(0,F.getCliBadgeClasses)(a);return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${d}`,title:`Agent CLI: ${c}`,children:c})}function M({mode:a}){let c="default"===a;return(0,b.jsx)("span",{title:a,className:`inline-block max-w-full truncate rounded px-1.5 py-0.5 align-middle text-[0.6rem] font-medium border ${c?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:a})}function N({ms:a}){return(0,b.jsx)("span",{className:`font-mono text-[0.7rem] ${a>500?"text-red-400":a>100?"text-amber-400":"text-muted-foreground"}`,children:a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`})}function O({text:a,field:d}){let[e,g]=(0,c.useState)(!1),{capture:h}=(0,C.usePostHog)(),i=async b=>{b.stopPropagation(),h("activity_copy_clicked",{field:d??"unknown"});try{await navigator.clipboard.writeText(a),g(!0),setTimeout(()=>g(!1),1500)}catch{let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b),g(!0),setTimeout(()=>g(!1),1500)}};return(0,b.jsx)("button",{onClick:i,className:"inline-flex items-center justify-center h-5 w-5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Copy",children:e?(0,b.jsx)(f.Check,{className:"h-3 w-3 text-emerald-400"}):(0,b.jsx)(j.Copy,{className:"h-3 w-3"})})}function P({value:a,onChange:c}){return(0,b.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5",children:[{label:"All",value:""},{label:"Allow",value:"allow"},{label:"Instruct",value:"instruct"},{label:"Deny",value:"deny"}].map(d=>(0,b.jsx)("button",{onClick:()=>c(d.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${a===d.value?"deny"===d.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===d.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===d.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.value))})}function Q({stats:a}){let c=a.totalEvents>0?a.denyCount/a.totalEvents*100:0,d=c.toFixed(c>=10?0:1),e=0===a.denyCount?"":c>=5?" is-deny":c>=2?" is-warn":"";return(0,b.jsxs)("div",{className:"stat-bar",role:"group","aria-label":"Activity stats",children:[(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"total events"}),(0,b.jsx)("span",{className:"value",children:a.totalEvents.toLocaleString()}),(0,b.jsx)("span",{className:"meta",children:"across all installed agents"})]}),(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"deny rate"}),(0,b.jsxs)("span",{className:`value${e}`,children:[d,"%"]}),(0,b.jsxs)("span",{className:"meta",children:[a.denyCount.toLocaleString()," of ",a.totalEvents.toLocaleString()," denied"]})]}),(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"top policy"}),(0,b.jsx)("span",{className:"value",style:{fontSize:16,fontWeight:500,color:a.topPolicy?"var(--accent-pink)":"var(--dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:a.topPolicy??void 0,children:a.topPolicy??"—"}),(0,b.jsx)("span",{className:"meta",children:"most-evaluated policy in scope"})]})]})}function R({item:a}){if("observe"!==function(a,b){if(!a||!b)return;let c=G[a];if(c)return c[b]}(a.integration,a.eventType))return null;let c=a.matchedPolicies??[];if(0===c.length)return null;let d=a.integration?(0,F.getCliLabel)(a.integration):"This CLI",e=c.map(a=>a.replace(/^(custom|\.failproofai-(project|user))\//,"")),f=1===e.length?e[0]:`${e.length} policies`,g="deny"===a.decision;return(0,b.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3 mt-1 flex items-start gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2.5 py-2",children:[(0,b.jsx)(p,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,b.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:g?"Not enforced.":"Ran, but cannot enforce here."})," ",(0,b.jsx)("span",{className:"font-mono",children:f})," ran on"," ",(0,b.jsx)("span",{className:"font-mono",children:a.eventType}),", but ",d," discards hook verdicts for this event",g?" — the action went ahead anyway.":", so a policy cannot block here."," ","Move the check to an event ",d," enforces on, such as"," ",(0,b.jsx)("span",{className:"font-mono",children:"PreToolUse"}),"."]})]})}function S({item:a}){return(0,b.jsx)("tr",{children:(0,b.jsx)("td",{colSpan:11,className:"px-0 py-0",children:(0,b.jsxs)("div",{className:"activity-detail animate-expand text-xs",children:[(0,b.jsxs)("span",{className:"activity-detail-eyebrow",children:[(0,b.jsx)("span",{"aria-hidden":"true",children:"▾"}),"event detail"]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-2",children:[(0,b.jsx)(R,{item:a}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.sessionId??"—"}),a.sessionId&&(0,b.jsx)(O,{text:a.sessionId,field:"session_id"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cwd??"—"}),a.cwd&&(0,b.jsx)(O,{text:a.cwd,field:"cwd"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,b.jsx)("span",{className:"font-mono text-foreground break-all",children:a.transcriptPath??"—"}),a.transcriptPath?.startsWith("opencode-db://")&&(0,b.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),a.policyNames&&a.policyNames.length>1&&(0,b.jsxs)("div",{style:{marginTop:8},children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.policyNames.join(", ")})]}),a.reason&&(0,b.jsxs)("div",{style:{marginTop:8},children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,b.jsx)("span",{className:"text-foreground",children:a.reason})]})]})})})}function T({hooksInstalled:a,onSwitchTab:d}){let{intervalSec:e}=(0,B.useAutoRefresh)(),{capture:f}=(0,C.usePostHog)(),h=(0,D.useUrlParams)(),i=(0,c.useRef)(!1),[j,k]=(0,c.useState)(()=>(0,E.paramToPage)(h.get("page"))),[m,n]=(0,c.useState)(null),[o,p]=(0,c.useState)(null),[q,s]=(0,c.useState)(()=>{let a=h.get("decision");return"allow"===a||"deny"===a||"instruct"===a?a:""}),[v,w]=(0,c.useState)(()=>h.get("event")??""),[x,y]=(0,c.useState)(()=>h.get("policy")??""),[z,A]=(0,c.useState)(()=>h.get("session")??""),[G,H]=(0,c.useState)(()=>{let a=h.get("cli");return(0,F.isKnownCli)(a)?a:""}),O=(0,c.useRef)(null),R=(0,c.useRef)(!0),U=(0,c.useRef)({filterDecision:q,filterEventType:v,filterPolicy:x,filterSessionId:z,filterCli:G});U.current={filterDecision:q,filterEventType:v,filterPolicy:x,filterSessionId:z,filterCli:G},(0,c.useEffect)(()=>{if(!i.current){i.current=!0;return}h.setAll({decision:q||void 0,event:v||void 0,policy:x||void 0,session:z||void 0,cli:G||void 0,page:(0,E.pageToParam)(j)})},[q,v,x,z,G,j]);let V=""!==q||""!==v||""!==x||""!==z||""!==G,W=(0,c.useCallback)(async a=>{try{let b,{filterDecision:c,filterEventType:d,filterPolicy:e,filterSessionId:f,filterCli:g}=U.current;b=""!==c||""!==d||""!==e||""!==f||""!==g?await u({decision:c||void 0,eventType:d||void 0,policyName:e||void 0,sessionId:f||void 0,integration:g||void 0},a):await t(a),n(b)}catch{}},[]);(0,c.useEffect)(()=>{W(j);let a=setInterval(()=>W(j),e>0?1e3*e:5e3);return()=>clearInterval(a)},[j,W,e]),(0,c.useEffect)(()=>(O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{if(k(1),p(null),W(1),R.current){R.current=!1;return}f("activity_filter_changed",{active_filter_count:+(""!==q)+ +(""!==v)+ +(""!==x)+ +(""!==z)+ +(""!==G),has_decision:""!==q,has_event_type:""!==v,has_policy:""!==x,has_session:""!==z,has_cli:""!==G,decision:q||null,event_type:v||null,cli:G||null})},300),()=>{O.current&&clearTimeout(O.current)}),[q,v,x,z,G]);let X=m?.entries??[],Y=m?.totalPages??1;return(0,b.jsxs)(b.Fragment,{children:[m?.stats&&m.stats.totalEvents>0&&(0,b.jsx)("div",{style:{marginBottom:18},children:(0,b.jsx)(Q,{stats:m.stats})}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"filter-bar",children:[(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"decision"}),(0,b.jsx)(P,{value:q,onChange:s})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"event"}),(0,b.jsxs)("select",{value:v,onChange:a=>w(a.target.value),className:"filter-input",children:[(0,b.jsx)("option",{value:"",children:"all events"}),(0,b.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,b.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,b.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,b.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,b.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,b.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"cli"}),(0,b.jsxs)("select",{value:G,onChange:a=>{let b=a.target.value;H(""===b||(0,F.isKnownCli)(b)?b:"")},className:"filter-input","aria-label":"Filter by CLI",children:[(0,b.jsx)("option",{value:"",children:"all clis"}),F.KNOWN_CLI_IDS.map(a=>(0,b.jsx)("option",{value:a,children:(0,F.getCliLabel)(a)},a))]})]}),(0,b.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,b.jsx)("span",{className:"filter-label",children:"policy"}),(0,b.jsx)("input",{type:"text",value:x,onChange:a=>y(a.target.value),placeholder:"filter by policy…",className:"filter-input"})]}),(0,b.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,b.jsx)("span",{className:"filter-label",children:"session"}),(0,b.jsx)("input",{type:"text",value:z,onChange:a=>A(a.target.value),placeholder:"filter by session…",className:"filter-input"})]}),V&&(0,b.jsx)("button",{type:"button",className:"filter-clear",onClick:()=>{s(""),w(""),H(""),y(""),A("")},"aria-label":"Clear all filters",children:"[ clear ]"})]}),0===X.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,b.jsx)(l,{className:"h-12 w-12 text-muted-foreground/30"}),!1===a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4 font-medium",children:"Policies are not installed"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:["Go to the"," ",(0,b.jsx)("button",{className:"underline hover:text-foreground transition-colors",onClick:()=>d?.("policies"),children:"Policies tab"})," ","and click ",(0,b.jsx)("span",{className:"font-mono bg-muted px-1 rounded",children:"Install"})," to enable policy monitoring."]})]}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4",children:V?"No matching activity.":"Waiting for hook events…"})]}):(0,b.jsx)("div",{className:"overflow-x-auto activity-table-wrap",children:(0,b.jsxs)("table",{className:"w-full text-xs activity-table",style:{tableLayout:"fixed"},children:[(0,b.jsxs)("colgroup",{children:[(0,b.jsx)("col",{style:{width:32}}),(0,b.jsx)("col",{style:{width:"7%"}}),(0,b.jsx)("col",{style:{width:"9%"}}),(0,b.jsx)("col",{style:{width:"12%"}}),(0,b.jsx)("col",{style:{width:"11%"}}),(0,b.jsx)("col",{style:{width:"9%"}}),(0,b.jsx)("col",{style:{width:"13%"}}),(0,b.jsx)("col",{style:{width:"12%"}}),(0,b.jsx)("col",{style:{width:"11%"}}),(0,b.jsx)("col",{style:{width:"8%"}}),(0,b.jsx)("col",{style:{width:"8%"}})]}),(0,b.jsx)("thead",{className:"activity-thead",children:(0,b.jsxs)("tr",{children:[(0,b.jsx)("th",{className:"px-4 py-3"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Time"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Decision"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Event"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"CLI"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Tool"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Policy"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Reason"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Mode"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Duration"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Session"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/30",children:X.map((a,d)=>{var e;let h,i="deny"===a.decision,j=o===d,k="instruct"===a.decision;return(0,b.jsxs)(c.default.Fragment,{children:[(0,b.jsxs)("tr",{onClick:()=>{p(a=>{let b=a===d?null:d,c=X[d];return f("activity_row_toggled",{expanded:null!==b,decision:c?.decision??null,policy_name:c?.policyName??null,event_type:c?.eventType??null}),b})},className:`activity-data-row cursor-pointer transition-colors ${i?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":k?"bg-amber-500/[0.03] hover:bg-amber-500/[0.07] border-l-2 border-l-amber-500/40":d%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${j?"bg-muted/20":""}`,children:[(0,b.jsx)("td",{className:"px-4 py-2",children:(0,b.jsx)(g.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${j?"rotate-0":"-rotate-90"}`})}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",title:new Date(a.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(e=a.timestamp,(h=Date.now()-e)<6e4?`${Math.max(1,Math.floor(h/1e3))}s ago`:h<36e5?`${Math.floor(h/6e4)}m ago`:h<864e5?`${Math.floor(h/36e5)}h ago`:`${Math.floor(h/864e5)}d ago`)}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(J,{decision:a.decision})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(K,{eventType:a.eventType})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(L,{integration:a.integration})}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.toolName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.policyNames&&a.policyNames.length>1?(0,b.jsxs)("span",{title:a.policyNames.join(", "),children:[a.policyNames[0],(0,b.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",a.policyNames.length-1]})]}):a.policyName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate",title:a.reason??"",children:a.reason??"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:a.permissionMode?(0,b.jsx)(M,{mode:a.permissionMode}):"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(N,{ms:a.durationMs})}),(0,b.jsx)("td",{className:"px-3 py-2",title:a.sessionId??"",children:(0,b.jsx)(I,{sessionId:a.sessionId,transcriptPath:a.transcriptPath,integration:a.integration,cwd:a.cwd})})]}),j&&(0,b.jsx)(S,{item:a})]},`${a.timestamp}-${d}`)})})]})}),(0,b.jsx)(r.default,{currentPage:j,totalPages:Y,onPageChange:a=>{f("activity_pagination_changed",{from_page:j,to_page:a,total_pages:Y}),k(a),p(null)}})]})]})}function U({enabled:a,onChange:c,disabled:d}){return(0,b.jsx)("button",{onClick:c,disabled:d,className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors disabled:opacity-40 ${a?"bg-emerald-500":"bg-muted-foreground/30"}`,"aria-label":a?"Disable policy":"Enable policy",children:(0,b.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform ${a?"translate-x-3.5":"translate-x-0.5"}`})})}function V({policy:a,onClose:d,onSave:e}){let f=a.params??{},g=a.currentParams??{},[h,i]=(0,c.useState)(()=>{let a={};for(let[b,c]of Object.entries(f)){let d=b in g?g[b]:c.default;a[b]=d}return a});(0,c.useEffect)(()=>{let a=a=>{"Escape"===a.key&&d()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[d]);let j=(a,b)=>{i(c=>({...c,[a]:b}))};return(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&d()},children:(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-sm font-mono font-semibold text-foreground",children:a.name}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]}),(0,b.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,b.jsx)(q.X,{className:"h-4 w-4"})})]}),(0,b.jsx)("div",{className:"overflow-y-auto flex-1 px-4 py-4 space-y-4",children:Object.entries(f).map(([a,c])=>(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1 font-mono",children:a}),(0,b.jsx)("p",{className:"text-[0.65rem] text-muted-foreground mb-1.5",children:c.description}),((a,c)=>{let d=h[a];if("boolean"===c.type)return(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,b.jsx)("input",{type:"checkbox",checked:!!d,onChange:b=>j(a,b.target.checked),className:"rounded border-border"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:c.description})]});if("number"===c.type)return(0,b.jsx)("input",{type:"number",value:"number"==typeof d?d:"",onChange:b=>j(a,Number(b.target.value)),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"});if("string[]"===c.type){let c=Array.isArray(d)?d.join("\n"):"";return(0,b.jsx)("textarea",{value:c,onChange:b=>j(a,b.target.value.split("\n").filter(a=>""!==a.trim())),rows:4,placeholder:"One entry per line",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-2 focus:ring-primary/40 resize-y"})}if("pattern[]"===c.type){let c=Array.isArray(d)?d:[];return(0,b.jsxs)("div",{className:"space-y-1.5",children:[c.map((d,e)=>(0,b.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,b.jsx)("input",{type:"text",value:d.regex,onChange:b=>{let d=[...c];d[e]={...d[e],regex:b.target.value},j(a,d)},placeholder:"regex",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs font-mono focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("input",{type:"text",value:d.label,onChange:b=>{let d=[...c];d[e]={...d[e],label:b.target.value},j(a,d)},placeholder:"label",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("button",{onClick:()=>j(a,c.filter((a,b)=>b!==e)),className:"text-muted-foreground/50 hover:text-destructive transition-colors",children:(0,b.jsx)(q.X,{className:"h-3.5 w-3.5"})})]},e)),(0,b.jsx)("button",{onClick:()=>j(a,[...c,{regex:"",label:""}]),className:"text-xs text-primary hover:underline",children:"+ Add pattern"})]})}return(0,b.jsx)("input",{type:"text",value:"string"==typeof d?d:"",onChange:b=>j(a,b.target.value),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"})})(a,c)]},a))}),(0,b.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,b.jsx)(H.Button,{variant:"outline",size:"sm",onClick:d,className:"h-7 text-xs",children:"Cancel"}),(0,b.jsx)(H.Button,{size:"sm",onClick:()=>e(h),className:"h-7 text-xs",children:"Save"})]})]})})}function W({message:a,onDismiss:c,onInstall:e,isPending:f}){let{capture:g}=(0,C.usePostHog)();return(0,d.createPortal)((0,b.jsxs)("div",{className:"fixed top-4 right-4 z-[9999] w-full max-w-sm",style:{animation:"slideInFromRight 0.25s ease-out"},children:[(0,b.jsx)("style",{children:`
|
|
1
|
+
module.exports=[22712,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(35112),e=a.i(38246),f=a.i(52562),g=a.i(89027),h=a.i(64831);let i=(0,h.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);var j=a.i(85650);let k=(0,h.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),l=(0,h.default)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),m=(0,h.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),n=(0,h.default)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),o=(0,h.default)("shield-x",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]),p=(0,h.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var q=a.i(74215),r=a.i(65967),s=a.i(5050);let t=(0,s.createServerReference)("40d39630f268c13b700211aa5e94c433f14c783f7c",s.callServer,void 0,s.findSourceMapURL,"getHookActivityAction"),u=(0,s.createServerReference)("604d1650a11c6c1416a221c663f1f65a90945eb44a",s.callServer,void 0,s.findSourceMapURL,"searchHookActivityAction"),v=(0,s.createServerReference)("0093c4cafecb8a0b4362f6222714701a1034c618aa",s.callServer,void 0,s.findSourceMapURL,"getActivePausesAction");function w({pauses:a,now:d}){let[e,f]=(0,c.useState)(()=>Date.now());(0,c.useEffect)(()=>{let a=setInterval(()=>f(Date.now()),3e4);return()=>clearInterval(a)},[]);let g=d??e,h=a.filter(a=>a.expiresAt>g);if(0===h.length)return null;let i=h.reduce((a,b)=>a.expiresAt<b.expiresAt?a:b);return(0,b.jsxs)("div",{role:"status",className:"mb-4 flex items-start gap-2.5 rounded border border-amber-500/40 bg-amber-500/[0.07] px-3 py-2.5",children:[(0,b.jsx)(m,{className:"h-4 w-4 shrink-0 text-amber-500 mt-0.5","aria-hidden":"true"}),(0,b.jsxs)("div",{className:"text-xs leading-relaxed",children:[(0,b.jsxs)("p",{className:"font-medium text-foreground",children:["Enforcement is paused for ",h.length," session",1===h.length?"":"s"," —"," ",function(a){if(a<=0)return"expiring now";if(a<6e4)return"under a minute";let b=Math.round(a/6e4);if(b<60)return`${b}m`;let c=Math.floor(b/60),d=b%60;return 0===d?`${c}h`:`${c}h${d}m`}(i.expiresAt-g)," left",h.length>1?" on the next to expire":"","."]}),(0,b.jsxs)("p",{className:"text-muted-foreground mt-0.5",children:["Builtin, custom and convention policies are suspended for"," ",1===h.length?"that session":"those sessions","; cloud-managed policies keep enforcing. It lifts on its own — or run"," ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:"failproofai config --resume"}),"."]})]})]})}function x(){return(0,b.jsx)("span",{title:"Enforcement was paused for this session — local policies did not run",className:"ml-1.5 inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium uppercase tracking-wide border border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-500",children:"paused"})}function y({item:a}){if(!a.pausedBy)return null;let c="number"==typeof a.pauseExpiresAt?new Date(a.pauseExpiresAt).toLocaleTimeString():null;return(0,b.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3 mt-1 flex items-start gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2.5 py-2",children:[(0,b.jsx)(p,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,b.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Not enforced — paused."})," Enforcement was suspended for this session","cli"===a.pausedBy?" from the CLI":` by ${a.pausedBy}`,c?`, lifting at ${c}`:"",". Builtin, custom and convention policies did not run for this event; cloud-managed policies did."]})]})}let z=(0,s.createServerReference)("00fa0ccbbb18ab82247615ac383d7d2f753d2058d3",s.callServer,void 0,s.findSourceMapURL,"getHooksConfigAction"),A=(0,s.createServerReference)("6052a01cdbc4a3d935a7765684aad10b1015734ee3",s.callServer,void 0,s.findSourceMapURL,"toggleCustomPolicyAction"),B=(0,s.createServerReference)("605517d77b3aed8a6c8f4fb46eeaea66ad744b3f13",s.callServer,void 0,s.findSourceMapURL,"togglePolicyAction"),C=(0,s.createServerReference)("6047add3505cca1a09c8c2ff92f05b3634307a8ae5",s.callServer,void 0,s.findSourceMapURL,"installHooksWebAction"),D=(0,s.createServerReference)("6020c4aff1ec462cd5e1c2091a0f823c2017a00b64",s.callServer,void 0,s.findSourceMapURL,"removeHooksWebAction"),E=(0,s.createServerReference)("60dc2c91a82990a38e9c61fa72ae6c6219d4a1eccd",s.callServer,void 0,s.findSourceMapURL,"updatePolicyParamsAction");var F=a.i(6236),G=a.i(10765),H=a.i(90619),I=a.i(95947),J=a.i(87256);let K={claude:{PreToolUse:"block",UserPromptSubmit:"block",PermissionRequest:"block",Stop:"block",SubagentStop:"block",PreCompact:"block",PostToolBatch:"block",ConfigChange:"block",UserPromptExpansion:"block",TaskCreated:"block",TaskCompleted:"block",TeammateIdle:"block",Elicitation:"block",ElicitationResult:"block",PostToolUse:"observe",PostToolUseFailure:"observe",SessionStart:"observe",Setup:"observe",SubagentStart:"observe",SessionEnd:"observe",StopFailure:"observe",PermissionDenied:"observe",Notification:"observe",InstructionsLoaded:"observe",CwdChanged:"observe",FileChanged:"observe",PostCompact:"observe",WorktreeRemove:"observe"},codex:{PreToolUse:"block",PermissionRequest:"block",UserPromptSubmit:"block",Stop:"block",SubagentStop:"block",PostToolUse:"observe",SessionStart:"observe",SubagentStart:"observe",PreCompact:"observe",PostCompact:"observe"},copilot:{PreToolUse:"block",Stop:"block",SubagentStop:"block",UserPromptSubmit:"block",PermissionRequest:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",PostToolUseFailure:"observe",PreCompact:"observe",Notification:"observe"},cursor:{PreToolUse:"block",Stop:"block",UserPromptSubmit:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"},opencode:{PreToolUse:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",UserPromptSubmit:"observe",PermissionRequest:"observe"},pi:{PreToolUse:"block",UserPromptSubmit:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",Stop:"observe"},hermes:{PreToolUse:"block",PostToolUse:"observe",SubagentStop:"observe",SessionStart:"observe",SessionEnd:"observe"},openclaw:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",SubagentStop:"observe",PreCompact:"observe"},factory:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PreCompact:"block",PostToolUse:"observe",SubagentStop:"observe",SessionStart:"observe",SessionEnd:"observe",Notification:"observe"},devin:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PermissionRequest:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"},antigravity:{PreToolUse:"block",Stop:"block",PostToolUse:"observe",UserPromptSubmit:"observe"},goose:{PreToolUse:"block",UserPromptSubmit:"observe",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"}};var L=a.i(40695);function M({sessionId:a,transcriptPath:c,integration:d,cwd:f}){if(!a)return(0,b.jsx)("span",{className:"text-muted-foreground",children:"\\u2014"});let g=a?a.slice(0,8):"—",h="codex"===d||(c?.includes("/.codex/")??!1),i="copilot"===d||(c?.includes("/.copilot/session-state/")??!1),j="cursor"===d||(c?.includes("/.cursor/")??!1),k="opencode"===d||(c?.includes("/.local/share/opencode/")??!1)||(c?.includes("/.opencode/")??!1),l="pi"===d||(c?.includes("/.pi/")??!1);if(h||i||j||k||l){let c,d=f?(c=/^([A-Za-z]):[\\/](.*)$/.exec(f))?c[1]+"--"+c[2].replace(/[\\/]/g,"-"):f.replace(/[\\/]/g,"-"):h?"codex":i?"copilot":j?"cursor":k?"opencode":"pi";return(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(d)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g})}let m=c?function(a){let b=a.replace(/\\/g,"/").split("/").filter(Boolean);if(b.length<2)return null;let c=b[b.length-2];return!c||c.startsWith(".")?null:c}(c):null;return m?(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(m)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g}):(0,b.jsx)("span",{className:"text-muted-foreground font-mono",children:g})}function N({decision:a}){return"deny"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-red-500/10 text-red-400 border border-red-500/20",children:[(0,b.jsx)(o,{className:"h-3 w-3"}),"Deny"]}):"instruct"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[(0,b.jsx)(m,{className:"h-3 w-3"}),"Instruct"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(0,b.jsx)(n,{className:"h-3 w-3"}),"Allow"]})}function O({eventType:a}){return(0,b.jsx)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium bg-muted text-muted-foreground border border-border/50",children:a})}function P({integration:a}){if(!a)return null;let c=(0,J.getCliLabel)(a),d=(0,J.getCliBadgeClasses)(a);return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${d}`,title:`Agent CLI: ${c}`,children:c})}function Q({mode:a}){let c="default"===a;return(0,b.jsx)("span",{title:a,className:`inline-block max-w-full truncate rounded px-1.5 py-0.5 align-middle text-[0.6rem] font-medium border ${c?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:a})}function R({ms:a}){return(0,b.jsx)("span",{className:`font-mono text-[0.7rem] ${a>500?"text-red-400":a>100?"text-amber-400":"text-muted-foreground"}`,children:a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`})}function S({text:a,field:d}){let[e,g]=(0,c.useState)(!1),{capture:h}=(0,G.usePostHog)(),i=async b=>{b.stopPropagation(),h("activity_copy_clicked",{field:d??"unknown"});try{await navigator.clipboard.writeText(a),g(!0),setTimeout(()=>g(!1),1500)}catch{let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b),g(!0),setTimeout(()=>g(!1),1500)}};return(0,b.jsx)("button",{onClick:i,className:"inline-flex items-center justify-center h-5 w-5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Copy",children:e?(0,b.jsx)(f.Check,{className:"h-3 w-3 text-emerald-400"}):(0,b.jsx)(j.Copy,{className:"h-3 w-3"})})}function T({value:a,onChange:c}){return(0,b.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5",children:[{label:"All",value:""},{label:"Allow",value:"allow"},{label:"Instruct",value:"instruct"},{label:"Deny",value:"deny"}].map(d=>(0,b.jsx)("button",{onClick:()=>c(d.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${a===d.value?"deny"===d.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===d.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===d.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.value))})}function U({stats:a}){let c=a.totalEvents>0?a.denyCount/a.totalEvents*100:0,d=c.toFixed(c>=10?0:1),e=0===a.denyCount?"":c>=5?" is-deny":c>=2?" is-warn":"";return(0,b.jsxs)("div",{className:"stat-bar",role:"group","aria-label":"Activity stats",children:[(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"total events"}),(0,b.jsx)("span",{className:"value",children:a.totalEvents.toLocaleString()}),(0,b.jsx)("span",{className:"meta",children:"across all installed agents"})]}),(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"deny rate"}),(0,b.jsxs)("span",{className:`value${e}`,children:[d,"%"]}),(0,b.jsxs)("span",{className:"meta",children:[a.denyCount.toLocaleString()," of ",a.totalEvents.toLocaleString()," denied"]})]}),(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"top policy"}),(0,b.jsx)("span",{className:"value",style:{fontSize:16,fontWeight:500,color:a.topPolicy?"var(--accent-pink)":"var(--dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:a.topPolicy??void 0,children:a.topPolicy??"—"}),(0,b.jsx)("span",{className:"meta",children:"most-evaluated policy in scope"})]})]})}function V({item:a}){if("observe"!==function(a,b){if(!a||!b)return;let c=K[a];if(c)return c[b]}(a.integration,a.eventType))return null;let c=a.matchedPolicies??[];if(0===c.length)return null;let d=a.integration?(0,J.getCliLabel)(a.integration):"This CLI",e=c.map(a=>a.replace(/^(custom|\.failproofai-(project|user))\//,"")),f=1===e.length?e[0]:`${e.length} policies`,g="deny"===a.decision;return(0,b.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3 mt-1 flex items-start gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2.5 py-2",children:[(0,b.jsx)(p,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,b.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:g?"Not enforced.":"Ran, but cannot enforce here."})," ",(0,b.jsx)("span",{className:"font-mono",children:f})," ran on"," ",(0,b.jsx)("span",{className:"font-mono",children:a.eventType}),", but ",d," discards hook verdicts for this event",g?" — the action went ahead anyway.":", so a policy cannot block here."," ","Move the check to an event ",d," enforces on, such as"," ",(0,b.jsx)("span",{className:"font-mono",children:"PreToolUse"}),"."]})]})}function W({item:a}){return(0,b.jsx)("tr",{children:(0,b.jsx)("td",{colSpan:11,className:"px-0 py-0",children:(0,b.jsxs)("div",{className:"activity-detail animate-expand text-xs",children:[(0,b.jsxs)("span",{className:"activity-detail-eyebrow",children:[(0,b.jsx)("span",{"aria-hidden":"true",children:"▾"}),"event detail"]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-2",children:[(0,b.jsx)(y,{item:a}),(0,b.jsx)(V,{item:a}),a.policySource&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Decided by: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:"cloud"===a.policySource&&a.cloudPolicyId?`cloud \xb7 ${a.cloudPolicyId} rev ${a.cloudRevision}`:a.policySource})]}),void 0!==a.cloudGeneration&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Cloud generation: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cloudGeneration})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.sessionId??"—"}),a.sessionId&&(0,b.jsx)(S,{text:a.sessionId,field:"session_id"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cwd??"—"}),a.cwd&&(0,b.jsx)(S,{text:a.cwd,field:"cwd"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,b.jsx)("span",{className:"font-mono text-foreground break-all",children:a.transcriptPath??"—"}),a.transcriptPath?.startsWith("opencode-db://")&&(0,b.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),a.policyNames&&a.policyNames.length>1&&(0,b.jsxs)("div",{style:{marginTop:8},children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.policyNames.join(", ")})]}),a.reason&&(0,b.jsxs)("div",{style:{marginTop:8},children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,b.jsx)("span",{className:"text-foreground",children:a.reason})]})]})})})}function X({hooksInstalled:a,onSwitchTab:d}){let{intervalSec:e}=(0,F.useAutoRefresh)(),{capture:f}=(0,G.usePostHog)(),h=(0,H.useUrlParams)(),i=(0,c.useRef)(!1),[j,k]=(0,c.useState)(()=>(0,I.paramToPage)(h.get("page"))),[m,n]=(0,c.useState)(null),[o,p]=(0,c.useState)([]),[q,s]=(0,c.useState)(null),[y,z]=(0,c.useState)(()=>{let a=h.get("decision");return"allow"===a||"deny"===a||"instruct"===a?a:""}),[A,B]=(0,c.useState)(()=>h.get("event")??""),[C,D]=(0,c.useState)(()=>h.get("policy")??""),[E,K]=(0,c.useState)(()=>h.get("session")??""),[L,S]=(0,c.useState)(()=>{let a=h.get("cli");return(0,J.isKnownCli)(a)?a:""}),[V,Y]=(0,c.useState)(()=>{let a=h.get("source");return"builtin"===a||"custom"===a||"convention"===a||"cloud"===a?a:""}),Z=(0,c.useRef)(null),$=(0,c.useRef)(!0),_=(0,c.useRef)({filterDecision:y,filterEventType:A,filterPolicy:C,filterSessionId:E,filterCli:L,filterSource:V});_.current={filterDecision:y,filterEventType:A,filterPolicy:C,filterSessionId:E,filterCli:L,filterSource:V},(0,c.useEffect)(()=>{if(!i.current){i.current=!0;return}h.setAll({decision:y||void 0,event:A||void 0,policy:C||void 0,session:E||void 0,cli:L||void 0,source:V||void 0,page:(0,I.pageToParam)(j)})},[y,A,C,E,L,V,j]);let aa=""!==y||""!==A||""!==C||""!==E||""!==L||""!==V,ab=(0,c.useCallback)(async a=>{try{let b,{filterDecision:c,filterEventType:d,filterPolicy:e,filterSessionId:f,filterCli:g,filterSource:h}=_.current;b=""!==c||""!==d||""!==e||""!==f||""!==g||""!==h?await u({decision:c||void 0,eventType:d||void 0,policyName:e||void 0,sessionId:f||void 0,integration:g||void 0,source:h||void 0},a):await t(a),n(b)}catch{}},[]);(0,c.useEffect)(()=>{ab(j);let a=setInterval(()=>ab(j),e>0?1e3*e:5e3);return()=>clearInterval(a)},[j,ab,e]),(0,c.useEffect)(()=>{let a=!1,b=()=>{v().then(b=>{a||p(b)}).catch(()=>{})};b();let c=setInterval(b,e>0?1e3*e:5e3);return()=>{a=!0,clearInterval(c)}},[e]),(0,c.useEffect)(()=>(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{if(k(1),s(null),ab(1),$.current){$.current=!1;return}f("activity_filter_changed",{active_filter_count:+(""!==y)+ +(""!==A)+ +(""!==C)+ +(""!==E)+ +(""!==L),has_decision:""!==y,has_event_type:""!==A,has_policy:""!==C,has_session:""!==E,has_cli:""!==L,decision:y||null,event_type:A||null,cli:L||null})},300),()=>{Z.current&&clearTimeout(Z.current)}),[y,A,C,E,L]);let ac=m?.entries??[],ad=m?.totalPages??1;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(w,{pauses:o}),m?.stats&&m.stats.totalEvents>0&&(0,b.jsx)("div",{style:{marginBottom:18},children:(0,b.jsx)(U,{stats:m.stats})}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"filter-bar",children:[(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"decision"}),(0,b.jsx)(T,{value:y,onChange:z})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"event"}),(0,b.jsxs)("select",{value:A,onChange:a=>B(a.target.value),className:"filter-input",children:[(0,b.jsx)("option",{value:"",children:"all events"}),(0,b.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,b.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,b.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,b.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,b.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,b.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"source"}),(0,b.jsxs)("select",{value:V,onChange:a=>{let b=a.target.value;Y("builtin"===b||"custom"===b||"convention"===b||"cloud"===b?b:"")},className:"filter-input","aria-label":"Filter by policy source",children:[(0,b.jsx)("option",{value:"",children:"all sources"}),(0,b.jsx)("option",{value:"builtin",children:"builtin"}),(0,b.jsx)("option",{value:"custom",children:"custom"}),(0,b.jsx)("option",{value:"convention",children:"convention"}),(0,b.jsx)("option",{value:"cloud",children:"cloud"})]})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"cli"}),(0,b.jsxs)("select",{value:L,onChange:a=>{let b=a.target.value;S(""===b||(0,J.isKnownCli)(b)?b:"")},className:"filter-input","aria-label":"Filter by CLI",children:[(0,b.jsx)("option",{value:"",children:"all clis"}),J.KNOWN_CLI_IDS.map(a=>(0,b.jsx)("option",{value:a,children:(0,J.getCliLabel)(a)},a))]})]}),(0,b.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,b.jsx)("span",{className:"filter-label",children:"policy"}),(0,b.jsx)("input",{type:"text",value:C,onChange:a=>D(a.target.value),placeholder:"filter by policy…",className:"filter-input"})]}),(0,b.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,b.jsx)("span",{className:"filter-label",children:"session"}),(0,b.jsx)("input",{type:"text",value:E,onChange:a=>K(a.target.value),placeholder:"filter by session…",className:"filter-input"})]}),aa&&(0,b.jsx)("button",{type:"button",className:"filter-clear",onClick:()=>{z(""),B(""),S(""),D(""),K(""),Y("")},"aria-label":"Clear all filters",children:"[ clear ]"})]}),0===ac.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,b.jsx)(l,{className:"h-12 w-12 text-muted-foreground/30"}),!1===a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4 font-medium",children:"Policies are not installed"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:["Go to the"," ",(0,b.jsx)("button",{className:"underline hover:text-foreground transition-colors",onClick:()=>d?.("policies"),children:"Policies tab"})," ","and click ",(0,b.jsx)("span",{className:"font-mono bg-muted px-1 rounded",children:"Install"})," to enable policy monitoring."]})]}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4",children:aa?"No matching activity.":"Waiting for hook events…"})]}):(0,b.jsx)("div",{className:"overflow-x-auto activity-table-wrap",children:(0,b.jsxs)("table",{className:"w-full text-xs activity-table",style:{tableLayout:"fixed"},children:[(0,b.jsxs)("colgroup",{children:[(0,b.jsx)("col",{style:{width:32}}),(0,b.jsx)("col",{style:{width:"7%"}}),(0,b.jsx)("col",{style:{width:"9%"}}),(0,b.jsx)("col",{style:{width:"12%"}}),(0,b.jsx)("col",{style:{width:"11%"}}),(0,b.jsx)("col",{style:{width:"9%"}}),(0,b.jsx)("col",{style:{width:"13%"}}),(0,b.jsx)("col",{style:{width:"12%"}}),(0,b.jsx)("col",{style:{width:"11%"}}),(0,b.jsx)("col",{style:{width:"8%"}}),(0,b.jsx)("col",{style:{width:"8%"}})]}),(0,b.jsx)("thead",{className:"activity-thead",children:(0,b.jsxs)("tr",{children:[(0,b.jsx)("th",{className:"px-4 py-3"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Time"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Decision"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Event"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"CLI"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Tool"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Policy"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Reason"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Mode"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Duration"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Session"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/30",children:ac.map((a,d)=>{var e;let h,i="deny"===a.decision,j=q===d,k="instruct"===a.decision;return(0,b.jsxs)(c.default.Fragment,{children:[(0,b.jsxs)("tr",{onClick:()=>{s(a=>{let b=a===d?null:d,c=ac[d];return f("activity_row_toggled",{expanded:null!==b,decision:c?.decision??null,policy_name:c?.policyName??null,event_type:c?.eventType??null}),b})},className:`activity-data-row cursor-pointer transition-colors ${i?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":k?"bg-amber-500/[0.03] hover:bg-amber-500/[0.07] border-l-2 border-l-amber-500/40":d%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${j?"bg-muted/20":""}`,children:[(0,b.jsx)("td",{className:"px-4 py-2",children:(0,b.jsx)(g.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${j?"rotate-0":"-rotate-90"}`})}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",title:new Date(a.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(e=a.timestamp,(h=Date.now()-e)<6e4?`${Math.max(1,Math.floor(h/1e3))}s ago`:h<36e5?`${Math.floor(h/6e4)}m ago`:h<864e5?`${Math.floor(h/36e5)}h ago`:`${Math.floor(h/864e5)}d ago`)}),(0,b.jsxs)("td",{className:"px-3 py-2",children:[(0,b.jsx)(N,{decision:a.decision}),a.pausedBy&&(0,b.jsx)(x,{})]}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(O,{eventType:a.eventType})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(P,{integration:a.integration})}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.toolName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.policyNames&&a.policyNames.length>1?(0,b.jsxs)("span",{title:a.policyNames.join(", "),children:[a.policyNames[0],(0,b.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",a.policyNames.length-1]})]}):a.policyName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate",title:a.reason??"",children:a.reason??"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:a.permissionMode?(0,b.jsx)(Q,{mode:a.permissionMode}):"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(R,{ms:a.durationMs})}),(0,b.jsx)("td",{className:"px-3 py-2",title:a.sessionId??"",children:(0,b.jsx)(M,{sessionId:a.sessionId,transcriptPath:a.transcriptPath,integration:a.integration,cwd:a.cwd})})]}),j&&(0,b.jsx)(W,{item:a})]},`${a.timestamp}-${d}`)})})]})}),(0,b.jsx)(r.default,{currentPage:j,totalPages:ad,onPageChange:a=>{f("activity_pagination_changed",{from_page:j,to_page:a,total_pages:ad}),k(a),s(null)}})]})]})}function Y({enabled:a,onChange:c,disabled:d}){return(0,b.jsx)("button",{onClick:c,disabled:d,className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors disabled:opacity-40 ${a?"bg-emerald-500":"bg-muted-foreground/30"}`,"aria-label":a?"Disable policy":"Enable policy",children:(0,b.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform ${a?"translate-x-3.5":"translate-x-0.5"}`})})}function Z({policy:a,onClose:d,onSave:e}){let f=a.params??{},g=a.currentParams??{},[h,i]=(0,c.useState)(()=>{let a={};for(let[b,c]of Object.entries(f)){let d=b in g?g[b]:c.default;a[b]=d}return a});(0,c.useEffect)(()=>{let a=a=>{"Escape"===a.key&&d()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[d]);let j=(a,b)=>{i(c=>({...c,[a]:b}))};return(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&d()},children:(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-sm font-mono font-semibold text-foreground",children:a.name}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]}),(0,b.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,b.jsx)(q.X,{className:"h-4 w-4"})})]}),(0,b.jsx)("div",{className:"overflow-y-auto flex-1 px-4 py-4 space-y-4",children:Object.entries(f).map(([a,c])=>(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1 font-mono",children:a}),(0,b.jsx)("p",{className:"text-[0.65rem] text-muted-foreground mb-1.5",children:c.description}),((a,c)=>{let d=h[a];if("boolean"===c.type)return(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,b.jsx)("input",{type:"checkbox",checked:!!d,onChange:b=>j(a,b.target.checked),className:"rounded border-border"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:c.description})]});if("number"===c.type)return(0,b.jsx)("input",{type:"number",value:"number"==typeof d?d:"",onChange:b=>j(a,Number(b.target.value)),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"});if("string[]"===c.type){let c=Array.isArray(d)?d.join("\n"):"";return(0,b.jsx)("textarea",{value:c,onChange:b=>j(a,b.target.value.split("\n").filter(a=>""!==a.trim())),rows:4,placeholder:"One entry per line",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-2 focus:ring-primary/40 resize-y"})}if("pattern[]"===c.type){let c=Array.isArray(d)?d:[];return(0,b.jsxs)("div",{className:"space-y-1.5",children:[c.map((d,e)=>(0,b.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,b.jsx)("input",{type:"text",value:d.regex,onChange:b=>{let d=[...c];d[e]={...d[e],regex:b.target.value},j(a,d)},placeholder:"regex",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs font-mono focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("input",{type:"text",value:d.label,onChange:b=>{let d=[...c];d[e]={...d[e],label:b.target.value},j(a,d)},placeholder:"label",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("button",{onClick:()=>j(a,c.filter((a,b)=>b!==e)),className:"text-muted-foreground/50 hover:text-destructive transition-colors",children:(0,b.jsx)(q.X,{className:"h-3.5 w-3.5"})})]},e)),(0,b.jsx)("button",{onClick:()=>j(a,[...c,{regex:"",label:""}]),className:"text-xs text-primary hover:underline",children:"+ Add pattern"})]})}return(0,b.jsx)("input",{type:"text",value:"string"==typeof d?d:"",onChange:b=>j(a,b.target.value),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"})})(a,c)]},a))}),(0,b.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,b.jsx)(L.Button,{variant:"outline",size:"sm",onClick:d,className:"h-7 text-xs",children:"Cancel"}),(0,b.jsx)(L.Button,{size:"sm",onClick:()=>e(h),className:"h-7 text-xs",children:"Save"})]})]})})}function $({message:a,onDismiss:c,onInstall:e,isPending:f}){let{capture:g}=(0,G.usePostHog)();return(0,d.createPortal)((0,b.jsxs)("div",{className:"fixed top-4 right-4 z-[9999] w-full max-w-sm",style:{animation:"slideInFromRight 0.25s ease-out"},children:[(0,b.jsx)("style",{children:`
|
|
2
2
|
@keyframes slideInFromRight {
|
|
3
3
|
from { transform: translateX(calc(100% + 1rem)); opacity: 0; }
|
|
4
4
|
to { transform: translateX(0); opacity: 1; }
|
|
5
5
|
}
|
|
6
|
-
`}),(0,b.jsxs)("div",{className:"rounded-lg border border-red-500/40 bg-red-950/95 shadow-2xl shadow-red-900/40 overflow-hidden backdrop-blur-sm",children:[(0,b.jsx)("div",{className:"h-0.5 w-full bg-gradient-to-r from-red-600 via-red-400 to-red-600"}),(0,b.jsxs)("div",{className:"p-4",children:[(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)("div",{className:"shrink-0 mt-0.5 flex h-5 w-5 items-center justify-center rounded-full bg-red-500 ring-2 ring-red-500/30",children:(0,b.jsx)(q.X,{className:"h-3 w-3 text-white",strokeWidth:3})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("p",{className:"text-[0.65rem] font-bold uppercase tracking-widest text-red-400 mb-0.5",children:"Error"}),(0,b.jsx)("p",{className:"text-sm text-red-100 leading-snug",children:a})]}),(0,b.jsx)("button",{onClick:c,className:"shrink-0 -mt-0.5 -mr-0.5 rounded p-0.5 text-red-400/60 transition-colors hover:bg-red-500/20 hover:text-red-200","aria-label":"Dismiss",children:(0,b.jsx)(q.X,{className:"h-4 w-4"})})]}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)(H.Button,{size:"sm",onClick:()=>{g("hooks_install_from_error_clicked",{error_message:a.slice(0,200)}),c(),e()},disabled:f,className:"h-7 flex-1 border-0 bg-red-500 px-3 text-xs font-semibold text-white hover:bg-red-400 disabled:opacity-50",children:"Install hooks"}),(0,b.jsx)(H.Button,{variant:"ghost",size:"sm",onClick:c,className:"h-7 px-3 text-xs text-red-400 hover:bg-red-500/10 hover:text-red-200",children:"Dismiss"})]})]})]})]}),document.body)}function X({onHooksInstallChange:a}){let[d,e]=(0,c.useState)(null),[f,g]=(0,c.useTransition)(),[h,j]=(0,c.useState)(null),[m,n]=(0,c.useState)(null),[o,p]=(0,c.useState)(null),[q,r]=(0,c.useState)(()=>new Set),s=(0,c.useRef)(!1),{capture:t}=(0,C.usePostHog)(),u=(0,c.useCallback)((a,b)=>{t("action_error_displayed",{error_type:a,error_message:b.slice(0,200)}),j(b)},[t]),B=(0,c.useCallback)(async()=>{try{let b=await v();e(b),a?.(b.clis.some(a=>a.installed))}catch{}},[a]);(0,c.useEffect)(()=>{B()},[B]),(0,c.useEffect)(()=>{d&&(s.current?r(new Set(d.clis.filter(a=>a.installed).map(a=>a.id))):(s.current=!0,r(new Set(d.clis.filter(a=>a.installed||a.detected).map(a=>a.id)))))},[d?.clis]);let D=(0,c.useMemo)(()=>new Set((d?.clis??[]).filter(a=>a.installed).map(a=>a.id)),[d?.clis]),E=(0,c.useMemo)(()=>{let a=[],b=[];for(let c of d?.clis??[]){let d=q.has(c.id);d&&!D.has(c.id)&&a.push(c.id),!d&&D.has(c.id)&&b.push(c.id)}return{toInstall:a,toRemove:b}},[d?.clis,q,D]),G=E.toInstall.length>0||E.toRemove.length>0,I=(a,b)=>{d&&(e(c=>c?{...c,customPolicies:c.customPolicies?.map(c=>c.id===a?{...c,enabled:!b}:c),conventionPolicies:c.conventionPolicies.map(c=>({...c,policies:c.policies.map(c=>c.id===a?{...c,enabled:!b}:c)}))}:c),g(async()=>{try{await w(a,!b)}catch{u("custom_policy_toggle","Failed to save custom policy change."),B()}}))},J=()=>{let{toInstall:a,toRemove:b}=E;(0!==a.length||0!==b.length)&&(t("cli_install_remove_submitted",{to_install:a,to_remove:b,count_install:a.length,count_remove:b.length}),g(async()=>{try{j(null),a.length>0&&await y("user",a),b.length>0&&await z("user",b)}catch(a){u("cli_apply",a instanceof Error?a.message:"Failed to apply changes.")}finally{await B()}}))};if(!d)return(0,b.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,b.jsxs)("span",{className:"text-sm text-muted-foreground",children:["Loading","…"]})});let K=d.clis.some(a=>a.installed),L=D.size,M=q.size,N=Array.from(new Set(d.policies.map(a=>a.category)));return(0,b.jsxs)(b.Fragment,{children:[o&&(0,b.jsx)(V,{policy:o,onClose:()=>{t("policy_config_modal_closed",{policy_name:o.name,action:"cancel"}),p(null)},onSave:a=>{if(!o)return;let b=o.name;p(null),g(async()=>{try{j(null),await A(b,a),await B()}catch(a){u("param_update",a instanceof Error?a.message:"Failed to save configuration.")}})}}),(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-4 px-5 py-3.5 border-b border-border/60 bg-muted/10",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-wrap",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:`h-2 w-2 rounded-full transition-shadow ${K?"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.6)]":"bg-muted-foreground/40"}`,"aria-hidden":!0}),(0,b.jsx)("span",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-foreground/90",children:"Integrations"})]}),(0,b.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,b.jsxs)("div",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-muted-foreground",children:[(0,b.jsx)("span",{className:"text-foreground tabular-nums",children:L.toString().padStart(2,"0")}),(0,b.jsxs)("span",{className:"opacity-50",children:[" / 0",d.clis.length," active"]})]}),G&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[0.65rem] uppercase tracking-[0.2em] font-mono text-pink-400",children:[(0,b.jsx)("span",{className:"h-1 w-1 rounded-full bg-pink-400 animate-pulse"}),E.toInstall.length+E.toRemove.length," pending"]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,b.jsx)(H.Button,{variant:"outline",size:"sm",onClick:()=>{let a=Array.from(D).filter(a=>q.has(a));0!==a.length&&(t("cli_reinstall_submitted",{cli_ids:a,count:a.length}),g(async()=>{try{j(null),await y("user",a)}catch(a){u("cli_reinstall",a instanceof Error?a.message:"Failed to reinstall.")}finally{await B()}}))},disabled:f||0===M,className:"text-xs h-7 px-3 font-mono",children:"Reinstall"}),(0,b.jsx)(H.Button,{variant:"default",size:"sm",onClick:J,disabled:f||!G,className:"text-xs h-7 px-3 font-mono",children:"Apply changes"})]})]}),(0,b.jsx)("div",{className:"divide-y divide-border/30 border-b border-border/60",children:d.clis.map((a,c)=>{let e=q.has(a.id),g=D.has(a.id),h=e!==g,i=(0,F.getCliBadgeClasses)(a.id),j=i.split(" ").find(a=>a.startsWith("text-"))??"text-foreground";return(0,b.jsxs)("label",{className:`group relative flex items-center gap-3 pl-6 pr-5 py-3 cursor-pointer transition-colors hover:bg-muted/15 ${h?"bg-pink-500/[0.04]":""}`,children:[(0,b.jsx)("div",{className:`absolute left-0 top-0 bottom-0 w-[3px] ${j} bg-current transition-opacity ${e?"opacity-100":"opacity-25 group-hover:opacity-60"}`,"aria-hidden":!0}),(0,b.jsx)("div",{className:"font-mono text-[0.65rem] text-muted-foreground/40 tabular-nums w-6 select-none",children:(c+1).toString().padStart(2,"0")}),(0,b.jsxs)("div",{className:"relative shrink-0",children:[(0,b.jsx)("input",{type:"checkbox",checked:e,onChange:()=>{var b;return b=a.id,void r(a=>{let c=new Set(a),e=!c.has(b);e?c.add(b):c.delete(b);let f=d?.clis.find(a=>a.id===b);return t("cli_selection_toggled",{cli_id:b,checked:e,current_state:f?.installed?"installed":f?.detected?"detected":"inactive"}),c})},disabled:f,className:"sr-only peer","aria-label":`Toggle ${a.label}`}),(0,b.jsx)("div",{className:`h-[18px] w-[18px] rounded-sm border transition-all peer-focus-visible:ring-2 peer-focus-visible:ring-primary/40 ${e?"bg-primary border-primary":"bg-background/50 border-border group-hover:border-foreground/40"}`,children:e&&(0,b.jsx)("svg",{viewBox:"0 0 18 18",className:"h-full w-full text-primary-foreground",fill:"none","aria-hidden":!0,children:(0,b.jsx)("path",{d:"M4 9.5L7.5 12.5L14 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),(0,b.jsx)("div",{className:"min-w-[150px] shrink-0",children:(0,b.jsx)("div",{className:"text-sm font-medium text-foreground",children:a.label})}),(0,b.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[g?(0,b.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border ${i}`,children:[(0,b.jsx)("span",{className:"h-1 w-1 rounded-full bg-current shadow-[0_0_4px_currentColor]"}),"Active"]}):a.detected?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-border/60 text-muted-foreground/80 bg-muted/20",children:[(0,b.jsx)("span",{className:"h-1 w-1 rounded-full bg-current opacity-60"}),"Detected"]}):(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-border/30 text-muted-foreground/40",children:"Inactive"}),h&&(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-pink-500/40 text-pink-400 bg-pink-500/10",children:e?"+ install":"− remove"})]}),(0,b.jsx)("div",{className:"ml-auto hidden lg:block text-[0.7rem] font-mono text-muted-foreground/50 truncate max-w-[420px] group-hover:text-muted-foreground/80 transition-colors",title:a.settingsPath,children:a.settingsPath})]},a.id)})}),(0,b.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border/40 bg-muted/5",children:[(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-semibold text-foreground",children:d.enabledPolicies.length})," / ",d.policies.length+(d.customPolicies?.length??0)+(d.conventionPolicies?.reduce((a,b)=>a+b.policies.length,0)??0)," ","policies enabled"]}),K&&(0,b.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground/60",children:["· shared across ",L," active CLI",1===L?"":"s"]})]}),h&&(0,b.jsx)("div",{className:"px-4 py-2 bg-red-500/10 border-b border-red-500/20 text-xs text-red-400",children:h}),m&&(0,b.jsx)(W,{message:m,onDismiss:()=>n(null),onInstall:J,isPending:f}),N.map(a=>{let c=d.policies.filter(b=>b.category===a),h=c.filter(a=>a.enabled).length;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,b.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:a}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[h," / ",c.length," enabled"]})]}),c.map(a=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,b.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,b.jsx)(U,{enabled:a.enabled,onChange:()=>{var b,c;return b=a.name,c=a.enabled,void(!d||(!d.clis.some(a=>a.installed)?n("Policies are not installed. Install policies to continue."):(n(null),e(a=>a?{...a,policies:a.policies.map(a=>a.name===b?{...a,enabled:!c}:a),enabledPolicies:c?a.enabledPolicies.filter(a=>a!==b):[...a.enabledPolicies,b]}:a),g(async()=>{try{await x(b,!c)}catch{u("policy_toggle","Failed to save policy change."),B()}}))))},disabled:f})}),(0,b.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:[(0,b.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:a.name}),a.beta&&(0,b.jsx)("span",{className:"shrink-0 text-[0.6rem] px-1 py-0.5 rounded border bg-violet-500/10 text-violet-400 border-violet-500/20",children:"beta"})]}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:a.description}),a.eventScope&&(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:a.eventScope}),a.params&&Object.keys(a.params).length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1 mt-1.5",children:Object.entries(a.params).map(([c,d])=>{let e=a.currentParams?.[c]??d.default,f=JSON.stringify(e)!==JSON.stringify(d.default);return(0,b.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[0.6rem] px-1.5 py-0.5 rounded border ${f?"bg-primary/10 text-primary/70 border-primary/20":"bg-muted/40 text-muted-foreground/55 border-border/40"}`,children:[(0,b.jsxs)("span",{className:"opacity-70",children:[c,":"]}),(0,b.jsx)("span",{children:function(a,b){if("string[]"===a||"pattern[]"===a){let c=Array.isArray(b)?b:[];return 0===c.length?"none":"pattern[]"===a?`${c.length} pattern${1!==c.length?"s":""}`:1===c.length?String(c[0]).slice(0,24):`${c.length} values`}return"boolean"===a?b?"on":"off":null==b||""===b?"—":String(b).slice(0,32)}(d.type,e)})]},c)})})]}),a.params&&Object.keys(a.params).length>0&&(0,b.jsx)("button",{className:"shrink-0 mt-0.5 text-muted-foreground hover:text-primary transition-colors",onClick:()=>{let b=Object.entries(a.params??{}).filter(([b,c])=>JSON.stringify(a.currentParams?.[b]??c.default)!==JSON.stringify(c.default)).length;t("policy_config_modal_opened",{policy_name:a.name,param_count:Object.keys(a.params??{}).length,has_customized_params:b>0,customized_count:b}),p(a)},title:"Edit parameters",children:(0,b.jsx)(k,{className:"h-3.5 w-3.5"})})]},a.name))]},a)}),(d.customPoliciesPaths?.length||d.customPoliciesPath)&&(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,b.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:"Custom Policies"}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[d.customPolicies?.length??0," detected"]})]}),(d.customPoliciesPaths??[d.customPoliciesPath]).map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,b.jsx)(i,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a})]},a)),(0,b.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,b.jsx)(l,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,b.jsx)("p",{className:"text-[0.7rem] text-muted-foreground/70 leading-relaxed",children:"Re-run the install command to add, remove, or reorder files."})]}),d.customPolicies?.map(a=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,b.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,b.jsx)(U,{enabled:a.enabled,onChange:()=>I(a.id,a.enabled),disabled:f})}),(0,b.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,b.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:a.name})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[a.description&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:a.description}),a.eventScope&&(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:a.eventScope})]})]},a.id))]}),d.conventionPolicies?.map(a=>(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,b.jsxs)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:["Convention Policies — ","project"===a.scope?"Project":"User"]}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[a.policies.length," hook",1===a.policies.length?"":"s"]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,b.jsx)(i,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a.path})]}),0===a.policies.length?(0,b.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,b.jsx)(l,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,b.jsxs)("p",{className:"text-[0.7rem] text-muted-foreground/70 leading-relaxed",children:["No policies could be read from this file. It is still loaded at runtime — run ",(0,b.jsx)("span",{className:"font-mono",children:"failproofai policies"})," to see what it registers."]})]}):a.policies.map(c=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,b.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,b.jsx)(U,{enabled:c.enabled,onChange:()=>I(c.id,c.enabled),disabled:f})}),(0,b.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,b.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:c.name})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[c.description&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:c.description}),c.eventScope&&(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:c.eventScope})]})]},`${a.path}:${c.name}`))]},a.path))]})]})}function Y({activeTab:a,onChange:c}){return(0,b.jsx)("div",{className:"tabs",style:{padding:0,marginBottom:24},children:[{id:"activity",label:"Activity"},{id:"policies",label:"Configure"}].map(d=>(0,b.jsx)("button",{type:"button",onClick:()=>c(d.id),className:`tab${a===d.id?" is-active":""}`,children:d.label.toLowerCase()},d.id))})}a.s(["default",0,function({initialTab:a="activity"}){let d=(0,D.useUrlParams)(),{capture:e}=(0,C.usePostHog)(),[f,g]=(0,c.useState)(a),[h,i]=(0,c.useState)(void 0),[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)([]);(0,c.useEffect)(()=>{v().then(a=>{i(a.clis.some(a=>a.installed)),k({enabled:a.enabledPolicies.length,total:a.policies.length+(a.customPolicies?.length??0)+(a.conventionPolicies?.reduce((a,b)=>a+b.policies.length,0)??0)}),m(a.clis.filter(a=>a.installed).map(a=>a.label))}).catch(()=>i(void 0))},[]);let n=0===l.length?"Policy evaluations":l.length<=3?`Policy evaluations across ${l.join(", ")}`:`Policy evaluations across ${l.length} agents`,o=a=>{a!==f&&e("policies_tab_switched",{tab:a,from_tab:f}),g(a),d.setAll({tab:"activity"===a?void 0:a})};return(0,b.jsx)("main",{className:"report",children:(0,b.jsxs)("section",{className:"section","data-screen-label":"policies",children:[(0,b.jsx)("h2",{style:{fontFamily:"var(--font-mono)",fontSize:24,fontWeight:600,letterSpacing:"-0.01em",color:"var(--ink)",margin:"0 0 16px"},children:"activity"===f?"Policies":"Configure Policies"}),"activity"===f?(0,b.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:32,flexWrap:"wrap",margin:"0 0 24px"},children:[(0,b.jsxs)("div",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--ink-2)",lineHeight:1.7,flex:"1 1 480px",minWidth:0},children:[n,j&&(0,b.jsxs)("span",{style:{color:"var(--dim)"},children:[" · ","enabled policies"," ",(0,b.jsxs)("span",{style:{color:"var(--ink)",fontVariantNumeric:"tabular-nums"},children:[j.enabled,"/",j.total]})]})]}),(0,b.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:6,flex:"0 0 auto"},children:[(0,b.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:"0.22em",textTransform:"uppercase",color:"var(--dim)"},children:"want to change which policies fire?"}),(0,b.jsx)("button",{type:"button",className:"btn btn-primary",onClick:()=>o("policies"),children:"[ configure policies → ]"})]})]}):(0,b.jsx)("p",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--ink-2)",lineHeight:1.7,maxWidth:720,margin:"0 0 24px"},children:"switch policies on or off across your installed agent CLIs."}),(0,b.jsx)(Y,{activeTab:f,onChange:o}),"activity"===f?(0,b.jsx)(T,{hooksInstalled:h,onSwitchTab:o}):(0,b.jsx)(X,{onHooksInstallChange:i})]})})}],22712)}];
|
|
6
|
+
`}),(0,b.jsxs)("div",{className:"rounded-lg border border-red-500/40 bg-red-950/95 shadow-2xl shadow-red-900/40 overflow-hidden backdrop-blur-sm",children:[(0,b.jsx)("div",{className:"h-0.5 w-full bg-gradient-to-r from-red-600 via-red-400 to-red-600"}),(0,b.jsxs)("div",{className:"p-4",children:[(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)("div",{className:"shrink-0 mt-0.5 flex h-5 w-5 items-center justify-center rounded-full bg-red-500 ring-2 ring-red-500/30",children:(0,b.jsx)(q.X,{className:"h-3 w-3 text-white",strokeWidth:3})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("p",{className:"text-[0.65rem] font-bold uppercase tracking-widest text-red-400 mb-0.5",children:"Error"}),(0,b.jsx)("p",{className:"text-sm text-red-100 leading-snug",children:a})]}),(0,b.jsx)("button",{onClick:c,className:"shrink-0 -mt-0.5 -mr-0.5 rounded p-0.5 text-red-400/60 transition-colors hover:bg-red-500/20 hover:text-red-200","aria-label":"Dismiss",children:(0,b.jsx)(q.X,{className:"h-4 w-4"})})]}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)(L.Button,{size:"sm",onClick:()=>{g("hooks_install_from_error_clicked",{error_message:a.slice(0,200)}),c(),e()},disabled:f,className:"h-7 flex-1 border-0 bg-red-500 px-3 text-xs font-semibold text-white hover:bg-red-400 disabled:opacity-50",children:"Install hooks"}),(0,b.jsx)(L.Button,{variant:"ghost",size:"sm",onClick:c,className:"h-7 px-3 text-xs text-red-400 hover:bg-red-500/10 hover:text-red-200",children:"Dismiss"})]})]})]})]}),document.body)}function _({onHooksInstallChange:a}){let[d,e]=(0,c.useState)(null),[f,g]=(0,c.useTransition)(),[h,j]=(0,c.useState)(null),[m,n]=(0,c.useState)(null),[o,p]=(0,c.useState)(null),[q,r]=(0,c.useState)(()=>new Set),s=(0,c.useRef)(!1),{capture:t}=(0,G.usePostHog)(),u=(0,c.useCallback)((a,b)=>{t("action_error_displayed",{error_type:a,error_message:b.slice(0,200)}),j(b)},[t]),v=(0,c.useCallback)(async()=>{try{let b=await z();e(b),a?.(b.clis.some(a=>a.installed))}catch{}},[a]);(0,c.useEffect)(()=>{v()},[v]),(0,c.useEffect)(()=>{d&&(s.current?r(new Set(d.clis.filter(a=>a.installed).map(a=>a.id))):(s.current=!0,r(new Set(d.clis.filter(a=>a.installed||a.detected).map(a=>a.id)))))},[d?.clis]);let w=(0,c.useMemo)(()=>new Set((d?.clis??[]).filter(a=>a.installed).map(a=>a.id)),[d?.clis]),x=(0,c.useMemo)(()=>{let a=[],b=[];for(let c of d?.clis??[]){let d=q.has(c.id);d&&!w.has(c.id)&&a.push(c.id),!d&&w.has(c.id)&&b.push(c.id)}return{toInstall:a,toRemove:b}},[d?.clis,q,w]),y=x.toInstall.length>0||x.toRemove.length>0,F=(a,b)=>{d&&(e(c=>c?{...c,customPolicies:c.customPolicies?.map(c=>c.id===a?{...c,enabled:!b}:c),conventionPolicies:c.conventionPolicies.map(c=>({...c,policies:c.policies.map(c=>c.id===a?{...c,enabled:!b}:c)}))}:c),g(async()=>{try{await A(a,!b)}catch{u("custom_policy_toggle","Failed to save custom policy change."),v()}}))},H=()=>{let{toInstall:a,toRemove:b}=x;(0!==a.length||0!==b.length)&&(t("cli_install_remove_submitted",{to_install:a,to_remove:b,count_install:a.length,count_remove:b.length}),g(async()=>{try{j(null),a.length>0&&await C("user",a),b.length>0&&await D("user",b)}catch(a){u("cli_apply",a instanceof Error?a.message:"Failed to apply changes.")}finally{await v()}}))};if(!d)return(0,b.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,b.jsxs)("span",{className:"text-sm text-muted-foreground",children:["Loading","…"]})});let I=d.clis.some(a=>a.installed),K=w.size,M=q.size,N=Array.from(new Set(d.policies.map(a=>a.category)));return(0,b.jsxs)(b.Fragment,{children:[o&&(0,b.jsx)(Z,{policy:o,onClose:()=>{t("policy_config_modal_closed",{policy_name:o.name,action:"cancel"}),p(null)},onSave:a=>{if(!o)return;let b=o.name;p(null),g(async()=>{try{j(null),await E(b,a),await v()}catch(a){u("param_update",a instanceof Error?a.message:"Failed to save configuration.")}})}}),(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-4 px-5 py-3.5 border-b border-border/60 bg-muted/10",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-wrap",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:`h-2 w-2 rounded-full transition-shadow ${I?"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.6)]":"bg-muted-foreground/40"}`,"aria-hidden":!0}),(0,b.jsx)("span",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-foreground/90",children:"Integrations"})]}),(0,b.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,b.jsxs)("div",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-muted-foreground",children:[(0,b.jsx)("span",{className:"text-foreground tabular-nums",children:K.toString().padStart(2,"0")}),(0,b.jsxs)("span",{className:"opacity-50",children:[" / 0",d.clis.length," active"]})]}),y&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[0.65rem] uppercase tracking-[0.2em] font-mono text-pink-400",children:[(0,b.jsx)("span",{className:"h-1 w-1 rounded-full bg-pink-400 animate-pulse"}),x.toInstall.length+x.toRemove.length," pending"]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,b.jsx)(L.Button,{variant:"outline",size:"sm",onClick:()=>{let a=Array.from(w).filter(a=>q.has(a));0!==a.length&&(t("cli_reinstall_submitted",{cli_ids:a,count:a.length}),g(async()=>{try{j(null),await C("user",a)}catch(a){u("cli_reinstall",a instanceof Error?a.message:"Failed to reinstall.")}finally{await v()}}))},disabled:f||0===M,className:"text-xs h-7 px-3 font-mono",children:"Reinstall"}),(0,b.jsx)(L.Button,{variant:"default",size:"sm",onClick:H,disabled:f||!y,className:"text-xs h-7 px-3 font-mono",children:"Apply changes"})]})]}),(0,b.jsx)("div",{className:"divide-y divide-border/30 border-b border-border/60",children:d.clis.map((a,c)=>{let e=q.has(a.id),g=w.has(a.id),h=e!==g,i=(0,J.getCliBadgeClasses)(a.id),j=i.split(" ").find(a=>a.startsWith("text-"))??"text-foreground";return(0,b.jsxs)("label",{className:`group relative flex items-center gap-3 pl-6 pr-5 py-3 cursor-pointer transition-colors hover:bg-muted/15 ${h?"bg-pink-500/[0.04]":""}`,children:[(0,b.jsx)("div",{className:`absolute left-0 top-0 bottom-0 w-[3px] ${j} bg-current transition-opacity ${e?"opacity-100":"opacity-25 group-hover:opacity-60"}`,"aria-hidden":!0}),(0,b.jsx)("div",{className:"font-mono text-[0.65rem] text-muted-foreground/40 tabular-nums w-6 select-none",children:(c+1).toString().padStart(2,"0")}),(0,b.jsxs)("div",{className:"relative shrink-0",children:[(0,b.jsx)("input",{type:"checkbox",checked:e,onChange:()=>{var b;return b=a.id,void r(a=>{let c=new Set(a),e=!c.has(b);e?c.add(b):c.delete(b);let f=d?.clis.find(a=>a.id===b);return t("cli_selection_toggled",{cli_id:b,checked:e,current_state:f?.installed?"installed":f?.detected?"detected":"inactive"}),c})},disabled:f,className:"sr-only peer","aria-label":`Toggle ${a.label}`}),(0,b.jsx)("div",{className:`h-[18px] w-[18px] rounded-sm border transition-all peer-focus-visible:ring-2 peer-focus-visible:ring-primary/40 ${e?"bg-primary border-primary":"bg-background/50 border-border group-hover:border-foreground/40"}`,children:e&&(0,b.jsx)("svg",{viewBox:"0 0 18 18",className:"h-full w-full text-primary-foreground",fill:"none","aria-hidden":!0,children:(0,b.jsx)("path",{d:"M4 9.5L7.5 12.5L14 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),(0,b.jsx)("div",{className:"min-w-[150px] shrink-0",children:(0,b.jsx)("div",{className:"text-sm font-medium text-foreground",children:a.label})}),(0,b.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[g?(0,b.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border ${i}`,children:[(0,b.jsx)("span",{className:"h-1 w-1 rounded-full bg-current shadow-[0_0_4px_currentColor]"}),"Active"]}):a.detected?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-border/60 text-muted-foreground/80 bg-muted/20",children:[(0,b.jsx)("span",{className:"h-1 w-1 rounded-full bg-current opacity-60"}),"Detected"]}):(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-border/30 text-muted-foreground/40",children:"Inactive"}),h&&(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm text-[0.6rem] uppercase tracking-[0.15em] font-mono border border-pink-500/40 text-pink-400 bg-pink-500/10",children:e?"+ install":"− remove"})]}),(0,b.jsx)("div",{className:"ml-auto hidden lg:block text-[0.7rem] font-mono text-muted-foreground/50 truncate max-w-[420px] group-hover:text-muted-foreground/80 transition-colors",title:a.settingsPath,children:a.settingsPath})]},a.id)})}),(0,b.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border/40 bg-muted/5",children:[(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-semibold text-foreground",children:d.enabledPolicies.length})," / ",d.policies.length+(d.customPolicies?.length??0)+(d.conventionPolicies?.reduce((a,b)=>a+b.policies.length,0)??0)," ","policies enabled"]}),I&&(0,b.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground/60",children:["· shared across ",K," active CLI",1===K?"":"s"]})]}),h&&(0,b.jsx)("div",{className:"px-4 py-2 bg-red-500/10 border-b border-red-500/20 text-xs text-red-400",children:h}),m&&(0,b.jsx)($,{message:m,onDismiss:()=>n(null),onInstall:H,isPending:f}),N.map(a=>{let c=d.policies.filter(b=>b.category===a),h=c.filter(a=>a.enabled).length;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,b.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:a}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[h," / ",c.length," enabled"]})]}),c.map(a=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,b.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,b.jsx)(Y,{enabled:a.enabled,onChange:()=>{var b,c;return b=a.name,c=a.enabled,void(!d||(!d.clis.some(a=>a.installed)?n("Policies are not installed. Install policies to continue."):(n(null),e(a=>a?{...a,policies:a.policies.map(a=>a.name===b?{...a,enabled:!c}:a),enabledPolicies:c?a.enabledPolicies.filter(a=>a!==b):[...a.enabledPolicies,b]}:a),g(async()=>{try{await B(b,!c)}catch{u("policy_toggle","Failed to save policy change."),v()}}))))},disabled:f})}),(0,b.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:[(0,b.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:a.name}),a.beta&&(0,b.jsx)("span",{className:"shrink-0 text-[0.6rem] px-1 py-0.5 rounded border bg-violet-500/10 text-violet-400 border-violet-500/20",children:"beta"})]}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:a.description}),a.eventScope&&(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:a.eventScope}),a.params&&Object.keys(a.params).length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1 mt-1.5",children:Object.entries(a.params).map(([c,d])=>{let e=a.currentParams?.[c]??d.default,f=JSON.stringify(e)!==JSON.stringify(d.default);return(0,b.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[0.6rem] px-1.5 py-0.5 rounded border ${f?"bg-primary/10 text-primary/70 border-primary/20":"bg-muted/40 text-muted-foreground/55 border-border/40"}`,children:[(0,b.jsxs)("span",{className:"opacity-70",children:[c,":"]}),(0,b.jsx)("span",{children:function(a,b){if("string[]"===a||"pattern[]"===a){let c=Array.isArray(b)?b:[];return 0===c.length?"none":"pattern[]"===a?`${c.length} pattern${1!==c.length?"s":""}`:1===c.length?String(c[0]).slice(0,24):`${c.length} values`}return"boolean"===a?b?"on":"off":null==b||""===b?"—":String(b).slice(0,32)}(d.type,e)})]},c)})})]}),a.params&&Object.keys(a.params).length>0&&(0,b.jsx)("button",{className:"shrink-0 mt-0.5 text-muted-foreground hover:text-primary transition-colors",onClick:()=>{let b=Object.entries(a.params??{}).filter(([b,c])=>JSON.stringify(a.currentParams?.[b]??c.default)!==JSON.stringify(c.default)).length;t("policy_config_modal_opened",{policy_name:a.name,param_count:Object.keys(a.params??{}).length,has_customized_params:b>0,customized_count:b}),p(a)},title:"Edit parameters",children:(0,b.jsx)(k,{className:"h-3.5 w-3.5"})})]},a.name))]},a)}),(d.customPoliciesPaths?.length||d.customPoliciesPath)&&(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,b.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:"Custom Policies"}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[d.customPolicies?.length??0," detected"]})]}),(d.customPoliciesPaths??[d.customPoliciesPath]).map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,b.jsx)(i,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a})]},a)),(0,b.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,b.jsx)(l,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,b.jsx)("p",{className:"text-[0.7rem] text-muted-foreground/70 leading-relaxed",children:"Re-run the install command to add, remove, or reorder files."})]}),d.customPolicies?.map(a=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,b.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,b.jsx)(Y,{enabled:a.enabled,onChange:()=>F(a.id,a.enabled),disabled:f})}),(0,b.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,b.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:a.name})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[a.description&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:a.description}),a.eventScope&&(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:a.eventScope})]})]},a.id))]}),d.conventionPolicies?.map(a=>(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,b.jsxs)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:["Convention Policies — ","project"===a.scope?"Project":"User"]}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[a.policies.length," hook",1===a.policies.length?"":"s"]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,b.jsx)(i,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:a.path})]}),0===a.policies.length?(0,b.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,b.jsx)(l,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,b.jsxs)("p",{className:"text-[0.7rem] text-muted-foreground/70 leading-relaxed",children:["No policies could be read from this file. It is still loaded at runtime — run ",(0,b.jsx)("span",{className:"font-mono",children:"failproofai policies"})," to see what it registers."]})]}):a.policies.map(c=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors",children:[(0,b.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,b.jsx)(Y,{enabled:c.enabled,onChange:()=>F(c.id,c.enabled),disabled:f})}),(0,b.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,b.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:c.name})}),(0,b.jsxs)("div",{className:"flex-1 min-w-0",children:[c.description&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:c.description}),c.eventScope&&(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:c.eventScope})]})]},`${a.path}:${c.name}`))]},a.path))]})]})}function aa({activeTab:a,onChange:c}){return(0,b.jsx)("div",{className:"tabs",style:{padding:0,marginBottom:24},children:[{id:"activity",label:"Activity"},{id:"policies",label:"Configure"}].map(d=>(0,b.jsx)("button",{type:"button",onClick:()=>c(d.id),className:`tab${a===d.id?" is-active":""}`,children:d.label.toLowerCase()},d.id))})}a.s(["default",0,function({initialTab:a="activity"}){let d=(0,H.useUrlParams)(),{capture:e}=(0,G.usePostHog)(),[f,g]=(0,c.useState)(a),[h,i]=(0,c.useState)(void 0),[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)([]);(0,c.useEffect)(()=>{z().then(a=>{i(a.clis.some(a=>a.installed)),k({enabled:a.enabledPolicies.length,total:a.policies.length+(a.customPolicies?.length??0)+(a.conventionPolicies?.reduce((a,b)=>a+b.policies.length,0)??0)}),m(a.clis.filter(a=>a.installed).map(a=>a.label))}).catch(()=>i(void 0))},[]);let n=0===l.length?"Policy evaluations":l.length<=3?`Policy evaluations across ${l.join(", ")}`:`Policy evaluations across ${l.length} agents`,o=a=>{a!==f&&e("policies_tab_switched",{tab:a,from_tab:f}),g(a),d.setAll({tab:"activity"===a?void 0:a})};return(0,b.jsx)("main",{className:"report",children:(0,b.jsxs)("section",{className:"section","data-screen-label":"policies",children:[(0,b.jsx)("h2",{style:{fontFamily:"var(--font-mono)",fontSize:24,fontWeight:600,letterSpacing:"-0.01em",color:"var(--ink)",margin:"0 0 16px"},children:"activity"===f?"Policies":"Configure Policies"}),"activity"===f?(0,b.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:32,flexWrap:"wrap",margin:"0 0 24px"},children:[(0,b.jsxs)("div",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--ink-2)",lineHeight:1.7,flex:"1 1 480px",minWidth:0},children:[n,j&&(0,b.jsxs)("span",{style:{color:"var(--dim)"},children:[" · ","enabled policies"," ",(0,b.jsxs)("span",{style:{color:"var(--ink)",fontVariantNumeric:"tabular-nums"},children:[j.enabled,"/",j.total]})]})]}),(0,b.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:6,flex:"0 0 auto"},children:[(0,b.jsx)("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:"0.22em",textTransform:"uppercase",color:"var(--dim)"},children:"want to change which policies fire?"}),(0,b.jsx)("button",{type:"button",className:"btn btn-primary",onClick:()=>o("policies"),children:"[ configure policies → ]"})]})]}):(0,b.jsx)("p",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--ink-2)",lineHeight:1.7,maxWidth:720,margin:"0 0 24px"},children:"switch policies on or off across your installed agent CLIs."}),(0,b.jsx)(aa,{activeTab:f,onChange:o}),"activity"===f?(0,b.jsx)(X,{hooksInstalled:h,onSwitchTab:o}):(0,b.jsx)(_,{onHooksInstallChange:i})]})})}],22712)}];
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=app_policies_hooks-client_tsx_19dqvpc._.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
module.exports=[3900,a=>{a.v(b=>Promise.all(["server/chunks/ssr/node_modules_html-to-image_es_index_1ao30b1.js"].map(b=>a.l(b))).then(()=>b(63460)))}];
|
|
2
2
|
|
|
3
|
-
//# sourceMappingURL=node_modules_html-to-
|
|
3
|
+
//# sourceMappingURL=node_modules_html-to-image_es_index_0jfts82.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module.exports=[62882,a=>{"use strict";a.s(["allow",0,function(a){return a?{decision:"allow",reason:a}:{decision:"allow"}},"deny",0,function(a){return{decision:"deny",reason:a}},"instruct",0,function(a){return{decision:"instruct",reason:a}}])},10695,a=>{"use strict";var b=a.i(2157),c=a.i(50227),d=a.i(60526);let e={info:0,warn:1,error:2},f=(0,c.join)((0,d.homedir)(),".failproofai","logs"),g=!1,h="warn",i=!1,j=f;function k(a){return!function(){if(g)return;g=!0;let a=(process.env.FAILPROOFAI_LOG_LEVEL??"").toLowerCase();("info"===a||"warn"===a||"error"===a)&&(h=a);let b=(process.env.FAILPROOFAI_HOOK_LOG_FILE??"").trim();b&&(i=!0,"1"!==b&&"true"!==b&&(j=b))}(),e[a]>=e[h]}function l(a,b){process.stderr.write(`[failproofai:hook] ${a} ${b}
|
|
2
2
|
`)}function m(a,d){if(i)try{(0,b.existsSync)(j)||(0,b.mkdirSync)(j,{recursive:!0});let e=(0,c.join)(j,"hooks.log");try{if((0,b.statSync)(e).size>=524288){let a=`hooks-${Date.now()}.log`;(0,b.renameSync)(e,(0,c.join)(j,a))}}catch{}let f=new Date().toISOString(),g=`[${f}] ${a} ${d}
|
|
3
|
-
`;(0,b.appendFileSync)(e,g,"utf-8")}catch{}}a.s(["hookLogError",0,function(a){k("error")&&(l("ERROR",a),m("ERROR",a))},"hookLogWarn",0,function(a){k("warn")&&(l("WARN",a),m("WARN",a))}])},92956,a=>{"use strict";var b=a.i(50227),c=a.i(2157),d=a.i(12714),e=a.i(74533),f=a.i(60526),g=a.i(62882),h=a.i(10695);let i=function(a){let c=a.replaceAll("\\","/");for(let a of[".claude",".codex",".copilot",".cursor",".opencode",".pi",".gemini"]){let d=(0,b.join)((0,f.homedir)(),a).replaceAll("\\","/");if(c===d||c.startsWith(d+"/"))return!0}for(let a of[(0,b.join)(".config","opencode"),(0,b.join)(".local","share","opencode")]){let d=(0,b.join)((0,f.homedir)(),a).replaceAll("\\","/");if(c===d||c.startsWith(d+"/"))return!0}return!1},j=function(a){return!!(/[\\/]\.claude[\\/]settings(?:\.[^/\\]+)?\.json$/.test(a)||/[\\/]\.codex[\\/]hooks\.json$/.test(a)||/[\\/]\.copilot[\\/]hooks[\\/][^/\\]+\.json$/.test(a)||/[\\/]\.github[\\/]hooks[\\/][^/\\]+\.json$/.test(a)||/[\\/]\.cursor[\\/]hooks\.json$/.test(a)||/[\\/]\.opencode[\\/]opencode\.jsonc?$/.test(a)||/[\\/]\.opencode[\\/]plugins[\\/][^/\\]+\.(?:mjs|js|ts)$/.test(a)||/[\\/]\.config[\\/]opencode[\\/]opencode\.jsonc?$/.test(a)||/[\\/]\.config[\\/]opencode[\\/]config\.json$/.test(a)||/[\\/]\.config[\\/]opencode[\\/]plugins[\\/][^/\\]+\.(?:mjs|js|ts)$/.test(a)||/[\\/]\.pi[\\/](?:agent[\\/])?settings\.json$/.test(a)||/[\\/]\.pi[\\/](?:agent[\\/])?extensions[\\/]/.test(a)||/[\\/]\.gemini[\\/]settings\.json$/.test(a)||/[\\/]\.gemini[\\/]config[\\/]hooks\.json$/.test(a))};function k(a){return a.toolInput?.command??""}function l(a){return a.toolInput?.file_path??""}function m(a){return a.trim().split(/\s+/).map(a=>a.replace(/^['"]|['"]$/g,""))}let n=new Set(["&&","||","|",";"]),o=/[;&<>`$()\\]/,p=/eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/,q=[[/sk-ant-[A-Za-z0-9\-_]{20,}/,"Anthropic API key"],[/sk-proj-[A-Za-z0-9\-_]{20,}/,"OpenAI project API key"],[/sk-[A-Za-z0-9]{20,}/,"OpenAI API key"],[/ghp_[A-Za-z0-9]{36}/,"GitHub personal access token"],[/github_pat_[A-Za-z0-9_]{82}/,"GitHub fine-grained token"],[/AKIA[A-Z0-9]{16}/,"AWS access key ID"],[/sk_live_[A-Za-z0-9]{24,}/,"Stripe live secret key"],[/sk_test_[A-Za-z0-9]{24,}/,"Stripe test secret key"],[/AIza[0-9A-Za-z\-_]{35}/,"Google API key"]],r=/(?:postgresql|postgres|mysql|mongodb(?:\+srv)?|redis|amqps?|smtps?):\/\/[^@\s]+@/,s=/-----BEGIN (?:[A-Z]+ )?PRIVATE KEY-----/,t=/Authorization:\s*Bearer\s+[A-Za-z0-9\-._~+/]{20,}/i,u=/\b(?:psql|mysql|sqlite3|pgcli|clickhouse-client)\b/,v=/\b(?:DROP\s+(?:TABLE|DATABASE|SCHEMA)|TRUNCATE\b)/i,w=/\bDELETE\s+FROM\b/i,x=/\bWHERE\b/i,y=/\bALTER\s+TABLE\b[\s\S]*\b(?:DROP\s+COLUMN|ADD\s+COLUMN|RENAME\s+(?:COLUMN|TO)|MODIFY\s+COLUMN)\b/i,z=/(?:npm\s+publish|bun\s+publish|pnpm\s+publish|yarn\s+npm\s+publish|twine\s+upload|poetry\s+publish|cargo\s+publish|gem\s+push)\b/,A=/(?:^|\s|;|&&|\|\|)(?:env|printenv)(?:\s|$|;|&&|\|)/,B=/echo\s+.*\$\{?[A-Za-z_]/,C=/(?:^|\s|;|&&|\|\|)export\s+\w+/,D=/\$env:[A-Za-z_]/i,E=/(?:Get-ChildItem|dir|gci|ls)\s+Env:/i,F=/\[Environment\]::GetEnvironment/i,G=/echo\s+%[A-Za-z_]/i,H=/(?:^|[\\/])\.env(?:\.|$)/,I=/\.env(?:\b|\s|$|\.)/,J=/(?:^|;|&&|\|\|)\s*sudo\s/,K=/Start-Process\s+.*-Verb\s+RunAs/i,L=/(?:^|;|&&|\|\|)\s*runas\s/i,M=/(?:curl|wget)\s.*\|\s*(?:sh|bash|zsh|dash|ksh|csh|tcsh|fish|ash)\b/,N=/(?:Invoke-WebRequest|iwr|Invoke-RestMethod|irm)\s+.*\|\s*(?:Invoke-Expression|iex)/i,O=/^-[a-zA-Z]*f[a-zA-Z]*$/,P=["--force-with-lease","--force-if-includes"],Q=/\.(?:pem|key)$/,R=/id_rsa/,S=/credentials/,T=/git\s+(commit|merge|rebase|cherry-pick)\b/,U=/(?:^|;|&&|\|\||\|)\s*failproofai(?:\s|$)/,V=/(?:npm\s+(?:uninstall|remove|un|r)\s.*failproofai|bun\s+remove\s.*failproofai|yarn\s+global\s+remove\s+failproofai|pnpm\s+(?:remove|uninstall|un)\s.*failproofai)/,W=/\bgit\s+commit\b.*--amend\b/,X=/\bgit\s+stash\s+(?:drop|clear)\b/,Y=/\bgit\s+add\s+(?:-A\b|--all\b|\.(?:\s|$|;|&&|\|\|))/,Z=/\bnpm\s+(?:install|i)\b(?=.*(?:\s-g\b|--global\b))/,$=/\byarn\s+global\s+add\b/,_=/\bpnpm\s+(?:add|install|i)\b(?=.*(?:\s-g\b|--global\b))/,aa=/\bbun\s+(?:install|add)\b(?=.*(?:\s-g\b|--global\b))/,ab=/\bcargo\s+install\b/,ac=/\bpip(?:3)?\s+install\b(?=.*(?:--user\b|--break-system-packages\b))/,ad={pip:[/\bpip\b/,/\bpip3\b/,/\bpython3?\s+-m\s+pip\b/],npm:[/\bnpm\b/,/\bnpx\b/],yarn:[/\byarn\b/],pnpm:[/\bpnpm\b/,/\bpnpx\b/],bun:[/\bbun\b/,/\bbunx\b/],uv:[/\buv\b/],poetry:[/\bpoetry\b/],pipenv:[/\bpipenv\b/],conda:[/\bconda\b/],cargo:[/\bcargo\b/]},ae=/\bnohup\s+\S/,af=/\bscreen\s+-[A-Za-z]*d[A-Za-z]*\b/,ag=/\btmux\s+(?:new-session|new)\b[^|&;]*-d\b/,ah=/\bdisown\b/,ai=/(?<![&|])\s?&\s*(?:$|#|;)/,aj=/(?:^|[;\n]|&&|\|\|?|&)\s*kubectl(?:\s|$)/,ak=/(?:^|[;\n]|&&|\|\|?|&)\s*(?:terraform|tofu)(?:\s|$)/,al=/(?:^|[;\n]|&&|\|\|?|&)\s*aws(?:\s|$)/,am=/(?:^|[;\n]|&&|\|\|?|&)\s*gcloud(?:\s|$)/,an=/(?:^|[;\n]|&&|\|\|?|&)\s*az(?:\s|$)/,ao=/(?:^|[;\n]|&&|\|\|?|&)\s*helm(?:\s|$)/,ap=/(?:^|[;\n]|&&|\|\|?|&)\s*gh\s+(?:workflow\s+(?:run|enable|disable)|run\s+(?:rerun|cancel)|pr\s+merge|release\s+(?:create|delete)|cache\s+delete|secret\s+(?:set|delete))\b/,aq=new Map;function ar(a){try{let d=function(a){try{return(0,c.statSync)((0,b.join)(a,".git","HEAD")).mtimeMs}catch{return null}}(a),f=aq.get(a);if(f&&null!==d&&f.headMtimeMs===d)return f.branch||null;let g=(0,e.execSync)("git rev-parse --abbrev-ref HEAD",{cwd:a,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3}).trim();return null!==d&&(aq.size>=500&&aq.clear(),aq.set(a,{branch:g,headMtimeMs:d})),g||null}catch{return null}}function as(a,b){let c=m(a),d=m(b);return!(c.length<d.length||c.some(a=>n.has(a))||c.some(a=>o.test(a)))&&d.every((a,b)=>"*"===a||a===c[b])}function at(a){return a.split(/&&|\|\||[|;\n]/).map(a=>a.trim()).filter(a=>/^git\s+push\s/.test(a)).map(a=>a.replace(/^git\s+push\s+/,""))}let au=/^(?:~[A-Za-z0-9_.-]*|\$HOME|\$\{HOME\})(?=$|\/)/,av=/^(?:\/\S*\/)?rm$/,aw=/^(?:\/\S*\/)?find$/,ax=/^-(?:exec|execdir|ok|okdir)$/,ay=/^-(?:[HLP]|D|O\d*)$/,az=/^(?:-|\\?[(!])/,aA=["/tmp","/var/tmp"];function aB(a){let b=a.match(/^(?:~|\$HOME|\$\{HOME\})(?=$|\/)/);return b?(0,f.homedir)()+a.slice(b[0].length):a}function aC(a){return a.replace(/\/\*$/,"").replace(/\/+$/,"")}function aD(a){let b=a.replace(/^['"]|['"]$/g,"");if(""===b)return!1;let c=b.match(au);if(!c&&/^[$`]/.test(b))return!0;let d=c?b.slice(c[0].length):b.startsWith("/")?b:null;if(null===d)return!1;let e=aC(d).split("/").filter(Boolean);return!(!c&&aA.some(a=>`/${e.join("/")}`.startsWith(`${a}/`)))&&e.length<=2}function aE(a){let b=m(a),c=b.findIndex(a=>aw.test(a));if(c>=0){let a=b.slice(c+1),d=a.findIndex(a=>ax.test(a));if(a.includes("-delete")||d>=0&&av.test(a[d+1]??"")){let b=0;for(;b<a.length&&ay.test(a[b]);)b+="-D"===a[b]?2:1;let c=a.slice(b),d=c.findIndex(a=>az.test(a));return d<0?c:c.slice(0,d)}}let d=b.findIndex(a=>av.test(a));if(d>=0){let a=b.slice(d+1),c=a.filter(a=>/^-[^-]/.test(a)).join(""),e=a.filter(a=>/^--/.test(a)),f=/r/i.test(c)||e.some(a=>/^--recursive$/i.test(a)),g=/f/.test(c)||e.some(a=>/^--force$/i.test(a));if(f&&g)return a.filter(a=>!a.startsWith("-"))}return null}function aF(a){return a.split(/&&|\|\||[|;\n]/).map(a=>a.trim()).filter(a=>""!==a)}let aG=/(?:^|;|&&|\|\||\|)\s*(?:ls|find|cat|head|tail|less|more|wc|file|stat|tree|du)\s/;function aH(a,b,c){if("Bash"!==a.toolName)return(0,g.allow)();let d=k(a);return!b.test(d)||(a.params?.allowPatterns??[]).some(a=>as(d,a))?(0,g.allow)():(0,g.deny)(c)}let aI=/\s*(?:&&|\|\||\||;)\s*/;function aJ(a){return a.session?.permissionMode==="plan"}let aK=[{name:"sanitize-jwt",description:"Stop Claude from reading JWTs in tool responses",displayTitle:"Redacted JWT tokens from tool output",impact:"Stops the agent from echoing auth tokens it saw in command output.",fn:function(a){let b=JSON.stringify(a.payload);return p.test(b)?{decision:"deny",reason:"JWT token detected in tool output",message:"[REDACTED: JWT token removed by failproofai]"}:(0,g.allow)()},match:{events:["PostToolUse"]},defaultEnabled:!0,category:"Sanitize"},{name:"sanitize-api-keys",description:"Stop Claude from reading API keys (OpenAI, Anthropic, GitHub, AWS, Stripe, Google) in tool responses",displayTitle:"Redacted API keys from tool output",impact:"Catches OpenAI / Anthropic / GitHub / AWS / Stripe / Google keys before the model sees them.",fn:function(a){let b=JSON.stringify(a.payload);for(let[a,c]of q)if(a.test(b))return{decision:"deny",reason:`${c} detected in tool output`,message:`[REDACTED: ${c} removed by failproofai]`};for(let{regex:c,label:d}of a.params?.additionalPatterns??[])try{if(new RegExp(c).test(b))return{decision:"deny",reason:`${d} detected in tool output`,message:`[REDACTED: ${d} removed by failproofai]`}}catch{(0,h.hookLogWarn)(`additionalPatterns: invalid regex "${c}", skipping`)}return(0,g.allow)()},match:{events:["PostToolUse"]},defaultEnabled:!0,category:"Sanitize",params:{additionalPatterns:{type:"pattern[]",description:"Additional API key patterns to scrub, each with { regex, label }",default:[]}}},{name:"sanitize-connection-strings",description:"Stop Claude from reading database connection strings with embedded credentials in tool responses",displayTitle:"Redacted database connection strings from tool output",impact:"Strips embedded DB credentials before they reach the model context.",fn:function(a){let b=JSON.stringify(a.payload);return r.test(b)?{decision:"deny",reason:"Database connection string with credentials detected in tool output",message:"[REDACTED: connection string removed by failproofai]"}:(0,g.allow)()},match:{events:["PostToolUse"]},defaultEnabled:!0,category:"Sanitize"},{name:"sanitize-private-key-content",description:"Stop Claude from reading PEM private key content in tool responses",displayTitle:"Redacted PEM private keys from tool output",impact:"Prevents private key bodies from being echoed into chat context.",fn:function(a){let b=JSON.stringify(a.payload);return s.test(b)?{decision:"deny",reason:"Private key content detected in tool output",message:"[REDACTED: private key content removed by failproofai]"}:(0,g.allow)()},match:{events:["PostToolUse"]},defaultEnabled:!0,category:"Sanitize"},{name:"sanitize-bearer-tokens",displayTitle:"Redacted bearer tokens from tool output",impact:"Strips Authorization: Bearer values before they hit the model.",description:"Stop Claude from reading Authorization Bearer tokens in tool responses",fn:function(a){let b=JSON.stringify(a.payload);return t.test(b)?{decision:"deny",reason:"Bearer token detected in tool output",message:"[REDACTED: Bearer token removed by failproofai]"}:(0,g.allow)()},match:{events:["PostToolUse"]},defaultEnabled:!0,category:"Sanitize"},{name:"protect-env-vars",displayTitle:"Tried to dump environment variables to chat",impact:"Env vars often contain secrets; blocking `env` / `printenv` keeps them out of the model context.",description:"Prevent commands that read environment variables",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return A.test(b)?(0,g.deny)("Command reads environment variables"):B.test(b)?(0,g.deny)("Command echoes environment variable"):C.test(b)?(0,g.deny)("Command exports environment variable"):D.test(b)?(0,g.deny)("Command reads environment variable via PowerShell"):E.test(b)?(0,g.deny)("Command reads environment variables via PowerShell"):F.test(b)?(0,g.deny)("Command reads environment variable via .NET"):G.test(b)?(0,g.deny)("Command echoes environment variable via cmd"):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!0,category:"Environment"},{name:"block-env-files",displayTitle:"Tried to read or write a .env file",impact:"`.env` files routinely contain API keys and DB credentials.",description:"Block reading/writing .env files",fn:function(a){let b=k(a),c=l(a);return c&&H.test(c)?(0,g.deny)("Access to .env file blocked"):"Bash"===a.toolName&&I.test(b)?(0,g.deny)("Command references .env file"):(0,g.allow)()},match:{events:["PreToolUse"]},defaultEnabled:!0,category:"Environment"},{name:"block-read-outside-cwd",displayTitle:"Tried to read files outside your project directory",impact:"Stops the agent from peeking at neighboring repos or your home directory.",description:"Block file reads outside the session working directory",fn:function(a){let c=process.env.CLAUDE_PROJECT_DIR||a.session?.cwd;if(!c)return(0,g.allow)();let d=a.params?.allowPaths??[];if("Bash"===a.toolName){let e=k(a);if(!aG.test(e))return(0,g.allow)();let h=function(a){let c,d=[],e=/(?<![a-zA-Z0-9_.\-~\\*?:=])(?:~\/[^\s;|&"'()\[\]{}]*|~(?=\s|$|[;|&"'()\[\]{}])|\/[^\s;|&"'()\[\]{}]*)/g;function g(a){let c;for(e.lastIndex=0;null!==(c=e.exec(a));){let a=c[0];"~"===a?a=(0,f.homedir)():a.startsWith("~/")&&(a=(0,b.join)((0,f.homedir)(),a.slice(2))),d.push(a)}}let h=a.length,i=!1,j=!1;for(let b=0;b<a.length;b++){let c=a[b];if('"'!==c||j)if("'"!==c||i){if("|"===c&&!i&&!j){h=b;break}}else j=!j;else i=!i}let k=a.slice(0,h),l=/"([^"]*)"|'([^']*)'/g;for(;null!==(c=l.exec(k));){let a=c[1]??c[2]??"";/[*?\[\]^$+()\\]/.test(a)||g(a)}return g(a.replace(/"[^"]*"/g,a=>" ".repeat(a.length)).replace(/'[^']*'/g,a=>" ".repeat(a.length))),d}(e),l=c.endsWith("/")?c:c+"/";for(let a of h){let e=(0,b.resolve)(c,a);if(j(e))return(0,g.deny)(`Reading agent settings file blocked: ${e}`);if(!i(e)&&"/dev/null"!==e&&e!==c&&!e.startsWith(l)){if(d.some(a=>e===a||e.startsWith(a.endsWith("/")?a:a+"/")))continue;return(0,g.deny)(`Bash read outside project directory blocked: ${e}`)}}return(0,g.allow)()}let e=l(a),h=a.toolInput?.path??"",m=e||h;if(!m)return(0,g.allow)();let n=(0,b.resolve)(c,m);if(j(n))return(0,g.deny)(`Reading agent settings file blocked: ${n}`);if(i(n)||"/dev/null"===n)return(0,g.allow)();let o=c.endsWith("/")?c:c+"/";return n===c||n.startsWith(o)?(0,g.allow)():d.some(a=>n===a||n.startsWith(a.endsWith("/")?a:a+"/"))?(0,g.allow)():(0,g.deny)(`Access outside project directory blocked: ${n}`)},match:{events:["PreToolUse"],toolNames:["Read","Glob","Grep","Bash"]},defaultEnabled:!1,category:"Environment",params:{allowPaths:{type:"string[]",description:"Absolute paths outside cwd that are allowed to be read",default:[]}}},{name:"block-sudo",displayTitle:"Tried to run a command with sudo",impact:"Sudo gives the agent root — blocked unless explicitly allow-listed.",description:"Block sudo commands",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a).trimStart();return J.test(b)||b.startsWith("sudo ")?(a.params?.allowPatterns??[]).some(a=>as(b,a))?(0,g.allow)():(0,g.deny)("sudo commands are blocked"):K.test(b)?(0,g.deny)("Elevated process launch is blocked"):L.test(b)?(0,g.deny)("runas elevation is blocked"):(0,g.allow)()},match:{events:["PreToolUse","PermissionRequest"],toolNames:["Bash"]},defaultEnabled:!0,category:"Dangerous Commands",params:{allowPatterns:{type:"string[]",description:"Sudo command patterns to allow, matched token-by-token (e.g. 'sudo systemctl status')",default:[]}}},{name:"block-curl-pipe-sh",displayTitle:"Tried to pipe a downloaded script straight to a shell",impact:"`curl ... | sh` runs unverified remote code on your machine.",description:"Block piping downloads to shell",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return M.test(b)?(0,g.deny)("Piping downloads to shell is blocked"):N.test(b)?(0,g.deny)("Piping downloads to Invoke-Expression is blocked"):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!0,category:"Dangerous Commands"},{name:"block-rm-rf",displayTitle:"Tried to recursively delete a system path",impact:"Catches catastrophic `rm -rf /` and Windows equivalents.",description:"Prevent catastrophic deletions",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return aF(b).some(a=>{let b=aE(a);return null!==b&&b.some(aD)})?!function(a,b){if(0===b.length)return!1;let c=b.map(a=>aC(aB(a))||"/"),d=!1;for(let e of aF(a)){let a=aE(e);if(null!==a)for(let f of(d=!0,a)){let a=aC(aB(f))||"/";if(!c.some(b=>a===b||a.startsWith(b+"/"))&&!b.some(a=>{let b=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return RegExp(`${b}(?:[/"'\\s/*]|$)`).test(e)}))return!1}}return d}(b,a.params?.allowPaths??[])?(0,g.deny)("Catastrophic deletion blocked"):(0,g.allow)():/Remove-Item\s+.*-Recurse.*-Force.*(?:[A-Z]:\\(?:\s|$)|\\\*)/i.test(b)||/(?:rd|rmdir)\s+\/s\s+\/q\s+[A-Z]:\\/i.test(b)?(0,g.deny)("Catastrophic deletion blocked"):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Dangerous Commands",params:{allowPaths:{type:"string[]",description:"Paths that are allowed to be recursively deleted",default:[]}}},{name:"block-failproofai-commands",displayTitle:"Tried to disable or modify failproofai itself",impact:"Prevents the agent from turning off the policies that protect you.",description:"Block failproofai CLI commands and uninstallation",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return U.test(b)?(0,g.deny)("Running failproofai CLI commands is blocked"):V.test(b)?(0,g.deny)("Uninstalling failproofai is blocked"):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!0,category:"Dangerous Commands"},{name:"block-kubectl",displayTitle:"Tried to run a Kubernetes command",impact:"kubectl can change live cluster state — gated unless allow-listed.",description:"Block kubectl commands (Kubernetes cluster mutations)",fn:function(a){return aH(a,aj,"kubectl commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"kubectl command patterns to allow, matched token-by-token (e.g. 'kubectl get *', 'kubectl describe *')",default:[]}}},{name:"block-terraform",displayTitle:"Tried to run a Terraform/OpenTofu command",impact:"Terraform mutates real infrastructure — gated unless allow-listed.",description:"Block terraform and tofu (OpenTofu) commands",fn:function(a){return aH(a,ak,"terraform/tofu commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"terraform/tofu command patterns to allow (e.g. 'terraform plan', 'terraform validate')",default:[]}}},{name:"block-aws-cli",displayTitle:"Tried to run an AWS CLI command",impact:"AWS CLI can spend money or break prod — gated.",description:"Block aws CLI commands",fn:function(a){return aH(a,al,"aws CLI commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"aws CLI command patterns to allow (e.g. 'aws s3 ls *', 'aws sts get-caller-identity')",default:[]}}},{name:"block-gcloud",displayTitle:"Tried to run a Google Cloud command",impact:"gcloud can spend money or break prod — gated.",description:"Block gcloud (Google Cloud) CLI commands",fn:function(a){return aH(a,am,"gcloud commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"gcloud command patterns to allow (e.g. 'gcloud auth list', 'gcloud config list')",default:[]}}},{name:"block-az-cli",displayTitle:"Tried to run an Azure CLI command",impact:"az can spend money or break prod — gated.",description:"Block az (Azure) CLI commands",fn:function(a){return aH(a,an,"az (Azure) CLI commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"az CLI command patterns to allow (e.g. 'az account show', 'az group list')",default:[]}}},{name:"block-helm",displayTitle:"Tried to run a Helm command",impact:"Helm releases mutate cluster state — gated.",description:"Block helm commands",fn:function(a){return aH(a,ao,"helm commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"helm command patterns to allow (e.g. 'helm list', 'helm status *')",default:[]}}},{name:"block-gh-pipeline",displayTitle:"Tried to run a privileged GitHub CLI pipeline command",impact:"Catches `gh workflow run`, `gh pr merge`, `gh secret set`, etc.",description:"Block gh CLI pipeline-trigger subcommands (workflow run, run rerun/cancel, pr merge, release create/delete, cache delete, secret set/delete)",fn:function(a){return aH(a,ap,"gh pipeline-trigger commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"gh pipeline command patterns to allow (e.g. specific scripted invocations); read-only gh subcommands like 'gh pr view' and 'gh run list' are not matched by this policy",default:[]}}},{name:"block-secrets-write",displayTitle:"Tried to write a secret-key file",impact:"Stops the agent from creating `.pem`, `id_rsa`, `credentials.json`, etc.",description:"Block writing secret key files",fn:function(a){if("Write"!==a.toolName)return(0,g.allow)();let b=l(a);if(Q.test(b)||R.test(b)||S.test(b))return(0,g.deny)("Writing secret key files is blocked");for(let c of a.params?.additionalPatterns??[])if(b.includes(c))return(0,g.deny)(`Writing blocked file pattern: ${c}`);return(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Write"]},defaultEnabled:!1,category:"Dangerous Commands",params:{additionalPatterns:{type:"string[]",description:"Additional filename patterns (substrings) to block",default:[]}}},{name:"block-push-master",displayTitle:"Tried to push directly to main/master",impact:"Direct pushes to a protected branch bypass review.",description:"Block pushing to main/master",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=a.params?.protectedBranches??["main","master"];if(0===b.length)return(0,g.allow)();let c=at(k(a)),d=RegExp(`\\b(?:${b.map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\b`);return c.some(a=>d.test(a))?(0,g.deny)(`Pushing to ${b.join("/")} is blocked`):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!0,category:"Git",params:{protectedBranches:{type:"string[]",description:"Branch names to protect from direct pushes",default:["main","master"]}}},{name:"block-force-push",displayTitle:"Tried to force-push",impact:"Force-pushes rewrite history and can clobber teammates' work.",description:"Prevent force-pushing to any branch",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();for(let b of at(k(a))){let a=!1;for(let c of b.split(/\s+/)){if("--"===c){a=!0;continue}if(!a&&function(a){return"--force"===a||!P.some(b=>a.startsWith(b))&&(!!a.startsWith("--force")||O.test(a))}(c))return(0,g.deny)("Force-pushing is blocked")}}return(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Git"},{name:"block-work-on-main",displayTitle:"Tried to commit or merge on main/master",impact:"Work should land via PR — direct commits skip review.",description:"Block git commits and merges on main/master branch",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a).match(T);if(!b)return(0,g.allow)();let c=a.session?.cwd;if(!c)return(0,g.allow)();let d=ar(c);return d&&(a.params?.protectedBranches??["main","master"]).includes(d)?(0,g.deny)(`Git ${b[1]} on ${d} is blocked. Create a feature branch first.`):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Git",params:{protectedBranches:{type:"string[]",description:"Branch names where commits/merges are blocked",default:["main","master"]}}},{name:"warn-git-amend",displayTitle:"Used git commit --amend",impact:"Amending after a push rewrites history that others may have pulled.",description:"Warns before amending git commits, which rewrites history",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return W.test(b)?(0,g.instruct)("STOP: This command amends the last commit, which rewrites git history. If this commit has already been pushed to a shared branch, this will cause divergence for other contributors. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Git"},{name:"warn-git-stash-drop",displayTitle:"Tried to drop or clear git stash",impact:"Stash deletions are permanent and silent.",description:"Warns before permanently deleting stashed changes",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return X.test(b)?(0,g.instruct)("STOP: This command permanently deletes stashed changes (git stash drop/clear). Stash entries cannot be recovered after deletion. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Git"},{name:"warn-all-files-staged",displayTitle:"Staged all files with git add -A / .",impact:"Wide stages routinely catch generated files or secrets you didn't intend to commit.",description:"Warns before staging all working tree files with git add -A / . / --all",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return Y.test(b)?(0,g.instruct)("STOP: This command stages all files in the working tree (git add -A / --all / .). This may inadvertently include build artifacts, generated files, or sensitive files not covered by .gitignore. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Git"},{name:"warn-destructive-sql",displayTitle:"Ran destructive SQL (DROP / TRUNCATE / DELETE without WHERE)",impact:"Easy way to wipe a table by accident.",description:"Warn before executing destructive SQL (DROP/TRUNCATE/DELETE without WHERE) via database clients",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return u.test(b)&&(v.test(b)||w.test(b)&&!x.test(b))?(0,g.instruct)("STOP: This command contains destructive SQL (DROP/TRUNCATE/DELETE). Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Database"},{name:"warn-schema-alteration",displayTitle:"Altered a database schema column",impact:"ALTER TABLE operations can lock tables and break readers.",description:"Warns before SQL schema changes (ALTER TABLE with column or rename operations)",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return u.test(b)&&y.test(b)?(0,g.instruct)("STOP: This command contains a schema-altering SQL statement (ALTER TABLE with column or rename operation). Schema changes on production databases are irreversible or disruptive. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Database"},{name:"warn-package-publish",displayTitle:"Tried to publish a package",impact:"Publishes are irreversible — `npm publish` / `cargo publish` shouldn't happen without intent.",description:"Warn before publishing packages to public registries (npm, PyPI, crates.io, RubyGems, etc.)",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return z.test(b)?(0,g.instruct)("STOP: This command publishes a package to a public registry. Confirm with the user that this is intentional."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Packages & System"},{name:"warn-global-package-install",displayTitle:"Installed a package globally",impact:"`npm i -g`, `cargo install`, `pip --user` pollute your machine outside the project.",description:"Warns before installing packages globally (npm -g, cargo install, etc.)",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return Z.test(b)||$.test(b)||_.test(b)||aa.test(b)||ab.test(b)||ac.test(b)?(0,g.instruct)("STOP: This command installs a package globally, which modifies the system-wide environment outside the project. This can conflict with other projects or system tools. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Packages & System"},{name:"prefer-package-manager",displayTitle:"Used a non-preferred package manager",impact:"Mixing package managers creates lockfile churn for your team.",description:"Blocks non-preferred package managers and tells Claude to use an allowed one (e.g., uv instead of pip)",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);if(!b)return(0,g.allow)();let c=a.params?.allowed??[];if(0===c.length)return(0,g.allow)();let d=new Set(c.map(a=>a.toLowerCase())),e=a.params?.blocked??[],f=c.join(", ");for(let a of b.split(aI)){let b=a.trim();if(!b)continue;let c=!1;for(let a of d){let d=ad[a];if(d){for(let a of d)if(a.test(b)){c=!0;break}if(c)break}}if(!c){for(let[a,c]of Object.entries(ad))if(!d.has(a)){for(let d of c)if(d.test(b))return(0,g.deny)(`"${a}" is not an allowed package manager. Allowed package managers for this project: ${f}. Rewrite this command using an allowed package manager.`)}for(let a of e){let c=a.toLowerCase();if(!d.has(c)&&RegExp(`\\b${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(b))return(0,g.deny)(`"${c}" is not an allowed package manager. Allowed package managers for this project: ${f}. Rewrite this command using an allowed package manager.`)}}}return(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Packages & System",params:{allowed:{type:"string[]",description:"Allowed package manager names (e.g. ['uv', 'bun']). Any detected manager not in this list is blocked.",default:[]},blocked:{type:"string[]",description:"Additional manager names to block beyond the built-in list (e.g. ['pdm', 'pipx']).",default:[]}}},{name:"warn-large-file-write",displayTitle:"Wrote a file larger than the configured threshold",impact:"Catches accidentally large file writes (logs, binaries, model dumps).",description:"Warn before writing files larger than 1MB (configurable via thresholdKb param)",fn:function(a){if("Write"!==a.toolName)return(0,g.allow)();let b=a.toolInput?.content;if("string"!=typeof b)return(0,g.allow)();let c=a.params?.thresholdKb??1024;return b.length>1024*c?(0,g.instruct)(`STOP: You are writing a file larger than ${c}KB (${Math.round(b.length/1024)}KB). This is unusually large. Confirm this is intentional before proceeding.`):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Write"]},defaultEnabled:!1,category:"Packages & System",params:{thresholdKb:{type:"number",description:"File size threshold in KB above which a warning is issued",default:1024}}},{name:"warn-background-process",displayTitle:"Started a long-lived background process",impact:"Catches `nohup` / `&` / `screen` / `tmux` / `disown` patterns that the agent often forgets to clean up.",description:"Warns before starting detached or background processes",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return ae.test(b)||af.test(b)||ag.test(b)||ah.test(b)||ai.test(b)?(0,g.instruct)("STOP: This command starts a background or detached process (nohup, screen -d, tmux -d, or trailing &). Background processes persist after Claude's session and may be difficult to track or stop. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Packages & System"},{name:"warn-repeated-tool-calls",displayTitle:"Called the same tool 3+ times with identical arguments",impact:"Usually a sign of a stuck loop burning tokens.",description:"Warn when the same tool is called 3+ times with identical parameters",fn:async function a(a){let b=a.session?.transcriptPath;if(!b||!a.toolName||!a.toolInput)return(0,g.allow)();let c=`${b}.tool-calls.json`,e=JSON.stringify({tool:a.toolName,input:a.toolInput}),f={};try{let a=await (0,d.readFile)(c,"utf8");f=JSON.parse(a)}catch{}let h=f[e]??0;if(h>=3)return(0,g.instruct)(`STOP: You have already called ${a.toolName} ${h} times with identical parameters. This is wasteful and unproductive. Do NOT repeat this call — use a different approach or ask the user for clarification.`);f[e]=h+1;try{let a=JSON.stringify(f);a.length<=65536&&await (0,d.writeFile)(c,a,"utf8")}catch{}return(0,g.allow)()},match:{events:["PreToolUse"]},defaultEnabled:!1,category:"AI Behavior"},{name:"require-commit-before-stop",displayTitle:"Stopped with uncommitted changes",impact:"Work not in a commit is invisible to teammates and easy to lose.",description:"Require all changes to be committed before Claude stops",fn:function(a){if(aJ(a))return(0,g.allow)("Plan mode — no changes made, skipping commit check.");let b=a.session?.cwd;if(!b)return(0,g.allow)("No working directory available, skipping commit check.");try{if((0,e.execSync)("git status --porcelain",{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim().length>0)return(0,g.deny)("You have uncommitted changes in the working directory. Commit all changes now.");return(0,g.allow)("All changes are committed.")}catch{return(0,g.allow)("Not a git repository, skipping commit check.")}},match:{events:["Stop"]},defaultEnabled:!1,category:"Workflow"},{name:"require-push-before-stop",displayTitle:"Stopped with unpushed commits",impact:"Local-only commits won't trigger CI or be reviewable.",description:"Require all commits to be pushed to remote before Claude stops",fn:function(a){if(aJ(a))return(0,g.allow)("Plan mode — no changes made, skipping push check.");let b=a.session?.cwd;if(!b)return(0,g.allow)("No working directory available, skipping push check.");try{if(!(0,e.execSync)("git remote",{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3}).trim())return(0,g.allow)("No git remote configured, skipping push check.");let c=a.params?.remote??"origin",d=ar(b);if(!d||"HEAD"===d)return(0,g.allow)("Detached HEAD, skipping push check.");let f=a.params?.baseBranch??"main";if(d===f)return(0,g.allow)(`On base branch "${f}", skipping push check.`);try{if(!(0,e.execFileSync)("git",["log",`${c}/${f}..HEAD`,"--oneline"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim())return(0,g.allow)(`No commits ahead of ${c}/${f}, skipping push check.`);if(!(0,e.execFileSync)("git",["diff","--stat",`${c}/${f}`,"HEAD"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim())return(0,g.allow)(`No file changes compared to ${c}/${f}, skipping push check.`)}catch{}let h=!1;try{(0,e.execFileSync)("git",["rev-parse","--verify",`${c}/${d}`],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3}),h=!0}catch{}if(!h)return(0,g.deny)(`Branch "${d}" has not been pushed to remote "${c}". Run now: git push -u ${c} ${d}`);let i=(0,e.execFileSync)("git",["log",`${c}/${d}..HEAD`,"--oneline"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim();if(i.length>0){let a=i.split("\n").length;return(0,g.deny)(`You have ${a} unpushed commit${a>1?"s":""} on branch "${d}". Run now: git push`)}return(0,g.allow)(`All commits pushed to "${c}".`)}catch{return(0,g.allow)("Could not check push status, skipping.")}},match:{events:["Stop"]},defaultEnabled:!1,category:"Workflow",params:{remote:{type:"string",description:"Remote name to push to (default: origin)",default:"origin"},baseBranch:{type:"string",description:"Base branch to compare against (default: main)",default:"main"}}},{name:"require-pr-before-stop",displayTitle:"Stopped without a PR for the branch",impact:"Branches without PRs don't get reviewed.",description:"Require a pull request to exist for the current branch before Claude stops",fn:function(a){if(aJ(a))return(0,g.allow)("Plan mode — no changes made, skipping PR check.");let b=a.session?.cwd;if(!b)return(0,g.allow)("No working directory available, skipping PR check.");try{let c;try{(0,e.execSync)("gh --version",{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3})}catch{return(0,g.allow)("GitHub CLI (gh) not installed, skipping PR check.")}let d=ar(b);if(!d||"HEAD"===d)return(0,g.allow)("Detached HEAD, skipping PR check.");let f=a.params?.baseBranch??"main";if(d===f)return(0,g.allow)(`On base branch "${f}", skipping PR check.`);try{if(!(0,e.execFileSync)("git",["log",`origin/${f}..HEAD`,"--oneline"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim())return(0,g.allow)(`No commits ahead of origin/${f}, skipping PR check.`);if(!(0,e.execFileSync)("git",["diff","--stat",`origin/${f}`,"HEAD"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim())return(0,g.allow)(`No file changes compared to origin/${f}, skipping PR check.`)}catch{}try{c=(0,e.execSync)("gh pr view --json number,url,state",{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}).trim()}catch{return(0,g.deny)(`No pull request found for branch "${d}". Run now: gh pr create`)}let h=JSON.parse(c);if("OPEN"===h.state)return(0,g.allow)(`PR #${h.number} exists: ${h.url}`);if("MERGED"===h.state)return(0,g.allow)(`PR #${h.number} was merged: ${h.url}. Switch off this branch (e.g. 'git checkout ${f} && git pull') before stopping again.`);return(0,g.deny)(`Pull request for branch "${d}" is ${h.state.toLowerCase()}. Run now: gh pr create`)}catch{return(0,g.allow)("Could not check PR status, skipping.")}},match:{events:["Stop"]},defaultEnabled:!1,category:"Workflow",params:{baseBranch:{type:"string",description:"Base branch to compare against (default: main)",default:"main"}}},{name:"require-no-conflicts-before-stop",displayTitle:"Stopped with a branch that conflicts with main",impact:"Conflicting branches can't merge — surface them early.",description:"Require the current branch to merge cleanly with the base branch before Claude stops",fn:function(a){let b,c;if(aJ(a))return(0,g.allow)("Plan mode — no changes made, skipping conflict check.");let d=a.session?.cwd;if(!d)return(0,g.allow)("No working directory available, skipping conflict check.");let f=ar(d);if(!f||"HEAD"===f)return(0,g.allow)("Detached HEAD, skipping conflict check.");let h=a.params?.baseBranch??"main";if(f===h)return(0,g.allow)(`On base branch "${h}", skipping conflict check.`);try{(0,e.execSync)("gh --version",{cwd:d,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3})}catch{return(0,g.allow)("gh CLI not installed, skipping conflict check.")}try{b=(0,e.execSync)("gh pr view --json mergeable,number,url,state",{cwd:d,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}).trim()}catch{return(0,g.allow)("No pull request found for branch, skipping conflict check.")}try{c=JSON.parse(b)}catch{return(0,g.allow)("Could not parse gh pr view output, skipping conflict check.")}if("OPEN"!==c.state)return(0,g.allow)(`PR #${c.number} is ${c.state.toLowerCase()}; skipping conflict check.`);try{(0,e.execFileSync)("git",["rev-parse","--verify",`origin/${h}`],{cwd:d,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3}),(0,e.execFileSync)("git",["log",`origin/${h}..HEAD`,"--oneline"],{cwd:d,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim()&&(0,e.execFileSync)("git",["merge-tree","--write-tree","--name-only",`origin/${h}`,"HEAD"],{cwd:d,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:1e4})}catch(a){if(1===a.status){let b=("string"==typeof a.stdout?a.stdout:a.stdout?.toString("utf8")??"").trim().split("\n"),c=[];for(let a=1;a<b.length;a++){let d=b[a];if(""===d)break;c.push(d)}let d=c.length?c.join(", "):"one or more files";return(0,g.deny)(`Branch "${f}" has merge conflicts with ${h} in: ${d}. Rebase or merge origin/${h} now and resolve the conflicts.`)}}return"CONFLICTING"===c.mergeable?(0,g.deny)(`PR #${c.number} has merge conflicts per GitHub (${c.url}). Rebase or merge origin/${h} now and resolve the conflicts.`):"UNKNOWN"===c.mergeable?(0,g.deny)(`GitHub is still computing mergeability for PR #${c.number} (${c.url}). Wait ~10 seconds, then re-check with \`gh pr view --json mergeable\` before attempting to stop again.`):(0,g.allow)(`PR #${c.number} merges cleanly per GitHub.`)},match:{events:["Stop"]},defaultEnabled:!1,category:"Workflow",params:{baseBranch:{type:"string",description:"Base branch to check for conflicts against (default: main)",default:"main"}}},{name:"require-ci-green-before-stop",displayTitle:"Stopped with failing CI",impact:"Failing CI blocks deploy.",description:"Require CI checks to pass on the current HEAD commit before Claude stops (ignores stale runs on prior commits)",fn:function(a){if(aJ(a))return(0,g.allow)("Plan mode — no changes made, skipping CI check.");let b=a.session?.cwd;if(!b)return(0,g.allow)("No working directory available, skipping CI check.");try{try{(0,e.execSync)("gh --version",{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3})}catch{return(0,g.allow)("GitHub CLI (gh) not installed, skipping CI check.")}let a=ar(b);if(!a||"HEAD"===a)return(0,g.allow)("Detached HEAD, skipping CI check.");let c=function(a){try{return(0,e.execSync)("git rev-parse HEAD",{cwd:a,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3}).trim()||null}catch{return null}}(b),d=[];try{let f=(0,e.execFileSync)("gh",["run","list","--branch",a,"--limit","20","--json","status,conclusion,name,headSha"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}).trim();if(f&&"[]"!==f){let a=JSON.parse(f),b=c?a.filter(a=>a.headSha===c):a,e=new Set;d=b.filter(a=>!e.has(a.name)&&(e.add(a.name),!0))}}catch{}let f=[],h=[];c&&(f=function(a,b){try{let c=(0,e.execFileSync)("gh",["api",`repos/{owner}/{repo}/commits/${b}/check-runs`,"--jq",'.check_runs | map(select(.app.slug != "github-actions")) | map({name: .name, status: .status, conclusion: (.conclusion // "")})'],{cwd:a,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}).trim();if(!c||"[]"===c)return[];return JSON.parse(c)}catch{return[]}}(b,c),h=function(a,b){try{let c=(0,e.execFileSync)("gh",["api",`repos/{owner}/{repo}/commits/${b}/statuses`,"--jq","map({name: .context, state: .state}) | unique_by(.name)"],{cwd:a,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}).trim();if(!c||"[]"===c)return[];return JSON.parse(c).map(a=>({name:a.name,status:"pending"===a.state?"in_progress":"completed",conclusion:"pending"===a.state?"":"success"===a.state?"success":"failure"}))}catch{return[]}}(b,c));let i=[...d,...f,...h];if(0===i.length)return(0,g.allow)(`No CI runs found for branch "${a}".`);let j=i.filter(a=>"completed"===a.status&&"success"!==a.conclusion&&"skipped"!==a.conclusion&&"cancelled"!==a.conclusion&&"neutral"!==a.conclusion);if(j.length>0){let b=j.map(a=>`"${a.name}"`).join(", ");return(0,g.deny)(`CI checks are failing on branch "${a}": ${b}. Fix the failing checks now.`)}let k=i.filter(a=>"in_progress"===a.status||"queued"===a.status||"waiting"===a.status);if(k.length>0){let b=k.map(a=>`"${a.name}"`).join(", ");return(0,g.deny)(`CI checks are still running on branch "${a}": ${b}. Wait for all checks to complete, then verify they pass.`)}return(0,g.allow)(`All CI checks passed on branch "${a}".`)}catch{return(0,g.allow)("Could not check CI status, skipping.")}},match:{events:["Stop"]},defaultEnabled:!1,category:"Workflow"}];a.s(["BUILTIN_POLICIES",0,aK])}];
|
|
3
|
+
`;(0,b.appendFileSync)(e,g,"utf-8")}catch{}}a.s(["hookLogError",0,function(a){k("error")&&(l("ERROR",a),m("ERROR",a))},"hookLogWarn",0,function(a){k("warn")&&(l("WARN",a),m("WARN",a))}])},92956,a=>{"use strict";var b=a.i(50227),c=a.i(2157),d=a.i(12714),e=a.i(74533),f=a.i(60526),g=a.i(62882),h=a.i(10695);let i=function(a){let c=a.replaceAll("\\","/");for(let a of[".claude",".codex",".copilot",".cursor",".opencode",".pi",".gemini"]){let d=(0,b.join)((0,f.homedir)(),a).replaceAll("\\","/");if(c===d||c.startsWith(d+"/"))return!0}for(let a of[(0,b.join)(".config","opencode"),(0,b.join)(".local","share","opencode")]){let d=(0,b.join)((0,f.homedir)(),a).replaceAll("\\","/");if(c===d||c.startsWith(d+"/"))return!0}return!1},j=function(a){return!!(/[\\/]\.claude[\\/]settings(?:\.[^/\\]+)?\.json$/.test(a)||/[\\/]\.codex[\\/]hooks\.json$/.test(a)||/[\\/]\.copilot[\\/]hooks[\\/][^/\\]+\.json$/.test(a)||/[\\/]\.github[\\/]hooks[\\/][^/\\]+\.json$/.test(a)||/[\\/]\.cursor[\\/]hooks\.json$/.test(a)||/[\\/]\.opencode[\\/]opencode\.jsonc?$/.test(a)||/[\\/]\.opencode[\\/]plugins[\\/][^/\\]+\.(?:mjs|js|ts)$/.test(a)||/[\\/]\.config[\\/]opencode[\\/]opencode\.jsonc?$/.test(a)||/[\\/]\.config[\\/]opencode[\\/]config\.json$/.test(a)||/[\\/]\.config[\\/]opencode[\\/]plugins[\\/][^/\\]+\.(?:mjs|js|ts)$/.test(a)||/[\\/]\.pi[\\/](?:agent[\\/])?settings\.json$/.test(a)||/[\\/]\.pi[\\/](?:agent[\\/])?extensions[\\/]/.test(a)||/[\\/]\.gemini[\\/]settings\.json$/.test(a)||/[\\/]\.gemini[\\/]config[\\/]hooks\.json$/.test(a))};function k(a){return a.toolInput?.command??""}function l(a){return a.toolInput?.file_path??""}function m(a){return a.trim().split(/\s+/).map(a=>a.replace(/^['"]|['"]$/g,""))}let n=new Set(["&&","||","|",";"]),o=/[;&<>`$()\\]/,p=/eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/,q=[[/sk-ant-[A-Za-z0-9\-_]{20,}/,"Anthropic API key"],[/sk-proj-[A-Za-z0-9\-_]{20,}/,"OpenAI project API key"],[/sk-[A-Za-z0-9]{20,}/,"OpenAI API key"],[/ghp_[A-Za-z0-9]{36}/,"GitHub personal access token"],[/github_pat_[A-Za-z0-9_]{82}/,"GitHub fine-grained token"],[/AKIA[A-Z0-9]{16}/,"AWS access key ID"],[/sk_live_[A-Za-z0-9]{24,}/,"Stripe live secret key"],[/sk_test_[A-Za-z0-9]{24,}/,"Stripe test secret key"],[/AIza[0-9A-Za-z\-_]{35}/,"Google API key"]],r=/(?:postgresql|postgres|mysql|mongodb(?:\+srv)?|redis|amqps?|smtps?):\/\/[^@\s]+@/,s=/-----BEGIN (?:[A-Z]+ )?PRIVATE KEY-----/,t=/Authorization:\s*Bearer\s+[A-Za-z0-9\-._~+/]{20,}/i,u=/\b(?:psql|mysql|sqlite3|pgcli|clickhouse-client)\b/,v=/\b(?:DROP\s+(?:TABLE|DATABASE|SCHEMA)|TRUNCATE\b)/i,w=/\bDELETE\s+FROM\b/i,x=/\bWHERE\b/i,y=/\bALTER\s+TABLE\b[\s\S]*\b(?:DROP\s+COLUMN|ADD\s+COLUMN|RENAME\s+(?:COLUMN|TO)|MODIFY\s+COLUMN)\b/i,z=/(?:npm\s+publish|bun\s+publish|pnpm\s+publish|yarn\s+npm\s+publish|twine\s+upload|poetry\s+publish|cargo\s+publish|gem\s+push)\b/,A=/(?:^|\s|;|&&|\|\|)(?:env|printenv)(?:\s|$|;|&&|\|)/,B=/echo\s+.*\$\{?[A-Za-z_]/,C=/(?:^|\s|;|&&|\|\|)export\s+\w+/,D=/\$env:[A-Za-z_]/i,E=/(?:Get-ChildItem|dir|gci|ls)\s+Env:/i,F=/\[Environment\]::GetEnvironment/i,G=/echo\s+%[A-Za-z_]/i,H=/(?:^|[\\/])\.env(?:\.|$)/,I=/\.env(?:\b|\s|$|\.)/,J=/(?:^|;|&&|\|\|)\s*sudo\s/,K=/Start-Process\s+.*-Verb\s+RunAs/i,L=/(?:^|;|&&|\|\|)\s*runas\s/i,M=/(?:curl|wget)\s.*\|\s*(?:sh|bash|zsh|dash|ksh|csh|tcsh|fish|ash)\b/,N=/failproofai[^\s]*(?:\s+\S+)*?\s+(?:config|configure|setup)\b(?:\s+\S+)*?\s+--pause\b/,O=/(?:Invoke-WebRequest|iwr|Invoke-RestMethod|irm)\s+.*\|\s*(?:Invoke-Expression|iex)/i,P=/^-[a-zA-Z]*f[a-zA-Z]*$/,Q=["--force-with-lease","--force-if-includes"],R=/\.(?:pem|key)$/,S=/id_rsa/,T=/credentials/,U=/git\s+(commit|merge|rebase|cherry-pick)\b/,V=/(?:^|;|&&|\|\||\|)\s*failproofai(?:\s|$)/,W=/(?:npm\s+(?:uninstall|remove|un|r)\s.*failproofai|bun\s+remove\s.*failproofai|yarn\s+global\s+remove\s+failproofai|pnpm\s+(?:remove|uninstall|un)\s.*failproofai)/,X=/\bgit\s+commit\b.*--amend\b/,Y=/\bgit\s+stash\s+(?:drop|clear)\b/,Z=/\bgit\s+add\s+(?:-A\b|--all\b|\.(?:\s|$|;|&&|\|\|))/,$=/\bnpm\s+(?:install|i)\b(?=.*(?:\s-g\b|--global\b))/,_=/\byarn\s+global\s+add\b/,aa=/\bpnpm\s+(?:add|install|i)\b(?=.*(?:\s-g\b|--global\b))/,ab=/\bbun\s+(?:install|add)\b(?=.*(?:\s-g\b|--global\b))/,ac=/\bcargo\s+install\b/,ad=/\bpip(?:3)?\s+install\b(?=.*(?:--user\b|--break-system-packages\b))/,ae={pip:[/\bpip\b/,/\bpip3\b/,/\bpython3?\s+-m\s+pip\b/],npm:[/\bnpm\b/,/\bnpx\b/],yarn:[/\byarn\b/],pnpm:[/\bpnpm\b/,/\bpnpx\b/],bun:[/\bbun\b/,/\bbunx\b/],uv:[/\buv\b/],poetry:[/\bpoetry\b/],pipenv:[/\bpipenv\b/],conda:[/\bconda\b/],cargo:[/\bcargo\b/]},af=/\bnohup\s+\S/,ag=/\bscreen\s+-[A-Za-z]*d[A-Za-z]*\b/,ah=/\btmux\s+(?:new-session|new)\b[^|&;]*-d\b/,ai=/\bdisown\b/,aj=/(?<![&|])\s?&\s*(?:$|#|;)/,ak=/(?:^|[;\n]|&&|\|\|?|&)\s*kubectl(?:\s|$)/,al=/(?:^|[;\n]|&&|\|\|?|&)\s*(?:terraform|tofu)(?:\s|$)/,am=/(?:^|[;\n]|&&|\|\|?|&)\s*aws(?:\s|$)/,an=/(?:^|[;\n]|&&|\|\|?|&)\s*gcloud(?:\s|$)/,ao=/(?:^|[;\n]|&&|\|\|?|&)\s*az(?:\s|$)/,ap=/(?:^|[;\n]|&&|\|\|?|&)\s*helm(?:\s|$)/,aq=/(?:^|[;\n]|&&|\|\|?|&)\s*gh\s+(?:workflow\s+(?:run|enable|disable)|run\s+(?:rerun|cancel)|pr\s+merge|release\s+(?:create|delete)|cache\s+delete|secret\s+(?:set|delete))\b/,ar=new Map;function as(a){try{let d=function(a){try{return(0,c.statSync)((0,b.join)(a,".git","HEAD")).mtimeMs}catch{return null}}(a),f=ar.get(a);if(f&&null!==d&&f.headMtimeMs===d)return f.branch||null;let g=(0,e.execSync)("git rev-parse --abbrev-ref HEAD",{cwd:a,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3}).trim();return null!==d&&(ar.size>=500&&ar.clear(),ar.set(a,{branch:g,headMtimeMs:d})),g||null}catch{return null}}function at(a,b){let c=m(a),d=m(b);return!(c.length<d.length||c.some(a=>n.has(a))||c.some(a=>o.test(a)))&&d.every((a,b)=>"*"===a||a===c[b])}function au(a){return a.split(/&&|\|\||[|;\n]/).map(a=>a.trim()).filter(a=>/^git\s+push\s/.test(a)).map(a=>a.replace(/^git\s+push\s+/,""))}let av=/^(?:~[A-Za-z0-9_.-]*|\$HOME|\$\{HOME\})(?=$|\/)/,aw=/^(?:\/\S*\/)?rm$/,ax=/^(?:\/\S*\/)?find$/,ay=/^-(?:exec|execdir|ok|okdir)$/,az=/^-(?:[HLP]|D|O\d*)$/,aA=/^(?:-|\\?[(!])/,aB=["/tmp","/var/tmp"];function aC(a){let b=a.match(/^(?:~|\$HOME|\$\{HOME\})(?=$|\/)/);return b?(0,f.homedir)()+a.slice(b[0].length):a}function aD(a){return a.replace(/\/\*$/,"").replace(/\/+$/,"")}function aE(a){let b=a.replace(/^['"]|['"]$/g,"");if(""===b)return!1;let c=b.match(av);if(!c&&/^[$`]/.test(b))return!0;let d=c?b.slice(c[0].length):b.startsWith("/")?b:null;if(null===d)return!1;let e=aD(d).split("/").filter(Boolean);return!(!c&&aB.some(a=>`/${e.join("/")}`.startsWith(`${a}/`)))&&e.length<=2}function aF(a){let b=m(a),c=b.findIndex(a=>ax.test(a));if(c>=0){let a=b.slice(c+1),d=a.findIndex(a=>ay.test(a));if(a.includes("-delete")||d>=0&&aw.test(a[d+1]??"")){let b=0;for(;b<a.length&&az.test(a[b]);)b+="-D"===a[b]?2:1;let c=a.slice(b),d=c.findIndex(a=>aA.test(a));return d<0?c:c.slice(0,d)}}let d=b.findIndex(a=>aw.test(a));if(d>=0){let a=b.slice(d+1),c=a.filter(a=>/^-[^-]/.test(a)).join(""),e=a.filter(a=>/^--/.test(a)),f=/r/i.test(c)||e.some(a=>/^--recursive$/i.test(a)),g=/f/.test(c)||e.some(a=>/^--force$/i.test(a));if(f&&g)return a.filter(a=>!a.startsWith("-"))}return null}function aG(a){return a.split(/&&|\|\||[|;\n]/).map(a=>a.trim()).filter(a=>""!==a)}let aH=/(?:^|;|&&|\|\||\|)\s*(?:ls|find|cat|head|tail|less|more|wc|file|stat|tree|du)\s/;function aI(a,b,c){if("Bash"!==a.toolName)return(0,g.allow)();let d=k(a);return!b.test(d)||(a.params?.allowPatterns??[]).some(a=>at(d,a))?(0,g.allow)():(0,g.deny)(c)}let aJ=/\s*(?:&&|\|\||\||;)\s*/;function aK(a){return a.session?.permissionMode==="plan"}let aL=[{name:"sanitize-jwt",description:"Stop Claude from reading JWTs in tool responses",displayTitle:"Redacted JWT tokens from tool output",impact:"Stops the agent from echoing auth tokens it saw in command output.",fn:function(a){let b=JSON.stringify(a.payload);return p.test(b)?{decision:"deny",reason:"JWT token detected in tool output",message:"[REDACTED: JWT token removed by failproofai]"}:(0,g.allow)()},match:{events:["PostToolUse"]},defaultEnabled:!0,category:"Sanitize"},{name:"sanitize-api-keys",description:"Stop Claude from reading API keys (OpenAI, Anthropic, GitHub, AWS, Stripe, Google) in tool responses",displayTitle:"Redacted API keys from tool output",impact:"Catches OpenAI / Anthropic / GitHub / AWS / Stripe / Google keys before the model sees them.",fn:function(a){let b=JSON.stringify(a.payload);for(let[a,c]of q)if(a.test(b))return{decision:"deny",reason:`${c} detected in tool output`,message:`[REDACTED: ${c} removed by failproofai]`};for(let{regex:c,label:d}of a.params?.additionalPatterns??[])try{if(new RegExp(c).test(b))return{decision:"deny",reason:`${d} detected in tool output`,message:`[REDACTED: ${d} removed by failproofai]`}}catch{(0,h.hookLogWarn)(`additionalPatterns: invalid regex "${c}", skipping`)}return(0,g.allow)()},match:{events:["PostToolUse"]},defaultEnabled:!0,category:"Sanitize",params:{additionalPatterns:{type:"pattern[]",description:"Additional API key patterns to scrub, each with { regex, label }",default:[]}}},{name:"sanitize-connection-strings",description:"Stop Claude from reading database connection strings with embedded credentials in tool responses",displayTitle:"Redacted database connection strings from tool output",impact:"Strips embedded DB credentials before they reach the model context.",fn:function(a){let b=JSON.stringify(a.payload);return r.test(b)?{decision:"deny",reason:"Database connection string with credentials detected in tool output",message:"[REDACTED: connection string removed by failproofai]"}:(0,g.allow)()},match:{events:["PostToolUse"]},defaultEnabled:!0,category:"Sanitize"},{name:"sanitize-private-key-content",description:"Stop Claude from reading PEM private key content in tool responses",displayTitle:"Redacted PEM private keys from tool output",impact:"Prevents private key bodies from being echoed into chat context.",fn:function(a){let b=JSON.stringify(a.payload);return s.test(b)?{decision:"deny",reason:"Private key content detected in tool output",message:"[REDACTED: private key content removed by failproofai]"}:(0,g.allow)()},match:{events:["PostToolUse"]},defaultEnabled:!0,category:"Sanitize"},{name:"sanitize-bearer-tokens",displayTitle:"Redacted bearer tokens from tool output",impact:"Strips Authorization: Bearer values before they hit the model.",description:"Stop Claude from reading Authorization Bearer tokens in tool responses",fn:function(a){let b=JSON.stringify(a.payload);return t.test(b)?{decision:"deny",reason:"Bearer token detected in tool output",message:"[REDACTED: Bearer token removed by failproofai]"}:(0,g.allow)()},match:{events:["PostToolUse"]},defaultEnabled:!0,category:"Sanitize"},{name:"protect-env-vars",displayTitle:"Tried to dump environment variables to chat",impact:"Env vars often contain secrets; blocking `env` / `printenv` keeps them out of the model context.",description:"Prevent commands that read environment variables",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return A.test(b)?(0,g.deny)("Command reads environment variables"):B.test(b)?(0,g.deny)("Command echoes environment variable"):C.test(b)?(0,g.deny)("Command exports environment variable"):D.test(b)?(0,g.deny)("Command reads environment variable via PowerShell"):E.test(b)?(0,g.deny)("Command reads environment variables via PowerShell"):F.test(b)?(0,g.deny)("Command reads environment variable via .NET"):G.test(b)?(0,g.deny)("Command echoes environment variable via cmd"):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!0,category:"Environment"},{name:"block-env-files",displayTitle:"Tried to read or write a .env file",impact:"`.env` files routinely contain API keys and DB credentials.",description:"Block reading/writing .env files",fn:function(a){let b=k(a),c=l(a);return c&&H.test(c)?(0,g.deny)("Access to .env file blocked"):"Bash"===a.toolName&&I.test(b)?(0,g.deny)("Command references .env file"):(0,g.allow)()},match:{events:["PreToolUse"]},defaultEnabled:!0,category:"Environment"},{name:"block-read-outside-cwd",displayTitle:"Tried to read files outside your project directory",impact:"Stops the agent from peeking at neighboring repos or your home directory.",description:"Block file reads outside the session working directory",fn:function(a){let c=process.env.CLAUDE_PROJECT_DIR||a.session?.cwd;if(!c)return(0,g.allow)();let d=a.params?.allowPaths??[];if("Bash"===a.toolName){let e=k(a);if(!aH.test(e))return(0,g.allow)();let h=function(a){let c,d=[],e=/(?<![a-zA-Z0-9_.\-~\\*?:=])(?:~\/[^\s;|&"'()\[\]{}]*|~(?=\s|$|[;|&"'()\[\]{}])|\/[^\s;|&"'()\[\]{}]*)/g;function g(a){let c;for(e.lastIndex=0;null!==(c=e.exec(a));){let a=c[0];"~"===a?a=(0,f.homedir)():a.startsWith("~/")&&(a=(0,b.join)((0,f.homedir)(),a.slice(2))),d.push(a)}}let h=a.length,i=!1,j=!1;for(let b=0;b<a.length;b++){let c=a[b];if('"'!==c||j)if("'"!==c||i){if("|"===c&&!i&&!j){h=b;break}}else j=!j;else i=!i}let k=a.slice(0,h),l=/"([^"]*)"|'([^']*)'/g;for(;null!==(c=l.exec(k));){let a=c[1]??c[2]??"";/[*?\[\]^$+()\\]/.test(a)||g(a)}return g(a.replace(/"[^"]*"/g,a=>" ".repeat(a.length)).replace(/'[^']*'/g,a=>" ".repeat(a.length))),d}(e),l=c.endsWith("/")?c:c+"/";for(let a of h){let e=(0,b.resolve)(c,a);if(j(e))return(0,g.deny)(`Reading agent settings file blocked: ${e}`);if(!i(e)&&"/dev/null"!==e&&e!==c&&!e.startsWith(l)){if(d.some(a=>e===a||e.startsWith(a.endsWith("/")?a:a+"/")))continue;return(0,g.deny)(`Bash read outside project directory blocked: ${e}`)}}return(0,g.allow)()}let e=l(a),h=a.toolInput?.path??"",m=e||h;if(!m)return(0,g.allow)();let n=(0,b.resolve)(c,m);if(j(n))return(0,g.deny)(`Reading agent settings file blocked: ${n}`);if(i(n)||"/dev/null"===n)return(0,g.allow)();let o=c.endsWith("/")?c:c+"/";return n===c||n.startsWith(o)?(0,g.allow)():d.some(a=>n===a||n.startsWith(a.endsWith("/")?a:a+"/"))?(0,g.allow)():(0,g.deny)(`Access outside project directory blocked: ${n}`)},match:{events:["PreToolUse"],toolNames:["Read","Glob","Grep","Bash"]},defaultEnabled:!1,category:"Environment",params:{allowPaths:{type:"string[]",description:"Absolute paths outside cwd that are allowed to be read",default:[]}}},{name:"block-self-pause",displayTitle:"Tried to pause failproofai enforcement",impact:"An agent that can pause enforcement can switch off every other policy.",description:"Block agents from pausing failproofai enforcement",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return N.test(b)||N.test(b.replace(/\\\r?\n/g,"").replace(/\$'((?:[^'\\]|\\.)*)'/g,(a,b)=>b.replace(/\\(x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{1,4}|U[0-9A-Fa-f]{1,8}|[0-7]{1,3}|.)/g,(a,b)=>{try{if("x"===b[0])return String.fromCharCode(parseInt(b.slice(1),16));if("u"===b[0]||"U"===b[0])return String.fromCodePoint(parseInt(b.slice(1),16));if(/^[0-7]+$/.test(b))return String.fromCharCode(parseInt(b,8))}catch{return b}return({a:"\x07",b:"\b",e:"\x1b",f:"\f",n:"\n",r:"\r",t:" ",v:"\v","\\":"\\","'":"'",'"':'"',"?":"?"})[b]??b})).replace(/\\(.)/g,"$1").replace(/['"]/g,""))?(0,g.deny)("Pausing failproofai enforcement is a human action, not an agent one. If a policy is blocking legitimate work, say so and let the operator decide."):(0,g.allow)()},match:{events:["PreToolUse","PermissionRequest"],toolNames:["Bash"]},defaultEnabled:!0,category:"Dangerous Commands"},{name:"block-sudo",displayTitle:"Tried to run a command with sudo",impact:"Sudo gives the agent root — blocked unless explicitly allow-listed.",description:"Block sudo commands",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a).trimStart();return J.test(b)||b.startsWith("sudo ")?(a.params?.allowPatterns??[]).some(a=>at(b,a))?(0,g.allow)():(0,g.deny)("sudo commands are blocked"):K.test(b)?(0,g.deny)("Elevated process launch is blocked"):L.test(b)?(0,g.deny)("runas elevation is blocked"):(0,g.allow)()},match:{events:["PreToolUse","PermissionRequest"],toolNames:["Bash"]},defaultEnabled:!0,category:"Dangerous Commands",params:{allowPatterns:{type:"string[]",description:"Sudo command patterns to allow, matched token-by-token (e.g. 'sudo systemctl status')",default:[]}}},{name:"block-curl-pipe-sh",displayTitle:"Tried to pipe a downloaded script straight to a shell",impact:"`curl ... | sh` runs unverified remote code on your machine.",description:"Block piping downloads to shell",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return M.test(b)?(0,g.deny)("Piping downloads to shell is blocked"):O.test(b)?(0,g.deny)("Piping downloads to Invoke-Expression is blocked"):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!0,category:"Dangerous Commands"},{name:"block-rm-rf",displayTitle:"Tried to recursively delete a system path",impact:"Catches catastrophic `rm -rf /` and Windows equivalents.",description:"Prevent catastrophic deletions",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return aG(b).some(a=>{let b=aF(a);return null!==b&&b.some(aE)})?!function(a,b){if(0===b.length)return!1;let c=b.map(a=>aD(aC(a))||"/"),d=!1;for(let e of aG(a)){let a=aF(e);if(null!==a)for(let f of(d=!0,a)){let a=aD(aC(f))||"/";if(!c.some(b=>a===b||a.startsWith(b+"/"))&&!b.some(a=>{let b=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return RegExp(`${b}(?:[/"'\\s/*]|$)`).test(e)}))return!1}}return d}(b,a.params?.allowPaths??[])?(0,g.deny)("Catastrophic deletion blocked"):(0,g.allow)():/Remove-Item\s+.*-Recurse.*-Force.*(?:[A-Z]:\\(?:\s|$)|\\\*)/i.test(b)||/(?:rd|rmdir)\s+\/s\s+\/q\s+[A-Z]:\\/i.test(b)?(0,g.deny)("Catastrophic deletion blocked"):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Dangerous Commands",params:{allowPaths:{type:"string[]",description:"Paths that are allowed to be recursively deleted",default:[]}}},{name:"block-failproofai-commands",displayTitle:"Tried to disable or modify failproofai itself",impact:"Prevents the agent from turning off the policies that protect you.",description:"Block failproofai CLI commands and uninstallation",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return V.test(b)?(0,g.deny)("Running failproofai CLI commands is blocked"):W.test(b)?(0,g.deny)("Uninstalling failproofai is blocked"):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!0,category:"Dangerous Commands"},{name:"block-kubectl",displayTitle:"Tried to run a Kubernetes command",impact:"kubectl can change live cluster state — gated unless allow-listed.",description:"Block kubectl commands (Kubernetes cluster mutations)",fn:function(a){return aI(a,ak,"kubectl commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"kubectl command patterns to allow, matched token-by-token (e.g. 'kubectl get *', 'kubectl describe *')",default:[]}}},{name:"block-terraform",displayTitle:"Tried to run a Terraform/OpenTofu command",impact:"Terraform mutates real infrastructure — gated unless allow-listed.",description:"Block terraform and tofu (OpenTofu) commands",fn:function(a){return aI(a,al,"terraform/tofu commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"terraform/tofu command patterns to allow (e.g. 'terraform plan', 'terraform validate')",default:[]}}},{name:"block-aws-cli",displayTitle:"Tried to run an AWS CLI command",impact:"AWS CLI can spend money or break prod — gated.",description:"Block aws CLI commands",fn:function(a){return aI(a,am,"aws CLI commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"aws CLI command patterns to allow (e.g. 'aws s3 ls *', 'aws sts get-caller-identity')",default:[]}}},{name:"block-gcloud",displayTitle:"Tried to run a Google Cloud command",impact:"gcloud can spend money or break prod — gated.",description:"Block gcloud (Google Cloud) CLI commands",fn:function(a){return aI(a,an,"gcloud commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"gcloud command patterns to allow (e.g. 'gcloud auth list', 'gcloud config list')",default:[]}}},{name:"block-az-cli",displayTitle:"Tried to run an Azure CLI command",impact:"az can spend money or break prod — gated.",description:"Block az (Azure) CLI commands",fn:function(a){return aI(a,ao,"az (Azure) CLI commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"az CLI command patterns to allow (e.g. 'az account show', 'az group list')",default:[]}}},{name:"block-helm",displayTitle:"Tried to run a Helm command",impact:"Helm releases mutate cluster state — gated.",description:"Block helm commands",fn:function(a){return aI(a,ap,"helm commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"helm command patterns to allow (e.g. 'helm list', 'helm status *')",default:[]}}},{name:"block-gh-pipeline",displayTitle:"Tried to run a privileged GitHub CLI pipeline command",impact:"Catches `gh workflow run`, `gh pr merge`, `gh secret set`, etc.",description:"Block gh CLI pipeline-trigger subcommands (workflow run, run rerun/cancel, pr merge, release create/delete, cache delete, secret set/delete)",fn:function(a){return aI(a,aq,"gh pipeline-trigger commands are blocked")},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Infra Commands",params:{allowPatterns:{type:"string[]",description:"gh pipeline command patterns to allow (e.g. specific scripted invocations); read-only gh subcommands like 'gh pr view' and 'gh run list' are not matched by this policy",default:[]}}},{name:"block-secrets-write",displayTitle:"Tried to write a secret-key file",impact:"Stops the agent from creating `.pem`, `id_rsa`, `credentials.json`, etc.",description:"Block writing secret key files",fn:function(a){if("Write"!==a.toolName)return(0,g.allow)();let b=l(a);if(R.test(b)||S.test(b)||T.test(b))return(0,g.deny)("Writing secret key files is blocked");for(let c of a.params?.additionalPatterns??[])if(b.includes(c))return(0,g.deny)(`Writing blocked file pattern: ${c}`);return(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Write"]},defaultEnabled:!1,category:"Dangerous Commands",params:{additionalPatterns:{type:"string[]",description:"Additional filename patterns (substrings) to block",default:[]}}},{name:"block-push-master",displayTitle:"Tried to push directly to main/master",impact:"Direct pushes to a protected branch bypass review.",description:"Block pushing to main/master",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=a.params?.protectedBranches??["main","master"];if(0===b.length)return(0,g.allow)();let c=au(k(a)),d=RegExp(`\\b(?:${b.map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\b`);return c.some(a=>d.test(a))?(0,g.deny)(`Pushing to ${b.join("/")} is blocked`):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!0,category:"Git",params:{protectedBranches:{type:"string[]",description:"Branch names to protect from direct pushes",default:["main","master"]}}},{name:"block-force-push",displayTitle:"Tried to force-push",impact:"Force-pushes rewrite history and can clobber teammates' work.",description:"Prevent force-pushing to any branch",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();for(let b of au(k(a))){let a=!1;for(let c of b.split(/\s+/)){if("--"===c){a=!0;continue}if(!a&&function(a){return"--force"===a||!Q.some(b=>a.startsWith(b))&&(!!a.startsWith("--force")||P.test(a))}(c))return(0,g.deny)("Force-pushing is blocked")}}return(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Git"},{name:"block-work-on-main",displayTitle:"Tried to commit or merge on main/master",impact:"Work should land via PR — direct commits skip review.",description:"Block git commits and merges on main/master branch",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a).match(U);if(!b)return(0,g.allow)();let c=a.session?.cwd;if(!c)return(0,g.allow)();let d=as(c);return d&&(a.params?.protectedBranches??["main","master"]).includes(d)?(0,g.deny)(`Git ${b[1]} on ${d} is blocked. Create a feature branch first.`):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Git",params:{protectedBranches:{type:"string[]",description:"Branch names where commits/merges are blocked",default:["main","master"]}}},{name:"warn-git-amend",displayTitle:"Used git commit --amend",impact:"Amending after a push rewrites history that others may have pulled.",description:"Warns before amending git commits, which rewrites history",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return X.test(b)?(0,g.instruct)("STOP: This command amends the last commit, which rewrites git history. If this commit has already been pushed to a shared branch, this will cause divergence for other contributors. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Git"},{name:"warn-git-stash-drop",displayTitle:"Tried to drop or clear git stash",impact:"Stash deletions are permanent and silent.",description:"Warns before permanently deleting stashed changes",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return Y.test(b)?(0,g.instruct)("STOP: This command permanently deletes stashed changes (git stash drop/clear). Stash entries cannot be recovered after deletion. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Git"},{name:"warn-all-files-staged",displayTitle:"Staged all files with git add -A / .",impact:"Wide stages routinely catch generated files or secrets you didn't intend to commit.",description:"Warns before staging all working tree files with git add -A / . / --all",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return Z.test(b)?(0,g.instruct)("STOP: This command stages all files in the working tree (git add -A / --all / .). This may inadvertently include build artifacts, generated files, or sensitive files not covered by .gitignore. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Git"},{name:"warn-destructive-sql",displayTitle:"Ran destructive SQL (DROP / TRUNCATE / DELETE without WHERE)",impact:"Easy way to wipe a table by accident.",description:"Warn before executing destructive SQL (DROP/TRUNCATE/DELETE without WHERE) via database clients",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return u.test(b)&&(v.test(b)||w.test(b)&&!x.test(b))?(0,g.instruct)("STOP: This command contains destructive SQL (DROP/TRUNCATE/DELETE). Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Database"},{name:"warn-schema-alteration",displayTitle:"Altered a database schema column",impact:"ALTER TABLE operations can lock tables and break readers.",description:"Warns before SQL schema changes (ALTER TABLE with column or rename operations)",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return u.test(b)&&y.test(b)?(0,g.instruct)("STOP: This command contains a schema-altering SQL statement (ALTER TABLE with column or rename operation). Schema changes on production databases are irreversible or disruptive. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Database"},{name:"warn-package-publish",displayTitle:"Tried to publish a package",impact:"Publishes are irreversible — `npm publish` / `cargo publish` shouldn't happen without intent.",description:"Warn before publishing packages to public registries (npm, PyPI, crates.io, RubyGems, etc.)",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return z.test(b)?(0,g.instruct)("STOP: This command publishes a package to a public registry. Confirm with the user that this is intentional."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Packages & System"},{name:"warn-global-package-install",displayTitle:"Installed a package globally",impact:"`npm i -g`, `cargo install`, `pip --user` pollute your machine outside the project.",description:"Warns before installing packages globally (npm -g, cargo install, etc.)",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return $.test(b)||_.test(b)||aa.test(b)||ab.test(b)||ac.test(b)||ad.test(b)?(0,g.instruct)("STOP: This command installs a package globally, which modifies the system-wide environment outside the project. This can conflict with other projects or system tools. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Packages & System"},{name:"prefer-package-manager",displayTitle:"Used a non-preferred package manager",impact:"Mixing package managers creates lockfile churn for your team.",description:"Blocks non-preferred package managers and tells Claude to use an allowed one (e.g., uv instead of pip)",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);if(!b)return(0,g.allow)();let c=a.params?.allowed??[];if(0===c.length)return(0,g.allow)();let d=new Set(c.map(a=>a.toLowerCase())),e=a.params?.blocked??[],f=c.join(", ");for(let a of b.split(aJ)){let b=a.trim();if(!b)continue;let c=!1;for(let a of d){let d=ae[a];if(d){for(let a of d)if(a.test(b)){c=!0;break}if(c)break}}if(!c){for(let[a,c]of Object.entries(ae))if(!d.has(a)){for(let d of c)if(d.test(b))return(0,g.deny)(`"${a}" is not an allowed package manager. Allowed package managers for this project: ${f}. Rewrite this command using an allowed package manager.`)}for(let a of e){let c=a.toLowerCase();if(!d.has(c)&&RegExp(`\\b${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(b))return(0,g.deny)(`"${c}" is not an allowed package manager. Allowed package managers for this project: ${f}. Rewrite this command using an allowed package manager.`)}}}return(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Packages & System",params:{allowed:{type:"string[]",description:"Allowed package manager names (e.g. ['uv', 'bun']). Any detected manager not in this list is blocked.",default:[]},blocked:{type:"string[]",description:"Additional manager names to block beyond the built-in list (e.g. ['pdm', 'pipx']).",default:[]}}},{name:"warn-large-file-write",displayTitle:"Wrote a file larger than the configured threshold",impact:"Catches accidentally large file writes (logs, binaries, model dumps).",description:"Warn before writing files larger than 1MB (configurable via thresholdKb param)",fn:function(a){if("Write"!==a.toolName)return(0,g.allow)();let b=a.toolInput?.content;if("string"!=typeof b)return(0,g.allow)();let c=a.params?.thresholdKb??1024;return b.length>1024*c?(0,g.instruct)(`STOP: You are writing a file larger than ${c}KB (${Math.round(b.length/1024)}KB). This is unusually large. Confirm this is intentional before proceeding.`):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Write"]},defaultEnabled:!1,category:"Packages & System",params:{thresholdKb:{type:"number",description:"File size threshold in KB above which a warning is issued",default:1024}}},{name:"warn-background-process",displayTitle:"Started a long-lived background process",impact:"Catches `nohup` / `&` / `screen` / `tmux` / `disown` patterns that the agent often forgets to clean up.",description:"Warns before starting detached or background processes",fn:function(a){if("Bash"!==a.toolName)return(0,g.allow)();let b=k(a);return af.test(b)||ag.test(b)||ah.test(b)||ai.test(b)||aj.test(b)?(0,g.instruct)("STOP: This command starts a background or detached process (nohup, screen -d, tmux -d, or trailing &). Background processes persist after Claude's session and may be difficult to track or stop. Confirm with the user before executing."):(0,g.allow)()},match:{events:["PreToolUse"],toolNames:["Bash"]},defaultEnabled:!1,category:"Packages & System"},{name:"warn-repeated-tool-calls",displayTitle:"Called the same tool 3+ times with identical arguments",impact:"Usually a sign of a stuck loop burning tokens.",description:"Warn when the same tool is called 3+ times with identical parameters",fn:async function a(a){let b=a.session?.transcriptPath;if(!b||!a.toolName||!a.toolInput)return(0,g.allow)();let c=`${b}.tool-calls.json`,e=JSON.stringify({tool:a.toolName,input:a.toolInput}),f={};try{let a=await (0,d.readFile)(c,"utf8");f=JSON.parse(a)}catch{}let h=f[e]??0;if(h>=3)return(0,g.instruct)(`STOP: You have already called ${a.toolName} ${h} times with identical parameters. This is wasteful and unproductive. Do NOT repeat this call — use a different approach or ask the user for clarification.`);f[e]=h+1;try{let a=JSON.stringify(f);a.length<=65536&&await (0,d.writeFile)(c,a,"utf8")}catch{}return(0,g.allow)()},match:{events:["PreToolUse"]},defaultEnabled:!1,category:"AI Behavior"},{name:"require-commit-before-stop",displayTitle:"Stopped with uncommitted changes",impact:"Work not in a commit is invisible to teammates and easy to lose.",description:"Require all changes to be committed before Claude stops",fn:function(a){if(aK(a))return(0,g.allow)("Plan mode — no changes made, skipping commit check.");let b=a.session?.cwd;if(!b)return(0,g.allow)("No working directory available, skipping commit check.");try{if((0,e.execSync)("git status --porcelain",{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim().length>0)return(0,g.deny)("You have uncommitted changes in the working directory. Commit all changes now.");return(0,g.allow)("All changes are committed.")}catch{return(0,g.allow)("Not a git repository, skipping commit check.")}},match:{events:["Stop"]},defaultEnabled:!1,category:"Workflow"},{name:"require-push-before-stop",displayTitle:"Stopped with unpushed commits",impact:"Local-only commits won't trigger CI or be reviewable.",description:"Require all commits to be pushed to remote before Claude stops",fn:function(a){if(aK(a))return(0,g.allow)("Plan mode — no changes made, skipping push check.");let b=a.session?.cwd;if(!b)return(0,g.allow)("No working directory available, skipping push check.");try{if(!(0,e.execSync)("git remote",{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3}).trim())return(0,g.allow)("No git remote configured, skipping push check.");let c=a.params?.remote??"origin",d=as(b);if(!d||"HEAD"===d)return(0,g.allow)("Detached HEAD, skipping push check.");let f=a.params?.baseBranch??"main";if(d===f)return(0,g.allow)(`On base branch "${f}", skipping push check.`);try{if(!(0,e.execFileSync)("git",["log",`${c}/${f}..HEAD`,"--oneline"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim())return(0,g.allow)(`No commits ahead of ${c}/${f}, skipping push check.`);if(!(0,e.execFileSync)("git",["diff","--stat",`${c}/${f}`,"HEAD"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim())return(0,g.allow)(`No file changes compared to ${c}/${f}, skipping push check.`)}catch{}let h=!1;try{(0,e.execFileSync)("git",["rev-parse","--verify",`${c}/${d}`],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3}),h=!0}catch{}if(!h)return(0,g.deny)(`Branch "${d}" has not been pushed to remote "${c}". Run now: git push -u ${c} ${d}`);let i=(0,e.execFileSync)("git",["log",`${c}/${d}..HEAD`,"--oneline"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim();if(i.length>0){let a=i.split("\n").length;return(0,g.deny)(`You have ${a} unpushed commit${a>1?"s":""} on branch "${d}". Run now: git push`)}return(0,g.allow)(`All commits pushed to "${c}".`)}catch{return(0,g.allow)("Could not check push status, skipping.")}},match:{events:["Stop"]},defaultEnabled:!1,category:"Workflow",params:{remote:{type:"string",description:"Remote name to push to (default: origin)",default:"origin"},baseBranch:{type:"string",description:"Base branch to compare against (default: main)",default:"main"}}},{name:"require-pr-before-stop",displayTitle:"Stopped without a PR for the branch",impact:"Branches without PRs don't get reviewed.",description:"Require a pull request to exist for the current branch before Claude stops",fn:function(a){if(aK(a))return(0,g.allow)("Plan mode — no changes made, skipping PR check.");let b=a.session?.cwd;if(!b)return(0,g.allow)("No working directory available, skipping PR check.");try{let c;try{(0,e.execSync)("gh --version",{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3})}catch{return(0,g.allow)("GitHub CLI (gh) not installed, skipping PR check.")}let d=as(b);if(!d||"HEAD"===d)return(0,g.allow)("Detached HEAD, skipping PR check.");let f=a.params?.baseBranch??"main";if(d===f)return(0,g.allow)(`On base branch "${f}", skipping PR check.`);try{if(!(0,e.execFileSync)("git",["log",`origin/${f}..HEAD`,"--oneline"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim())return(0,g.allow)(`No commits ahead of origin/${f}, skipping PR check.`);if(!(0,e.execFileSync)("git",["diff","--stat",`origin/${f}`,"HEAD"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim())return(0,g.allow)(`No file changes compared to origin/${f}, skipping PR check.`)}catch{}try{c=(0,e.execSync)("gh pr view --json number,url,state",{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}).trim()}catch{return(0,g.deny)(`No pull request found for branch "${d}". Run now: gh pr create`)}let h=JSON.parse(c);if("OPEN"===h.state)return(0,g.allow)(`PR #${h.number} exists: ${h.url}`);if("MERGED"===h.state)return(0,g.allow)(`PR #${h.number} was merged: ${h.url}. Switch off this branch (e.g. 'git checkout ${f} && git pull') before stopping again.`);return(0,g.deny)(`Pull request for branch "${d}" is ${h.state.toLowerCase()}. Run now: gh pr create`)}catch{return(0,g.allow)("Could not check PR status, skipping.")}},match:{events:["Stop"]},defaultEnabled:!1,category:"Workflow",params:{baseBranch:{type:"string",description:"Base branch to compare against (default: main)",default:"main"}}},{name:"require-no-conflicts-before-stop",displayTitle:"Stopped with a branch that conflicts with main",impact:"Conflicting branches can't merge — surface them early.",description:"Require the current branch to merge cleanly with the base branch before Claude stops",fn:function(a){let b,c;if(aK(a))return(0,g.allow)("Plan mode — no changes made, skipping conflict check.");let d=a.session?.cwd;if(!d)return(0,g.allow)("No working directory available, skipping conflict check.");let f=as(d);if(!f||"HEAD"===f)return(0,g.allow)("Detached HEAD, skipping conflict check.");let h=a.params?.baseBranch??"main";if(f===h)return(0,g.allow)(`On base branch "${h}", skipping conflict check.`);try{(0,e.execSync)("gh --version",{cwd:d,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3})}catch{return(0,g.allow)("gh CLI not installed, skipping conflict check.")}try{b=(0,e.execSync)("gh pr view --json mergeable,number,url,state",{cwd:d,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}).trim()}catch{return(0,g.allow)("No pull request found for branch, skipping conflict check.")}try{c=JSON.parse(b)}catch{return(0,g.allow)("Could not parse gh pr view output, skipping conflict check.")}if("OPEN"!==c.state)return(0,g.allow)(`PR #${c.number} is ${c.state.toLowerCase()}; skipping conflict check.`);try{(0,e.execFileSync)("git",["rev-parse","--verify",`origin/${h}`],{cwd:d,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3}),(0,e.execFileSync)("git",["log",`origin/${h}..HEAD`,"--oneline"],{cwd:d,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:5e3}).trim()&&(0,e.execFileSync)("git",["merge-tree","--write-tree","--name-only",`origin/${h}`,"HEAD"],{cwd:d,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:1e4})}catch(a){if(1===a.status){let b=("string"==typeof a.stdout?a.stdout:a.stdout?.toString("utf8")??"").trim().split("\n"),c=[];for(let a=1;a<b.length;a++){let d=b[a];if(""===d)break;c.push(d)}let d=c.length?c.join(", "):"one or more files";return(0,g.deny)(`Branch "${f}" has merge conflicts with ${h} in: ${d}. Rebase or merge origin/${h} now and resolve the conflicts.`)}}return"CONFLICTING"===c.mergeable?(0,g.deny)(`PR #${c.number} has merge conflicts per GitHub (${c.url}). Rebase or merge origin/${h} now and resolve the conflicts.`):"UNKNOWN"===c.mergeable?(0,g.deny)(`GitHub is still computing mergeability for PR #${c.number} (${c.url}). Wait ~10 seconds, then re-check with \`gh pr view --json mergeable\` before attempting to stop again.`):(0,g.allow)(`PR #${c.number} merges cleanly per GitHub.`)},match:{events:["Stop"]},defaultEnabled:!1,category:"Workflow",params:{baseBranch:{type:"string",description:"Base branch to check for conflicts against (default: main)",default:"main"}}},{name:"require-ci-green-before-stop",displayTitle:"Stopped with failing CI",impact:"Failing CI blocks deploy.",description:"Require CI checks to pass on the current HEAD commit before Claude stops (ignores stale runs on prior commits)",fn:function(a){if(aK(a))return(0,g.allow)("Plan mode — no changes made, skipping CI check.");let b=a.session?.cwd;if(!b)return(0,g.allow)("No working directory available, skipping CI check.");try{try{(0,e.execSync)("gh --version",{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3})}catch{return(0,g.allow)("GitHub CLI (gh) not installed, skipping CI check.")}let a=as(b);if(!a||"HEAD"===a)return(0,g.allow)("Detached HEAD, skipping CI check.");let c=function(a){try{return(0,e.execSync)("git rev-parse HEAD",{cwd:a,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:3e3}).trim()||null}catch{return null}}(b),d=[];try{let f=(0,e.execFileSync)("gh",["run","list","--branch",a,"--limit","20","--json","status,conclusion,name,headSha"],{cwd:b,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}).trim();if(f&&"[]"!==f){let a=JSON.parse(f),b=c?a.filter(a=>a.headSha===c):a,e=new Set;d=b.filter(a=>!e.has(a.name)&&(e.add(a.name),!0))}}catch{}let f=[],h=[];c&&(f=function(a,b){try{let c=(0,e.execFileSync)("gh",["api",`repos/{owner}/{repo}/commits/${b}/check-runs`,"--jq",'.check_runs | map(select(.app.slug != "github-actions")) | map({name: .name, status: .status, conclusion: (.conclusion // "")})'],{cwd:a,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}).trim();if(!c||"[]"===c)return[];return JSON.parse(c)}catch{return[]}}(b,c),h=function(a,b){try{let c=(0,e.execFileSync)("gh",["api",`repos/{owner}/{repo}/commits/${b}/statuses`,"--jq","map({name: .context, state: .state}) | unique_by(.name)"],{cwd:a,encoding:"utf8",stdio:["pipe","pipe","pipe"],timeout:15e3}).trim();if(!c||"[]"===c)return[];return JSON.parse(c).map(a=>({name:a.name,status:"pending"===a.state?"in_progress":"completed",conclusion:"pending"===a.state?"":"success"===a.state?"success":"failure"}))}catch{return[]}}(b,c));let i=[...d,...f,...h];if(0===i.length)return(0,g.allow)(`No CI runs found for branch "${a}".`);let j=i.filter(a=>"completed"===a.status&&"success"!==a.conclusion&&"skipped"!==a.conclusion&&"cancelled"!==a.conclusion&&"neutral"!==a.conclusion);if(j.length>0){let b=j.map(a=>`"${a.name}"`).join(", ");return(0,g.deny)(`CI checks are failing on branch "${a}": ${b}. Fix the failing checks now.`)}let k=i.filter(a=>"in_progress"===a.status||"queued"===a.status||"waiting"===a.status);if(k.length>0){let b=k.map(a=>`"${a.name}"`).join(", ");return(0,g.deny)(`CI checks are still running on branch "${a}": ${b}. Wait for all checks to complete, then verify they pass.`)}return(0,g.allow)(`All CI checks passed on branch "${a}".`)}catch{return(0,g.allow)("Could not check CI status, skipping.")}},match:{events:["Stop"]},defaultEnabled:!1,category:"Workflow"}];a.s(["BUILTIN_POLICIES",0,aL])}];
|
|
4
4
|
|
|
5
5
|
//# sourceMappingURL=src_hooks_1ezd2jf._.js.map
|