failproofai 1.0.10-beta.1 → 1.0.11-beta.0

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 (298) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +6 -6
  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/build-manifest.json +3 -3
  6. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  7. package/.next/standalone/.next/server/app/_global-error/page.js +4 -4
  8. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  9. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.meta +8 -0
  12. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  13. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
  14. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  15. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  16. package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +3 -3
  17. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  18. package/.next/standalone/.next/server/app/_not-found/page.js +4 -4
  19. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  20. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  21. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  22. package/.next/standalone/.next/server/app/_not-found.meta +8 -0
  23. package/.next/standalone/.next/server/app/_not-found.rsc +14 -14
  24. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
  25. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
  26. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  27. package/.next/standalone/.next/server/app/api/audit/invite/route.js +4 -4
  28. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/audit/run/route.js +4 -4
  30. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/audit/status/route.js +1 -1
  32. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
  33. package/.next/standalone/.next/server/app/api/auth/login-request/route.js +2 -2
  34. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js +4 -4
  36. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
  37. package/.next/standalone/.next/server/app/api/auth/logout/route.js +3 -3
  38. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/api/auth/status/route.js +3 -3
  40. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  41. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js +1 -1
  42. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/audit/page/build-manifest.json +3 -3
  44. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
  45. package/.next/standalone/.next/server/app/audit/page.js +4 -4
  46. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  48. package/.next/standalone/.next/server/app/index.html +1 -1
  49. package/.next/standalone/.next/server/app/index.meta +8 -0
  50. package/.next/standalone/.next/server/app/index.rsc +14 -14
  51. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +13 -13
  52. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +14 -14
  53. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  54. package/.next/standalone/.next/server/app/page/build-manifest.json +3 -3
  55. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  56. package/.next/standalone/.next/server/app/page.js +4 -4
  57. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  58. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  59. package/.next/standalone/.next/server/app/policies/page/build-manifest.json +3 -3
  60. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
  61. package/.next/standalone/.next/server/app/policies/page.js +8 -8
  62. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  63. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  64. package/.next/standalone/.next/server/app/project/[name]/page/build-manifest.json +3 -3
  65. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  66. package/.next/standalone/.next/server/app/project/[name]/page.js +5 -5
  67. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  68. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  69. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/build-manifest.json +3 -3
  70. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  71. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  72. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +5 -5
  73. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  74. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  75. package/.next/standalone/.next/server/app/projects/page/build-manifest.json +3 -3
  76. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  77. package/.next/standalone/.next/server/app/projects/page.js +5 -5
  78. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  79. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  80. package/.next/standalone/.next/server/app/settings/page/build-manifest.json +3 -3
  81. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +8 -8
  82. package/.next/standalone/.next/server/app/settings/page.js +9 -9
  83. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  84. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  85. package/.next/standalone/.next/server/chunks/{[externals]__0qxhecv._.js → [externals]__0d7i9ea._.js} +2 -2
  86. package/.next/standalone/.next/server/chunks/{[externals]__0sg9-3p._.js → [externals]__0hjaw70._.js} +1 -1
  87. package/.next/standalone/.next/server/chunks/[externals]__1_9ze9b._.js +3 -0
  88. package/.next/standalone/.next/server/chunks/[externals]__1oenfmn._.js +3 -0
  89. package/.next/standalone/.next/server/chunks/[root-of-the-server]__08dchfu._.js +1 -1
  90. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0ga9hs7._.js +3 -0
  91. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0l3yhx4._.js +2 -2
  92. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0moxohc._.js +22 -0
  93. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
  94. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0z2ll-a._.js +3 -0
  95. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1adacul._.js +11 -11
  96. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1autwno._.js +3 -0
  97. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1v25n-6._.js +3 -0
  98. package/.next/standalone/.next/server/chunks/_09dz7xv._.js +1 -1
  99. package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
  100. package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
  101. package/.next/standalone/.next/server/chunks/_1ek68ln._.js +2 -2
  102. package/.next/standalone/.next/server/chunks/_1fz8m31._.js +1 -1
  103. package/.next/standalone/.next/server/chunks/_1jrv3hg._.js +3 -0
  104. package/.next/standalone/.next/server/chunks/_1nx8fim._.js +3 -0
  105. package/.next/standalone/.next/server/chunks/_1ogwigf._.js +1 -1
  106. package/.next/standalone/.next/server/chunks/{_1q5i8mb._.js → _1q27azx._.js} +2 -2
  107. package/.next/standalone/.next/server/chunks/lib_telemetry_ts_0dctyyw._.js +1 -1
  108. package/.next/standalone/.next/server/chunks/{node_modules_posthog-node_dist_entrypoints_index_node_mjs_0el6rg8._.js → node_modules_posthog-node_dist_entrypoints_index_node_mjs_0ol5pa3._.js} +2 -2
  109. package/.next/standalone/.next/server/chunks/{node_modules_posthog-node_dist_entrypoints_index_node_mjs_04op_ou._.js → node_modules_posthog-node_dist_entrypoints_index_node_mjs_1rqmk27._.js} +2 -2
  110. package/.next/standalone/.next/server/chunks/{node_modules_posthog-node_dist_entrypoints_index_node_mjs_0dr20uz._.js → node_modules_posthog-node_dist_entrypoints_index_node_mjs_1w7tiq4._.js} +2 -2
  111. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
  112. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__04usis8._.js +2 -2
  113. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1-bm5zf._.js → [root-of-the-server]__0502lat._.js} +1 -1
  114. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0_gn5iz._.js +4 -0
  115. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0f765xr._.js +4 -0
  116. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__01bmjsj._.js → [root-of-the-server]__0h38gzz._.js} +1 -1
  117. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__056wjo4._.js → [root-of-the-server]__0hoaz1g._.js} +3 -3
  118. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1ouobn4._.js → [root-of-the-server]__0mxmwtx._.js} +1 -1
  119. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__19evfi8._.js → [root-of-the-server]__0uescqv._.js} +1 -1
  120. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1484zv2._.js +3 -0
  121. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1mf3zp6._.js → [root-of-the-server]__19dutr7._.js} +4 -4
  122. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0a2-9ht._.js → [root-of-the-server]__1_qv8oh._.js} +2 -2
  123. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1u6sn69._.js → [root-of-the-server]__1ab4ifb._.js} +1 -1
  124. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1q4p5b8._.js → [root-of-the-server]__1fbrk56._.js} +3 -3
  125. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1pprgri._.js +2 -2
  126. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0n0xg95._.js → [root-of-the-server]__1um4yxn._.js} +3 -3
  127. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0rwtwpm._.js → [root-of-the-server]__1wb4yt2._.js} +3 -3
  128. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__11mayhe._.js → [root-of-the-server]__1y3n3cn._.js} +3 -3
  129. package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
  130. package/.next/standalone/.next/server/chunks/ssr/_0bqoto4._.js +1 -1
  131. package/.next/standalone/.next/server/chunks/ssr/{_0krq5f0._.js → _0lnpwk8._.js} +3 -3
  132. package/.next/standalone/.next/server/chunks/ssr/{_1n-mym7._.js → _15y8myg._.js} +1 -1
  133. package/.next/standalone/.next/server/chunks/ssr/_1gb0ifp._.js +2 -2
  134. package/.next/standalone/.next/server/chunks/ssr/{_042cgl1._.js → _1o95rf0._.js} +2 -2
  135. package/.next/standalone/.next/server/chunks/ssr/{_1zopuov._.js → _1thr5rf._.js} +2 -2
  136. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +12 -14
  137. package/.next/standalone/.next/server/chunks/ssr/app_actions_get-scheduled-audit_ts_0ei9sni._.js +1 -1
  138. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
  139. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
  140. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
  141. package/.next/standalone/.next/server/chunks/ssr/app_settings_02tf1h4._.js +1 -1
  142. package/.next/standalone/.next/server/chunks/ssr/node_modules_1hl81y4._.js +1 -1
  143. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_0nkkbfv._.js +6 -0
  144. package/.next/standalone/.next/server/chunks/ssr/src_hooks_fp-config_ts_04t589g._.js +1 -1
  145. package/.next/standalone/.next/server/chunks/ssr/src_hooks_fp-home_ts_0je3xkv._.js +1 -1
  146. package/.next/standalone/.next/server/middleware-build-manifest.js +6 -6
  147. package/.next/standalone/.next/server/middleware.js +1 -1
  148. package/.next/standalone/.next/server/pages/404.html +1 -1
  149. package/.next/standalone/.next/server/pages/500.html +1 -1
  150. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  151. package/.next/standalone/.next/server/server-reference-manifest.json +23 -23
  152. package/.next/standalone/.next/static/chunks/{3q8vesnwk_r0i.js → 0pra9i676pym1.js} +1 -1
  153. package/.next/standalone/.next/static/chunks/{1-k37ijadiv9h.js → 1-lpi0m-hc1kb.js} +1 -1
  154. package/.next/standalone/.next/static/chunks/{3z7mx6me_j7d3.js → 17yvyyblr_eb5.js} +1 -1
  155. package/.next/standalone/.next/static/chunks/{2cvvec76j9bwq.js → 1mylcr99gccyz.js} +1 -1
  156. package/.next/standalone/.next/static/chunks/{0s4cko_weh6pi.js → 1wozchtn2etvh.js} +1 -1
  157. package/.next/standalone/.next/static/chunks/{3vk6jdkxvb7yk.js → 23thtelz1a-ur.js} +2 -2
  158. package/.next/standalone/.next/static/chunks/2bc17tohgs4bs.js +1 -0
  159. package/.next/standalone/.next/static/chunks/{3ztf2h_fv6_t9.js → 2hg_bp8z_vm2g.js} +1 -1
  160. package/.next/standalone/.next/static/chunks/{18reoqya39rov.js → 2xq-ejo8kti18.js} +1 -1
  161. package/.next/standalone/.next/static/chunks/3-_pth_c9n938.js +1 -0
  162. package/.next/standalone/.next/static/chunks/{3i8rg2fv9nd6e.js → 3n46e45atic-m.js} +1 -1
  163. package/.next/standalone/.next/static/chunks/3q7sndqftqhw9.js +1 -0
  164. package/.next/standalone/.next/static/chunks/{0542cuk_va8g1.js → 3sg07wnn969xq.js} +1 -1
  165. package/.next/standalone/.next/static/chunks/{turbopack-11dn2pegmg9_9.js → turbopack-1opxka4dtjbc5.js} +1 -1
  166. package/.next/standalone/app/actions/install-hooks-web.ts +10 -2
  167. package/.next/standalone/hermes-plugin/README.md +10 -5
  168. package/.next/standalone/hermes-plugin/__init__.py +77 -26
  169. package/.next/standalone/hermes-plugin/plugin.yaml +1 -1
  170. package/.next/standalone/node_modules/@next/env/package.json +1 -1
  171. package/.next/standalone/node_modules/next/dist/build/swc/index.js +1 -1
  172. package/.next/standalone/node_modules/next/dist/compiled/hash.js/sha256/256.js +1 -0
  173. package/.next/standalone/node_modules/next/dist/compiled/hash.js/sha256/package.json +1 -0
  174. package/.next/standalone/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +17 -17
  175. package/.next/standalone/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +18 -18
  176. package/.next/standalone/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +3 -3
  177. package/.next/standalone/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +13 -13
  178. package/.next/standalone/node_modules/next/dist/lib/patch-incorrect-lockfile.js +3 -3
  179. package/.next/standalone/node_modules/next/dist/server/base-server.js +1 -2
  180. package/.next/standalone/node_modules/next/dist/server/config.js +1 -1
  181. package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +2 -2
  182. package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1 -1
  183. package/.next/standalone/node_modules/next/dist/server/image-optimizer.js +265 -53
  184. package/.next/standalone/node_modules/next/dist/server/lib/app-info-log.js +1 -1
  185. package/.next/standalone/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js +177 -19
  186. package/.next/standalone/node_modules/next/dist/server/lib/incremental-cache/index.js +36 -17
  187. package/.next/standalone/node_modules/next/dist/server/lib/incremental-cache/shared-cache-controls.external.js +14 -6
  188. package/.next/standalone/node_modules/next/dist/server/lib/match-next-data-pathname.js +3 -1
  189. package/.next/standalone/node_modules/next/dist/server/lib/node-fs-methods.js +14 -0
  190. package/.next/standalone/node_modules/next/dist/server/lib/route-cache-key.js +77 -0
  191. package/.next/standalone/node_modules/next/dist/server/lib/router-utils/block-cross-site-dev.js +9 -11
  192. package/.next/standalone/node_modules/next/dist/server/lib/start-server.js +1 -1
  193. package/.next/standalone/node_modules/next/dist/server/mcp/get-mcp-middleware.js +4 -2
  194. package/.next/standalone/node_modules/next/dist/server/next-server.js +7 -3
  195. package/.next/standalone/node_modules/next/dist/server/response-cache/index.js +32 -16
  196. package/.next/standalone/node_modules/next/dist/server/route-matcher-providers/app-page-route-matcher-provider.js +2 -2
  197. package/.next/standalone/node_modules/next/dist/server/route-modules/pages/pages-handler.js +6 -1
  198. package/.next/standalone/node_modules/next/dist/server/route-modules/route-module.js +9 -2
  199. package/.next/standalone/node_modules/next/dist/server/use-cache/use-cache-wrapper.js +30 -29
  200. package/.next/standalone/node_modules/next/dist/shared/lib/router/utils/app-paths.js +18 -1
  201. package/.next/standalone/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
  202. package/.next/standalone/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
  203. package/.next/standalone/node_modules/next/dist/telemetry/events/version.js +2 -2
  204. package/.next/standalone/node_modules/next/package.json +10 -10
  205. package/.next/standalone/package.json +14 -11
  206. package/.next/standalone/sdk/python/README.md +41 -0
  207. package/.next/standalone/sdk/python/docs/README.md +1 -0
  208. package/.next/standalone/sdk/python/docs/otel/README.md +36 -0
  209. package/.next/standalone/sdk/python/docs/otel/examples/agent_trace.py +30 -0
  210. package/.next/standalone/sdk/python/docs/otel/examples/quickstart.py +22 -0
  211. package/.next/standalone/sdk/python/failproofai_sdk/__init__.py +8 -0
  212. package/.next/standalone/sdk/python/failproofai_sdk/integrations/__init__.py +3 -0
  213. package/.next/standalone/sdk/python/failproofai_sdk/integrations/otel.py +189 -0
  214. package/.next/standalone/sdk/python/pyproject.toml +2 -1
  215. package/.next/standalone/sdk/python/tests/test_docs.py +16 -3
  216. package/.next/standalone/sdk/python/tests/test_integrations.py +1 -1
  217. package/.next/standalone/sdk/python/tests/test_otel.py +147 -0
  218. package/.next/standalone/sdk/python/tests/test_zero_dependencies.py +4 -1
  219. package/.next/standalone/sdk/python/uv.lock +258 -147
  220. package/.next/standalone/sdk/typescript/README.md +43 -0
  221. package/.next/standalone/sdk/typescript/integration/ai.test.ts +9 -2
  222. package/.next/standalone/sdk/typescript/package-lock.json +57 -5
  223. package/.next/standalone/sdk/typescript/package.json +2 -0
  224. package/.next/standalone/sdk/typescript/src/edge/index.ts +9 -0
  225. package/.next/standalone/sdk/typescript/src/index.ts +2 -0
  226. package/.next/standalone/sdk/typescript/src/integrations/index.ts +4 -1
  227. package/.next/standalone/sdk/typescript/src/integrations/otel.ts +204 -0
  228. package/.next/standalone/sdk/typescript/test/integrations.test.ts +1 -1
  229. package/.next/standalone/sdk/typescript/test/otel.test.ts +125 -0
  230. package/.next/standalone/server.js +1 -1
  231. package/bin/failproofai.mjs +653 -1077
  232. package/dist/cli.mjs +8781 -4050
  233. package/dist/worker.mjs +170 -62
  234. package/hermes-plugin/README.md +10 -5
  235. package/hermes-plugin/__init__.py +77 -26
  236. package/hermes-plugin/plugin.yaml +1 -1
  237. package/package.json +14 -11
  238. package/scripts/launch-facts.ts +157 -0
  239. package/scripts/launch-ready.ts +228 -0
  240. package/scripts/launch-screen.ts +202 -0
  241. package/scripts/launch.ts +106 -49
  242. package/scripts/skew-log-filter.ts +38 -0
  243. package/src/audit/cli-login.ts +39 -59
  244. package/src/audit/cli.ts +308 -228
  245. package/src/audit/index.ts +45 -2
  246. package/src/audit/schedule-cli.ts +83 -120
  247. package/src/audit/types.ts +31 -0
  248. package/src/hooks/agent-selection.ts +155 -0
  249. package/src/hooks/backfill-cli.ts +151 -137
  250. package/src/hooks/backfill-request.ts +149 -0
  251. package/src/hooks/cloud-connection.ts +1 -1
  252. package/src/hooks/cloud-enrollment-cli.ts +78 -28
  253. package/src/hooks/cloud-introspect.ts +3 -0
  254. package/src/hooks/collector-config.ts +10 -1
  255. package/src/hooks/config-status.ts +717 -0
  256. package/src/hooks/configure-wizard.ts +967 -988
  257. package/src/hooks/daemon-service.ts +16 -6
  258. package/src/hooks/did-you-mean.ts +185 -0
  259. package/src/hooks/flush-cli.ts +33 -7
  260. package/src/hooks/fp-config.ts +96 -0
  261. package/src/hooks/fp-home.ts +11 -0
  262. package/src/hooks/fp-reset.ts +102 -95
  263. package/src/hooks/handler.ts +4 -0
  264. package/src/hooks/harness-cli.ts +87 -138
  265. package/src/hooks/install-prompt.ts +38 -477
  266. package/src/hooks/integrations.ts +1 -1
  267. package/src/hooks/jev-cli.ts +183 -196
  268. package/src/hooks/manager.ts +554 -358
  269. package/src/hooks/onboarding-attempt.ts +11 -9
  270. package/src/hooks/otel-cli.ts +350 -0
  271. package/src/hooks/otel-output.ts +24 -0
  272. package/src/hooks/otel-writers.ts +215 -0
  273. package/src/hooks/pack-cli.ts +219 -204
  274. package/src/hooks/report-body.ts +50 -0
  275. package/src/hooks/safe-config-write.ts +4 -2
  276. package/src/hooks/session-pause-cli.ts +93 -73
  277. package/src/hooks/tui.ts +849 -389
  278. package/src/hooks/uninstall-cli.ts +136 -149
  279. package/src/hooks/untraced-note.ts +52 -0
  280. package/.next/standalone/.next/server/chunks/[externals]__19_pzeq._.js +0 -3
  281. package/.next/standalone/.next/server/chunks/[externals]__20kzpkf._.js +0 -3
  282. package/.next/standalone/.next/server/chunks/[root-of-the-server]__01eqny5._.js +0 -3
  283. package/.next/standalone/.next/server/chunks/[root-of-the-server]__05ja_05._.js +0 -3
  284. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0igxt32._.js +0 -3
  285. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zyc_nm._.js +0 -3
  286. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1ttrwnd._.js +0 -22
  287. package/.next/standalone/.next/server/chunks/_0bs-v8p._.js +0 -3
  288. package/.next/standalone/.next/server/chunks/_185gyk9._.js +0 -3
  289. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0yrsbd_._.js +0 -3
  290. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__15578wp._.js +0 -4
  291. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1m_svbe._.js +0 -4
  292. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_1n3w9lb._.js +0 -6
  293. package/.next/standalone/.next/static/chunks/0yclxmfppc_8e.js +0 -1
  294. package/.next/standalone/.next/static/chunks/2o9-3ff26v4yd.js +0 -1
  295. package/.next/standalone/.next/static/chunks/3tj1zi4xv-bll.js +0 -1
  296. /package/.next/standalone/.next/static/{OJTzlkhxVSWnwhlF2Q7m3 → xtcpqBNBdjQVerPMkI2HI}/_buildManifest.js +0 -0
  297. /package/.next/standalone/.next/static/{OJTzlkhxVSWnwhlF2Q7m3 → xtcpqBNBdjQVerPMkI2HI}/_clientMiddlewareManifest.js +0 -0
  298. /package/.next/standalone/.next/static/{OJTzlkhxVSWnwhlF2Q7m3 → xtcpqBNBdjQVerPMkI2HI}/_ssgManifest.js +0 -0
@@ -69,12 +69,18 @@ _OBSERVE_TIMEOUT_MS = 2_000
69
69
  # A reminder is attached once per (session, turn) for the same policy and reason.
70
70
  _DELIVERED_LIMIT = 1024
71
71
 
72
- # Hermes persists a result over its smallest threshold (8,000 chars) and shows
73
- # the model only a 1,500-char preview. When the full reminder would take the
74
- # result past this size it is shortened instead, so the reminder never pushes a
75
- # result over that threshold and never fills the preview of one already past it.
72
+ # Hermes saves a result to a file once it passes 15% of the model's context
73
+ # window (at 4 chars per token, clamped to 8,000-100,000 chars; read_file is
74
+ # never saved) and shows the model a 1,500-char preview. When the full reminder
75
+ # would take a result past 7,500 chars it is compacted to a bounded size (each
76
+ # policy name, each reason and the number of reminders are capped), so it stays
77
+ # inside that preview. It is always attached: on a model whose threshold is the
78
+ # 8,000 floor, a result just under it may be saved because of the reminder, and
79
+ # the reminder is then the head of the preview the model reads.
76
80
  _FULL_REMINDER_MAX_CHARS = 7_500
77
81
  _COMPACT_REASON_CHARS = 160
82
+ _COMPACT_POLICY_CHARS = 80
83
+ _COMPACT_MAX_REMINDERS = 3
78
84
 
79
85
 
80
86
  def _bounded_int(value: object, default: int, minimum: int, maximum: int) -> int:
@@ -283,9 +289,13 @@ class _ReminderHandoff:
283
289
  self._entries[key] = (now, reminders)
284
290
 
285
291
  def take(self, key: tuple[str, ...]) -> list[_Reminder]:
292
+ now = time.monotonic()
286
293
  with self._lock:
287
294
  entry = self._entries.pop(key, None)
288
- return entry[1] if entry is not None else []
295
+ # An entry past its TTL belonged to a call that never reached its frame.
296
+ if entry is None or now - entry[0] > _HANDOFF_TTL_SECONDS:
297
+ return []
298
+ return entry[1]
289
299
 
290
300
  def pending(self) -> bool:
291
301
  # Lets the middleware skip hashing every call's arguments.
@@ -305,26 +315,33 @@ def _call_key(
305
315
  return (_string(session_id), _string(task_id), _string(tool_call_id), _string(tool_name), digest)
306
316
 
307
317
 
318
+ def _clip(text: str, limit: int) -> str:
319
+ return text if len(text) <= limit else text[:limit].rstrip() + "…"
320
+
321
+
308
322
  def _reason(reminder: _Reminder, compact: bool) -> str:
309
- if compact and len(reminder.reason) > _COMPACT_REASON_CHARS:
310
- return reminder.reason[:_COMPACT_REASON_CHARS].rstrip() + "…"
311
- return reminder.reason
323
+ return _clip(reminder.reason, _COMPACT_REASON_CHARS) if compact else reminder.reason
324
+
325
+
326
+ def _policies(reminder: _Reminder, compact: bool) -> str:
327
+ # Custom policy names have no length limit, so the compact form caps them too.
328
+ return _clip(reminder.policies, _COMPACT_POLICY_CHARS) if compact else reminder.policies
329
+
330
+
331
+ def _reminder_lines(reminders: tuple[_Reminder, ...], compact: bool, line: Callable[[str, str], str]) -> str:
332
+ shown = reminders[:_COMPACT_MAX_REMINDERS] if compact else reminders
333
+ lines = [line(_policies(r, compact), _reason(r, compact)) for r in shown]
334
+ if len(shown) < len(reminders):
335
+ lines.append(f"(+{len(reminders) - len(shown)} more FailproofAI policy reminders)")
336
+ return "\n".join(lines) + " — the tool call ran; apply this when you use its result."
312
337
 
313
338
 
314
339
  def _reminder_text(reminders: tuple[_Reminder, ...], compact: bool = False) -> str:
315
- body = "\n".join(
316
- f"FailproofAI policy reminder ({reminder.policies}): {_reason(reminder, compact)}"
317
- for reminder in reminders
318
- )
319
- return f"{body} — the tool call ran; apply this when you use its result."
340
+ return _reminder_lines(reminders, compact, lambda p, r: f"FailproofAI policy reminder ({p}): {r}")
320
341
 
321
342
 
322
343
  def _reminder_prefix(reminders: tuple[_Reminder, ...], compact: bool = False) -> str:
323
- body = "\n".join(
324
- f"[FailproofAI policy reminder ({reminder.policies})] {_reason(reminder, compact)}"
325
- for reminder in reminders
326
- )
327
- return f"{body} — the tool call ran; apply this when you use its result."
344
+ return _reminder_lines(reminders, compact, lambda p, r: f"[FailproofAI policy reminder ({p})] {r}")
328
345
 
329
346
 
330
347
  def _result_chars(result: Any) -> int:
@@ -358,15 +375,36 @@ class _TurnDeliveries:
358
375
  return tuple(r for r in reminders if self._key(session_id, turn_id, r) not in self._seen)
359
376
 
360
377
  def mark(self, session_id: str, turn_id: str, reminders: tuple[_Reminder, ...]) -> None:
378
+ if not session_id or not turn_id:
379
+ return
380
+ with self._lock:
381
+ self._mark_locked(session_id, turn_id, reminders)
382
+
383
+ def _mark_locked(self, session_id: str, turn_id: str, reminders: tuple[_Reminder, ...]) -> None:
384
+ for reminder in reminders:
385
+ key = self._key(session_id, turn_id, reminder)
386
+ self._seen[key] = None
387
+ self._seen.move_to_end(key)
388
+ while len(self._seen) > self._limit:
389
+ self._seen.popitem(last=False)
390
+
391
+ def claim(self, session_id: str, turn_id: str, reminders: tuple[_Reminder, ...]) -> tuple[_Reminder, ...]:
392
+ """The reminders not yet delivered in this turn, marked delivered in the
393
+ same step, so two calls running at once cannot both take one."""
394
+ if not session_id or not turn_id:
395
+ return reminders
396
+ with self._lock:
397
+ fresh = tuple(r for r in reminders if self._key(session_id, turn_id, r) not in self._seen)
398
+ self._mark_locked(session_id, turn_id, fresh)
399
+ return fresh
400
+
401
+ def release(self, session_id: str, turn_id: str, reminders: tuple[_Reminder, ...]) -> None:
402
+ """Undo a claim whose reminders found no carrier, so a later call delivers them."""
361
403
  if not session_id or not turn_id:
362
404
  return
363
405
  with self._lock:
364
406
  for reminder in reminders:
365
- key = self._key(session_id, turn_id, reminder)
366
- self._seen[key] = None
367
- self._seen.move_to_end(key)
368
- while len(self._seen) > self._limit:
369
- self._seen.popitem(last=False)
407
+ self._seen.pop(self._key(session_id, turn_id, reminder), None)
370
408
 
371
409
 
372
410
  def _unexecuted(result: Any) -> bool:
@@ -657,6 +695,11 @@ class FailproofAIPlugin:
657
695
  except Exception as exc:
658
696
  return self._fallback(exc)
659
697
 
698
+ if verdict.decision in ("allow", "deny"):
699
+ # An identical earlier call that never reached its frame (another
700
+ # plugin blocked it) left a reminder under this call's key; this
701
+ # call's own verdict replaces it.
702
+ self._drop_handoff(session_id, task_id, tool_call_id, tool_name, payload["tool_input"])
660
703
  if verdict.decision == "allow":
661
704
  return None
662
705
  if verdict.decision == "deny":
@@ -711,6 +754,14 @@ class FailproofAIPlugin:
711
754
  ),
712
755
  }
713
756
 
757
+ def _drop_handoff(self, session_id: str, task_id: str, tool_call_id: str, tool_name: str,
758
+ tool_input: Mapping[str, Any]) -> None:
759
+ try:
760
+ if self._handoff.pending():
761
+ self._handoff.take(_call_key(session_id, task_id, tool_call_id, tool_name, tool_input))
762
+ except Exception as exc:
763
+ logger.warning("FailproofAI could not clear a stale reminder handoff: %s", exc)
764
+
714
765
  def _innermost_frame(self) -> _ReminderFrame | None:
715
766
  frames = self._frames.get()
716
767
  if frames and frames[-1].open:
@@ -821,12 +872,12 @@ class FailproofAIPlugin:
821
872
  # untouched, so nothing it prints, writes or sends can carry it.
822
873
  return result
823
874
  session, turn = _string(session_id), _string(turn_id)
824
- fresh = self._delivered.unseen(session, turn, reminders)
875
+ fresh = self._delivered.claim(session, turn, reminders)
825
876
  if not fresh:
826
877
  return result
827
878
  annotated = _attach_reminders(result, fresh)
828
- if annotated is not result:
829
- self._delivered.mark(session, turn, fresh)
879
+ if annotated is result:
880
+ self._delivered.release(session, turn, fresh)
830
881
  return annotated
831
882
 
832
883
  def _observe(self, event: str, payload: Mapping[str, Any]) -> None:
@@ -1,5 +1,5 @@
1
1
  name: failproofai
2
- version: 1.0.10-beta.1
2
+ version: 1.0.11-beta.0
3
3
  description: Real-time FailproofAI policy enforcement for Hermes
4
4
  manifest_version: 2
5
5
  api_version: 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "failproofai",
3
- "version": "1.0.10-beta.1",
3
+ "version": "1.0.11-beta.0",
4
4
  "description": "Observability and enforcement for AI agent harnesses. 40 built-in policies hooked into 12 of them — Claude Code, Codex, Cursor, Hermes, OpenClaw and more — blocking the tool call before it runs. Local dashboard included, no account needed.",
5
5
  "bin": {
6
6
  "failproofai": "./dist/cli.mjs",
@@ -97,7 +97,7 @@
97
97
  "eslint-config-next": "^16.3.2",
98
98
  "jsdom": "^30.0.1",
99
99
  "lucide-react": "^1.33.0",
100
- "next": "^16.3.2",
100
+ "next": "^16.3.8",
101
101
  "react": "^19.2.4",
102
102
  "react-dom": "^19.2.4",
103
103
  "tailwind-merge": "^3.4.0",
@@ -107,7 +107,9 @@
107
107
  },
108
108
  "dependencies": {
109
109
  "html-to-image": "^1.11.13",
110
+ "jsonc-parser": "^3.3.1",
110
111
  "posthog-node": "^5.50.0",
112
+ "smol-toml": "^1.9.1",
111
113
  "sql.js": "^1.14.1",
112
114
  "yaml": "^2.9.0"
113
115
  },
@@ -118,19 +120,20 @@
118
120
  "vite": "8.0.16",
119
121
  "undici": "7.29.1",
120
122
  "brace-expansion": "5.0.12",
121
- "sharp": "0.35.4",
123
+ "sharp": "0.35.5",
124
+ "source-map-js": "1.2.2",
122
125
  "browserslist": "4.28.8"
123
126
  },
124
127
  "optionalDependencies": {
125
- "@failproofai/failproofaid-linux-x64": "1.0.10-beta.1",
126
- "@failproofai/failproofaid-linux-arm64": "1.0.10-beta.1",
127
- "@failproofai/failproofaid-darwin-x64": "1.0.10-beta.1",
128
- "@failproofai/failproofaid-darwin-arm64": "1.0.10-beta.1"
128
+ "@failproofai/failproofaid-linux-x64": "1.0.11-beta.0",
129
+ "@failproofai/failproofaid-linux-arm64": "1.0.11-beta.0",
130
+ "@failproofai/failproofaid-darwin-x64": "1.0.11-beta.0",
131
+ "@failproofai/failproofaid-darwin-arm64": "1.0.11-beta.0"
129
132
  },
130
133
  "failproofaidBinaries": {
131
- "linux-x64": "868a4978a66e4407b86dac8d6c8af4ad0b2b355da56983fa5530f5d8b5024098",
132
- "linux-arm64": "8a4603784e43552ed8cf5ed7a1552721c7216be4fb106ed6851daabd18e19ebe",
133
- "darwin-x64": "b6a59948ad12c06cedc90ebca95492a357430a2a150b76ceaf98930f8b1279c2",
134
- "darwin-arm64": "8c14361f7274973bb2cf99135ddb4a5a9cdc8b453a33e653156ba6b68354c417"
134
+ "linux-x64": "40b05c741f4c3c63bbf23b21cc4e200a396c07d568656a10d67a84b12fee42b8",
135
+ "linux-arm64": "afe688afba9e7f225d6d521c01b7d0038f1374125ede22f669ed45847a12e9b0",
136
+ "darwin-x64": "d8398fafe3a58abce754437f92111918d0229f966cd987be923d5dafbd5d3f84",
137
+ "darwin-arm64": "80108cfd087ecae5e1f2c2ba9bab77e160daceb169a0c44b5fe8b6ca519fc8dc"
135
138
  }
136
139
  }
@@ -0,0 +1,157 @@
1
+ /**
2
+ * What the launch screen states about this machine, read from disk.
3
+ *
4
+ * Files only: no daemon probe, no `systemctl`, no `which` (`detectInstalled()`
5
+ * spawns one per agent), and no policy file imported. This runs on every bare
6
+ * `failproofai`, while someone waits for a URL. Each fact is read on its own
7
+ * and degrades on its own, so an unreadable file costs one row its detail and
8
+ * never the screen.
9
+ */
10
+ // Aliased for the same reason as the long names below: the CLI is one
11
+ // scope-hoisted bundle, where another plain `resolve` import renumbers every
12
+ // later module's `resolveN` binding.
13
+ import { resolve as resolveLaunchPath } from "node:path";
14
+ import { INTEGRATION_TYPES } from "../src/hooks/types";
15
+ import { getIntegration } from "../src/hooks/integrations";
16
+ import { integrationsInstalledAt, notEnforcingReason } from "../src/hooks/manager";
17
+ import { readConfig, readCredentials, type FpConfig } from "../src/hooks/fp-config";
18
+ import { readCloudCredentials } from "../src/hooks/cloud-enrollment";
19
+ import { readIngestCredential } from "../src/hooks/collector-config";
20
+ import { cloudBaseFor } from "../src/hooks/cloud-connection";
21
+ import { deliveryHealth } from "../src/hooks/delivery-health";
22
+ import { hasInstalledRegexPacks, readInstalledPacks } from "../src/hooks/pack-manifest";
23
+ import { readActiveCloudManagedPolicies } from "../src/hooks/cloud-managed-policies";
24
+ import { configuredCustomPolicyPaths, findProjectConfigDir, readMergedHooksConfig } from "../src/hooks/hooks-config";
25
+ import { discoverPolicyFiles } from "../src/hooks/custom-hooks-loader";
26
+ import { customPoliciesDir } from "../src/hooks/fp-home";
27
+ import {
28
+ describeCloudConnection,
29
+ describePoliciesOn,
30
+ describeTracedAgents,
31
+ type LaunchCloudSummary,
32
+ type LaunchPoliciesSummary,
33
+ } from "./launch-screen";
34
+
35
+ export interface LaunchMachineFacts {
36
+ policies: string;
37
+ agents: string;
38
+ cloud: string;
39
+ notEnforcing: boolean;
40
+ }
41
+
42
+ export function gatherLaunchFacts(cwd: string): LaunchMachineFacts {
43
+ const row = (read: () => string): string => {
44
+ try {
45
+ return read();
46
+ } catch {
47
+ return "could not be read";
48
+ }
49
+ };
50
+ let notEnforcing = false;
51
+ try {
52
+ notEnforcing = notEnforcingReason(cwd) !== null;
53
+ } catch {
54
+ // Unknown is not a warning: `failproofai policies` is the full answer.
55
+ }
56
+ return {
57
+ policies: row(() => describePoliciesOn(readLaunchPolicies(cwd))),
58
+ agents: row(() => describeTracedAgents(readTracedAgentNames(cwd))),
59
+ cloud: row(() => describeCloudConnection(readLaunchCloud())),
60
+ notEnforcing,
61
+ };
62
+ }
63
+
64
+ /**
65
+ * Policies switched on, from the same inputs `notEnforcingReason` reads, so the
66
+ * row and the warning under it cannot disagree: installed packs (minus the
67
+ * per-version switches the dashboard used to write), the cloud deployment, the
68
+ * legacy built-ins on a machine still on the pre-pack shim, and whether custom
69
+ * policy files exist. Their contents are never imported to count them.
70
+ */
71
+ export function readLaunchPolicies(cwd: string): LaunchPoliciesSummary {
72
+ const config = readMergedHooksConfig(cwd);
73
+ const disabled = new Set(config.disabledCustomPolicies ?? []);
74
+ const sources: LaunchPoliciesSummary["sources"] = [];
75
+ try {
76
+ for (const pack of readInstalledPacks().packs) {
77
+ const taken = pack.enabled ?? pack.policies.map((policy) => policy.name);
78
+ const on = taken.filter((name) => !disabled.has(`pack:${pack.id}@${pack.version}:${name}`)).length;
79
+ if (on > 0) sources.push({ label: `${pack.id}@${pack.version}`, count: on, pack: true });
80
+ }
81
+ } catch {
82
+ // An unreadable manifest is reported by `failproofai policies`.
83
+ }
84
+ try {
85
+ const managed = readActiveCloudManagedPolicies();
86
+ if (managed.length > 0) sources.push({ label: "FailproofAI Cloud", count: managed.length, pack: false });
87
+ } catch {
88
+ // No deployment, or an unreadable one: nothing is on from there.
89
+ }
90
+ if (config.enabledPolicies.length > 0 && !hasInstalledRegexPacks()) {
91
+ sources.push({ label: "built-in policies", count: config.enabledPolicies.length, pack: false });
92
+ }
93
+ const projectDir = resolveLaunchPath(findProjectConfigDir(cwd), ".failproofai", "policies");
94
+ const customFiles =
95
+ configuredCustomPolicyPaths(config).length > 0 ||
96
+ discoverPolicyFiles(projectDir).length > 0 ||
97
+ discoverPolicyFiles(customPoliciesDir()).length > 0;
98
+ return { sources, customFiles };
99
+ }
100
+
101
+ /**
102
+ * The agents failproofai traces, by display name in the canonical order: the
103
+ * saved selection when there is one, else the agents hooked at user scope.
104
+ */
105
+ export function readTracedAgentNames(cwd: string, config: FpConfig = readConfig()): string[] {
106
+ const ids: readonly string[] = config.agents ? config.agents.selected : integrationsInstalledAt("user", cwd);
107
+ return INTEGRATION_TYPES.filter((id) => ids.includes(id)).map((id) => {
108
+ try {
109
+ return getIntegration(id).displayName;
110
+ } catch {
111
+ return id;
112
+ }
113
+ });
114
+ }
115
+
116
+ /**
117
+ * The connection, in the precedence `config --status` uses
118
+ * (`connectionStatusReport`): the environment first, then either credential,
119
+ * and the collector's record of refused uploads over the files' claim, because
120
+ * a revoked key leaves both files byte-for-byte correct while nothing arrives.
121
+ * The daemon's state is left out: reading it runs `systemctl`.
122
+ */
123
+ export function readLaunchCloud(): LaunchCloudSummary {
124
+ const envUrl = process.env.FAILPROOFAI_CLOUD_URL;
125
+ if (envUrl) return { kind: "environment", url: envUrl };
126
+ const creds = readCloudCredentials();
127
+ const ingest = readIngestCredential();
128
+ if (!creds && !ingest) return { kind: "none" };
129
+ const org = readCredentials().org;
130
+ const where = creds ? creds.url : cloudBaseFor(ingest!.url);
131
+ let host = where;
132
+ try {
133
+ host = new URL(where).host || where;
134
+ } catch {
135
+ // Not a URL: show it as written.
136
+ }
137
+ let refused: { codes: number[]; credential: boolean } | null = null;
138
+ if (ingest) {
139
+ const health = deliveryHealth();
140
+ if (health.rejected > 0) {
141
+ refused = {
142
+ codes: Object.keys(health.byStatus)
143
+ .map(Number)
144
+ .sort((a, b) => a - b),
145
+ credential: health.credentialRejected > 0,
146
+ };
147
+ }
148
+ }
149
+ return {
150
+ kind: "connected",
151
+ org: org?.name || org?.slug || org?.id || null,
152
+ host,
153
+ pulling: Boolean(creds),
154
+ sending: Boolean(ingest),
155
+ refused,
156
+ };
157
+ }
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Watches the dashboard server start, so the launch screen can say it is live.
3
+ *
4
+ * Only `start` mode can: it pipes the standalone server's output, which is
5
+ * where Next says it is listening. Three signals decide the start, in order of
6
+ * preference:
7
+ *
8
+ * - Next's `Ready in` line on stdout (`makeNextStartupFilter`), logged from the
9
+ * server's own `listening` handler.
10
+ * - A TCP connect to the bind address, tried every 250ms once 5s have passed
11
+ * with no ready line: a Next upgrade that rewords the line must not leave
12
+ * the screen waiting for the deadline.
13
+ * - The server exiting first. That is a failure to start, and the cause is in
14
+ * what it wrote to stderr.
15
+ *
16
+ * Until then the server's output is held back, so the screen opens the output
17
+ * rather than appearing halfway down it. After 30s with no answer the screen
18
+ * prints anyway, marked as still starting, and Next's own banner is let through
19
+ * from then on, so a late start still says when it happened.
20
+ */
21
+ // Aliased: in the scope-hoisted CLI bundle a bare `connect` binding would make
22
+ // the bundler rename every local `connect` elsewhere (the setup wizard has one).
23
+ import { connect as connectDashboardProbe } from "node:net";
24
+ import { createInterface } from "node:readline";
25
+ import type { EventEmitter } from "node:events";
26
+ import { makeNextStartupFilter, makeSkewLogFilter } from "./skew-log-filter";
27
+
28
+ export interface DashboardChild extends EventEmitter {
29
+ stdout: NodeJS.ReadableStream | null;
30
+ stderr: NodeJS.ReadableStream | null;
31
+ }
32
+
33
+ export interface DashboardSink {
34
+ write(chunk: string): unknown;
35
+ }
36
+
37
+ export type DashboardStartOutcome =
38
+ | { kind: "ready"; via: "ready-line" | "probe" }
39
+ | { kind: "timeout" }
40
+ | { kind: "failed"; code: number | null; portInUse: boolean; cause: string | null };
41
+
42
+ export interface DashboardStartWatch {
43
+ child: DashboardChild;
44
+ stdout: DashboardSink;
45
+ stderr: DashboardSink;
46
+ /** True once something accepts a connection on the bind address and port. */
47
+ probe: () => Promise<boolean>;
48
+ /**
49
+ * Called once, when the start is decided. The held-back output is released
50
+ * right after it for a ready or a timeout, so the screen comes first, and
51
+ * right before it for a failure, so the ✕ line comes last.
52
+ */
53
+ onSettled: (outcome: DashboardStartOutcome) => void;
54
+ /** The server exited, or errored, after the start was decided. */
55
+ onExit: (code: number | null, error?: Error) => void;
56
+ probeAfterMs?: number;
57
+ probeEveryMs?: number;
58
+ timeoutMs?: number;
59
+ /** How long to wait after `exit` for the streams to close, in case a grandchild holds them open. */
60
+ exitGraceMs?: number;
61
+ }
62
+
63
+ export function watchDashboardStart(watch: DashboardStartWatch): void {
64
+ const probeAfterMs = watch.probeAfterMs ?? 5_000;
65
+ const probeEveryMs = watch.probeEveryMs ?? 250;
66
+ const timeoutMs = watch.timeoutMs ?? 30_000;
67
+ const exitGraceMs = watch.exitGraceMs ?? 500;
68
+ // A server that floods its output before it listens stops being held back
69
+ // past this many lines, and so does what is kept to find a failure's cause.
70
+ const holdLimit = 2_000;
71
+
72
+ let starting = true;
73
+ let holding = true;
74
+ let bannerActive = true;
75
+ let finished = false;
76
+ const held: Array<{ sink: DashboardSink; line: string; fromStderr: boolean }> = [];
77
+ const startupText: string[] = [];
78
+ const timers = new Set<ReturnType<typeof setTimeout>>();
79
+ const later = (fn: () => void, ms: number): void => {
80
+ const timer = setTimeout(() => {
81
+ timers.delete(timer);
82
+ fn();
83
+ }, ms);
84
+ timers.add(timer);
85
+ };
86
+
87
+ const release = (dropStderr: boolean): void => {
88
+ holding = false;
89
+ for (const entry of held.splice(0)) {
90
+ if (!(dropStderr && entry.fromStderr)) entry.sink.write(`${entry.line}\n`);
91
+ }
92
+ };
93
+
94
+ const decide = (outcome: DashboardStartOutcome): void => {
95
+ if (!starting) return;
96
+ starting = false;
97
+ for (const timer of timers) clearTimeout(timer);
98
+ timers.clear();
99
+ if (outcome.kind === "failed") {
100
+ // Next's own dump for a port in use is a stack trace that says what the
101
+ // ✕ line already says; anything else is the evidence, and stays.
102
+ release(outcome.portInUse);
103
+ watch.onSettled(outcome);
104
+ return;
105
+ }
106
+ if (outcome.kind === "timeout") bannerActive = false;
107
+ try {
108
+ watch.onSettled(outcome);
109
+ } finally {
110
+ release(false);
111
+ }
112
+ };
113
+
114
+ const pipe = (src: NodeJS.ReadableStream | null, sink: DashboardSink, fromStderr: boolean): void => {
115
+ if (!src) return;
116
+ // One of each per stream: both filters are stateful.
117
+ const skew = makeSkewLogFilter();
118
+ const banner = fromStderr ? null : makeNextStartupFilter(() => decide({ kind: "ready", via: "ready-line" }));
119
+ createInterface({ input: src, crlfDelay: Infinity }).on("line", (raw) => {
120
+ let line = skew(raw);
121
+ if (line !== null && banner && bannerActive) line = banner(line);
122
+ if (line === null) return;
123
+ if (starting && startupText.length < holdLimit) startupText.push(line);
124
+ if (holding && held.length >= holdLimit) release(false);
125
+ if (holding) held.push({ sink, line, fromStderr });
126
+ else sink.write(`${line}\n`);
127
+ });
128
+ };
129
+ pipe(watch.child.stdout, watch.stdout, false);
130
+ pipe(watch.child.stderr, watch.stderr, true);
131
+
132
+ const probeOnce = (): void => {
133
+ if (!starting) return;
134
+ const next = (): void => {
135
+ if (starting) later(probeOnce, probeEveryMs);
136
+ };
137
+ let attempt: Promise<boolean>;
138
+ try {
139
+ attempt = watch.probe();
140
+ } catch {
141
+ next();
142
+ return;
143
+ }
144
+ attempt.then((up) => {
145
+ if (!starting) return;
146
+ if (up) decide({ kind: "ready", via: "probe" });
147
+ else next();
148
+ }, next);
149
+ };
150
+ later(probeOnce, probeAfterMs);
151
+ later(() => decide({ kind: "timeout" }), timeoutMs);
152
+
153
+ // `close` comes after the streams have ended, so the last lines (where the
154
+ // cause is) have been read. `exit` alone can arrive first; the grace timer
155
+ // covers a grandchild that keeps a stream open and so delays `close`.
156
+ let grace: ReturnType<typeof setTimeout> | undefined;
157
+ const finish = (code: number | null, error?: Error): void => {
158
+ if (finished) return;
159
+ finished = true;
160
+ if (grace) clearTimeout(grace);
161
+ if (!starting) {
162
+ watch.onExit(code, error);
163
+ return;
164
+ }
165
+ const portInUse = !error && startupText.some((line) => line.includes("EADDRINUSE"));
166
+ decide({
167
+ kind: "failed",
168
+ code,
169
+ portInUse,
170
+ cause: error ? error.message : portInUse ? null : dashboardStartupCause(startupText),
171
+ });
172
+ };
173
+ watch.child.on("exit", (code: number | null) => {
174
+ if (grace === undefined) grace = setTimeout(() => finish(code), exitGraceMs);
175
+ });
176
+ watch.child.on("close", (code: number | null) => finish(code));
177
+ watch.child.on("error", (error: Error) => finish(null, error));
178
+ }
179
+
180
+ /**
181
+ * The line that says why the server stopped: the first `Error:` line (Node
182
+ * prints the message first), else Next's first `⨯` line. A plain `Error: `
183
+ * prefix is dropped as noise; a named one (`TypeError: …`) is kept.
184
+ */
185
+ export function dashboardStartupCause(lines: readonly string[]): string | null {
186
+ const plain = lines.map((line) => line.replace(/\x1B\[[0-9;]*m/g, "").trim());
187
+ for (const line of plain) {
188
+ const match = /(?:^|[\s[])((?:[A-Z][A-Za-z]*)?Error): (.+)$/.exec(line);
189
+ if (match) return match[1] === "Error" ? match[2].trim() : `${match[1]}: ${match[2].trim()}`;
190
+ }
191
+ for (const line of plain) {
192
+ if (line.startsWith("⨯ ")) return line.slice(2).trim();
193
+ }
194
+ return null;
195
+ }
196
+
197
+ /** Where to probe for a bind address: a wildcard bind answers on loopback. */
198
+ export function dashboardProbeHost(bindHost: string): string {
199
+ const raw = bindHost.trim();
200
+ if (raw === "" || raw === "0.0.0.0") return "127.0.0.1";
201
+ if (raw === "::" || raw === "[::]" || raw === "0:0:0:0:0:0:0:0") return "::1";
202
+ return raw.startsWith("[") && raw.endsWith("]") ? raw.slice(1, -1) : raw;
203
+ }
204
+
205
+ /** One TCP connect: true when something accepts it within `timeoutMs`. */
206
+ export function probeDashboardPort(host: string, port: number, timeoutMs = 1_000): Promise<boolean> {
207
+ return new Promise((settle) => {
208
+ let socket: ReturnType<typeof connectDashboardProbe>;
209
+ try {
210
+ socket = connectDashboardProbe({ host, port });
211
+ } catch {
212
+ // A port that is not a port (`--port abc`) throws here; the server has
213
+ // already failed on it, and its exit says why.
214
+ settle(false);
215
+ return;
216
+ }
217
+ let answered = false;
218
+ const answer = (up: boolean): void => {
219
+ if (answered) return;
220
+ answered = true;
221
+ socket.destroy();
222
+ settle(up);
223
+ };
224
+ socket.setTimeout(timeoutMs, () => answer(false));
225
+ socket.once("connect", () => answer(true));
226
+ socket.once("error", () => answer(false));
227
+ });
228
+ }