failproofai 1.0.4-beta.2 → 1.0.4-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  6. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  7. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  10. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
  11. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.rsc +14 -14
  18. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
  19. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
  20. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  21. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/audit/run/route.js +1 -1
  23. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +5 -5
  31. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  33. package/.next/standalone/.next/server/app/index.html +1 -1
  34. package/.next/standalone/.next/server/app/index.rsc +14 -14
  35. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +13 -13
  36. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +14 -14
  37. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  38. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  39. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  40. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  41. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
  42. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  44. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  45. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  46. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  47. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  48. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  49. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  50. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  51. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  52. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  53. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  54. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -4
  55. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  57. package/.next/standalone/.next/server/chunks/{[externals]__1lh7m5d._.js → [externals]__0v1hz15._.js} +1 -1
  58. package/.next/standalone/.next/server/chunks/{[externals]__1rqkg_y._.js → [externals]__1nb206a._.js} +1 -1
  59. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0--lkk6._.js +1 -1
  60. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
  61. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0q0qzx1._.js +1 -1
  62. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1le9jqc._.js +1 -1
  63. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1p-qi2t._.js +1 -1
  64. package/.next/standalone/.next/server/chunks/{_08w6xzm._.js → _0otft92._.js} +2 -2
  65. package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
  66. package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
  67. package/.next/standalone/.next/server/chunks/_1ek68ln._.js +3 -3
  68. package/.next/standalone/.next/server/chunks/_1vslkoe._.js +1 -1
  69. package/.next/standalone/.next/server/chunks/lib_factory-projects_ts_1eo_bk-._.js +1 -1
  70. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
  71. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__013jr2b._.js +2 -2
  72. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01wy8d-._.js +2 -2
  73. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02npjtd._.js +2 -2
  74. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0da85px._.js +2 -2
  75. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ftmoxc._.js +2 -2
  76. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0oa1lav._.js +1 -1
  77. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0p-5p8u._.js +2 -2
  78. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s740oi._.js +2 -2
  79. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0yl9wb5._.js +3 -0
  80. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1p2otjt._.js +2 -2
  81. package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
  82. package/.next/standalone/.next/server/chunks/ssr/_0guxnh-._.js +23 -0
  83. package/.next/standalone/.next/server/chunks/ssr/_0oq1dh6._.js +1 -1
  84. package/.next/standalone/.next/server/chunks/ssr/_1_ozgif._.js +1 -1
  85. package/.next/standalone/.next/server/chunks/ssr/_1es2j7i._.js +13 -0
  86. package/.next/standalone/.next/server/chunks/ssr/_1u8-lu2._.js +1 -1
  87. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +2 -2
  88. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
  89. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
  90. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
  91. package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +1 -1
  92. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  93. package/.next/standalone/.next/server/pages/404.html +1 -1
  94. package/.next/standalone/.next/server/pages/500.html +1 -1
  95. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  96. package/.next/standalone/.next/server/server-reference-manifest.json +22 -22
  97. package/.next/standalone/.next/static/chunks/{04r6ch8uf_n8m.js → 04o5zfl7p5lhx.js} +1 -1
  98. package/.next/standalone/.next/static/chunks/{0o-hh5_turzlz.css → 0jpd8dv2vk930.css} +1 -1
  99. package/.next/standalone/.next/static/chunks/{2ej3b8gk5ittu.js → 0po8n4tyotjf2.js} +1 -1
  100. package/.next/standalone/.next/static/chunks/0qx7gav1c2_vu.js +1 -0
  101. package/.next/standalone/.next/static/chunks/{2aquitk72k2op.js → 17tfki9x5rd_7.js} +1 -1
  102. package/.next/standalone/.next/static/chunks/{010bv1w6j171t.js → 1i-i0pxg9q_8y.js} +1 -1
  103. package/.next/standalone/.next/static/chunks/{32spub4wqjem-.js → 2bxr2_2h4kaqq.js} +1 -1
  104. package/.next/standalone/.next/static/chunks/{0wz8yftk18ts2.js → 323cyb3a2s06y.js} +1 -1
  105. package/.next/standalone/.next/static/chunks/{1pb1oztsbwcss.js → 364cqbpeg1y5i.js} +1 -1
  106. package/.next/standalone/.next/static/chunks/{3m4upvybtrexd.js → 38dqur43qthrl.js} +1 -1
  107. package/.next/standalone/.next/static/chunks/{2bi_1y0a_smt7.js → 42gwu2bsz4ske.js} +2 -2
  108. package/.next/standalone/app/actions/get-leaks.ts +10 -1
  109. package/.next/standalone/app/audit/_components/audit-dashboard.tsx +29 -2
  110. package/.next/standalone/app/audit/_components/leak-section.tsx +15 -2
  111. package/.next/standalone/app/audit/audit-styles.css +18 -0
  112. package/.next/standalone/lib/sqlite-reader.ts +78 -1
  113. package/.next/standalone/package.json +10 -10
  114. package/.next/standalone/server.js +1 -1
  115. package/bin/failproofai.mjs +1 -1
  116. package/dist/cli.mjs +397 -225
  117. package/dist/worker.mjs +81 -35
  118. package/lib/sqlite-reader.ts +78 -1
  119. package/package.json +10 -10
  120. package/pi-extension/index.ts +19 -4
  121. package/src/audit/cache.ts +6 -0
  122. package/src/audit/cli-adapters/claude.ts +13 -0
  123. package/src/audit/cli-login.ts +4 -1
  124. package/src/audit/cli.ts +84 -59
  125. package/src/audit/index.ts +149 -8
  126. package/src/audit/leak-notice.ts +99 -1
  127. package/src/audit/leak-scan.ts +20 -44
  128. package/src/audit/leak-store.ts +49 -1
  129. package/src/audit/redact-example.ts +60 -5
  130. package/src/audit/types.ts +6 -0
  131. package/src/hooks/handler.ts +30 -10
  132. package/src/hooks/integrations.ts +14 -0
  133. package/src/hooks/notice.ts +45 -9
  134. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0rgu2r3._.js +0 -3
  135. package/.next/standalone/.next/server/chunks/ssr/_0-oij9d._.js +0 -23
  136. package/.next/standalone/.next/static/chunks/0zebh1n9jkfbt.js +0 -1
  137. /package/.next/standalone/.next/static/{aKNv4Kmv98Xpwns0Xa-C- → P6icI2V2PvVuePJrqjHCr}/_buildManifest.js +0 -0
  138. /package/.next/standalone/.next/static/{aKNv4Kmv98Xpwns0Xa-C- → P6icI2V2PvVuePJrqjHCr}/_clientMiddlewareManifest.js +0 -0
  139. /package/.next/standalone/.next/static/{aKNv4Kmv98Xpwns0Xa-C- → P6icI2V2PvVuePJrqjHCr}/_ssgManifest.js +0 -0
@@ -154,6 +154,19 @@ async function applyDecision(result, ctx, eventName) {
154
154
  if (out && out.decision && out.decision.behavior === "deny") {
155
155
  throw new Error((out.decision.message) || "Blocked by failproofai");
156
156
  }
157
+ const notice = parsed.failproofaiNotice;
158
+ if (typeof notice === "string" && notice && ctx && ctx.client && ctx.client.tui) {
159
+ try {
160
+ await ctx.client.tui.showToast({
161
+ body: {
162
+ title: "failproofai audit",
163
+ message: notice,
164
+ variant: "warning",
165
+ duration: 12_000,
166
+ },
167
+ });
168
+ } catch { /* a courtesy notice must never break the host hook */ }
169
+ }
157
170
  // Forward additional context as a prompt to the session. For Stop /
158
171
  // SubagentStop the prompt is the only force-retry channel (session.idle
159
172
  // already fired), so AWAIT to ensure the SDK round-trip completes before
@@ -1,3 +1,3 @@
1
- module.exports=[21776,a=>{"use strict";var b=a.i(36359),c=a.i(7292);a.s([],84740),a.i(84740),a.s(["000ae5b9f039195740b0697383b66ef36475abe12d",()=>b.getTelemetryConfig,"60d4b56a98077468792db89d8812f1e5e786583628",()=>c.searchHookActivityAction],21776)},2726,a=>{a.v(b=>Promise.all(["server/chunks/ssr/[externals]__0vmspq5._.js","server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_11bnuzn._.js"].map(b=>a.l(b))).then(()=>b(74493)))}];
1
+ module.exports=[21776,a=>{"use strict";var b=a.i(36359),c=a.i(7292);a.s([],84740),a.i(84740),a.s(["000c85ddbcc0c76485115f8fdbd1792f16d26c97bb",()=>b.getTelemetryConfig,"609c318d728a87a53cb332ec72a48951a1f2cd65c2",()=>c.searchHookActivityAction],21776)},2726,a=>{a.v(b=>Promise.all(["server/chunks/ssr/[externals]__0vmspq5._.js","server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_11bnuzn._.js"].map(b=>a.l(b))).then(()=>b(74493)))}];
2
2
 
3
3
  //# sourceMappingURL=_1u8-lu2._.js.map
@@ -1,4 +1,4 @@
1
- module.exports=[73338,a=>{"use strict";var b=a.i(36359),c=a.i(7292),d=a.i(37936),e=a.i(2157);a.i(66680);var f=a.i(50227);a.i(8674),a.i(1144);var g=a.i(75818),h=a.i(13095);async function i(){return function(a=Date.now()){let b,c,d=(c=process.env.FAILPROOFAI_STATE_DIR)?(0,f.resolve)(c,"sessions"):(0,g.sessionPauseDir)();if(!(0,e.existsSync)(d))return[];let h=[];try{b=(0,e.readdirSync)(d)}catch{return[]}for(let c of b)if(c.endsWith(".json"))try{let b=function(a){if(!a||"object"!=typeof a||1!==a.schemaVersion||"string"!=typeof a.sessionId||0===a.sessionId.length||!Number.isFinite(a.pausedAt)||!Number.isFinite(a.expiresAt))return null;let b=a.pausedAt,c=Number.isFinite(a.firstPausedAt)?a.firstPausedAt:b;return{schemaVersion:1,sessionId:a.sessionId,pausedAt:b,firstPausedAt:c,expiresAt:Math.min(a.expiresAt,c+288e5),setBy:"string"==typeof a.setBy?a.setBy:"unknown",..."string"==typeof a.cwd?{cwd:a.cwd}:{}}}(JSON.parse((0,e.readFileSync)((0,f.join)(d,c),"utf8")));if(!b||b.expiresAt<=a)continue;let{schemaVersion:g,...i}=b;h.push(i)}catch{}return h.sort((a,b)=>b.pausedAt-a.pausedAt)}()}(0,h.ensureServerEntryExports)([i]),(0,d.registerServerReference)(i,"00f2651d6c61b8af94fb61a3e35baa07db7a565f71",null);var j=a.i(17280);a.i(10695);var k=a.i(98378),l=a.i(69839),m=a.i(28120),n=a.i(74533),o=a.i(60526),p=a.i(91997),q=a.i(67121),r=a.i(92956),s=a.i(15638);class t extends Error{exitCode;constructor(a,b=1){super(a),this.name="CliError",this.exitCode=b}}a.i(89790);var u=a.i(9909);a.i(1459);let v=new Set(r.BUILTIN_POLICIES.map(a=>a.name));function w(a,b){return q.claudeCode.getSettingsPath(a,b)}function x(a){let b=[],c=[],d=[],e=[];try{e=(0,u.readInstalledPacks)().packs}catch{}let f=(a,b)=>e.filter(b=>null===a||b.id===a).filter(a=>a.policies.some(a=>a.name===b)).map(a=>({packId:a.id,packVersion:a.version,name:b,disabledKey:`pack:${a.id}@${a.version}:${b}`}));for(let e of a){let a=f(null,e);if(1===a.length){c.push(a[0]);continue}if(a.length>1)throw new t(`"${e}" is declared by ${a.length} installed packs.
1
+ module.exports=[73338,a=>{"use strict";var b=a.i(36359),c=a.i(7292),d=a.i(37936),e=a.i(2157);a.i(66680);var f=a.i(50227);a.i(8674),a.i(1144);var g=a.i(75818),h=a.i(13095);async function i(){return function(a=Date.now()){let b,c,d=(c=process.env.FAILPROOFAI_STATE_DIR)?(0,f.resolve)(c,"sessions"):(0,g.sessionPauseDir)();if(!(0,e.existsSync)(d))return[];let h=[];try{b=(0,e.readdirSync)(d)}catch{return[]}for(let c of b)if(c.endsWith(".json"))try{let b=function(a){if(!a||"object"!=typeof a||1!==a.schemaVersion||"string"!=typeof a.sessionId||0===a.sessionId.length||!Number.isFinite(a.pausedAt)||!Number.isFinite(a.expiresAt))return null;let b=a.pausedAt,c=Number.isFinite(a.firstPausedAt)?a.firstPausedAt:b;return{schemaVersion:1,sessionId:a.sessionId,pausedAt:b,firstPausedAt:c,expiresAt:Math.min(a.expiresAt,c+288e5),setBy:"string"==typeof a.setBy?a.setBy:"unknown",..."string"==typeof a.cwd?{cwd:a.cwd}:{}}}(JSON.parse((0,e.readFileSync)((0,f.join)(d,c),"utf8")));if(!b||b.expiresAt<=a)continue;let{schemaVersion:g,...i}=b;h.push(i)}catch{}return h.sort((a,b)=>b.pausedAt-a.pausedAt)}()}(0,h.ensureServerEntryExports)([i]),(0,d.registerServerReference)(i,"00ed7012cd02c771c585849eee94d7a6053fea233a",null);var j=a.i(17280);a.i(10695);var k=a.i(98378),l=a.i(69839),m=a.i(28120),n=a.i(74533),o=a.i(60526),p=a.i(91997),q=a.i(67121),r=a.i(92956),s=a.i(15638);class t extends Error{exitCode;constructor(a,b=1){super(a),this.name="CliError",this.exitCode=b}}a.i(89790);var u=a.i(9909);a.i(1459);let v=new Set(r.BUILTIN_POLICIES.map(a=>a.name));function w(a,b){return q.claudeCode.getSettingsPath(a,b)}function x(a){let b=[],c=[],d=[],e=[];try{e=(0,u.readInstalledPacks)().packs}catch{}let f=(a,b)=>e.filter(b=>null===a||b.id===a).filter(a=>a.policies.some(a=>a.name===b)).map(a=>({packId:a.id,packVersion:a.version,name:b,disabledKey:`pack:${a.id}@${a.version}:${b}`}));for(let e of a){let a=f(null,e);if(1===a.length){c.push(a[0]);continue}if(a.length>1)throw new t(`"${e}" is declared by ${a.length} installed packs.
2
2
  Name the one you mean:
3
3
  `+a.map(a=>` ${a.packId}:${a.name}`).join("\n"));if(v.has(e)){b.push(e);continue}let g=e.lastIndexOf(":"),h=g>0?{packId:e.slice(0,g),name:e.slice(g+1)}:null,i=h?f(h.packId,h.name):f(null,e);if(1===i.length){c.push(i[0]);continue}if(i.length>1)throw new t(`"${e}" is declared by ${i.length} installed packs.
4
4
  Name the one you mean:
@@ -12,6 +12,6 @@ Run \`failproofai policies add FailproofAI/policies\` once you are online.`)}if(
12
12
  Enabled ${E.length} policy(ies): ${E.join(", ")}
13
13
  `),i)console.log("Custom hooks path cleared.");else if(K.customPoliciesPaths?.length||K.customPoliciesPath){let a=K.customPoliciesPaths??[K.customPoliciesPath];console.log(`Custom hooks paths: ${a.join(", ")}`)}let N=[];for(let a of G){let d=(0,q.getIntegration)(a),e=(0,q.settingsPathsFor)(d,b,c);try{for(let c of e){let e=d.readSettings(c);d.writeHookEntries(e,H,b),d.writeSettings(c,e),N.push({cli:a,path:c})}}catch(d){let c=d instanceof Error&&/EACCES|EPERM/.test(d.message)?"permission_denied":d instanceof Error&&/ENOENT|ENOTDIR/.test(d.message)?"path_not_found":"write_error";try{await (0,k.trackHookEvent)((0,l.getInstanceId)(),"hook_write_failed",{cli:a,scope:b,error_type:c})}catch{}throw d}}try{let a=new Set(E),c=E.filter(a=>!J.has(a)),e=[...J].filter(b=>!a.has(b)),f=(0,l.getInstanceId)();if(await (0,k.trackHookEvent)(f,"hooks_installed",{scope:b,cli:G,cli_count:G.length,policies:E,policy_count:E.length,policies_added:c,policies_removed:e,...g?{source:g}:{},platform:(0,o.platform)(),arch:(0,o.arch)(),os_release:(0,o.release)(),hostname_hash:(0,l.hashToId)((0,o.hostname)()),has_custom_hooks_path:!!(K.customPoliciesPaths?.length||K.customPoliciesPath),has_policy_params:!!(K.policyParams&&Object.keys(K.policyParams).length>0),param_policy_names:K.policyParams?Object.keys(K.policyParams):[],command_format:"project"===b?"npx":"absolute"}),d){let a=new Set(r.BUILTIN_POLICIES.filter(a=>a.beta).map(a=>a.name)),c=E.filter(b=>a.has(b));c.length>0&&await (0,k.trackHookEvent)(f,"beta_policies_installed",{scope:b,cli:G,beta_count:c.length,beta_policy_names:c,...g?{source:g}:{}})}}catch{}for(let{cli:a,path:c}of N){let d=(0,q.getIntegration)(a);console.log(`Failproof AI hooks installed for ${d.displayName} (${d.eventTypes.length} event types, scope: ${b}).`),console.log(`Settings: ${c}`)}"project"===b?(console.log("Command: npx -y failproofai"),console.log(`
14
14
  This file can be committed to git — no machine-specific paths.`)):console.log(`Binary: ${H}`);let O=(D=p.HOOK_SCOPES,F=new Set,D.filter(a=>{let b=w(a,c);return!F.has(b)&&(F.add(b),!0)})).filter(a=>a!==b).filter(a=>z(a,c));if(O.length>0){let a=O.map(a=>`${a} (${function(a){switch(a){case"user":return"~/.claude/settings.json";case"project":return"{cwd}/.claude/settings.json";case"local":return"{cwd}/.claude/settings.local.json"}}(a)})`).join(", ");console.log(),console.log(`\x1b[33mWarning: Failproof AI hooks are also installed at ${a}.\x1b[0m`),console.log("Having hooks in multiple scopes may cause duplicate policy evaluation."),console.log(`Use \`failproofai policies --uninstall --scope ${O[0]}\` to remove the other installation,`),console.log("or `failproofai policies` to see all scopes.");try{await (0,k.trackHookEvent)((0,l.getInstanceId)(),"multi_scope_warning_shown",{new_scope:b,existing_scopes:O,cli:G})}catch{}}}async function C(a,b="user",c,d){let f="all"===b?"user":b,g=d?.cli&&d.cli.length>0?[...new Set(d.cli)]:["claude"];if(d?.removeCustomHooks){let a=(0,m.readScopedHooksConfig)(f,c);delete a.customPoliciesPath,delete a.customPoliciesPaths,(0,m.writeScopedHooksConfig)(a,f,c),console.log("Custom hooks path cleared.")}if(a&&a.length>0&&(1!==a.length||"all"!==a[0])){let b=x(a);y(b.packs,!1,f,c);var h=a=b.builtins;let d=new Set(r.BUILTIN_POLICIES.filter(a=>a.alwaysOn).map(a=>a.name)),e=h.filter(a=>d.has(a));if(e.length>0)throw new t(`Cannot disable: ${e.join(", ")}
15
- This policy stops an agent from switching off failproofai itself, so it is always on and ships with the package. A guard the agent can disable by the means it is meant to prevent is not a guard.`);if(b.packs.length>0&&0===a.length)return}if(a&&a.length>0&&(1!==a.length||"all"!==a[0])){let e=(0,m.readScopedHooksConfig)(f,c),h=new Set(a),i=e.enabledPolicies.filter(a=>!h.has(a)),j=a.filter(a=>!e.enabledPolicies.includes(a));j.length>0&&console.log(`Warning: policy(ies) not currently enabled: ${j.join(", ")}`);let{policyParams:n,...p}=e,q=n?Object.fromEntries(Object.entries(n).filter(([a])=>!h.has(a))):null,r={...p,enabledPolicies:i,...q&&Object.keys(q).length>0?{policyParams:q}:{}};(0,m.writeScopedHooksConfig)(r,f,c);try{let c=(0,l.getInstanceId)(),f=a.filter(a=>e.enabledPolicies.includes(a));await (0,k.trackHookEvent)(c,"hooks_removed",{scope:b,cli:g,removal_mode:d?.betaOnly?"beta_policies":"policies",beta_only:d?.betaOnly??!1,policies_removed:f,removed_count:f.length,...d?.source?{source:d.source}:{},platform:(0,o.platform)(),arch:(0,o.arch)(),os_release:(0,o.release)(),hostname_hash:(0,l.hashToId)((0,o.hostname)())})}catch{}console.log(`Disabled ${a.length-j.length} policy(ies).`),console.log(`Remaining: ${i.length>0?i.join(", "):"(none)"}`);return}let i=(0,m.readScopedHooksConfig)(f,c),j=0,n=!1;for(let a of g){let d=(0,q.getIntegration)(a);for(let a of"all"===b?[...d.scopes]:d.scopes.includes(b)?[b]:[]){let f=(0,q.settingsPathsFor)(d,a,c).filter(a=>(0,e.existsSync)(a));if(0===f.length){"all"!==b&&1===g.length&&(console.log("No settings file found. Nothing to remove."),n=!0);continue}let h=0;for(let a of f){let c=d.removeHooksFromFile(a);h+=c,c>0&&"all"!==b&&(console.log(`Removed ${c} failproofai hook(s) from ${d.displayName} settings.`),console.log(`Settings: ${a}`))}if(0===h&&"all"!==b&&1===g.length){console.log("No hooks found in settings. Nothing to remove."),n=!0;continue}j+=h}}if(!n||0!==j){if("all"===b)for(let a of(console.log(`Removed ${j} failproofai hook(s) from all scopes.`),g)){let b=(0,q.getIntegration)(a);for(let a of b.scopes)for(let d of(0,q.settingsPathsFor)(b,a,c))console.log(` ${b.displayName} / ${a}: ${d}`)}try{let a=(0,l.getInstanceId)();await (0,k.trackHookEvent)(a,"hooks_removed",{scope:b,cli:g,removal_mode:"hooks",policies_removed:i.enabledPolicies,removed_count:j,...d?.source?{source:d.source}:{},platform:(0,o.platform)(),arch:(0,o.arch)(),os_release:(0,o.release)(),hostname_hash:(0,l.hashToId)((0,o.hostname)())})}catch{}if("all"===b)for(let a of p.HOOK_SCOPES){let b=(0,m.readScopedHooksConfig)(a,c);if(b.enabledPolicies.length>0||b.customPoliciesPaths?.length||b.customPoliciesPath||b.policyParams){let{customPoliciesPath:d,customPoliciesPaths:e,policyParams:f,...g}=b;(0,m.writeScopedHooksConfig)({...g,enabledPolicies:[]},a,c)}}else if(!p.HOOK_SCOPES.some(a=>z(a,c))){let{customPoliciesPath:a,customPoliciesPaths:b,policyParams:d,...e}=(0,m.readScopedHooksConfig)(f,c);(0,m.writeScopedHooksConfig)({...e,enabledPolicies:[]},f,c)}}}var D=a.i(24282),E=a.i(12714);async function F(a,b){let c=process.env.FAILPROOFAI_LAUNCH_CWD||process.cwd(),d=(0,f.resolve)((0,m.findProjectConfigDir)(c),".failproofai","policies"),e=(0,g.customPoliciesDir)(),h=[];for(let{scope:c,dir:g}of[{scope:"project",dir:d},...e===d?[]:[{scope:"user",dir:e}]]){let d=[];try{d=(0,s.discoverPolicyFiles)(g)}catch{continue}for(let e of d){if(b.has(e))continue;let d=[];try{d=(await G(e)).map(b=>{let d=(0,s.conventionPolicyId)(c,(0,f.basename)(e),b.name);return{...b,id:d,enabled:!a.has(d)}})}catch{}h.push({scope:c,file:(0,f.basename)(e),path:e,policies:d})}}return h}async function G(a){if(!(0,e.existsSync)(a))return[];let b=await (0,E.readFile)(a,"utf-8"),c=[],d=b.split(/customPolicies\.add\s*\(/);for(let a=1;a<d.length;a++){let b=d[a],e=b.match(/name:\s*["'`]([^"'`]+)["'`]/);if(!e)continue;let f=b.match(/description:\s*["'`]([^"'`]+)["'`]/),g=b.match(/events:\s*\[([^\]]+)\]/),h=g?g[1].replace(/["'`\s]/g,"").split(",").filter(Boolean).join(", "):void 0;c.push({name:e[1],description:f?.[1],eventScope:h,id:"",enabled:!0})}return c}async function H(){let a=process.env.FAILPROOFAI_LAUNCH_CWD||process.cwd(),b=(0,m.readMergedHooksConfig)(a),c=new Set(b.disabledCustomPolicies??[]),d=p.HOOK_SCOPES.filter(a=>z(a)),e=w(d[0]??"user"),g=(0,q.listIntegrations)().map(a=>({id:a.id,label:(0,D.getCliLabel)(a.id),installed:a.hooksInstalledInSettings("user"),settingsPath:a.getSettingsPath("user"),detected:a.detectInstalled()})),h=[],i=[];try{let a=(0,u.readInstalledPacks)();h=a.packs,i=a.errors}catch{}let k=[];for(let a of h){let d=a.enabled??a.policies.map(a=>a.name);for(let e of a.policies)k.push({name:e.name,description:e.description,category:e.category,defaultEnabled:e.defaultEnabled,beta:!1,enabled:d.includes(e.name)&&!c.has(`pack:${a.id}@${a.version}:${e.name}`),eventScope:function(a){let b=a.events?.join(", ")??"",c=a.toolNames?` \xb7 ${a.toolNames.join(", ")}`:"";return`${b}${c}`}(e.match),packId:a.id,packVersion:a.version,...e.params?{params:Object.fromEntries(Object.entries(e.params).map(([a,b])=>[a,{type:b.type,description:b.description,default:b.default}])),currentParams:function(a,b,c){if(!a)return;let d=a[`pack/${b}/${c}`];return d||(b.toLowerCase()===j.CORE_SOURCE.toLowerCase()?a[c]:void 0)}(b.policyParams,a.id,e.name)??{}}:{}})}let l=(0,m.configuredCustomPolicyPaths)(b),n=(0,m.findProjectConfigDir)(a),o=l.map(a=>(0,f.resolve)(n,a)),r=(await Promise.all(o.map(async a=>{try{return(await G(a)).map(b=>{let d=(0,s.customPolicyId)(a,b.name);return{...b,id:d,enabled:!c.has(d)}})}catch{return[]}}))).flat(),t=await F(c,new Set(o)),v=h.map(a=>{let b=a.enabled??a.policies.map(a=>a.name);return{id:a.id,version:a.version,source:a.source,effect:a.effect,policies:a.policies.map(d=>({name:d.name,description:d.description,category:d.category,enabled:b.includes(d.name)&&!c.has(`pack:${a.id}@${a.version}:${d.name}`)}))}});for(let a of i)v.push({id:a.id??"(unnamed pack)",version:"",source:"",effect:"enforce",policies:[],error:a.reason});return{enabledPolicies:b.enabledPolicies,installedScopes:d,settingsPath:e,clis:g,policies:k,customPoliciesPaths:l.length?l:void 0,customPoliciesPath:1===l.length?l[0]:void 0,customPolicies:r.length?r:void 0,conventionPolicies:t,packs:v}}async function I(a,b){let c=(0,m.readHooksConfig)(),d=new Set(c.enabledPolicies);b?d.add(a):d.delete(a),(0,m.writeHooksConfig)({...c,enabledPolicies:[...d]});try{let c=(0,l.getInstanceId)();await (0,k.trackHookEvent)(c,"policy_toggled",{policy_name:a,enabled:b,action:b?"enable":"disable",source:"web"})}catch{}}async function J(a,b){if(!a.startsWith("custom:")&&!a.startsWith("convention:"))throw Error("Invalid custom policy ID");let c=process.env.FAILPROOFAI_LAUNCH_CWD||process.cwd();if(b){for(let b of p.HOOK_SCOPES){let d=(0,m.readScopedHooksConfig)(b,c);if(!d.disabledCustomPolicies?.includes(a))continue;let e=d.disabledCustomPolicies.filter(b=>b!==a),f={...d,disabledCustomPolicies:e};e.length||delete f.disabledCustomPolicies,(0,m.writeScopedHooksConfig)(f,b,c)}return}let d=(0,m.readHooksConfig)(),e=new Set(d.disabledCustomPolicies??[]);e.add(a);let f={...d,disabledCustomPolicies:[...e]};e.size||delete f.disabledCustomPolicies,(0,m.writeHooksConfig)(f)}async function K(a,b){let c=a.trim();if(!c)return{ok:!1,error:"Enter a pack source, for example acme/ops"};try{let a=await (0,j.addPackFromSource)(c,b??{});return{ok:!0,id:a.id,version:a.version,enabled:a.enabled,available:a.available}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function L(){try{let a=await (0,j.addPack)(j.CORE_SOURCE);return{ok:!0,id:a.id,version:a.version,enabled:a.enabled,available:a.available}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function M(a){let b;try{b=(0,j.removePack)(a)}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}return b?{ok:!0,id:b}:{ok:!1,error:`No installed pack with id ${a}`}}async function N(a,b,c){let d=(0,j.setPackPolicyEnabled)(a,b,c);if(!d.ok)return{ok:!1,error:d.reason};if(c){let c=(0,u.readInstalledPacks)().packs.find(b=>b.id===a);if(c){let a=`pack:${c.id}@${c.version}:${b}`,d=(0,m.readHooksConfig)(),e=(d.disabledCustomPolicies??[]).filter(b=>b!==a);if(e.length!==(d.disabledCustomPolicies??[]).length){let{disabledCustomPolicies:a,...b}=d;(0,m.writeHooksConfig)(e.length>0?{...b,disabledCustomPolicies:e}:b)}}}return{ok:!0,id:a}}async function O(a){let b=a.trim();if(!b)return{ok:!1,error:"Enter a pack source, for example acme/ops"};try{let a=await (0,j.fetchPackPreview)(b);return{ok:!0,id:a.id,version:a.version,source:a.source,effect:a.effect,policies:a.policies.map(a=>({name:a.name,description:a.description,category:a.category,defaultEnabled:a.defaultEnabled}))}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function P(a="user",b){let c=(0,m.readHooksConfig)(),d=c.enabledPolicies.length>0?c.enabledPolicies:r.BUILTIN_POLICIES.filter(a=>a.defaultEnabled&&!a.beta).map(a=>a.name),e=b&&b.length>0?b:(0,q.detectInstalledClis)(),f=e.length>0?e:["claude"];await A(d,a,void 0,!1,"web",void 0,!1,f)}async function Q(a="user",b){let c=b&&b.length>0?b:(0,q.detectInstalledClis)(),d=c.length>0?c:["claude"];await C(void 0,a,void 0,{source:"web",cli:d})}async function R(a,b){let c=(0,m.readHooksConfig)(),d={...c.policyParams??{},[a]:b};(0,m.writeHooksConfig)({...c,policyParams:d});try{let c=(0,l.getInstanceId)();await (0,k.trackHookEvent)(c,"policy_params_updated",{policy_name:a,param_keys:Object.keys(b),source:"web"})}catch{}}(0,h.ensureServerEntryExports)([H]),(0,d.registerServerReference)(H,"00b6455f46f538e1e0f7872d2d9c77b0195511e731",null),(0,h.ensureServerEntryExports)([I,J]),(0,d.registerServerReference)(I,"604f1a4f8765fa231e831310dc35ebaeab568bf35d",null),(0,d.registerServerReference)(J,"605b9184ee6c68dfd18071b7cd687b276f30b2a74f",null),(0,h.ensureServerEntryExports)([K,L,M,N,O]),(0,d.registerServerReference)(K,"60aa1ce805f4904d4cdeccaaae4d76d4946ca5a9d2",null),(0,d.registerServerReference)(L,"005b82e13b42131f7051c1e6c50a53397488f2b941",null),(0,d.registerServerReference)(M,"40dc4f9e49f77dfc2297f895811fd835ef1ccbddbf",null),(0,d.registerServerReference)(N,"700600aa6454cbfa68fe29c391688523cd653e14c1",null),(0,d.registerServerReference)(O,"40d026a27c6a92fce5300b06bcf44fa1ce0e01709a",null),(0,h.ensureServerEntryExports)([P,Q]),(0,d.registerServerReference)(P,"60cae434e394962a07674df6f52f22fe7b332ed128",null),(0,d.registerServerReference)(Q,"60f12e9ff49120ca670f1fbff765bfd0768f125900",null),(0,h.ensureServerEntryExports)([R]),(0,d.registerServerReference)(R,"60eaa0aad0a7c8253b6935f0ea15b16a343173f09f",null),a.s([],96801),a.i(96801),a.s(["000ae5b9f039195740b0697383b66ef36475abe12d",()=>b.getTelemetryConfig,"005b82e13b42131f7051c1e6c50a53397488f2b941",0,L,"00b6455f46f538e1e0f7872d2d9c77b0195511e731",0,H,"00f2651d6c61b8af94fb61a3e35baa07db7a565f71",0,i,"40d026a27c6a92fce5300b06bcf44fa1ce0e01709a",0,O,"40dc4f9e49f77dfc2297f895811fd835ef1ccbddbf",0,M,"40fd166f9e08915649b8a51bc4f455a44462deefd1",()=>c.getHookActivityAction,"605b9184ee6c68dfd18071b7cd687b276f30b2a74f",0,J,"60aa1ce805f4904d4cdeccaaae4d76d4946ca5a9d2",0,K,"60cae434e394962a07674df6f52f22fe7b332ed128",0,P,"60d4b56a98077468792db89d8812f1e5e786583628",()=>c.searchHookActivityAction,"60eaa0aad0a7c8253b6935f0ea15b16a343173f09f",0,R,"60f12e9ff49120ca670f1fbff765bfd0768f125900",0,Q,"700600aa6454cbfa68fe29c391688523cd653e14c1",0,N],73338)}];
15
+ This policy stops an agent from switching off failproofai itself, so it is always on and ships with the package. A guard the agent can disable by the means it is meant to prevent is not a guard.`);if(b.packs.length>0&&0===a.length)return}if(a&&a.length>0&&(1!==a.length||"all"!==a[0])){let e=(0,m.readScopedHooksConfig)(f,c),h=new Set(a),i=e.enabledPolicies.filter(a=>!h.has(a)),j=a.filter(a=>!e.enabledPolicies.includes(a));j.length>0&&console.log(`Warning: policy(ies) not currently enabled: ${j.join(", ")}`);let{policyParams:n,...p}=e,q=n?Object.fromEntries(Object.entries(n).filter(([a])=>!h.has(a))):null,r={...p,enabledPolicies:i,...q&&Object.keys(q).length>0?{policyParams:q}:{}};(0,m.writeScopedHooksConfig)(r,f,c);try{let c=(0,l.getInstanceId)(),f=a.filter(a=>e.enabledPolicies.includes(a));await (0,k.trackHookEvent)(c,"hooks_removed",{scope:b,cli:g,removal_mode:d?.betaOnly?"beta_policies":"policies",beta_only:d?.betaOnly??!1,policies_removed:f,removed_count:f.length,...d?.source?{source:d.source}:{},platform:(0,o.platform)(),arch:(0,o.arch)(),os_release:(0,o.release)(),hostname_hash:(0,l.hashToId)((0,o.hostname)())})}catch{}console.log(`Disabled ${a.length-j.length} policy(ies).`),console.log(`Remaining: ${i.length>0?i.join(", "):"(none)"}`);return}let i=(0,m.readScopedHooksConfig)(f,c),j=0,n=!1;for(let a of g){let d=(0,q.getIntegration)(a);for(let a of"all"===b?[...d.scopes]:d.scopes.includes(b)?[b]:[]){let f=(0,q.settingsPathsFor)(d,a,c).filter(a=>(0,e.existsSync)(a));if(0===f.length){"all"!==b&&1===g.length&&(console.log("No settings file found. Nothing to remove."),n=!0);continue}let h=0;for(let a of f){let c=d.removeHooksFromFile(a);h+=c,c>0&&"all"!==b&&(console.log(`Removed ${c} failproofai hook(s) from ${d.displayName} settings.`),console.log(`Settings: ${a}`))}if(0===h&&"all"!==b&&1===g.length){console.log("No hooks found in settings. Nothing to remove."),n=!0;continue}j+=h}}if(!n||0!==j){if("all"===b)for(let a of(console.log(`Removed ${j} failproofai hook(s) from all scopes.`),g)){let b=(0,q.getIntegration)(a);for(let a of b.scopes)for(let d of(0,q.settingsPathsFor)(b,a,c))console.log(` ${b.displayName} / ${a}: ${d}`)}try{let a=(0,l.getInstanceId)();await (0,k.trackHookEvent)(a,"hooks_removed",{scope:b,cli:g,removal_mode:"hooks",policies_removed:i.enabledPolicies,removed_count:j,...d?.source?{source:d.source}:{},platform:(0,o.platform)(),arch:(0,o.arch)(),os_release:(0,o.release)(),hostname_hash:(0,l.hashToId)((0,o.hostname)())})}catch{}if("all"===b)for(let a of p.HOOK_SCOPES){let b=(0,m.readScopedHooksConfig)(a,c);if(b.enabledPolicies.length>0||b.customPoliciesPaths?.length||b.customPoliciesPath||b.policyParams){let{customPoliciesPath:d,customPoliciesPaths:e,policyParams:f,...g}=b;(0,m.writeScopedHooksConfig)({...g,enabledPolicies:[]},a,c)}}else if(!p.HOOK_SCOPES.some(a=>z(a,c))){let{customPoliciesPath:a,customPoliciesPaths:b,policyParams:d,...e}=(0,m.readScopedHooksConfig)(f,c);(0,m.writeScopedHooksConfig)({...e,enabledPolicies:[]},f,c)}}}var D=a.i(24282),E=a.i(12714);async function F(a,b){let c=process.env.FAILPROOFAI_LAUNCH_CWD||process.cwd(),d=(0,f.resolve)((0,m.findProjectConfigDir)(c),".failproofai","policies"),e=(0,g.customPoliciesDir)(),h=[];for(let{scope:c,dir:g}of[{scope:"project",dir:d},...e===d?[]:[{scope:"user",dir:e}]]){let d=[];try{d=(0,s.discoverPolicyFiles)(g)}catch{continue}for(let e of d){if(b.has(e))continue;let d=[];try{d=(await G(e)).map(b=>{let d=(0,s.conventionPolicyId)(c,(0,f.basename)(e),b.name);return{...b,id:d,enabled:!a.has(d)}})}catch{}h.push({scope:c,file:(0,f.basename)(e),path:e,policies:d})}}return h}async function G(a){if(!(0,e.existsSync)(a))return[];let b=await (0,E.readFile)(a,"utf-8"),c=[],d=b.split(/customPolicies\.add\s*\(/);for(let a=1;a<d.length;a++){let b=d[a],e=b.match(/name:\s*["'`]([^"'`]+)["'`]/);if(!e)continue;let f=b.match(/description:\s*["'`]([^"'`]+)["'`]/),g=b.match(/events:\s*\[([^\]]+)\]/),h=g?g[1].replace(/["'`\s]/g,"").split(",").filter(Boolean).join(", "):void 0;c.push({name:e[1],description:f?.[1],eventScope:h,id:"",enabled:!0})}return c}async function H(){let a=process.env.FAILPROOFAI_LAUNCH_CWD||process.cwd(),b=(0,m.readMergedHooksConfig)(a),c=new Set(b.disabledCustomPolicies??[]),d=p.HOOK_SCOPES.filter(a=>z(a)),e=w(d[0]??"user"),g=(0,q.listIntegrations)().map(a=>({id:a.id,label:(0,D.getCliLabel)(a.id),installed:a.hooksInstalledInSettings("user"),settingsPath:a.getSettingsPath("user"),detected:a.detectInstalled()})),h=[],i=[];try{let a=(0,u.readInstalledPacks)();h=a.packs,i=a.errors}catch{}let k=[];for(let a of h){let d=a.enabled??a.policies.map(a=>a.name);for(let e of a.policies)k.push({name:e.name,description:e.description,category:e.category,defaultEnabled:e.defaultEnabled,beta:!1,enabled:d.includes(e.name)&&!c.has(`pack:${a.id}@${a.version}:${e.name}`),eventScope:function(a){let b=a.events?.join(", ")??"",c=a.toolNames?` \xb7 ${a.toolNames.join(", ")}`:"";return`${b}${c}`}(e.match),packId:a.id,packVersion:a.version,...e.params?{params:Object.fromEntries(Object.entries(e.params).map(([a,b])=>[a,{type:b.type,description:b.description,default:b.default}])),currentParams:function(a,b,c){if(!a)return;let d=a[`pack/${b}/${c}`];return d||(b.toLowerCase()===j.CORE_SOURCE.toLowerCase()?a[c]:void 0)}(b.policyParams,a.id,e.name)??{}}:{}})}let l=(0,m.configuredCustomPolicyPaths)(b),n=(0,m.findProjectConfigDir)(a),o=l.map(a=>(0,f.resolve)(n,a)),r=(await Promise.all(o.map(async a=>{try{return(await G(a)).map(b=>{let d=(0,s.customPolicyId)(a,b.name);return{...b,id:d,enabled:!c.has(d)}})}catch{return[]}}))).flat(),t=await F(c,new Set(o)),v=h.map(a=>{let b=a.enabled??a.policies.map(a=>a.name);return{id:a.id,version:a.version,source:a.source,effect:a.effect,policies:a.policies.map(d=>({name:d.name,description:d.description,category:d.category,enabled:b.includes(d.name)&&!c.has(`pack:${a.id}@${a.version}:${d.name}`)}))}});for(let a of i)v.push({id:a.id??"(unnamed pack)",version:"",source:"",effect:"enforce",policies:[],error:a.reason});return{enabledPolicies:b.enabledPolicies,installedScopes:d,settingsPath:e,clis:g,policies:k,customPoliciesPaths:l.length?l:void 0,customPoliciesPath:1===l.length?l[0]:void 0,customPolicies:r.length?r:void 0,conventionPolicies:t,packs:v}}async function I(a,b){let c=(0,m.readHooksConfig)(),d=new Set(c.enabledPolicies);b?d.add(a):d.delete(a),(0,m.writeHooksConfig)({...c,enabledPolicies:[...d]});try{let c=(0,l.getInstanceId)();await (0,k.trackHookEvent)(c,"policy_toggled",{policy_name:a,enabled:b,action:b?"enable":"disable",source:"web"})}catch{}}async function J(a,b){if(!a.startsWith("custom:")&&!a.startsWith("convention:"))throw Error("Invalid custom policy ID");let c=process.env.FAILPROOFAI_LAUNCH_CWD||process.cwd();if(b){for(let b of p.HOOK_SCOPES){let d=(0,m.readScopedHooksConfig)(b,c);if(!d.disabledCustomPolicies?.includes(a))continue;let e=d.disabledCustomPolicies.filter(b=>b!==a),f={...d,disabledCustomPolicies:e};e.length||delete f.disabledCustomPolicies,(0,m.writeScopedHooksConfig)(f,b,c)}return}let d=(0,m.readHooksConfig)(),e=new Set(d.disabledCustomPolicies??[]);e.add(a);let f={...d,disabledCustomPolicies:[...e]};e.size||delete f.disabledCustomPolicies,(0,m.writeHooksConfig)(f)}async function K(a,b){let c=a.trim();if(!c)return{ok:!1,error:"Enter a pack source, for example acme/ops"};try{let a=await (0,j.addPackFromSource)(c,b??{});return{ok:!0,id:a.id,version:a.version,enabled:a.enabled,available:a.available}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function L(){try{let a=await (0,j.addPack)(j.CORE_SOURCE);return{ok:!0,id:a.id,version:a.version,enabled:a.enabled,available:a.available}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function M(a){let b;try{b=(0,j.removePack)(a)}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}return b?{ok:!0,id:b}:{ok:!1,error:`No installed pack with id ${a}`}}async function N(a,b,c){let d=(0,j.setPackPolicyEnabled)(a,b,c);if(!d.ok)return{ok:!1,error:d.reason};if(c){let c=(0,u.readInstalledPacks)().packs.find(b=>b.id===a);if(c){let a=`pack:${c.id}@${c.version}:${b}`,d=(0,m.readHooksConfig)(),e=(d.disabledCustomPolicies??[]).filter(b=>b!==a);if(e.length!==(d.disabledCustomPolicies??[]).length){let{disabledCustomPolicies:a,...b}=d;(0,m.writeHooksConfig)(e.length>0?{...b,disabledCustomPolicies:e}:b)}}}return{ok:!0,id:a}}async function O(a){let b=a.trim();if(!b)return{ok:!1,error:"Enter a pack source, for example acme/ops"};try{let a=await (0,j.fetchPackPreview)(b);return{ok:!0,id:a.id,version:a.version,source:a.source,effect:a.effect,policies:a.policies.map(a=>({name:a.name,description:a.description,category:a.category,defaultEnabled:a.defaultEnabled}))}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function P(a="user",b){let c=(0,m.readHooksConfig)(),d=c.enabledPolicies.length>0?c.enabledPolicies:r.BUILTIN_POLICIES.filter(a=>a.defaultEnabled&&!a.beta).map(a=>a.name),e=b&&b.length>0?b:(0,q.detectInstalledClis)(),f=e.length>0?e:["claude"];await A(d,a,void 0,!1,"web",void 0,!1,f)}async function Q(a="user",b){let c=b&&b.length>0?b:(0,q.detectInstalledClis)(),d=c.length>0?c:["claude"];await C(void 0,a,void 0,{source:"web",cli:d})}async function R(a,b){let c=(0,m.readHooksConfig)(),d={...c.policyParams??{},[a]:b};(0,m.writeHooksConfig)({...c,policyParams:d});try{let c=(0,l.getInstanceId)();await (0,k.trackHookEvent)(c,"policy_params_updated",{policy_name:a,param_keys:Object.keys(b),source:"web"})}catch{}}(0,h.ensureServerEntryExports)([H]),(0,d.registerServerReference)(H,"005522600d6fbb081686f93c46b7cfdd511952019c",null),(0,h.ensureServerEntryExports)([I,J]),(0,d.registerServerReference)(I,"600f9a92c6ac2b5289ed6bc0a9b4b053a956cc1f46",null),(0,d.registerServerReference)(J,"60bd0c397a5619455861677dac468240e4a94d7f7e",null),(0,h.ensureServerEntryExports)([K,L,M,N,O]),(0,d.registerServerReference)(K,"6015944c0002e3de9925d099e3f93d86ad58dce223",null),(0,d.registerServerReference)(L,"00ef9203a2377fd3bdfc62cd72b43e5c95dc6df935",null),(0,d.registerServerReference)(M,"4049c5cd42665a8cb03cbe1799de52a0c5a7f17865",null),(0,d.registerServerReference)(N,"7017a6c96fcc288ebdb8602e196fe8a16f0801c6e4",null),(0,d.registerServerReference)(O,"40ee5489fbcf5c2f737d28add3b6544ef7b44320f0",null),(0,h.ensureServerEntryExports)([P,Q]),(0,d.registerServerReference)(P,"602791a5ab13510b48d89bd621813f716ed24a2425",null),(0,d.registerServerReference)(Q,"60634fe91f588027e3e525da91d3e7e0161d87da14",null),(0,h.ensureServerEntryExports)([R]),(0,d.registerServerReference)(R,"601d3b3485ed0a39e3878b085c3546657de5ec565f",null),a.s([],96801),a.i(96801),a.s(["000c85ddbcc0c76485115f8fdbd1792f16d26c97bb",()=>b.getTelemetryConfig,"005522600d6fbb081686f93c46b7cfdd511952019c",0,H,"00ed7012cd02c771c585849eee94d7a6053fea233a",0,i,"00ef9203a2377fd3bdfc62cd72b43e5c95dc6df935",0,L,"4037bcfdb2f730a3d281d456841cc048c23655b450",()=>c.getHookActivityAction,"4049c5cd42665a8cb03cbe1799de52a0c5a7f17865",0,M,"40ee5489fbcf5c2f737d28add3b6544ef7b44320f0",0,O,"6015944c0002e3de9925d099e3f93d86ad58dce223",0,K,"601d3b3485ed0a39e3878b085c3546657de5ec565f",0,R,"602791a5ab13510b48d89bd621813f716ed24a2425",0,P,"60634fe91f588027e3e525da91d3e7e0161d87da14",0,Q,"609c318d728a87a53cb332ec72a48951a1f2cd65c2",()=>c.searchHookActivityAction,"60bd0c397a5619455861677dac468240e4a94d7f7e",0,J,"7017a6c96fcc288ebdb8602e196fe8a16f0801c6e4",0,N],73338)}];
16
16
 
17
17
  //# sourceMappingURL=_next-internal_server_app_policies_page_actions_1sp2-yo.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[80311,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(5050);let e=(0,d.createServerReference)("00840e34fdc0ab0093541d34b83cc649ce4f5d86f3",d.callServer,void 0,d.findSourceMapURL,"getAuditResultAction");var f=a.i(10765);function g({cachedAt:a,fixed:c=!1}){return(0,b.jsxs)("footer",{className:c?"report-footer report-footer--fixed":"report-footer",children:[(0,b.jsx)("img",{src:"/logo.svg",alt:"failproof_ai",style:{height:18,display:"inline-block",verticalAlign:"middle"}}),(0,b.jsx)("span",{style:{margin:"0 12px",color:"var(--line-2)"},children:"·"}),"audit v1.0",(0,b.jsx)("span",{style:{margin:"0 12px",color:"var(--line-2)"},children:"·"}),"generated ",function(a){if(!a)return"—";let b=new Date(a);if(Number.isNaN(b.getTime()))return"—";let c=b.getUTCDate().toString().padStart(2,"0"),d=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"][b.getUTCMonth()],e=b.getUTCFullYear(),f=b.getUTCHours().toString().padStart(2,"0"),g=b.getUTCMinutes().toString().padStart(2,"0");return`${c} ${d} ${e}, ${f}:${g} utc`}(a),(0,b.jsx)("span",{style:{margin:"0 12px",color:"var(--line-2)"},children:"·"}),(0,b.jsx)("span",{style:{color:"var(--ink-2)"},children:"auto-healing for your agents."})]})}let h=(0,d.createServerReference)("40d9250b20c84e4d86f5898290e4a7a464c019b309",d.callServer,void 0,d.findSourceMapURL,"dismissLeakAction"),i=(0,d.createServerReference)("00290d6c5d144e8bf121d1b8e95c08990b6bafca27",d.callServer,void 0,d.findSourceMapURL,"getLeaksAction"),j=(0,d.createServerReference)("40f2667668aae1ab9d2a5b00c81eebc40f91a3fc8b",d.callServer,void 0,d.findSourceMapURL,"setLeakNotifyAction");function k(){let[a,d]=(0,c.useState)(null),[e,f]=(0,c.useState)(!0),[g,k]=(0,c.useState)(null),l=(0,c.useCallback)(async()=>{let a=await i();d(a.rows),f(a.notify)},[]);(0,c.useEffect)(()=>{l()},[l]);let m=(0,c.useCallback)(async a=>{k(a);try{await h(a)&&d(b=>b?.filter(b=>b.id!==a)??null)}finally{k(null)}},[]),n=(0,c.useCallback)(async()=>{let a=!e;f(a),await j(a)||f(!a)},[e]);return null===a?null:(0,b.jsxs)("section",{className:"audit-sec","data-screen-label":"02 Leaks",children:[(0,b.jsxs)("div",{className:"audit-sec-head",children:[(0,b.jsxs)("span",{className:"audit-sec-eyebrow",children:[(0,b.jsx)("span",{className:"ix",children:"02"}),"// credentials"]}),(0,b.jsx)("button",{type:"button",className:"cbb-toggle leak-notify","data-on":e,onClick:n,"aria-label":e?"turn desktop notifications off":"turn desktop notifications on",title:"desktop notification when a new credential is found",children:(0,b.jsx)("span",{className:"cbb-toggle-knob"})})]}),0===a.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("h2",{className:"audit-sec-title",children:"no credentials found"}),(0,b.jsxs)("div",{className:"audit-sec-sub",children:["// nothing in this machine's transcripts matched a known key format",(0,b.jsx)("br",{}),"// or a secret-named assignment."]})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("h2",{className:"audit-sec-title",children:[a.length," credential",1===a.length?"":"s"," in your transcripts"]}),(0,b.jsx)("div",{className:"audit-sec-sub",children:"// one row per distinct key — an exposure count is not a key count."}),(0,b.jsx)("ul",{className:"leak-list",children:a.map(a=>(0,b.jsxs)("li",{className:"leak-row","data-attributed":a.attributed,children:[(0,b.jsxs)("div",{className:"leak-row-top",children:[(0,b.jsx)("code",{className:"leak-key",children:a.display}),(0,b.jsx)("span",{className:"leak-label",children:a.label}),a.name?(0,b.jsx)("span",{className:"leak-name",children:a.name}):null,(0,b.jsx)("button",{type:"button",className:"leak-dismiss",onClick:()=>void m(a.id),disabled:g===a.id,children:"not a secret"})]}),(0,b.jsxs)("div",{className:"leak-how",children:[(0,b.jsx)("span",{className:"leak-verb",children:a.mechanism})," in ",(0,b.jsx)("span",{className:"leak-where",children:a.project})," via ",(0,b.jsx)("span",{className:"leak-who",children:a.cli})," · ",(0,b.jsx)("span",{className:"leak-when",children:function(a){let b=Date.parse(a);if(!Number.isFinite(b))return"unknown";let c=Math.floor((Date.now()-b)/864e5);return c<=0?"today":1===c?"yesterday":c<30?`${c}d ago`:new Date(b).toLocaleDateString(void 0,{month:"short",day:"numeric"})}(a.lastSeen)})]}),(0,b.jsxs)("div",{className:"leak-foot",children:[(0,b.jsxs)("span",{className:"leak-meta",children:[a.occurrences," exposure",1===a.occurrences?"":"s",a.sessions>1?` \xb7 ${a.sessions} sessions`:""," · ",a.length," chars"]}),(0,b.jsx)("span",{className:"leak-dir",children:"input"===a.direction?"sent by the agent — blockable at PreToolUse":"returned to the agent — already in the transcript"}),(0,b.jsx)("span",{className:"leak-fix",children:a.attributed?`rotate it in the ${a.label.replace(/ (API )?(key|token).*$/i,"")} console`:a.name?`find what reads ${a.name}, then rotate it there`:"trace it to its owner, then rotate it"})]})]},a.id))})]})]})}var l=a.i(89564);function m({mode:a,running:c,onStarted:d,onCompleted:e}){let{capture:g}=(0,f.usePostHog)(),h=async()=>{g("audit_first_run_clicked",{source:"empty_state",mode:a}),d();try{await (0,l.triggerRun)({cli:[],since:"all"})}catch(a){console.error("audit first run failed:",a)}finally{await e()}};return"no-cache"===a?(0,b.jsxs)("section",{className:"section empty-section","data-screen-label":"00 Empty",children:[(0,b.jsxs)("div",{className:"section-mast",children:[(0,b.jsxs)("div",{className:"section-label",children:[(0,b.jsx)("span",{className:"glyph",children:"━━"})," audit"," ",(0,b.jsx)("span",{className:"sep",children:"·"})," first run"]}),(0,b.jsxs)("div",{className:"section-meta",children:[(0,b.jsx)("span",{style:{color:"var(--dim)"},children:"○"})," no cache yet"]})]}),(0,b.jsx)("h2",{className:"section-h",children:"scan and see."}),(0,b.jsxs)("div",{className:"panel empty-panel",children:[(0,b.jsxs)("div",{className:"empty-glyph","aria-hidden":"true",children:[(0,b.jsx)("div",{className:"empty-glyph-grid",children:Array.from({length:36}).map((a,c)=>{let d=["1","5","8","10","13","17","20","23","25","30","32"].includes(String(c));return(0,b.jsx)("span",{className:"px"+(d?" on":"")},c)})}),(0,b.jsx)("div",{className:"empty-glyph-label",children:"▮▮ no audit data yet"})]}),(0,b.jsx)("h3",{className:"empty-headline",children:"run your first audit."}),(0,b.jsxs)("p",{className:"empty-sub",children:["we'll walk every transcript across your installed CLIs — Claude Code, Codex, Copilot, Cursor, OpenCode, Pi — and count every wasteful","or risky action. you'll get your agent's archetype and a punch-list."]}),(0,b.jsxs)("div",{className:"empty-actions",children:[(0,b.jsx)("button",{type:"button",className:"btn btn-primary btn-press empty-cta",onClick:h,disabled:c,children:c?"[ scanning… ]":"[ run audit ]"}),(0,b.jsx)("span",{className:"empty-meta",children:"scans all sessions · all installed CLIs · may take a while"})]})]})]}):(0,b.jsxs)("section",{className:"section empty-section","data-screen-label":"00 Empty",children:[(0,b.jsxs)("div",{className:"section-mast",children:[(0,b.jsxs)("div",{className:"section-label",children:[(0,b.jsx)("span",{className:"glyph",children:"━━"})," audit"," ",(0,b.jsx)("span",{className:"sep",children:"·"})," zero transcripts"]}),(0,b.jsxs)("div",{className:"section-meta",children:[(0,b.jsx)("span",{style:{color:"var(--amber)"},children:"●"})," hooks not installed"]})]}),(0,b.jsx)("h2",{className:"section-h",children:"nothing to read."}),(0,b.jsxs)("div",{className:"panel empty-panel",children:[(0,b.jsxs)("div",{className:"empty-glyph","aria-hidden":"true",children:[(0,b.jsx)("div",{className:"empty-glyph-grid",children:Array.from({length:36}).map((a,c)=>{let d=["2","4","9","11","16","18","23","25","27","30","33"].includes(String(c));return(0,b.jsx)("span",{className:"px"+(d?" on":"")},c)})}),(0,b.jsx)("div",{className:"empty-glyph-label",children:"▮▮ no sessions found"})]}),(0,b.jsx)("h3",{className:"empty-headline",children:"install hooks first."}),(0,b.jsx)("p",{className:"empty-sub",children:"failproofai couldn't find any transcripts to scan on this machine. install the hooks for at least one CLI and come back."}),(0,b.jsxs)("div",{className:"empty-actions",children:[(0,b.jsx)("a",{href:"https://docs.befailproof.ai/getting-started",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-press empty-cta",onClick:()=>{g("audit_install_guide_clicked",{source:"empty_state",mode:a})},children:"[ install guide → ]"}),(0,b.jsx)("span",{className:"empty-meta",children:"takes about 30 seconds · one command per CLI"})]})]})]})}let n=[{label:"discovering transcripts",detail:"walking ~/.claude, ~/.codex, ~/.cursor, …"},{label:"parsing session logs",detail:"reading JSONL + sqlite session stores"},{label:"running policy checks",detail:"replaying every policy against each tool call"},{label:"aggregating results",detail:"counting hits, ranking by frequency"}];function o(){let[a,d]=(0,c.useState)(0),[e,f]=(0,c.useState)(0);(0,c.useEffect)(()=>{let a=setInterval(()=>{d(a=>Math.min(a+1,n.length-1))},4e3),b=setInterval(()=>f(a=>(a+1)%4),350);return()=>{clearInterval(a),clearInterval(b)}},[]);let g=".".repeat(e+1),h=a===n.length-1,i=Math.round(100*Math.min(.9,(a+1)/n.length*.9));return(0,b.jsxs)("section",{className:"section running-section","data-screen-label":"00 Running",children:[(0,b.jsxs)("div",{className:"section-mast",children:[(0,b.jsxs)("div",{className:"section-label",children:[(0,b.jsx)("span",{className:"glyph",children:"━━"})," audit"," ",(0,b.jsx)("span",{className:"sep",children:"·"})," in progress"]}),(0,b.jsxs)("div",{className:"section-meta",children:[(0,b.jsx)("span",{style:{color:"var(--accent-pink)"},children:"●"})," scanning"]})]}),(0,b.jsxs)("h2",{className:"section-h",children:["scanning sessions",g]}),(0,b.jsxs)("div",{className:"panel running-panel",children:[(0,b.jsxs)("div",{className:"running-header",children:[(0,b.jsx)("span",{className:"running-prompt",children:"$"}),(0,b.jsx)("span",{className:"running-cmd",children:"failproofai audit"}),(0,b.jsx)("span",{className:"running-cursor","aria-hidden":"true",children:"▮"})]}),(0,b.jsx)("ul",{className:"running-stages",children:n.map((c,d)=>{let f=d<a,g=d===a;return(0,b.jsxs)("li",{className:"running-stage"+(f?" done":g?" active":" queued"),children:[(0,b.jsx)("span",{className:"running-marker","aria-hidden":"true",children:f?"✓":g?"▮▮":"○"}),(0,b.jsxs)("div",{className:"running-stage-body",children:[(0,b.jsx)("div",{className:"running-stage-label",children:c.label}),g&&(0,b.jsx)("div",{className:"running-stage-detail",children:h?"finishing up…":c.detail})]}),g&&(0,b.jsx)("span",{className:"running-stage-spin","aria-hidden":"true",children:["⠋","⠙","⠹","⠸"][e]})]},d)})}),(0,b.jsxs)("div",{className:"running-bar-label",children:[(0,b.jsx)("span",{children:"progress"}),(0,b.jsxs)("span",{style:{color:"var(--dim)"},children:[i,"%"]})]}),(0,b.jsx)("div",{className:"running-bar-track",children:(0,b.jsx)("div",{className:"running-bar-fill",style:{width:`${i}%`}})}),(0,b.jsx)("p",{className:"running-foot",children:"this can take a while depending on how much session history you have."})]})]})}let p={timeout:"audit took too long — try again",network:"network hiccup — check your connection",post_failed:"audit failed — try again"};function q({status:a,onDismiss:d}){let[e,f]=(0,c.useState)(()=>Date.now());if((0,c.useEffect)(()=>{if("running"!==a.kind)return;let b=setInterval(()=>f(Date.now()),1e3);return()=>clearInterval(b)},[a.kind]),"idle"===a.kind)return null;if("running"===a.kind){let c=Math.max(0,e-a.startedAt);return(0,b.jsxs)("div",{className:"audit-progress-strip",role:"status","aria-live":"polite",children:[(0,b.jsxs)("div",{className:"audit-progress-strip__inner",children:[(0,b.jsxs)("span",{className:"audit-progress-strip__label",children:[(0,b.jsx)("span",{className:"audit-progress-strip__spinner","aria-hidden":"true"}),"re-auditing your sessions"]}),(0,b.jsx)("span",{className:"audit-progress-strip__elapsed",children:function(a){if(a<0)return"00:00";let b=Math.floor(a/1e3),c=Math.floor(b/60).toString().padStart(2,"0"),d=(b%60).toString().padStart(2,"0");return`${c}:${d}`}(c)})]}),(0,b.jsx)("div",{className:"audit-progress-strip__pulse","aria-hidden":"true"})]})}return(0,b.jsx)("div",{className:"audit-progress-strip audit-progress-strip--failed",role:"alert",children:(0,b.jsxs)("div",{className:"audit-progress-strip__inner",children:[(0,b.jsxs)("span",{className:"audit-progress-strip__label",children:[(0,b.jsx)("span",{className:"audit-progress-strip__x","aria-hidden":"true",children:"×"}),p[a.reason]]}),(0,b.jsx)("button",{type:"button",className:"audit-progress-strip__dismiss",onClick:d,"aria-label":"dismiss",children:"[ dismiss ]"})]})})}function r({result:a,cachedAt:d,projectFromUrl:e,isRunning:h,rerunStatus:i,onRerun:j,onDismissRerun:l}){let{capture:m}=(0,f.usePostHog)(),{detectorsTriggered:n,missing:o}=(0,c.useMemo)(()=>{let b=0,c=0;for(let d of a.results)d.hits>0&&b++,"builtin"===d.source&&!d.enabledInConfig&&d.hits>0&&c++;return{detectorsTriggered:b,missing:c}},[a]),p=(0,c.useRef)(!1);return(0,c.useEffect)(()=>{p.current||(p.current=!0,m("audit_dashboard_viewed",{missing:o,transcripts_scanned:a.transcripts.scanned,results_count:a.results.length,detectors_triggered:n}))},[m,o,a.transcripts.scanned,a.results.length,n]),(0,b.jsxs)("div",{className:"app",children:[(0,b.jsx)(q,{status:i,onDismiss:l}),(0,b.jsxs)("div",{className:"app-shell",children:[(0,b.jsxs)("div",{className:"report",children:[(0,b.jsx)(s,{transcripts:a.transcripts.scanned,events:a.eventsScanned??0,projects:a.projectsScanned.length}),(0,b.jsx)(k,{})]}),(0,b.jsx)(g,{cachedAt:d})]})]})}function s({transcripts:a,events:c,projects:d}){return(0,b.jsxs)("section",{className:"audit-sec","data-screen-label":"01 Scan",children:[(0,b.jsx)("div",{className:"audit-sec-head",children:(0,b.jsxs)("span",{className:"audit-sec-eyebrow",children:[(0,b.jsx)("span",{className:"ix",children:"01"}),"// scan"]})}),(0,b.jsx)("h2",{className:"audit-sec-title",children:"scan complete"}),(0,b.jsxs)("div",{className:"audit-sec-sub",children:[c.toLocaleString()," tool call",1===c?"":"s"," across ",a.toLocaleString()," ","transcript",1===a?"":"s",d>0?` \xb7 ${d.toLocaleString()} project${1===d?"":"s"}`:""]}),(0,b.jsxs)("div",{className:"audit-sec-sub",children:["// the report is being rebuilt around leak detection. the scan, the",(0,b.jsx)("br",{}),"// 12-CLI transcript reader and the emailed digest are unaffected."]})]})}function t({running:a,mode:c="no-cache",rerunStatus:d,onDismissRerun:e,onStarted:f,onCompleted:h}){return(0,b.jsxs)("div",{className:"app",children:[(0,b.jsx)(q,{status:d,onDismiss:e}),(0,b.jsxs)("div",{className:"app-shell",children:[(0,b.jsx)("div",{className:"report",children:a?(0,b.jsx)(o,{}):(0,b.jsx)(m,{mode:c,running:a,onStarted:f,onCompleted:h})}),(0,b.jsx)(g,{cachedAt:null,fixed:!0})]})]})}a.s(["AuditDashboard",0,function({initial:a,projectFromUrl:d,totalCatalogSize:g}){let[h,i]=(0,c.useState)(a),[j,k]=(0,c.useState)(!1),[m,n]=(0,c.useState)({kind:"idle"}),{capture:o}=(0,f.usePostHog)(),p=(0,c.useRef)(null),q=(0,c.useRef)(!1),s="cached"===h.status?h.result.transcripts.scanned:0,u="cached"===h.status?h.result.results.length:0,v=(0,c.useCallback)(async()=>{i(await e())},[]),w=(0,c.useCallback)(async a=>{if(j)return;o("audit_rerun_clicked",{source:a,since:"all"}),k(!0);let b=Date.now();n({kind:"running",startedAt:b});try{await (0,l.triggerRun)({cli:[],since:"all",noCache:!0}),await v(),o("audit_rerun_succeeded",{source:a,since:"all",duration_ms:Date.now()-b}),n({kind:"idle"})}catch(d){let c=d instanceof l.RerunError?d.kind:"network";o("audit_rerun_failed",{kind:c,source:a,since:"all",cli_filter:"all",duration_ms:Date.now()-b}),n({kind:"failed",reason:c,failedAt:Date.now()})}finally{k(!1)}},[o,v,j]),x=(0,c.useCallback)(()=>{n({kind:"idle"})},[]);if((0,c.useEffect)(()=>(document.body.classList.add("audit-body"),()=>document.body.classList.remove("audit-body")),[]),(0,c.useEffect)(()=>{let a=j?"running":"empty"===h.status?"empty":0===s?"zero_sessions":"report";p.current!==a&&(p.current=a,o("audit_page_viewed",{state:a,has_cache:"cached"===h.status}))},[h.status,o,j,s]),(0,c.useEffect)(()=>{q.current=!1},[h.status,j,s]),(0,c.useEffect)(()=>{if(j||"cached"!==h.status||0===s)return;let a=0,b=()=>{if(a=0,q.current)return;let b=document.documentElement.scrollHeight-window.innerHeight;b<=0||window.scrollY>=b-24&&(q.current=!0,o("audit_page_scrolled_to_end",{results_count:u,transcripts_scanned:s}))},c=()=>{0===a&&(a=requestAnimationFrame(b))};return b(),window.addEventListener("scroll",c,{passive:!0}),()=>{window.removeEventListener("scroll",c),0!==a&&cancelAnimationFrame(a)}},[h.status,o,u,j,s]),"empty"===h.status&&!j)return(0,b.jsx)(t,{running:!1,rerunStatus:m,onDismissRerun:x,onStarted:()=>k(!0),onCompleted:async()=>{k(!1),await v()}});if("empty"===h.status&&j)return(0,b.jsx)(t,{running:!0,rerunStatus:m,onDismissRerun:x,onStarted:()=>{},onCompleted:async()=>{k(!1),await v()}});let y="cached"===h.status?h.result:null;if(!y)return null;let z="cached"===h.status?h.cachedAt:null;return 0===y.transcripts.scanned?(0,b.jsx)(t,{running:j,mode:"zero-sessions",rerunStatus:m,onDismissRerun:x,onStarted:()=>k(!0),onCompleted:async()=>{k(!1),await v()}}):(0,b.jsx)(r,{result:y,cachedAt:z,projectFromUrl:d,isRunning:j,rerunStatus:m,onRerun:a=>w(a),onDismissRerun:x})}],80311)}];
1
+ module.exports=[80311,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(5050);let e=(0,d.createServerReference)("0048814305f7563284b0e6413ac4ea842889a1d6eb",d.callServer,void 0,d.findSourceMapURL,"getAuditResultAction");var f=a.i(10765);function g({cachedAt:a,fixed:c=!1}){return(0,b.jsxs)("footer",{className:c?"report-footer report-footer--fixed":"report-footer",children:[(0,b.jsx)("img",{src:"/logo.svg",alt:"failproof_ai",style:{height:18,display:"inline-block",verticalAlign:"middle"}}),(0,b.jsx)("span",{style:{margin:"0 12px",color:"var(--line-2)"},children:"·"}),"audit v1.0",(0,b.jsx)("span",{style:{margin:"0 12px",color:"var(--line-2)"},children:"·"}),"generated ",function(a){if(!a)return"—";let b=new Date(a);if(Number.isNaN(b.getTime()))return"—";let c=b.getUTCDate().toString().padStart(2,"0"),d=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"][b.getUTCMonth()],e=b.getUTCFullYear(),f=b.getUTCHours().toString().padStart(2,"0"),g=b.getUTCMinutes().toString().padStart(2,"0");return`${c} ${d} ${e}, ${f}:${g} utc`}(a),(0,b.jsx)("span",{style:{margin:"0 12px",color:"var(--line-2)"},children:"·"}),(0,b.jsx)("span",{style:{color:"var(--ink-2)"},children:"auto-healing for your agents."})]})}let h=(0,d.createServerReference)("4097c062c6b1d13b1d6f2a64af27881249bbf9d989",d.callServer,void 0,d.findSourceMapURL,"dismissLeakAction"),i=(0,d.createServerReference)("00fd330814bcefc936e301ec49d66099ed614ecf67",d.callServer,void 0,d.findSourceMapURL,"getLeaksAction"),j=(0,d.createServerReference)("409ed106c4be852cd917c107309fc8fd09d79a0beb",d.callServer,void 0,d.findSourceMapURL,"setLeakNotifyAction");function k(a){let b=Date.parse(a);if(!Number.isFinite(b))return"unknown";let c=Math.floor((Date.now()-b)/864e5);return c<=0?"today":1===c?"yesterday":c<30?`${c}d ago`:new Date(b).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function l(){let[a,d]=(0,c.useState)(null),[e,f]=(0,c.useState)(!0),[g,l]=(0,c.useState)(null),m=(0,c.useCallback)(async()=>{let a=await i();d(a.rows),f(a.notify)},[]);(0,c.useEffect)(()=>{m()},[m]);let n=(0,c.useCallback)(async a=>{l(a);try{await h(a)&&d(b=>b?.filter(b=>b.id!==a)??null)}finally{l(null)}},[]),o=(0,c.useCallback)(async()=>{let a=!e;f(a),await j(a)||f(!a)},[e]);return null===a?null:(0,b.jsxs)("section",{className:"audit-sec","data-screen-label":"02 Leaks",children:[(0,b.jsxs)("div",{className:"audit-sec-head",children:[(0,b.jsxs)("span",{className:"audit-sec-eyebrow",children:[(0,b.jsx)("span",{className:"ix",children:"02"}),"// credentials"]}),(0,b.jsx)("button",{type:"button",className:"cbb-toggle leak-notify","data-on":e,onClick:o,"aria-label":e?"turn desktop notifications off":"turn desktop notifications on",title:"desktop notification when a new credential is found",children:(0,b.jsx)("span",{className:"cbb-toggle-knob"})})]}),0===a.length?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("h2",{className:"audit-sec-title",children:"no credentials found"}),(0,b.jsxs)("div",{className:"audit-sec-sub",children:["// nothing in this machine's transcripts matched a known key format",(0,b.jsx)("br",{}),"// or a secret-named assignment."]})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("h2",{className:"audit-sec-title",children:[a.length," credential",1===a.length?"":"s"," in your transcripts"]}),(0,b.jsx)("div",{className:"audit-sec-sub",children:"// one row per distinct key — an exposure count is not a key count."}),(0,b.jsx)("ul",{className:"leak-list",children:a.map(a=>(0,b.jsxs)("li",{className:"leak-row","data-attributed":a.attributed,children:[(0,b.jsxs)("div",{className:"leak-row-top",children:[(0,b.jsx)("code",{className:"leak-key",children:a.display}),(0,b.jsx)("span",{className:"leak-label",children:a.label}),a.name?(0,b.jsx)("span",{className:"leak-name",children:a.name}):null,(0,b.jsx)("button",{type:"button",className:"leak-dismiss",onClick:()=>void n(a.id),disabled:g===a.id,children:"not a secret"})]}),(0,b.jsxs)("div",{className:"leak-how",children:[(0,b.jsx)("span",{className:"leak-verb",children:a.mechanism})," in ",(0,b.jsx)("span",{className:"leak-where",children:a.project})," via ",(0,b.jsx)("span",{className:"leak-who",children:a.cli})," · leaked ",(0,b.jsx)("span",{className:"leak-when",children:k(a.firstSeen)}),k(a.firstSeen)!==k(a.lastSeen)?(0,b.jsxs)(b.Fragment,{children:[" · last seen ",(0,b.jsx)("span",{className:"leak-when",children:k(a.lastSeen)})]}):null]}),(0,b.jsxs)("div",{className:"leak-foot",children:[(0,b.jsxs)("span",{className:"leak-meta",children:[a.occurrences," exposure",1===a.occurrences?"":"s",a.sessions>1?` \xb7 ${a.sessions} sessions`:""," · ",a.length," chars"]}),(0,b.jsx)("span",{className:"leak-dir",children:"input"===a.direction?"sent by the agent — blockable at PreToolUse":"returned to the agent — already in the transcript"}),(0,b.jsx)("span",{className:"leak-fix",children:a.attributed?`rotate it in the ${a.label.replace(/ (API )?(key|token).*$/i,"")} console`:a.name?`find what reads ${a.name}, then rotate it there`:"trace it to its owner, then rotate it"})]})]},a.id))})]})]})}var m=a.i(89564);function n({mode:a,running:c,onStarted:d,onCompleted:e}){let{capture:g}=(0,f.usePostHog)(),h=async()=>{g("audit_first_run_clicked",{source:"empty_state",mode:a}),d();try{await (0,m.triggerRun)({cli:[],since:"all"})}catch(a){console.error("audit first run failed:",a)}finally{await e()}};return"no-cache"===a?(0,b.jsxs)("section",{className:"section empty-section","data-screen-label":"00 Empty",children:[(0,b.jsxs)("div",{className:"section-mast",children:[(0,b.jsxs)("div",{className:"section-label",children:[(0,b.jsx)("span",{className:"glyph",children:"━━"})," audit"," ",(0,b.jsx)("span",{className:"sep",children:"·"})," first run"]}),(0,b.jsxs)("div",{className:"section-meta",children:[(0,b.jsx)("span",{style:{color:"var(--dim)"},children:"○"})," no cache yet"]})]}),(0,b.jsx)("h2",{className:"section-h",children:"scan and see."}),(0,b.jsxs)("div",{className:"panel empty-panel",children:[(0,b.jsxs)("div",{className:"empty-glyph","aria-hidden":"true",children:[(0,b.jsx)("div",{className:"empty-glyph-grid",children:Array.from({length:36}).map((a,c)=>{let d=["1","5","8","10","13","17","20","23","25","30","32"].includes(String(c));return(0,b.jsx)("span",{className:"px"+(d?" on":"")},c)})}),(0,b.jsx)("div",{className:"empty-glyph-label",children:"▮▮ no audit data yet"})]}),(0,b.jsx)("h3",{className:"empty-headline",children:"run your first audit."}),(0,b.jsxs)("p",{className:"empty-sub",children:["we'll walk every transcript across your installed CLIs — Claude Code, Codex, Copilot, Cursor, OpenCode, Pi — and count every wasteful","or risky action. you'll get your agent's archetype and a punch-list."]}),(0,b.jsxs)("div",{className:"empty-actions",children:[(0,b.jsx)("button",{type:"button",className:"btn btn-primary btn-press empty-cta",onClick:h,disabled:c,children:c?"[ scanning… ]":"[ run audit ]"}),(0,b.jsx)("span",{className:"empty-meta",children:"scans all sessions · all installed CLIs · may take a while"})]})]})]}):(0,b.jsxs)("section",{className:"section empty-section","data-screen-label":"00 Empty",children:[(0,b.jsxs)("div",{className:"section-mast",children:[(0,b.jsxs)("div",{className:"section-label",children:[(0,b.jsx)("span",{className:"glyph",children:"━━"})," audit"," ",(0,b.jsx)("span",{className:"sep",children:"·"})," zero transcripts"]}),(0,b.jsxs)("div",{className:"section-meta",children:[(0,b.jsx)("span",{style:{color:"var(--amber)"},children:"●"})," hooks not installed"]})]}),(0,b.jsx)("h2",{className:"section-h",children:"nothing to read."}),(0,b.jsxs)("div",{className:"panel empty-panel",children:[(0,b.jsxs)("div",{className:"empty-glyph","aria-hidden":"true",children:[(0,b.jsx)("div",{className:"empty-glyph-grid",children:Array.from({length:36}).map((a,c)=>{let d=["2","4","9","11","16","18","23","25","27","30","33"].includes(String(c));return(0,b.jsx)("span",{className:"px"+(d?" on":"")},c)})}),(0,b.jsx)("div",{className:"empty-glyph-label",children:"▮▮ no sessions found"})]}),(0,b.jsx)("h3",{className:"empty-headline",children:"install hooks first."}),(0,b.jsx)("p",{className:"empty-sub",children:"failproofai couldn't find any transcripts to scan on this machine. install the hooks for at least one CLI and come back."}),(0,b.jsxs)("div",{className:"empty-actions",children:[(0,b.jsx)("a",{href:"https://docs.befailproof.ai/getting-started",target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary btn-press empty-cta",onClick:()=>{g("audit_install_guide_clicked",{source:"empty_state",mode:a})},children:"[ install guide → ]"}),(0,b.jsx)("span",{className:"empty-meta",children:"takes about 30 seconds · one command per CLI"})]})]})]})}let o=[{label:"discovering transcripts",detail:"walking ~/.claude, ~/.codex, ~/.cursor, …"},{label:"parsing session logs",detail:"reading JSONL + sqlite session stores"},{label:"running policy checks",detail:"replaying every policy against each tool call"},{label:"aggregating results",detail:"counting hits, ranking by frequency"}];function p(){let[a,d]=(0,c.useState)(0),[e,f]=(0,c.useState)(0);(0,c.useEffect)(()=>{let a=setInterval(()=>{d(a=>Math.min(a+1,o.length-1))},4e3),b=setInterval(()=>f(a=>(a+1)%4),350);return()=>{clearInterval(a),clearInterval(b)}},[]);let g=".".repeat(e+1),h=a===o.length-1,i=Math.round(100*Math.min(.9,(a+1)/o.length*.9));return(0,b.jsxs)("section",{className:"section running-section","data-screen-label":"00 Running",children:[(0,b.jsxs)("div",{className:"section-mast",children:[(0,b.jsxs)("div",{className:"section-label",children:[(0,b.jsx)("span",{className:"glyph",children:"━━"})," audit"," ",(0,b.jsx)("span",{className:"sep",children:"·"})," in progress"]}),(0,b.jsxs)("div",{className:"section-meta",children:[(0,b.jsx)("span",{style:{color:"var(--accent-pink)"},children:"●"})," scanning"]})]}),(0,b.jsxs)("h2",{className:"section-h",children:["scanning sessions",g]}),(0,b.jsxs)("div",{className:"panel running-panel",children:[(0,b.jsxs)("div",{className:"running-header",children:[(0,b.jsx)("span",{className:"running-prompt",children:"$"}),(0,b.jsx)("span",{className:"running-cmd",children:"failproofai audit"}),(0,b.jsx)("span",{className:"running-cursor","aria-hidden":"true",children:"▮"})]}),(0,b.jsx)("ul",{className:"running-stages",children:o.map((c,d)=>{let f=d<a,g=d===a;return(0,b.jsxs)("li",{className:"running-stage"+(f?" done":g?" active":" queued"),children:[(0,b.jsx)("span",{className:"running-marker","aria-hidden":"true",children:f?"✓":g?"▮▮":"○"}),(0,b.jsxs)("div",{className:"running-stage-body",children:[(0,b.jsx)("div",{className:"running-stage-label",children:c.label}),g&&(0,b.jsx)("div",{className:"running-stage-detail",children:h?"finishing up…":c.detail})]}),g&&(0,b.jsx)("span",{className:"running-stage-spin","aria-hidden":"true",children:["⠋","⠙","⠹","⠸"][e]})]},d)})}),(0,b.jsxs)("div",{className:"running-bar-label",children:[(0,b.jsx)("span",{children:"progress"}),(0,b.jsxs)("span",{style:{color:"var(--dim)"},children:[i,"%"]})]}),(0,b.jsx)("div",{className:"running-bar-track",children:(0,b.jsx)("div",{className:"running-bar-fill",style:{width:`${i}%`}})}),(0,b.jsx)("p",{className:"running-foot",children:"this can take a while depending on how much session history you have."})]})]})}let q={timeout:"audit took too long — try again",network:"network hiccup — check your connection",post_failed:"audit failed — try again"};function r({status:a,onDismiss:d}){let[e,f]=(0,c.useState)(()=>Date.now());if((0,c.useEffect)(()=>{if("running"!==a.kind)return;let b=setInterval(()=>f(Date.now()),1e3);return()=>clearInterval(b)},[a.kind]),"idle"===a.kind)return null;if("running"===a.kind){let c=Math.max(0,e-a.startedAt);return(0,b.jsxs)("div",{className:"audit-progress-strip",role:"status","aria-live":"polite",children:[(0,b.jsxs)("div",{className:"audit-progress-strip__inner",children:[(0,b.jsxs)("span",{className:"audit-progress-strip__label",children:[(0,b.jsx)("span",{className:"audit-progress-strip__spinner","aria-hidden":"true"}),"re-auditing your sessions"]}),(0,b.jsx)("span",{className:"audit-progress-strip__elapsed",children:function(a){if(a<0)return"00:00";let b=Math.floor(a/1e3),c=Math.floor(b/60).toString().padStart(2,"0"),d=(b%60).toString().padStart(2,"0");return`${c}:${d}`}(c)})]}),(0,b.jsx)("div",{className:"audit-progress-strip__pulse","aria-hidden":"true"})]})}return(0,b.jsx)("div",{className:"audit-progress-strip audit-progress-strip--failed",role:"alert",children:(0,b.jsxs)("div",{className:"audit-progress-strip__inner",children:[(0,b.jsxs)("span",{className:"audit-progress-strip__label",children:[(0,b.jsx)("span",{className:"audit-progress-strip__x","aria-hidden":"true",children:"×"}),q[a.reason]]}),(0,b.jsx)("button",{type:"button",className:"audit-progress-strip__dismiss",onClick:d,"aria-label":"dismiss",children:"[ dismiss ]"})]})})}function s({result:a,cachedAt:d,projectFromUrl:e,isRunning:h,rerunStatus:i,onRerun:j,onDismissRerun:k}){let{capture:m}=(0,f.usePostHog)(),{detectorsTriggered:n,missing:o}=(0,c.useMemo)(()=>{let b=0,c=0;for(let d of a.results)d.hits>0&&b++,"builtin"===d.source&&!d.enabledInConfig&&d.hits>0&&c++;return{detectorsTriggered:b,missing:c}},[a]),p=(0,c.useRef)(!1);return(0,c.useEffect)(()=>{p.current||(p.current=!0,m("audit_dashboard_viewed",{missing:o,transcripts_scanned:a.transcripts.scanned,results_count:a.results.length,detectors_triggered:n}))},[m,o,a.transcripts.scanned,a.results.length,n]),(0,b.jsxs)("div",{className:"app",children:[(0,b.jsx)(r,{status:i,onDismiss:k}),(0,b.jsxs)("div",{className:"app-shell",children:[(0,b.jsxs)("div",{className:"report",children:[(0,b.jsx)(t,{transcripts:a.transcripts.scanned,events:a.eventsScanned??0,projects:a.projectsScanned.length,isRunning:h||"running"===i.kind,onRerun:()=>j("scan_header")}),(0,b.jsx)(l,{})]}),(0,b.jsx)(g,{cachedAt:d})]})]})}function t({transcripts:a,events:c,projects:d,isRunning:e,onRerun:f}){return(0,b.jsxs)("section",{className:"audit-sec","data-screen-label":"01 Scan",children:[(0,b.jsxs)("div",{className:"audit-sec-head",children:[(0,b.jsxs)("span",{className:"audit-sec-eyebrow",children:[(0,b.jsx)("span",{className:"ix",children:"01"}),"// scan"]}),(0,b.jsx)("button",{type:"button",className:"scan-rerun",onClick:f,disabled:e,children:e?"scanning…":"run again"})]}),(0,b.jsx)("h2",{className:"audit-sec-title",children:"scan complete"}),(0,b.jsxs)("div",{className:"audit-sec-sub",children:[c.toLocaleString()," tool call",1===c?"":"s"," across ",a.toLocaleString()," ","transcript",1===a?"":"s",d>0?` \xb7 ${d.toLocaleString()} project${1===d?"":"s"}`:""]}),(0,b.jsxs)("div",{className:"audit-sec-sub",children:["// the report is being rebuilt around leak detection. the scan, the",(0,b.jsx)("br",{}),"// 12-CLI transcript reader and the emailed digest are unaffected."]})]})}function u({running:a,mode:c="no-cache",rerunStatus:d,onDismissRerun:e,onStarted:f,onCompleted:h}){return(0,b.jsxs)("div",{className:"app",children:[(0,b.jsx)(r,{status:d,onDismiss:e}),(0,b.jsxs)("div",{className:"app-shell",children:[(0,b.jsx)("div",{className:"report",children:a?(0,b.jsx)(p,{}):(0,b.jsx)(n,{mode:c,running:a,onStarted:f,onCompleted:h})}),(0,b.jsx)(g,{cachedAt:null,fixed:!0})]})]})}a.s(["AuditDashboard",0,function({initial:a,projectFromUrl:d,totalCatalogSize:g}){let[h,i]=(0,c.useState)(a),[j,k]=(0,c.useState)(!1),[l,n]=(0,c.useState)({kind:"idle"}),{capture:o}=(0,f.usePostHog)(),p=(0,c.useRef)(null),q=(0,c.useRef)(!1),r="cached"===h.status?h.result.transcripts.scanned:0,t="cached"===h.status?h.result.results.length:0,v=(0,c.useCallback)(async()=>{i(await e())},[]),w=(0,c.useCallback)(async a=>{if(j)return;o("audit_rerun_clicked",{source:a,since:"all"}),k(!0);let b=Date.now();n({kind:"running",startedAt:b});try{await (0,m.triggerRun)({cli:[],since:"all",noCache:!0}),await v(),o("audit_rerun_succeeded",{source:a,since:"all",duration_ms:Date.now()-b}),n({kind:"idle"})}catch(d){let c=d instanceof m.RerunError?d.kind:"network";o("audit_rerun_failed",{kind:c,source:a,since:"all",cli_filter:"all",duration_ms:Date.now()-b}),n({kind:"failed",reason:c,failedAt:Date.now()})}finally{k(!1)}},[o,v,j]),x=(0,c.useCallback)(()=>{n({kind:"idle"})},[]);if((0,c.useEffect)(()=>(document.body.classList.add("audit-body"),()=>document.body.classList.remove("audit-body")),[]),(0,c.useEffect)(()=>{let a=j?"running":"empty"===h.status?"empty":0===r?"zero_sessions":"report";p.current!==a&&(p.current=a,o("audit_page_viewed",{state:a,has_cache:"cached"===h.status}))},[h.status,o,j,r]),(0,c.useEffect)(()=>{q.current=!1},[h.status,j,r]),(0,c.useEffect)(()=>{if(j||"cached"!==h.status||0===r)return;let a=0,b=()=>{if(a=0,q.current)return;let b=document.documentElement.scrollHeight-window.innerHeight;b<=0||window.scrollY>=b-24&&(q.current=!0,o("audit_page_scrolled_to_end",{results_count:t,transcripts_scanned:r}))},c=()=>{0===a&&(a=requestAnimationFrame(b))};return b(),window.addEventListener("scroll",c,{passive:!0}),()=>{window.removeEventListener("scroll",c),0!==a&&cancelAnimationFrame(a)}},[h.status,o,t,j,r]),"empty"===h.status&&!j)return(0,b.jsx)(u,{running:!1,rerunStatus:l,onDismissRerun:x,onStarted:()=>k(!0),onCompleted:async()=>{k(!1),await v()}});if("empty"===h.status&&j)return(0,b.jsx)(u,{running:!0,rerunStatus:l,onDismissRerun:x,onStarted:()=>{},onCompleted:async()=>{k(!1),await v()}});let y="cached"===h.status?h.result:null;if(!y)return null;let z="cached"===h.status?h.cachedAt:null;return 0===y.transcripts.scanned?(0,b.jsx)(u,{running:j,mode:"zero-sessions",rerunStatus:l,onDismissRerun:x,onStarted:()=>k(!0),onCompleted:async()=>{k(!1),await v()}}):(0,b.jsx)(s,{result:y,cachedAt:z,projectFromUrl:d,isRunning:j,rerunStatus:l,onRerun:a=>w(a),onDismissRerun:x})}],80311)}];
2
2
 
3
3
  //# sourceMappingURL=app_audit__components_audit-dashboard_tsx_0p9ud47._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[3171,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(1355),e=a.i(66036);a.s(["default",0,function({error:a,reset:f}){return(0,c.useEffect)(()=>{(0,d.getTelemetryConfig)().then(b=>{(0,e.setClientTelemetryConfig)(b),(0,e.captureClientEvent)("client_error",{error_message:a.message,error_name:a.name,error_digest:a.digest,boundary:"global"})}).catch(()=>{})},[a]),(0,b.jsx)("html",{children:(0,b.jsx)("body",{children:(0,b.jsx)("main",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"#031035",color:"#f8fafc",fontFamily:"system-ui, sans-serif"},children:(0,b.jsxs)("div",{style:{textAlign:"center",padding:"2rem",border:"1px solid rgba(239,68,68,0.4)",borderRadius:"0.5rem",maxWidth:"500px"},children:[(0,b.jsx)("h2",{style:{color:"#ef4444",marginBottom:"0.5rem",fontSize:"1.25rem"},children:"Something went wrong"}),(0,b.jsx)("p",{style:{color:"#94a3b8",marginBottom:"1.5rem"},children:a.message||"An unexpected error occurred."}),(0,b.jsx)("button",{onClick:f,style:{padding:"0.5rem 1.25rem",background:"#3b82f6",color:"white",border:"none",borderRadius:"0.375rem",cursor:"pointer",fontSize:"0.875rem"},children:"Try again"})]})})})})}])}];
1
+ module.exports=[3171,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(45221),e=a.i(66036);a.s(["default",0,function({error:a,reset:f}){return(0,c.useEffect)(()=>{(0,d.getTelemetryConfig)().then(b=>{(0,e.setClientTelemetryConfig)(b),(0,e.captureClientEvent)("client_error",{error_message:a.message,error_name:a.name,error_digest:a.digest,boundary:"global"})}).catch(()=>{})},[a]),(0,b.jsx)("html",{children:(0,b.jsx)("body",{children:(0,b.jsx)("main",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"#031035",color:"#f8fafc",fontFamily:"system-ui, sans-serif"},children:(0,b.jsxs)("div",{style:{textAlign:"center",padding:"2rem",border:"1px solid rgba(239,68,68,0.4)",borderRadius:"0.5rem",maxWidth:"500px"},children:[(0,b.jsx)("h2",{style:{color:"#ef4444",marginBottom:"0.5rem",fontSize:"1.25rem"},children:"Something went wrong"}),(0,b.jsx)("p",{style:{color:"#94a3b8",marginBottom:"1.5rem"},children:a.message||"An unexpected error occurred."}),(0,b.jsx)("button",{onClick:f,style:{padding:"0.5rem 1.25rem",background:"#3b82f6",color:"white",border:"none",borderRadius:"0.375rem",cursor:"pointer",fontSize:"0.875rem"},children:"Try again"})]})})})})}])}];
2
2
 
3
3
  //# sourceMappingURL=app_global-error_tsx_1kp6l3x._.js.map
@@ -1,4 +1,4 @@
1
- module.exports=[22712,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(35112),e=a.i(38246),f=a.i(52562),g=a.i(89027),h=a.i(64831);let i=(0,h.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);var j=a.i(85650);let k=(0,h.default)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),l=(0,h.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);var m=a.i(41476);let n=(0,h.default)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),o=(0,h.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),p=(0,h.default)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),q=(0,h.default)("shield-x",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]),r=(0,h.default)("trash",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),s=(0,h.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var t=a.i(74215),u=a.i(65967),v=a.i(5050);let w=(0,v.createServerReference)("40fd166f9e08915649b8a51bc4f455a44462deefd1",v.callServer,void 0,v.findSourceMapURL,"getHookActivityAction"),x=(0,v.createServerReference)("60d4b56a98077468792db89d8812f1e5e786583628",v.callServer,void 0,v.findSourceMapURL,"searchHookActivityAction"),y=(0,v.createServerReference)("00f2651d6c61b8af94fb61a3e35baa07db7a565f71",v.callServer,void 0,v.findSourceMapURL,"getActivePausesAction");function z({pauses:a,now:d}){let[e,f]=(0,c.useState)(()=>Date.now());(0,c.useEffect)(()=>{let a=setInterval(()=>f(Date.now()),3e4);return()=>clearInterval(a)},[]);let g=d??e,h=a.filter(a=>a.expiresAt>g);if(0===h.length)return null;let i=h.reduce((a,b)=>a.expiresAt<b.expiresAt?a:b);return(0,b.jsxs)("div",{role:"status",className:"mb-4 flex items-start gap-2.5 rounded border border-amber-500/40 bg-amber-500/[0.07] px-3 py-2.5",children:[(0,b.jsx)(o,{className:"h-4 w-4 shrink-0 text-amber-500 mt-0.5","aria-hidden":"true"}),(0,b.jsxs)("div",{className:"text-xs leading-relaxed",children:[(0,b.jsxs)("p",{className:"font-medium text-foreground",children:["Enforcement is paused for ",h.length," session",1===h.length?"":"s"," —"," ",function(a){if(a<=0)return"expiring now";if(a<6e4)return"under a minute";let b=Math.round(a/6e4);if(b<60)return`${b}m`;let c=Math.floor(b/60),d=b%60;return 0===d?`${c}h`:`${c}h${d}m`}(i.expiresAt-g)," left",h.length>1?" on the next to expire":"","."]}),(0,b.jsxs)("p",{className:"text-muted-foreground mt-0.5",children:["Builtin, custom and convention policies are suspended for"," ",1===h.length?"that session":"those sessions","; cloud-managed policies keep enforcing. It lifts on its own — or run"," ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:"failproofai config --resume"}),"."]})]})]})}function A(){return(0,b.jsx)("span",{title:"Enforcement was paused for this session — local policies did not run",className:"ml-1.5 inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium uppercase tracking-wide border border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-500",children:"paused"})}function B({item:a}){if(!a.pausedBy)return null;let c="number"==typeof a.pauseExpiresAt?new Date(a.pauseExpiresAt).toLocaleTimeString():null;return(0,b.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3 mt-1 flex items-start gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2.5 py-2",children:[(0,b.jsx)(s,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,b.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Not enforced — paused."})," Enforcement was suspended for this session","cli"===a.pausedBy?" from the CLI":` by ${a.pausedBy}`,c?`, lifting at ${c}`:"",". Builtin, custom and convention policies did not run for this event; cloud-managed policies did."]})]})}let C=(0,v.createServerReference)("00b6455f46f538e1e0f7872d2d9c77b0195511e731",v.callServer,void 0,v.findSourceMapURL,"getHooksConfigAction"),D=(0,v.createServerReference)("605b9184ee6c68dfd18071b7cd687b276f30b2a74f",v.callServer,void 0,v.findSourceMapURL,"toggleCustomPolicyAction"),E=(0,v.createServerReference)("005b82e13b42131f7051c1e6c50a53397488f2b941",v.callServer,void 0,v.findSourceMapURL,"addBundledPackWebAction"),F=(0,v.createServerReference)("60aa1ce805f4904d4cdeccaaae4d76d4946ca5a9d2",v.callServer,void 0,v.findSourceMapURL,"addPackWebAction"),G=(0,v.createServerReference)("40d026a27c6a92fce5300b06bcf44fa1ce0e01709a",v.callServer,void 0,v.findSourceMapURL,"previewPackWebAction"),H=(0,v.createServerReference)("40dc4f9e49f77dfc2297f895811fd835ef1ccbddbf",v.callServer,void 0,v.findSourceMapURL,"removePackWebAction"),I=(0,v.createServerReference)("700600aa6454cbfa68fe29c391688523cd653e14c1",v.callServer,void 0,v.findSourceMapURL,"togglePackPolicyAction"),J=(0,v.createServerReference)("60cae434e394962a07674df6f52f22fe7b332ed128",v.callServer,void 0,v.findSourceMapURL,"installHooksWebAction"),K=(0,v.createServerReference)("60f12e9ff49120ca670f1fbff765bfd0768f125900",v.callServer,void 0,v.findSourceMapURL,"removeHooksWebAction"),L=(0,v.createServerReference)("60eaa0aad0a7c8253b6935f0ea15b16a343173f09f",v.callServer,void 0,v.findSourceMapURL,"updatePolicyParamsAction");var M=a.i(6236),N=a.i(10765),O=a.i(90619),P=a.i(95947),Q=a.i(87256);let R={claude:{PreToolUse:"block",UserPromptSubmit:"block",PermissionRequest:"block",Stop:"block",SubagentStop:"block",PreCompact:"block",PostToolBatch:"block",ConfigChange:"block",UserPromptExpansion:"block",TaskCreated:"block",TaskCompleted:"block",TeammateIdle:"block",Elicitation:"block",ElicitationResult:"block",PostToolUse:"observe",PostToolUseFailure:"observe",SessionStart:"observe",Setup:"observe",SubagentStart:"observe",SessionEnd:"observe",StopFailure:"observe",PermissionDenied:"observe",Notification:"observe",InstructionsLoaded:"observe",CwdChanged:"observe",FileChanged:"observe",PostCompact:"observe",WorktreeRemove:"observe"},codex:{PreToolUse:"block",PermissionRequest:"block",UserPromptSubmit:"block",Stop:"block",SubagentStop:"block",PostToolUse:"block",SessionStart:"observe",SubagentStart:"observe",PreCompact:"observe",PostCompact:"observe"},copilot:{PreToolUse:"block",Stop:"block",SubagentStop:"block",UserPromptSubmit:"block",PermissionRequest:"block",PostToolUse:"block",SessionStart:"observe",SessionEnd:"observe",PostToolUseFailure:"observe",PreCompact:"observe",Notification:"observe"},cursor:{PreToolUse:"block",Stop:"block",UserPromptSubmit:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"},opencode:{PreToolUse:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",UserPromptSubmit:"observe",PermissionRequest:"observe"},pi:{PreToolUse:"block",UserPromptSubmit:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",Stop:"observe"},hermes:{PreToolUse:"block",PostToolUse:"observe",SubagentStop:"observe",SessionStart:"observe",SessionEnd:"observe"},openclaw:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",SubagentStop:"observe",PreCompact:"observe"},factory:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PreCompact:"block",PostToolUse:"observe",SubagentStop:"observe",SessionStart:"observe",SessionEnd:"observe",Notification:"observe"},devin:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PermissionRequest:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"},antigravity:{PreToolUse:"block",Stop:"block",PostToolUse:"observe",UserPromptSubmit:"observe"},goose:{PreToolUse:"block",UserPromptSubmit:"observe",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"}};var S=a.i(80977),T=a.i(40695);function U({sessionId:a,transcriptPath:c,integration:d,cwd:f}){if(!a)return(0,b.jsx)("span",{className:"text-muted-foreground",children:"\\u2014"});let g=a?a.slice(0,8):"—",h="codex"===d||(c?.includes("/.codex/")??!1),i="copilot"===d||(c?.includes("/.copilot/session-state/")??!1),j="cursor"===d||(c?.includes("/.cursor/")??!1),k="opencode"===d||(c?.includes("/.local/share/opencode/")??!1)||(c?.includes("/.opencode/")??!1),l="pi"===d||(c?.includes("/.pi/")??!1);if(h||i||j||k||l){let c,d=f?(c=/^([A-Za-z]):[\\/](.*)$/.exec(f))?c[1]+"--"+c[2].replace(/[\\/]/g,"-"):f.replace(/[\\/]/g,"-"):h?"codex":i?"copilot":j?"cursor":k?"opencode":"pi";return(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(d)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g})}let m=c?function(a){let b=a.replace(/\\/g,"/").split("/").filter(Boolean);if(b.length<2)return null;let c=b[b.length-2];return!c||c.startsWith(".")?null:c}(c):null;return m?(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(m)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g}):(0,b.jsx)("span",{className:"text-muted-foreground font-mono",children:g})}function V({decision:a}){return"deny"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-red-500/10 text-red-400 border border-red-500/20",children:[(0,b.jsx)(q,{className:"h-3 w-3"}),"Deny"]}):"instruct"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[(0,b.jsx)(o,{className:"h-3 w-3"}),"Instruct"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(0,b.jsx)(p,{className:"h-3 w-3"}),"Allow"]})}function W({eventType:a}){return(0,b.jsx)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium bg-muted text-muted-foreground border border-border/50",children:a})}function X({integration:a}){if(!a)return null;let c=(0,Q.getCliLabel)(a),d=(0,Q.getCliBadgeClasses)(a);return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${d}`,title:`Agent CLI: ${c}`,children:c})}function Y({mode:a}){let c="default"===a;return(0,b.jsx)("span",{title:a,className:`inline-block max-w-full truncate rounded px-1.5 py-0.5 align-middle text-[0.6rem] font-medium border ${c?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:a})}function Z({ms:a}){return(0,b.jsx)("span",{className:`font-mono text-[0.7rem] ${a>500?"text-red-400":a>100?"text-amber-400":"text-muted-foreground"}`,children:a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`})}function $({text:a,field:d}){let[e,g]=(0,c.useState)(!1),{capture:h}=(0,N.usePostHog)(),i=async b=>{b.stopPropagation(),h("activity_copy_clicked",{field:d??"unknown"});try{await navigator.clipboard.writeText(a),g(!0),setTimeout(()=>g(!1),1500)}catch{let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b),g(!0),setTimeout(()=>g(!1),1500)}};return(0,b.jsx)("button",{onClick:i,className:"inline-flex items-center justify-center h-5 w-5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Copy",children:e?(0,b.jsx)(f.Check,{className:"h-3 w-3 text-emerald-400"}):(0,b.jsx)(j.Copy,{className:"h-3 w-3"})})}function _({value:a,onChange:c}){return(0,b.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5",children:[{label:"All",value:""},{label:"Allow",value:"allow"},{label:"Instruct",value:"instruct"},{label:"Deny",value:"deny"}].map(d=>(0,b.jsx)("button",{onClick:()=>c(d.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${a===d.value?"deny"===d.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===d.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===d.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.value))})}function aa({stats:a}){let c=a.totalEvents>0?a.denyCount/a.totalEvents*100:0,d=c.toFixed(c>=10?0:1),e=0===a.denyCount?"":c>=5?" is-deny":c>=2?" is-warn":"";return(0,b.jsxs)("div",{className:"stat-bar",role:"group","aria-label":"Activity stats",children:[(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"total events"}),(0,b.jsx)("span",{className:"value",children:a.totalEvents.toLocaleString()}),(0,b.jsx)("span",{className:"meta",children:"across all installed agents"})]}),(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"deny rate"}),(0,b.jsxs)("span",{className:`value${e}`,children:[d,"%"]}),(0,b.jsxs)("span",{className:"meta",children:[a.denyCount.toLocaleString()," of ",a.totalEvents.toLocaleString()," denied"]})]}),(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"top policy"}),(0,b.jsx)("span",{className:"value",style:{fontSize:16,fontWeight:500,color:a.topPolicy?"var(--accent-pink)":"var(--dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:a.topPolicy??void 0,children:a.topPolicy??"—"}),(0,b.jsx)("span",{className:"meta",children:"most-evaluated policy in scope"})]})]})}function ab({item:a}){if("observe"!==function(a,b){if(!a||!b)return;let c=R[a];if(c)return c[b]}(a.integration,a.eventType))return null;let c=a.matchedPolicies??[];if(0===c.length)return null;let d=a.integration?(0,Q.getCliLabel)(a.integration):"This CLI",e=c.map(a=>a.replace(/^(custom|\.failproofai-(project|user))\//,"")),f=1===e.length?e[0]:`${e.length} policies`,g="deny"===a.decision;return(0,b.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3 mt-1 flex items-start gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2.5 py-2",children:[(0,b.jsx)(s,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,b.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:g?"Not enforced.":"Ran, but cannot enforce here."})," ",(0,b.jsx)("span",{className:"font-mono",children:f})," ran on"," ",(0,b.jsx)("span",{className:"font-mono",children:a.eventType}),", but ",d," discards hook verdicts for this event",g?" — the action went ahead anyway.":", so a policy cannot block here."," ","Move the check to an event ",d," enforces on, such as"," ",(0,b.jsx)("span",{className:"font-mono",children:"PreToolUse"}),"."]})]})}function ac({item:a}){return(0,b.jsx)("tr",{children:(0,b.jsx)("td",{colSpan:11,className:"px-0 py-0",children:(0,b.jsxs)("div",{className:"activity-detail animate-expand text-xs",children:[(0,b.jsxs)("span",{className:"activity-detail-eyebrow",children:[(0,b.jsx)("span",{"aria-hidden":"true",children:"▾"}),"event detail"]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-2",children:[(0,b.jsx)(B,{item:a}),(0,b.jsx)(ab,{item:a}),a.policySource&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Decided by: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:"cloud"===a.policySource&&a.cloudPolicyId?`cloud \xb7 ${a.cloudPolicyId} version ${a.cloudVersion}`:a.policySource})]}),void 0!==a.cloudDeployment&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Cloud deployment: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cloudDeployment})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.sessionId??"—"}),a.sessionId&&(0,b.jsx)($,{text:a.sessionId,field:"session_id"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cwd??"—"}),a.cwd&&(0,b.jsx)($,{text:a.cwd,field:"cwd"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,b.jsx)("span",{className:"font-mono text-foreground break-all",children:a.transcriptPath??"—"}),a.transcriptPath?.startsWith("opencode-db://")&&(0,b.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),a.policyNames&&a.policyNames.length>1&&(0,b.jsxs)("div",{style:{marginTop:8},children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.policyNames.join(", ")})]}),a.reason&&(0,b.jsxs)("div",{style:{marginTop:8},children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,b.jsx)("span",{className:"text-foreground",children:a.reason})]})]})})})}function ad({hooksInstalled:a,onSwitchTab:d}){let{intervalSec:e}=(0,M.useAutoRefresh)(),{capture:f}=(0,N.usePostHog)(),h=(0,O.useUrlParams)(),i=(0,c.useRef)(!1),[j,k]=(0,c.useState)(()=>(0,P.paramToPage)(h.get("page"))),[l,m]=(0,c.useState)(null),[o,p]=(0,c.useState)([]),[q,r]=(0,c.useState)(null),[s,t]=(0,c.useState)(()=>{let a=h.get("decision");return"allow"===a||"deny"===a||"instruct"===a?a:""}),[v,B]=(0,c.useState)(()=>h.get("event")??""),[C,D]=(0,c.useState)(()=>h.get("policy")??""),[E,F]=(0,c.useState)(()=>h.get("session")??""),[G,H]=(0,c.useState)(()=>{let a=h.get("cli");return(0,Q.isKnownCli)(a)?a:""}),[I,J]=(0,c.useState)(()=>{let a=h.get("source");return"custom"===a||"convention"===a||"cloud"===a||"pack"===a?a:""}),K=(0,c.useRef)(null),L=(0,c.useRef)(!0),R=(0,c.useRef)({filterDecision:s,filterEventType:v,filterPolicy:C,filterSessionId:E,filterCli:G,filterSource:I});R.current={filterDecision:s,filterEventType:v,filterPolicy:C,filterSessionId:E,filterCli:G,filterSource:I},(0,c.useEffect)(()=>{if(!i.current){i.current=!0;return}h.setAll({decision:s||void 0,event:v||void 0,policy:C||void 0,session:E||void 0,cli:G||void 0,source:I||void 0,page:(0,P.pageToParam)(j)})},[s,v,C,E,G,I,j]);let T=""!==s||""!==v||""!==C||""!==E||""!==G||""!==I,$=(0,c.useCallback)(async a=>{try{let b,{filterDecision:c,filterEventType:d,filterPolicy:e,filterSessionId:f,filterCli:g,filterSource:h}=R.current;b=""!==c||""!==d||""!==e||""!==f||""!==g||""!==h?await x({decision:c||void 0,eventType:d||void 0,policyName:e||void 0,sessionId:f||void 0,integration:g||void 0,source:h||void 0},a):await w(a),m(b)}catch{}},[]);(0,c.useEffect)(()=>{$(j);let a=setInterval(()=>$(j),e>0?1e3*e:5e3);return()=>clearInterval(a)},[j,$,e]),(0,c.useEffect)(()=>{let a=!1,b=()=>{y().then(b=>{a||p(b)}).catch(()=>{})};b();let c=setInterval(b,e>0?1e3*e:5e3);return()=>{a=!0,clearInterval(c)}},[e]),(0,c.useEffect)(()=>(K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{if(k(1),r(null),$(1),L.current){L.current=!1;return}f("activity_filter_changed",{active_filter_count:+(""!==s)+ +(""!==v)+ +(""!==C)+ +(""!==E)+ +(""!==G),has_decision:""!==s,has_event_type:""!==v,has_policy:""!==C,has_session:""!==E,has_cli:""!==G,decision:s||null,event_type:v||null,cli:G||null})},300),()=>{K.current&&clearTimeout(K.current)}),[s,v,C,E,G]);let ab=l?.entries??[],ae=l?.totalPages??1;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(z,{pauses:o}),l?.stats&&l.stats.totalEvents>0&&(0,b.jsx)("div",{style:{marginBottom:18},children:(0,b.jsx)(aa,{stats:l.stats})}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"filter-bar",children:[(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"decision"}),(0,b.jsx)(_,{value:s,onChange:t})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"event"}),(0,b.jsxs)("select",{value:v,onChange:a=>B(a.target.value),className:"filter-input",children:[(0,b.jsx)("option",{value:"",children:"all events"}),(0,b.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,b.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,b.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,b.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,b.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,b.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"source"}),(0,b.jsxs)("select",{value:I,onChange:a=>{let b=a.target.value;J("custom"===b||"convention"===b||"cloud"===b||"pack"===b?b:"")},className:"filter-input","aria-label":"Filter by policy source",children:[(0,b.jsx)("option",{value:"",children:"all sources"}),(0,b.jsx)("option",{value:"custom",children:"custom"}),(0,b.jsx)("option",{value:"convention",children:"convention"}),(0,b.jsx)("option",{value:"cloud",children:"cloud"}),(0,b.jsx)("option",{value:"pack",children:"pack"})]})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"cli"}),(0,b.jsxs)("select",{value:G,onChange:a=>{let b=a.target.value;H(""===b||(0,Q.isKnownCli)(b)?b:"")},className:"filter-input","aria-label":"Filter by CLI",children:[(0,b.jsx)("option",{value:"",children:"all clis"}),Q.KNOWN_CLI_IDS.map(a=>(0,b.jsx)("option",{value:a,children:(0,Q.getCliLabel)(a)},a))]})]}),(0,b.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,b.jsx)("span",{className:"filter-label",children:"policy"}),(0,b.jsx)("input",{type:"text",value:C,onChange:a=>D(a.target.value),placeholder:"filter by policy…",className:"filter-input"})]}),(0,b.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,b.jsx)("span",{className:"filter-label",children:"session"}),(0,b.jsx)("input",{type:"text",value:E,onChange:a=>F(a.target.value),placeholder:"filter by session…",className:"filter-input"})]}),T&&(0,b.jsx)("button",{type:"button",className:"filter-clear",onClick:()=>{t(""),B(""),H(""),D(""),F(""),J("")},"aria-label":"Clear all filters",children:"[ clear ]"})]}),0===ab.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,b.jsx)(n,{className:"h-12 w-12 text-muted-foreground/30"}),!1===a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4 font-medium",children:"Policies are not installed"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:["Go to the"," ",(0,b.jsx)("button",{className:"underline hover:text-foreground transition-colors",onClick:()=>d?.("policies"),children:"Policies tab"})," ","and click ",(0,b.jsx)("span",{className:"font-mono bg-muted px-1 rounded",children:"Install"})," to enable policy monitoring."]})]}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4",children:T?"No matching activity.":"Waiting for hook events…"})]}):(0,b.jsx)("div",{className:"overflow-x-auto activity-table-wrap",children:(0,b.jsxs)("table",{className:"w-full text-xs activity-table",style:{tableLayout:"fixed"},children:[(0,b.jsxs)("colgroup",{children:[(0,b.jsx)("col",{style:{width:32}}),(0,b.jsx)("col",{style:{width:"7%"}}),(0,b.jsx)("col",{style:{width:"9%"}}),(0,b.jsx)("col",{style:{width:"12%"}}),(0,b.jsx)("col",{style:{width:"11%"}}),(0,b.jsx)("col",{style:{width:"9%"}}),(0,b.jsx)("col",{style:{width:"13%"}}),(0,b.jsx)("col",{style:{width:"12%"}}),(0,b.jsx)("col",{style:{width:"11%"}}),(0,b.jsx)("col",{style:{width:"8%"}}),(0,b.jsx)("col",{style:{width:"8%"}})]}),(0,b.jsx)("thead",{className:"activity-thead",children:(0,b.jsxs)("tr",{children:[(0,b.jsx)("th",{className:"px-4 py-3"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Time"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Decision"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Event"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"CLI"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Tool"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Policy"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Reason"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Mode"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Duration"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Session"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/30",children:ab.map((a,d)=>{let e="deny"===a.decision,h=q===d,i="instruct"===a.decision;return(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)("tr",{onClick:()=>{r(a=>{let b=a===d?null:d,c=ab[d];return f("activity_row_toggled",{expanded:null!==b,decision:c?.decision??null,policy_name:c?.policyName??null,event_type:c?.eventType??null}),b})},className:`activity-data-row cursor-pointer transition-colors ${e?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":i?"bg-amber-500/[0.03] hover:bg-amber-500/[0.07] border-l-2 border-l-amber-500/40":d%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${h?"bg-muted/20":""}`,children:[(0,b.jsx)("td",{className:"px-4 py-2",children:(0,b.jsx)(g.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${h?"rotate-0":"-rotate-90"}`})}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",title:new Date(a.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(0,S.formatRelativeTime)(a.timestamp)}),(0,b.jsxs)("td",{className:"px-3 py-2",children:[(0,b.jsx)(V,{decision:a.decision}),a.pausedBy&&(0,b.jsx)(A,{})]}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(W,{eventType:a.eventType})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(X,{integration:a.integration})}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.toolName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.policyNames&&a.policyNames.length>1?(0,b.jsxs)("span",{title:a.policyNames.join(", "),children:[a.policyNames[0],(0,b.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",a.policyNames.length-1]})]}):a.policyName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate",title:a.reason??"",children:a.reason??"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:a.permissionMode?(0,b.jsx)(Y,{mode:a.permissionMode}):"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(Z,{ms:a.durationMs})}),(0,b.jsx)("td",{className:"px-3 py-2",title:a.sessionId??"",children:(0,b.jsx)(U,{sessionId:a.sessionId,transcriptPath:a.transcriptPath,integration:a.integration,cwd:a.cwd})})]}),h&&(0,b.jsx)(ac,{item:a})]},`${a.timestamp}-${d}`)})})]})}),(0,b.jsx)(u.default,{currentPage:j,totalPages:ae,onPageChange:a=>{f("activity_pagination_changed",{from_page:j,to_page:a,total_pages:ae}),k(a),r(null)}})]})]})}function ae({enabled:a,onChange:c,disabled:d}){return(0,b.jsx)("button",{onClick:c,disabled:d,className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors disabled:opacity-40 ${a?"bg-emerald-500":"bg-muted-foreground/30"}`,"aria-label":a?"Disable policy":"Enable policy",children:(0,b.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform ${a?"translate-x-3.5":"translate-x-0.5"}`})})}function af({policy:a,onClose:d,onSave:e}){let f=a.params??{},g=a.currentParams??{},[h,i]=(0,c.useState)(()=>{let a={};for(let[b,c]of Object.entries(f)){let d=b in g?g[b]:c.default;a[b]=d}return a});(0,c.useEffect)(()=>{let a=a=>{"Escape"===a.key&&d()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[d]);let j=(a,b)=>{i(c=>({...c,[a]:b}))};return(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&d()},children:(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-sm font-mono font-semibold text-foreground",children:a.name}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]}),(0,b.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,b.jsx)(t.X,{className:"h-4 w-4"})})]}),(0,b.jsx)("div",{className:"overflow-y-auto flex-1 px-4 py-4 space-y-4",children:Object.entries(f).map(([a,c])=>(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1 font-mono",children:a}),(0,b.jsx)("p",{className:"text-[0.65rem] text-muted-foreground mb-1.5",children:c.description}),((a,c)=>{let d=h[a];if("boolean"===c.type)return(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,b.jsx)("input",{type:"checkbox",checked:!!d,onChange:b=>j(a,b.target.checked),className:"rounded border-border"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:c.description})]});if("number"===c.type)return(0,b.jsx)("input",{type:"number",value:"number"==typeof d?d:"",onChange:b=>j(a,Number(b.target.value)),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"});if("string[]"===c.type){let c=Array.isArray(d)?d.join("\n"):"";return(0,b.jsx)("textarea",{value:c,onChange:b=>j(a,b.target.value.split("\n").filter(a=>""!==a.trim())),rows:4,placeholder:"One entry per line",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-2 focus:ring-primary/40 resize-y"})}if("pattern[]"===c.type){let c=Array.isArray(d)?d:[];return(0,b.jsxs)("div",{className:"space-y-1.5",children:[c.map((d,e)=>(0,b.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,b.jsx)("input",{type:"text",value:d.regex,onChange:b=>{let d=[...c];d[e]={...d[e],regex:b.target.value},j(a,d)},placeholder:"regex",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs font-mono focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("input",{type:"text",value:d.label,onChange:b=>{let d=[...c];d[e]={...d[e],label:b.target.value},j(a,d)},placeholder:"label",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("button",{onClick:()=>j(a,c.filter((a,b)=>b!==e)),className:"text-muted-foreground/50 hover:text-destructive transition-colors",children:(0,b.jsx)(t.X,{className:"h-3.5 w-3.5"})})]},e)),(0,b.jsx)("button",{onClick:()=>j(a,[...c,{regex:"",label:""}]),className:"text-xs text-primary hover:underline",children:"+ Add pattern"})]})}return(0,b.jsx)("input",{type:"text",value:"string"==typeof d?d:"",onChange:b=>j(a,b.target.value),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"})})(a,c)]},a))}),(0,b.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,b.jsx)(T.Button,{variant:"outline",size:"sm",onClick:d,className:"h-7 text-xs",children:"Cancel"}),(0,b.jsx)(T.Button,{size:"sm",onClick:()=>e(h),className:"h-7 text-xs",children:"Save"})]})]})})}function ag({message:a,onDismiss:c,onInstall:e,isPending:f}){let{capture:g}=(0,N.usePostHog)();return(0,d.createPortal)((0,b.jsxs)("div",{className:"fixed top-4 right-4 z-[9999] w-full max-w-sm",style:{animation:"slideInFromRight 0.25s ease-out"},children:[(0,b.jsx)("style",{children:`
1
+ module.exports=[22712,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(35112),e=a.i(38246),f=a.i(52562),g=a.i(89027),h=a.i(64831);let i=(0,h.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);var j=a.i(85650);let k=(0,h.default)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),l=(0,h.default)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);var m=a.i(41476);let n=(0,h.default)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),o=(0,h.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),p=(0,h.default)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),q=(0,h.default)("shield-x",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]),r=(0,h.default)("trash",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]),s=(0,h.default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);var t=a.i(74215),u=a.i(65967),v=a.i(5050);let w=(0,v.createServerReference)("4037bcfdb2f730a3d281d456841cc048c23655b450",v.callServer,void 0,v.findSourceMapURL,"getHookActivityAction"),x=(0,v.createServerReference)("609c318d728a87a53cb332ec72a48951a1f2cd65c2",v.callServer,void 0,v.findSourceMapURL,"searchHookActivityAction"),y=(0,v.createServerReference)("00ed7012cd02c771c585849eee94d7a6053fea233a",v.callServer,void 0,v.findSourceMapURL,"getActivePausesAction");function z({pauses:a,now:d}){let[e,f]=(0,c.useState)(()=>Date.now());(0,c.useEffect)(()=>{let a=setInterval(()=>f(Date.now()),3e4);return()=>clearInterval(a)},[]);let g=d??e,h=a.filter(a=>a.expiresAt>g);if(0===h.length)return null;let i=h.reduce((a,b)=>a.expiresAt<b.expiresAt?a:b);return(0,b.jsxs)("div",{role:"status",className:"mb-4 flex items-start gap-2.5 rounded border border-amber-500/40 bg-amber-500/[0.07] px-3 py-2.5",children:[(0,b.jsx)(o,{className:"h-4 w-4 shrink-0 text-amber-500 mt-0.5","aria-hidden":"true"}),(0,b.jsxs)("div",{className:"text-xs leading-relaxed",children:[(0,b.jsxs)("p",{className:"font-medium text-foreground",children:["Enforcement is paused for ",h.length," session",1===h.length?"":"s"," —"," ",function(a){if(a<=0)return"expiring now";if(a<6e4)return"under a minute";let b=Math.round(a/6e4);if(b<60)return`${b}m`;let c=Math.floor(b/60),d=b%60;return 0===d?`${c}h`:`${c}h${d}m`}(i.expiresAt-g)," left",h.length>1?" on the next to expire":"","."]}),(0,b.jsxs)("p",{className:"text-muted-foreground mt-0.5",children:["Builtin, custom and convention policies are suspended for"," ",1===h.length?"that session":"those sessions","; cloud-managed policies keep enforcing. It lifts on its own — or run"," ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:"failproofai config --resume"}),"."]})]})]})}function A(){return(0,b.jsx)("span",{title:"Enforcement was paused for this session — local policies did not run",className:"ml-1.5 inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium uppercase tracking-wide border border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-500",children:"paused"})}function B({item:a}){if(!a.pausedBy)return null;let c="number"==typeof a.pauseExpiresAt?new Date(a.pauseExpiresAt).toLocaleTimeString():null;return(0,b.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3 mt-1 flex items-start gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2.5 py-2",children:[(0,b.jsx)(s,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,b.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Not enforced — paused."})," Enforcement was suspended for this session","cli"===a.pausedBy?" from the CLI":` by ${a.pausedBy}`,c?`, lifting at ${c}`:"",". Builtin, custom and convention policies did not run for this event; cloud-managed policies did."]})]})}let C=(0,v.createServerReference)("005522600d6fbb081686f93c46b7cfdd511952019c",v.callServer,void 0,v.findSourceMapURL,"getHooksConfigAction"),D=(0,v.createServerReference)("60bd0c397a5619455861677dac468240e4a94d7f7e",v.callServer,void 0,v.findSourceMapURL,"toggleCustomPolicyAction"),E=(0,v.createServerReference)("00ef9203a2377fd3bdfc62cd72b43e5c95dc6df935",v.callServer,void 0,v.findSourceMapURL,"addBundledPackWebAction"),F=(0,v.createServerReference)("6015944c0002e3de9925d099e3f93d86ad58dce223",v.callServer,void 0,v.findSourceMapURL,"addPackWebAction"),G=(0,v.createServerReference)("40ee5489fbcf5c2f737d28add3b6544ef7b44320f0",v.callServer,void 0,v.findSourceMapURL,"previewPackWebAction"),H=(0,v.createServerReference)("4049c5cd42665a8cb03cbe1799de52a0c5a7f17865",v.callServer,void 0,v.findSourceMapURL,"removePackWebAction"),I=(0,v.createServerReference)("7017a6c96fcc288ebdb8602e196fe8a16f0801c6e4",v.callServer,void 0,v.findSourceMapURL,"togglePackPolicyAction"),J=(0,v.createServerReference)("602791a5ab13510b48d89bd621813f716ed24a2425",v.callServer,void 0,v.findSourceMapURL,"installHooksWebAction"),K=(0,v.createServerReference)("60634fe91f588027e3e525da91d3e7e0161d87da14",v.callServer,void 0,v.findSourceMapURL,"removeHooksWebAction"),L=(0,v.createServerReference)("601d3b3485ed0a39e3878b085c3546657de5ec565f",v.callServer,void 0,v.findSourceMapURL,"updatePolicyParamsAction");var M=a.i(6236),N=a.i(10765),O=a.i(90619),P=a.i(95947),Q=a.i(87256);let R={claude:{PreToolUse:"block",UserPromptSubmit:"block",PermissionRequest:"block",Stop:"block",SubagentStop:"block",PreCompact:"block",PostToolBatch:"block",ConfigChange:"block",UserPromptExpansion:"block",TaskCreated:"block",TaskCompleted:"block",TeammateIdle:"block",Elicitation:"block",ElicitationResult:"block",PostToolUse:"observe",PostToolUseFailure:"observe",SessionStart:"observe",Setup:"observe",SubagentStart:"observe",SessionEnd:"observe",StopFailure:"observe",PermissionDenied:"observe",Notification:"observe",InstructionsLoaded:"observe",CwdChanged:"observe",FileChanged:"observe",PostCompact:"observe",WorktreeRemove:"observe"},codex:{PreToolUse:"block",PermissionRequest:"block",UserPromptSubmit:"block",Stop:"block",SubagentStop:"block",PostToolUse:"block",SessionStart:"observe",SubagentStart:"observe",PreCompact:"observe",PostCompact:"observe"},copilot:{PreToolUse:"block",Stop:"block",SubagentStop:"block",UserPromptSubmit:"block",PermissionRequest:"block",PostToolUse:"block",SessionStart:"observe",SessionEnd:"observe",PostToolUseFailure:"observe",PreCompact:"observe",Notification:"observe"},cursor:{PreToolUse:"block",Stop:"block",UserPromptSubmit:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"},opencode:{PreToolUse:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",UserPromptSubmit:"observe",PermissionRequest:"observe"},pi:{PreToolUse:"block",UserPromptSubmit:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",Stop:"observe"},hermes:{PreToolUse:"block",PostToolUse:"observe",SubagentStop:"observe",SessionStart:"observe",SessionEnd:"observe"},openclaw:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe",SubagentStop:"observe",PreCompact:"observe"},factory:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PreCompact:"block",PostToolUse:"observe",SubagentStop:"observe",SessionStart:"observe",SessionEnd:"observe",Notification:"observe"},devin:{PreToolUse:"block",UserPromptSubmit:"block",Stop:"block",PermissionRequest:"block",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"},antigravity:{PreToolUse:"block",Stop:"block",PostToolUse:"observe",UserPromptSubmit:"observe"},goose:{PreToolUse:"block",UserPromptSubmit:"observe",PostToolUse:"observe",SessionStart:"observe",SessionEnd:"observe"}};var S=a.i(80977),T=a.i(40695);function U({sessionId:a,transcriptPath:c,integration:d,cwd:f}){if(!a)return(0,b.jsx)("span",{className:"text-muted-foreground",children:"\\u2014"});let g=a?a.slice(0,8):"—",h="codex"===d||(c?.includes("/.codex/")??!1),i="copilot"===d||(c?.includes("/.copilot/session-state/")??!1),j="cursor"===d||(c?.includes("/.cursor/")??!1),k="opencode"===d||(c?.includes("/.local/share/opencode/")??!1)||(c?.includes("/.opencode/")??!1),l="pi"===d||(c?.includes("/.pi/")??!1);if(h||i||j||k||l){let c,d=f?(c=/^([A-Za-z]):[\\/](.*)$/.exec(f))?c[1]+"--"+c[2].replace(/[\\/]/g,"-"):f.replace(/[\\/]/g,"-"):h?"codex":i?"copilot":j?"cursor":k?"opencode":"pi";return(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(d)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g})}let m=c?function(a){let b=a.replace(/\\/g,"/").split("/").filter(Boolean);if(b.length<2)return null;let c=b[b.length-2];return!c||c.startsWith(".")?null:c}(c):null;return m?(0,b.jsx)(e.default,{href:`/project/${encodeURIComponent(m)}/session/${encodeURIComponent(a)}`,className:"text-primary hover:underline font-mono",onClick:a=>a.stopPropagation(),children:g}):(0,b.jsx)("span",{className:"text-muted-foreground font-mono",children:g})}function V({decision:a}){return"deny"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-red-500/10 text-red-400 border border-red-500/20",children:[(0,b.jsx)(q,{className:"h-3 w-3"}),"Deny"]}):"instruct"===a?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[(0,b.jsx)(o,{className:"h-3 w-3"}),"Instruct"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.65rem] font-semibold tracking-wide uppercase bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(0,b.jsx)(p,{className:"h-3 w-3"}),"Allow"]})}function W({eventType:a}){return(0,b.jsx)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium bg-muted text-muted-foreground border border-border/50",children:a})}function X({integration:a}){if(!a)return null;let c=(0,Q.getCliLabel)(a),d=(0,Q.getCliBadgeClasses)(a);return(0,b.jsx)("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium border ${d}`,title:`Agent CLI: ${c}`,children:c})}function Y({mode:a}){let c="default"===a;return(0,b.jsx)("span",{title:a,className:`inline-block max-w-full truncate rounded px-1.5 py-0.5 align-middle text-[0.6rem] font-medium border ${c?"bg-sky-500/10 text-sky-400 border-sky-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:a})}function Z({ms:a}){return(0,b.jsx)("span",{className:`font-mono text-[0.7rem] ${a>500?"text-red-400":a>100?"text-amber-400":"text-muted-foreground"}`,children:a<1e3?`${a}ms`:`${(a/1e3).toFixed(1)}s`})}function $({text:a,field:d}){let[e,g]=(0,c.useState)(!1),{capture:h}=(0,N.usePostHog)(),i=async b=>{b.stopPropagation(),h("activity_copy_clicked",{field:d??"unknown"});try{await navigator.clipboard.writeText(a),g(!0),setTimeout(()=>g(!1),1500)}catch{let b=document.createElement("textarea");b.value=a,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b),g(!0),setTimeout(()=>g(!1),1500)}};return(0,b.jsx)("button",{onClick:i,className:"inline-flex items-center justify-center h-5 w-5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Copy",children:e?(0,b.jsx)(f.Check,{className:"h-3 w-3 text-emerald-400"}):(0,b.jsx)(j.Copy,{className:"h-3 w-3"})})}function _({value:a,onChange:c}){return(0,b.jsx)("div",{className:"inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5",children:[{label:"All",value:""},{label:"Allow",value:"allow"},{label:"Instruct",value:"instruct"},{label:"Deny",value:"deny"}].map(d=>(0,b.jsx)("button",{onClick:()=>c(d.value),className:`px-2.5 py-1 text-[0.65rem] font-medium rounded transition-all ${a===d.value?"deny"===d.value?"bg-red-500/15 text-red-400 shadow-sm":"allow"===d.value?"bg-emerald-500/15 text-emerald-400 shadow-sm":"instruct"===d.value?"bg-amber-500/15 text-amber-400 shadow-sm":"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:d.label},d.value))})}function aa({stats:a}){let c=a.totalEvents>0?a.denyCount/a.totalEvents*100:0,d=c.toFixed(c>=10?0:1),e=0===a.denyCount?"":c>=5?" is-deny":c>=2?" is-warn":"";return(0,b.jsxs)("div",{className:"stat-bar",role:"group","aria-label":"Activity stats",children:[(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"total events"}),(0,b.jsx)("span",{className:"value",children:a.totalEvents.toLocaleString()}),(0,b.jsx)("span",{className:"meta",children:"across all installed agents"})]}),(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"deny rate"}),(0,b.jsxs)("span",{className:`value${e}`,children:[d,"%"]}),(0,b.jsxs)("span",{className:"meta",children:[a.denyCount.toLocaleString()," of ",a.totalEvents.toLocaleString()," denied"]})]}),(0,b.jsxs)("div",{className:"stat-cell",children:[(0,b.jsx)("span",{className:"eyebrow",children:"top policy"}),(0,b.jsx)("span",{className:"value",style:{fontSize:16,fontWeight:500,color:a.topPolicy?"var(--accent-pink)":"var(--dim)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:a.topPolicy??void 0,children:a.topPolicy??"—"}),(0,b.jsx)("span",{className:"meta",children:"most-evaluated policy in scope"})]})]})}function ab({item:a}){if("observe"!==function(a,b){if(!a||!b)return;let c=R[a];if(c)return c[b]}(a.integration,a.eventType))return null;let c=a.matchedPolicies??[];if(0===c.length)return null;let d=a.integration?(0,Q.getCliLabel)(a.integration):"This CLI",e=c.map(a=>a.replace(/^(custom|\.failproofai-(project|user))\//,"")),f=1===e.length?e[0]:`${e.length} policies`,g="deny"===a.decision;return(0,b.jsxs)("div",{className:"sm:col-span-2 lg:col-span-3 mt-1 flex items-start gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2.5 py-2",children:[(0,b.jsx)(s,{className:"h-3.5 w-3.5 shrink-0 text-amber-500/80 mt-0.5","aria-hidden":"true"}),(0,b.jsxs)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:g?"Not enforced.":"Ran, but cannot enforce here."})," ",(0,b.jsx)("span",{className:"font-mono",children:f})," ran on"," ",(0,b.jsx)("span",{className:"font-mono",children:a.eventType}),", but ",d," discards hook verdicts for this event",g?" — the action went ahead anyway.":", so a policy cannot block here."," ","Move the check to an event ",d," enforces on, such as"," ",(0,b.jsx)("span",{className:"font-mono",children:"PreToolUse"}),"."]})]})}function ac({item:a}){return(0,b.jsx)("tr",{children:(0,b.jsx)("td",{colSpan:11,className:"px-0 py-0",children:(0,b.jsxs)("div",{className:"activity-detail animate-expand text-xs",children:[(0,b.jsxs)("span",{className:"activity-detail-eyebrow",children:[(0,b.jsx)("span",{"aria-hidden":"true",children:"▾"}),"event detail"]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-x-8 gap-y-2",children:[(0,b.jsx)(B,{item:a}),(0,b.jsx)(ab,{item:a}),a.policySource&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Decided by: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:"cloud"===a.policySource&&a.cloudPolicyId?`cloud \xb7 ${a.cloudPolicyId} version ${a.cloudVersion}`:a.policySource})]}),void 0!==a.cloudDeployment&&(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Cloud deployment: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cloudDeployment})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Session ID: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.sessionId??"—"}),a.sessionId&&(0,b.jsx)($,{text:a.sessionId,field:"session_id"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"CWD: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.cwd??"—"}),a.cwd&&(0,b.jsx)($,{text:a.cwd,field:"cwd"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Transcript: "}),(0,b.jsx)("span",{className:"font-mono text-foreground break-all",children:a.transcriptPath??"—"}),a.transcriptPath?.startsWith("opencode-db://")&&(0,b.jsx)("span",{className:"text-muted-foreground ml-1",children:"(stored in opencode DB)"})]})]}),a.policyNames&&a.policyNames.length>1&&(0,b.jsxs)("div",{style:{marginTop:8},children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Policies: "}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:a.policyNames.join(", ")})]}),a.reason&&(0,b.jsxs)("div",{style:{marginTop:8},children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Full reason: "}),(0,b.jsx)("span",{className:"text-foreground",children:a.reason})]})]})})})}function ad({hooksInstalled:a,onSwitchTab:d}){let{intervalSec:e}=(0,M.useAutoRefresh)(),{capture:f}=(0,N.usePostHog)(),h=(0,O.useUrlParams)(),i=(0,c.useRef)(!1),[j,k]=(0,c.useState)(()=>(0,P.paramToPage)(h.get("page"))),[l,m]=(0,c.useState)(null),[o,p]=(0,c.useState)([]),[q,r]=(0,c.useState)(null),[s,t]=(0,c.useState)(()=>{let a=h.get("decision");return"allow"===a||"deny"===a||"instruct"===a?a:""}),[v,B]=(0,c.useState)(()=>h.get("event")??""),[C,D]=(0,c.useState)(()=>h.get("policy")??""),[E,F]=(0,c.useState)(()=>h.get("session")??""),[G,H]=(0,c.useState)(()=>{let a=h.get("cli");return(0,Q.isKnownCli)(a)?a:""}),[I,J]=(0,c.useState)(()=>{let a=h.get("source");return"custom"===a||"convention"===a||"cloud"===a||"pack"===a?a:""}),K=(0,c.useRef)(null),L=(0,c.useRef)(!0),R=(0,c.useRef)({filterDecision:s,filterEventType:v,filterPolicy:C,filterSessionId:E,filterCli:G,filterSource:I});R.current={filterDecision:s,filterEventType:v,filterPolicy:C,filterSessionId:E,filterCli:G,filterSource:I},(0,c.useEffect)(()=>{if(!i.current){i.current=!0;return}h.setAll({decision:s||void 0,event:v||void 0,policy:C||void 0,session:E||void 0,cli:G||void 0,source:I||void 0,page:(0,P.pageToParam)(j)})},[s,v,C,E,G,I,j]);let T=""!==s||""!==v||""!==C||""!==E||""!==G||""!==I,$=(0,c.useCallback)(async a=>{try{let b,{filterDecision:c,filterEventType:d,filterPolicy:e,filterSessionId:f,filterCli:g,filterSource:h}=R.current;b=""!==c||""!==d||""!==e||""!==f||""!==g||""!==h?await x({decision:c||void 0,eventType:d||void 0,policyName:e||void 0,sessionId:f||void 0,integration:g||void 0,source:h||void 0},a):await w(a),m(b)}catch{}},[]);(0,c.useEffect)(()=>{$(j);let a=setInterval(()=>$(j),e>0?1e3*e:5e3);return()=>clearInterval(a)},[j,$,e]),(0,c.useEffect)(()=>{let a=!1,b=()=>{y().then(b=>{a||p(b)}).catch(()=>{})};b();let c=setInterval(b,e>0?1e3*e:5e3);return()=>{a=!0,clearInterval(c)}},[e]),(0,c.useEffect)(()=>(K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{if(k(1),r(null),$(1),L.current){L.current=!1;return}f("activity_filter_changed",{active_filter_count:+(""!==s)+ +(""!==v)+ +(""!==C)+ +(""!==E)+ +(""!==G),has_decision:""!==s,has_event_type:""!==v,has_policy:""!==C,has_session:""!==E,has_cli:""!==G,decision:s||null,event_type:v||null,cli:G||null})},300),()=>{K.current&&clearTimeout(K.current)}),[s,v,C,E,G]);let ab=l?.entries??[],ae=l?.totalPages??1;return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(z,{pauses:o}),l?.stats&&l.stats.totalEvents>0&&(0,b.jsx)("div",{style:{marginBottom:18},children:(0,b.jsx)(aa,{stats:l.stats})}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"filter-bar",children:[(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"decision"}),(0,b.jsx)(_,{value:s,onChange:t})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"event"}),(0,b.jsxs)("select",{value:v,onChange:a=>B(a.target.value),className:"filter-input",children:[(0,b.jsx)("option",{value:"",children:"all events"}),(0,b.jsx)("option",{value:"PreToolUse",children:"PreToolUse"}),(0,b.jsx)("option",{value:"PostToolUse",children:"PostToolUse"}),(0,b.jsx)("option",{value:"SessionStart",children:"SessionStart"}),(0,b.jsx)("option",{value:"SessionEnd",children:"SessionEnd"}),(0,b.jsx)("option",{value:"UserPromptSubmit",children:"UserPromptSubmit"}),(0,b.jsx)("option",{value:"PermissionRequest",children:"PermissionRequest"})]})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"source"}),(0,b.jsxs)("select",{value:I,onChange:a=>{let b=a.target.value;J("custom"===b||"convention"===b||"cloud"===b||"pack"===b?b:"")},className:"filter-input","aria-label":"Filter by policy source",children:[(0,b.jsx)("option",{value:"",children:"all sources"}),(0,b.jsx)("option",{value:"custom",children:"custom"}),(0,b.jsx)("option",{value:"convention",children:"convention"}),(0,b.jsx)("option",{value:"cloud",children:"cloud"}),(0,b.jsx)("option",{value:"pack",children:"pack"})]})]}),(0,b.jsxs)("div",{className:"filter-group",children:[(0,b.jsx)("span",{className:"filter-label",children:"cli"}),(0,b.jsxs)("select",{value:G,onChange:a=>{let b=a.target.value;H(""===b||(0,Q.isKnownCli)(b)?b:"")},className:"filter-input","aria-label":"Filter by CLI",children:[(0,b.jsx)("option",{value:"",children:"all clis"}),Q.KNOWN_CLI_IDS.map(a=>(0,b.jsx)("option",{value:a,children:(0,Q.getCliLabel)(a)},a))]})]}),(0,b.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,b.jsx)("span",{className:"filter-label",children:"policy"}),(0,b.jsx)("input",{type:"text",value:C,onChange:a=>D(a.target.value),placeholder:"filter by policy…",className:"filter-input"})]}),(0,b.jsxs)("div",{className:"filter-group filter-group--grow",children:[(0,b.jsx)("span",{className:"filter-label",children:"session"}),(0,b.jsx)("input",{type:"text",value:E,onChange:a=>F(a.target.value),placeholder:"filter by session…",className:"filter-input"})]}),T&&(0,b.jsx)("button",{type:"button",className:"filter-clear",onClick:()=>{t(""),B(""),H(""),D(""),F(""),J("")},"aria-label":"Clear all filters",children:"[ clear ]"})]}),0===ab.length?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 px-4 text-center",children:[(0,b.jsx)(n,{className:"h-12 w-12 text-muted-foreground/30"}),!1===a?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4 font-medium",children:"Policies are not installed"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground mt-1 max-w-sm",children:["Go to the"," ",(0,b.jsx)("button",{className:"underline hover:text-foreground transition-colors",onClick:()=>d?.("policies"),children:"Policies tab"})," ","and click ",(0,b.jsx)("span",{className:"font-mono bg-muted px-1 rounded",children:"Install"})," to enable policy monitoring."]})]}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground mt-4",children:T?"No matching activity.":"Waiting for hook events…"})]}):(0,b.jsx)("div",{className:"overflow-x-auto activity-table-wrap",children:(0,b.jsxs)("table",{className:"w-full text-xs activity-table",style:{tableLayout:"fixed"},children:[(0,b.jsxs)("colgroup",{children:[(0,b.jsx)("col",{style:{width:32}}),(0,b.jsx)("col",{style:{width:"7%"}}),(0,b.jsx)("col",{style:{width:"9%"}}),(0,b.jsx)("col",{style:{width:"12%"}}),(0,b.jsx)("col",{style:{width:"11%"}}),(0,b.jsx)("col",{style:{width:"9%"}}),(0,b.jsx)("col",{style:{width:"13%"}}),(0,b.jsx)("col",{style:{width:"12%"}}),(0,b.jsx)("col",{style:{width:"11%"}}),(0,b.jsx)("col",{style:{width:"8%"}}),(0,b.jsx)("col",{style:{width:"8%"}})]}),(0,b.jsx)("thead",{className:"activity-thead",children:(0,b.jsxs)("tr",{children:[(0,b.jsx)("th",{className:"px-4 py-3"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Time"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Decision"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Event"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"CLI"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Tool"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Policy"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Reason"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Mode"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Duration"}),(0,b.jsx)("th",{className:"px-3 py-3 activity-th",children:"Session"})]})}),(0,b.jsx)("tbody",{className:"divide-y divide-border/30",children:ab.map((a,d)=>{let e="deny"===a.decision,h=q===d,i="instruct"===a.decision;return(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)("tr",{onClick:()=>{r(a=>{let b=a===d?null:d,c=ab[d];return f("activity_row_toggled",{expanded:null!==b,decision:c?.decision??null,policy_name:c?.policyName??null,event_type:c?.eventType??null}),b})},className:`activity-data-row cursor-pointer transition-colors ${e?"bg-red-500/[0.03] hover:bg-red-500/[0.07] border-l-2 border-l-red-500/40":i?"bg-amber-500/[0.03] hover:bg-amber-500/[0.07] border-l-2 border-l-amber-500/40":d%2==0?"hover:bg-muted/30":"bg-muted/[0.04] hover:bg-muted/30"} ${h?"bg-muted/20":""}`,children:[(0,b.jsx)("td",{className:"px-4 py-2",children:(0,b.jsx)(g.ChevronDown,{className:`h-3.5 w-3.5 text-muted-foreground transition-transform duration-150 ${h?"rotate-0":"-rotate-90"}`})}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground whitespace-nowrap",title:new Date(a.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),children:(0,S.formatRelativeTime)(a.timestamp)}),(0,b.jsxs)("td",{className:"px-3 py-2",children:[(0,b.jsx)(V,{decision:a.decision}),a.pausedBy&&(0,b.jsx)(A,{})]}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(W,{eventType:a.eventType})}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(X,{integration:a.integration})}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.toolName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 font-mono text-foreground",children:a.policyNames&&a.policyNames.length>1?(0,b.jsxs)("span",{title:a.policyNames.join(", "),children:[a.policyNames[0],(0,b.jsxs)("span",{className:"text-muted-foreground text-[0.6rem]",children:[" +",a.policyNames.length-1]})]}):a.policyName??"—"}),(0,b.jsx)("td",{className:"px-3 py-2 text-muted-foreground truncate",title:a.reason??"",children:a.reason??"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:a.permissionMode?(0,b.jsx)(Y,{mode:a.permissionMode}):"—"}),(0,b.jsx)("td",{className:"px-3 py-2",children:(0,b.jsx)(Z,{ms:a.durationMs})}),(0,b.jsx)("td",{className:"px-3 py-2",title:a.sessionId??"",children:(0,b.jsx)(U,{sessionId:a.sessionId,transcriptPath:a.transcriptPath,integration:a.integration,cwd:a.cwd})})]}),h&&(0,b.jsx)(ac,{item:a})]},`${a.timestamp}-${d}`)})})]})}),(0,b.jsx)(u.default,{currentPage:j,totalPages:ae,onPageChange:a=>{f("activity_pagination_changed",{from_page:j,to_page:a,total_pages:ae}),k(a),r(null)}})]})]})}function ae({enabled:a,onChange:c,disabled:d}){return(0,b.jsx)("button",{onClick:c,disabled:d,className:`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors disabled:opacity-40 ${a?"bg-emerald-500":"bg-muted-foreground/30"}`,"aria-label":a?"Disable policy":"Enable policy",children:(0,b.jsx)("span",{className:`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform ${a?"translate-x-3.5":"translate-x-0.5"}`})})}function af({policy:a,onClose:d,onSave:e}){let f=a.params??{},g=a.currentParams??{},[h,i]=(0,c.useState)(()=>{let a={};for(let[b,c]of Object.entries(f)){let d=b in g?g[b]:c.default;a[b]=d}return a});(0,c.useEffect)(()=>{let a=a=>{"Escape"===a.key&&d()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[d]);let j=(a,b)=>{i(c=>({...c,[a]:b}))};return(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:a=>{a.target===a.currentTarget&&d()},children:(0,b.jsxs)("div",{className:"bg-card border border-border rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[80vh] flex flex-col",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-sm font-mono font-semibold text-foreground",children:a.name}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:a.description})]}),(0,b.jsx)("button",{onClick:d,className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,b.jsx)(t.X,{className:"h-4 w-4"})})]}),(0,b.jsx)("div",{className:"overflow-y-auto flex-1 px-4 py-4 space-y-4",children:Object.entries(f).map(([a,c])=>(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-semibold text-foreground mb-1 font-mono",children:a}),(0,b.jsx)("p",{className:"text-[0.65rem] text-muted-foreground mb-1.5",children:c.description}),((a,c)=>{let d=h[a];if("boolean"===c.type)return(0,b.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,b.jsx)("input",{type:"checkbox",checked:!!d,onChange:b=>j(a,b.target.checked),className:"rounded border-border"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:c.description})]});if("number"===c.type)return(0,b.jsx)("input",{type:"number",value:"number"==typeof d?d:"",onChange:b=>j(a,Number(b.target.value)),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"});if("string[]"===c.type){let c=Array.isArray(d)?d.join("\n"):"";return(0,b.jsx)("textarea",{value:c,onChange:b=>j(a,b.target.value.split("\n").filter(a=>""!==a.trim())),rows:4,placeholder:"One entry per line",className:"w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-2 focus:ring-primary/40 resize-y"})}if("pattern[]"===c.type){let c=Array.isArray(d)?d:[];return(0,b.jsxs)("div",{className:"space-y-1.5",children:[c.map((d,e)=>(0,b.jsxs)("div",{className:"flex gap-1.5 items-center",children:[(0,b.jsx)("input",{type:"text",value:d.regex,onChange:b=>{let d=[...c];d[e]={...d[e],regex:b.target.value},j(a,d)},placeholder:"regex",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs font-mono focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("input",{type:"text",value:d.label,onChange:b=>{let d=[...c];d[e]={...d[e],label:b.target.value},j(a,d)},placeholder:"label",className:"flex-1 h-6 rounded border border-border bg-background px-2 text-xs focus:outline-none focus:ring-2 focus:ring-primary/40"}),(0,b.jsx)("button",{onClick:()=>j(a,c.filter((a,b)=>b!==e)),className:"text-muted-foreground/50 hover:text-destructive transition-colors",children:(0,b.jsx)(t.X,{className:"h-3.5 w-3.5"})})]},e)),(0,b.jsx)("button",{onClick:()=>j(a,[...c,{regex:"",label:""}]),className:"text-xs text-primary hover:underline",children:"+ Add pattern"})]})}return(0,b.jsx)("input",{type:"text",value:"string"==typeof d?d:"",onChange:b=>j(a,b.target.value),className:"w-full h-7 rounded border border-border bg-background px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-primary/40"})})(a,c)]},a))}),(0,b.jsxs)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-border",children:[(0,b.jsx)(T.Button,{variant:"outline",size:"sm",onClick:d,className:"h-7 text-xs",children:"Cancel"}),(0,b.jsx)(T.Button,{size:"sm",onClick:()=>e(h),className:"h-7 text-xs",children:"Save"})]})]})})}function ag({message:a,onDismiss:c,onInstall:e,isPending:f}){let{capture:g}=(0,N.usePostHog)();return(0,d.createPortal)((0,b.jsxs)("div",{className:"fixed top-4 right-4 z-[9999] w-full max-w-sm",style:{animation:"slideInFromRight 0.25s ease-out"},children:[(0,b.jsx)("style",{children:`
2
2
  @keyframes slideInFromRight {
3
3
  from { transform: translateX(calc(100% + 1rem)); opacity: 0; }
4
4
  to { transform: translateX(0); opacity: 1; }
@@ -1,3 +1,3 @@
1
- module.exports=[41857,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(5050);let e=(0,d.createServerReference)("00fba8e3afdca9169f059ee29f0a079b25dadd01d6",d.callServer,void 0,d.findSourceMapURL,"getScheduledAuditAction"),f=(0,d.createServerReference)("40c02d8b68c2c311ae947c910df0ffa7b94933324e",d.callServer,void 0,d.findSourceMapURL,"setAutoAuditAction"),g=(0,d.createServerReference)("409282b29dd0a877370c6bdc276c47c030e8308dce",d.callServer,void 0,d.findSourceMapURL,"setAuditIntervalAction");var h=a.i(89564),i=a.i(10765),j=a.i(17094);let k=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function l(a){if((0,j.isAbortError)(a))return"request timed out. check your network and try again.";let b=a instanceof Error?a.message:String(a);return`network error: ${b}`}function m({open:a,headline:d="where to route the reminder?",subhead:e="we'll send a one-time code to confirm.",onClose:f,onAuthed:g,source:h="unknown"}){let{capture:n}=(0,i.usePostHog)(),[o,p]=(0,c.useState)({kind:"email",error:null}),[q,r]=(0,c.useState)(!1),s=(0,c.useRef)(!1),t=(0,c.useRef)(null),u=(0,c.useRef)(null);(0,c.useEffect)(()=>{a&&(p({kind:"email",error:null}),r(!1),s.current=!1,n("audit_auth_dialog_opened",{source:h}))},[n,a,h]);let v=(0,c.useRef)(!1);(0,c.useEffect)(()=>{if(a){v.current=!0;return}v.current&&!s.current&&n("audit_auth_dialog_dismissed",{source:h,step:o.kind}),v.current=!1},[n,a,h,o.kind]),(0,c.useEffect)(()=>{if(!a)return;let b=setTimeout(()=>{"email"===o.kind?t.current?.focus():"code"===o.kind&&u.current?.focus()},50);return()=>clearTimeout(b)},[a,o.kind]),(0,c.useEffect)(()=>{if(!a)return;let b=a=>{"Escape"!==a.key||q||f()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[a,q,f]);let w="code"===o.kind&&o.resendIn>0;(0,c.useEffect)(()=>{if(!w)return;let a=setInterval(()=>{p(a=>"code"===a.kind?{...a,resendIn:Math.max(0,a.resendIn-1)}:a)},1e3);return()=>clearInterval(a)},[w]);let x=(0,c.useCallback)(async(a,b={})=>{let{isResend:c=!1}=b,d=a=>{c?p(b=>"code"===b.kind?{...b,error:a}:b):p({kind:"email",error:a})};r(!0);try{let b=await (0,j.fetchWithTimeout)("/api/auth/login-request",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({email:a})}),c=await b.json().catch(()=>({}));if(!b.ok){let a=c.message??"could not send code.";"rate_limited"===c.code&&void 0!==c.retry_after_secs?a=`too many tries. wait ${c.retry_after_secs}s and try again.`:"upstream_unreachable"===c.code&&(a="api-server unreachable. check your network."),d(a);return}p({kind:"code",email:a,error:null,expiresIn:c.expires_in??600,resendIn:c.resend_available_in??30})}catch(a){d(l(a))}finally{r(!1)}},[]),y=(0,c.useCallback)(async(a,b)=>{r(!0);try{let c=await (0,j.fetchWithTimeout)("/api/auth/login-verify",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({email:a,code:b})}),d=await c.json().catch(()=>({}));if(!c.ok||!d.authenticated||!d.user){let a=d.message??"invalid code.";"invalid_code"===d.code&&(a="wrong code, or it expired. try again."),p(b=>"code"===b.kind?{...b,error:a}:b);return}s.current=!0,n("audit_auth_dialog_succeeded",{source:h}),p({kind:"done",user:d.user}),g(d.user)}catch(b){let a=l(b);p(b=>"code"===b.kind?{...b,error:a}:b)}finally{r(!1)}},[n,g,h]),z=(0,c.useCallback)(async a=>{if(a.preventDefault(),q||"email"!==o.kind)return;let b=String(new FormData(a.currentTarget).get("email")??"").trim().toLowerCase();k.test(b)?await x(b):p({kind:"email",error:"that doesn't look like an email."})},[q,o,x]),A=(0,c.useCallback)(async a=>{if(a.preventDefault(),q||"code"!==o.kind)return;let b=String(new FormData(a.currentTarget).get("code")??"").trim();b.length<4||b.length>12?p(a=>"code"===a.kind?{...a,error:"code is 4–12 characters."}:a):await y(o.email,b)},[q,o,y]),B=(0,c.useCallback)(async()=>{"code"!==o.kind||o.resendIn>0||q||await x(o.email,{isResend:!0})},[o,q,x]);return a?(0,b.jsx)("div",{className:"auth-dialog-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"auth-dialog-title",onClick:a=>{q||a.target!==a.currentTarget||f()},children:(0,b.jsxs)("div",{className:"auth-dialog",children:[(0,b.jsx)("button",{type:"button",className:"auth-close",onClick:f,disabled:q,"aria-label":"close",children:"×"}),(0,b.jsx)("h2",{id:"auth-dialog-title",className:"auth-headline",children:d}),"email"===o.kind&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"auth-sub",children:e}),(0,b.jsxs)("form",{onSubmit:z,className:"auth-form",children:[(0,b.jsx)("input",{ref:t,id:"auth-dialog-email",name:"email",type:"email",autoComplete:"email",inputMode:"email",spellCheck:!1,placeholder:"you@yourdomain.com",disabled:q,className:"auth-input",required:!0}),o.error&&(0,b.jsx)("div",{className:"auth-error",children:o.error}),(0,b.jsxs)("div",{className:"auth-actions",children:[(0,b.jsx)("button",{type:"submit",className:"auth-btn primary",disabled:q,children:q?"sending…":"send code"}),(0,b.jsx)("button",{type:"button",className:"auth-btn",onClick:f,disabled:q,children:"cancel"})]})]})]}),"code"===o.kind&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("p",{className:"auth-sub",children:["code sent to ",(0,b.jsx)("span",{className:"auth-email",children:o.email}),". expires in ",Math.ceil(o.expiresIn/60)," min."]}),(0,b.jsxs)("form",{onSubmit:A,className:"auth-form",children:[(0,b.jsx)("input",{ref:u,id:"auth-dialog-code",name:"code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",spellCheck:!1,placeholder:"123456",disabled:q,className:"auth-input auth-input-code",maxLength:12,required:!0}),o.error&&(0,b.jsx)("div",{className:"auth-error",children:o.error}),(0,b.jsxs)("div",{className:"auth-actions",children:[(0,b.jsx)("button",{type:"submit",className:"auth-btn primary",disabled:q,children:q?"verifying…":"verify"}),(0,b.jsx)("button",{type:"button",className:"auth-btn",onClick:B,disabled:q||o.resendIn>0,children:o.resendIn>0?`resend in ${o.resendIn}s`:"resend code"})]}),(0,b.jsx)("button",{type:"button",className:"auth-back",onClick:()=>p({kind:"email",error:null}),disabled:q,children:"← use a different email"})]})]}),"done"===o.kind&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("p",{className:"auth-sub",children:[(0,b.jsx)("span",{className:"auth-ok",children:"✓"})," signed in as"," ",(0,b.jsx)("span",{className:"auth-email",children:o.user.email}),"."]}),(0,b.jsx)("div",{className:"auth-actions",children:(0,b.jsx)("button",{type:"button",className:"auth-btn primary",onClick:f,children:"continue"})})]})]})}):null}var n=a.i(18952),o=a.i(80977);function p(a){return new Date(a).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function q(a,b){let c=a-b;if(c<=0)return"now";let d=Math.floor(c/864e5),e=Math.floor(c%864e5/36e5);return d>0?e>0?`${d}d ${e}h`:`${d}d`:e>0?`${e}h`:`${Math.max(1,Math.floor(c/6e4))}m`}function r(a){return a.toLocaleString("en-US")}function s({label:a,value:c,sub:d,tone:e}){return(0,b.jsxs)("div",{className:"set-stat",children:[(0,b.jsx)("div",{className:"set-stat-label",children:a}),(0,b.jsx)("div",{className:`set-stat-value${e?` ${e}`:""}`,children:c}),(0,b.jsx)("div",{className:"set-stat-sub",children:d??" "})]})}function t({lastRunAtMs:a,nextDueAtMs:c,now:d}){if(null==a||null==c||c<=a)return null;let e=Math.min(100,Math.max(0,(d-a)/(c-a)*100));return(0,b.jsxs)("div",{className:"tape","aria-hidden":"true",children:[(0,b.jsxs)("div",{className:"tape-rail",children:[(0,b.jsx)("div",{className:"tape-fill",style:{width:`${e}%`}}),(0,b.jsx)("div",{className:"tape-now",style:{left:`${e}%`}})]}),(0,b.jsxs)("div",{className:"tape-ends",children:[(0,b.jsxs)("span",{children:["last scan · ",p(a)]}),(0,b.jsxs)("span",{className:"tape-next",children:["next · ",q(c,d)]})]})]})}function u({enabled:a,onChange:c,disabled:d,label:e}){return(0,b.jsx)("button",{type:"button",role:"switch","aria-checked":a,"aria-label":e,disabled:d,onClick:c,className:"sw","data-on":a?"true":"false",children:(0,b.jsx)("span",{className:"sw-knob"})})}let v=[{label:"reads",body:"every session transcript on disk — your prompts, the files your agents read and wrote, and command output."},{label:"runs",body:"entirely on this machine. the transcripts never leave it."},{label:"sends",body:"counts, redacted examples, and this machine's name — and only when a scan finds something harmful."}];a.s(["default",0,function({initial:a}){let[d,i]=(0,c.useState)(a),[j,k]=(0,c.useState)(a?.auto??!1),[l,w]=(0,c.useState)(a?.intervalDays??7),[x,y]=(0,c.useState)(!1),[z,A]=(0,c.useState)(!1),[B,C]=(0,c.useState)(!1),[D,E]=(0,c.useState)(null===a),[F,G]=(0,c.useState)(0),H=(0,c.useRef)(!0),I=(0,c.useRef)(null!==a),J=(0,c.useCallback)(async()=>{try{let a=await e();if(!H.current)return;i(a),I.current=!0,k(a.auto),w(a.intervalDays),G(Date.now()),E(!1)}catch{H.current&&!I.current&&E(!0)}},[]);(0,c.useEffect)(()=>(H.current=!0,J(),()=>{H.current=!1}),[J]),(0,c.useEffect)(()=>{let a=()=>void J();return window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),()=>{window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a)}},[J]);let K=d?.signedInAs??null,L=d?.daemon==="running",M=d?.daemon==="unsupported-platform",N=d?.schedule??null,O=d?.lastScan??null,P=N?.lastExitCode!=null&&0!==N.lastExitCode&&75!==N.lastExitCode,Q=(0,c.useCallback)(async()=>{y(!0);try{let a=await f(!0);if(!a.ok){if(k(!1),"unreachable"===a.reason)return void(0,n.toast)("could not reach the server. check your connection and try again.");await J(),C(!0),(0,n.toast)("that sign-in expired. one more code and it's on.");return}k(a.auto),(0,n.toast)("scheduled audits on."),await J()}catch{k(!1),(0,n.toast)("could not turn that on.")}finally{y(!1)}},[J]),R=(0,c.useCallback)(async()=>{if(j){y(!0);try{let a=await f(!1);a.ok&&k(a.auto),(0,n.toast)("scheduled audits off."),await J()}catch{(0,n.toast)("could not turn that off.")}finally{y(!1)}return}K?await Q():C(!0)},[j,Q,J,K]),S=(0,c.useCallback)(async a=>{y(!0);try{let b=await g(a);w(b.intervalDays),i(a=>a?{...a,intervalDays:b.intervalDays}:a),(0,n.toast)(`scanning every ${b.intervalDays} day${1===b.intervalDays?"":"s"}.`)}catch{w(d?.intervalDays??7),(0,n.toast)("could not save that.")}finally{y(!1)}},[d?.intervalDays]),T=(0,c.useCallback)(async()=>{y(!0);try{await fetch("/api/auth/logout",{method:"POST"}),(0,n.toast)("signed out. scans continue; digests pause."),await J()}catch{(0,n.toast)("could not sign out.")}finally{y(!1)}},[J]),U=(0,c.useCallback)(async()=>{if(!z){A(!0);try{await (0,h.triggerRun)({cli:[],since:"all",noCache:!1}),(0,n.toast)("scan complete."),await J()}catch(a){(0,n.toast)(a instanceof h.RerunError&&"timeout"===a.kind?"the scan is taking a while — it will finish in the background.":"the scan could not be completed.")}finally{A(!1)}}},[J,z]),V=(0,c.useCallback)(async a=>{C(!1),await J(),await Q()},[Q,J]),W=d?L?{value:"running",sub:null!=d.daemonStartedAtMs&&F>0?`up ${function(a){let b=Math.floor(a/864e5);if(b>0)return`${b}d`;let c=Math.floor(a/36e5);return c>0?`${c}h`:`${Math.max(1,Math.floor(a/6e4))}m`}(Math.max(0,F-d.daemonStartedAtMs))}`:"",tone:"ok"}:M?{value:"unavailable",sub:"not on this platform"}:"not-installed"===d.daemon?{value:"not installed",sub:"run failproofai config",tone:"warn"}:"unknown"===d.daemon?{value:"unknown",sub:"could not read it"}:{value:"stopped",sub:"run failproofai config",tone:"warn"}:{value:"…",sub:"reading"},X=j?N?.nextDueAtMs==null?{value:"pending",sub:"after the next scan"}:{value:F>0?q(N.nextDueAtMs,F):"—",sub:p(N.nextDueAtMs)}:{value:"off",sub:"nothing scheduled"},Y=O?{value:(0,o.formatRelativeTime)(Date.parse(O.finishedAt)),sub:null!=O.sessionsScanned?`${r(O.sessionsScanned)} sessions`:"scanned"}:{value:"none yet",sub:"run one below"},Z=O?null==O.findings?{value:"—",sub:"unreadable"}:{value:r(O.findings),sub:"this scan",...O.findings>0?{tone:"warn"}:{}}:{value:"—",sub:"no scan yet"};return(0,b.jsxs)("main",{className:"report",children:[(0,b.jsxs)("section",{className:"section set-sec",children:[(0,b.jsxs)("div",{className:"set-mast",children:[(0,b.jsx)("h1",{className:"set-title",children:"settings"}),(0,b.jsx)("p",{className:"set-lede",children:"keeping watch, so you don't have to."})]}),D?(0,b.jsx)("div",{className:"set-console",children:(0,b.jsx)("div",{className:"set-cell",children:(0,b.jsxs)("p",{className:"set-warn",children:["could not read this machine's settings. check that the dashboard can reach ",(0,b.jsx)("code",{children:"~/.failproofai/config.json"}),"."]})})}):(0,b.jsxs)("div",{className:"set-console",children:[(0,b.jsxs)("div",{className:"set-stats",children:[(0,b.jsx)(s,{label:"daemon",...W}),(0,b.jsx)(s,{label:"next scan",...X}),(0,b.jsx)(s,{label:"last scan",...Y}),(0,b.jsx)(s,{label:"findings",...Z})]}),(0,b.jsxs)("div",{className:"set-cols",children:[(0,b.jsxs)("div",{className:"set-cell set-config",children:[(0,b.jsx)("h2",{className:"set-cell-title",children:"scheduled audit"}),(0,b.jsxs)("div",{className:"set-row set-row-main",children:[(0,b.jsx)(u,{enabled:j,disabled:x||null===d,onChange:()=>void R(),label:j?"turn off scheduled audits":"turn on scheduled audits"}),(0,b.jsxs)("div",{className:"set-row-copy",children:[(0,b.jsx)("span",{className:"set-strong",children:j?"scanning on a schedule.":"scan on a schedule."}),(0,b.jsx)("span",{className:"set-dim",children:j?"you'll get an email only when a scan finds something.":"off. nothing runs and nothing is sent."})]})]}),(0,b.jsxs)("div",{className:"set-row set-row-interval",children:[(0,b.jsx)("span",{className:"set-dim",children:"scan every"}),(0,b.jsx)("input",{type:"number",className:"set-num",min:1,max:90,value:l,disabled:x||null===d,"aria-label":"days between scheduled scans",onChange:a=>w(Number(a.target.value)),onBlur:a=>{let b=Number(a.target.value);Number.isFinite(b)?b!==d?.intervalDays&&S(b):w(d?.intervalDays??7)}}),(0,b.jsx)("span",{className:"set-dim",children:"days"}),(0,b.jsxs)("span",{className:"set-hint",children:[1,"–",90]})]}),(0,b.jsx)("div",{className:"set-rule"}),(0,b.jsx)("div",{className:"set-row set-row-identity",children:K?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"set-dim",children:"reports go to"}),(0,b.jsx)("span",{className:"set-email",children:K.email}),(0,b.jsx)("button",{type:"button",className:"set-link",disabled:x,onClick:()=>void T(),children:"sign out"})]}):j?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"set-warn",children:"signed out — scans continue, digests are paused."}),(0,b.jsx)("button",{type:"button",className:"set-link",disabled:x,onClick:()=>C(!0),children:"sign in to resume"})]}):(0,b.jsx)("span",{className:"set-dim",children:"turning this on asks for an email, so there is somewhere to send the report."})}),j&&d&&!L&&(0,b.jsx)("p",{className:"set-warn",children:M?"the background service isn't available on this platform, so scheduled scans can't run here. you can still run one now.":"not-installed"===d.daemon?"the background service isn't installed, so nothing will run on the timer. install it with `failproofai config`.":"the background service is stopped, so nothing will run until it starts. repair it with `failproofai config`."}),P&&(0,b.jsxs)("p",{className:"set-warn",children:["the last scheduled scan exited ",N?.lastExitCode,". the next one will still run."]}),(0,b.jsx)("div",{className:"set-actions",children:(0,b.jsx)("button",{type:"button",className:"btn btn-press",disabled:z,onClick:()=>void U(),children:z?"[ scanning… ]":"[ run a scan now ]"})})]}),(0,b.jsxs)("div",{className:"set-cell set-how",children:[(0,b.jsx)("h2",{className:"set-cell-title",children:"how it works"}),(0,b.jsx)("dl",{className:"set-how-list",children:v.map(a=>(0,b.jsxs)("div",{className:"set-how-row",children:[(0,b.jsx)("dt",{className:"set-how-label",children:a.label}),(0,b.jsx)("dd",{className:"set-how-body",children:a.body})]},a.label))})]})]})]}),j&&F>0&&(0,b.jsx)(t,{lastRunAtMs:N?.lastRunAtMs??null,nextDueAtMs:N?.nextDueAtMs??null,now:F})]}),(0,b.jsx)(m,{open:B,source:"settings_scheduled_audit",headline:"where should the report go?",subhead:"we'll send a one-time code to confirm.",onClose:()=>C(!1),onAuthed:a=>void V(a)})]})}],41857)}];
1
+ module.exports=[41857,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(5050);let e=(0,d.createServerReference)("00d97410f220c9506cdadd420812b2c7ab41b6dee8",d.callServer,void 0,d.findSourceMapURL,"getScheduledAuditAction"),f=(0,d.createServerReference)("4070638273d8ce919cc1cb3a9c56f9581269fad56d",d.callServer,void 0,d.findSourceMapURL,"setAutoAuditAction"),g=(0,d.createServerReference)("40b2805baae56152c00aa41d8f14da989078e7227d",d.callServer,void 0,d.findSourceMapURL,"setAuditIntervalAction");var h=a.i(89564),i=a.i(10765),j=a.i(17094);let k=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function l(a){if((0,j.isAbortError)(a))return"request timed out. check your network and try again.";let b=a instanceof Error?a.message:String(a);return`network error: ${b}`}function m({open:a,headline:d="where to route the reminder?",subhead:e="we'll send a one-time code to confirm.",onClose:f,onAuthed:g,source:h="unknown"}){let{capture:n}=(0,i.usePostHog)(),[o,p]=(0,c.useState)({kind:"email",error:null}),[q,r]=(0,c.useState)(!1),s=(0,c.useRef)(!1),t=(0,c.useRef)(null),u=(0,c.useRef)(null);(0,c.useEffect)(()=>{a&&(p({kind:"email",error:null}),r(!1),s.current=!1,n("audit_auth_dialog_opened",{source:h}))},[n,a,h]);let v=(0,c.useRef)(!1);(0,c.useEffect)(()=>{if(a){v.current=!0;return}v.current&&!s.current&&n("audit_auth_dialog_dismissed",{source:h,step:o.kind}),v.current=!1},[n,a,h,o.kind]),(0,c.useEffect)(()=>{if(!a)return;let b=setTimeout(()=>{"email"===o.kind?t.current?.focus():"code"===o.kind&&u.current?.focus()},50);return()=>clearTimeout(b)},[a,o.kind]),(0,c.useEffect)(()=>{if(!a)return;let b=a=>{"Escape"!==a.key||q||f()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[a,q,f]);let w="code"===o.kind&&o.resendIn>0;(0,c.useEffect)(()=>{if(!w)return;let a=setInterval(()=>{p(a=>"code"===a.kind?{...a,resendIn:Math.max(0,a.resendIn-1)}:a)},1e3);return()=>clearInterval(a)},[w]);let x=(0,c.useCallback)(async(a,b={})=>{let{isResend:c=!1}=b,d=a=>{c?p(b=>"code"===b.kind?{...b,error:a}:b):p({kind:"email",error:a})};r(!0);try{let b=await (0,j.fetchWithTimeout)("/api/auth/login-request",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({email:a})}),c=await b.json().catch(()=>({}));if(!b.ok){let a=c.message??"could not send code.";"rate_limited"===c.code&&void 0!==c.retry_after_secs?a=`too many tries. wait ${c.retry_after_secs}s and try again.`:"upstream_unreachable"===c.code&&(a="api-server unreachable. check your network."),d(a);return}p({kind:"code",email:a,error:null,expiresIn:c.expires_in??600,resendIn:c.resend_available_in??30})}catch(a){d(l(a))}finally{r(!1)}},[]),y=(0,c.useCallback)(async(a,b)=>{r(!0);try{let c=await (0,j.fetchWithTimeout)("/api/auth/login-verify",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({email:a,code:b})}),d=await c.json().catch(()=>({}));if(!c.ok||!d.authenticated||!d.user){let a=d.message??"invalid code.";"invalid_code"===d.code&&(a="wrong code, or it expired. try again."),p(b=>"code"===b.kind?{...b,error:a}:b);return}s.current=!0,n("audit_auth_dialog_succeeded",{source:h}),p({kind:"done",user:d.user}),g(d.user)}catch(b){let a=l(b);p(b=>"code"===b.kind?{...b,error:a}:b)}finally{r(!1)}},[n,g,h]),z=(0,c.useCallback)(async a=>{if(a.preventDefault(),q||"email"!==o.kind)return;let b=String(new FormData(a.currentTarget).get("email")??"").trim().toLowerCase();k.test(b)?await x(b):p({kind:"email",error:"that doesn't look like an email."})},[q,o,x]),A=(0,c.useCallback)(async a=>{if(a.preventDefault(),q||"code"!==o.kind)return;let b=String(new FormData(a.currentTarget).get("code")??"").trim();b.length<4||b.length>12?p(a=>"code"===a.kind?{...a,error:"code is 4–12 characters."}:a):await y(o.email,b)},[q,o,y]),B=(0,c.useCallback)(async()=>{"code"!==o.kind||o.resendIn>0||q||await x(o.email,{isResend:!0})},[o,q,x]);return a?(0,b.jsx)("div",{className:"auth-dialog-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"auth-dialog-title",onClick:a=>{q||a.target!==a.currentTarget||f()},children:(0,b.jsxs)("div",{className:"auth-dialog",children:[(0,b.jsx)("button",{type:"button",className:"auth-close",onClick:f,disabled:q,"aria-label":"close",children:"×"}),(0,b.jsx)("h2",{id:"auth-dialog-title",className:"auth-headline",children:d}),"email"===o.kind&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("p",{className:"auth-sub",children:e}),(0,b.jsxs)("form",{onSubmit:z,className:"auth-form",children:[(0,b.jsx)("input",{ref:t,id:"auth-dialog-email",name:"email",type:"email",autoComplete:"email",inputMode:"email",spellCheck:!1,placeholder:"you@yourdomain.com",disabled:q,className:"auth-input",required:!0}),o.error&&(0,b.jsx)("div",{className:"auth-error",children:o.error}),(0,b.jsxs)("div",{className:"auth-actions",children:[(0,b.jsx)("button",{type:"submit",className:"auth-btn primary",disabled:q,children:q?"sending…":"send code"}),(0,b.jsx)("button",{type:"button",className:"auth-btn",onClick:f,disabled:q,children:"cancel"})]})]})]}),"code"===o.kind&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("p",{className:"auth-sub",children:["code sent to ",(0,b.jsx)("span",{className:"auth-email",children:o.email}),". expires in ",Math.ceil(o.expiresIn/60)," min."]}),(0,b.jsxs)("form",{onSubmit:A,className:"auth-form",children:[(0,b.jsx)("input",{ref:u,id:"auth-dialog-code",name:"code",type:"text",inputMode:"numeric",autoComplete:"one-time-code",spellCheck:!1,placeholder:"123456",disabled:q,className:"auth-input auth-input-code",maxLength:12,required:!0}),o.error&&(0,b.jsx)("div",{className:"auth-error",children:o.error}),(0,b.jsxs)("div",{className:"auth-actions",children:[(0,b.jsx)("button",{type:"submit",className:"auth-btn primary",disabled:q,children:q?"verifying…":"verify"}),(0,b.jsx)("button",{type:"button",className:"auth-btn",onClick:B,disabled:q||o.resendIn>0,children:o.resendIn>0?`resend in ${o.resendIn}s`:"resend code"})]}),(0,b.jsx)("button",{type:"button",className:"auth-back",onClick:()=>p({kind:"email",error:null}),disabled:q,children:"← use a different email"})]})]}),"done"===o.kind&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("p",{className:"auth-sub",children:[(0,b.jsx)("span",{className:"auth-ok",children:"✓"})," signed in as"," ",(0,b.jsx)("span",{className:"auth-email",children:o.user.email}),"."]}),(0,b.jsx)("div",{className:"auth-actions",children:(0,b.jsx)("button",{type:"button",className:"auth-btn primary",onClick:f,children:"continue"})})]})]})}):null}var n=a.i(18952),o=a.i(80977);function p(a){return new Date(a).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function q(a,b){let c=a-b;if(c<=0)return"now";let d=Math.floor(c/864e5),e=Math.floor(c%864e5/36e5);return d>0?e>0?`${d}d ${e}h`:`${d}d`:e>0?`${e}h`:`${Math.max(1,Math.floor(c/6e4))}m`}function r(a){return a.toLocaleString("en-US")}function s({label:a,value:c,sub:d,tone:e}){return(0,b.jsxs)("div",{className:"set-stat",children:[(0,b.jsx)("div",{className:"set-stat-label",children:a}),(0,b.jsx)("div",{className:`set-stat-value${e?` ${e}`:""}`,children:c}),(0,b.jsx)("div",{className:"set-stat-sub",children:d??" "})]})}function t({lastRunAtMs:a,nextDueAtMs:c,now:d}){if(null==a||null==c||c<=a)return null;let e=Math.min(100,Math.max(0,(d-a)/(c-a)*100));return(0,b.jsxs)("div",{className:"tape","aria-hidden":"true",children:[(0,b.jsxs)("div",{className:"tape-rail",children:[(0,b.jsx)("div",{className:"tape-fill",style:{width:`${e}%`}}),(0,b.jsx)("div",{className:"tape-now",style:{left:`${e}%`}})]}),(0,b.jsxs)("div",{className:"tape-ends",children:[(0,b.jsxs)("span",{children:["last scan · ",p(a)]}),(0,b.jsxs)("span",{className:"tape-next",children:["next · ",q(c,d)]})]})]})}function u({enabled:a,onChange:c,disabled:d,label:e}){return(0,b.jsx)("button",{type:"button",role:"switch","aria-checked":a,"aria-label":e,disabled:d,onClick:c,className:"sw","data-on":a?"true":"false",children:(0,b.jsx)("span",{className:"sw-knob"})})}let v=[{label:"reads",body:"every session transcript on disk — your prompts, the files your agents read and wrote, and command output."},{label:"runs",body:"entirely on this machine. the transcripts never leave it."},{label:"sends",body:"counts, redacted examples, and this machine's name — and only when a scan finds something harmful."}];a.s(["default",0,function({initial:a}){let[d,i]=(0,c.useState)(a),[j,k]=(0,c.useState)(a?.auto??!1),[l,w]=(0,c.useState)(a?.intervalDays??7),[x,y]=(0,c.useState)(!1),[z,A]=(0,c.useState)(!1),[B,C]=(0,c.useState)(!1),[D,E]=(0,c.useState)(null===a),[F,G]=(0,c.useState)(0),H=(0,c.useRef)(!0),I=(0,c.useRef)(null!==a),J=(0,c.useCallback)(async()=>{try{let a=await e();if(!H.current)return;i(a),I.current=!0,k(a.auto),w(a.intervalDays),G(Date.now()),E(!1)}catch{H.current&&!I.current&&E(!0)}},[]);(0,c.useEffect)(()=>(H.current=!0,J(),()=>{H.current=!1}),[J]),(0,c.useEffect)(()=>{let a=()=>void J();return window.addEventListener("focus",a),document.addEventListener("visibilitychange",a),()=>{window.removeEventListener("focus",a),document.removeEventListener("visibilitychange",a)}},[J]);let K=d?.signedInAs??null,L=d?.daemon==="running",M=d?.daemon==="unsupported-platform",N=d?.schedule??null,O=d?.lastScan??null,P=N?.lastExitCode!=null&&0!==N.lastExitCode&&75!==N.lastExitCode,Q=(0,c.useCallback)(async()=>{y(!0);try{let a=await f(!0);if(!a.ok){if(k(!1),"unreachable"===a.reason)return void(0,n.toast)("could not reach the server. check your connection and try again.");await J(),C(!0),(0,n.toast)("that sign-in expired. one more code and it's on.");return}k(a.auto),(0,n.toast)("scheduled audits on."),await J()}catch{k(!1),(0,n.toast)("could not turn that on.")}finally{y(!1)}},[J]),R=(0,c.useCallback)(async()=>{if(j){y(!0);try{let a=await f(!1);a.ok&&k(a.auto),(0,n.toast)("scheduled audits off."),await J()}catch{(0,n.toast)("could not turn that off.")}finally{y(!1)}return}K?await Q():C(!0)},[j,Q,J,K]),S=(0,c.useCallback)(async a=>{y(!0);try{let b=await g(a);w(b.intervalDays),i(a=>a?{...a,intervalDays:b.intervalDays}:a),(0,n.toast)(`scanning every ${b.intervalDays} day${1===b.intervalDays?"":"s"}.`)}catch{w(d?.intervalDays??7),(0,n.toast)("could not save that.")}finally{y(!1)}},[d?.intervalDays]),T=(0,c.useCallback)(async()=>{y(!0);try{await fetch("/api/auth/logout",{method:"POST"}),(0,n.toast)("signed out. scans continue; digests pause."),await J()}catch{(0,n.toast)("could not sign out.")}finally{y(!1)}},[J]),U=(0,c.useCallback)(async()=>{if(!z){A(!0);try{await (0,h.triggerRun)({cli:[],since:"all",noCache:!1}),(0,n.toast)("scan complete."),await J()}catch(a){(0,n.toast)(a instanceof h.RerunError&&"timeout"===a.kind?"the scan is taking a while — it will finish in the background.":"the scan could not be completed.")}finally{A(!1)}}},[J,z]),V=(0,c.useCallback)(async a=>{C(!1),await J(),await Q()},[Q,J]),W=d?L?{value:"running",sub:null!=d.daemonStartedAtMs&&F>0?`up ${function(a){let b=Math.floor(a/864e5);if(b>0)return`${b}d`;let c=Math.floor(a/36e5);return c>0?`${c}h`:`${Math.max(1,Math.floor(a/6e4))}m`}(Math.max(0,F-d.daemonStartedAtMs))}`:"",tone:"ok"}:M?{value:"unavailable",sub:"not on this platform"}:"not-installed"===d.daemon?{value:"not installed",sub:"run failproofai config",tone:"warn"}:"unknown"===d.daemon?{value:"unknown",sub:"could not read it"}:{value:"stopped",sub:"run failproofai config",tone:"warn"}:{value:"…",sub:"reading"},X=j?N?.nextDueAtMs==null?{value:"pending",sub:"after the next scan"}:{value:F>0?q(N.nextDueAtMs,F):"—",sub:p(N.nextDueAtMs)}:{value:"off",sub:"nothing scheduled"},Y=O?{value:(0,o.formatRelativeTime)(Date.parse(O.finishedAt)),sub:null!=O.sessionsScanned?`${r(O.sessionsScanned)} sessions`:"scanned"}:{value:"none yet",sub:"run one below"},Z=O?null==O.findings?{value:"—",sub:"unreadable"}:{value:r(O.findings),sub:"this scan",...O.findings>0?{tone:"warn"}:{}}:{value:"—",sub:"no scan yet"};return(0,b.jsxs)("main",{className:"report",children:[(0,b.jsxs)("section",{className:"section set-sec",children:[(0,b.jsxs)("div",{className:"set-mast",children:[(0,b.jsx)("h1",{className:"set-title",children:"settings"}),(0,b.jsx)("p",{className:"set-lede",children:"keeping watch, so you don't have to."})]}),D?(0,b.jsx)("div",{className:"set-console",children:(0,b.jsx)("div",{className:"set-cell",children:(0,b.jsxs)("p",{className:"set-warn",children:["could not read this machine's settings. check that the dashboard can reach ",(0,b.jsx)("code",{children:"~/.failproofai/config.json"}),"."]})})}):(0,b.jsxs)("div",{className:"set-console",children:[(0,b.jsxs)("div",{className:"set-stats",children:[(0,b.jsx)(s,{label:"daemon",...W}),(0,b.jsx)(s,{label:"next scan",...X}),(0,b.jsx)(s,{label:"last scan",...Y}),(0,b.jsx)(s,{label:"findings",...Z})]}),(0,b.jsxs)("div",{className:"set-cols",children:[(0,b.jsxs)("div",{className:"set-cell set-config",children:[(0,b.jsx)("h2",{className:"set-cell-title",children:"scheduled audit"}),(0,b.jsxs)("div",{className:"set-row set-row-main",children:[(0,b.jsx)(u,{enabled:j,disabled:x||null===d,onChange:()=>void R(),label:j?"turn off scheduled audits":"turn on scheduled audits"}),(0,b.jsxs)("div",{className:"set-row-copy",children:[(0,b.jsx)("span",{className:"set-strong",children:j?"scanning on a schedule.":"scan on a schedule."}),(0,b.jsx)("span",{className:"set-dim",children:j?"you'll get an email only when a scan finds something.":"off. nothing runs and nothing is sent."})]})]}),(0,b.jsxs)("div",{className:"set-row set-row-interval",children:[(0,b.jsx)("span",{className:"set-dim",children:"scan every"}),(0,b.jsx)("input",{type:"number",className:"set-num",min:1,max:90,value:l,disabled:x||null===d,"aria-label":"days between scheduled scans",onChange:a=>w(Number(a.target.value)),onBlur:a=>{let b=Number(a.target.value);Number.isFinite(b)?b!==d?.intervalDays&&S(b):w(d?.intervalDays??7)}}),(0,b.jsx)("span",{className:"set-dim",children:"days"}),(0,b.jsxs)("span",{className:"set-hint",children:[1,"–",90]})]}),(0,b.jsx)("div",{className:"set-rule"}),(0,b.jsx)("div",{className:"set-row set-row-identity",children:K?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"set-dim",children:"reports go to"}),(0,b.jsx)("span",{className:"set-email",children:K.email}),(0,b.jsx)("button",{type:"button",className:"set-link",disabled:x,onClick:()=>void T(),children:"sign out"})]}):j?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"set-warn",children:"signed out — scans continue, digests are paused."}),(0,b.jsx)("button",{type:"button",className:"set-link",disabled:x,onClick:()=>C(!0),children:"sign in to resume"})]}):(0,b.jsx)("span",{className:"set-dim",children:"turning this on asks for an email, so there is somewhere to send the report."})}),j&&d&&!L&&(0,b.jsx)("p",{className:"set-warn",children:M?"the background service isn't available on this platform, so scheduled scans can't run here. you can still run one now.":"not-installed"===d.daemon?"the background service isn't installed, so nothing will run on the timer. install it with `failproofai config`.":"the background service is stopped, so nothing will run until it starts. repair it with `failproofai config`."}),P&&(0,b.jsxs)("p",{className:"set-warn",children:["the last scheduled scan exited ",N?.lastExitCode,". the next one will still run."]}),(0,b.jsx)("div",{className:"set-actions",children:(0,b.jsx)("button",{type:"button",className:"btn btn-press",disabled:z,onClick:()=>void U(),children:z?"[ scanning… ]":"[ run a scan now ]"})})]}),(0,b.jsxs)("div",{className:"set-cell set-how",children:[(0,b.jsx)("h2",{className:"set-cell-title",children:"how it works"}),(0,b.jsx)("dl",{className:"set-how-list",children:v.map(a=>(0,b.jsxs)("div",{className:"set-how-row",children:[(0,b.jsx)("dt",{className:"set-how-label",children:a.label}),(0,b.jsx)("dd",{className:"set-how-body",children:a.body})]},a.label))})]})]})]}),j&&F>0&&(0,b.jsx)(t,{lastRunAtMs:N?.lastRunAtMs??null,nextDueAtMs:N?.nextDueAtMs??null,now:F})]}),(0,b.jsx)(m,{open:B,source:"settings_scheduled_audit",headline:"where should the report go?",subhead:"we'll send a one-time code to confirm.",onClose:()=>C(!1),onAuthed:a=>void V(a)})]})}],41857)}];
2
2
 
3
3
  //# sourceMappingURL=app_settings_settings-client_tsx_20lq-mq._.js.map
@@ -7,9 +7,9 @@ globalThis.__BUILD_MANIFEST = {
7
7
  "static/chunks/0cz1d0mv5g_q7.js"
8
8
  ],
9
9
  "lowPriorityFiles": [
10
- "static/aKNv4Kmv98Xpwns0Xa-C-/_buildManifest.js",
11
- "static/aKNv4Kmv98Xpwns0Xa-C-/_ssgManifest.js",
12
- "static/aKNv4Kmv98Xpwns0Xa-C-/_clientMiddlewareManifest.js"
10
+ "static/P6icI2V2PvVuePJrqjHCr/_buildManifest.js",
11
+ "static/P6icI2V2PvVuePJrqjHCr/_ssgManifest.js",
12
+ "static/P6icI2V2PvVuePJrqjHCr/_clientMiddlewareManifest.js"
13
13
  ],
14
14
  "rootMainFiles": [
15
15
  "static/chunks/1c6aptmytnu6q.js",