failproofai 0.0.10 → 0.0.11-beta.10

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 (565) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/app-path-routes-manifest.json +9 -1
  3. package/.next/standalone/.next/build-manifest.json +10 -10
  4. package/.next/standalone/.next/prerender-manifest.json +3 -32
  5. package/.next/standalone/.next/required-server-files.json +2 -1
  6. package/.next/standalone/.next/routes-manifest.json +51 -3
  7. package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +7 -7
  8. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  9. package/.next/standalone/.next/server/app/_global-error/page.js +6 -6
  10. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  11. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  12. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  13. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  14. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
  15. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  16. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
  17. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
  18. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  19. package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +7 -7
  20. package/.next/standalone/.next/server/app/_not-found/page/next-font-manifest.json +2 -6
  21. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  22. package/.next/standalone/.next/server/app/_not-found/page.js +12 -13
  23. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  25. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  26. package/.next/standalone/.next/server/app/_not-found.rsc +16 -16
  27. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +16 -16
  28. package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  29. package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +10 -10
  30. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  31. package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  32. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  33. package/.next/standalone/.next/server/app/api/audit/invite/route/app-paths-manifest.json +3 -0
  34. package/.next/standalone/.next/server/app/api/audit/invite/route/server-reference-manifest.json +4 -0
  35. package/.next/standalone/.next/server/app/api/audit/invite/route.js +7 -0
  36. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -0
  37. package/.next/standalone/.next/server/app/api/audit/invite/route_client-reference-manifest.js +3 -0
  38. package/.next/standalone/.next/server/app/api/audit/run/route/app-paths-manifest.json +3 -0
  39. package/.next/standalone/.next/server/app/api/audit/run/route/build-manifest.json +9 -0
  40. package/.next/standalone/.next/server/app/api/audit/run/route/server-reference-manifest.json +4 -0
  41. package/.next/standalone/.next/server/app/api/audit/run/route.js +8 -0
  42. package/.next/standalone/.next/server/app/api/audit/run/route.js.map +5 -0
  43. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -0
  44. package/.next/standalone/.next/server/app/api/audit/run/route_client-reference-manifest.js +3 -0
  45. package/.next/standalone/.next/server/app/api/audit/status/route/app-paths-manifest.json +3 -0
  46. package/.next/standalone/.next/server/app/api/audit/status/route/build-manifest.json +9 -0
  47. package/.next/standalone/.next/server/app/api/audit/status/route/server-reference-manifest.json +4 -0
  48. package/.next/standalone/.next/server/app/api/audit/status/route.js +6 -0
  49. package/.next/standalone/.next/server/app/api/audit/status/route.js.map +5 -0
  50. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -0
  51. package/.next/standalone/.next/server/app/api/audit/status/route_client-reference-manifest.js +3 -0
  52. package/.next/standalone/.next/server/app/api/auth/login-request/route/app-paths-manifest.json +3 -0
  53. package/.next/standalone/.next/server/app/api/auth/login-request/route/build-manifest.json +9 -0
  54. package/.next/standalone/.next/server/app/api/auth/login-request/route/server-reference-manifest.json +4 -0
  55. package/.next/standalone/.next/server/app/api/auth/login-request/route.js +6 -0
  56. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.map +5 -0
  57. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -0
  58. package/.next/standalone/.next/server/app/api/auth/login-request/route_client-reference-manifest.js +3 -0
  59. package/.next/standalone/.next/server/app/api/auth/login-verify/route/app-paths-manifest.json +3 -0
  60. package/.next/standalone/.next/server/app/api/auth/login-verify/route/build-manifest.json +9 -0
  61. package/.next/standalone/.next/server/app/api/auth/login-verify/route/server-reference-manifest.json +4 -0
  62. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js +7 -0
  63. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.map +5 -0
  64. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -0
  65. package/.next/standalone/.next/server/app/api/auth/login-verify/route_client-reference-manifest.js +3 -0
  66. package/.next/standalone/.next/server/app/api/auth/logout/route/app-paths-manifest.json +3 -0
  67. package/.next/standalone/.next/server/app/api/auth/logout/route/build-manifest.json +9 -0
  68. package/.next/standalone/.next/server/app/api/auth/logout/route/server-reference-manifest.json +4 -0
  69. package/.next/standalone/.next/server/app/api/auth/logout/route.js +7 -0
  70. package/.next/standalone/.next/server/app/api/auth/logout/route.js.map +5 -0
  71. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -0
  72. package/.next/standalone/.next/server/app/api/auth/logout/route_client-reference-manifest.js +3 -0
  73. package/.next/standalone/.next/server/app/api/auth/reminder/route/app-paths-manifest.json +3 -0
  74. package/.next/standalone/.next/server/app/api/auth/reminder/route/build-manifest.json +9 -0
  75. package/.next/standalone/.next/server/app/api/auth/reminder/route/server-reference-manifest.json +4 -0
  76. package/.next/standalone/.next/server/app/api/auth/reminder/route.js +7 -0
  77. package/.next/standalone/.next/server/app/api/auth/reminder/route.js.map +5 -0
  78. package/.next/standalone/.next/server/app/api/auth/reminder/route.js.nft.json +1 -0
  79. package/.next/standalone/.next/server/app/api/auth/reminder/route_client-reference-manifest.js +3 -0
  80. package/.next/standalone/.next/server/app/api/auth/status/route/app-paths-manifest.json +3 -0
  81. package/.next/standalone/.next/server/app/api/auth/status/route/build-manifest.json +9 -0
  82. package/.next/standalone/.next/server/app/api/auth/status/route/server-reference-manifest.json +4 -0
  83. package/.next/standalone/.next/server/app/api/auth/status/route.js +7 -0
  84. package/.next/standalone/.next/server/app/api/auth/status/route.js.map +5 -0
  85. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -0
  86. package/.next/standalone/.next/server/app/api/auth/status/route_client-reference-manifest.js +3 -0
  87. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js +3 -3
  88. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  89. package/.next/standalone/.next/server/app/audit/page/app-paths-manifest.json +3 -0
  90. package/.next/standalone/.next/server/app/audit/page/build-manifest.json +18 -0
  91. package/.next/standalone/.next/server/app/audit/page/next-font-manifest.json +6 -0
  92. package/.next/standalone/.next/server/app/audit/page/react-loadable-manifest.json +1 -0
  93. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +29 -0
  94. package/.next/standalone/.next/server/app/audit/page.js +17 -0
  95. package/.next/standalone/.next/server/app/audit/page.js.map +5 -0
  96. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -0
  97. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +3 -0
  98. package/.next/standalone/.next/server/app/index.html +1 -1
  99. package/.next/standalone/.next/server/app/index.rsc +16 -17
  100. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  101. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +16 -17
  102. package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +4 -4
  103. package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +10 -10
  104. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -3
  105. package/.next/standalone/.next/server/app/page/build-manifest.json +7 -7
  106. package/.next/standalone/.next/server/app/page/next-font-manifest.json +2 -6
  107. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  108. package/.next/standalone/.next/server/app/page.js +14 -15
  109. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  110. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  111. package/.next/standalone/.next/server/app/policies/page/build-manifest.json +7 -7
  112. package/.next/standalone/.next/server/app/policies/page/next-font-manifest.json +2 -6
  113. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +8 -8
  114. package/.next/standalone/.next/server/app/policies/page.js +16 -16
  115. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  116. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  117. package/.next/standalone/.next/server/app/project/[name]/page/build-manifest.json +7 -7
  118. package/.next/standalone/.next/server/app/project/[name]/page/next-font-manifest.json +2 -6
  119. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  120. package/.next/standalone/.next/server/app/project/[name]/page.js +16 -17
  121. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  122. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  123. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/build-manifest.json +7 -7
  124. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/next-font-manifest.json +2 -6
  125. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  126. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  127. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +19 -20
  128. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  129. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  130. package/.next/standalone/.next/server/app/projects/page/build-manifest.json +7 -7
  131. package/.next/standalone/.next/server/app/projects/page/next-font-manifest.json +2 -6
  132. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  133. package/.next/standalone/.next/server/app/projects/page.js +15 -16
  134. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  135. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  136. package/.next/standalone/.next/server/app-paths-manifest.json +9 -1
  137. package/.next/standalone/.next/server/chunks/[externals]__14odj07._.js +3 -0
  138. package/.next/standalone/.next/server/chunks/{[externals]__0z0j--b._.js → [externals]__1nl3dvw._.js} +1 -1
  139. package/.next/standalone/.next/server/chunks/{[externals]__0-p9.k~._.js → [externals]__1s61mel._.js} +1 -1
  140. package/.next/standalone/.next/server/chunks/{[externals]_node_os_06ur78j._.js → [externals]_node_os_0by37l-._.js} +1 -1
  141. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0kjo7d_._.js → [root-of-the-server]__0_0xu5z._.js} +2 -2
  142. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0cag8qd._.js +3 -0
  143. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0z-180.._.js → [root-of-the-server]__0cycwg6._.js} +2 -2
  144. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__08px0ym._.js → [root-of-the-server]__0f7mikp._.js} +1 -1
  145. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0q-v9z2._.js +3 -0
  146. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0rv7m0k._.js +3 -0
  147. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0g48iv.._.js → [root-of-the-server]__0sb_5m8._.js} +2 -2
  148. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0j8-xkl._.js → [root-of-the-server]__0xuaoik._.js} +2 -2
  149. package/.next/standalone/.next/server/chunks/[root-of-the-server]__13h8pzr._.js +3 -0
  150. package/.next/standalone/.next/server/chunks/[root-of-the-server]__17g9wh7._.js +3 -0
  151. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1_mqemn._.js +3 -0
  152. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0vlhtkc._.js → [root-of-the-server]__1hgv_75._.js} +1 -1
  153. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0wu7fr7._.js → [root-of-the-server]__1jm9fw6._.js} +1 -1
  154. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1legmza._.js +3 -0
  155. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__044xt9.._.js → [root-of-the-server]__1m2_4t0._.js} +2 -2
  156. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0yfq1yr._.js → [root-of-the-server]__1mhmdzs._.js} +1 -1
  157. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0zso~62._.js → [root-of-the-server]__1ou2ehh._.js} +1 -1
  158. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1qxztj-._.js +3 -0
  159. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1r1h8v9._.js +3 -0
  160. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1rhmvod._.js +3 -0
  161. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1uatkiv._.js +3 -0
  162. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0.~nmr9._.js → [root-of-the-server]__1w9zl9-._.js} +1 -1
  163. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1y6gxxb._.js +3 -0
  164. package/.next/standalone/.next/server/chunks/{_0ebx_lc._.js → _0p53ge1._.js} +2 -2
  165. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_audit_invite_route_actions_0-2n5sy.js +3 -0
  166. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_audit_run_route_actions_1qgp9io.js +3 -0
  167. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_audit_status_route_actions_1f7pjof.js +3 -0
  168. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_auth_login-request_route_actions_1c49co0.js +3 -0
  169. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_auth_login-verify_route_actions_1r3slzk.js +3 -0
  170. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_auth_logout_route_actions_0regwyr.js +3 -0
  171. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_auth_reminder_route_actions_1kjgxf8.js +3 -0
  172. package/.next/standalone/.next/server/chunks/_next-internal_server_app_api_auth_status_route_actions_1aho9zu.js +3 -0
  173. package/.next/standalone/.next/server/chunks/{_next-internal_server_app_api_download_[project]_[session]_route_actions_0wb00i-.js → _next-internal_server_app_api_download_[project]_[session]_route_actions_1is7vs7.js} +1 -1
  174. package/.next/standalone/.next/server/chunks/{lib_logger_ts_047tt9f._.js → lib_logger_ts_07e65t5._.js} +1 -1
  175. package/.next/standalone/.next/server/chunks/node_modules_0-tu4ot._.js +3 -0
  176. package/.next/standalone/.next/server/chunks/node_modules_0ttxbz7._.js +3 -0
  177. package/.next/standalone/.next/server/chunks/node_modules_1bnh1y0._.js +3 -0
  178. package/.next/standalone/.next/server/chunks/node_modules_1epycqa._.js +3 -0
  179. package/.next/standalone/.next/server/chunks/node_modules_1wpdcgo._.js +3 -0
  180. package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_17k9e3w.js +23 -0
  181. package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_01r25oi._.js +3 -0
  182. package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_09z9-p7._.js +3 -0
  183. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +3 -0
  184. package/.next/standalone/.next/server/chunks/ssr/{[externals]__12dv.x0._.js → [externals]__1_g_b3t._.js} +1 -1
  185. package/.next/standalone/.next/server/chunks/ssr/{[externals]_node_async_hooks_0v0ln8c._.js → [externals]_node_async_hooks_1gjz99j._.js} +1 -1
  186. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01tn1ou._.js +3 -0
  187. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0808sha._.js +4 -0
  188. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0e4-6d8._.js +4 -0
  189. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ehe24g._.js +4 -0
  190. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0f62vu9._.js +3 -0
  191. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0g253ve._.js +4 -0
  192. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0h12me5._.js +3 -0
  193. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0k65l27._.js +3 -0
  194. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0vxf0_g._.js +4 -0
  195. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11rtg6s._.js +3 -0
  196. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__12mcauo._.js +4 -0
  197. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__14dd6h8._.js +3 -0
  198. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0t5l7a5._.js → [root-of-the-server]__1d8omgc._.js} +1 -1
  199. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__10xgshr._.js → [root-of-the-server]__1dky4g0._.js} +2 -2
  200. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1e-x7j4._.js +3 -0
  201. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1fax1sl._.js +19 -0
  202. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1mt35_w._.js +221 -0
  203. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1pcxxwg._.js +4 -0
  204. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1usf8v2._.js +3 -0
  205. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1uvfwgr._.js +4 -0
  206. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1w6v_1u._.js +3 -0
  207. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__212nf49._.js +3 -0
  208. package/.next/standalone/.next/server/chunks/ssr/{_03d7qyt._.js → _05whahf._.js} +2 -2
  209. package/.next/standalone/.next/server/chunks/ssr/_0il3fl1._.js +3 -0
  210. package/.next/standalone/.next/server/chunks/ssr/_11_p9y8._.js +3 -0
  211. package/.next/standalone/.next/server/chunks/ssr/{_0xb8ngh._.js → _1kje4fm._.js} +1 -1
  212. package/.next/standalone/.next/server/chunks/ssr/{_0zx~s__._.js → _1p0-leb._.js} +1 -1
  213. package/.next/standalone/.next/server/chunks/ssr/{app_04qfs8z._.js → app_087bt9w._.js} +1 -1
  214. package/.next/standalone/.next/server/chunks/ssr/{app_0uosk1e._.js → app_1fvisnp._.js} +1 -1
  215. package/.next/standalone/.next/server/chunks/ssr/{app_13f0ohr._.js → app_209u41o._.js} +1 -1
  216. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +65 -0
  217. package/.next/standalone/.next/server/chunks/ssr/app_audit_loading_tsx_1j1kc6j._.js +3 -0
  218. package/.next/standalone/.next/server/chunks/ssr/{app_error_tsx_11t4ysq._.js → app_error_tsx_1zds1ns._.js} +1 -1
  219. package/.next/standalone/.next/server/chunks/ssr/{app_global-error_tsx_0m9qisk._.js → app_global-error_tsx_113y3za._.js} +1 -1
  220. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +3 -0
  221. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +8 -0
  222. package/.next/standalone/.next/server/chunks/ssr/{app_project_[name]_error_tsx_0.9-fod._.js → app_project_[name]_error_tsx_1v02_5n._.js} +1 -1
  223. package/.next/standalone/.next/server/chunks/ssr/{app_project_[name]_loading_tsx_03g9xy0._.js → app_project_[name]_loading_tsx_05-l4uf._.js} +1 -1
  224. package/.next/standalone/.next/server/chunks/ssr/{app_project_[name]_session_[sessionId]_error_tsx_0ler-mr._.js → app_project_[name]_session_[sessionId]_error_tsx_0-lj3nd._.js} +1 -1
  225. package/.next/standalone/.next/server/chunks/ssr/{app_project_[name]_session_[sessionId]_loading_tsx_0c0e3yx._.js → app_project_[name]_session_[sessionId]_loading_tsx_0l4aixs._.js} +1 -1
  226. package/.next/standalone/.next/server/chunks/ssr/app_projects_loading_tsx_20-3u8b._.js +3 -0
  227. package/.next/standalone/.next/server/chunks/ssr/{lib_codex-projects_ts_0eosib~._.js → lib_codex-projects_ts_0pqlw37._.js} +1 -1
  228. package/.next/standalone/.next/server/chunks/ssr/{lib_copilot-projects_ts_0r8xkn8._.js → lib_copilot-projects_ts_19wl7tp._.js} +1 -1
  229. package/.next/standalone/.next/server/chunks/ssr/{lib_cursor-projects_ts_0qt1scg._.js → lib_cursor-projects_ts_18-iwyk._.js} +1 -1
  230. package/.next/standalone/.next/server/chunks/ssr/{lib_gemini-projects_ts_0sl~yqr._.js → lib_gemini-projects_ts_1c7bgx-._.js} +1 -1
  231. package/.next/standalone/.next/server/chunks/ssr/{lib_opencode-projects_ts_0op9gyp._.js → lib_opencode-projects_ts_15bjxkm._.js} +1 -1
  232. package/.next/standalone/.next/server/chunks/ssr/{lib_pi-projects_ts_103tsh1._.js → lib_pi-projects_ts_1wikofb._.js} +1 -1
  233. package/.next/standalone/.next/server/chunks/ssr/lib_utils_ts_0az0sfq._.js +3 -0
  234. package/.next/standalone/.next/server/chunks/ssr/node_modules_1ynf7el._.js +3 -0
  235. package/.next/standalone/.next/server/chunks/ssr/node_modules_html-to-image_es_index_0nye1s3.js +3 -0
  236. package/.next/standalone/.next/server/chunks/ssr/node_modules_html-to-image_es_index_1ao30b1.js +3 -0
  237. package/.next/standalone/.next/server/chunks/ssr/{node_modules_next_0rd0oc-._.js → node_modules_next_1a1kch7._.js} +1 -1
  238. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_0uboya6._.js +6 -0
  239. package/.next/standalone/.next/server/chunks/ssr/{node_modules_next_dist_11dij6w._.js → node_modules_next_dist_1d_onnt._.js} +2 -2
  240. package/.next/standalone/.next/server/chunks/ssr/{node_modules_next_dist_client_components_0inhx6q._.js → node_modules_next_dist_client_components_0wpq8j3._.js} +1 -1
  241. package/.next/standalone/.next/server/chunks/ssr/{node_modules_next_dist_client_components_builtin_forbidden_0ghu-f7.js → node_modules_next_dist_client_components_builtin_forbidden_0symwr9.js} +1 -1
  242. package/.next/standalone/.next/server/chunks/ssr/{node_modules_next_dist_client_components_builtin_unauthorized_0cjv-23.js → node_modules_next_dist_client_components_builtin_unauthorized_0l_sp0x.js} +1 -1
  243. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0-uvagv.js +4 -0
  244. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_03c7gi5.js +4 -0
  245. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_09p-8om.js +4 -0
  246. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0v-kfiu.js +4 -0
  247. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0xrgzyz.js +4 -0
  248. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_1806lsc.js +4 -0
  249. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_1j6dd-e.js +4 -0
  250. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_1sa65r-.js +4 -0
  251. package/.next/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_11bnuzn._.js +3 -0
  252. package/.next/standalone/.next/server/chunks/ssr/src_hooks_1ezd2jf._.js +5 -0
  253. package/.next/standalone/.next/server/chunks/ssr/src_hooks_1tnuifj._.js +5 -0
  254. package/.next/standalone/.next/server/functions-config-manifest.json +2 -2
  255. package/.next/standalone/.next/server/instrumentation.js +1 -1
  256. package/.next/standalone/.next/server/middleware-build-manifest.js +10 -10
  257. package/.next/standalone/.next/server/middleware.js +2 -2
  258. package/.next/standalone/.next/server/next-font-manifest.js +1 -1
  259. package/.next/standalone/.next/server/next-font-manifest.json +2 -21
  260. package/.next/standalone/.next/server/pages/404.html +1 -1
  261. package/.next/standalone/.next/server/pages/500.html +1 -1
  262. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  263. package/.next/standalone/.next/server/server-reference-manifest.json +27 -9
  264. package/.next/standalone/.next/static/{dAuQps6jUwCz9X1Q5FFOO → DOSSF5hRUtt3-QZEm-ZIk}/_clientMiddlewareManifest.js +2 -2
  265. package/.next/standalone/.next/static/chunks/{0pkl..xgo-qox.js → 02e80j0576qfu.js} +1 -1
  266. package/.next/standalone/.next/static/chunks/{07uz2g0_38qia.js → 03fmihek9n986.js} +1 -1
  267. package/.next/standalone/.next/static/chunks/0f7d7hnbh4djs.js +1 -0
  268. package/.next/standalone/.next/static/chunks/0h7auy7hzjyhw.js +1 -0
  269. package/.next/standalone/.next/static/chunks/0wwt5o04i4zwh.js +1 -0
  270. package/.next/standalone/.next/static/chunks/0zbxssxh53n-3.js +1 -0
  271. package/.next/standalone/.next/static/chunks/13f1kmjea-0md.js +2 -0
  272. package/.next/standalone/.next/static/chunks/13xzda05yw19e.js +1 -0
  273. package/.next/standalone/.next/static/chunks/{150i0n26fnvso.js → 1__i9af9g78vd.js} +1 -1
  274. package/.next/standalone/.next/static/chunks/1uxa5lm6yco79.js +1 -0
  275. package/.next/standalone/.next/static/chunks/20dqelk3xz_ya.css +1 -0
  276. package/.next/standalone/.next/static/chunks/{0j171xiqge4rv.js → 29lzaddhez98q.js} +1 -1
  277. package/.next/standalone/.next/static/chunks/29nrs5xs9c4hx.css +2 -0
  278. package/.next/standalone/.next/static/chunks/{0lt8ko3lw.5yt.js → 2b_e9tyly10lo.js} +1 -1
  279. package/.next/standalone/.next/static/chunks/{0rnqmir4cd5p9.js → 2h0dkzyy0vocp.js} +1 -1
  280. package/.next/standalone/.next/static/chunks/2lp3a3a3_4_9o.js +63 -0
  281. package/.next/standalone/.next/static/chunks/{179yytvmam0ug.js → 2nt_slonrn0rw.js} +1 -1
  282. package/.next/standalone/.next/static/chunks/2plcgtv_tkv9t.js +1 -0
  283. package/.next/standalone/.next/static/chunks/33k2epr1iz8_z.js +6 -0
  284. package/.next/standalone/.next/static/chunks/{0d3shmwh5_nmn.js → 33u59vf_8xpd-.js} +1 -1
  285. package/.next/standalone/.next/static/chunks/3zkg2s2vzxc3d.js +1 -0
  286. package/.next/standalone/.next/static/chunks/{turbopack-05z7a19q43zfq.js → turbopack-3lrm4f20fz89b.js} +1 -1
  287. package/.next/standalone/SECURITY.md +73 -0
  288. package/.next/standalone/app/actions/get-audit-result.ts +35 -0
  289. package/.next/standalone/app/api/audit/_state.ts +79 -0
  290. package/.next/standalone/app/api/audit/invite/route.ts +183 -0
  291. package/.next/standalone/app/api/audit/run/route.ts +103 -0
  292. package/.next/standalone/app/api/audit/status/route.ts +24 -0
  293. package/.next/standalone/app/api/auth/login-request/route.ts +91 -0
  294. package/.next/standalone/app/api/auth/login-verify/route.ts +98 -0
  295. package/.next/standalone/app/api/auth/logout/route.ts +48 -0
  296. package/.next/standalone/app/api/auth/reminder/route.ts +213 -0
  297. package/.next/standalone/app/api/auth/status/route.ts +42 -0
  298. package/.next/standalone/app/audit/_components/audit-dashboard.tsx +397 -0
  299. package/.next/standalone/app/audit/_components/audit-poster.tsx +326 -0
  300. package/.next/standalone/app/audit/_components/audit-progress-strip.tsx +98 -0
  301. package/.next/standalone/app/audit/_components/auth-dialog.tsx +375 -0
  302. package/.next/standalone/app/audit/_components/come-back-better-section.tsx +333 -0
  303. package/.next/standalone/app/audit/_components/empty-state.tsx +152 -0
  304. package/.next/standalone/app/audit/_components/how-to-improve-section.tsx +187 -0
  305. package/.next/standalone/app/audit/_components/invite-dialog.tsx +227 -0
  306. package/.next/standalone/app/audit/_components/quirks-section.tsx +75 -0
  307. package/.next/standalone/app/audit/_components/report-footer.tsx +35 -0
  308. package/.next/standalone/app/audit/_components/rerun-button.tsx +119 -0
  309. package/.next/standalone/app/audit/_components/run-progress.tsx +120 -0
  310. package/.next/standalone/app/audit/_components/share-templates.ts +94 -0
  311. package/.next/standalone/app/audit/_components/sigil.tsx +36 -0
  312. package/.next/standalone/app/audit/_components/strengths-section.tsx +45 -0
  313. package/.next/standalone/app/audit/audit-styles.css +1178 -0
  314. package/.next/standalone/app/audit/loading.tsx +24 -0
  315. package/.next/standalone/app/audit/page.tsx +63 -0
  316. package/.next/standalone/app/components/sessions-list.tsx +77 -80
  317. package/.next/standalone/app/globals.css +754 -139
  318. package/.next/standalone/app/layout.tsx +6 -8
  319. package/.next/standalone/app/policies/hooks-client.tsx +340 -141
  320. package/.next/standalone/app/project/[name]/page.tsx +31 -37
  321. package/.next/standalone/app/projects/loading.tsx +30 -8
  322. package/.next/standalone/app/projects/page.tsx +66 -17
  323. package/.next/standalone/assets/audit/Audit Report.html +22 -0
  324. package/.next/standalone/assets/audit/Show Off Your Agent.html +22 -0
  325. package/.next/standalone/assets/audit/archetypes.jsx +277 -0
  326. package/.next/standalone/assets/audit/assets/fonts/bitcount-prop-single.woff2 +0 -0
  327. package/.next/standalone/assets/audit/audit.jsx +825 -0
  328. package/.next/standalone/assets/audit/poster-styles.css +424 -0
  329. package/.next/standalone/assets/audit/poster.jsx +247 -0
  330. package/.next/standalone/assets/audit/screenshots/poster-optimist.png +0 -0
  331. package/.next/standalone/assets/audit/screenshots/poster-scrolled.png +0 -0
  332. package/.next/standalone/assets/audit/styles.css +1225 -0
  333. package/.next/standalone/assets/audit/tweaks-panel.jsx +425 -0
  334. package/.next/standalone/assets/logos/company/icon.svg +1 -0
  335. package/.next/standalone/assets/logos/company/logo.svg +1 -0
  336. package/.next/standalone/components/navbar.tsx +119 -65
  337. package/.next/standalone/components/reach-developers.tsx +39 -11
  338. package/.next/standalone/lib/atomic-write.ts +67 -0
  339. package/.next/standalone/lib/auth/api-server-client.ts +306 -0
  340. package/.next/standalone/lib/auth/auth-store.ts +250 -0
  341. package/.next/standalone/lib/claude-sessions.ts +181 -0
  342. package/.next/standalone/lib/client-telemetry.ts +2 -0
  343. package/.next/standalone/lib/fetch-with-timeout.ts +59 -0
  344. package/.next/standalone/lib/share-card.ts +144 -0
  345. package/.next/standalone/lib/telemetry.ts +12 -7
  346. package/.next/standalone/node_modules/@next/env/package.json +2 -2
  347. package/.next/standalone/node_modules/next/dist/build/static-paths/app.js +2 -1
  348. package/.next/standalone/node_modules/next/dist/build/swc/index.js +1 -1
  349. package/.next/standalone/node_modules/next/dist/build/utils.js +2 -1
  350. package/.next/standalone/node_modules/next/dist/client/components/router-reducer/fetch-server-response.js +2 -2
  351. package/.next/standalone/node_modules/next/dist/client/components/router-reducer/set-cache-busting-search-param.js +8 -2
  352. package/.next/standalone/node_modules/next/dist/client/dev/debug-channel.js +102 -2
  353. package/.next/standalone/node_modules/next/dist/client/route-params.js +23 -6
  354. package/.next/standalone/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +13 -13
  355. package/.next/standalone/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +13 -13
  356. package/.next/standalone/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +2 -2
  357. package/.next/standalone/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +10 -10
  358. package/.next/standalone/node_modules/next/dist/lib/patch-incorrect-lockfile.js +3 -3
  359. package/.next/standalone/node_modules/next/dist/server/app-render/action-handler.js +21 -14
  360. package/.next/standalone/node_modules/next/dist/server/app-render/app-render.js +62 -9
  361. package/.next/standalone/node_modules/next/dist/server/app-render/collect-segment-data.js +16 -0
  362. package/.next/standalone/node_modules/next/dist/server/app-render/create-component-tree.js +49 -19
  363. package/.next/standalone/node_modules/next/dist/server/app-render/get-script-nonce-from-header.js +8 -20
  364. package/.next/standalone/node_modules/next/dist/server/app-render/metadata-insertion/create-server-inserted-metadata.js +8 -7
  365. package/.next/standalone/node_modules/next/dist/server/app-render/use-flight-response.js +2 -2
  366. package/.next/standalone/node_modules/next/dist/server/async-storage/work-store.js +2 -1
  367. package/.next/standalone/node_modules/next/dist/server/base-server.js +13 -5
  368. package/.next/standalone/node_modules/next/dist/server/config-schema.js +1 -0
  369. package/.next/standalone/node_modules/next/dist/server/config.js +1 -1
  370. package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +2 -2
  371. package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1 -1
  372. package/.next/standalone/node_modules/next/dist/server/dev/static-paths-worker.js +2 -1
  373. package/.next/standalone/node_modules/next/dist/server/image-optimizer.js +22 -2
  374. package/.next/standalone/node_modules/next/dist/server/lib/app-info-log.js +1 -1
  375. package/.next/standalone/node_modules/next/dist/server/lib/encode-cache-tag.js +45 -0
  376. package/.next/standalone/node_modules/next/dist/server/lib/implicit-tags.js +6 -3
  377. package/.next/standalone/node_modules/next/dist/server/lib/is-rsc-request.js +18 -0
  378. package/.next/standalone/node_modules/next/dist/server/lib/mock-request.js +30 -5
  379. package/.next/standalone/node_modules/next/dist/server/lib/patch-fetch.js +5 -1
  380. package/.next/standalone/node_modules/next/dist/server/lib/patch-set-header.js +7 -0
  381. package/.next/standalone/node_modules/next/dist/server/lib/router-server.js +6 -3
  382. package/.next/standalone/node_modules/next/dist/server/lib/router-utils/resolve-routes.js +18 -4
  383. package/.next/standalone/node_modules/next/dist/server/lib/server-ipc/utils.js +3 -1
  384. package/.next/standalone/node_modules/next/dist/server/lib/start-server.js +1 -1
  385. package/.next/standalone/node_modules/next/dist/server/next-server.js +1 -1
  386. package/.next/standalone/node_modules/next/dist/server/request/fallback-params.js +27 -1
  387. package/.next/standalone/node_modules/next/dist/server/route-modules/app-route/module.js +1 -0
  388. package/.next/standalone/node_modules/next/dist/server/route-modules/route-module.js +11 -1
  389. package/.next/standalone/node_modules/next/dist/server/server-utils.js +19 -2
  390. package/.next/standalone/node_modules/next/dist/server/stream-utils/node-web-streams-helper.js +5 -5
  391. package/.next/standalone/node_modules/next/dist/server/use-cache/use-cache-wrapper.js +1 -1
  392. package/.next/standalone/node_modules/next/dist/server/web/adapter.js +4 -1
  393. package/.next/standalone/node_modules/next/dist/server/web/edge-route-module-wrapper.js +2 -1
  394. package/.next/standalone/node_modules/next/dist/server/web/spec-extension/revalidate.js +4 -3
  395. package/.next/standalone/node_modules/next/dist/server/web/spec-extension/unstable-cache.js +6 -2
  396. package/.next/standalone/node_modules/next/dist/shared/lib/errors/canary-only-config-error.js +1 -1
  397. package/.next/standalone/node_modules/next/dist/{server → shared/lib}/htmlescape.js +15 -0
  398. package/.next/standalone/node_modules/next/dist/shared/lib/router/routes/app.js +13 -1
  399. package/.next/standalone/node_modules/next/dist/shared/lib/router/utils/cache-busting-search-param.js +56 -10
  400. package/.next/standalone/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
  401. package/.next/standalone/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
  402. package/.next/standalone/node_modules/next/dist/telemetry/events/version.js +2 -2
  403. package/.next/standalone/node_modules/next/package.json +15 -15
  404. package/.next/standalone/node_modules/react/cjs/react.development.js +1 -1
  405. package/.next/standalone/node_modules/react/cjs/react.production.js +1 -1
  406. package/.next/standalone/node_modules/react/package.json +1 -1
  407. package/.next/standalone/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.js +1 -1
  408. package/.next/standalone/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.js +1 -1
  409. package/.next/standalone/node_modules/react-dom/cjs/react-dom-server.browser.production.js +3 -3
  410. package/.next/standalone/node_modules/react-dom/cjs/react-dom-server.edge.production.js +3 -3
  411. package/.next/standalone/node_modules/react-dom/cjs/react-dom-server.node.production.js +3 -3
  412. package/.next/standalone/node_modules/react-dom/cjs/react-dom.production.js +1 -1
  413. package/.next/standalone/node_modules/react-dom/package.json +2 -2
  414. package/.next/standalone/osv-scanner.toml +17 -0
  415. package/.next/standalone/package.json +26 -18
  416. package/.next/standalone/proxy.ts +1 -1
  417. package/.next/standalone/public/audit/fonts/bitcount-prop-single.woff2 +0 -0
  418. package/.next/standalone/public/icon.svg +1 -0
  419. package/.next/standalone/public/logo.svg +1 -0
  420. package/.next/standalone/server.js +1 -1
  421. package/.next/standalone/templates/bitcount-font/README.md +42 -0
  422. package/.next/standalone/templates/bitcount-font/bitcount-prop-single.woff2 +0 -0
  423. package/.next/standalone/templates/bitcount-font/bitcount.css +49 -0
  424. package/.next/standalone/templates/bitcount-font/fonts.ts.example +23 -0
  425. package/README.md +12 -5
  426. package/bin/failproofai.mjs +263 -70
  427. package/dist/cli.mjs +3830 -1617
  428. package/lib/atomic-write.ts +67 -0
  429. package/lib/auth/api-server-client.ts +306 -0
  430. package/lib/auth/auth-store.ts +250 -0
  431. package/lib/claude-sessions.ts +181 -0
  432. package/lib/client-telemetry.ts +2 -0
  433. package/lib/fetch-with-timeout.ts +59 -0
  434. package/lib/share-card.ts +144 -0
  435. package/lib/telemetry.ts +12 -7
  436. package/package.json +26 -18
  437. package/scripts/install-telemetry.mjs +4 -0
  438. package/scripts/launch.ts +2 -2
  439. package/scripts/postinstall.mjs +89 -1
  440. package/src/audit/archetypes.ts +944 -0
  441. package/src/audit/cache.ts +151 -0
  442. package/src/audit/cli-adapters/claude.ts +97 -0
  443. package/src/audit/cli-adapters/codex.ts +56 -0
  444. package/src/audit/cli-adapters/copilot.ts +51 -0
  445. package/src/audit/cli-adapters/cursor.ts +51 -0
  446. package/src/audit/cli-adapters/gemini.ts +51 -0
  447. package/src/audit/cli-adapters/index.ts +70 -0
  448. package/src/audit/cli-adapters/opencode.ts +52 -0
  449. package/src/audit/cli-adapters/pi.ts +51 -0
  450. package/src/audit/cli-adapters/shared.ts +85 -0
  451. package/src/audit/cli.ts +319 -0
  452. package/src/audit/dashboard-cache.ts +158 -0
  453. package/src/audit/detectors/find-from-root.ts +27 -0
  454. package/src/audit/detectors/git-commit-no-verify.ts +22 -0
  455. package/src/audit/detectors/index.ts +33 -0
  456. package/src/audit/detectors/prefer-edit-over-read-cat.ts +31 -0
  457. package/src/audit/detectors/prefer-edit-over-sed-awk.ts +27 -0
  458. package/src/audit/detectors/prefer-write-over-heredoc.ts +36 -0
  459. package/src/audit/detectors/redundant-cd-cwd.ts +28 -0
  460. package/src/audit/detectors/reread-after-edit.ts +58 -0
  461. package/src/audit/detectors/sleep-polling-loop.ts +34 -0
  462. package/src/audit/features.ts +314 -0
  463. package/src/audit/findings.ts +298 -0
  464. package/src/audit/index.ts +387 -0
  465. package/src/audit/open-browser.ts +69 -0
  466. package/src/audit/replay.ts +147 -0
  467. package/src/audit/report.ts +349 -0
  468. package/src/audit/scoring.ts +174 -0
  469. package/src/audit/social-proof.ts +34 -0
  470. package/src/audit/strengths.ts +138 -0
  471. package/src/audit/types.ts +216 -0
  472. package/src/auth/cli.ts +359 -0
  473. package/src/hooks/builtin-policies.ts +81 -2
  474. package/src/hooks/custom-hooks-loader.ts +19 -3
  475. package/src/hooks/first-run-nudge.ts +146 -0
  476. package/src/hooks/handler.ts +21 -102
  477. package/src/hooks/hook-telemetry.ts +2 -2
  478. package/src/hooks/install-prompt.ts +34 -4
  479. package/src/hooks/manager.ts +72 -5
  480. package/src/hooks/policy-evaluator.ts +19 -4
  481. package/src/hooks/policy-registry.ts +21 -1
  482. package/src/hooks/policy-types.ts +9 -0
  483. package/src/hooks/tool-name-canonicalize.ts +65 -0
  484. package/src/posthog-key.ts +9 -0
  485. package/.next/standalone/.next/server/app/icon.png/route/app-paths-manifest.json +0 -3
  486. package/.next/standalone/.next/server/app/icon.png/route.js +0 -7
  487. package/.next/standalone/.next/server/app/icon.png/route.js.nft.json +0 -1
  488. package/.next/standalone/.next/server/app/icon.png.body +0 -0
  489. package/.next/standalone/.next/server/app/icon.png.meta +0 -1
  490. package/.next/standalone/.next/server/chunks/[externals]_next_dist_0sqmaqd._.js +0 -3
  491. package/.next/standalone/.next/server/chunks/[root-of-the-server]__06.arfm._.js +0 -3
  492. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0__i0h0._.js +0 -3
  493. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0d_ob4n._.js +0 -3
  494. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0fe7_q_._.js +0 -3
  495. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0fw.e.h._.js +0 -3
  496. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0pxn0e1._.js +0 -3
  497. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0xv0jh2._.js +0 -3
  498. package/.next/standalone/.next/server/chunks/_next-internal_server_app_icon_png_route_actions_12.gv.r.js +0 -3
  499. package/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_0bdfoky.js +0 -3
  500. package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_05pz9._._.js +0 -3
  501. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_0z7w.hh._.js +0 -3
  502. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02r.cjq._.js +0 -3
  503. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0370~qj._.js +0 -3
  504. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0609ezh._.js +0 -3
  505. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__07_-mkc._.js +0 -3
  506. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__09z7o2x._.js +0 -19
  507. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0_sh2n0._.js +0 -3
  508. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0e9o9ri._.js +0 -4
  509. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0l6swv1._.js +0 -3
  510. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0logebz._.js +0 -3
  511. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0mi5ejy._.js +0 -4
  512. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0odijkc._.js +0 -3
  513. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0podumr._.js +0 -4
  514. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0rkxer-._.js +0 -3
  515. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0rl2kwi._.js +0 -4
  516. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0vg0uey._.js +0 -4
  517. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0x5limi._.js +0 -3
  518. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ye1w50._.js +0 -4
  519. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ymlddl._.js +0 -223
  520. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__10._f0s._.js +0 -4
  521. package/.next/standalone/.next/server/chunks/ssr/app_0cdqd9w._.js +0 -3
  522. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_0xerkr6._.js +0 -3
  523. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_0q-m0y-._.js +0 -8
  524. package/.next/standalone/.next/server/chunks/ssr/app_projects_loading_tsx_13veom4._.js +0 -3
  525. package/.next/standalone/.next/server/chunks/ssr/lib_utils_ts_068jk73._.js +0 -3
  526. package/.next/standalone/.next/server/chunks/ssr/node_modules_0ttbz1~._.js +0 -3
  527. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_06u0kr8._.js +0 -3
  528. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_0h9llsw._.js +0 -6
  529. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0a_7sdg.js +0 -4
  530. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0ef3uwk.js +0 -4
  531. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0j79~gv.js +0 -4
  532. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0pbja1x.js +0 -4
  533. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0r6o0i2.js +0 -4
  534. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_11y81~_.js +0 -4
  535. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_12or2kf.js +0 -4
  536. package/.next/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_0mebn66._.js +0 -3
  537. package/.next/standalone/.next/static/chunks/01q52wg_amm60.js +0 -2
  538. package/.next/standalone/.next/static/chunks/0kqar56yl~41o.js +0 -6
  539. package/.next/standalone/.next/static/chunks/0ml1.ck_5t36i.js +0 -1
  540. package/.next/standalone/.next/static/chunks/0w6fzf.07a24u.js +0 -1
  541. package/.next/standalone/.next/static/chunks/0zig0fh30t6ou.js +0 -1
  542. package/.next/standalone/.next/static/chunks/12l2t63hkyo2q.js +0 -1
  543. package/.next/standalone/.next/static/chunks/12pt~2f.c1sha.js +0 -1
  544. package/.next/standalone/.next/static/chunks/14lii11wmo450.js +0 -4
  545. package/.next/standalone/.next/static/chunks/17rm86uz2nd5a.css +0 -2
  546. package/.next/standalone/.next/static/media/4fa387ec64143e14-s.0q3udbd2bu5yp.woff2 +0 -0
  547. package/.next/standalone/.next/static/media/797e433ab948586e-s.p.0.q-h669a_dqa.woff2 +0 -0
  548. package/.next/standalone/.next/static/media/bbc41e54d2fcbd21-s.0gw~uztddq1df.woff2 +0 -0
  549. package/.next/standalone/.next/static/media/icon.0a.gigb3_x5pd.png +0 -0
  550. package/.next/standalone/app/icon.png +0 -0
  551. package/src/auth/login.ts +0 -104
  552. package/src/auth/logout.ts +0 -50
  553. package/src/auth/token-store.ts +0 -64
  554. package/src/relay/daemon.ts +0 -362
  555. package/src/relay/pid.ts +0 -76
  556. package/src/relay/queue.ts +0 -225
  557. /package/.next/standalone/.next/server/app/{icon.png → api/audit/invite}/route/build-manifest.json +0 -0
  558. /package/.next/standalone/.next/server/app/{icon.png → api/audit/invite}/route.js.map +0 -0
  559. /package/.next/standalone/.next/static/{dAuQps6jUwCz9X1Q5FFOO → DOSSF5hRUtt3-QZEm-ZIk}/_buildManifest.js +0 -0
  560. /package/.next/standalone/.next/static/{dAuQps6jUwCz9X1Q5FFOO → DOSSF5hRUtt3-QZEm-ZIk}/_ssgManifest.js +0 -0
  561. /package/.next/standalone/.next/static/chunks/{03~yq9q893hmn.js → 0cz1d0mv5g_q7.js} +0 -0
  562. /package/.next/standalone/.next/static/chunks/{0xbo5nl6w4lka.js → 2wbuxnsvux4di.js} +0 -0
  563. /package/.next/standalone/.next/static/chunks/{0_s0luks5tay-.js → 35fgpd_feci6x.js} +0 -0
  564. /package/.next/standalone/.next/static/chunks/{15fklyav5py5m.js → 3xpjn3cdgm-7m.js} +0 -0
  565. /package/.next/standalone/.next/static/chunks/{17.b3suj8zjjj.js → 4448_qq7bd963.js} +0 -0
@@ -0,0 +1,375 @@
1
+ "use client";
2
+
3
+ /**
4
+ * Auth dialog — modal overlay shown when an unauthenticated user clicks
5
+ * a cadence button to set a reminder. Two-step flow:
6
+ *
7
+ * 1. Email entry → POST /api/auth/login-request
8
+ * 2. OTP entry → POST /api/auth/login-verify
9
+ *
10
+ * Calm chrome to match the rest of /audit: 1px borders, plain
11
+ * lowercase copy, no corner crosshair frame. The dialog never sees
12
+ * the refresh token — the dashboard's API route writes it to
13
+ * ~/.failproofai/auth.json.
14
+ */
15
+
16
+ import React, { useCallback, useEffect, useRef, useState } from "react";
17
+ import { usePostHog } from "@/contexts/PostHogContext";
18
+ import { fetchWithTimeout, isAbortError } from "@/lib/fetch-with-timeout";
19
+
20
+ export interface AuthedUser {
21
+ id: string;
22
+ email: string;
23
+ }
24
+
25
+ interface Props {
26
+ open: boolean;
27
+ /** Optional title. Defaults to "where to route the reminder?". */
28
+ headline?: string;
29
+ /** Optional subtitle shown under the title on the email step. Defaults to
30
+ * "we'll send a one-time code to confirm." */
31
+ subhead?: string;
32
+ onClose: () => void;
33
+ /** Fired after successful verify. Caller decides what to do next. */
34
+ onAuthed: (user: AuthedUser) => void;
35
+ /** Telemetry tag identifying which CTA opened the dialog. */
36
+ source?: string;
37
+ }
38
+
39
+ type Step =
40
+ | { kind: "email"; error: string | null }
41
+ | { kind: "code"; email: string; error: string | null; expiresIn: number; resendIn: number }
42
+ | { kind: "done"; user: AuthedUser };
43
+
44
+ const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
45
+
46
+ function describeFetchError(err: unknown): string {
47
+ if (isAbortError(err)) {
48
+ return "request timed out. check your network and try again.";
49
+ }
50
+ const message = err instanceof Error ? err.message : String(err);
51
+ return `network error: ${message}`;
52
+ }
53
+
54
+ export function AuthDialog({
55
+ open,
56
+ headline = "where to route the reminder?",
57
+ subhead = "we'll send a one-time code to confirm.",
58
+ onClose,
59
+ onAuthed,
60
+ source = "unknown",
61
+ }: Props): React.ReactElement | null {
62
+ const { capture } = usePostHog();
63
+ const [step, setStep] = useState<Step>({ kind: "email", error: null });
64
+ const [busy, setBusy] = useState(false);
65
+ const succeededRef = useRef(false);
66
+ const emailInputRef = useRef<HTMLInputElement | null>(null);
67
+ const codeInputRef = useRef<HTMLInputElement | null>(null);
68
+
69
+ useEffect(() => {
70
+ if (open) {
71
+ setStep({ kind: "email", error: null });
72
+ setBusy(false);
73
+ succeededRef.current = false;
74
+ capture("audit_auth_dialog_opened", { source });
75
+ }
76
+ }, [capture, open, source]);
77
+
78
+ const wasOpenRef = useRef(false);
79
+ useEffect(() => {
80
+ if (open) {
81
+ wasOpenRef.current = true;
82
+ return;
83
+ }
84
+ if (wasOpenRef.current && !succeededRef.current) {
85
+ capture("audit_auth_dialog_dismissed", {
86
+ source,
87
+ step: step.kind,
88
+ });
89
+ }
90
+ wasOpenRef.current = false;
91
+ }, [capture, open, source, step.kind]);
92
+
93
+ useEffect(() => {
94
+ if (!open) return;
95
+ const t = setTimeout(() => {
96
+ if (step.kind === "email") emailInputRef.current?.focus();
97
+ else if (step.kind === "code") codeInputRef.current?.focus();
98
+ }, 50);
99
+ return () => clearTimeout(t);
100
+ }, [open, step.kind]);
101
+
102
+ useEffect(() => {
103
+ if (!open) return;
104
+ const onKey = (e: KeyboardEvent): void => {
105
+ if (e.key === "Escape" && !busy) onClose();
106
+ };
107
+ window.addEventListener("keydown", onKey);
108
+ return () => window.removeEventListener("keydown", onKey);
109
+ }, [open, busy, onClose]);
110
+
111
+ const resendActive = step.kind === "code" && step.resendIn > 0;
112
+ useEffect(() => {
113
+ if (!resendActive) return;
114
+ const id = setInterval(() => {
115
+ setStep((s) =>
116
+ s.kind === "code" ? { ...s, resendIn: Math.max(0, s.resendIn - 1) } : s,
117
+ );
118
+ }, 1000);
119
+ return () => clearInterval(id);
120
+ }, [resendActive]);
121
+
122
+ const requestCode = useCallback(
123
+ async (email: string, opts: { isResend?: boolean } = {}): Promise<void> => {
124
+ const { isResend = false } = opts;
125
+ const setError = (msg: string) => {
126
+ if (isResend) {
127
+ setStep((s) => (s.kind === "code" ? { ...s, error: msg } : s));
128
+ } else {
129
+ setStep({ kind: "email", error: msg });
130
+ }
131
+ };
132
+ setBusy(true);
133
+ try {
134
+ const res = await fetchWithTimeout("/api/auth/login-request", {
135
+ method: "POST",
136
+ headers: { "content-type": "application/json" },
137
+ body: JSON.stringify({ email }),
138
+ });
139
+ const body = (await res.json().catch(() => ({}))) as {
140
+ code?: string;
141
+ message?: string;
142
+ expires_in?: number;
143
+ resend_available_in?: number;
144
+ retry_after_secs?: number;
145
+ };
146
+ if (!res.ok) {
147
+ let msg = body.message ?? "could not send code.";
148
+ if (body.code === "rate_limited" && body.retry_after_secs !== undefined) {
149
+ msg = `too many tries. wait ${body.retry_after_secs}s and try again.`;
150
+ } else if (body.code === "upstream_unreachable") {
151
+ msg = "api-server unreachable. check your network.";
152
+ }
153
+ setError(msg);
154
+ return;
155
+ }
156
+ setStep({
157
+ kind: "code",
158
+ email,
159
+ error: null,
160
+ expiresIn: body.expires_in ?? 600,
161
+ resendIn: body.resend_available_in ?? 30,
162
+ });
163
+ } catch (err) {
164
+ setError(describeFetchError(err));
165
+ } finally {
166
+ setBusy(false);
167
+ }
168
+ },
169
+ [],
170
+ );
171
+
172
+ const verifyCode = useCallback(
173
+ async (email: string, code: string): Promise<void> => {
174
+ setBusy(true);
175
+ try {
176
+ const res = await fetchWithTimeout("/api/auth/login-verify", {
177
+ method: "POST",
178
+ headers: { "content-type": "application/json" },
179
+ body: JSON.stringify({ email, code }),
180
+ });
181
+ const body = (await res.json().catch(() => ({}))) as {
182
+ authenticated?: boolean;
183
+ user?: AuthedUser;
184
+ code?: string;
185
+ message?: string;
186
+ };
187
+ if (!res.ok || !body.authenticated || !body.user) {
188
+ let msg = body.message ?? "invalid code.";
189
+ if (body.code === "invalid_code") msg = "wrong code, or it expired. try again.";
190
+ setStep((s) =>
191
+ s.kind === "code" ? { ...s, error: msg } : s,
192
+ );
193
+ return;
194
+ }
195
+ succeededRef.current = true;
196
+ capture("audit_auth_dialog_succeeded", { source });
197
+ setStep({ kind: "done", user: body.user });
198
+ onAuthed(body.user);
199
+ } catch (err) {
200
+ const msg = describeFetchError(err);
201
+ setStep((s) =>
202
+ s.kind === "code" ? { ...s, error: msg } : s,
203
+ );
204
+ } finally {
205
+ setBusy(false);
206
+ }
207
+ },
208
+ [capture, onAuthed, source],
209
+ );
210
+
211
+ const onEmailSubmit = useCallback(
212
+ async (e: React.FormEvent<HTMLFormElement>) => {
213
+ e.preventDefault();
214
+ if (busy || step.kind !== "email") return;
215
+ const fd = new FormData(e.currentTarget);
216
+ const email = String(fd.get("email") ?? "").trim().toLowerCase();
217
+ if (!EMAIL_RE.test(email)) {
218
+ setStep({ kind: "email", error: "that doesn't look like an email." });
219
+ return;
220
+ }
221
+ await requestCode(email);
222
+ },
223
+ [busy, step, requestCode],
224
+ );
225
+
226
+ const onCodeSubmit = useCallback(
227
+ async (e: React.FormEvent<HTMLFormElement>) => {
228
+ e.preventDefault();
229
+ if (busy || step.kind !== "code") return;
230
+ const fd = new FormData(e.currentTarget);
231
+ const code = String(fd.get("code") ?? "").trim();
232
+ if (code.length < 4 || code.length > 12) {
233
+ setStep((s) =>
234
+ s.kind === "code" ? { ...s, error: "code is 4–12 characters." } : s,
235
+ );
236
+ return;
237
+ }
238
+ await verifyCode(step.email, code);
239
+ },
240
+ [busy, step, verifyCode],
241
+ );
242
+
243
+ const onResend = useCallback(async () => {
244
+ if (step.kind !== "code" || step.resendIn > 0 || busy) return;
245
+ await requestCode(step.email, { isResend: true });
246
+ }, [step, busy, requestCode]);
247
+
248
+ if (!open) return null;
249
+
250
+ return (
251
+ <div
252
+ className="auth-dialog-backdrop"
253
+ role="dialog"
254
+ aria-modal="true"
255
+ aria-labelledby="auth-dialog-title"
256
+ onClick={(e) => {
257
+ if (!busy && e.target === e.currentTarget) onClose();
258
+ }}
259
+ >
260
+ <div className="auth-dialog">
261
+ <button
262
+ type="button"
263
+ className="auth-close"
264
+ onClick={onClose}
265
+ disabled={busy}
266
+ aria-label="close"
267
+ >
268
+ ×
269
+ </button>
270
+
271
+ <h2 id="auth-dialog-title" className="auth-headline">
272
+ {headline}
273
+ </h2>
274
+
275
+ {step.kind === "email" && (
276
+ <>
277
+ <p className="auth-sub">{subhead}</p>
278
+ <form onSubmit={onEmailSubmit} className="auth-form">
279
+ <input
280
+ ref={emailInputRef}
281
+ id="auth-dialog-email"
282
+ name="email"
283
+ type="email"
284
+ autoComplete="email"
285
+ inputMode="email"
286
+ spellCheck={false}
287
+ placeholder="you@yourdomain.com"
288
+ disabled={busy}
289
+ className="auth-input"
290
+ required
291
+ />
292
+ {step.error && <div className="auth-error">{step.error}</div>}
293
+ <div className="auth-actions">
294
+ <button type="submit" className="auth-btn primary" disabled={busy}>
295
+ {busy ? "sending…" : "send code"}
296
+ </button>
297
+ <button
298
+ type="button"
299
+ className="auth-btn"
300
+ onClick={onClose}
301
+ disabled={busy}
302
+ >
303
+ cancel
304
+ </button>
305
+ </div>
306
+ </form>
307
+ </>
308
+ )}
309
+
310
+ {step.kind === "code" && (
311
+ <>
312
+ <p className="auth-sub">
313
+ code sent to <span className="auth-email">{step.email}</span>.
314
+ expires in {Math.ceil(step.expiresIn / 60)} min.
315
+ </p>
316
+ <form onSubmit={onCodeSubmit} className="auth-form">
317
+ <input
318
+ ref={codeInputRef}
319
+ id="auth-dialog-code"
320
+ name="code"
321
+ type="text"
322
+ inputMode="numeric"
323
+ autoComplete="one-time-code"
324
+ spellCheck={false}
325
+ placeholder="123456"
326
+ disabled={busy}
327
+ className="auth-input auth-input-code"
328
+ maxLength={12}
329
+ required
330
+ />
331
+ {step.error && <div className="auth-error">{step.error}</div>}
332
+ <div className="auth-actions">
333
+ <button type="submit" className="auth-btn primary" disabled={busy}>
334
+ {busy ? "verifying…" : "verify"}
335
+ </button>
336
+ <button
337
+ type="button"
338
+ className="auth-btn"
339
+ onClick={onResend}
340
+ disabled={busy || step.resendIn > 0}
341
+ >
342
+ {step.resendIn > 0
343
+ ? `resend in ${step.resendIn}s`
344
+ : "resend code"}
345
+ </button>
346
+ </div>
347
+ <button
348
+ type="button"
349
+ className="auth-back"
350
+ onClick={() => setStep({ kind: "email", error: null })}
351
+ disabled={busy}
352
+ >
353
+ ← use a different email
354
+ </button>
355
+ </form>
356
+ </>
357
+ )}
358
+
359
+ {step.kind === "done" && (
360
+ <>
361
+ <p className="auth-sub">
362
+ <span className="auth-ok">✓</span> signed in as{" "}
363
+ <span className="auth-email">{step.user.email}</span>.
364
+ </p>
365
+ <div className="auth-actions">
366
+ <button type="button" className="auth-btn primary" onClick={onClose}>
367
+ continue
368
+ </button>
369
+ </div>
370
+ </>
371
+ )}
372
+ </div>
373
+ </div>
374
+ );
375
+ }
@@ -0,0 +1,333 @@
1
+ "use client";
2
+
3
+ /**
4
+ * Section 05 — COME BACK BETTER. "build the habit."
5
+ *
6
+ * Two side-by-side cards:
7
+ *
8
+ * • Reminder — set a reminder cadence (3d / 7d / 14d / 30d). The cadence
9
+ * selection persists through /api/auth/reminder. Anon users get the
10
+ * AuthDialog first; authed-with-existing-reminder users see the next
11
+ * audit date and can reset.
12
+ *
13
+ * • Unlock perks — share with N friends to unlock pro features for a
14
+ * month. UI only — invite tracking + entitlement is a follow-up; the
15
+ * button opens the same X share intent the poster uses.
16
+ *
17
+ * Re-audit moves out of this section: a small inline "or re-audit now"
18
+ * link sits under the reminder card so the affordance survives without
19
+ * dominating the layout.
20
+ */
21
+ import React, { useCallback, useEffect, useRef, useState } from "react";
22
+ import { usePostHog } from "@/contexts/PostHogContext";
23
+ import { isAbortError } from "@/lib/fetch-with-timeout";
24
+ import { AuthDialog, type AuthedUser } from "./auth-dialog";
25
+ import { InviteDialog } from "./invite-dialog";
26
+
27
+ interface Props {
28
+ isRunning: boolean;
29
+ onRerun: () => void;
30
+ }
31
+
32
+ const DEFAULT_REMINDER_DAYS = 7;
33
+ const REMINDER_OPTIONS = [3, 7, 14, 30] as const;
34
+ type Cadence = typeof REMINDER_OPTIONS[number];
35
+
36
+ const PERKS_PERK = "share with 3 friends → unlock pro features for a month.";
37
+
38
+ // The AuthDialog is shared by the reminder and invite CTAs. The reminder path
39
+ // keeps the dialog's default copy; the invite path swaps in login-required
40
+ // copy. Content only — the auth flow is identical for both.
41
+ const INVITE_AUTH_COPY = {
42
+ headline: "Oops! Login required",
43
+ subhead: "What's your email?",
44
+ } as const;
45
+
46
+ type AuthStatus =
47
+ | { kind: "unknown" }
48
+ | { kind: "anon" }
49
+ | { kind: "authed"; user: { id: string; email: string } };
50
+
51
+ interface Reminder {
52
+ next_audit_at: number;
53
+ user_email: string;
54
+ set_at: number;
55
+ }
56
+
57
+ function daysUntil(unixSecs: number): number {
58
+ const nowSecs = Math.floor(Date.now() / 1000);
59
+ return Math.max(0, Math.ceil((unixSecs - nowSecs) / 86400));
60
+ }
61
+
62
+ function formatNextAudit(unixSecs: number): string {
63
+ const d = new Date(unixSecs * 1000);
64
+ return d.toLocaleDateString(undefined, {
65
+ weekday: "short",
66
+ month: "short",
67
+ day: "numeric",
68
+ });
69
+ }
70
+
71
+ export function ComeBackBetterSection({ isRunning, onRerun }: Props) {
72
+ const { capture } = usePostHog();
73
+ const [authStatus, setAuthStatus] = useState<AuthStatus>({ kind: "unknown" });
74
+ const [reminder, setReminder] = useState<Reminder | null>(null);
75
+ const [cadence, setCadence] = useState<Cadence>(DEFAULT_REMINDER_DAYS);
76
+ const [dialogOpen, setDialogOpen] = useState(false);
77
+ const [inviteDialogOpen, setInviteDialogOpen] = useState(false);
78
+ const [reminderBusy, setReminderBusy] = useState(false);
79
+ // Copy for the shared AuthDialog: {} keeps the reminder defaults,
80
+ // INVITE_AUTH_COPY shows the invite variant. Set by whichever CTA opens the
81
+ // dialog — content selection only, no effect on the auth flow.
82
+ const [authCopy, setAuthCopy] = useState<{ headline?: string; subhead?: string }>({});
83
+ const ctaShownRef = useRef(false);
84
+ const lastRefreshAtRef = useRef(0);
85
+
86
+ const refreshStatus = useCallback(async () => {
87
+ lastRefreshAtRef.current = Date.now();
88
+ // Preserve current UI state on transient failures (5xx, network blips).
89
+ // Downgrading to anon on every error would clear a valid reminder mid-
90
+ // session on a single failed poll, forcing an unnecessary auth prompt.
91
+ // Only fall through to anon on the very first probe (still "unknown")
92
+ // so the cadence buttons unlock even if the server is unreachable.
93
+ const fallbackToAnonOnError = () => {
94
+ setAuthStatus((prev) => (prev.kind === "unknown" ? { kind: "anon" } : prev));
95
+ };
96
+ try {
97
+ const res = await fetch("/api/auth/status", { cache: "no-store" });
98
+ if (!res.ok) {
99
+ fallbackToAnonOnError();
100
+ return;
101
+ }
102
+ const body = (await res.json()) as {
103
+ authenticated?: boolean;
104
+ user?: { id: string; email: string };
105
+ reminder?: Reminder | null;
106
+ };
107
+ if (body.authenticated && body.user) {
108
+ setAuthStatus({ kind: "authed", user: body.user });
109
+ setReminder(body.reminder ?? null);
110
+ } else {
111
+ setAuthStatus({ kind: "anon" });
112
+ setReminder(null);
113
+ }
114
+ } catch {
115
+ fallbackToAnonOnError();
116
+ }
117
+ }, []);
118
+
119
+ useEffect(() => {
120
+ void refreshStatus();
121
+ const REFRESH_MIN_INTERVAL_MS = 5_000;
122
+ const maybeRefresh = () => {
123
+ if (Date.now() - lastRefreshAtRef.current < REFRESH_MIN_INTERVAL_MS) return;
124
+ void refreshStatus();
125
+ };
126
+ const onFocus = () => maybeRefresh();
127
+ const onVisibility = () => {
128
+ if (document.visibilityState === "visible") maybeRefresh();
129
+ };
130
+ window.addEventListener("focus", onFocus);
131
+ document.addEventListener("visibilitychange", onVisibility);
132
+ return () => {
133
+ window.removeEventListener("focus", onFocus);
134
+ document.removeEventListener("visibilitychange", onVisibility);
135
+ };
136
+ }, [refreshStatus]);
137
+
138
+ useEffect(() => {
139
+ if (ctaShownRef.current) return;
140
+ if (authStatus.kind === "unknown") return;
141
+ ctaShownRef.current = true;
142
+ capture("audit_reminder_cta_shown", {
143
+ auth_state: authStatus.kind,
144
+ has_existing_reminder: reminder !== null,
145
+ source: "come_back_better_section",
146
+ });
147
+ }, [authStatus, capture, reminder]);
148
+
149
+ const persistReminder = useCallback(
150
+ async (inDays: number): Promise<Reminder | null> => {
151
+ const controller = new AbortController();
152
+ const timer = setTimeout(() => controller.abort(), 10_000);
153
+ try {
154
+ setReminderBusy(true);
155
+ const res = await fetch("/api/auth/reminder", {
156
+ method: "POST",
157
+ headers: { "content-type": "application/json" },
158
+ body: JSON.stringify({ in_days: inDays }),
159
+ signal: controller.signal,
160
+ });
161
+ if (!res.ok) {
162
+ if (res.status === 401) {
163
+ setAuthStatus({ kind: "anon" });
164
+ setReminder(null);
165
+ }
166
+ capture("audit_reminder_saved", {
167
+ status: `http_${res.status}`,
168
+ source: "come_back_better_section",
169
+ cadence_days: inDays,
170
+ });
171
+ return null;
172
+ }
173
+ const body = (await res.json()) as { reminder?: Reminder };
174
+ capture("audit_reminder_saved", {
175
+ status: body.reminder ? "success" : "empty",
176
+ source: "come_back_better_section",
177
+ cadence_days: inDays,
178
+ });
179
+ return body.reminder ?? null;
180
+ } catch (err) {
181
+ const kind = isAbortError(err) ? "timeout" : "error";
182
+ capture("audit_reminder_saved", {
183
+ status: kind,
184
+ source: "come_back_better_section",
185
+ cadence_days: inDays,
186
+ });
187
+ return null;
188
+ } finally {
189
+ clearTimeout(timer);
190
+ setReminderBusy(false);
191
+ }
192
+ },
193
+ [capture],
194
+ );
195
+
196
+ const handleCadenceClick = useCallback(
197
+ async (next: Cadence) => {
198
+ setCadence(next);
199
+ capture("audit_reminder_cta_clicked", {
200
+ auth_state: authStatus.kind,
201
+ has_existing_reminder: reminder !== null,
202
+ cadence_days: next,
203
+ source: "come_back_better_section",
204
+ });
205
+ if (authStatus.kind === "authed") {
206
+ const saved = await persistReminder(next);
207
+ if (saved) setReminder(saved);
208
+ return;
209
+ }
210
+ if (authStatus.kind === "anon") {
211
+ setAuthCopy({}); // reminder context → keep the dialog's default copy
212
+ setDialogOpen(true);
213
+ }
214
+ },
215
+ [authStatus, capture, persistReminder, reminder],
216
+ );
217
+
218
+ const handleAuthed = useCallback(
219
+ async (user: AuthedUser) => {
220
+ setAuthStatus({ kind: "authed", user });
221
+ capture("audit_auth_completed", {
222
+ source: "come_back_better_section",
223
+ });
224
+ const saved = await persistReminder(cadence);
225
+ if (saved) setReminder(saved);
226
+ },
227
+ [cadence, capture, persistReminder],
228
+ );
229
+
230
+ const handleInvite = useCallback(() => {
231
+ capture("audit_perks_invite_clicked", {
232
+ source: "come_back_better_section",
233
+ auth_state: authStatus.kind,
234
+ });
235
+ // Unauthed users go through the AuthDialog first so we have a sender
236
+ // identity to Cc on the invite email.
237
+ if (authStatus.kind !== "authed") {
238
+ setAuthCopy(INVITE_AUTH_COPY); // invite context → "Oops! Login required"
239
+ setDialogOpen(true);
240
+ return;
241
+ }
242
+ setInviteDialogOpen(true);
243
+ }, [authStatus.kind, capture]);
244
+
245
+ const handleRerunInline = useCallback(() => {
246
+ if (isRunning) return;
247
+ onRerun();
248
+ }, [isRunning, onRerun]);
249
+
250
+ const days = reminder ? daysUntil(reminder.next_audit_at) : 0;
251
+
252
+ return (
253
+ <section className="audit-sec" data-screen-label="05 Come back better">
254
+ <div className="audit-sec-head">
255
+ <span className="audit-sec-eyebrow">
256
+ <span className="ix">05</span>{"// come back better"}
257
+ </span>
258
+ </div>
259
+ <h2 className="audit-sec-title">build the habit</h2>
260
+
261
+ <div className="cbb-grid">
262
+ {/* Reminder card */}
263
+ <div className="cbb-card">
264
+ <div className="cbb-card-title">set a reminder</div>
265
+ <div className="cbb-card-sub">
266
+ {reminder
267
+ ? `next audit set for ${formatNextAudit(reminder.next_audit_at)} · in ${days} day${days === 1 ? "" : "s"}.`
268
+ : "we'll nudge you when your next audit is due. pick the cadence:"}
269
+ </div>
270
+ <div className="cadence-row">
271
+ {REMINDER_OPTIONS.map((d) => (
272
+ <button
273
+ key={d}
274
+ type="button"
275
+ className={`cadence-btn${cadence === d ? " on" : ""}`}
276
+ disabled={reminderBusy || authStatus.kind === "unknown"}
277
+ onClick={() => void handleCadenceClick(d)}
278
+ >
279
+ {d}d
280
+ </button>
281
+ ))}
282
+ </div>
283
+ <button
284
+ type="button"
285
+ className="cbb-link"
286
+ disabled={isRunning}
287
+ onClick={handleRerunInline}
288
+ >
289
+ {isRunning ? "scanning…" : "or re-audit now →"}
290
+ </button>
291
+ </div>
292
+
293
+ {/* Perks card */}
294
+ <div className="cbb-card">
295
+ <div className="cbb-card-title">unlock failproof perks</div>
296
+ <div className="cbb-card-sub">{PERKS_PERK}</div>
297
+ <button type="button" className="invite-btn" onClick={handleInvite}>
298
+ invite a friend
299
+ </button>
300
+ <div className="cbb-foot">
301
+ {"// invites are sent from failproof.ai, Cc'd to you, with a link to run their own audit."}
302
+ </div>
303
+ </div>
304
+ </div>
305
+
306
+ <InviteDialog
307
+ open={inviteDialogOpen}
308
+ source="come_back_better_section"
309
+ onClose={() => setInviteDialogOpen(false)}
310
+ onUnauthorized={() => {
311
+ // Session expired between probe and submit — flip back to anon
312
+ // and bounce through the AuthDialog so the user re-auths.
313
+ setAuthStatus({ kind: "anon" });
314
+ setReminder(null);
315
+ setAuthCopy(INVITE_AUTH_COPY); // still the invite context
316
+ setDialogOpen(true);
317
+ }}
318
+ />
319
+
320
+ <AuthDialog
321
+ open={dialogOpen}
322
+ source="return_section"
323
+ headline={authCopy.headline}
324
+ subhead={authCopy.subhead}
325
+ onClose={() => setDialogOpen(false)}
326
+ onAuthed={(u) => {
327
+ setDialogOpen(false);
328
+ void handleAuthed(u);
329
+ }}
330
+ />
331
+ </section>
332
+ );
333
+ }