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.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +4 -4
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +14 -14
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/audit/invite/route.js +3 -2
- package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/run/route.js +4 -3
- package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js +2 -2
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js +4 -3
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js +4 -4
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js +4 -4
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +14 -14
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +13 -13
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +14 -14
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
- package/.next/standalone/.next/server/app/policies/page.js +4 -4
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -4
- package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[externals]__0-9ti7z._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[externals]__1lt47k4._.js → [externals]__0sg9-3p._.js} +1 -1
- package/.next/standalone/.next/server/chunks/[externals]__0u3wrvq._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__01eqny5._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1p8poxd._.js → [root-of-the-server]__0igxt32._.js} +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zlqo2t._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1anxb5k._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1le9jqc._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1p-qi2t._.js +5 -0
- package/.next/standalone/.next/server/chunks/_09dz7xv._.js +27 -0
- package/.next/standalone/.next/server/chunks/_0bs-v8p._.js +3 -0
- package/.next/standalone/.next/server/chunks/_0tovk6q._.js +3 -0
- package/.next/standalone/.next/server/chunks/_0trp3yc._.js +3 -0
- package/.next/standalone/.next/server/chunks/{_19uwam-._.js → _1-akg6w._.js} +2 -2
- package/.next/standalone/.next/server/chunks/_185gyk9._.js +3 -0
- package/.next/standalone/.next/server/chunks/_1ek68ln._.js +5 -7
- 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
- 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
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
- package/.next/standalone/.next/server/chunks/src_hooks_0iu54mz._.js +3 -0
- package/.next/standalone/.next/server/chunks/src_hooks_custom-hooks-loader_ts_0lnb3n3._.js +10 -0
- package/.next/standalone/.next/server/chunks/src_hooks_fp-home_ts_09kv0bn._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__013jr2b._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01wy8d-._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02npjtd._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0da85px._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ftmoxc._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0n_lxhg._.js +5 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0oa1lav._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0p-5p8u._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s740oi._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1p2otjt._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1yh7hlv._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0ehudfr._.js +23 -0
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1n2ywfz._.js → _1es2j7i._.js} +4 -4
- package/.next/standalone/.next/server/chunks/ssr/_1u8-lu2._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_1h33neq._.js → _1un1pug._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1zopuov._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +9 -9
- package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1cv9_c4._.js +10 -0
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_builtin-policies_ts_09j2ndl._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/middleware.js +1 -1
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +19 -19
- package/.next/standalone/.next/static/chunks/0nkpwjk01ei3t.js +1 -0
- package/.next/standalone/.next/static/chunks/{2iryw37qfqy5y.js → 0ofdelz65_517.js} +1 -1
- package/.next/standalone/.next/static/chunks/{34j7nmidlcuni.js → 12uhnpwgsmcev.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0i3a6wf-f_yky.js → 1_1eb_149xyt9.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3927pu4ss_l4k.js → 1tx9pnxyjrkoj.js} +1 -1
- package/.next/standalone/.next/static/chunks/{1n04wzsaes73g.js → 1x0jrl3a4_i2m.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3r0udrtpn78-e.js → 1zpv6omeln7al.js} +1 -1
- package/.next/standalone/.next/static/chunks/{416zumre3fvfw.js → 20hbg-r3io_ip.js} +1 -1
- package/.next/standalone/.next/static/chunks/{11a_m8yksthtf.js → 32bhi32ym8yrz.js} +2 -2
- package/.next/standalone/.next/static/chunks/{0u2ojcw25c_np.js → 3fr78ugeb4tjc.js} +1 -1
- package/.next/standalone/app/actions/get-hooks-config.ts +8 -1
- package/.next/standalone/app/actions/pack-actions.ts +12 -1
- package/.next/standalone/app/policies/hooks-client.tsx +41 -4
- package/.next/standalone/fp-cloud-cli/tests/test_pagination.py +204 -0
- package/.next/standalone/package.json +9 -9
- package/.next/standalone/server.js +1 -1
- package/README.md +58 -13
- package/bin/failproofai.mjs +10 -1
- package/dist/cli.mjs +22429 -21292
- package/dist/worker.mjs +1247 -540
- package/package.json +9 -9
- package/src/audit/index.ts +24 -4
- package/src/hooks/builtin-policies.ts +933 -8
- package/src/hooks/custom-hooks-loader.ts +98 -8
- package/src/hooks/handler.ts +26 -14
- package/src/hooks/manager.ts +36 -2
- package/src/hooks/pack-cli.ts +415 -42
- package/src/hooks/pack-failclosed.ts +100 -4
- package/src/hooks/pack-manifest.ts +29 -0
- package/src/hooks/pack-param-key.ts +36 -0
- package/src/hooks/pack-store.ts +101 -9
- package/src/hooks/policy-catalog.ts +9 -1
- package/src/hooks/policy-evaluator.ts +77 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__06cuf1y._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_usx0j._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0_zk340._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0jnjf2t._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0oy4kxb._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zf034w._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1tg4pu6._.js +0 -3
- package/.next/standalone/.next/server/chunks/_0lxbzdq._.js +0 -3
- package/.next/standalone/.next/server/chunks/_1zuiiy3._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0mgrjnx._.js +0 -10
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1-wzs7f._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1wlvpe5._.js +0 -5
- package/.next/standalone/.next/server/chunks/ssr/_0l7zv8b._.js +0 -23
- package/.next/standalone/.next/static/chunks/1ch5l9t2p16y4.js +0 -1
- /package/.next/standalone/.next/static/{NgD5HvuyPxwgrpeIiafJL → 5-xDMxcnrcXDFPQiy3yhg}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{NgD5HvuyPxwgrpeIiafJL → 5-xDMxcnrcXDFPQiy3yhg}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{NgD5HvuyPxwgrpeIiafJL → 5-xDMxcnrcXDFPQiy3yhg}/_ssgManifest.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,64245,e=>{"use strict";var t=e.i(43476),s=e.i(71645),r=e.i(74080),n=e.i(22016),o=e.i(89664),a=e.i(16327),l=e.i(56420);let i=(0,l.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);var c=e.i(8734);let d=(0,l.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"}]]),m=(0,l.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);var u=e.i(66794),x=e.i(82954),p=e.i(16306),h=e.i(84026),b=e.i(29407);let f=(0,l.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"}]]),g=(0,l.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 v=e.i(63676),j=e.i(73520),y=e.i(95187);let N=(0,y.createServerReference)("40d845904971e2c2447db0c7babcad414d256286da",y.callServer,void 0,y.findSourceMapURL,"getHookActivityAction");var k=e.i(36134);let w=(0,y.createServerReference)("00c43b8e7c113f31ebd7b3e020ccad0d6b00c5b016",y.callServer,void 0,y.findSourceMapURL,"getActivePausesAction");function S({pauses:e,now:r}){let[n,o]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{let e=setInterval(()=>o(Date.now()),3e4);return()=>clearInterval(e)},[]);let a=r??n,l=e.filter(e=>e.expiresAt>a);if(0===l.length)return null;let i=l.reduce((e,t)=>e.expiresAt<t.expiresAt?e:t);return(0,t.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,t.jsx)(p.ShieldAlert,{className:"h-4 w-4 shrink-0 text-amber-500 mt-0.5","aria-hidden":"true"}),(0,t.jsxs)("div",{className:"text-xs leading-relaxed",children:[(0,t.jsxs)("p",{className:"font-medium text-foreground",children:["Enforcement is paused for ",l.length," session",1===l.length?"":"s"," —"," ",function(e){if(e<=0)return"expiring now";if(e<6e4)return"under a minute";let t=Math.round(e/6e4);if(t<60)return`${t}m`;let s=Math.floor(t/60),r=t%60;return 0===r?`${s}h`:`${s}h${r}m`}(i.expiresAt-a)," left",l.length>1?" on the next to expire":"","."]}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-0.5",children:["Builtin, custom and convention policies are suspended for"," ",1===l.length?"that session":"those sessions","; cloud-managed policies keep enforcing. It lifts on its own — or run"," ",(0,t.jsx)("span",{className:"font-mono text-foreground",children:"failproofai config --resume"}),"."]})]})]})}function P(){return(0,t.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 C({item:e}){if(!e.pausedBy)return null;let s="number"==typeof e.pauseExpiresAt?new Date(e.pauseExpiresAt).toLocaleTimeString():null;return(0,t.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,t.jsx)(g,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,t.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-medium text-foreground",children:"Not enforced — paused."})," Enforcement was suspended for this session","cli"===e.pausedBy?" from the CLI":` by ${e.pausedBy}`,s?`, lifting at ${s}`:"",". Builtin, custom and convention policies did not run for this event; cloud-managed policies did."]})]})}let _=(0,y.createServerReference)("0045245821d5fa379ec4f6984839ad459f7fd31aa9",y.callServer,void 0,y.findSourceMapURL,"getHooksConfigAction"),T=(0,y.createServerReference)("60af7a14ec5e9d40867dd57a601864e996bcf688c4",y.callServer,void 0,y.findSourceMapURL,"toggleCustomPolicyAction"),U=(0,y.createServerReference)("0036b57b2077ecba95f0efc1287c0920346d09a6bb",y.callServer,void 0,y.findSourceMapURL,"addBundledPackWebAction"),I=(0,y.createServerReference)("60f4fbb247d558c4565ec43d90581ab578fadc7eac",y.callServer,void 0,y.findSourceMapURL,"addPackWebAction"),R=(0,y.createServerReference)("40c911afc62e67cac4f0775030ee93c7102476dc0d",y.callServer,void 0,y.findSourceMapURL,"previewPackWebAction"),$=(0,y.createServerReference)("406395da8dc847a3a7142e6b7e1f88b42800d311fc",y.callServer,void 0,y.findSourceMapURL,"removePackWebAction"),A=(0,y.createServerReference)("7061de6390bc26e79c569c9b09b6576846aa13e6e4",y.callServer,void 0,y.findSourceMapURL,"togglePackPolicyAction"),E=(0,y.createServerReference)("606697c0d76e6337755a33f897c61448242e46e0ed",y.callServer,void 0,y.findSourceMapURL,"installHooksWebAction"),L=(0,y.createServerReference)("609850fd7f3ff102f3165256c7fc4b4433d67fa89f",y.callServer,void 0,y.findSourceMapURL,"removeHooksWebAction"),M=(0,y.createServerReference)("606efc2d5df43e5a1df1cba1ca69d025db75413928",y.callServer,void 0,y.findSourceMapURL,"updatePolicyParamsAction");var B=e.i(85881),F=e.i(12344),z=e.i(80060),D=e.i(2711),W=e.i(24578);let H={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 O=e.i(34713),q=e.i(67881);function X({sessionId:e,transcriptPath:s,integration:r,cwd:o}){if(!e)return(0,t.jsx)("span",{className:"text-muted-foreground",children:"\\u2014"});let a=e?e.slice(0,8):"—",l="codex"===r||(s?.includes("/.codex/")??!1),i="copilot"===r||(s?.includes("/.copilot/session-state/")??!1),c="cursor"===r||(s?.includes("/.cursor/")??!1),d="opencode"===r||(s?.includes("/.local/share/opencode/")??!1)||(s?.includes("/.opencode/")??!1),m="pi"===r||(s?.includes("/.pi/")??!1);if(l||i||c||d||m){let s,r=o?(s=/^([A-Za-z]):[\\/](.*)$/.exec(o))?s[1]+"--"+s[2].replace(/[\\/]/g,"-"):o.replace(/[\\/]/g,"-"):l?"codex":i?"copilot":c?"cursor":d?"opencode":"pi";return(0,t.jsx)(n.default,{href:`/project/${encodeURIComponent(r)}/session/${encodeURIComponent(e)}`,className:"text-primary hover:underline font-mono",onClick:e=>e.stopPropagation(),children:a})}let u=s?function(e){let t=e.replace(/\\/g,"/").split("/").filter(Boolean);if(t.length<2)return null;let s=t[t.length-2];return!s||s.startsWith(".")?null:s}(s):null;return u?(0,t.jsx)(n.default,{href:`/project/${encodeURIComponent(u)}/session/${encodeURIComponent(e)}`,className:"text-primary hover:underline font-mono",onClick:e=>e.stopPropagation(),children:a}):(0,t.jsx)("span",{className:"text-muted-foreground font-mono",children:a})}function K({decision:e}){return"deny"===e?(0,t.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,t.jsx)(b.ShieldX,{className:"h-3 w-3"}),"Deny"]}):"instruct"===e?(0,t.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,t.jsx)(p.ShieldAlert,{className:"h-3 w-3"}),"Instruct"]}):(0,t.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,t.jsx)(h.ShieldCheck,{className:"h-3 w-3"}),"Allow"]})}function V({eventType:e}){return(0,t.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:e})}function J({integration:e}){if(!e)return null;let s=(0,W.getCliLabel)(e),r=(0,W.getCliBadgeClasses)(e);return(0,t.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${r}`,title:`Agent CLI: ${s}`,children:s})}function G({mode:e}){let s="default"===e;return(0,t.jsx)("span",{title:e,className:`inline-block max-w-full truncate rounded px-1.5 py-0.5 align-middle text-[0.6rem] font-medium border ${s?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:e})}function Z({ms:e}){return(0,t.jsx)("span",{className:`font-mono text-[0.7rem] ${e>500?"text-red-400":e>100?"text-amber-400":"text-muted-foreground"}`,children:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`})}function Q({text:e,field:r}){let[n,a]=(0,s.useState)(!1),{capture:l}=(0,F.usePostHog)(),i=async t=>{t.stopPropagation(),l("activity_copy_clicked",{field:r??"unknown"});try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),1500)}catch{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),a(!0),setTimeout(()=>a(!1),1500)}};return(0,t.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:n?(0,t.jsx)(o.Check,{className:"h-3 w-3 text-emerald-400"}):(0,t.jsx)(c.Copy,{className:"h-3 w-3"})})}function Y({value:e,onChange:s}){return(0,t.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(r=>(0,t.jsx)("button",{onClick:()=>s(r.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${e===r.value?"deny"===r.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===r.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===r.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r.label},r.value))})}function ee({stats:e}){let s=e.totalEvents>0?e.denyCount/e.totalEvents*100:0,r=s.toFixed(s>=10?0:1),n=0===e.denyCount?"":s>=5?" is-deny":s>=2?" is-warn":"";return(0,t.jsxs)("div",{className:"stat-bar",role:"group","aria-label":"Activity stats",children:[(0,t.jsxs)("div",{className:"stat-cell",children:[(0,t.jsx)("span",{className:"eyebrow",children:"total events"}),(0,t.jsx)("span",{className:"value",children:e.totalEvents.toLocaleString()}),(0,t.jsx)("span",{className:"meta",children:"across all installed agents"})]}),(0,t.jsxs)("div",{className:"stat-cell",children:[(0,t.jsx)("span",{className:"eyebrow",children:"deny rate"}),(0,t.jsxs)("span",{className:`value${n}`,children:[r,"%"]}),(0,t.jsxs)("span",{className:"meta",children:[e.denyCount.toLocaleString()," of ",e.totalEvents.toLocaleString()," denied"]})]}),(0,t.jsxs)("div",{className:"stat-cell",children:[(0,t.jsx)("span",{className:"eyebrow",children:"top policy"}),(0,t.jsx)("span",{className:"value",style:{fontSize:16,fontWeight:500,color:e.topPolicy?"var(--accent-pink)":"var(--dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.topPolicy??void 0,children:e.topPolicy??"—"}),(0,t.jsx)("span",{className:"meta",children:"most-evaluated policy in scope"})]})]})}function et({item:e}){if("observe"!==function(e,t){if(!e||!t)return;let s=H[e];if(s)return s[t]}(e.integration,e.eventType))return null;let s=e.matchedPolicies??[];if(0===s.length)return null;let r=e.integration?(0,W.getCliLabel)(e.integration):"This CLI",n=s.map(e=>e.replace(/^(custom|\.failproofai-(project|user))\//,"")),o=1===n.length?n[0]:`${n.length} policies`,a="deny"===e.decision;return(0,t.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,t.jsx)(g,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,t.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-medium text-foreground",children:a?"Not enforced.":"Ran, but cannot enforce here."})," ",(0,t.jsx)("span",{className:"font-mono",children:o})," ran on"," ",(0,t.jsx)("span",{className:"font-mono",children:e.eventType}),", but ",r," discards hook verdicts for this event",a?" — the action went ahead anyway.":", so a policy cannot block here."," ","Move the check to an event ",r," enforces on, such as"," ",(0,t.jsx)("span",{className:"font-mono",children:"PreToolUse"}),"."]})]})}function es({item:e}){return(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:11,className:"px-0 py-0",children:(0,t.jsxs)("div",{className:"activity-detail animate-expand text-xs",children:[(0,t.jsxs)("span",{className:"activity-detail-eyebrow",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"▾"}),"event detail"]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-2",children:[(0,t.jsx)(C,{item:e}),(0,t.jsx)(et,{item:e}),e.policySource&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Decided by: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:"cloud"===e.policySource&&e.cloudPolicyId?`cloud \xb7 ${e.cloudPolicyId} version ${e.cloudVersion}`:e.policySource})]}),void 0!==e.cloudDeployment&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Cloud deployment: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.cloudDeployment})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.sessionId??"—"}),e.sessionId&&(0,t.jsx)(Q,{text:e.sessionId,field:"session_id"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.cwd??"—"}),e.cwd&&(0,t.jsx)(Q,{text:e.cwd,field:"cwd"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,t.jsx)("span",{className:"font-mono text-foreground break-all",children:e.transcriptPath??"—"}),e.transcriptPath?.startsWith("opencode-db://")&&(0,t.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),e.policyNames&&e.policyNames.length>1&&(0,t.jsxs)("div",{style:{marginTop:8},children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.policyNames.join(", ")})]}),e.reason&&(0,t.jsxs)("div",{style:{marginTop:8},children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,t.jsx)("span",{className:"text-foreground",children:e.reason})]})]})})})}function er({hooksInstalled:e,onSwitchTab:r}){let{intervalSec:n}=(0,B.useAutoRefresh)(),{capture:o}=(0,F.usePostHog)(),l=(0,z.useUrlParams)(),i=(0,s.useRef)(!1),[c,d]=(0,s.useState)(()=>(0,D.paramToPage)(l.get("page"))),[m,u]=(0,s.useState)(null),[p,h]=(0,s.useState)([]),[b,f]=(0,s.useState)(null),[g,v]=(0,s.useState)(()=>{let e=l.get("decision");return"allow"===e||"deny"===e||"instruct"===e?e:""}),[y,C]=(0,s.useState)(()=>l.get("event")??""),[_,T]=(0,s.useState)(()=>l.get("policy")??""),[U,I]=(0,s.useState)(()=>l.get("session")??""),[R,$]=(0,s.useState)(()=>{let e=l.get("cli");return(0,W.isKnownCli)(e)?e:""}),[A,E]=(0,s.useState)(()=>{let e=l.get("source");return"custom"===e||"convention"===e||"cloud"===e||"pack"===e?e:""}),L=(0,s.useRef)(null),M=(0,s.useRef)(!0),H=(0,s.useRef)({filterDecision:g,filterEventType:y,filterPolicy:_,filterSessionId:U,filterCli:R,filterSource:A});H.current={filterDecision:g,filterEventType:y,filterPolicy:_,filterSessionId:U,filterCli:R,filterSource:A},(0,s.useEffect)(()=>{if(!i.current){i.current=!0;return}l.setAll({decision:g||void 0,event:y||void 0,policy:_||void 0,session:U||void 0,cli:R||void 0,source:A||void 0,page:(0,D.pageToParam)(c)})},[g,y,_,U,R,A,c]);let q=""!==g||""!==y||""!==_||""!==U||""!==R||""!==A,Q=(0,s.useCallback)(async e=>{try{let t,{filterDecision:s,filterEventType:r,filterPolicy:n,filterSessionId:o,filterCli:a,filterSource:l}=H.current;t=""!==s||""!==r||""!==n||""!==o||""!==a||""!==l?await (0,k.searchHookActivityAction)({decision:s||void 0,eventType:r||void 0,policyName:n||void 0,sessionId:o||void 0,integration:a||void 0,source:l||void 0},e):await N(e),u(t)}catch{}},[]);(0,s.useEffect)(()=>{Q(c);let e=setInterval(()=>Q(c),n>0?1e3*n:5e3);return()=>clearInterval(e)},[c,Q,n]),(0,s.useEffect)(()=>{let e=!1,t=()=>{w().then(t=>{e||h(t)}).catch(()=>{})};t();let s=setInterval(t,n>0?1e3*n:5e3);return()=>{e=!0,clearInterval(s)}},[n]),(0,s.useEffect)(()=>(L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{if(d(1),f(null),Q(1),M.current){M.current=!1;return}o("activity_filter_changed",{active_filter_count:+(""!==g)+ +(""!==y)+ +(""!==_)+ +(""!==U)+ +(""!==R),has_decision:""!==g,has_event_type:""!==y,has_policy:""!==_,has_session:""!==U,has_cli:""!==R,decision:g||null,event_type:y||null,cli:R||null})},300),()=>{L.current&&clearTimeout(L.current)}),[g,y,_,U,R]);let et=m?.entries??[],en=m?.totalPages??1;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(S,{pauses:p}),m?.stats&&m.stats.totalEvents>0&&(0,t.jsx)("div",{style:{marginBottom:18},children:(0,t.jsx)(ee,{stats:m.stats})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"filter-bar",children:[(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"decision"}),(0,t.jsx)(Y,{value:g,onChange:v})]}),(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"event"}),(0,t.jsxs)("select",{value:y,onChange:e=>C(e.target.value),className:"filter-input",children:[(0,t.jsx)("option",{value:"",children:"all events"}),(0,t.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,t.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,t.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,t.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,t.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,t.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]})]}),(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"source"}),(0,t.jsxs)("select",{value:A,onChange:e=>{let t=e.target.value;E("custom"===t||"convention"===t||"cloud"===t||"pack"===t?t:"")},className:"filter-input","aria-label":"Filter by policy source",children:[(0,t.jsx)("option",{value:"",children:"all sources"}),(0,t.jsx)("option",{value:"custom",children:"custom"}),(0,t.jsx)("option",{value:"convention",children:"convention"}),(0,t.jsx)("option",{value:"cloud",children:"cloud"}),(0,t.jsx)("option",{value:"pack",children:"pack"})]})]}),(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"cli"}),(0,t.jsxs)("select",{value:R,onChange:e=>{let t=e.target.value;$(""===t||(0,W.isKnownCli)(t)?t:"")},className:"filter-input","aria-label":"Filter by CLI",children:[(0,t.jsx)("option",{value:"",children:"all clis"}),W.KNOWN_CLI_IDS.map(e=>(0,t.jsx)("option",{value:e,children:(0,W.getCliLabel)(e)},e))]})]}),(0,t.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,t.jsx)("span",{className:"filter-label",children:"policy"}),(0,t.jsx)("input",{type:"text",value:_,onChange:e=>T(e.target.value),placeholder:"filter by policy…",className:"filter-input"})]}),(0,t.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,t.jsx)("span",{className:"filter-label",children:"session"}),(0,t.jsx)("input",{type:"text",value:U,onChange:e=>I(e.target.value),placeholder:"filter by session…",className:"filter-input"})]}),q&&(0,t.jsx)("button",{type:"button",className:"filter-clear",onClick:()=>{v(""),C(""),$(""),T(""),I(""),E("")},"aria-label":"Clear all filters",children:"[ clear ]"})]}),0===et.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,t.jsx)(x.Shield,{className:"h-12 w-12 text-muted-foreground/30"}),!1===e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-4 font-medium",children:"Policies are not installed"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:["Go to the"," ",(0,t.jsx)("button",{className:"underline hover:text-foreground transition-colors",onClick:()=>r?.("policies"),children:"Policies tab"})," ","and click ",(0,t.jsx)("span",{className:"font-mono bg-muted px-1 rounded",children:"Install"})," to enable policy monitoring."]})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-4",children:q?"No matching activity.":"Waiting for hook events…"})]}):(0,t.jsx)("div",{className:"overflow-x-auto activity-table-wrap",children:(0,t.jsxs)("table",{className:"w-full text-xs activity-table",style:{tableLayout:"fixed"},children:[(0,t.jsxs)("colgroup",{children:[(0,t.jsx)("col",{style:{width:32}}),(0,t.jsx)("col",{style:{width:"7%"}}),(0,t.jsx)("col",{style:{width:"9%"}}),(0,t.jsx)("col",{style:{width:"12%"}}),(0,t.jsx)("col",{style:{width:"11%"}}),(0,t.jsx)("col",{style:{width:"9%"}}),(0,t.jsx)("col",{style:{width:"13%"}}),(0,t.jsx)("col",{style:{width:"12%"}}),(0,t.jsx)("col",{style:{width:"11%"}}),(0,t.jsx)("col",{style:{width:"8%"}}),(0,t.jsx)("col",{style:{width:"8%"}})]}),(0,t.jsx)("thead",{className:"activity-thead",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"px-4 py-3"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Time"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Decision"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Event"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"CLI"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Tool"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Policy"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Reason"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Mode"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Duration"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Session"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border/30",children:et.map((e,r)=>{let n="deny"===e.decision,l=b===r,i="instruct"===e.decision;return(0,t.jsxs)(s.Fragment,{children:[(0,t.jsxs)("tr",{onClick:()=>{f(e=>{let t=e===r?null:r,s=et[r];return o("activity_row_toggled",{expanded:null!==t,decision:s?.decision??null,policy_name:s?.policyName??null,event_type:s?.eventType??null}),t})},className:`activity-data-row cursor-pointer transition-colors ${n?"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":r%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${l?"bg-muted/20":""}`,children:[(0,t.jsx)("td",{className:"px-4 py-2",children:(0,t.jsx)(a.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${l?"rotate-0":"-rotate-90"}`})}),(0,t.jsx)("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",title:new Date(e.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(0,O.formatRelativeTime)(e.timestamp)}),(0,t.jsxs)("td",{className:"px-3 py-2",children:[(0,t.jsx)(K,{decision:e.decision}),e.pausedBy&&(0,t.jsx)(P,{})]}),(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)(V,{eventType:e.eventType})}),(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)(J,{integration:e.integration})}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:e.toolName??"—"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:e.policyNames&&e.policyNames.length>1?(0,t.jsxs)("span",{title:e.policyNames.join(", "),children:[e.policyNames[0],(0,t.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",e.policyNames.length-1]})]}):e.policyName??"—"}),(0,t.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate",title:e.reason??"",children:e.reason??"—"}),(0,t.jsx)("td",{className:"px-3 py-2",children:e.permissionMode?(0,t.jsx)(G,{mode:e.permissionMode}):"—"}),(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)(Z,{ms:e.durationMs})}),(0,t.jsx)("td",{className:"px-3 py-2",title:e.sessionId??"",children:(0,t.jsx)(X,{sessionId:e.sessionId,transcriptPath:e.transcriptPath,integration:e.integration,cwd:e.cwd})})]}),l&&(0,t.jsx)(es,{item:e})]},`${e.timestamp}-${r}`)})})]})}),(0,t.jsx)(j.default,{currentPage:c,totalPages:en,onPageChange:e=>{o("activity_pagination_changed",{from_page:c,to_page:e,total_pages:en}),d(e),f(null)}})]})]})}function en({enabled:e,onChange:s,disabled:r}){return(0,t.jsx)("button",{onClick:s,disabled:r,className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors disabled:opacity-40 ${e?"bg-emerald-500":"bg-muted-foreground/30"}`,"aria-label":e?"Disable policy":"Enable policy",children:(0,t.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform ${e?"translate-x-3.5":"translate-x-0.5"}`})})}function eo({policy:e,onClose:r,onSave:n}){let o=e.params??{},a=e.currentParams??{},[l,i]=(0,s.useState)(()=>{let e={};for(let[t,s]of Object.entries(o)){let r=t in a?a[t]:s.default;e[t]=r}return e});(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]);let c=(e,t)=>{i(s=>({...s,[e]:t}))};return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:e=>{e.target===e.currentTarget&&r()},children:(0,t.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,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-mono font-semibold text-foreground",children:e.name}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.description})]}),(0,t.jsx)("button",{onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,t.jsx)(v.X,{className:"h-4 w-4"})})]}),(0,t.jsx)("div",{className:"overflow-y-auto flex-1 px-4 py-4 space-y-4",children:Object.entries(o).map(([e,s])=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1 font-mono",children:e}),(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground mb-1.5",children:s.description}),((e,s)=>{let r=l[e];if("boolean"===s.type)return(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:!!r,onChange:t=>c(e,t.target.checked),className:"rounded border-border"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:s.description})]});if("number"===s.type)return(0,t.jsx)("input",{type:"number",value:"number"==typeof r?r:"",onChange:t=>c(e,Number(t.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[]"===s.type){let s=Array.isArray(r)?r.join("\n"):"";return(0,t.jsx)("textarea",{value:s,onChange:t=>c(e,t.target.value.split("\n").filter(e=>""!==e.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[]"===s.type){let s=Array.isArray(r)?r:[];return(0,t.jsxs)("div",{className:"space-y-1.5",children:[s.map((r,n)=>(0,t.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,t.jsx)("input",{type:"text",value:r.regex,onChange:t=>{let r=[...s];r[n]={...r[n],regex:t.target.value},c(e,r)},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,t.jsx)("input",{type:"text",value:r.label,onChange:t=>{let r=[...s];r[n]={...r[n],label:t.target.value},c(e,r)},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,t.jsx)("button",{onClick:()=>c(e,s.filter((e,t)=>t!==n)),className:"text-muted-foreground/50 hover:text-destructive transition-colors",children:(0,t.jsx)(v.X,{className:"h-3.5 w-3.5"})})]},n)),(0,t.jsx)("button",{onClick:()=>c(e,[...s,{regex:"",label:""}]),className:"text-xs text-primary hover:underline",children:"+ Add pattern"})]})}return(0,t.jsx)("input",{type:"text",value:"string"==typeof r?r:"",onChange:t=>c(e,t.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"})})(e,s)]},e))}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,t.jsx)(q.Button,{variant:"outline",size:"sm",onClick:r,className:"h-7 text-xs",children:"Cancel"}),(0,t.jsx)(q.Button,{size:"sm",onClick:()=>n(l),className:"h-7 text-xs",children:"Save"})]})]})})}function ea({message:e,onDismiss:s,onInstall:n,isPending:o}){let{capture:a}=(0,F.usePostHog)();return(0,r.createPortal)((0,t.jsxs)("div",{className:"fixed top-4 right-4 z-[9999] w-full max-w-sm",style:{animation:"slideInFromRight 0.25s ease-out"},children:[(0,t.jsx)("style",{children:`
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,64245,e=>{"use strict";var t=e.i(43476),s=e.i(71645),r=e.i(74080),n=e.i(22016),a=e.i(89664),o=e.i(16327),l=e.i(56420);let i=(0,l.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);var c=e.i(8734);let d=(0,l.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"}]]),m=(0,l.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);var u=e.i(66794),p=e.i(82954),x=e.i(16306),h=e.i(84026),b=e.i(29407);let f=(0,l.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"}]]),g=(0,l.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 v=e.i(63676),j=e.i(73520),y=e.i(95187);let N=(0,y.createServerReference)("403b20a4869750d09a473954af76f127b1bcf868c6",y.callServer,void 0,y.findSourceMapURL,"getHookActivityAction");var k=e.i(32828);let w=(0,y.createServerReference)("008708709e55a7563e038b0d2f851db312a7c35fb4",y.callServer,void 0,y.findSourceMapURL,"getActivePausesAction");function S({pauses:e,now:r}){let[n,a]=(0,s.useState)(()=>Date.now());(0,s.useEffect)(()=>{let e=setInterval(()=>a(Date.now()),3e4);return()=>clearInterval(e)},[]);let o=r??n,l=e.filter(e=>e.expiresAt>o);if(0===l.length)return null;let i=l.reduce((e,t)=>e.expiresAt<t.expiresAt?e:t);return(0,t.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,t.jsx)(x.ShieldAlert,{className:"h-4 w-4 shrink-0 text-amber-500 mt-0.5","aria-hidden":"true"}),(0,t.jsxs)("div",{className:"text-xs leading-relaxed",children:[(0,t.jsxs)("p",{className:"font-medium text-foreground",children:["Enforcement is paused for ",l.length," session",1===l.length?"":"s"," —"," ",function(e){if(e<=0)return"expiring now";if(e<6e4)return"under a minute";let t=Math.round(e/6e4);if(t<60)return`${t}m`;let s=Math.floor(t/60),r=t%60;return 0===r?`${s}h`:`${s}h${r}m`}(i.expiresAt-o)," left",l.length>1?" on the next to expire":"","."]}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-0.5",children:["Builtin, custom and convention policies are suspended for"," ",1===l.length?"that session":"those sessions","; cloud-managed policies keep enforcing. It lifts on its own — or run"," ",(0,t.jsx)("span",{className:"font-mono text-foreground",children:"failproofai config --resume"}),"."]})]})]})}function P(){return(0,t.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 C({item:e}){if(!e.pausedBy)return null;let s="number"==typeof e.pauseExpiresAt?new Date(e.pauseExpiresAt).toLocaleTimeString():null;return(0,t.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,t.jsx)(g,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,t.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-medium text-foreground",children:"Not enforced — paused."})," Enforcement was suspended for this session","cli"===e.pausedBy?" from the CLI":` by ${e.pausedBy}`,s?`, lifting at ${s}`:"",". Builtin, custom and convention policies did not run for this event; cloud-managed policies did."]})]})}let _=(0,y.createServerReference)("00d55eca2c530ee167dc8bfae59edfb632c949f94c",y.callServer,void 0,y.findSourceMapURL,"getHooksConfigAction"),T=(0,y.createServerReference)("607dc07af2fa5dbd0794565f0271bd9a148bde88f8",y.callServer,void 0,y.findSourceMapURL,"toggleCustomPolicyAction"),U=(0,y.createServerReference)("004a956ee569aecbe4f8c22a2e2219bfb699bb1076",y.callServer,void 0,y.findSourceMapURL,"addBundledPackWebAction"),I=(0,y.createServerReference)("60527de16160bf47bae463c54299c65dd3754bcdaa",y.callServer,void 0,y.findSourceMapURL,"addPackWebAction"),R=(0,y.createServerReference)("40aa5c5f859d152d56d662b4ff52630494f178ef54",y.callServer,void 0,y.findSourceMapURL,"previewPackWebAction"),$=(0,y.createServerReference)("40e10932309e736311f25b278a8dc7e00e9805cf49",y.callServer,void 0,y.findSourceMapURL,"removePackWebAction"),A=(0,y.createServerReference)("704faed3414c1e47c0f6c2a75ec52aa5c8b4021992",y.callServer,void 0,y.findSourceMapURL,"togglePackPolicyAction"),E=(0,y.createServerReference)("60d7e6ec234c2f9dd135c187fde82138fe9cff6608",y.callServer,void 0,y.findSourceMapURL,"installHooksWebAction"),L=(0,y.createServerReference)("603307051c148c1ad888f6d8977ac928f8f3239d4c",y.callServer,void 0,y.findSourceMapURL,"removeHooksWebAction"),M=(0,y.createServerReference)("60b48ba21e36e522f8b8df30a87f945cb21fe5fd7a",y.callServer,void 0,y.findSourceMapURL,"updatePolicyParamsAction");var B=e.i(85881),F=e.i(12344),z=e.i(80060),D=e.i(2711),W=e.i(24578);let H={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 O=e.i(34713),q=e.i(67881);function X({sessionId:e,transcriptPath:s,integration:r,cwd:a}){if(!e)return(0,t.jsx)("span",{className:"text-muted-foreground",children:"\\u2014"});let o=e?e.slice(0,8):"—",l="codex"===r||(s?.includes("/.codex/")??!1),i="copilot"===r||(s?.includes("/.copilot/session-state/")??!1),c="cursor"===r||(s?.includes("/.cursor/")??!1),d="opencode"===r||(s?.includes("/.local/share/opencode/")??!1)||(s?.includes("/.opencode/")??!1),m="pi"===r||(s?.includes("/.pi/")??!1);if(l||i||c||d||m){let s,r=a?(s=/^([A-Za-z]):[\\/](.*)$/.exec(a))?s[1]+"--"+s[2].replace(/[\\/]/g,"-"):a.replace(/[\\/]/g,"-"):l?"codex":i?"copilot":c?"cursor":d?"opencode":"pi";return(0,t.jsx)(n.default,{href:`/project/${encodeURIComponent(r)}/session/${encodeURIComponent(e)}`,className:"text-primary hover:underline font-mono",onClick:e=>e.stopPropagation(),children:o})}let u=s?function(e){let t=e.replace(/\\/g,"/").split("/").filter(Boolean);if(t.length<2)return null;let s=t[t.length-2];return!s||s.startsWith(".")?null:s}(s):null;return u?(0,t.jsx)(n.default,{href:`/project/${encodeURIComponent(u)}/session/${encodeURIComponent(e)}`,className:"text-primary hover:underline font-mono",onClick:e=>e.stopPropagation(),children:o}):(0,t.jsx)("span",{className:"text-muted-foreground font-mono",children:o})}function K({decision:e}){return"deny"===e?(0,t.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,t.jsx)(b.ShieldX,{className:"h-3 w-3"}),"Deny"]}):"instruct"===e?(0,t.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,t.jsx)(x.ShieldAlert,{className:"h-3 w-3"}),"Instruct"]}):(0,t.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,t.jsx)(h.ShieldCheck,{className:"h-3 w-3"}),"Allow"]})}function V({eventType:e}){return(0,t.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:e})}function J({integration:e}){if(!e)return null;let s=(0,W.getCliLabel)(e),r=(0,W.getCliBadgeClasses)(e);return(0,t.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${r}`,title:`Agent CLI: ${s}`,children:s})}function G({mode:e}){let s="default"===e;return(0,t.jsx)("span",{title:e,className:`inline-block max-w-full truncate rounded px-1.5 py-0.5 align-middle text-[0.6rem] font-medium border ${s?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:e})}function Z({ms:e}){return(0,t.jsx)("span",{className:`font-mono text-[0.7rem] ${e>500?"text-red-400":e>100?"text-amber-400":"text-muted-foreground"}`,children:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`})}function Q({text:e,field:r}){let[n,o]=(0,s.useState)(!1),{capture:l}=(0,F.usePostHog)(),i=async t=>{t.stopPropagation(),l("activity_copy_clicked",{field:r??"unknown"});try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1500)}catch{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),o(!0),setTimeout(()=>o(!1),1500)}};return(0,t.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:n?(0,t.jsx)(a.Check,{className:"h-3 w-3 text-emerald-400"}):(0,t.jsx)(c.Copy,{className:"h-3 w-3"})})}function Y({value:e,onChange:s}){return(0,t.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(r=>(0,t.jsx)("button",{onClick:()=>s(r.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${e===r.value?"deny"===r.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===r.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===r.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:r.label},r.value))})}function ee({stats:e}){let s=e.totalEvents>0?e.denyCount/e.totalEvents*100:0,r=s.toFixed(s>=10?0:1),n=0===e.denyCount?"":s>=5?" is-deny":s>=2?" is-warn":"";return(0,t.jsxs)("div",{className:"stat-bar",role:"group","aria-label":"Activity stats",children:[(0,t.jsxs)("div",{className:"stat-cell",children:[(0,t.jsx)("span",{className:"eyebrow",children:"total events"}),(0,t.jsx)("span",{className:"value",children:e.totalEvents.toLocaleString()}),(0,t.jsx)("span",{className:"meta",children:"across all installed agents"})]}),(0,t.jsxs)("div",{className:"stat-cell",children:[(0,t.jsx)("span",{className:"eyebrow",children:"deny rate"}),(0,t.jsxs)("span",{className:`value${n}`,children:[r,"%"]}),(0,t.jsxs)("span",{className:"meta",children:[e.denyCount.toLocaleString()," of ",e.totalEvents.toLocaleString()," denied"]})]}),(0,t.jsxs)("div",{className:"stat-cell",children:[(0,t.jsx)("span",{className:"eyebrow",children:"top policy"}),(0,t.jsx)("span",{className:"value",style:{fontSize:16,fontWeight:500,color:e.topPolicy?"var(--accent-pink)":"var(--dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.topPolicy??void 0,children:e.topPolicy??"—"}),(0,t.jsx)("span",{className:"meta",children:"most-evaluated policy in scope"})]})]})}function et({item:e}){if("observe"!==function(e,t){if(!e||!t)return;let s=H[e];if(s)return s[t]}(e.integration,e.eventType))return null;let s=e.matchedPolicies??[];if(0===s.length)return null;let r=e.integration?(0,W.getCliLabel)(e.integration):"This CLI",n=s.map(e=>e.replace(/^(custom|\.failproofai-(project|user))\//,"")),a=1===n.length?n[0]:`${n.length} policies`,o="deny"===e.decision;return(0,t.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,t.jsx)(g,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,t.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-medium text-foreground",children:o?"Not enforced.":"Ran, but cannot enforce here."})," ",(0,t.jsx)("span",{className:"font-mono",children:a})," ran on"," ",(0,t.jsx)("span",{className:"font-mono",children:e.eventType}),", but ",r," discards hook verdicts for this event",o?" — the action went ahead anyway.":", so a policy cannot block here."," ","Move the check to an event ",r," enforces on, such as"," ",(0,t.jsx)("span",{className:"font-mono",children:"PreToolUse"}),"."]})]})}function es({item:e}){return(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:11,className:"px-0 py-0",children:(0,t.jsxs)("div",{className:"activity-detail animate-expand text-xs",children:[(0,t.jsxs)("span",{className:"activity-detail-eyebrow",children:[(0,t.jsx)("span",{"aria-hidden":"true",children:"▾"}),"event detail"]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-2",children:[(0,t.jsx)(C,{item:e}),(0,t.jsx)(et,{item:e}),e.policySource&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Decided by: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:"cloud"===e.policySource&&e.cloudPolicyId?`cloud \xb7 ${e.cloudPolicyId} version ${e.cloudVersion}`:e.policySource})]}),void 0!==e.cloudDeployment&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Cloud deployment: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.cloudDeployment})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.sessionId??"—"}),e.sessionId&&(0,t.jsx)(Q,{text:e.sessionId,field:"session_id"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.cwd??"—"}),e.cwd&&(0,t.jsx)(Q,{text:e.cwd,field:"cwd"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,t.jsx)("span",{className:"font-mono text-foreground break-all",children:e.transcriptPath??"—"}),e.transcriptPath?.startsWith("opencode-db://")&&(0,t.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),e.policyNames&&e.policyNames.length>1&&(0,t.jsxs)("div",{style:{marginTop:8},children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:e.policyNames.join(", ")})]}),e.reason&&(0,t.jsxs)("div",{style:{marginTop:8},children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,t.jsx)("span",{className:"text-foreground",children:e.reason})]})]})})})}function er({hooksInstalled:e,onSwitchTab:r}){let{intervalSec:n}=(0,B.useAutoRefresh)(),{capture:a}=(0,F.usePostHog)(),l=(0,z.useUrlParams)(),i=(0,s.useRef)(!1),[c,d]=(0,s.useState)(()=>(0,D.paramToPage)(l.get("page"))),[m,u]=(0,s.useState)(null),[x,h]=(0,s.useState)([]),[b,f]=(0,s.useState)(null),[g,v]=(0,s.useState)(()=>{let e=l.get("decision");return"allow"===e||"deny"===e||"instruct"===e?e:""}),[y,C]=(0,s.useState)(()=>l.get("event")??""),[_,T]=(0,s.useState)(()=>l.get("policy")??""),[U,I]=(0,s.useState)(()=>l.get("session")??""),[R,$]=(0,s.useState)(()=>{let e=l.get("cli");return(0,W.isKnownCli)(e)?e:""}),[A,E]=(0,s.useState)(()=>{let e=l.get("source");return"custom"===e||"convention"===e||"cloud"===e||"pack"===e?e:""}),L=(0,s.useRef)(null),M=(0,s.useRef)(!0),H=(0,s.useRef)({filterDecision:g,filterEventType:y,filterPolicy:_,filterSessionId:U,filterCli:R,filterSource:A});H.current={filterDecision:g,filterEventType:y,filterPolicy:_,filterSessionId:U,filterCli:R,filterSource:A},(0,s.useEffect)(()=>{if(!i.current){i.current=!0;return}l.setAll({decision:g||void 0,event:y||void 0,policy:_||void 0,session:U||void 0,cli:R||void 0,source:A||void 0,page:(0,D.pageToParam)(c)})},[g,y,_,U,R,A,c]);let q=""!==g||""!==y||""!==_||""!==U||""!==R||""!==A,Q=(0,s.useCallback)(async e=>{try{let t,{filterDecision:s,filterEventType:r,filterPolicy:n,filterSessionId:a,filterCli:o,filterSource:l}=H.current;t=""!==s||""!==r||""!==n||""!==a||""!==o||""!==l?await (0,k.searchHookActivityAction)({decision:s||void 0,eventType:r||void 0,policyName:n||void 0,sessionId:a||void 0,integration:o||void 0,source:l||void 0},e):await N(e),u(t)}catch{}},[]);(0,s.useEffect)(()=>{Q(c);let e=setInterval(()=>Q(c),n>0?1e3*n:5e3);return()=>clearInterval(e)},[c,Q,n]),(0,s.useEffect)(()=>{let e=!1,t=()=>{w().then(t=>{e||h(t)}).catch(()=>{})};t();let s=setInterval(t,n>0?1e3*n:5e3);return()=>{e=!0,clearInterval(s)}},[n]),(0,s.useEffect)(()=>(L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{if(d(1),f(null),Q(1),M.current){M.current=!1;return}a("activity_filter_changed",{active_filter_count:+(""!==g)+ +(""!==y)+ +(""!==_)+ +(""!==U)+ +(""!==R),has_decision:""!==g,has_event_type:""!==y,has_policy:""!==_,has_session:""!==U,has_cli:""!==R,decision:g||null,event_type:y||null,cli:R||null})},300),()=>{L.current&&clearTimeout(L.current)}),[g,y,_,U,R]);let et=m?.entries??[],en=m?.totalPages??1;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(S,{pauses:x}),m?.stats&&m.stats.totalEvents>0&&(0,t.jsx)("div",{style:{marginBottom:18},children:(0,t.jsx)(ee,{stats:m.stats})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"filter-bar",children:[(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"decision"}),(0,t.jsx)(Y,{value:g,onChange:v})]}),(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"event"}),(0,t.jsxs)("select",{value:y,onChange:e=>C(e.target.value),className:"filter-input",children:[(0,t.jsx)("option",{value:"",children:"all events"}),(0,t.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,t.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,t.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,t.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,t.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,t.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]})]}),(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"source"}),(0,t.jsxs)("select",{value:A,onChange:e=>{let t=e.target.value;E("custom"===t||"convention"===t||"cloud"===t||"pack"===t?t:"")},className:"filter-input","aria-label":"Filter by policy source",children:[(0,t.jsx)("option",{value:"",children:"all sources"}),(0,t.jsx)("option",{value:"custom",children:"custom"}),(0,t.jsx)("option",{value:"convention",children:"convention"}),(0,t.jsx)("option",{value:"cloud",children:"cloud"}),(0,t.jsx)("option",{value:"pack",children:"pack"})]})]}),(0,t.jsxs)("div",{className:"filter-group",children:[(0,t.jsx)("span",{className:"filter-label",children:"cli"}),(0,t.jsxs)("select",{value:R,onChange:e=>{let t=e.target.value;$(""===t||(0,W.isKnownCli)(t)?t:"")},className:"filter-input","aria-label":"Filter by CLI",children:[(0,t.jsx)("option",{value:"",children:"all clis"}),W.KNOWN_CLI_IDS.map(e=>(0,t.jsx)("option",{value:e,children:(0,W.getCliLabel)(e)},e))]})]}),(0,t.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,t.jsx)("span",{className:"filter-label",children:"policy"}),(0,t.jsx)("input",{type:"text",value:_,onChange:e=>T(e.target.value),placeholder:"filter by policy…",className:"filter-input"})]}),(0,t.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,t.jsx)("span",{className:"filter-label",children:"session"}),(0,t.jsx)("input",{type:"text",value:U,onChange:e=>I(e.target.value),placeholder:"filter by session…",className:"filter-input"})]}),q&&(0,t.jsx)("button",{type:"button",className:"filter-clear",onClick:()=>{v(""),C(""),$(""),T(""),I(""),E("")},"aria-label":"Clear all filters",children:"[ clear ]"})]}),0===et.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,t.jsx)(p.Shield,{className:"h-12 w-12 text-muted-foreground/30"}),!1===e?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-4 font-medium",children:"Policies are not installed"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:["Go to the"," ",(0,t.jsx)("button",{className:"underline hover:text-foreground transition-colors",onClick:()=>r?.("policies"),children:"Policies tab"})," ","and click ",(0,t.jsx)("span",{className:"font-mono bg-muted px-1 rounded",children:"Install"})," to enable policy monitoring."]})]}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-4",children:q?"No matching activity.":"Waiting for hook events…"})]}):(0,t.jsx)("div",{className:"overflow-x-auto activity-table-wrap",children:(0,t.jsxs)("table",{className:"w-full text-xs activity-table",style:{tableLayout:"fixed"},children:[(0,t.jsxs)("colgroup",{children:[(0,t.jsx)("col",{style:{width:32}}),(0,t.jsx)("col",{style:{width:"7%"}}),(0,t.jsx)("col",{style:{width:"9%"}}),(0,t.jsx)("col",{style:{width:"12%"}}),(0,t.jsx)("col",{style:{width:"11%"}}),(0,t.jsx)("col",{style:{width:"9%"}}),(0,t.jsx)("col",{style:{width:"13%"}}),(0,t.jsx)("col",{style:{width:"12%"}}),(0,t.jsx)("col",{style:{width:"11%"}}),(0,t.jsx)("col",{style:{width:"8%"}}),(0,t.jsx)("col",{style:{width:"8%"}})]}),(0,t.jsx)("thead",{className:"activity-thead",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"px-4 py-3"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Time"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Decision"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Event"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"CLI"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Tool"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Policy"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Reason"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Mode"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Duration"}),(0,t.jsx)("th",{className:"px-3 py-3 activity-th",children:"Session"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border/30",children:et.map((e,r)=>{let n="deny"===e.decision,l=b===r,i="instruct"===e.decision;return(0,t.jsxs)(s.Fragment,{children:[(0,t.jsxs)("tr",{onClick:()=>{f(e=>{let t=e===r?null:r,s=et[r];return a("activity_row_toggled",{expanded:null!==t,decision:s?.decision??null,policy_name:s?.policyName??null,event_type:s?.eventType??null}),t})},className:`activity-data-row cursor-pointer transition-colors ${n?"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":r%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${l?"bg-muted/20":""}`,children:[(0,t.jsx)("td",{className:"px-4 py-2",children:(0,t.jsx)(o.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${l?"rotate-0":"-rotate-90"}`})}),(0,t.jsx)("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",title:new Date(e.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(0,O.formatRelativeTime)(e.timestamp)}),(0,t.jsxs)("td",{className:"px-3 py-2",children:[(0,t.jsx)(K,{decision:e.decision}),e.pausedBy&&(0,t.jsx)(P,{})]}),(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)(V,{eventType:e.eventType})}),(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)(J,{integration:e.integration})}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:e.toolName??"—"}),(0,t.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:e.policyNames&&e.policyNames.length>1?(0,t.jsxs)("span",{title:e.policyNames.join(", "),children:[e.policyNames[0],(0,t.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",e.policyNames.length-1]})]}):e.policyName??"—"}),(0,t.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate",title:e.reason??"",children:e.reason??"—"}),(0,t.jsx)("td",{className:"px-3 py-2",children:e.permissionMode?(0,t.jsx)(G,{mode:e.permissionMode}):"—"}),(0,t.jsx)("td",{className:"px-3 py-2",children:(0,t.jsx)(Z,{ms:e.durationMs})}),(0,t.jsx)("td",{className:"px-3 py-2",title:e.sessionId??"",children:(0,t.jsx)(X,{sessionId:e.sessionId,transcriptPath:e.transcriptPath,integration:e.integration,cwd:e.cwd})})]}),l&&(0,t.jsx)(es,{item:e})]},`${e.timestamp}-${r}`)})})]})}),(0,t.jsx)(j.default,{currentPage:c,totalPages:en,onPageChange:e=>{a("activity_pagination_changed",{from_page:c,to_page:e,total_pages:en}),d(e),f(null)}})]})]})}function en({enabled:e,onChange:s,disabled:r}){return(0,t.jsx)("button",{onClick:s,disabled:r,className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors disabled:opacity-40 ${e?"bg-emerald-500":"bg-muted-foreground/30"}`,"aria-label":e?"Disable policy":"Enable policy",children:(0,t.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform ${e?"translate-x-3.5":"translate-x-0.5"}`})})}function ea({policy:e,onClose:r,onSave:n}){let a=e.params??{},o=e.currentParams??{},[l,i]=(0,s.useState)(()=>{let e={};for(let[t,s]of Object.entries(a)){let r=t in o?o[t]:s.default;e[t]=r}return e});(0,s.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]);let c=(e,t)=>{i(s=>({...s,[e]:t}))};return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:e=>{e.target===e.currentTarget&&r()},children:(0,t.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,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-mono font-semibold text-foreground",children:e.name}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:e.description})]}),(0,t.jsx)("button",{onClick:r,className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,t.jsx)(v.X,{className:"h-4 w-4"})})]}),(0,t.jsx)("div",{className:"overflow-y-auto flex-1 px-4 py-4 space-y-4",children:Object.entries(a).map(([e,s])=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1 font-mono",children:e}),(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground mb-1.5",children:s.description}),((e,s)=>{let r=l[e];if("boolean"===s.type)return(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:!!r,onChange:t=>c(e,t.target.checked),className:"rounded border-border"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:s.description})]});if("number"===s.type)return(0,t.jsx)("input",{type:"number",value:"number"==typeof r?r:"",onChange:t=>c(e,Number(t.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[]"===s.type){let s=Array.isArray(r)?r.join("\n"):"";return(0,t.jsx)("textarea",{value:s,onChange:t=>c(e,t.target.value.split("\n").filter(e=>""!==e.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[]"===s.type){let s=Array.isArray(r)?r:[];return(0,t.jsxs)("div",{className:"space-y-1.5",children:[s.map((r,n)=>(0,t.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,t.jsx)("input",{type:"text",value:r.regex,onChange:t=>{let r=[...s];r[n]={...r[n],regex:t.target.value},c(e,r)},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,t.jsx)("input",{type:"text",value:r.label,onChange:t=>{let r=[...s];r[n]={...r[n],label:t.target.value},c(e,r)},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,t.jsx)("button",{onClick:()=>c(e,s.filter((e,t)=>t!==n)),className:"text-muted-foreground/50 hover:text-destructive transition-colors",children:(0,t.jsx)(v.X,{className:"h-3.5 w-3.5"})})]},n)),(0,t.jsx)("button",{onClick:()=>c(e,[...s,{regex:"",label:""}]),className:"text-xs text-primary hover:underline",children:"+ Add pattern"})]})}return(0,t.jsx)("input",{type:"text",value:"string"==typeof r?r:"",onChange:t=>c(e,t.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"})})(e,s)]},e))}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,t.jsx)(q.Button,{variant:"outline",size:"sm",onClick:r,className:"h-7 text-xs",children:"Cancel"}),(0,t.jsx)(q.Button,{size:"sm",onClick:()=>n(l),className:"h-7 text-xs",children:"Save"})]})]})})}function eo({message:e,onDismiss:s,onInstall:n,isPending:a}){let{capture:o}=(0,F.usePostHog)();return(0,r.createPortal)((0,t.jsxs)("div",{className:"fixed top-4 right-4 z-[9999] w-full max-w-sm",style:{animation:"slideInFromRight 0.25s ease-out"},children:[(0,t.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,t.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,t.jsx)("div",{className:"h-0.5 w-full bg-gradient-to-r from-red-600 via-red-400 to-red-600"}),(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.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,t.jsx)(v.X,{className:"h-3 w-3 text-white",strokeWidth:3})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-[0.65rem] font-bold uppercase tracking-widest text-red-400 mb-0.5",children:"Error"}),(0,t.jsx)("p",{className:"text-sm text-red-100 leading-snug",children:e})]}),(0,t.jsx)("button",{onClick:s,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,t.jsx)(v.X,{className:"h-4 w-4"})})]}),(0,t.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,t.jsx)(q.Button,{size:"sm",onClick:()=>{a("hooks_install_from_error_clicked",{error_message:e.slice(0,200)}),s(),n()},disabled:o,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,t.jsx)(q.Button,{variant:"ghost",size:"sm",onClick:s,className:"h-7 px-3 text-xs text-red-400 hover:bg-red-500/10 hover:text-red-200",children:"Dismiss"})]})]})]})]}),document.body)}function el({onHooksInstallChange:e}){let[r,n]=(0,s.useState)(null),[o,a]=(0,s.useTransition)(),[l,c]=(0,s.useState)(null),[d,m]=(0,s.useState)(null),[p,h]=(0,s.useState)(null),[b,f]=(0,s.useState)(()=>new Set),g=(0,s.useRef)(!1),{capture:v}=(0,F.usePostHog)(),j=(0,s.useCallback)((e,t)=>{v("action_error_displayed",{error_type:e,error_message:t.slice(0,200)}),c(t)},[v]),y=(0,s.useCallback)(async()=>{try{let t=await _();n(t),e?.(t.clis.some(e=>e.installed))}catch{}},[e]);(0,s.useEffect)(()=>{y()},[y]),(0,s.useEffect)(()=>{r&&(g.current?f(new Set(r.clis.filter(e=>e.installed).map(e=>e.id))):(g.current=!0,f(new Set(r.clis.filter(e=>e.installed||e.detected).map(e=>e.id)))))},[r?.clis]);let N=(0,s.useMemo)(()=>new Set((r?.clis??[]).filter(e=>e.installed).map(e=>e.id)),[r?.clis]),k=(0,s.useMemo)(()=>{let e=[],t=[];for(let s of r?.clis??[]){let r=b.has(s.id);r&&!N.has(s.id)&&e.push(s.id),!r&&N.has(s.id)&&t.push(s.id)}return{toInstall:e,toRemove:t}},[r?.clis,b,N]),w=k.toInstall.length>0||k.toRemove.length>0,S=(e,t)=>{r&&(n(s=>s?{...s,customPolicies:s.customPolicies?.map(s=>s.id===e?{...s,enabled:!t}:s),conventionPolicies:s.conventionPolicies.map(s=>({...s,policies:s.policies.map(s=>s.id===e?{...s,enabled:!t}:s)}))}:s),a(async()=>{try{await T(e,!t)}catch{j("custom_policy_toggle","Failed to save custom policy change."),y()}}))},P=()=>{let{toInstall:e,toRemove:t}=k;(0!==e.length||0!==t.length)&&(v("cli_install_remove_submitted",{to_install:e,to_remove:t,count_install:e.length,count_remove:t.length}),a(async()=>{try{c(null),e.length>0&&await E("user",e),t.length>0&&await L("user",t)}catch(e){j("cli_apply",e instanceof Error?e.message:"Failed to apply changes.")}finally{await y()}}))};if(!r)return(0,t.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,t.jsxs)("span",{className:"text-sm text-muted-foreground",children:["Loading","…"]})});let C=r.clis.some(e=>e.installed),U=N.size,I=b.size,R=Array.from(new Set(r.policies.map(e=>e.category)));return(0,t.jsxs)(t.Fragment,{children:[p&&(0,t.jsx)(eo,{policy:p,onClose:()=>{v("policy_config_modal_closed",{policy_name:p.name,action:"cancel"}),h(null)},onSave:e=>{if(!p)return;let t=p.name;h(null),a(async()=>{try{c(null),await M(t,e),await y()}catch(e){j("param_update",e instanceof Error?e.message:"Failed to save configuration.")}})}}),(0,t.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:[(0,t.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,t.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-wrap",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:`h-2 w-2 rounded-full transition-shadow ${C?"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.6)]":"bg-muted-foreground/40"}`,"aria-hidden":!0}),(0,t.jsx)("span",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-foreground/90",children:"Integrations"})]}),(0,t.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,t.jsxs)("div",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-muted-foreground",children:[(0,t.jsx)("span",{className:"text-foreground tabular-nums",children:U.toString().padStart(2,"0")}),(0,t.jsxs)("span",{className:"opacity-50",children:[" / 0",r.clis.length," active"]})]}),w&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[0.65rem] uppercase tracking-[0.2em] font-mono text-pink-400",children:[(0,t.jsx)("span",{className:"h-1 w-1 rounded-full bg-pink-400 animate-pulse"}),k.toInstall.length+k.toRemove.length," pending"]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,t.jsx)(q.Button,{variant:"outline",size:"sm",onClick:()=>{let e=Array.from(N).filter(e=>b.has(e));0!==e.length&&(v("cli_reinstall_submitted",{cli_ids:e,count:e.length}),a(async()=>{try{c(null),await E("user",e)}catch(e){j("cli_reinstall",e instanceof Error?e.message:"Failed to reinstall.")}finally{await y()}}))},disabled:o||0===I,className:"text-xs h-7 px-3 font-mono",children:"Reinstall"}),(0,t.jsx)(q.Button,{variant:"default",size:"sm",onClick:P,disabled:o||!w,className:"text-xs h-7 px-3 font-mono",children:"Apply changes"})]})]}),(0,t.jsx)("div",{className:"divide-y divide-border/30 border-b border-border/60",children:r.clis.map((e,s)=>{let n=b.has(e.id),a=N.has(e.id),l=n!==a,i=(0,W.getCliBadgeClasses)(e.id),c=i.split(" ").find(e=>e.startsWith("text-"))??"text-foreground";return(0,t.jsxs)("label",{className:`group relative flex items-center gap-3 pl-6 pr-5 py-3 cursor-pointer transition-colors hover:bg-muted/15 ${l?"bg-pink-500/[0.04]":""}`,children:[(0,t.jsx)("div",{className:`absolute left-0 top-0 bottom-0 w-[3px] ${c} bg-current transition-opacity ${n?"opacity-100":"opacity-25 group-hover:opacity-60"}`,"aria-hidden":!0}),(0,t.jsx)("div",{className:"font-mono text-[0.65rem] text-muted-foreground/40 tabular-nums w-6 select-none",children:(s+1).toString().padStart(2,"0")}),(0,t.jsxs)("div",{className:"relative shrink-0",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:()=>{var t;return t=e.id,void f(e=>{let s=new Set(e),n=!s.has(t);n?s.add(t):s.delete(t);let o=r?.clis.find(e=>e.id===t);return v("cli_selection_toggled",{cli_id:t,checked:n,current_state:o?.installed?"installed":o?.detected?"detected":"inactive"}),s})},disabled:o,className:"sr-only peer","aria-label":`Toggle ${e.label}`}),(0,t.jsx)("div",{className:`h-[18px] w-[18px] rounded-sm border transition-all peer-focus-visible:ring-2 peer-focus-visible:ring-primary/40 ${n?"bg-primary border-primary":"bg-background/50 border-border group-hover:border-foreground/40"}`,children:n&&(0,t.jsx)("svg",{viewBox:"0 0 18 18",className:"h-full w-full text-primary-foreground",fill:"none","aria-hidden":!0,children:(0,t.jsx)("path",{d:"M4 9.5L7.5 12.5L14 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),(0,t.jsx)("div",{className:"min-w-[150px] shrink-0",children:(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[a?(0,t.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,t.jsx)("span",{className:"h-1 w-1 rounded-full bg-current shadow-[0_0_4px_currentColor]"}),"Active"]}):e.detected?(0,t.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,t.jsx)("span",{className:"h-1 w-1 rounded-full bg-current opacity-60"}),"Detected"]}):(0,t.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"}),l&&(0,t.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:n?"+ install":"− remove"})]}),(0,t.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:e.settingsPath,children:e.settingsPath})]},e.id)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border/40 bg-muted/5",children:[(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:r.policies.filter(e=>e.enabled).length+(r.customPolicies?.filter(e=>e.enabled).length??0)+(r.conventionPolicies?.reduce((e,t)=>e+t.policies.filter(e=>e.enabled).length,0)??0)})," / ",r.policies.length+(r.customPolicies?.length??0)+(r.conventionPolicies?.reduce((e,t)=>e+t.policies.length,0)??0)," ","policies enabled"]}),C&&(0,t.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground/60",children:["· shared across ",U," active CLI",1===U?"":"s"]})]}),l&&(0,t.jsx)("div",{className:"px-4 py-2 bg-red-500/10 border-b border-red-500/20 text-xs text-red-400",children:l}),d&&(0,t.jsx)(ea,{message:d,onDismiss:()=>m(null),onInstall:P,isPending:o}),R.map(e=>{let s=r.policies.filter(t=>t.category===e),l=s.filter(e=>e.enabled).length;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[l," / ",s.length," enabled"]})]}),s.map(e=>(0,t.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,t.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,t.jsx)(en,{enabled:e.enabled,onChange:()=>{var t;let s;return t=e.enabled,s=e.name,void(!r||(!r.clis.some(e=>e.installed)?m("Policies are not installed. Install policies to continue."):(m(null),n(r=>r?{...r,policies:r.policies.map(e=>e.name===s?{...e,enabled:!t}:e),packs:r.packs.map(r=>r.id===e.packId?{...r,policies:r.policies.map(e=>e.name===s?{...e,enabled:!t}:e)}:r)}:r),a(async()=>{try{await A(e.packId,s,!t)}catch{j("policy_toggle","Failed to save policy change."),y()}}))))},disabled:o})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:[(0,t.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:e.name}),e.beta&&(0,t.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,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:e.description}),e.eventScope&&(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:e.eventScope}),e.params&&Object.keys(e.params).length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1.5",children:Object.entries(e.params).map(([s,r])=>{let n=e.currentParams?.[s]??r.default,o=JSON.stringify(n)!==JSON.stringify(r.default);return(0,t.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[0.6rem] px-1.5 py-0.5 rounded border ${o?"bg-primary/10 text-primary/70 border-primary/20":"bg-muted/40 text-muted-foreground/55 border-border/40"}`,children:[(0,t.jsxs)("span",{className:"opacity-70",children:[s,":"]}),(0,t.jsx)("span",{children:function(e,t){if("string[]"===e||"pattern[]"===e){let s=Array.isArray(t)?t:[];return 0===s.length?"none":"pattern[]"===e?`${s.length} pattern${1!==s.length?"s":""}`:1===s.length?String(s[0]).slice(0,24):`${s.length} values`}return"boolean"===e?t?"on":"off":null==t||""===t?"—":String(t).slice(0,32)}(r.type,n)})]},s)})})]}),e.params&&Object.keys(e.params).length>0&&(0,t.jsx)("button",{className:"shrink-0 mt-0.5 text-muted-foreground hover:text-primary transition-colors",onClick:()=>{let t=Object.entries(e.params??{}).filter(([t,s])=>JSON.stringify(e.currentParams?.[t]??s.default)!==JSON.stringify(s.default)).length;v("policy_config_modal_opened",{policy_name:e.name,param_count:Object.keys(e.params??{}).length,has_customized_params:t>0,customized_count:t}),h(e)},title:"Edit parameters",children:(0,t.jsx)(u.Settings,{className:"h-3.5 w-3.5"})})]},e.name))]},e)}),(r.customPoliciesPaths?.length||r.customPoliciesPath)&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:"Custom Policies"}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[r.customPolicies?.length??0," detected"]})]}),(r.customPoliciesPaths??[r.customPoliciesPath]).map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)(i,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e})]},e)),(0,t.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,t.jsx)(x.Shield,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,t.jsx)("p",{className:"text-[0.7rem] text-muted-foreground/70 leading-relaxed",children:"Re-run the install command to add, remove, or reorder files."})]}),r.customPolicies?.map(e=>(0,t.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,t.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,t.jsx)(en,{enabled:e.enabled,onChange:()=>S(e.id,e.enabled),disabled:o})}),(0,t.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,t.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:e.name})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[e.description&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:e.description}),e.eventScope&&(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:e.eventScope})]})]},e.id))]}),r.conventionPolicies?.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsxs)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:["Convention Policies — ","project"===e.scope?"Project":"User"]}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[e.policies.length," hook",1===e.policies.length?"":"s"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)(i,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e.path})]}),0===e.policies.length?(0,t.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,t.jsx)(x.Shield,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,t.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,t.jsx)("span",{className:"font-mono",children:"failproofai policies"})," to see what it registers."]})]}):e.policies.map(s=>(0,t.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,t.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,t.jsx)(en,{enabled:s.enabled,onChange:()=>S(s.id,s.enabled),disabled:o})}),(0,t.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,t.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:s.name})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[s.description&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:s.description}),s.eventScope&&(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:s.eventScope})]})]},`${e.path}:${s.name}`))]},e.path)),(0,t.jsx)(ei,{packs:r.packs??[],disabled:o,onChanged:y,onError:e=>j("pack_action",e)})]})]})}function ei({packs:e,disabled:r,onChanged:n,onError:o}){let[a,l]=(0,s.useState)(""),[i,c]=(0,s.useState)(null),[u,x]=(0,s.useState)(null),[p,h]=(0,s.useState)(null),{capture:b}=(0,F.usePostHog)(),j=async()=>{if(a.trim()){c("preview"),h(null);try{let e=await R(a);if(!e.ok)return void o(e.error??"Could not read that pack.");h(e)}finally{c(null)}}},y=async(e,t)=>{c(e),x(null);try{let e=await t();if(!e.ok)return void o(e.error??"Could not install that pack.");x(e.version?`${e.id}@${e.version}`:e.id??null),l(""),n()}catch(e){o(e instanceof Error?e.message:"Could not install that pack.")}finally{c(null)}};return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:"Policy Packs"}),(0,t.jsx)("span",{className:"text-[0.7rem] text-muted-foreground",children:0===e.length?"none installed":`${e.length} installed`})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)("input",{value:a,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&a.trim()&&!i&&(b("pack_install_submitted",{via:"input"}),y("input",()=>I(a)))},placeholder:"core · acme/ops · acme/ops@v1.2.0 · a release URL",spellCheck:!1,disabled:r||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,t.jsx)(q.Button,{size:"sm",variant:"outline",disabled:r||null!==i||0===a.trim().length,onClick:()=>{b("pack_preview_submitted",{}),j()},children:"preview"===i?"Reading…":"Preview"}),(0,t.jsxs)(q.Button,{size:"sm",variant:"default",disabled:r||null!==i||0===a.trim().length,onClick:()=>{b("pack_install_submitted",{via:"button"}),y("input",()=>I(a))},children:[(0,t.jsx)(m,{className:"h-3.5 w-3.5"}),"input"===i?"Installing…":"Install"]})]}),p?.ok&&(0,t.jsxs)("div",{className:"border-b border-border/20 bg-muted/5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,t.jsx)(d,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsxs)("span",{className:"text-xs font-mono text-foreground",children:[p.id,"@",p.version]}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[p.policies?.length??0," policies ·"," ",p.policies?.filter(e=>e.defaultEnabled).length??0," on by default"]}),"observe"===p.effect&&(0,t.jsx)("span",{className:"text-[0.65rem] uppercase tracking-wider text-amber-500",children:"observes only"}),(0,t.jsx)("button",{onClick:()=>h(null),className:"ml-auto text-muted-foreground/60 hover:text-foreground","aria-label":"Close preview",children:(0,t.jsx)(v.X,{className:"h-3.5 w-3.5"})})]}),(0,t.jsx)("div",{className:"max-h-64 overflow-y-auto",children:p.policies?.map(e=>(0,t.jsxs)("div",{className:"flex items-start gap-3 px-4 py-2 border-t border-border/10",children:[(0,t.jsx)("span",{className:`text-[0.65rem] uppercase tracking-wider w-14 shrink-0 mt-0.5 ${e.defaultEnabled?"text-emerald-500":"text-muted-foreground/50"}`,children:e.defaultEnabled?"default":"opt-in"}),(0,t.jsx)("span",{className:"text-xs font-mono text-foreground w-56 shrink-0 truncate",children:e.name}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground leading-relaxed min-w-0",children:[e.description,(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5",children:e.category})]})]},e.name))}),(0,t.jsx)("div",{className:"px-4 py-2.5 border-t border-border/20",children:(0,t.jsxs)(q.Button,{size:"sm",variant:"default",disabled:r||null!==i,onClick:()=>{b("pack_install_submitted",{via:"preview"}),y("input",()=>I(a)).then(()=>h(null))},children:[(0,t.jsx)(m,{className:"h-3.5 w-3.5"}),"Install its defaults"]})})]}),(0,t.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,t.jsx)("span",{className:"text-[0.7rem] text-muted-foreground/70 mr-1",children:"Failproof AI policies:"}),(0,t.jsx)(q.Button,{size:"sm",variant:"outline",disabled:r||null!==i,onClick:()=>{b("pack_install_submitted",{via:"ours"}),y("ours",()=>I("FailproofAI/policies"))},children:"ours"===i?"Installing…":"Install from GitHub"}),(0,t.jsx)(q.Button,{size:"sm",variant:"outline",disabled:r||null!==i,onClick:()=>{b("pack_install_submitted",{via:"bundled"}),y("bundled",()=>U())},children:"bundled"===i?"Installing…":"Install offline copy"}),u&&(0,t.jsxs)("span",{className:"text-[0.7rem] text-emerald-500 font-mono",children:["installed ",u]})]}),e.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)(d,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsxs)("span",{className:"text-xs font-mono text-foreground truncate",children:[e.id,e.version?`@${e.version}`:""]}),"observe"===e.effect&&(0,t.jsx)("span",{className:"text-[0.65rem] uppercase tracking-wider text-amber-500",children:"observing"}),(0,t.jsx)("span",{className:"text-[0.65rem] text-muted-foreground/50 font-mono truncate hidden lg:inline",children:e.source}),(0,t.jsx)("button",{onClick:()=>void y(e.id,()=>$(e.id)),disabled:r||null!==i,className:"ml-auto text-muted-foreground/60 hover:text-foreground disabled:opacity-40","aria-label":`Remove ${e.id}`,children:(0,t.jsx)(f,{className:"h-3.5 w-3.5"})})]}),e.error?(0,t.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-amber-500/5",children:[(0,t.jsx)(g,{className:"h-3.5 w-3.5 text-amber-500 shrink-0 mt-0.5"}),(0,t.jsxs)("p",{className:"text-[0.7rem] text-muted-foreground leading-relaxed",children:["This pack will not load: ",e.error]})]}):(0,t.jsx)("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-border/20",children:(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[e.policies.filter(e=>e.enabled).length," of ",e.policies.length," on — listed by category above"]})})]},`${e.id}@${e.version}`))]})}function ec({activeTab:e,onChange:s}){return(0,t.jsx)("div",{className:"tabs",style:{padding:0,marginBottom:24},children:[{id:"activity",label:"Activity"},{id:"policies",label:"Configure"}].map(r=>(0,t.jsx)("button",{type:"button",onClick:()=>s(r.id),className:`tab${e===r.id?" is-active":""}`,children:r.label.toLowerCase()},r.id))})}e.s(["default",0,function({initialTab:e="activity"}){let r=(0,z.useUrlParams)(),{capture:n}=(0,F.usePostHog)(),[o,a]=(0,s.useState)(e),[l,i]=(0,s.useState)(void 0),[c,d]=(0,s.useState)(null),[m,u]=(0,s.useState)([]);(0,s.useEffect)(()=>{_().then(e=>{i(e.clis.some(e=>e.installed)),d({enabled:e.enabledPolicies.length,total:e.policies.length+(e.customPolicies?.length??0)+(e.conventionPolicies?.reduce((e,t)=>e+t.policies.length,0)??0)}),u(e.clis.filter(e=>e.installed).map(e=>e.label))}).catch(()=>i(void 0))},[]);let x=0===m.length?"Policy evaluations":m.length<=3?`Policy evaluations across ${m.join(", ")}`:`Policy evaluations across ${m.length} agents`,p=e=>{e!==o&&n("policies_tab_switched",{tab:e,from_tab:o}),a(e),r.setAll({tab:"activity"===e?void 0:e})};return(0,t.jsx)("main",{className:"report",children:(0,t.jsxs)("section",{className:"section","data-screen-label":"policies",children:[(0,t.jsx)("h2",{style:{fontFamily:"var(--font-mono)",fontSize:24,fontWeight:600,letterSpacing:"-0.01em",color:"var(--ink)",margin:"0 0 16px"},children:"activity"===o?"Policies":"Configure Policies"}),"activity"===o?(0,t.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:32,flexWrap:"wrap",margin:"0 0 24px"},children:[(0,t.jsxs)("div",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--ink-2)",lineHeight:1.7,flex:"1 1 480px",minWidth:0},children:[x,c&&(0,t.jsxs)("span",{style:{color:"var(--dim)"},children:[" · ","enabled policies"," ",(0,t.jsxs)("span",{style:{color:"var(--ink)",fontVariantNumeric:"tabular-nums"},children:[c.enabled,"/",c.total]})]})]}),(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:6,flex:"0 0 auto"},children:[(0,t.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,t.jsx)("button",{type:"button",className:"btn btn-primary",onClick:()=>p("policies"),children:"[ configure policies → ]"})]})]}):(0,t.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,t.jsx)(ec,{activeTab:o,onChange:p}),"activity"===o?(0,t.jsx)(er,{hooksInstalled:l,onSwitchTab:p}):(0,t.jsx)(el,{onHooksInstallChange:i})]})})}],64245)}]);
|
|
6
|
+
`}),(0,t.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,t.jsx)("div",{className:"h-0.5 w-full bg-gradient-to-r from-red-600 via-red-400 to-red-600"}),(0,t.jsxs)("div",{className:"p-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.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,t.jsx)(v.X,{className:"h-3 w-3 text-white",strokeWidth:3})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("p",{className:"text-[0.65rem] font-bold uppercase tracking-widest text-red-400 mb-0.5",children:"Error"}),(0,t.jsx)("p",{className:"text-sm text-red-100 leading-snug",children:e})]}),(0,t.jsx)("button",{onClick:s,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,t.jsx)(v.X,{className:"h-4 w-4"})})]}),(0,t.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,t.jsx)(q.Button,{size:"sm",onClick:()=>{o("hooks_install_from_error_clicked",{error_message:e.slice(0,200)}),s(),n()},disabled:a,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,t.jsx)(q.Button,{variant:"ghost",size:"sm",onClick:s,className:"h-7 px-3 text-xs text-red-400 hover:bg-red-500/10 hover:text-red-200",children:"Dismiss"})]})]})]})]}),document.body)}function el({onHooksInstallChange:e}){let[r,n]=(0,s.useState)(null),[a,o]=(0,s.useTransition)(),[l,c]=(0,s.useState)(null),[d,m]=(0,s.useState)(null),[x,h]=(0,s.useState)(null),[b,f]=(0,s.useState)(()=>new Set),g=(0,s.useRef)(!1),{capture:v}=(0,F.usePostHog)(),j=(0,s.useCallback)((e,t)=>{v("action_error_displayed",{error_type:e,error_message:t.slice(0,200)}),c(t)},[v]),y=(0,s.useCallback)(async()=>{try{let t=await _();n(t),e?.(t.clis.some(e=>e.installed))}catch{}},[e]);(0,s.useEffect)(()=>{y()},[y]),(0,s.useEffect)(()=>{r&&(g.current?f(new Set(r.clis.filter(e=>e.installed).map(e=>e.id))):(g.current=!0,f(new Set(r.clis.filter(e=>e.installed||e.detected).map(e=>e.id)))))},[r?.clis]);let N=(0,s.useMemo)(()=>new Set((r?.clis??[]).filter(e=>e.installed).map(e=>e.id)),[r?.clis]),k=(0,s.useMemo)(()=>{let e=[],t=[];for(let s of r?.clis??[]){let r=b.has(s.id);r&&!N.has(s.id)&&e.push(s.id),!r&&N.has(s.id)&&t.push(s.id)}return{toInstall:e,toRemove:t}},[r?.clis,b,N]),w=k.toInstall.length>0||k.toRemove.length>0,S=(e,t)=>{r&&(n(s=>s?{...s,customPolicies:s.customPolicies?.map(s=>s.id===e?{...s,enabled:!t}:s),conventionPolicies:s.conventionPolicies.map(s=>({...s,policies:s.policies.map(s=>s.id===e?{...s,enabled:!t}:s)}))}:s),o(async()=>{try{await T(e,!t)}catch{j("custom_policy_toggle","Failed to save custom policy change."),y()}}))},P=()=>{let{toInstall:e,toRemove:t}=k;(0!==e.length||0!==t.length)&&(v("cli_install_remove_submitted",{to_install:e,to_remove:t,count_install:e.length,count_remove:t.length}),o(async()=>{try{c(null),e.length>0&&await E("user",e),t.length>0&&await L("user",t)}catch(e){j("cli_apply",e instanceof Error?e.message:"Failed to apply changes.")}finally{await y()}}))};if(!r)return(0,t.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,t.jsxs)("span",{className:"text-sm text-muted-foreground",children:["Loading","…"]})});let C=r.clis.some(e=>e.installed),U=N.size,I=b.size,R=Array.from(new Set(r.policies.map(e=>e.category)));return(0,t.jsxs)(t.Fragment,{children:[x&&(0,t.jsx)(ea,{policy:x,onClose:()=>{v("policy_config_modal_closed",{policy_name:x.name,action:"cancel"}),h(null)},onSave:e=>{var t,s;if(!x)return;let r=x.packId?(t=x.packId,s=x.name,`pack/${t}/${s}`):x.name;h(null),o(async()=>{try{c(null),await M(r,e),await y()}catch(e){j("param_update",e instanceof Error?e.message:"Failed to save configuration.")}})}}),(0,t.jsxs)("div",{className:"bg-card border border-border rounded-lg overflow-hidden",children:[(0,t.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,t.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-wrap",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:`h-2 w-2 rounded-full transition-shadow ${C?"bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.6)]":"bg-muted-foreground/40"}`,"aria-hidden":!0}),(0,t.jsx)("span",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-foreground/90",children:"Integrations"})]}),(0,t.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,t.jsxs)("div",{className:"text-[0.65rem] uppercase tracking-[0.2em] font-mono text-muted-foreground",children:[(0,t.jsx)("span",{className:"text-foreground tabular-nums",children:U.toString().padStart(2,"0")}),(0,t.jsxs)("span",{className:"opacity-50",children:[" / 0",r.clis.length," active"]})]}),w&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-[0.65rem] font-mono text-muted-foreground/40",children:"·"}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[0.65rem] uppercase tracking-[0.2em] font-mono text-pink-400",children:[(0,t.jsx)("span",{className:"h-1 w-1 rounded-full bg-pink-400 animate-pulse"}),k.toInstall.length+k.toRemove.length," pending"]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,t.jsx)(q.Button,{variant:"outline",size:"sm",onClick:()=>{let e=Array.from(N).filter(e=>b.has(e));0!==e.length&&(v("cli_reinstall_submitted",{cli_ids:e,count:e.length}),o(async()=>{try{c(null),await E("user",e)}catch(e){j("cli_reinstall",e instanceof Error?e.message:"Failed to reinstall.")}finally{await y()}}))},disabled:a||0===I,className:"text-xs h-7 px-3 font-mono",children:"Reinstall"}),(0,t.jsx)(q.Button,{variant:"default",size:"sm",onClick:P,disabled:a||!w,className:"text-xs h-7 px-3 font-mono",children:"Apply changes"})]})]}),(0,t.jsx)("div",{className:"divide-y divide-border/30 border-b border-border/60",children:r.clis.map((e,s)=>{let n=b.has(e.id),o=N.has(e.id),l=n!==o,i=(0,W.getCliBadgeClasses)(e.id),c=i.split(" ").find(e=>e.startsWith("text-"))??"text-foreground";return(0,t.jsxs)("label",{className:`group relative flex items-center gap-3 pl-6 pr-5 py-3 cursor-pointer transition-colors hover:bg-muted/15 ${l?"bg-pink-500/[0.04]":""}`,children:[(0,t.jsx)("div",{className:`absolute left-0 top-0 bottom-0 w-[3px] ${c} bg-current transition-opacity ${n?"opacity-100":"opacity-25 group-hover:opacity-60"}`,"aria-hidden":!0}),(0,t.jsx)("div",{className:"font-mono text-[0.65rem] text-muted-foreground/40 tabular-nums w-6 select-none",children:(s+1).toString().padStart(2,"0")}),(0,t.jsxs)("div",{className:"relative shrink-0",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:()=>{var t;return t=e.id,void f(e=>{let s=new Set(e),n=!s.has(t);n?s.add(t):s.delete(t);let a=r?.clis.find(e=>e.id===t);return v("cli_selection_toggled",{cli_id:t,checked:n,current_state:a?.installed?"installed":a?.detected?"detected":"inactive"}),s})},disabled:a,className:"sr-only peer","aria-label":`Toggle ${e.label}`}),(0,t.jsx)("div",{className:`h-[18px] w-[18px] rounded-sm border transition-all peer-focus-visible:ring-2 peer-focus-visible:ring-primary/40 ${n?"bg-primary border-primary":"bg-background/50 border-border group-hover:border-foreground/40"}`,children:n&&(0,t.jsx)("svg",{viewBox:"0 0 18 18",className:"h-full w-full text-primary-foreground",fill:"none","aria-hidden":!0,children:(0,t.jsx)("path",{d:"M4 9.5L7.5 12.5L14 6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),(0,t.jsx)("div",{className:"min-w-[150px] shrink-0",children:(0,t.jsx)("div",{className:"text-sm font-medium text-foreground",children:e.label})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[o?(0,t.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,t.jsx)("span",{className:"h-1 w-1 rounded-full bg-current shadow-[0_0_4px_currentColor]"}),"Active"]}):e.detected?(0,t.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,t.jsx)("span",{className:"h-1 w-1 rounded-full bg-current opacity-60"}),"Detected"]}):(0,t.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"}),l&&(0,t.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:n?"+ install":"− remove"})]}),(0,t.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:e.settingsPath,children:e.settingsPath})]},e.id)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border/40 bg-muted/5",children:[(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:r.policies.filter(e=>e.enabled).length+(r.customPolicies?.filter(e=>e.enabled).length??0)+(r.conventionPolicies?.reduce((e,t)=>e+t.policies.filter(e=>e.enabled).length,0)??0)})," / ",r.policies.length+(r.customPolicies?.length??0)+(r.conventionPolicies?.reduce((e,t)=>e+t.policies.length,0)??0)," ","policies enabled"]}),C&&(0,t.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground/60",children:["· shared across ",U," active CLI",1===U?"":"s"]})]}),l&&(0,t.jsx)("div",{className:"px-4 py-2 bg-red-500/10 border-b border-red-500/20 text-xs text-red-400",children:l}),d&&(0,t.jsx)(eo,{message:d,onDismiss:()=>m(null),onInstall:P,isPending:a}),R.map(e=>{let s=r.policies.filter(t=>t.category===e),l=s.filter(e=>e.enabled).length;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:e}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[l," / ",s.length," enabled"]})]}),s.map(e=>(0,t.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,t.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,t.jsx)(en,{enabled:e.enabled,onChange:()=>{var t;let s;return t=e.enabled,s=e.name,void(!r||(!r.clis.some(e=>e.installed)?m("Policies are not installed. Install policies to continue."):(m(null),n(r=>r?{...r,policies:r.policies.map(r=>r.name===s&&r.packId===e.packId?{...r,enabled:!t}:r),packs:r.packs.map(r=>r.id===e.packId?{...r,policies:r.policies.map(e=>e.name===s?{...e,enabled:!t}:e)}:r)}:r),o(async()=>{try{let r=await A(e.packId,s,!t);r.ok||(j("policy_toggle",r.error??"Failed to save policy change."),y())}catch{j("policy_toggle","Failed to save policy change."),y()}}))))},disabled:a})}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:[(0,t.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:e.name}),e.beta&&(0,t.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,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:e.description}),e.eventScope&&(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:e.eventScope}),e.params&&Object.keys(e.params).length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1 mt-1.5",children:Object.entries(e.params).map(([s,r])=>{let n=e.currentParams?.[s]??r.default,a=JSON.stringify(n)!==JSON.stringify(r.default);return(0,t.jsxs)("span",{className:`inline-flex items-center gap-1 font-mono text-[0.6rem] px-1.5 py-0.5 rounded border ${a?"bg-primary/10 text-primary/70 border-primary/20":"bg-muted/40 text-muted-foreground/55 border-border/40"}`,children:[(0,t.jsxs)("span",{className:"opacity-70",children:[s,":"]}),(0,t.jsx)("span",{children:function(e,t){if("string[]"===e||"pattern[]"===e){let s=Array.isArray(t)?t:[];return 0===s.length?"none":"pattern[]"===e?`${s.length} pattern${1!==s.length?"s":""}`:1===s.length?String(s[0]).slice(0,24):`${s.length} values`}return"boolean"===e?t?"on":"off":null==t||""===t?"—":String(t).slice(0,32)}(r.type,n)})]},s)})})]}),e.params&&Object.keys(e.params).length>0&&(0,t.jsx)("button",{className:"shrink-0 mt-0.5 text-muted-foreground hover:text-primary transition-colors",onClick:()=>{let t=Object.entries(e.params??{}).filter(([t,s])=>JSON.stringify(e.currentParams?.[t]??s.default)!==JSON.stringify(s.default)).length;v("policy_config_modal_opened",{policy_name:e.name,param_count:Object.keys(e.params??{}).length,has_customized_params:t>0,customized_count:t}),h(e)},title:"Edit parameters",children:(0,t.jsx)(u.Settings,{className:"h-3.5 w-3.5"})})]},`${e.packId}/${e.name}`))]},e)}),(r.customPoliciesPaths?.length||r.customPoliciesPath)&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:"Custom Policies"}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[r.customPolicies?.length??0," detected"]})]}),(r.customPoliciesPaths??[r.customPoliciesPath]).map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)(i,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e})]},e)),(0,t.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,t.jsx)(p.Shield,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,t.jsx)("p",{className:"text-[0.7rem] text-muted-foreground/70 leading-relaxed",children:"Re-run the install command to add, remove, or reorder files."})]}),r.customPolicies?.map(e=>(0,t.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,t.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,t.jsx)(en,{enabled:e.enabled,onChange:()=>S(e.id,e.enabled),disabled:a})}),(0,t.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,t.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:e.name})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[e.description&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:e.description}),e.eventScope&&(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:e.eventScope})]})]},e.id))]}),r.conventionPolicies?.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsxs)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:["Convention Policies — ","project"===e.scope?"Project":"User"]}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[e.policies.length," hook",1===e.policies.length?"":"s"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)(i,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e.path})]}),0===e.policies.length?(0,t.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-muted/10",children:[(0,t.jsx)(p.Shield,{className:"h-3.5 w-3.5 text-muted-foreground/60 shrink-0 mt-0.5"}),(0,t.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,t.jsx)("span",{className:"font-mono",children:"failproofai policies"})," to see what it registers."]})]}):e.policies.map(s=>(0,t.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,t.jsx)("div",{className:"mt-0.5 shrink-0",children:(0,t.jsx)(en,{enabled:s.enabled,onChange:()=>S(s.id,s.enabled),disabled:a})}),(0,t.jsx)("div",{className:"flex items-center gap-1.5 min-w-0 w-56 shrink-0 mt-0.5",children:(0,t.jsx)("span",{className:"text-xs font-mono text-foreground truncate",children:s.name})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[s.description&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground leading-relaxed",children:s.description}),s.eventScope&&(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5 hidden lg:block",children:s.eventScope})]})]},`${e.path}:${s.name}`))]},e.path)),(0,t.jsx)(ei,{packs:r.packs??[],disabled:a,onChanged:y,onError:e=>j("pack_action",e)})]})]})}function ei({packs:e,disabled:r,onChanged:n,onError:a}){let[o,l]=(0,s.useState)(""),[i,c]=(0,s.useState)(null),[u,p]=(0,s.useState)(null),[x,h]=(0,s.useState)(null),{capture:b}=(0,F.usePostHog)(),j=async()=>{if(o.trim()){c("preview"),h(null);try{let e=await R(o);if(!e.ok)return void a(e.error??"Could not read that pack.");h(e)}finally{c(null)}}},y=async(e,t)=>{c(e),p(null);try{let e=await t();if(!e.ok)return void a(e.error??"Could not install that pack.");p(e.version?`${e.id}@${e.version}`:e.id??null),l(""),n()}catch(e){a(e instanceof Error?e.message:"Could not install that pack.")}finally{c(null)}};return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 bg-muted/20 border-b border-border/50",children:[(0,t.jsx)("span",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:"Policy Packs"}),(0,t.jsx)("span",{className:"text-[0.7rem] text-muted-foreground",children:0===e.length?"none installed":`${e.length} installed`})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)("input",{value:o,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&o.trim()&&!i&&(b("pack_install_submitted",{via:"input"}),y("input",()=>I(o)))},placeholder:"core · acme/ops · acme/ops@v1.2.0 · a release URL",spellCheck:!1,disabled:r||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,t.jsx)(q.Button,{size:"sm",variant:"outline",disabled:r||null!==i||0===o.trim().length,onClick:()=>{b("pack_preview_submitted",{}),j()},children:"preview"===i?"Reading…":"Preview"}),(0,t.jsxs)(q.Button,{size:"sm",variant:"default",disabled:r||null!==i||0===o.trim().length,onClick:()=>{b("pack_install_submitted",{via:"button"}),y("input",()=>I(o))},children:[(0,t.jsx)(m,{className:"h-3.5 w-3.5"}),"input"===i?"Installing…":"Install"]})]}),x?.ok&&(0,t.jsxs)("div",{className:"border-b border-border/20 bg-muted/5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[(0,t.jsx)(d,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsxs)("span",{className:"text-xs font-mono text-foreground",children:[x.id,"@",x.version]}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[x.policies?.length??0," policies ·"," ",x.policies?.filter(e=>e.defaultEnabled).length??0," on by default"]}),"observe"===x.effect&&(0,t.jsx)("span",{className:"text-[0.65rem] uppercase tracking-wider text-amber-500",children:"observes only"}),(0,t.jsx)("button",{onClick:()=>h(null),className:"ml-auto text-muted-foreground/60 hover:text-foreground","aria-label":"Close preview",children:(0,t.jsx)(v.X,{className:"h-3.5 w-3.5"})})]}),(0,t.jsx)("div",{className:"max-h-64 overflow-y-auto",children:x.policies?.map(e=>(0,t.jsxs)("div",{className:"flex items-start gap-3 px-4 py-2 border-t border-border/10",children:[(0,t.jsx)("span",{className:`text-[0.65rem] uppercase tracking-wider w-14 shrink-0 mt-0.5 ${e.defaultEnabled?"text-emerald-500":"text-muted-foreground/50"}`,children:e.defaultEnabled?"default":"opt-in"}),(0,t.jsx)("span",{className:"text-xs font-mono text-foreground w-56 shrink-0 truncate",children:e.name}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground leading-relaxed min-w-0",children:[e.description,(0,t.jsx)("span",{className:"block text-[0.65rem] text-muted-foreground/40 font-mono mt-0.5",children:e.category})]})]},e.name))}),(0,t.jsx)("div",{className:"px-4 py-2.5 border-t border-border/20",children:(0,t.jsxs)(q.Button,{size:"sm",variant:"default",disabled:r||null!==i,onClick:()=>{b("pack_install_submitted",{via:"preview"}),y("input",()=>I(o)).then(()=>h(null))},children:[(0,t.jsx)(m,{className:"h-3.5 w-3.5"}),"Install its defaults"]})})]}),(0,t.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,t.jsx)("span",{className:"text-[0.7rem] text-muted-foreground/70 mr-1",children:"Failproof AI policies:"}),(0,t.jsx)(q.Button,{size:"sm",variant:"outline",disabled:r||null!==i,onClick:()=>{b("pack_install_submitted",{via:"ours"}),y("ours",()=>I("FailproofAI/policies"))},children:"ours"===i?"Installing…":"Install from GitHub"}),(0,t.jsx)(q.Button,{size:"sm",variant:"outline",disabled:r||null!==i,onClick:()=>{b("pack_install_submitted",{via:"bundled"}),y("bundled",()=>U())},children:"bundled"===i?"Installing…":"Install offline copy"}),u&&(0,t.jsxs)("span",{className:"text-[0.7rem] text-emerald-500 font-mono",children:["installed ",u]})]}),e.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20",children:[(0,t.jsx)(d,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,t.jsxs)("span",{className:"text-xs font-mono text-foreground truncate",children:[e.id,e.version?`@${e.version}`:""]}),"observe"===e.effect&&(0,t.jsx)("span",{className:"text-[0.65rem] uppercase tracking-wider text-amber-500",children:"observing"}),(0,t.jsx)("span",{className:"text-[0.65rem] text-muted-foreground/50 font-mono truncate hidden lg:inline",children:e.source}),(0,t.jsx)("button",{onClick:()=>void y(e.id,()=>$(e.id)),disabled:r||null!==i,className:"ml-auto text-muted-foreground/60 hover:text-foreground disabled:opacity-40","aria-label":`Remove ${e.id}`,children:(0,t.jsx)(f,{className:"h-3.5 w-3.5"})})]}),e.error?(0,t.jsxs)("div",{className:"flex items-start gap-2 px-4 py-2.5 border-b border-border/20 bg-amber-500/5",children:[(0,t.jsx)(g,{className:"h-3.5 w-3.5 text-amber-500 shrink-0 mt-0.5"}),(0,t.jsxs)("p",{className:"text-[0.7rem] text-muted-foreground leading-relaxed",children:["This pack will not load: ",e.error]})]}):(0,t.jsx)("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-border/20",children:(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:[e.policies.filter(e=>e.enabled).length," of ",e.policies.length," on — listed by category above"]})})]},`${e.id}@${e.version}`))]})}function ec({activeTab:e,onChange:s}){return(0,t.jsx)("div",{className:"tabs",style:{padding:0,marginBottom:24},children:[{id:"activity",label:"Activity"},{id:"policies",label:"Configure"}].map(r=>(0,t.jsx)("button",{type:"button",onClick:()=>s(r.id),className:`tab${e===r.id?" is-active":""}`,children:r.label.toLowerCase()},r.id))})}e.s(["default",0,function({initialTab:e="activity"}){let r=(0,z.useUrlParams)(),{capture:n}=(0,F.usePostHog)(),[a,o]=(0,s.useState)(e),[l,i]=(0,s.useState)(void 0),[c,d]=(0,s.useState)(null),[m,u]=(0,s.useState)([]);(0,s.useEffect)(()=>{_().then(e=>{i(e.clis.some(e=>e.installed)),d({enabled:e.enabledPolicies.length,total:e.policies.length+(e.customPolicies?.length??0)+(e.conventionPolicies?.reduce((e,t)=>e+t.policies.length,0)??0)}),u(e.clis.filter(e=>e.installed).map(e=>e.label))}).catch(()=>i(void 0))},[]);let p=0===m.length?"Policy evaluations":m.length<=3?`Policy evaluations across ${m.join(", ")}`:`Policy evaluations across ${m.length} agents`,x=e=>{e!==a&&n("policies_tab_switched",{tab:e,from_tab:a}),o(e),r.setAll({tab:"activity"===e?void 0:e})};return(0,t.jsx)("main",{className:"report",children:(0,t.jsxs)("section",{className:"section","data-screen-label":"policies",children:[(0,t.jsx)("h2",{style:{fontFamily:"var(--font-mono)",fontSize:24,fontWeight:600,letterSpacing:"-0.01em",color:"var(--ink)",margin:"0 0 16px"},children:"activity"===a?"Policies":"Configure Policies"}),"activity"===a?(0,t.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:32,flexWrap:"wrap",margin:"0 0 24px"},children:[(0,t.jsxs)("div",{style:{fontFamily:"var(--font-mono)",fontSize:14,color:"var(--ink-2)",lineHeight:1.7,flex:"1 1 480px",minWidth:0},children:[p,c&&(0,t.jsxs)("span",{style:{color:"var(--dim)"},children:[" · ","enabled policies"," ",(0,t.jsxs)("span",{style:{color:"var(--ink)",fontVariantNumeric:"tabular-nums"},children:[c.enabled,"/",c.total]})]})]}),(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:6,flex:"0 0 auto"},children:[(0,t.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,t.jsx)("button",{type:"button",className:"btn btn-primary",onClick:()=>x("policies"),children:"[ configure policies → ]"})]})]}):(0,t.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,t.jsx)(ec,{activeTab:a,onChange:x}),"activity"===a?(0,t.jsx)(er,{hooksInstalled:l,onSwitchTab:x}):(0,t.jsx)(el,{onHooksInstallChange:i})]})})}],64245)}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,24380,e=>{"use strict";var t=e.i(43476),r=e.i(71645),n=e.i(8734),o=e.i(89664),l=e.i(47163);function
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,24380,e=>{"use strict";var t=e.i(43476),r=e.i(71645),n=e.i(8734),o=e.i(89664),l=e.i(47163);function u(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t);try{return t.select(),document.execCommand("copy")}finally{document.body.removeChild(t)}}e.s(["CopyButton",0,function({text:e,className:a}){let[i,c]=(0,r.useState)(!1),s=(0,r.useRef)(void 0);(0,r.useEffect)(()=>()=>{s.current&&clearTimeout(s.current)},[]);let d=(0,r.useCallback)(()=>{s.current&&clearTimeout(s.current),c(!0),s.current=setTimeout(()=>c(!1),2e3)},[]),f=(0,r.useCallback)(async()=>{try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(e);else if(!u(e))throw Error("Both clipboard methods failed");d()}catch(t){console.error("Failed to copy to clipboard:",t);try{u(e)&&d()}catch{}}},[e,d]);return(0,t.jsx)("button",{type:"button",onClick:f,title:"Copy to clipboard",className:(0,l.cn)("inline-flex items-center justify-center rounded p-1 text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors",a),children:i?(0,t.jsx)(o.Check,{className:"w-3.5 h-3.5 text-green-500"}):(0,t.jsx)(n.Copy,{className:"w-3.5 h-3.5"})})}])},69186,e=>{"use strict";var t=e.i(43476);let r=(0,e.i(70703).default)(()=>e.A(79348),{loadableGenerated:{modules:[5780]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"bg-card border border-border rounded-lg p-4 shadow-sm",children:(0,t.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,t.jsx)("div",{className:"animate-pulse text-muted-foreground",children:"Loading log viewer..."})})})});e.s(["default",0,function({entries:e,projectName:n,sessionId:o}){return(0,t.jsx)(r,{entries:e,projectName:n,sessionId:o})}])},79348,e=>{e.v(t=>Promise.all(["static/chunks/0ofdelz65_517.js","static/chunks/1_1eb_149xyt9.js"].map(t=>e.l(t))).then(()=>t(5780)))},89664,e=>{"use strict";let t=(0,e.i(56420).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);e.s(["Check",0,t],89664)},8734,e=>{"use strict";let t=(0,e.i(56420).default)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);e.s(["Copy",0,t],8734)},90317,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n={bindSnapshot:function(){return c},createAsyncLocalStorage:function(){return i},createSnapshot:function(){return s}};for(var o in n)Object.defineProperty(r,o,{enumerable:!0,get:n[o]});let l=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class u{disable(){throw l}getStore(){}run(){throw l}exit(){throw l}enterWith(){throw l}static bind(e){return e}}let a="u">typeof globalThis&&globalThis.AsyncLocalStorage;function i(){return a?new a:new u}function c(e){return a?a.bind(e):u.bind(e)}function s(){return a?a.snapshot():function(e,...t){return e(...t)}}},42344,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"workAsyncStorageInstance",{enumerable:!0,get:function(){return n}});let n=(0,e.r(90317).createAsyncLocalStorage)()},63599,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"workAsyncStorage",{enumerable:!0,get:function(){return n.workAsyncStorageInstance}});let n=e.r(42344)},9885,(e,t,r)=>{"use strict";function n(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"encodeURIPath",{enumerable:!0,get:function(){return n}})},67585,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"BailoutToCSR",{enumerable:!0,get:function(){return o}});let n=e.r(32061);function o({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new n.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},52157,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"PreloadChunks",{enumerable:!0,get:function(){return i}});let n=e.r(43476),o=e.r(74080),l=e.r(63599),u=e.r(9885),a=e.r(43369);function i({moduleIds:e}){if("u">typeof window)return null;let t=l.workAsyncStorage.getStore();if(void 0===t)return null;let r=[];if(t.reactLoadableManifest&&e){let n=t.reactLoadableManifest;for(let t of e){if(!n[t])continue;let e=n[t].files;r.push(...e)}}if(0===r.length)return null;let c=(0,a.getAssetTokenQuery)();return(0,n.jsx)(n.Fragment,{children:r.map(e=>{let r=`${t.assetPrefix}/_next/${(0,u.encodeURIPath)(e)}${c}`;return e.endsWith(".css")?(0,n.jsx)("link",{precedence:"dynamic",href:r,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,o.preload)(r,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},69093,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return c}});let n=e.r(43476),o=e.r(71645),l=e.r(67585),u=e.r(52157);function a(e){return{default:e&&"default"in e?e.default:e}}let i={loader:()=>Promise.resolve(a(()=>null)),loading:null,ssr:!0},c=function(e){let t={...i,...e},r=(0,o.lazy)(()=>t.loader().then(a)),c=t.loading;function s(e){let a=c?(0,n.jsx)(c,{isLoading:!0,pastDelay:!0,error:null}):null,i=!t.ssr||!!t.loading,s=i?o.Suspense:o.Fragment,d=t.ssr?(0,n.jsxs)(n.Fragment,{children:["u"<typeof window?(0,n.jsx)(u.PreloadChunks,{moduleIds:t.modules}):null,(0,n.jsx)(r,{...e})]}):(0,n.jsx)(l.BailoutToCSR,{reason:"next/dynamic",children:(0,n.jsx)(r,{...e})});return(0,n.jsx)(s,{...i?{fallback:a}:{},children:d})}return s.displayName="LoadableComponent",s}},70703,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"default",{enumerable:!0,get:function(){return o}});let n=e.r(55682)._(e.r(69093));function o(e,t){let r={};"function"==typeof e&&(r.loader=e);let o={...r,...t};return(0,n.default)({...o,modules:o.loadableGenerated?.modules})}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)}]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use server";
|
|
2
2
|
|
|
3
|
+
import { readPackPolicyParams } from "@/src/hooks/policy-evaluator";
|
|
3
4
|
import { configuredCustomPolicyPaths, readMergedHooksConfig } from "@/src/hooks/hooks-config";
|
|
4
5
|
import { hooksInstalledInSettings, getSettingsPath } from "@/src/hooks/manager";
|
|
5
6
|
import { listIntegrations } from "@/src/hooks/integrations";
|
|
@@ -258,7 +259,13 @@ export async function getHooksConfigAction(): Promise<HooksConfigPayload> {
|
|
|
258
259
|
{ type: v.type, description: v.description, default: v.default },
|
|
259
260
|
]),
|
|
260
261
|
),
|
|
261
|
-
|
|
262
|
+
// The evaluator's OWN lookup, called rather than re-implemented.
|
|
263
|
+
// This side had its own copy with an unscoped bare-name
|
|
264
|
+
// fallback, so a stranger's pack that happened to declare
|
|
265
|
+
// `block-sudo` was shown our pack's saved parameters — which the
|
|
266
|
+
// modal then seeded its inputs from and Save wrote back under
|
|
267
|
+
// the stranger's key, making the wrong display real.
|
|
268
|
+
currentParams: readPackPolicyParams(config.policyParams, pack.id, policy.name) ?? {},
|
|
262
269
|
}
|
|
263
270
|
: {}),
|
|
264
271
|
});
|
|
@@ -86,7 +86,18 @@ export async function addBundledPackWebAction(): Promise<PackActionResult> {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
export async function removePackWebAction(id: string): Promise<PackActionResult> {
|
|
89
|
-
|
|
89
|
+
// The dashboard always sends an id it read off an installed pack, so the
|
|
90
|
+
// ambiguous case is unreachable from here — caught anyway, because an
|
|
91
|
+
// uncaught throw in a server action reaches the browser as a generic failure
|
|
92
|
+
// with the reason stripped, and "something went wrong" is the least useful
|
|
93
|
+
// thing this could say.
|
|
94
|
+
let removed: string | null;
|
|
95
|
+
try {
|
|
96
|
+
removed = removePack(id);
|
|
97
|
+
} catch (err) {
|
|
98
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
99
|
+
}
|
|
100
|
+
return removed ? { ok: true, id: removed } : { ok: false, error: `No installed pack with id ${id}` };
|
|
90
101
|
}
|
|
91
102
|
|
|
92
103
|
/**
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
import type { PackPreviewResult } from "@/app/actions/pack-actions";
|
|
26
26
|
import { installHooksWebAction, removeHooksWebAction } from "@/app/actions/install-hooks-web";
|
|
27
27
|
import { updatePolicyParamsAction } from "@/app/actions/update-policy-params";
|
|
28
|
+
import { packPolicyParamKey } from "@/src/hooks/pack-param-key";
|
|
28
29
|
import { useAutoRefresh } from "@/contexts/AutoRefreshContext";
|
|
29
30
|
import { usePostHog } from "@/contexts/PostHogContext";
|
|
30
31
|
import { useUrlParams } from "@/lib/use-url-params";
|
|
@@ -1284,13 +1285,26 @@ function PoliciesTab({ onHooksInstallChange }: { onHooksInstallChange?: (install
|
|
|
1284
1285
|
return;
|
|
1285
1286
|
}
|
|
1286
1287
|
setHooksWarning(null);
|
|
1288
|
+
// A policy name is unique only WITHIN a pack, so `config.policies` — the
|
|
1289
|
+
// flat list across every installed pack — can hold two `block-sudo` rows.
|
|
1290
|
+
// The write below targets (packId, name); matching the optimistic update on
|
|
1291
|
+
// the name alone flipped the OTHER pack's row too, showing a change nothing
|
|
1292
|
+
// persisted until the next reload silently undid it.
|
|
1293
|
+
//
|
|
1294
|
+
// Matched on the pair with no fallback to the name. `PolicyInfo.packId` is
|
|
1295
|
+
// required — every policy comes from a pack — and `togglePackPolicyAction`
|
|
1296
|
+
// takes a `string`, so a row without one is a type error at the call below,
|
|
1297
|
+
// not a case to widen for here. A `packId === undefined ||` guard would only
|
|
1298
|
+
// ever restore the conflation this line exists to remove.
|
|
1287
1299
|
// Optimistic update
|
|
1288
1300
|
setConfig((prev) => {
|
|
1289
1301
|
if (!prev) return prev;
|
|
1290
1302
|
return {
|
|
1291
1303
|
...prev,
|
|
1292
1304
|
policies: prev.policies.map((p) =>
|
|
1293
|
-
p.name === name
|
|
1305
|
+
p.name === name && p.packId === policy.packId
|
|
1306
|
+
? { ...p, enabled: !currentlyEnabled }
|
|
1307
|
+
: p,
|
|
1294
1308
|
),
|
|
1295
1309
|
packs: prev.packs.map((pack) =>
|
|
1296
1310
|
pack.id === policy.packId
|
|
@@ -1306,7 +1320,19 @@ function PoliciesTab({ onHooksInstallChange }: { onHooksInstallChange?: (install
|
|
|
1306
1320
|
});
|
|
1307
1321
|
startTransition(async () => {
|
|
1308
1322
|
try {
|
|
1309
|
-
|
|
1323
|
+
// The RESULT, not just the absence of a throw. This action reports a
|
|
1324
|
+
// missing pack, an unreadable manifest, or a policy an intervening pack
|
|
1325
|
+
// update removed by RETURNING `{ ok: false, error }` — deliberately,
|
|
1326
|
+
// because none of those is exceptional. Awaiting and discarding it left
|
|
1327
|
+
// the optimistic row showing enforcement that was never written: the
|
|
1328
|
+
// dashboard said a policy was on, and nothing was running it. Every
|
|
1329
|
+
// reachable path there is a stale dashboard, which is the ordinary
|
|
1330
|
+
// state of a tab somebody left open.
|
|
1331
|
+
const result = await togglePackPolicyAction(policy.packId, name, !currentlyEnabled);
|
|
1332
|
+
if (!result.ok) {
|
|
1333
|
+
fireActionError("policy_toggle", result.error ?? "Failed to save policy change.");
|
|
1334
|
+
reload();
|
|
1335
|
+
}
|
|
1310
1336
|
} catch {
|
|
1311
1337
|
fireActionError("policy_toggle", "Failed to save policy change.");
|
|
1312
1338
|
reload();
|
|
@@ -1380,7 +1406,14 @@ function PoliciesTab({ onHooksInstallChange }: { onHooksInstallChange?: (install
|
|
|
1380
1406
|
|
|
1381
1407
|
const handleSaveParams = (params: Record<string, unknown>) => {
|
|
1382
1408
|
if (!configuringPolicy) return;
|
|
1383
|
-
|
|
1409
|
+
// A PACK policy is saved under the stable pack-qualified key, because the
|
|
1410
|
+
// bare name is not what the evaluator looks up — it registers pack policies
|
|
1411
|
+
// as `pack/<id>@<version>/<name>`, so a bare key was written, displayed as
|
|
1412
|
+
// saved, and ignored at runtime. Version-less on purpose: a key carrying
|
|
1413
|
+
// the version would be orphaned by the publisher's next release.
|
|
1414
|
+
const policyName = configuringPolicy.packId
|
|
1415
|
+
? packPolicyParamKey(configuringPolicy.packId, configuringPolicy.name)
|
|
1416
|
+
: configuringPolicy.name;
|
|
1384
1417
|
setConfiguringPolicy(null);
|
|
1385
1418
|
startTransition(async () => {
|
|
1386
1419
|
try {
|
|
@@ -1642,8 +1675,12 @@ function PoliciesTab({ onHooksInstallChange }: { onHooksInstallChange?: (install
|
|
|
1642
1675
|
</div>
|
|
1643
1676
|
{/* Policy rows */}
|
|
1644
1677
|
{policies.map((policy) => (
|
|
1678
|
+
// Keyed by pack AND name: two installed packs may each declare
|
|
1679
|
+
// `block-sudo` in the same category, and a bare name key made
|
|
1680
|
+
// them one React key — React warns and reuses the first row's
|
|
1681
|
+
// state for the second.
|
|
1645
1682
|
<div
|
|
1646
|
-
key={policy.name}
|
|
1683
|
+
key={`${policy.packId}/${policy.name}`}
|
|
1647
1684
|
className="flex items-start gap-3 px-4 py-3 border-b border-border/20 hover:bg-muted/20 transition-colors"
|
|
1648
1685
|
>
|
|
1649
1686
|
<div className="mt-0.5 shrink-0">
|