failproofai 1.0.2-beta.8 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +4 -4
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  6. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  7. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  10. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
  11. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.rsc +14 -14
  18. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
  19. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
  20. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  21. package/.next/standalone/.next/server/app/api/audit/invite/route.js +3 -2
  22. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/audit/run/route.js +4 -3
  24. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/auth/login-request/route.js +2 -2
  27. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js +4 -3
  29. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/auth/logout/route.js +4 -4
  31. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/api/auth/status/route.js +4 -4
  33. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  34. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
  36. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  38. package/.next/standalone/.next/server/app/index.html +1 -1
  39. package/.next/standalone/.next/server/app/index.rsc +14 -14
  40. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +13 -13
  41. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +14 -14
  42. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  43. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  44. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  46. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
  47. package/.next/standalone/.next/server/app/policies/page.js +4 -4
  48. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  50. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  51. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  53. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  54. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  55. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  57. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  58. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  60. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -4
  61. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  62. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  63. package/.next/standalone/.next/server/chunks/[externals]__0-9ti7z._.js +3 -0
  64. package/.next/standalone/.next/server/chunks/{[externals]__1lt47k4._.js → [externals]__0sg9-3p._.js} +1 -1
  65. package/.next/standalone/.next/server/chunks/[externals]__0u3wrvq._.js +3 -0
  66. package/.next/standalone/.next/server/chunks/[root-of-the-server]__01eqny5._.js +3 -0
  67. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1p8poxd._.js → [root-of-the-server]__0igxt32._.js} +2 -2
  68. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
  69. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zlqo2t._.js +3 -0
  70. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1anxb5k._.js +3 -0
  71. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1le9jqc._.js +1 -1
  72. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1p-qi2t._.js +5 -0
  73. package/.next/standalone/.next/server/chunks/_09dz7xv._.js +27 -0
  74. package/.next/standalone/.next/server/chunks/_0bs-v8p._.js +3 -0
  75. package/.next/standalone/.next/server/chunks/_0tovk6q._.js +3 -0
  76. package/.next/standalone/.next/server/chunks/_0trp3yc._.js +3 -0
  77. package/.next/standalone/.next/server/chunks/{_19uwam-._.js → _1-akg6w._.js} +2 -2
  78. package/.next/standalone/.next/server/chunks/_185gyk9._.js +3 -0
  79. package/.next/standalone/.next/server/chunks/_1ek68ln._.js +5 -7
  80. package/.next/standalone/.next/server/chunks/{node_modules_posthog-node_dist_entrypoints_index_node_mjs_09d5c79._.js → node_modules_posthog-node_dist_entrypoints_index_node_mjs_04op_ou._.js} +1 -1
  81. package/.next/standalone/.next/server/chunks/{node_modules_posthog-node_dist_entrypoints_index_node_mjs_1d2g73o._.js → node_modules_posthog-node_dist_entrypoints_index_node_mjs_0dr20uz._.js} +1 -1
  82. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
  83. package/.next/standalone/.next/server/chunks/src_hooks_0iu54mz._.js +3 -0
  84. package/.next/standalone/.next/server/chunks/src_hooks_custom-hooks-loader_ts_0lnb3n3._.js +10 -0
  85. package/.next/standalone/.next/server/chunks/src_hooks_fp-home_ts_09kv0bn._.js +1 -1
  86. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__013jr2b._.js +2 -2
  87. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01wy8d-._.js +2 -2
  88. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02npjtd._.js +2 -2
  89. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0da85px._.js +2 -2
  90. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ftmoxc._.js +2 -2
  91. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0n_lxhg._.js +5 -0
  92. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0oa1lav._.js +1 -1
  93. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0p-5p8u._.js +2 -2
  94. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s740oi._.js +2 -2
  95. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1p2otjt._.js +2 -2
  96. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1yh7hlv._.js +3 -0
  97. package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
  98. package/.next/standalone/.next/server/chunks/ssr/_0ehudfr._.js +23 -0
  99. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1n2ywfz._.js → _1es2j7i._.js} +4 -4
  100. package/.next/standalone/.next/server/chunks/ssr/_1u8-lu2._.js +1 -1
  101. package/.next/standalone/.next/server/chunks/ssr/{_1h33neq._.js → _1un1pug._.js} +1 -1
  102. package/.next/standalone/.next/server/chunks/ssr/_1zopuov._.js +1 -1
  103. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +9 -9
  104. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
  105. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
  106. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +2 -2
  107. package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +1 -1
  108. package/.next/standalone/.next/server/chunks/ssr/src_hooks_1cv9_c4._.js +10 -0
  109. package/.next/standalone/.next/server/chunks/ssr/src_hooks_builtin-policies_ts_09j2ndl._.js +1 -1
  110. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  111. package/.next/standalone/.next/server/middleware.js +1 -1
  112. package/.next/standalone/.next/server/pages/404.html +1 -1
  113. package/.next/standalone/.next/server/pages/500.html +1 -1
  114. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  115. package/.next/standalone/.next/server/server-reference-manifest.json +19 -19
  116. package/.next/standalone/.next/static/chunks/0nkpwjk01ei3t.js +1 -0
  117. package/.next/standalone/.next/static/chunks/{2iryw37qfqy5y.js → 0ofdelz65_517.js} +1 -1
  118. package/.next/standalone/.next/static/chunks/{34j7nmidlcuni.js → 12uhnpwgsmcev.js} +1 -1
  119. package/.next/standalone/.next/static/chunks/{0i3a6wf-f_yky.js → 1_1eb_149xyt9.js} +1 -1
  120. package/.next/standalone/.next/static/chunks/{3927pu4ss_l4k.js → 1tx9pnxyjrkoj.js} +1 -1
  121. package/.next/standalone/.next/static/chunks/{1n04wzsaes73g.js → 1x0jrl3a4_i2m.js} +1 -1
  122. package/.next/standalone/.next/static/chunks/{3r0udrtpn78-e.js → 1zpv6omeln7al.js} +1 -1
  123. package/.next/standalone/.next/static/chunks/{416zumre3fvfw.js → 20hbg-r3io_ip.js} +1 -1
  124. package/.next/standalone/.next/static/chunks/{11a_m8yksthtf.js → 32bhi32ym8yrz.js} +2 -2
  125. package/.next/standalone/.next/static/chunks/{0u2ojcw25c_np.js → 3fr78ugeb4tjc.js} +1 -1
  126. package/.next/standalone/app/actions/get-hooks-config.ts +8 -1
  127. package/.next/standalone/app/actions/pack-actions.ts +12 -1
  128. package/.next/standalone/app/policies/hooks-client.tsx +41 -4
  129. package/.next/standalone/fp-cloud-cli/tests/test_pagination.py +204 -0
  130. package/.next/standalone/package.json +9 -9
  131. package/.next/standalone/server.js +1 -1
  132. package/README.md +58 -13
  133. package/bin/failproofai.mjs +10 -1
  134. package/dist/cli.mjs +22429 -21292
  135. package/dist/worker.mjs +1247 -540
  136. package/package.json +9 -9
  137. package/src/audit/index.ts +24 -4
  138. package/src/hooks/builtin-policies.ts +933 -8
  139. package/src/hooks/custom-hooks-loader.ts +98 -8
  140. package/src/hooks/handler.ts +26 -14
  141. package/src/hooks/manager.ts +36 -2
  142. package/src/hooks/pack-cli.ts +415 -42
  143. package/src/hooks/pack-failclosed.ts +100 -4
  144. package/src/hooks/pack-manifest.ts +29 -0
  145. package/src/hooks/pack-param-key.ts +36 -0
  146. package/src/hooks/pack-store.ts +101 -9
  147. package/src/hooks/policy-catalog.ts +9 -1
  148. package/src/hooks/policy-evaluator.ts +77 -1
  149. package/.next/standalone/.next/server/chunks/[root-of-the-server]__06cuf1y._.js +0 -3
  150. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_usx0j._.js +0 -3
  151. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_zk340._.js +0 -3
  152. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0jnjf2t._.js +0 -3
  153. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0oy4kxb._.js +0 -3
  154. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zf034w._.js +0 -3
  155. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1tg4pu6._.js +0 -3
  156. package/.next/standalone/.next/server/chunks/_0lxbzdq._.js +0 -3
  157. package/.next/standalone/.next/server/chunks/_1zuiiy3._.js +0 -3
  158. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0mgrjnx._.js +0 -10
  159. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1-wzs7f._.js +0 -3
  160. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1wlvpe5._.js +0 -5
  161. package/.next/standalone/.next/server/chunks/ssr/_0l7zv8b._.js +0 -23
  162. package/.next/standalone/.next/static/chunks/1ch5l9t2p16y4.js +0 -1
  163. /package/.next/standalone/.next/static/{NgD5HvuyPxwgrpeIiafJL → 5-xDMxcnrcXDFPQiy3yhg}/_buildManifest.js +0 -0
  164. /package/.next/standalone/.next/static/{NgD5HvuyPxwgrpeIiafJL → 5-xDMxcnrcXDFPQiy3yhg}/_clientMiddlewareManifest.js +0 -0
  165. /package/.next/standalone/.next/static/{NgD5HvuyPxwgrpeIiafJL → 5-xDMxcnrcXDFPQiy3yhg}/_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)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),l=(0,h.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);var m=a.i(41476);let n=(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"}]]),o=(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"}]]),p=(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"}]]),q=(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"}]]),r=(0,h.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),s=(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 t=a.i(74215),u=a.i(65967),v=a.i(5050);let w=(0,v.createServerReference)("40d845904971e2c2447db0c7babcad414d256286da",v.callServer,void 0,v.findSourceMapURL,"getHookActivityAction"),x=(0,v.createServerReference)("60396bb1e351760a369c0b60afb2184343351dd5da",v.callServer,void 0,v.findSourceMapURL,"searchHookActivityAction"),y=(0,v.createServerReference)("00c43b8e7c113f31ebd7b3e020ccad0d6b00c5b016",v.callServer,void 0,v.findSourceMapURL,"getActivePausesAction");function z({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)(o,{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 A(){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 B({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)(s,{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 C=(0,v.createServerReference)("0045245821d5fa379ec4f6984839ad459f7fd31aa9",v.callServer,void 0,v.findSourceMapURL,"getHooksConfigAction"),D=(0,v.createServerReference)("60af7a14ec5e9d40867dd57a601864e996bcf688c4",v.callServer,void 0,v.findSourceMapURL,"toggleCustomPolicyAction"),E=(0,v.createServerReference)("0036b57b2077ecba95f0efc1287c0920346d09a6bb",v.callServer,void 0,v.findSourceMapURL,"addBundledPackWebAction"),F=(0,v.createServerReference)("60f4fbb247d558c4565ec43d90581ab578fadc7eac",v.callServer,void 0,v.findSourceMapURL,"addPackWebAction"),G=(0,v.createServerReference)("40c911afc62e67cac4f0775030ee93c7102476dc0d",v.callServer,void 0,v.findSourceMapURL,"previewPackWebAction"),H=(0,v.createServerReference)("406395da8dc847a3a7142e6b7e1f88b42800d311fc",v.callServer,void 0,v.findSourceMapURL,"removePackWebAction"),I=(0,v.createServerReference)("7061de6390bc26e79c569c9b09b6576846aa13e6e4",v.callServer,void 0,v.findSourceMapURL,"togglePackPolicyAction"),J=(0,v.createServerReference)("606697c0d76e6337755a33f897c61448242e46e0ed",v.callServer,void 0,v.findSourceMapURL,"installHooksWebAction"),K=(0,v.createServerReference)("609850fd7f3ff102f3165256c7fc4b4433d67fa89f",v.callServer,void 0,v.findSourceMapURL,"removeHooksWebAction"),L=(0,v.createServerReference)("606efc2d5df43e5a1df1cba1ca69d025db75413928",v.callServer,void 0,v.findSourceMapURL,"updatePolicyParamsAction");var M=a.i(6236),N=a.i(10765),O=a.i(90619),P=a.i(95947),Q=a.i(87256);let R={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:"block",SessionStart:"observe",SubagentStart:"observe",PreCompact:"observe",PostCompact:"observe"},copilot:{PreToolUse:"block",Stop:"block",SubagentStop:"block",UserPromptSubmit:"block",PermissionRequest:"block",PostToolUse:"block",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 S=a.i(80977),T=a.i(40695);function U({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 V({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)(q,{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)(o,{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)(p,{className:"h-3 w-3"}),"Allow"]})}function W({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 X({integration:a}){if(!a)return null;let c=(0,Q.getCliLabel)(a),d=(0,Q.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 Y({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 Z({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 $({text:a,field:d}){let[e,g]=(0,c.useState)(!1),{capture:h}=(0,N.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 _({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 aa({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 ab({item:a}){if("observe"!==function(a,b){if(!a||!b)return;let c=R[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,Q.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)(s,{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 ac({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)(B,{item:a}),(0,b.jsx)(ab,{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} version ${a.cloudVersion}`:a.policySource})]}),void 0!==a.cloudDeployment&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Cloud deployment: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cloudDeployment})]}),(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)($,{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)($,{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 ad({hooksInstalled:a,onSwitchTab:d}){let{intervalSec:e}=(0,M.useAutoRefresh)(),{capture:f}=(0,N.usePostHog)(),h=(0,O.useUrlParams)(),i=(0,c.useRef)(!1),[j,k]=(0,c.useState)(()=>(0,P.paramToPage)(h.get("page"))),[l,m]=(0,c.useState)(null),[o,p]=(0,c.useState)([]),[q,r]=(0,c.useState)(null),[s,t]=(0,c.useState)(()=>{let a=h.get("decision");return"allow"===a||"deny"===a||"instruct"===a?a:""}),[v,B]=(0,c.useState)(()=>h.get("event")??""),[C,D]=(0,c.useState)(()=>h.get("policy")??""),[E,F]=(0,c.useState)(()=>h.get("session")??""),[G,H]=(0,c.useState)(()=>{let a=h.get("cli");return(0,Q.isKnownCli)(a)?a:""}),[I,J]=(0,c.useState)(()=>{let a=h.get("source");return"custom"===a||"convention"===a||"cloud"===a||"pack"===a?a:""}),K=(0,c.useRef)(null),L=(0,c.useRef)(!0),R=(0,c.useRef)({filterDecision:s,filterEventType:v,filterPolicy:C,filterSessionId:E,filterCli:G,filterSource:I});R.current={filterDecision:s,filterEventType:v,filterPolicy:C,filterSessionId:E,filterCli:G,filterSource:I},(0,c.useEffect)(()=>{if(!i.current){i.current=!0;return}h.setAll({decision:s||void 0,event:v||void 0,policy:C||void 0,session:E||void 0,cli:G||void 0,source:I||void 0,page:(0,P.pageToParam)(j)})},[s,v,C,E,G,I,j]);let T=""!==s||""!==v||""!==C||""!==E||""!==G||""!==I,$=(0,c.useCallback)(async a=>{try{let b,{filterDecision:c,filterEventType:d,filterPolicy:e,filterSessionId:f,filterCli:g,filterSource:h}=R.current;b=""!==c||""!==d||""!==e||""!==f||""!==g||""!==h?await x({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 w(a),m(b)}catch{}},[]);(0,c.useEffect)(()=>{$(j);let a=setInterval(()=>$(j),e>0?1e3*e:5e3);return()=>clearInterval(a)},[j,$,e]),(0,c.useEffect)(()=>{let a=!1,b=()=>{y().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)(()=>(K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{if(k(1),r(null),$(1),L.current){L.current=!1;return}f("activity_filter_changed",{active_filter_count:+(""!==s)+ +(""!==v)+ +(""!==C)+ +(""!==E)+ +(""!==G),has_decision:""!==s,has_event_type:""!==v,has_policy:""!==C,has_session:""!==E,has_cli:""!==G,decision:s||null,event_type:v||null,cli:G||null})},300),()=>{K.current&&clearTimeout(K.current)}),[s,v,C,E,G]);let ab=l?.entries??[],ae=l?.totalPages??1;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(z,{pauses:o}),l?.stats&&l.stats.totalEvents>0&&(0,b.jsx)("div",{style:{marginBottom:18},children:(0,b.jsx)(aa,{stats:l.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)(_,{value:s,onChange:t})]}),(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=>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:I,onChange:a=>{let b=a.target.value;J("custom"===b||"convention"===b||"cloud"===b||"pack"===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:"custom",children:"custom"}),(0,b.jsx)("option",{value:"convention",children:"convention"}),(0,b.jsx)("option",{value:"cloud",children:"cloud"}),(0,b.jsx)("option",{value:"pack",children:"pack"})]})]}),(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,Q.isKnownCli)(b)?b:"")},className:"filter-input","aria-label":"Filter by CLI",children:[(0,b.jsx)("option",{value:"",children:"all clis"}),Q.KNOWN_CLI_IDS.map(a=>(0,b.jsx)("option",{value:a,children:(0,Q.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=>F(a.target.value),placeholder:"filter by session…",className:"filter-input"})]}),T&&(0,b.jsx)("button",{type:"button",className:"filter-clear",onClick:()=>{t(""),B(""),H(""),D(""),F(""),J("")},"aria-label":"Clear all filters",children:"[ clear ]"})]}),0===ab.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,b.jsx)(n,{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:T?"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:ab.map((a,d)=>{let e="deny"===a.decision,h=q===d,i="instruct"===a.decision;return(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)("tr",{onClick:()=>{r(a=>{let b=a===d?null:d,c=ab[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 ${e?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":i?"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"} ${h?"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 ${h?"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:(0,S.formatRelativeTime)(a.timestamp)}),(0,b.jsxs)("td",{className:"px-3 py-2",children:[(0,b.jsx)(V,{decision:a.decision}),a.pausedBy&&(0,b.jsx)(A,{})]}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(W,{eventType:a.eventType})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(X,{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)(Y,{mode:a.permissionMode}):"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(Z,{ms:a.durationMs})}),(0,b.jsx)("td",{className:"px-3 py-2",title:a.sessionId??"",children:(0,b.jsx)(U,{sessionId:a.sessionId,transcriptPath:a.transcriptPath,integration:a.integration,cwd:a.cwd})})]}),h&&(0,b.jsx)(ac,{item:a})]},`${a.timestamp}-${d}`)})})]})}),(0,b.jsx)(u.default,{currentPage:j,totalPages:ae,onPageChange:a=>{f("activity_pagination_changed",{from_page:j,to_page:a,total_pages:ae}),k(a),r(null)}})]})]})}function ae({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 af({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)(t.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)(t.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)(T.Button,{variant:"outline",size:"sm",onClick:d,className:"h-7 text-xs",children:"Cancel"}),(0,b.jsx)(T.Button,{size:"sm",onClick:()=>e(h),className:"h-7 text-xs",children:"Save"})]})]})})}function ag({message:a,onDismiss:c,onInstall:e,isPending:f}){let{capture:g}=(0,N.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)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),l=(0,h.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);var m=a.i(41476);let n=(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"}]]),o=(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"}]]),p=(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"}]]),q=(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"}]]),r=(0,h.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),s=(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 t=a.i(74215),u=a.i(65967),v=a.i(5050);let w=(0,v.createServerReference)("403b20a4869750d09a473954af76f127b1bcf868c6",v.callServer,void 0,v.findSourceMapURL,"getHookActivityAction"),x=(0,v.createServerReference)("60224d7a734788f9cd429a331a1796d3e8cf5c723a",v.callServer,void 0,v.findSourceMapURL,"searchHookActivityAction"),y=(0,v.createServerReference)("008708709e55a7563e038b0d2f851db312a7c35fb4",v.callServer,void 0,v.findSourceMapURL,"getActivePausesAction");function z({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)(o,{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 A(){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 B({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)(s,{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 C=(0,v.createServerReference)("00d55eca2c530ee167dc8bfae59edfb632c949f94c",v.callServer,void 0,v.findSourceMapURL,"getHooksConfigAction"),D=(0,v.createServerReference)("607dc07af2fa5dbd0794565f0271bd9a148bde88f8",v.callServer,void 0,v.findSourceMapURL,"toggleCustomPolicyAction"),E=(0,v.createServerReference)("004a956ee569aecbe4f8c22a2e2219bfb699bb1076",v.callServer,void 0,v.findSourceMapURL,"addBundledPackWebAction"),F=(0,v.createServerReference)("60527de16160bf47bae463c54299c65dd3754bcdaa",v.callServer,void 0,v.findSourceMapURL,"addPackWebAction"),G=(0,v.createServerReference)("40aa5c5f859d152d56d662b4ff52630494f178ef54",v.callServer,void 0,v.findSourceMapURL,"previewPackWebAction"),H=(0,v.createServerReference)("40e10932309e736311f25b278a8dc7e00e9805cf49",v.callServer,void 0,v.findSourceMapURL,"removePackWebAction"),I=(0,v.createServerReference)("704faed3414c1e47c0f6c2a75ec52aa5c8b4021992",v.callServer,void 0,v.findSourceMapURL,"togglePackPolicyAction"),J=(0,v.createServerReference)("60d7e6ec234c2f9dd135c187fde82138fe9cff6608",v.callServer,void 0,v.findSourceMapURL,"installHooksWebAction"),K=(0,v.createServerReference)("603307051c148c1ad888f6d8977ac928f8f3239d4c",v.callServer,void 0,v.findSourceMapURL,"removeHooksWebAction"),L=(0,v.createServerReference)("60b48ba21e36e522f8b8df30a87f945cb21fe5fd7a",v.callServer,void 0,v.findSourceMapURL,"updatePolicyParamsAction");var M=a.i(6236),N=a.i(10765),O=a.i(90619),P=a.i(95947),Q=a.i(87256);let R={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:"block",SessionStart:"observe",SubagentStart:"observe",PreCompact:"observe",PostCompact:"observe"},copilot:{PreToolUse:"block",Stop:"block",SubagentStop:"block",UserPromptSubmit:"block",PermissionRequest:"block",PostToolUse:"block",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 S=a.i(80977),T=a.i(40695);function U({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 V({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)(q,{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)(o,{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)(p,{className:"h-3 w-3"}),"Allow"]})}function W({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 X({integration:a}){if(!a)return null;let c=(0,Q.getCliLabel)(a),d=(0,Q.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 Y({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 Z({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 $({text:a,field:d}){let[e,g]=(0,c.useState)(!1),{capture:h}=(0,N.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 _({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 aa({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 ab({item:a}){if("observe"!==function(a,b){if(!a||!b)return;let c=R[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,Q.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)(s,{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 ac({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)(B,{item:a}),(0,b.jsx)(ab,{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} version ${a.cloudVersion}`:a.policySource})]}),void 0!==a.cloudDeployment&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Cloud deployment: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cloudDeployment})]}),(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)($,{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)($,{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 ad({hooksInstalled:a,onSwitchTab:d}){let{intervalSec:e}=(0,M.useAutoRefresh)(),{capture:f}=(0,N.usePostHog)(),h=(0,O.useUrlParams)(),i=(0,c.useRef)(!1),[j,k]=(0,c.useState)(()=>(0,P.paramToPage)(h.get("page"))),[l,m]=(0,c.useState)(null),[o,p]=(0,c.useState)([]),[q,r]=(0,c.useState)(null),[s,t]=(0,c.useState)(()=>{let a=h.get("decision");return"allow"===a||"deny"===a||"instruct"===a?a:""}),[v,B]=(0,c.useState)(()=>h.get("event")??""),[C,D]=(0,c.useState)(()=>h.get("policy")??""),[E,F]=(0,c.useState)(()=>h.get("session")??""),[G,H]=(0,c.useState)(()=>{let a=h.get("cli");return(0,Q.isKnownCli)(a)?a:""}),[I,J]=(0,c.useState)(()=>{let a=h.get("source");return"custom"===a||"convention"===a||"cloud"===a||"pack"===a?a:""}),K=(0,c.useRef)(null),L=(0,c.useRef)(!0),R=(0,c.useRef)({filterDecision:s,filterEventType:v,filterPolicy:C,filterSessionId:E,filterCli:G,filterSource:I});R.current={filterDecision:s,filterEventType:v,filterPolicy:C,filterSessionId:E,filterCli:G,filterSource:I},(0,c.useEffect)(()=>{if(!i.current){i.current=!0;return}h.setAll({decision:s||void 0,event:v||void 0,policy:C||void 0,session:E||void 0,cli:G||void 0,source:I||void 0,page:(0,P.pageToParam)(j)})},[s,v,C,E,G,I,j]);let T=""!==s||""!==v||""!==C||""!==E||""!==G||""!==I,$=(0,c.useCallback)(async a=>{try{let b,{filterDecision:c,filterEventType:d,filterPolicy:e,filterSessionId:f,filterCli:g,filterSource:h}=R.current;b=""!==c||""!==d||""!==e||""!==f||""!==g||""!==h?await x({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 w(a),m(b)}catch{}},[]);(0,c.useEffect)(()=>{$(j);let a=setInterval(()=>$(j),e>0?1e3*e:5e3);return()=>clearInterval(a)},[j,$,e]),(0,c.useEffect)(()=>{let a=!1,b=()=>{y().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)(()=>(K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{if(k(1),r(null),$(1),L.current){L.current=!1;return}f("activity_filter_changed",{active_filter_count:+(""!==s)+ +(""!==v)+ +(""!==C)+ +(""!==E)+ +(""!==G),has_decision:""!==s,has_event_type:""!==v,has_policy:""!==C,has_session:""!==E,has_cli:""!==G,decision:s||null,event_type:v||null,cli:G||null})},300),()=>{K.current&&clearTimeout(K.current)}),[s,v,C,E,G]);let ab=l?.entries??[],ae=l?.totalPages??1;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(z,{pauses:o}),l?.stats&&l.stats.totalEvents>0&&(0,b.jsx)("div",{style:{marginBottom:18},children:(0,b.jsx)(aa,{stats:l.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)(_,{value:s,onChange:t})]}),(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=>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:I,onChange:a=>{let b=a.target.value;J("custom"===b||"convention"===b||"cloud"===b||"pack"===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:"custom",children:"custom"}),(0,b.jsx)("option",{value:"convention",children:"convention"}),(0,b.jsx)("option",{value:"cloud",children:"cloud"}),(0,b.jsx)("option",{value:"pack",children:"pack"})]})]}),(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,Q.isKnownCli)(b)?b:"")},className:"filter-input","aria-label":"Filter by CLI",children:[(0,b.jsx)("option",{value:"",children:"all clis"}),Q.KNOWN_CLI_IDS.map(a=>(0,b.jsx)("option",{value:a,children:(0,Q.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=>F(a.target.value),placeholder:"filter by session…",className:"filter-input"})]}),T&&(0,b.jsx)("button",{type:"button",className:"filter-clear",onClick:()=>{t(""),B(""),H(""),D(""),F(""),J("")},"aria-label":"Clear all filters",children:"[ clear ]"})]}),0===ab.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,b.jsx)(n,{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:T?"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:ab.map((a,d)=>{let e="deny"===a.decision,h=q===d,i="instruct"===a.decision;return(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)("tr",{onClick:()=>{r(a=>{let b=a===d?null:d,c=ab[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 ${e?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":i?"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"} ${h?"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 ${h?"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:(0,S.formatRelativeTime)(a.timestamp)}),(0,b.jsxs)("td",{className:"px-3 py-2",children:[(0,b.jsx)(V,{decision:a.decision}),a.pausedBy&&(0,b.jsx)(A,{})]}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(W,{eventType:a.eventType})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(X,{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)(Y,{mode:a.permissionMode}):"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(Z,{ms:a.durationMs})}),(0,b.jsx)("td",{className:"px-3 py-2",title:a.sessionId??"",children:(0,b.jsx)(U,{sessionId:a.sessionId,transcriptPath:a.transcriptPath,integration:a.integration,cwd:a.cwd})})]}),h&&(0,b.jsx)(ac,{item:a})]},`${a.timestamp}-${d}`)})})]})}),(0,b.jsx)(u.default,{currentPage:j,totalPages:ae,onPageChange:a=>{f("activity_pagination_changed",{from_page:j,to_page:a,total_pages:ae}),k(a),r(null)}})]})]})}function ae({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 af({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)(t.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)(t.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)(T.Button,{variant:"outline",size:"sm",onClick:d,className:"h-7 text-xs",children:"Cancel"}),(0,b.jsx)(T.Button,{size:"sm",onClick:()=>e(h),className:"h-7 text-xs",children:"Save"})]})]})})}function ag({message:a,onDismiss:c,onInstall:e,isPending:f}){let{capture:g}=(0,N.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)(t.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)(t.X,{className:"h-4 w-4"})})]}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)(T.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)(T.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 ah({onHooksInstallChange:a}){let[d,e]=(0,c.useState)(null),[f,g]=(0,c.useTransition)(),[h,j]=(0,c.useState)(null),[k,l]=(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,N.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 C();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,z=(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 D(a,!b)}catch{u("custom_policy_toggle","Failed to save custom policy change."),v()}}))},A=()=>{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 J("user",a),b.length>0&&await K("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 B=d.clis.some(a=>a.installed),E=w.size,F=q.size,G=Array.from(new Set(d.policies.map(a=>a.category)));return(0,b.jsxs)(b.Fragment,{children:[o&&(0,b.jsx)(af,{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 L(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 ${B?"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:E.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)(T.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 J("user",a)}catch(a){u("cli_reinstall",a instanceof Error?a.message:"Failed to reinstall.")}finally{await v()}}))},disabled:f||0===F,className:"text-xs h-7 px-3 font-mono",children:"Reinstall"}),(0,b.jsx)(T.Button,{variant:"default",size:"sm",onClick:A,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,Q.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.policies.filter(a=>a.enabled).length+(d.customPolicies?.filter(a=>a.enabled).length??0)+(d.conventionPolicies?.reduce((a,b)=>a+b.policies.filter(a=>a.enabled).length,0)??0)})," / ",d.policies.length+(d.customPolicies?.length??0)+(d.conventionPolicies?.reduce((a,b)=>a+b.policies.length,0)??0)," ","policies enabled"]}),B&&(0,b.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground/60",children:["· shared across ",E," active CLI",1===E?"":"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}),k&&(0,b.jsx)(ag,{message:k,onDismiss:()=>l(null),onInstall:A,isPending:f}),G.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)(ae,{enabled:a.enabled,onChange:()=>{var b;let c;return b=a.enabled,c=a.name,void(!d||(!d.clis.some(a=>a.installed)?l("Policies are not installed. Install policies to continue."):(l(null),e(d=>d?{...d,policies:d.policies.map(a=>a.name===c?{...a,enabled:!b}:a),packs:d.packs.map(d=>d.id===a.packId?{...d,policies:d.policies.map(a=>a.name===c?{...a,enabled:!b}:a)}:d)}:d),g(async()=>{try{await I(a.packId,c,!b)}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)(m.Settings,{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)(n,{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)(ae,{enabled:a.enabled,onChange:()=>z(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)(n,{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)(ae,{enabled:c.enabled,onChange:()=>z(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)),(0,b.jsx)(ai,{packs:d.packs??[],disabled:f,onChanged:v,onError:a=>u("pack_action",a)})]})]})}function ai({packs:a,disabled:d,onChanged:e,onError:f}){let[g,h]=(0,c.useState)(""),[i,j]=(0,c.useState)(null),[m,n]=(0,c.useState)(null),[o,p]=(0,c.useState)(null),{capture:q}=(0,N.usePostHog)(),u=async()=>{if(g.trim()){j("preview"),p(null);try{let a=await G(g);if(!a.ok)return void f(a.error??"Could not read that pack.");p(a)}finally{j(null)}}},v=async(a,b)=>{j(a),n(null);try{let a=await b();if(!a.ok)return void f(a.error??"Could not install that pack.");n(a.version?`${a.id}@${a.version}`:a.id??null),h(""),e()}catch(a){f(a instanceof Error?a.message:"Could not install that pack.")}finally{j(null)}};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:"Policy Packs"}),(0,b.jsx)("span",{className:"text-[0.7rem] text-muted-foreground",children:0===a.length?"none installed":`${a.length} installed`})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 px-4 py-3 border-b border-border/20",children:[(0,b.jsx)("input",{value:g,onChange:a=>h(a.target.value),onKeyDown:a=>{"Enter"===a.key&&g.trim()&&!i&&(q("pack_install_submitted",{via:"input"}),v("input",()=>F(g)))},placeholder:"core · acme/ops · acme/ops@v1.2.0 · a release URL",spellCheck:!1,disabled:d||null!==i,className:"flex-1 min-w-[16rem] rounded-md border border-border/60 bg-background px-2.5 py-1.5 text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50","aria-label":"Pack source"}),(0,b.jsx)(T.Button,{size:"sm",variant:"outline",disabled:d||null!==i||0===g.trim().length,onClick:()=>{q("pack_preview_submitted",{}),u()},children:"preview"===i?"Reading…":"Preview"}),(0,b.jsxs)(T.Button,{size:"sm",variant:"default",disabled:d||null!==i||0===g.trim().length,onClick:()=>{q("pack_install_submitted",{via:"button"}),v("input",()=>F(g))},children:[(0,b.jsx)(l,{className:"h-3.5 w-3.5"}),"input"===i?"Installing…":"Install"]})]}),o?.ok&&(0,b.jsxs)("div",{className:"border-b border-border/20 bg-muted/5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,b.jsx)(k,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,b.jsxs)("span",{className:"text-xs font-mono text-foreground",children:[o.id,"@",o.version]}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[o.policies?.length??0," policies ·"," ",o.policies?.filter(a=>a.defaultEnabled).length??0," on by default"]}),"observe"===o.effect&&(0,b.jsx)("span",{className:"text-[0.65rem] uppercase tracking-wider text-amber-500",children:"observes only"}),(0,b.jsx)("button",{onClick:()=>p(null),className:"ml-auto text-muted-foreground/60 hover:text-foreground","aria-label":"Close preview",children:(0,b.jsx)(t.X,{className:"h-3.5 w-3.5"})})]}),(0,b.jsx)("div",{className:"max-h-64 overflow-y-auto",children:o.policies?.map(a=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-2 border-t border-border/10",children:[(0,b.jsx)("span",{className:`text-[0.65rem] uppercase tracking-wider w-14 shrink-0 mt-0.5 ${a.defaultEnabled?"text-emerald-500":"text-muted-foreground/50"}`,children:a.defaultEnabled?"default":"opt-in"}),(0,b.jsx)("span",{className:"text-xs font-mono text-foreground w-56 shrink-0 truncate",children:a.name}),(0,b.jsxs)("span",{className:"text-xs text-muted-foreground leading-relaxed min-w-0",children:[a.description,(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5",children:a.category})]})]},a.name))}),(0,b.jsx)("div",{className:"px-4 py-2.5 border-t border-border/20",children:(0,b.jsxs)(T.Button,{size:"sm",variant:"default",disabled:d||null!==i,onClick:()=>{q("pack_install_submitted",{via:"preview"}),v("input",()=>F(g)).then(()=>p(null))},children:[(0,b.jsx)(l,{className:"h-3.5 w-3.5"}),"Install its defaults"]})})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,b.jsx)("span",{className:"text-[0.7rem] text-muted-foreground/70 mr-1",children:"Failproof AI policies:"}),(0,b.jsx)(T.Button,{size:"sm",variant:"outline",disabled:d||null!==i,onClick:()=>{q("pack_install_submitted",{via:"ours"}),v("ours",()=>F("FailproofAI/policies"))},children:"ours"===i?"Installing…":"Install from GitHub"}),(0,b.jsx)(T.Button,{size:"sm",variant:"outline",disabled:d||null!==i,onClick:()=>{q("pack_install_submitted",{via:"bundled"}),v("bundled",()=>E())},children:"bundled"===i?"Installing…":"Install offline copy"}),m&&(0,b.jsxs)("span",{className:"text-[0.7rem] text-emerald-500 font-mono",children:["installed ",m]})]}),a.map(a=>(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,b.jsx)(k,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,b.jsxs)("span",{className:"text-xs font-mono text-foreground truncate",children:[a.id,a.version?`@${a.version}`:""]}),"observe"===a.effect&&(0,b.jsx)("span",{className:"text-[0.65rem] uppercase tracking-wider text-amber-500",children:"observing"}),(0,b.jsx)("span",{className:"text-[0.65rem] text-muted-foreground/50 font-mono truncate hidden lg:inline",children:a.source}),(0,b.jsx)("button",{onClick:()=>void v(a.id,()=>H(a.id)),disabled:d||null!==i,className:"ml-auto text-muted-foreground/60 hover:text-foreground disabled:opacity-40","aria-label":`Remove ${a.id}`,children:(0,b.jsx)(r,{className:"h-3.5 w-3.5"})})]}),a.error?(0,b.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-amber-500/5",children:[(0,b.jsx)(s,{className:"h-3.5 w-3.5 text-amber-500 shrink-0 mt-0.5"}),(0,b.jsxs)("p",{className:"text-[0.7rem] text-muted-foreground leading-relaxed",children:["This pack will not load: ",a.error]})]}):(0,b.jsx)("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-border/20",children:(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[a.policies.filter(a=>a.enabled).length," of ",a.policies.length," on — listed by category above"]})})]},`${a.id}@${a.version}`))]})}function aj({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,O.useUrlParams)(),{capture:e}=(0,N.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)(()=>{C().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 harnesses."}),(0,b.jsx)(aj,{activeTab:f,onChange:o}),"activity"===f?(0,b.jsx)(ad,{hooksInstalled:h,onSwitchTab:o}):(0,b.jsx)(ah,{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)(t.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)(t.X,{className:"h-4 w-4"})})]}),(0,b.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,b.jsx)(T.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)(T.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 ah({onHooksInstallChange:a}){let[d,e]=(0,c.useState)(null),[f,g]=(0,c.useTransition)(),[h,j]=(0,c.useState)(null),[k,l]=(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,N.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 C();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,z=(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 D(a,!b)}catch{u("custom_policy_toggle","Failed to save custom policy change."),v()}}))},A=()=>{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 J("user",a),b.length>0&&await K("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 B=d.clis.some(a=>a.installed),E=w.size,F=q.size,G=Array.from(new Set(d.policies.map(a=>a.category)));return(0,b.jsxs)(b.Fragment,{children:[o&&(0,b.jsx)(af,{policy:o,onClose:()=>{t("policy_config_modal_closed",{policy_name:o.name,action:"cancel"}),p(null)},onSave:a=>{var b,c;if(!o)return;let d=o.packId?(b=o.packId,c=o.name,`pack/${b}/${c}`):o.name;p(null),g(async()=>{try{j(null),await L(d,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 ${B?"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:E.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)(T.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 J("user",a)}catch(a){u("cli_reinstall",a instanceof Error?a.message:"Failed to reinstall.")}finally{await v()}}))},disabled:f||0===F,className:"text-xs h-7 px-3 font-mono",children:"Reinstall"}),(0,b.jsx)(T.Button,{variant:"default",size:"sm",onClick:A,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,Q.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.policies.filter(a=>a.enabled).length+(d.customPolicies?.filter(a=>a.enabled).length??0)+(d.conventionPolicies?.reduce((a,b)=>a+b.policies.filter(a=>a.enabled).length,0)??0)})," / ",d.policies.length+(d.customPolicies?.length??0)+(d.conventionPolicies?.reduce((a,b)=>a+b.policies.length,0)??0)," ","policies enabled"]}),B&&(0,b.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground/60",children:["· shared across ",E," active CLI",1===E?"":"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}),k&&(0,b.jsx)(ag,{message:k,onDismiss:()=>l(null),onInstall:A,isPending:f}),G.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)(ae,{enabled:a.enabled,onChange:()=>{var b;let c;return b=a.enabled,c=a.name,void(!d||(!d.clis.some(a=>a.installed)?l("Policies are not installed. Install policies to continue."):(l(null),e(d=>d?{...d,policies:d.policies.map(d=>d.name===c&&d.packId===a.packId?{...d,enabled:!b}:d),packs:d.packs.map(d=>d.id===a.packId?{...d,policies:d.policies.map(a=>a.name===c?{...a,enabled:!b}:a)}:d)}:d),g(async()=>{try{let d=await I(a.packId,c,!b);d.ok||(u("policy_toggle",d.error??"Failed to save policy change."),v())}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)(m.Settings,{className:"h-3.5 w-3.5"})})]},`${a.packId}/${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)(n,{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)(ae,{enabled:a.enabled,onChange:()=>z(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)(n,{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)(ae,{enabled:c.enabled,onChange:()=>z(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)),(0,b.jsx)(ai,{packs:d.packs??[],disabled:f,onChanged:v,onError:a=>u("pack_action",a)})]})]})}function ai({packs:a,disabled:d,onChanged:e,onError:f}){let[g,h]=(0,c.useState)(""),[i,j]=(0,c.useState)(null),[m,n]=(0,c.useState)(null),[o,p]=(0,c.useState)(null),{capture:q}=(0,N.usePostHog)(),u=async()=>{if(g.trim()){j("preview"),p(null);try{let a=await G(g);if(!a.ok)return void f(a.error??"Could not read that pack.");p(a)}finally{j(null)}}},v=async(a,b)=>{j(a),n(null);try{let a=await b();if(!a.ok)return void f(a.error??"Could not install that pack.");n(a.version?`${a.id}@${a.version}`:a.id??null),h(""),e()}catch(a){f(a instanceof Error?a.message:"Could not install that pack.")}finally{j(null)}};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:"Policy Packs"}),(0,b.jsx)("span",{className:"text-[0.7rem] text-muted-foreground",children:0===a.length?"none installed":`${a.length} installed`})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 px-4 py-3 border-b border-border/20",children:[(0,b.jsx)("input",{value:g,onChange:a=>h(a.target.value),onKeyDown:a=>{"Enter"===a.key&&g.trim()&&!i&&(q("pack_install_submitted",{via:"input"}),v("input",()=>F(g)))},placeholder:"core · acme/ops · acme/ops@v1.2.0 · a release URL",spellCheck:!1,disabled:d||null!==i,className:"flex-1 min-w-[16rem] rounded-md border border-border/60 bg-background px-2.5 py-1.5 text-xs font-mono placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-ring disabled:opacity-50","aria-label":"Pack source"}),(0,b.jsx)(T.Button,{size:"sm",variant:"outline",disabled:d||null!==i||0===g.trim().length,onClick:()=>{q("pack_preview_submitted",{}),u()},children:"preview"===i?"Reading…":"Preview"}),(0,b.jsxs)(T.Button,{size:"sm",variant:"default",disabled:d||null!==i||0===g.trim().length,onClick:()=>{q("pack_install_submitted",{via:"button"}),v("input",()=>F(g))},children:[(0,b.jsx)(l,{className:"h-3.5 w-3.5"}),"input"===i?"Installing…":"Install"]})]}),o?.ok&&(0,b.jsxs)("div",{className:"border-b border-border/20 bg-muted/5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,b.jsx)(k,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,b.jsxs)("span",{className:"text-xs font-mono text-foreground",children:[o.id,"@",o.version]}),(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[o.policies?.length??0," policies ·"," ",o.policies?.filter(a=>a.defaultEnabled).length??0," on by default"]}),"observe"===o.effect&&(0,b.jsx)("span",{className:"text-[0.65rem] uppercase tracking-wider text-amber-500",children:"observes only"}),(0,b.jsx)("button",{onClick:()=>p(null),className:"ml-auto text-muted-foreground/60 hover:text-foreground","aria-label":"Close preview",children:(0,b.jsx)(t.X,{className:"h-3.5 w-3.5"})})]}),(0,b.jsx)("div",{className:"max-h-64 overflow-y-auto",children:o.policies?.map(a=>(0,b.jsxs)("div",{className:"flex items-start gap-3 px-4 py-2 border-t border-border/10",children:[(0,b.jsx)("span",{className:`text-[0.65rem] uppercase tracking-wider w-14 shrink-0 mt-0.5 ${a.defaultEnabled?"text-emerald-500":"text-muted-foreground/50"}`,children:a.defaultEnabled?"default":"opt-in"}),(0,b.jsx)("span",{className:"text-xs font-mono text-foreground w-56 shrink-0 truncate",children:a.name}),(0,b.jsxs)("span",{className:"text-xs text-muted-foreground leading-relaxed min-w-0",children:[a.description,(0,b.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5",children:a.category})]})]},a.name))}),(0,b.jsx)("div",{className:"px-4 py-2.5 border-t border-border/20",children:(0,b.jsxs)(T.Button,{size:"sm",variant:"default",disabled:d||null!==i,onClick:()=>{q("pack_install_submitted",{via:"preview"}),v("input",()=>F(g)).then(()=>p(null))},children:[(0,b.jsx)(l,{className:"h-3.5 w-3.5"}),"Install its defaults"]})})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,b.jsx)("span",{className:"text-[0.7rem] text-muted-foreground/70 mr-1",children:"Failproof AI policies:"}),(0,b.jsx)(T.Button,{size:"sm",variant:"outline",disabled:d||null!==i,onClick:()=>{q("pack_install_submitted",{via:"ours"}),v("ours",()=>F("FailproofAI/policies"))},children:"ours"===i?"Installing…":"Install from GitHub"}),(0,b.jsx)(T.Button,{size:"sm",variant:"outline",disabled:d||null!==i,onClick:()=>{q("pack_install_submitted",{via:"bundled"}),v("bundled",()=>E())},children:"bundled"===i?"Installing…":"Install offline copy"}),m&&(0,b.jsxs)("span",{className:"text-[0.7rem] text-emerald-500 font-mono",children:["installed ",m]})]}),a.map(a=>(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,b.jsx)(k,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,b.jsxs)("span",{className:"text-xs font-mono text-foreground truncate",children:[a.id,a.version?`@${a.version}`:""]}),"observe"===a.effect&&(0,b.jsx)("span",{className:"text-[0.65rem] uppercase tracking-wider text-amber-500",children:"observing"}),(0,b.jsx)("span",{className:"text-[0.65rem] text-muted-foreground/50 font-mono truncate hidden lg:inline",children:a.source}),(0,b.jsx)("button",{onClick:()=>void v(a.id,()=>H(a.id)),disabled:d||null!==i,className:"ml-auto text-muted-foreground/60 hover:text-foreground disabled:opacity-40","aria-label":`Remove ${a.id}`,children:(0,b.jsx)(r,{className:"h-3.5 w-3.5"})})]}),a.error?(0,b.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-amber-500/5",children:[(0,b.jsx)(s,{className:"h-3.5 w-3.5 text-amber-500 shrink-0 mt-0.5"}),(0,b.jsxs)("p",{className:"text-[0.7rem] text-muted-foreground leading-relaxed",children:["This pack will not load: ",a.error]})]}):(0,b.jsx)("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-border/20",children:(0,b.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[a.policies.filter(a=>a.enabled).length," of ",a.policies.length," on — listed by category above"]})})]},`${a.id}@${a.version}`))]})}function aj({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,O.useUrlParams)(),{capture:e}=(0,N.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)(()=>{C().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 harnesses."}),(0,b.jsx)(aj,{activeTab:f,onChange:o}),"activity"===f?(0,b.jsx)(ad,{hooksInstalled:h,onSwitchTab:o}):(0,b.jsx)(ah,{onHooksInstallChange:i})]})})}],22712)}];
7
7
 
8
8
  //# sourceMappingURL=app_policies_hooks-client_tsx_19dqvpc._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[41857,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(5050);let e=(0,d.createServerReference)("00c78a3b3965b1c7b3e77ca07bce6472ebeef149cc",d.callServer,void 0,d.findSourceMapURL,"getScheduledAuditAction"),f=(0,d.createServerReference)("40aff699caed8dd22c43afbc14eb30dbf1843654ed",d.callServer,void 0,d.findSourceMapURL,"setAutoAuditAction"),g=(0,d.createServerReference)("402ab2cdcb843674993066b0e6cf6d0d33ae5b6af8",d.callServer,void 0,d.findSourceMapURL,"setAuditIntervalAction");var h=a.i(89564),i=a.i(4543),j=a.i(18952),k=a.i(80977);function l(a){return new Date(a).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function m(a,b){let c=a-b;if(c<=0)return"now";let d=Math.floor(c/864e5),e=Math.floor(c%864e5/36e5);return d>0?e>0?`${d}d ${e}h`:`${d}d`:e>0?`${e}h`:`${Math.max(1,Math.floor(c/6e4))}m`}function n(a){return a.toLocaleString("en-US")}function o({label:a,value:c,sub:d,tone:e}){return(0,b.jsxs)("div",{className:"set-stat",children:[(0,b.jsx)("div",{className:"set-stat-label",children:a}),(0,b.jsx)("div",{className:`set-stat-value${e?` ${e}`:""}`,children:c}),(0,b.jsx)("div",{className:"set-stat-sub",children:d??" "})]})}function p({lastRunAtMs:a,nextDueAtMs:c,now:d}){if(null==a||null==c||c<=a)return null;let e=Math.min(100,Math.max(0,(d-a)/(c-a)*100));return(0,b.jsxs)("div",{className:"tape","aria-hidden":"true",children:[(0,b.jsxs)("div",{className:"tape-rail",children:[(0,b.jsx)("div",{className:"tape-fill",style:{width:`${e}%`}}),(0,b.jsx)("div",{className:"tape-now",style:{left:`${e}%`}})]}),(0,b.jsxs)("div",{className:"tape-ends",children:[(0,b.jsxs)("span",{children:["last scan · ",l(a)]}),(0,b.jsxs)("span",{className:"tape-next",children:["next · ",m(c,d)]})]})]})}function q({enabled:a,onChange:c,disabled:d,label:e}){return(0,b.jsx)("button",{type:"button",role:"switch","aria-checked":a,"aria-label":e,disabled:d,onClick:c,className:"sw","data-on":a?"true":"false",children:(0,b.jsx)("span",{className:"sw-knob"})})}let r=[{label:"reads",body:"every session transcript on disk — your prompts, the files your agents read and wrote, and command output."},{label:"runs",body:"entirely on this machine. the transcripts never leave it."},{label:"sends",body:"counts, redacted examples, and this machine's name — and only when a scan finds something harmful."}];a.s(["default",0,function({initial:a}){let[d,s]=(0,c.useState)(a),[t,u]=(0,c.useState)(a?.auto??!1),[v,w]=(0,c.useState)(a?.intervalDays??7),[x,y]=(0,c.useState)(!1),[z,A]=(0,c.useState)(!1),[B,C]=(0,c.useState)(!1),[D,E]=(0,c.useState)(null===a),[F,G]=(0,c.useState)(0),H=(0,c.useRef)(!0),I=(0,c.useRef)(null!==a),J=(0,c.useCallback)(async()=>{try{let a=await e();if(!H.current)return;s(a),I.current=!0,u(a.auto),w(a.intervalDays),G(Date.now()),E(!1)}catch{H.current&&!I.current&&E(!0)}},[]);(0,c.useEffect)(()=>(H.current=!0,J(),()=>{H.current=!1}),[J]),(0,c.useEffect)(()=>{let a=()=>void J();return window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),()=>{window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a)}},[J]);let K=d?.signedInAs??null,L=d?.daemon==="running",M=d?.daemon==="unsupported-platform",N=d?.schedule??null,O=d?.lastScan??null,P=N?.lastExitCode!=null&&0!==N.lastExitCode&&75!==N.lastExitCode,Q=(0,c.useCallback)(async()=>{y(!0);try{let a=await f(!0);if(!a.ok){if(u(!1),"unreachable"===a.reason)return void(0,j.toast)("could not reach the server. check your connection and try again.");await J(),C(!0),(0,j.toast)("that sign-in expired. one more code and it's on.");return}u(a.auto),(0,j.toast)("scheduled audits on."),await J()}catch{u(!1),(0,j.toast)("could not turn that on.")}finally{y(!1)}},[J]),R=(0,c.useCallback)(async()=>{if(t){y(!0);try{let a=await f(!1);a.ok&&u(a.auto),(0,j.toast)("scheduled audits off."),await J()}catch{(0,j.toast)("could not turn that off.")}finally{y(!1)}return}K?await Q():C(!0)},[t,Q,J,K]),S=(0,c.useCallback)(async a=>{y(!0);try{let b=await g(a);w(b.intervalDays),s(a=>a?{...a,intervalDays:b.intervalDays}:a),(0,j.toast)(`scanning every ${b.intervalDays} day${1===b.intervalDays?"":"s"}.`)}catch{w(d?.intervalDays??7),(0,j.toast)("could not save that.")}finally{y(!1)}},[d?.intervalDays]),T=(0,c.useCallback)(async()=>{y(!0);try{await fetch("/api/auth/logout",{method:"POST"}),(0,j.toast)("signed out. scans continue; digests pause."),await J()}catch{(0,j.toast)("could not sign out.")}finally{y(!1)}},[J]),U=(0,c.useCallback)(async()=>{if(!z){A(!0);try{await (0,h.triggerRun)({cli:[],since:"all",noCache:!1}),(0,j.toast)("scan complete."),await J()}catch(a){(0,j.toast)(a instanceof h.RerunError&&"timeout"===a.kind?"the scan is taking a while — it will finish in the background.":"the scan could not be completed.")}finally{A(!1)}}},[J,z]),V=(0,c.useCallback)(async a=>{C(!1),await J(),await Q()},[Q,J]),W=d?L?{value:"running",sub:null!=d.daemonStartedAtMs&&F>0?`up ${function(a){let b=Math.floor(a/864e5);if(b>0)return`${b}d`;let c=Math.floor(a/36e5);return c>0?`${c}h`:`${Math.max(1,Math.floor(a/6e4))}m`}(Math.max(0,F-d.daemonStartedAtMs))}`:"",tone:"ok"}:M?{value:"unavailable",sub:"not on this platform"}:"not-installed"===d.daemon?{value:"not installed",sub:"run failproofai config",tone:"warn"}:"unknown"===d.daemon?{value:"unknown",sub:"could not read it"}:{value:"stopped",sub:"run failproofai config",tone:"warn"}:{value:"…",sub:"reading"},X=t?N?.nextDueAtMs==null?{value:"pending",sub:"after the next scan"}:{value:F>0?m(N.nextDueAtMs,F):"—",sub:l(N.nextDueAtMs)}:{value:"off",sub:"nothing scheduled"},Y=O?{value:(0,k.formatRelativeTime)(Date.parse(O.finishedAt)),sub:null!=O.sessionsScanned?`${n(O.sessionsScanned)} sessions`:"scanned"}:{value:"none yet",sub:"run one below"},Z=O?null==O.findings?{value:"—",sub:"unreadable"}:{value:n(O.findings),sub:"this scan",...O.findings>0?{tone:"warn"}:{}}:{value:"—",sub:"no scan yet"};return(0,b.jsxs)("main",{className:"report",children:[(0,b.jsxs)("section",{className:"section set-sec",children:[(0,b.jsxs)("div",{className:"set-mast",children:[(0,b.jsx)("h1",{className:"set-title",children:"settings"}),(0,b.jsx)("p",{className:"set-lede",children:"keeping watch, so you don't have to."})]}),D?(0,b.jsx)("div",{className:"set-console",children:(0,b.jsx)("div",{className:"set-cell",children:(0,b.jsxs)("p",{className:"set-warn",children:["could not read this machine's settings. check that the dashboard can reach ",(0,b.jsx)("code",{children:"~/.failproofai/config.json"}),"."]})})}):(0,b.jsxs)("div",{className:"set-console",children:[(0,b.jsxs)("div",{className:"set-stats",children:[(0,b.jsx)(o,{label:"daemon",...W}),(0,b.jsx)(o,{label:"next scan",...X}),(0,b.jsx)(o,{label:"last scan",...Y}),(0,b.jsx)(o,{label:"findings",...Z})]}),(0,b.jsxs)("div",{className:"set-cols",children:[(0,b.jsxs)("div",{className:"set-cell set-config",children:[(0,b.jsx)("h2",{className:"set-cell-title",children:"scheduled audit"}),(0,b.jsxs)("div",{className:"set-row set-row-main",children:[(0,b.jsx)(q,{enabled:t,disabled:x||null===d,onChange:()=>void R(),label:t?"turn off scheduled audits":"turn on scheduled audits"}),(0,b.jsxs)("div",{className:"set-row-copy",children:[(0,b.jsx)("span",{className:"set-strong",children:t?"scanning on a schedule.":"scan on a schedule."}),(0,b.jsx)("span",{className:"set-dim",children:t?"you'll get an email only when a scan finds something.":"off. nothing runs and nothing is sent."})]})]}),(0,b.jsxs)("div",{className:"set-row set-row-interval",children:[(0,b.jsx)("span",{className:"set-dim",children:"scan every"}),(0,b.jsx)("input",{type:"number",className:"set-num",min:1,max:90,value:v,disabled:x||null===d,"aria-label":"days between scheduled scans",onChange:a=>w(Number(a.target.value)),onBlur:a=>{let b=Number(a.target.value);Number.isFinite(b)?b!==d?.intervalDays&&S(b):w(d?.intervalDays??7)}}),(0,b.jsx)("span",{className:"set-dim",children:"days"}),(0,b.jsxs)("span",{className:"set-hint",children:[1,"–",90]})]}),(0,b.jsx)("div",{className:"set-rule"}),(0,b.jsx)("div",{className:"set-row set-row-identity",children:K?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"set-dim",children:"reports go to"}),(0,b.jsx)("span",{className:"set-email",children:K.email}),(0,b.jsx)("button",{type:"button",className:"set-link",disabled:x,onClick:()=>void T(),children:"sign out"})]}):t?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"set-warn",children:"signed out — scans continue, digests are paused."}),(0,b.jsx)("button",{type:"button",className:"set-link",disabled:x,onClick:()=>C(!0),children:"sign in to resume"})]}):(0,b.jsx)("span",{className:"set-dim",children:"turning this on asks for an email, so there is somewhere to send the report."})}),t&&d&&!L&&(0,b.jsx)("p",{className:"set-warn",children:M?"the background service isn't available on this platform, so scheduled scans can't run here. you can still run one now.":"not-installed"===d.daemon?"the background service isn't installed, so nothing will run on the timer. install it with `failproofai config`.":"the background service is stopped, so nothing will run until it starts. repair it with `failproofai config`."}),P&&(0,b.jsxs)("p",{className:"set-warn",children:["the last scheduled scan exited ",N?.lastExitCode,". the next one will still run."]}),(0,b.jsx)("div",{className:"set-actions",children:(0,b.jsx)("button",{type:"button",className:"btn btn-press",disabled:z,onClick:()=>void U(),children:z?"[ scanning… ]":"[ run a scan now ]"})})]}),(0,b.jsxs)("div",{className:"set-cell set-how",children:[(0,b.jsx)("h2",{className:"set-cell-title",children:"how it works"}),(0,b.jsx)("dl",{className:"set-how-list",children:r.map(a=>(0,b.jsxs)("div",{className:"set-how-row",children:[(0,b.jsx)("dt",{className:"set-how-label",children:a.label}),(0,b.jsx)("dd",{className:"set-how-body",children:a.body})]},a.label))})]})]})]}),t&&F>0&&(0,b.jsx)(p,{lastRunAtMs:N?.lastRunAtMs??null,nextDueAtMs:N?.nextDueAtMs??null,now:F})]}),(0,b.jsx)(i.AuthDialog,{open:B,source:"settings_scheduled_audit",headline:"where should the report go?",subhead:"we'll send a one-time code to confirm.",onClose:()=>C(!1),onAuthed:a=>void V(a)})]})}],41857)}];
1
+ module.exports=[41857,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(5050);let e=(0,d.createServerReference)("00587d4a2f4593133653948c72e3ef6ff0e53de865",d.callServer,void 0,d.findSourceMapURL,"getScheduledAuditAction"),f=(0,d.createServerReference)("40d6d04262c3b72c0287d9199e482ead760a7ed3ac",d.callServer,void 0,d.findSourceMapURL,"setAutoAuditAction"),g=(0,d.createServerReference)("40d82998f3602e35c10dd285acd1da7a1b84835266",d.callServer,void 0,d.findSourceMapURL,"setAuditIntervalAction");var h=a.i(89564),i=a.i(4543),j=a.i(18952),k=a.i(80977);function l(a){return new Date(a).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function m(a,b){let c=a-b;if(c<=0)return"now";let d=Math.floor(c/864e5),e=Math.floor(c%864e5/36e5);return d>0?e>0?`${d}d ${e}h`:`${d}d`:e>0?`${e}h`:`${Math.max(1,Math.floor(c/6e4))}m`}function n(a){return a.toLocaleString("en-US")}function o({label:a,value:c,sub:d,tone:e}){return(0,b.jsxs)("div",{className:"set-stat",children:[(0,b.jsx)("div",{className:"set-stat-label",children:a}),(0,b.jsx)("div",{className:`set-stat-value${e?` ${e}`:""}`,children:c}),(0,b.jsx)("div",{className:"set-stat-sub",children:d??" "})]})}function p({lastRunAtMs:a,nextDueAtMs:c,now:d}){if(null==a||null==c||c<=a)return null;let e=Math.min(100,Math.max(0,(d-a)/(c-a)*100));return(0,b.jsxs)("div",{className:"tape","aria-hidden":"true",children:[(0,b.jsxs)("div",{className:"tape-rail",children:[(0,b.jsx)("div",{className:"tape-fill",style:{width:`${e}%`}}),(0,b.jsx)("div",{className:"tape-now",style:{left:`${e}%`}})]}),(0,b.jsxs)("div",{className:"tape-ends",children:[(0,b.jsxs)("span",{children:["last scan · ",l(a)]}),(0,b.jsxs)("span",{className:"tape-next",children:["next · ",m(c,d)]})]})]})}function q({enabled:a,onChange:c,disabled:d,label:e}){return(0,b.jsx)("button",{type:"button",role:"switch","aria-checked":a,"aria-label":e,disabled:d,onClick:c,className:"sw","data-on":a?"true":"false",children:(0,b.jsx)("span",{className:"sw-knob"})})}let r=[{label:"reads",body:"every session transcript on disk — your prompts, the files your agents read and wrote, and command output."},{label:"runs",body:"entirely on this machine. the transcripts never leave it."},{label:"sends",body:"counts, redacted examples, and this machine's name — and only when a scan finds something harmful."}];a.s(["default",0,function({initial:a}){let[d,s]=(0,c.useState)(a),[t,u]=(0,c.useState)(a?.auto??!1),[v,w]=(0,c.useState)(a?.intervalDays??7),[x,y]=(0,c.useState)(!1),[z,A]=(0,c.useState)(!1),[B,C]=(0,c.useState)(!1),[D,E]=(0,c.useState)(null===a),[F,G]=(0,c.useState)(0),H=(0,c.useRef)(!0),I=(0,c.useRef)(null!==a),J=(0,c.useCallback)(async()=>{try{let a=await e();if(!H.current)return;s(a),I.current=!0,u(a.auto),w(a.intervalDays),G(Date.now()),E(!1)}catch{H.current&&!I.current&&E(!0)}},[]);(0,c.useEffect)(()=>(H.current=!0,J(),()=>{H.current=!1}),[J]),(0,c.useEffect)(()=>{let a=()=>void J();return window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),()=>{window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a)}},[J]);let K=d?.signedInAs??null,L=d?.daemon==="running",M=d?.daemon==="unsupported-platform",N=d?.schedule??null,O=d?.lastScan??null,P=N?.lastExitCode!=null&&0!==N.lastExitCode&&75!==N.lastExitCode,Q=(0,c.useCallback)(async()=>{y(!0);try{let a=await f(!0);if(!a.ok){if(u(!1),"unreachable"===a.reason)return void(0,j.toast)("could not reach the server. check your connection and try again.");await J(),C(!0),(0,j.toast)("that sign-in expired. one more code and it's on.");return}u(a.auto),(0,j.toast)("scheduled audits on."),await J()}catch{u(!1),(0,j.toast)("could not turn that on.")}finally{y(!1)}},[J]),R=(0,c.useCallback)(async()=>{if(t){y(!0);try{let a=await f(!1);a.ok&&u(a.auto),(0,j.toast)("scheduled audits off."),await J()}catch{(0,j.toast)("could not turn that off.")}finally{y(!1)}return}K?await Q():C(!0)},[t,Q,J,K]),S=(0,c.useCallback)(async a=>{y(!0);try{let b=await g(a);w(b.intervalDays),s(a=>a?{...a,intervalDays:b.intervalDays}:a),(0,j.toast)(`scanning every ${b.intervalDays} day${1===b.intervalDays?"":"s"}.`)}catch{w(d?.intervalDays??7),(0,j.toast)("could not save that.")}finally{y(!1)}},[d?.intervalDays]),T=(0,c.useCallback)(async()=>{y(!0);try{await fetch("/api/auth/logout",{method:"POST"}),(0,j.toast)("signed out. scans continue; digests pause."),await J()}catch{(0,j.toast)("could not sign out.")}finally{y(!1)}},[J]),U=(0,c.useCallback)(async()=>{if(!z){A(!0);try{await (0,h.triggerRun)({cli:[],since:"all",noCache:!1}),(0,j.toast)("scan complete."),await J()}catch(a){(0,j.toast)(a instanceof h.RerunError&&"timeout"===a.kind?"the scan is taking a while — it will finish in the background.":"the scan could not be completed.")}finally{A(!1)}}},[J,z]),V=(0,c.useCallback)(async a=>{C(!1),await J(),await Q()},[Q,J]),W=d?L?{value:"running",sub:null!=d.daemonStartedAtMs&&F>0?`up ${function(a){let b=Math.floor(a/864e5);if(b>0)return`${b}d`;let c=Math.floor(a/36e5);return c>0?`${c}h`:`${Math.max(1,Math.floor(a/6e4))}m`}(Math.max(0,F-d.daemonStartedAtMs))}`:"",tone:"ok"}:M?{value:"unavailable",sub:"not on this platform"}:"not-installed"===d.daemon?{value:"not installed",sub:"run failproofai config",tone:"warn"}:"unknown"===d.daemon?{value:"unknown",sub:"could not read it"}:{value:"stopped",sub:"run failproofai config",tone:"warn"}:{value:"…",sub:"reading"},X=t?N?.nextDueAtMs==null?{value:"pending",sub:"after the next scan"}:{value:F>0?m(N.nextDueAtMs,F):"—",sub:l(N.nextDueAtMs)}:{value:"off",sub:"nothing scheduled"},Y=O?{value:(0,k.formatRelativeTime)(Date.parse(O.finishedAt)),sub:null!=O.sessionsScanned?`${n(O.sessionsScanned)} sessions`:"scanned"}:{value:"none yet",sub:"run one below"},Z=O?null==O.findings?{value:"—",sub:"unreadable"}:{value:n(O.findings),sub:"this scan",...O.findings>0?{tone:"warn"}:{}}:{value:"—",sub:"no scan yet"};return(0,b.jsxs)("main",{className:"report",children:[(0,b.jsxs)("section",{className:"section set-sec",children:[(0,b.jsxs)("div",{className:"set-mast",children:[(0,b.jsx)("h1",{className:"set-title",children:"settings"}),(0,b.jsx)("p",{className:"set-lede",children:"keeping watch, so you don't have to."})]}),D?(0,b.jsx)("div",{className:"set-console",children:(0,b.jsx)("div",{className:"set-cell",children:(0,b.jsxs)("p",{className:"set-warn",children:["could not read this machine's settings. check that the dashboard can reach ",(0,b.jsx)("code",{children:"~/.failproofai/config.json"}),"."]})})}):(0,b.jsxs)("div",{className:"set-console",children:[(0,b.jsxs)("div",{className:"set-stats",children:[(0,b.jsx)(o,{label:"daemon",...W}),(0,b.jsx)(o,{label:"next scan",...X}),(0,b.jsx)(o,{label:"last scan",...Y}),(0,b.jsx)(o,{label:"findings",...Z})]}),(0,b.jsxs)("div",{className:"set-cols",children:[(0,b.jsxs)("div",{className:"set-cell set-config",children:[(0,b.jsx)("h2",{className:"set-cell-title",children:"scheduled audit"}),(0,b.jsxs)("div",{className:"set-row set-row-main",children:[(0,b.jsx)(q,{enabled:t,disabled:x||null===d,onChange:()=>void R(),label:t?"turn off scheduled audits":"turn on scheduled audits"}),(0,b.jsxs)("div",{className:"set-row-copy",children:[(0,b.jsx)("span",{className:"set-strong",children:t?"scanning on a schedule.":"scan on a schedule."}),(0,b.jsx)("span",{className:"set-dim",children:t?"you'll get an email only when a scan finds something.":"off. nothing runs and nothing is sent."})]})]}),(0,b.jsxs)("div",{className:"set-row set-row-interval",children:[(0,b.jsx)("span",{className:"set-dim",children:"scan every"}),(0,b.jsx)("input",{type:"number",className:"set-num",min:1,max:90,value:v,disabled:x||null===d,"aria-label":"days between scheduled scans",onChange:a=>w(Number(a.target.value)),onBlur:a=>{let b=Number(a.target.value);Number.isFinite(b)?b!==d?.intervalDays&&S(b):w(d?.intervalDays??7)}}),(0,b.jsx)("span",{className:"set-dim",children:"days"}),(0,b.jsxs)("span",{className:"set-hint",children:[1,"–",90]})]}),(0,b.jsx)("div",{className:"set-rule"}),(0,b.jsx)("div",{className:"set-row set-row-identity",children:K?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"set-dim",children:"reports go to"}),(0,b.jsx)("span",{className:"set-email",children:K.email}),(0,b.jsx)("button",{type:"button",className:"set-link",disabled:x,onClick:()=>void T(),children:"sign out"})]}):t?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"set-warn",children:"signed out — scans continue, digests are paused."}),(0,b.jsx)("button",{type:"button",className:"set-link",disabled:x,onClick:()=>C(!0),children:"sign in to resume"})]}):(0,b.jsx)("span",{className:"set-dim",children:"turning this on asks for an email, so there is somewhere to send the report."})}),t&&d&&!L&&(0,b.jsx)("p",{className:"set-warn",children:M?"the background service isn't available on this platform, so scheduled scans can't run here. you can still run one now.":"not-installed"===d.daemon?"the background service isn't installed, so nothing will run on the timer. install it with `failproofai config`.":"the background service is stopped, so nothing will run until it starts. repair it with `failproofai config`."}),P&&(0,b.jsxs)("p",{className:"set-warn",children:["the last scheduled scan exited ",N?.lastExitCode,". the next one will still run."]}),(0,b.jsx)("div",{className:"set-actions",children:(0,b.jsx)("button",{type:"button",className:"btn btn-press",disabled:z,onClick:()=>void U(),children:z?"[ scanning… ]":"[ run a scan now ]"})})]}),(0,b.jsxs)("div",{className:"set-cell set-how",children:[(0,b.jsx)("h2",{className:"set-cell-title",children:"how it works"}),(0,b.jsx)("dl",{className:"set-how-list",children:r.map(a=>(0,b.jsxs)("div",{className:"set-how-row",children:[(0,b.jsx)("dt",{className:"set-how-label",children:a.label}),(0,b.jsx)("dd",{className:"set-how-body",children:a.body})]},a.label))})]})]})]}),t&&F>0&&(0,b.jsx)(p,{lastRunAtMs:N?.lastRunAtMs??null,nextDueAtMs:N?.nextDueAtMs??null,now:F})]}),(0,b.jsx)(i.AuthDialog,{open:B,source:"settings_scheduled_audit",headline:"where should the report go?",subhead:"we'll send a one-time code to confirm.",onClose:()=>C(!1),onAuthed:a=>void V(a)})]})}],41857)}];
2
2
 
3
3
  //# sourceMappingURL=app_settings_settings-client_tsx_20lq-mq._.js.map
@@ -0,0 +1,10 @@
1
+ module.exports=[15638,a=>{"use strict";var b=a.i(50227),c=a.i(54799),d=a.i(2157),e=a.i(12714),f=a.i(57764),g=a.i(66680),h=a.i(10695),i=a.i(32352),j=a.i(84948);a.i(28120);var k=a.i(98378),l=a.i(69839);a.i(75818);let m="__FAILPROOFAI_LOADING_HOOKS__",n=/policies\.(js|mjs|ts)$/,o=0,p=new Map;async function q(a){let b,c,d=Number.isFinite(c=Number(process.env.FAILPROOFAI_POLICY_LOAD_TIMEOUT_MS))&&c>0?c:1e4;try{await Promise.race([import(a),new Promise((a,c)=>{b=setTimeout(()=>c(Error(`timed out loading module after ${d}ms`)),d),b.unref?.()})])}finally{b&&clearTimeout(b)}}async function r(a,d){let e=globalThis;e[m]=!0;let g=[];try{let b=await (0,j.findDistIndex)(),e=b?(0,f.pathToFileURL)(b).href:null,h=++o,k=`${j.TMP_SUFFIX}.${process.pid}.${h}.${(0,c.randomUUID)()}.mjs`;g=await (0,j.rewriteFileTree)(a,e,b,k,d?.verifyEntrySha);let l=await s(g,k),m=p.get(a);if(m?.fingerprint===l){for(let a of m.hooks)i.customPolicies.add({...a});return null}let n=a+k,r=(0,f.pathToFileURL)(n).href,t=(0,i.getCustomHooks)().length;return await q(r),p.size>=500&&p.clear(),p.set(a,{fingerprint:l,hooks:(0,i.getCustomHooks)().slice(t).map(a=>({...a}))}),null}catch(f){let c=f instanceof Error?f.message:String(f),e=/Cannot find module|MODULE_NOT_FOUND|ENOENT/i.test(c)?"module_not_found":/SyntaxError|Unexpected token/i.test(c)?"syntax_error":/timed out loading module/i.test(c)?"load_timeout":"runtime_error";if((0,k.trackHookEvent)((0,l.getInstanceId)(),"custom_hooks_load_error",{error_type:e,is_convention:!!d?.conventionScope,convention_scope:d?.conventionScope??null,file_basename:(0,b.basename)(a)}),d?.strict)throw Error(`Failed to load custom hooks from ${a}: ${c}`);return(0,h.hookLogError)(`failed to load custom hooks from ${a}: ${c}`),{type:e,reason:c}}finally{e[m]=!1,await (0,j.cleanupTmpFiles)(g)}}async function s(a,b){let c=(0,g.createHash)("sha256");for(let d of[...a].sort()){c.update(d.replaceAll(b,j.TMP_SUFFIX));let a=await (0,e.readFile)(d,"utf8");c.update(a.replaceAll(b,j.TMP_SUFFIX))}return c.digest("hex")}async function t(a,c){if(!a)return[];let e=(0,b.isAbsolute)(a)?a:(0,b.resolve)(c?.sessionCwd??process.cwd(),a);if(!(0,d.existsSync)(e)){if(c?.strict)throw Error(`Custom hooks file not found: ${e}`);return(0,h.hookLogWarn)(`customPoliciesPath not found: ${e}`),[]}return(0,i.clearCustomHooks)(),await r(e,c),(0,i.getCustomHooks)()}a.s(["conventionPolicyId",0,function(a,b,c){return`convention:${a}:${b}:${c}`},"customPolicyId",0,function(a,b){return`custom:${a}:${b}`},"discoverPolicyFiles",0,function(a){if(!(0,d.existsSync)(a))return[];try{return(0,d.readdirSync)(a,{withFileTypes:!0}).filter(a=>a.isFile()&&n.test(a.name)).sort((a,b)=>a.name.localeCompare(b.name)).map(c=>(0,b.resolve)(a,c.name))}catch{return[]}},"loadCustomHooks",0,t])},32352,84948,a=>{"use strict";let b="__failproofai_custom_hooks__";function c(){let a=globalThis;return Array.isArray(a[b])||(a[b]=[]),a[b]}a.s(["clearCustomHooks",0,function(){globalThis[b]=[]},"customPolicies",0,{add(a){c().push(a)}},"getCustomHooks",0,function(){return c()}],32352);var d=a.i(24868),e=a.i(46786),f=a.i(14747),g=a.i(92509),h=a.i(54799),i=a.i(75818),j=a.i(10695);let k=".__failproofai_tmp__.mjs",l=/(?:import\s+(?:[\s\S]*?\s+from\s+)?|export\s+(?:[\s\S]*?\s+from\s+))(['"])(\.\.?\/[^'"]+)\1/g,m=/require\s*\(\s*(['"])(\.\.?\/[^'"]+)\1\s*\)/g;async function n(a){try{return await (0,d.access)(a),!0}catch{return!1}}async function o(){let a=process.env.FAILPROOFAI_DIST_PATH;if(a){let b=(0,f.resolve)(a,"index.js");if(await n(b))return b}for(let a of[(0,f.resolve)((0,f.dirname)(process.execPath),"..","assets","dist","index.js"),(0,f.resolve)(process.cwd(),"dist","index.js"),(0,f.resolve)(process.cwd(),"node_modules","failproofai","dist","index.js")])if(await n(a))return a;return null}async function p(a,b){let c=(0,f.resolve)(a,b);for(let a of[c,`${c}.js`,`${c}.mjs`,`${c}.ts`,(0,f.resolve)(c,"index.js")])if(await n(a))return a;return null}async function q(a,b,c,e){let g=(0,f.join)(a,b);return await (0,d.writeFile)(g,c,{encoding:"utf-8",mode:384,...e?{flag:"wx"}:{}}),g}async function r(a,b,c=k){let f=`import _cjs from '${b}';
2
+ export const customPolicies = _cjs.customPolicies;
3
+ export const getCustomHooks = _cjs.getCustomHooks;
4
+ export const clearCustomHooks = _cjs.clearCustomHooks;
5
+ export const allow = _cjs.allow;
6
+ export const deny = _cjs.deny;
7
+ export const instruct = _cjs.instruct;
8
+ export default _cjs;`,h=`failproofai-dist${c}.shim.mjs`;try{let a=(0,i.shimsDir)();await (0,d.mkdir)(a,{recursive:!0,mode:448});let b=await (0,d.lstat)(a),c="function"==typeof process.getuid?process.getuid():null;if(!b.isDirectory()||b.isSymbolicLink()||null!==c&&b.uid!==c||63&b.mode)throw Error(`${a} is not a private directory owned by this user`);let e=await q(a,h,f,!1);return{shimPath:e,shimUrl:(0,g.pathToFileURL)(e).href}}catch(a){(0,j.hookLogWarn)(`policy shim directory unusable (${a instanceof Error?a.message:String(a)}); falling back to ${(0,e.tmpdir)()}`)}let l=await q((0,e.tmpdir)(),h,f,!0);return{shimPath:l,shimUrl:(0,g.pathToFileURL)(l).href}}async function s(a,b,c,e=k,g){let i=[a],j=new Set,n=[],o=null;if(c&&b){let a=await r(c,b,e);n.push(a.shimPath),o=a.shimUrl}for(;i.length>0;){let b,k=i.shift();if(j.has(k))continue;if(j.add(k),g&&k===a){let a=await (0,d.readFile)(k),c=(0,h.createHash)("sha256").update(a).digest("hex");if(c!==g)throw Error(`cloud-managed policy failed integrity re-verification at load: expected ${g}, got ${c}`);b=a.toString("utf-8")}else b=await (0,d.readFile)(k,"utf-8");o&&(b=b.replace(/from\s+(['"])(?:claudeye|failproofai)\1/g,`from '${o}'`)),c&&(b=b.replace(/require\s*\(\s*(['"])(?:claudeye|failproofai)\1\s*\)/g,`require('${c.replace(/\\/g,"\\\\")}')`));let q=(0,f.dirname)(k),r=new Map;for(let a of[l,m]){let c,d=new RegExp(a.source,a.flags);for(;null!==(c=d.exec(b));){let a=c[2];if(r.has(a))continue;let b=await p(q,a);if(!b)continue;j.has(b)||i.includes(b)||i.push(b);let d=(0,f.relative)(q,b+e).split("\\").join("/");d.startsWith(".")||(d="./"+d),r.set(a,d)}}for(let a of[...r.keys()].sort((a,b)=>b.length-a.length)){let c=r.get(a),d=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");b=(b=b.replace(RegExp(`'${d}'`,"g"),`'${c}'`)).replace(RegExp(`"${d}"`,"g"),`"${c}"`)}let s=k+e;await (0,d.writeFile)(s,b,"utf-8"),n.push(s)}return n}async function t(a){for(let b of a)try{await (0,d.unlink)(b)}catch{}}a.s(["TMP_SUFFIX",0,k,"cleanupTmpFiles",0,t,"findDistIndex",0,o,"rewriteFileTree",0,s],84948)},98378,a=>{"use strict";var b=a.i(12072),c=a.i(79779),d=a.i(31920);let e=c.POSTHOG_API_KEY,f=new Set;async function g(a,d,f){let g=JSON.stringify({api_key:process.env.FAILPROOFAI_POSTHOG_KEY??e,event:d,distinct_id:a,properties:{...f,$lib:"failproofai-hooks",failproofai_version:b.version,product:c.POSTHOG_PRODUCT}});try{await fetch(process.env.FAILPROOFAI_POSTHOG_HOST?`${process.env.FAILPROOFAI_POSTHOG_HOST}/capture/`:"https://us.i.posthog.com/capture/",{method:"POST",headers:{"Content-Type":"application/json"},body:g,signal:AbortSignal.timeout(5e3)})}catch{}}async function h(a,b,c){if(!(0,d.isTelemetryEnabled)())return;let e=g(a,b,c);f.add(e),e.finally(()=>f.delete(e)),await e}a.s(["trackHookEvent",0,h])},28120,a=>{"use strict";var b=a.i(2157),c=a.i(50227),d=a.i(60526),e=a.i(10695),f=a.i(75818);function g(a){if(!(0,b.existsSync)(a))return{};try{let c=(0,b.readFileSync)(a,"utf8");return JSON.parse(c)}catch(b){return(0,e.hookLogWarn)(`failed to parse config at ${a}: ${b instanceof Error?b.message:String(b)}`),{}}}function h(a){let e=(0,d.homedir)(),f=(0,c.resolve)(a);for(;f!==e;){let a=(0,c.resolve)(f,".failproofai");try{if((0,b.statSync)(a).isDirectory())return f}catch{}let d=(0,c.dirname)(f);if(d===f)break;f=d}return(0,c.resolve)(a)}function i(){return(0,f.globalPolicyConfigFile)()}function j(a,b){switch(a){case"user":return(0,f.globalPolicyConfigFile)();case"project":return(0,c.resolve)(h(b??process.cwd()),".failproofai","policies-config.json");case"local":return(0,c.resolve)(h(b??process.cwd()),".failproofai","policies-config.local.json")}}a.s(["configuredCustomPolicyPaths",0,function(a){return a.customPoliciesPaths??(a.customPoliciesPath?[a.customPoliciesPath]:[])},"findProjectConfigDir",0,h,"readHooksConfig",0,function(){let a=i();if(!(0,b.existsSync)(a))return{enabledPolicies:[]};try{let c=(0,b.readFileSync)(a,"utf8");return JSON.parse(c)}catch(b){return(0,e.hookLogWarn)(`failed to parse config at ${a}: ${b instanceof Error?b.message:String(b)}`),{enabledPolicies:[]}}},"readMergedHooksConfig",0,function(a){let b=h(a??process.cwd()),d=(0,c.resolve)(b,".failproofai","policies-config.json"),e=(0,c.resolve)(b,".failproofai","policies-config.local.json"),i=(0,f.globalPolicyConfigFile)(),j=g(d),k=g(e),l=g(i),m=new Set([...j.enabledPolicies??[],...k.enabledPolicies??[],...l.enabledPolicies??[]]),n={};for(let a of[j,k,l])if(a.policyParams)for(let[b,c]of Object.entries(a.policyParams))b in n||(n[b]=c);let o=[j,k,l].map(a=>void 0!==a.customPoliciesPaths?a.customPoliciesPaths:void 0!==a.customPoliciesPath?[a.customPoliciesPath]:void 0).find(a=>void 0!==a),p=new Set([...j.disabledCustomPolicies??[],...k.disabledCustomPolicies??[],...l.disabledCustomPolicies??[]]),q=j.customPoliciesEnabled??k.customPoliciesEnabled??l.customPoliciesEnabled,r=j.llm??k.llm??l.llm;return{enabledPolicies:[...m],...Object.keys(n).length>0?{policyParams:n}:{},...void 0!==o?{customPoliciesPaths:o}:{},...p.size?{disabledCustomPolicies:[...p]}:{},...void 0!==q?{customPoliciesEnabled:q}:{},...void 0!==r?{llm:r}:{}}},"readScopedHooksConfig",0,function(a,c){let d=j(a,c);if(!(0,b.existsSync)(d))return{enabledPolicies:[]};try{let a=(0,b.readFileSync)(d,"utf8");return JSON.parse(a)}catch(a){return(0,e.hookLogWarn)(`failed to parse config at ${d}: ${a instanceof Error?a.message:String(a)}`),{enabledPolicies:[]}}},"writeHooksConfig",0,function(a){let d=i(),e=(0,c.dirname)(d);(0,b.existsSync)(e)||(0,b.mkdirSync)(e,{recursive:!0}),(0,b.writeFileSync)(d,JSON.stringify(a,null,2)+"\n","utf8")},"writeScopedHooksConfig",0,function(a,d,e){let f=j(d,e),g=(0,c.dirname)(f);(0,b.existsSync)(g)||(0,b.mkdirSync)(g,{recursive:!0}),(0,b.writeFileSync)(f,JSON.stringify(a,null,2)+"\n","utf8")}])}];
9
+
10
+ //# sourceMappingURL=src_hooks_1cv9_c4._.js.map