failproofai 1.0.7-beta.1 → 1.0.7

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 (429) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +4 -4
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  6. package/.next/standalone/.next/server/app/_global-error/page.js +4 -4
  7. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  8. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  11. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
  12. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  13. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page.js +4 -4
  16. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  17. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.rsc +15 -15
  20. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +15 -15
  21. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +14 -14
  22. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  23. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/audit/run/route.js +7 -8
  25. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
  33. package/.next/standalone/.next/server/app/audit/page.js +5 -7
  34. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
  35. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  36. package/.next/standalone/.next/server/app/index.html +1 -1
  37. package/.next/standalone/.next/server/app/index.rsc +15 -15
  38. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +14 -14
  39. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +15 -15
  40. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  41. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  42. package/.next/standalone/.next/server/app/page.js +6 -6
  43. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  44. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  45. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
  46. package/.next/standalone/.next/server/app/policies/page.js +11 -13
  47. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  48. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  49. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  50. package/.next/standalone/.next/server/app/project/[name]/page.js +7 -8
  51. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  53. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  54. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  55. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +7 -7
  56. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  58. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  59. package/.next/standalone/.next/server/app/projects/page.js +6 -7
  60. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  61. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  62. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +8 -41
  63. package/.next/standalone/.next/server/app/settings/page.js +9 -12
  64. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  65. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  66. package/.next/standalone/.next/server/chunks/{[externals]__1j-zsg5._.js → [externals]__1_bftcl._.js} +1 -1
  67. package/.next/standalone/.next/server/chunks/{[externals]__19_pzeq._.js → [externals]__1msfs-h._.js} +1 -1
  68. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
  69. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1bf34x4._.js → [root-of-the-server]__1_r2rbg._.js} +7 -5
  70. package/.next/standalone/.next/server/chunks/_09dz7xv._.js +21 -21
  71. package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
  72. package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
  73. package/.next/standalone/.next/server/chunks/{_1q5i8mb._.js → _1c3k-8x._.js} +2 -2
  74. package/.next/standalone/.next/server/chunks/_1ek68ln._.js +16 -16
  75. package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_09z9-p7._.js +1 -1
  76. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
  77. package/.next/standalone/.next/server/chunks/src_hooks_0iu54mz._.js +3 -0
  78. package/.next/standalone/.next/server/chunks/src_hooks_custom-hooks-loader_ts_0lnb3n3._.js +2 -4
  79. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0-_ki57._.js +4 -0
  80. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__013jr2b._.js +4 -0
  81. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01wy8d-._.js +4 -0
  82. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02npjtd._.js +4 -0
  83. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0yxwl6j._.js → [root-of-the-server]__0bd3mje._.js} +2 -2
  84. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0cg-bgc._.js +5 -0
  85. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0cpu_mj._.js +3 -0
  86. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1mf3zp6._.js → [root-of-the-server]__0cxe_2_._.js} +3 -3
  87. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0da85px._.js +4 -0
  88. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ftmoxc._.js +4 -0
  89. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0p-5p8u._.js +4 -0
  90. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0u3w0ll._.js +22 -0
  91. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__17d_ffl._.js +3 -0
  92. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__19d9tgz._.js +5 -0
  93. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1ctpynv._.js +3 -0
  94. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1jiwfsj._.js +3 -0
  95. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1p2otjt._.js +4 -0
  96. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1phc187._.js +3 -0
  97. package/.next/standalone/.next/server/chunks/ssr/_06imw3p._.js +5 -0
  98. package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
  99. package/.next/standalone/.next/server/chunks/ssr/{_1w_5l7t._.js → _0h_douw._.js} +1 -1
  100. package/.next/standalone/.next/server/chunks/ssr/{_214wgrp._.js → _1-i_gzc._.js} +2 -2
  101. package/.next/standalone/.next/server/chunks/ssr/{_0bn2oo8._.js → _166t73i._.js} +1 -1
  102. package/.next/standalone/.next/server/chunks/ssr/{_1q46vxx._.js → _1_qswah._.js} +2 -2
  103. package/.next/standalone/.next/server/chunks/ssr/{_1gb0ifp._.js → _1es2j7i._.js} +5 -5
  104. package/.next/standalone/.next/server/chunks/ssr/_1u8-lu2._.js +3 -0
  105. package/.next/standalone/.next/server/chunks/ssr/_1zopuov._.js +1 -1
  106. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +2 -2
  107. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
  108. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
  109. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +2 -2
  110. package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +3 -0
  111. package/.next/standalone/.next/server/chunks/ssr/{node_modules_next_dist_18_d8l1._.js → node_modules_next_dist_0drixxt._.js} +4 -4
  112. package/.next/standalone/.next/server/chunks/ssr/src_hooks_1cv9_c4._.js +10 -0
  113. package/.next/standalone/.next/server/chunks/ssr/src_hooks_builtin-policies_ts_09j2ndl._.js +1 -1
  114. package/.next/standalone/.next/server/chunks/ssr/src_hooks_fp-home_ts_0je3xkv._.js +1 -1
  115. package/.next/standalone/.next/server/chunks/ssr/src_hooks_pack-cli_ts_0t7me65._.js +1 -1
  116. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  117. package/.next/standalone/.next/server/pages/404.html +1 -1
  118. package/.next/standalone/.next/server/pages/500.html +1 -1
  119. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  120. package/.next/standalone/.next/server/server-reference-manifest.json +23 -56
  121. package/.next/standalone/.next/static/chunks/094xgi4owxaqf.js +1 -0
  122. package/.next/standalone/.next/static/chunks/0__8a7m868fvf.js +1 -0
  123. package/.next/standalone/.next/static/chunks/{12tvm75t5ffui.js → 0o6qlkgubtoex.js} +1 -1
  124. package/.next/standalone/.next/static/chunks/13i7-9is-vhys.js +1 -0
  125. package/.next/standalone/.next/static/chunks/1rz20_pz828f3.js +6 -0
  126. package/.next/standalone/.next/static/chunks/2k9f4tyv04809.css +1 -0
  127. package/.next/standalone/.next/static/chunks/{0vmd180qfntfb.js → 2klitrtzpaoe0.js} +1 -1
  128. package/.next/standalone/.next/static/chunks/{258668t68du6b.js → 2mdh397ghgnvv.js} +1 -1
  129. package/.next/standalone/.next/static/chunks/2rshywgeqsyzk.css +2 -0
  130. package/.next/standalone/.next/static/chunks/3pzx4chkhko9k.js +1 -0
  131. package/.next/standalone/.next/static/chunks/{0qrbdkv9qmvli.js → 3rh5o7e16irrm.js} +1 -1
  132. package/.next/standalone/.next/static/chunks/{29fql3nbnfc9q.js → 43ufqrz8qo3h-.js} +1 -1
  133. package/.next/standalone/SECURITY.md +53 -0
  134. package/.next/standalone/app/actions/pack-actions.ts +0 -12
  135. package/.next/standalone/app/policies/hooks-client.tsx +0 -9
  136. package/.next/standalone/app/settings/page.tsx +1 -20
  137. package/.next/standalone/app/settings/settings-client.tsx +1 -27
  138. package/.next/standalone/app/settings/settings.css +0 -79
  139. package/.next/standalone/package.json +9 -9
  140. package/.next/standalone/sdk/python/skill/SKILL.md +60 -14
  141. package/.next/standalone/sdk/python/skill/agents/openai.yaml +2 -1
  142. package/.next/standalone/sdk/python/skill/references/evaluator.md +255 -0
  143. package/.next/standalone/sdk/python/skill/references/events.md +17 -8
  144. package/.next/standalone/sdk/python/skill/references/frameworks.md +3 -0
  145. package/.next/standalone/sdk/python/skill/references/install.md +3 -0
  146. package/.next/standalone/sdk/python/skill/references/integration.md +6 -2
  147. package/.next/standalone/sdk/python/skill/references/typescript.md +568 -0
  148. package/.next/standalone/sdk/typescript/CHANGELOG.md +133 -0
  149. package/.next/standalone/sdk/typescript/LICENSE +42 -0
  150. package/.next/standalone/sdk/typescript/README.md +552 -0
  151. package/.next/standalone/sdk/typescript/eslint.config.mjs +59 -0
  152. package/.next/standalone/sdk/typescript/examples/research-agent.ts +197 -0
  153. package/.next/standalone/sdk/typescript/integration/ai.test.ts +920 -0
  154. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/agent.ts +337 -0
  155. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/package-lock.json +261 -0
  156. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/package.json +16 -0
  157. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/surfaces.ts +605 -0
  158. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/tsconfig.json +12 -0
  159. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/tsconfig.surfaces.json +4 -0
  160. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/agent.ts +342 -0
  161. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/package-lock.json +156 -0
  162. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/package.json +16 -0
  163. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/surfaces.ts +628 -0
  164. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/tsconfig.json +12 -0
  165. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/tsconfig.surfaces.json +4 -0
  166. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/agent.ts +346 -0
  167. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/package-lock.json +156 -0
  168. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/package.json +13 -0
  169. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/surfaces.ts +651 -0
  170. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/tsconfig.json +12 -0
  171. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/tsconfig.surfaces.json +4 -0
  172. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/agent.ts +350 -0
  173. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/package-lock.json +153 -0
  174. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/package.json +13 -0
  175. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/surfaces.ts +651 -0
  176. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/tsconfig.json +12 -0
  177. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/tsconfig.surfaces.json +4 -0
  178. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/agent.ts +623 -0
  179. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/package-lock.json +344 -0
  180. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/package.json +19 -0
  181. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/tsconfig.json +12 -0
  182. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/agent-v1.ts +99 -0
  183. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/agent.ts +623 -0
  184. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/package-lock.json +336 -0
  185. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/package.json +15 -0
  186. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/tsconfig.json +12 -0
  187. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/agent.ts +96 -0
  188. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/package-lock.json +441 -0
  189. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/package.json +19 -0
  190. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/tsconfig.json +12 -0
  191. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/vendor/lc-weather-provider/index.cjs +53 -0
  192. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/vendor/lc-weather-provider/index.mjs +55 -0
  193. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/vendor/lc-weather-provider/package.json +18 -0
  194. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/agent.ts +659 -0
  195. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/package-lock.json +635 -0
  196. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/package.json +15 -0
  197. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/tsconfig.json +12 -0
  198. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/agent.ts +659 -0
  199. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/package-lock.json +553 -0
  200. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/package.json +15 -0
  201. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/tsconfig.json +12 -0
  202. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/agent.ts +877 -0
  203. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/mcp-server.mjs +66 -0
  204. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/package-lock.json +6797 -0
  205. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/package.json +24 -0
  206. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/tsconfig.json +12 -0
  207. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/agent.ts +872 -0
  208. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/mcp-server.mjs +66 -0
  209. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/package-lock.json +2540 -0
  210. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/package.json +15 -0
  211. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/tsconfig.json +12 -0
  212. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/actions.ts +18 -0
  213. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/ai/route.ts +42 -0
  214. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/edge/route.ts +29 -0
  215. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/langgraph/route.ts +21 -0
  216. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/llamaindex/route.ts +11 -0
  217. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/mastra/route.ts +19 -0
  218. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/status/route.ts +7 -0
  219. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/layout.tsx +9 -0
  220. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/page.tsx +15 -0
  221. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/instrumentation.ts +15 -0
  222. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/ai.ts +61 -0
  223. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/langgraph.ts +68 -0
  224. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/llamaindex.ts +98 -0
  225. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/mastra.ts +90 -0
  226. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/next.config.ts +52 -0
  227. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/package-lock.json +4343 -0
  228. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/package.json +28 -0
  229. package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/agent.ts +51 -0
  230. package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/deno-npm.ts +76 -0
  231. package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/package-lock.json +484 -0
  232. package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/package.json +15 -0
  233. package/.next/standalone/sdk/typescript/integration/fixtures/types/agent.ts +79 -0
  234. package/.next/standalone/sdk/typescript/integration/fixtures/types/package-lock.json +740 -0
  235. package/.next/standalone/sdk/typescript/integration/fixtures/types/package.json +11 -0
  236. package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/agent.ts +197 -0
  237. package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/package-lock.json +70 -0
  238. package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/package.json +12 -0
  239. package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/tsconfig.json +12 -0
  240. package/.next/standalone/sdk/typescript/integration/global-setup.ts +29 -0
  241. package/.next/standalone/sdk/typescript/integration/harness.ts +451 -0
  242. package/.next/standalone/sdk/typescript/integration/langchain.test.ts +682 -0
  243. package/.next/standalone/sdk/typescript/integration/llamaindex.test.ts +709 -0
  244. package/.next/standalone/sdk/typescript/integration/mastra-coverage.test.ts +386 -0
  245. package/.next/standalone/sdk/typescript/integration/mastra.test.ts +311 -0
  246. package/.next/standalone/sdk/typescript/integration/nextjs.test.ts +341 -0
  247. package/.next/standalone/sdk/typescript/integration/runtime-parity.ts +180 -0
  248. package/.next/standalone/sdk/typescript/integration/runtimes.bun.test.ts +15 -0
  249. package/.next/standalone/sdk/typescript/integration/runtimes.core.test.ts +113 -0
  250. package/.next/standalone/sdk/typescript/integration/runtimes.deno.test.ts +19 -0
  251. package/.next/standalone/sdk/typescript/integration/types.test.ts +141 -0
  252. package/.next/standalone/sdk/typescript/integration/vanilla.test.ts +255 -0
  253. package/.next/standalone/sdk/typescript/package-lock.json +2640 -0
  254. package/.next/standalone/sdk/typescript/package.json +401 -0
  255. package/.next/standalone/sdk/typescript/scripts/finalize-build.mjs +123 -0
  256. package/.next/standalone/sdk/typescript/scripts/release.mjs +177 -0
  257. package/.next/standalone/sdk/typescript/src/clock.ts +58 -0
  258. package/.next/standalone/sdk/typescript/src/context.ts +214 -0
  259. package/.next/standalone/sdk/typescript/src/edge/adapter.ts +18 -0
  260. package/.next/standalone/sdk/typescript/src/edge/ai.ts +116 -0
  261. package/.next/standalone/sdk/typescript/src/edge/index.ts +238 -0
  262. package/.next/standalone/sdk/typescript/src/edge/langchain.ts +18 -0
  263. package/.next/standalone/sdk/typescript/src/edge/llamaindex.ts +12 -0
  264. package/.next/standalone/sdk/typescript/src/edge/mastra.ts +17 -0
  265. package/.next/standalone/sdk/typescript/src/edge/notice.ts +33 -0
  266. package/.next/standalone/sdk/typescript/src/environment.ts +75 -0
  267. package/.next/standalone/sdk/typescript/src/evaluator/authoring.ts +480 -0
  268. package/.next/standalone/sdk/typescript/src/evaluator/cli.ts +96 -0
  269. package/.next/standalone/sdk/typescript/src/evaluator/client.ts +421 -0
  270. package/.next/standalone/sdk/typescript/src/evaluator/expression.ts +1292 -0
  271. package/.next/standalone/sdk/typescript/src/evaluator/index.ts +144 -0
  272. package/.next/standalone/sdk/typescript/src/evaluator/protocol.ts +747 -0
  273. package/.next/standalone/sdk/typescript/src/evaluator/runtime.ts +930 -0
  274. package/.next/standalone/sdk/typescript/src/evaluator/sandbox-worker.ts +171 -0
  275. package/.next/standalone/sdk/typescript/src/evaluator/source-limits.ts +27 -0
  276. package/.next/standalone/sdk/typescript/src/evaluator/source.ts +509 -0
  277. package/.next/standalone/sdk/typescript/src/events.ts +879 -0
  278. package/.next/standalone/sdk/typescript/src/exit.ts +117 -0
  279. package/.next/standalone/sdk/typescript/src/index.ts +186 -0
  280. package/.next/standalone/sdk/typescript/src/integrations/ai.ts +1566 -0
  281. package/.next/standalone/sdk/typescript/src/integrations/compat.ts +322 -0
  282. package/.next/standalone/sdk/typescript/src/integrations/core.ts +1321 -0
  283. package/.next/standalone/sdk/typescript/src/integrations/index.ts +355 -0
  284. package/.next/standalone/sdk/typescript/src/integrations/langchain.ts +2340 -0
  285. package/.next/standalone/sdk/typescript/src/integrations/llamaindex.ts +2111 -0
  286. package/.next/standalone/sdk/typescript/src/integrations/mastra.ts +1802 -0
  287. package/.next/standalone/sdk/typescript/src/logger.ts +98 -0
  288. package/.next/standalone/sdk/typescript/src/next.ts +115 -0
  289. package/.next/standalone/sdk/typescript/src/node-require.ts +446 -0
  290. package/.next/standalone/sdk/typescript/src/redact.ts +305 -0
  291. package/.next/standalone/sdk/typescript/src/resolver.ts +120 -0
  292. package/.next/standalone/sdk/typescript/src/runtime.ts +29 -0
  293. package/.next/standalone/sdk/typescript/src/schema.ts +410 -0
  294. package/.next/standalone/sdk/typescript/src/scopes.ts +701 -0
  295. package/.next/standalone/sdk/typescript/src/shared.ts +33 -0
  296. package/.next/standalone/sdk/typescript/src/version.ts +5 -0
  297. package/.next/standalone/sdk/typescript/src/writer.ts +934 -0
  298. package/.next/standalone/sdk/typescript/test/adapters.test.ts +397 -0
  299. package/.next/standalone/sdk/typescript/test/ai.test.ts +1076 -0
  300. package/.next/standalone/sdk/typescript/test/copies.test.ts +204 -0
  301. package/.next/standalone/sdk/typescript/test/edge.test.ts +183 -0
  302. package/.next/standalone/sdk/typescript/test/evaluator-client.test.ts +234 -0
  303. package/.next/standalone/sdk/typescript/test/evaluator-protocol.test.ts +225 -0
  304. package/.next/standalone/sdk/typescript/test/events.test.ts +193 -0
  305. package/.next/standalone/sdk/typescript/test/expression.test.ts +181 -0
  306. package/.next/standalone/sdk/typescript/test/global-setup.ts +26 -0
  307. package/.next/standalone/sdk/typescript/test/helpers.ts +130 -0
  308. package/.next/standalone/sdk/typescript/test/integrations.test.ts +369 -0
  309. package/.next/standalone/sdk/typescript/test/langchain-copies.test.ts +204 -0
  310. package/.next/standalone/sdk/typescript/test/langchain.test.ts +999 -0
  311. package/.next/standalone/sdk/typescript/test/llamaindex.test.ts +1760 -0
  312. package/.next/standalone/sdk/typescript/test/mastra-coverage.test.ts +501 -0
  313. package/.next/standalone/sdk/typescript/test/mastra-lifecycle.test.ts +479 -0
  314. package/.next/standalone/sdk/typescript/test/mastra.test.ts +285 -0
  315. package/.next/standalone/sdk/typescript/test/next.test.ts +109 -0
  316. package/.next/standalone/sdk/typescript/test/packaging.test.ts +312 -0
  317. package/.next/standalone/sdk/typescript/test/redaction.test.ts +171 -0
  318. package/.next/standalone/sdk/typescript/test/runtimes.test.ts +101 -0
  319. package/.next/standalone/sdk/typescript/test/sandbox.test.ts +189 -0
  320. package/.next/standalone/sdk/typescript/test/scopes.test.ts +271 -0
  321. package/.next/standalone/sdk/typescript/test/setup.ts +19 -0
  322. package/.next/standalone/sdk/typescript/test/skill-snippets.test.ts +73 -0
  323. package/.next/standalone/sdk/typescript/test/spool-contract.test.ts +124 -0
  324. package/.next/standalone/sdk/typescript/test/tracker-bounds.test.ts +191 -0
  325. package/.next/standalone/sdk/typescript/test/wire-format.test.ts +214 -0
  326. package/.next/standalone/sdk/typescript/test/writer.test.ts +407 -0
  327. package/.next/standalone/sdk/typescript/tsconfig.build.json +15 -0
  328. package/.next/standalone/sdk/typescript/tsconfig.cjs.json +19 -0
  329. package/.next/standalone/sdk/typescript/tsconfig.json +28 -0
  330. package/.next/standalone/sdk/typescript/vitest.config.ts +33 -0
  331. package/.next/standalone/sdk/typescript/vitest.integration.config.ts +23 -0
  332. package/.next/standalone/server.js +1 -1
  333. package/bin/failproofai.mjs +2 -115
  334. package/dist/cli.mjs +6538 -13686
  335. package/dist/index.js +1 -19
  336. package/dist/worker.mjs +2085 -8012
  337. package/package.json +9 -9
  338. package/pi-extension/index.ts +0 -11
  339. package/scripts/build-policy-pack.mjs +2 -39
  340. package/src/hooks/builtin-policies.ts +3 -21
  341. package/src/hooks/cloud-enrollment-cli.ts +1 -1
  342. package/src/hooks/cloud-managed-policies.ts +0 -22
  343. package/src/hooks/custom-hooks-loader.ts +7 -45
  344. package/src/hooks/custom-hooks-registry.ts +1 -45
  345. package/src/hooks/first-run-gate.ts +0 -5
  346. package/src/hooks/fp-home.ts +0 -23
  347. package/src/hooks/handler.ts +6 -265
  348. package/src/hooks/hook-activity-store.ts +1 -105
  349. package/src/hooks/hook-telemetry.ts +0 -41
  350. package/src/hooks/loader-utils.ts +0 -6
  351. package/src/hooks/pack-cli.ts +17 -278
  352. package/src/hooks/pack-manifest.ts +7 -479
  353. package/src/hooks/pack-store.ts +10 -156
  354. package/src/hooks/policy-catalog.ts +0 -65
  355. package/src/hooks/policy-evaluator.ts +796 -940
  356. package/src/hooks/policy-registry.ts +0 -25
  357. package/src/hooks/policy-types.ts +0 -126
  358. package/src/hooks/worker-server.ts +26 -119
  359. package/src/index.ts +0 -6
  360. package/.next/standalone/.next/server/chunks/src_hooks_01frwmb._.js +0 -5
  361. package/.next/standalone/.next/server/chunks/src_hooks_18qtd42._.js +0 -3
  362. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01bmjsj._.js +0 -3
  363. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__04usis8._.js +0 -4
  364. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__056wjo4._.js +0 -4
  365. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__059yza8._.js +0 -3
  366. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0eip4_k._.js +0 -22
  367. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0n0xg95._.js +0 -4
  368. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0qcb0mg._.js +0 -3
  369. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0qxnccm._.js +0 -5
  370. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0rwtwpm._.js +0 -4
  371. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s_yomn._.js +0 -4
  372. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0soxz2z._.js +0 -3
  373. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0yrsbd_._.js +0 -3
  374. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11mayhe._.js +0 -4
  375. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__13d-wb6._.js +0 -3
  376. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1dinjii._.js +0 -3
  377. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1pprgri._.js +0 -4
  378. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1q4p5b8._.js +0 -4
  379. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1qiz0e4._.js +0 -3
  380. package/.next/standalone/.next/server/chunks/ssr/_042cgl1._.js +0 -3
  381. package/.next/standalone/.next/server/chunks/ssr/_0bqoto4._.js +0 -3
  382. package/.next/standalone/.next/server/chunks/ssr/_0uyu3jf._.js +0 -3
  383. package/.next/standalone/.next/server/chunks/ssr/_1feuvhb._.js +0 -5
  384. package/.next/standalone/.next/server/chunks/ssr/app_actions_get-scheduled-audit_ts_0ei9sni._.js +0 -3
  385. package/.next/standalone/.next/server/chunks/ssr/app_settings_02tf1h4._.js +0 -3
  386. package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_0w6mzq5._.js +0 -151
  387. package/.next/standalone/.next/server/chunks/ssr/src_hooks_095a_79._.js +0 -5
  388. package/.next/standalone/.next/server/chunks/ssr/src_hooks_15t8kqj._.js +0 -3
  389. package/.next/standalone/.next/server/chunks/ssr/src_hooks_18k8rl0._.js +0 -12
  390. package/.next/standalone/.next/server/chunks/ssr/src_hooks_1fm2w5z._.js +0 -3
  391. package/.next/standalone/.next/server/chunks/ssr/src_hooks_1j0zy3v._.js +0 -3
  392. package/.next/standalone/.next/static/chunks/0cd-_8-c-m1ea.js +0 -6
  393. package/.next/standalone/.next/static/chunks/0uldbut9y2-e8.js +0 -1
  394. package/.next/standalone/.next/static/chunks/1u5zsejmgrir_.js +0 -1
  395. package/.next/standalone/.next/static/chunks/285spx855h_3r.css +0 -2
  396. package/.next/standalone/.next/static/chunks/2qv4hshejedtx.css +0 -1
  397. package/.next/standalone/.next/static/chunks/2vkvu9-opa_1z.js +0 -1
  398. package/.next/standalone/.next/static/chunks/37lhv7wa3ywt6.js +0 -1
  399. package/.next/standalone/app/actions/get-jev-config.ts +0 -409
  400. package/.next/standalone/app/actions/update-jev-config.ts +0 -420
  401. package/.next/standalone/app/components/jev-notices.tsx +0 -96
  402. package/.next/standalone/app/settings/jev-panel.tsx +0 -469
  403. package/src/hooks/effective-reviewers.ts +0 -79
  404. package/src/hooks/jev-activity.ts +0 -385
  405. package/src/hooks/jev-cli.ts +0 -1193
  406. package/src/hooks/policy-authority.ts +0 -333
  407. package/src/hooks/policy-reviewability.ts +0 -229
  408. package/src/hooks/semantic/combine.ts +0 -541
  409. package/src/hooks/semantic/compile.ts +0 -176
  410. package/src/hooks/semantic/decide.ts +0 -392
  411. package/src/hooks/semantic/envelope.ts +0 -1296
  412. package/src/hooks/semantic/evaluator.ts +0 -547
  413. package/src/hooks/semantic/facts.ts +0 -292
  414. package/src/hooks/semantic/intent.ts +0 -1190
  415. package/src/hooks/semantic/jev-client.ts +0 -643
  416. package/src/hooks/semantic/jev-config.ts +0 -594
  417. package/src/hooks/semantic/jev-review.ts +0 -374
  418. package/src/hooks/semantic/jev-stats.ts +0 -289
  419. package/src/hooks/semantic/jev-throttle.ts +0 -421
  420. package/src/hooks/semantic/pack-policies.ts +0 -251
  421. package/src/hooks/semantic/policies.ts +0 -596
  422. package/src/hooks/semantic/precondition-names.ts +0 -60
  423. package/src/hooks/semantic/preconditions.ts +0 -58
  424. package/src/hooks/semantic/redact.ts +0 -2910
  425. package/src/hooks/semantic/types.ts +0 -145
  426. package/src/hooks/semver-precedence.ts +0 -128
  427. /package/.next/standalone/.next/static/{T8YAYM9h_64fKv705vug7 → PgeWCHmyVbjRznv2VO7KF}/_buildManifest.js +0 -0
  428. /package/.next/standalone/.next/static/{T8YAYM9h_64fKv705vug7 → PgeWCHmyVbjRznv2VO7KF}/_clientMiddlewareManifest.js +0 -0
  429. /package/.next/standalone/.next/static/{T8YAYM9h_64fKv705vug7 → PgeWCHmyVbjRznv2VO7KF}/_ssgManifest.js +0 -0
@@ -1,420 +0,0 @@
1
- "use server";
2
-
3
- /**
4
- * Write side of the /settings "Jev" section — the dashboard's half of
5
- * `failproofai jev setup` / `failproofai jev remove`.
6
- *
7
- * ## One file, one writer, one validator
8
- *
9
- * The file is `~/.failproofai/jev.json`, written through the same
10
- * `writeJsonAtomically` the CLI's `jev setup` calls, with the same
11
- * `{ mode: 0o600, dirMode: 0o700 }`, after the same `validateJevConfig` the
12
- * loader itself runs. Nothing here re-states a rule that lives in
13
- * `jev-config.ts`: not the URL scheme, not "plain http only in shadow mode",
14
- * not "cloudflare needs an account id". A second copy of those rules is how the
15
- * dashboard ends up writing a file the hooks then refuse — the exact failure
16
- * mode this module exists to avoid.
17
- *
18
- * ## Cross-origin writes
19
- *
20
- * The dashboard is an unauthenticated local web server, so a page on any other
21
- * site can POST to it from the victim's own browser. That matters more here
22
- * than anywhere else on the surface: a cross-site write could point the
23
- * evaluator at the attacker's endpoint — which then sees a redacted envelope
24
- * for every command failproofai judges — or switch Jev on in enforce mode,
25
- * where its answers can clear a deny.
26
- *
27
- * `proxy.ts` already refuses cross-origin mutating requests and non-loopback
28
- * `Host` headers for the whole dashboard, and a Server Action is a POST, so it
29
- * is covered. The check is repeated HERE, against the same
30
- * `lib/dashboard-host` helpers so the two cannot diverge on what "loopback"
31
- * or "same origin" means, because this is the one write on the dashboard whose
32
- * payload is a credential and whose effect is the destination that credential
33
- * is sent to. Two layers that read the same rule from one place cost a header
34
- * lookup; one layer costs the whole feature if the middleware matcher is ever
35
- * narrowed.
36
- *
37
- * ## The token
38
- *
39
- * It arrives, it is validated, it is written at 0600, and it is never returned.
40
- * Both actions answer with a `JevSettingsView`, which carries a presence flag
41
- * and at most the last four characters — see `get-jev-config.ts`.
42
- *
43
- * A stored token is KEPT only when the provider and the base URL are both
44
- * unchanged and the file was owner-only. Anything else — a new provider, a
45
- * moved endpoint, or a file other users could have written — asks for it
46
- * again, because a key issued for one gateway must not be sent to another
47
- * unasked. That is the CLI's rule, applied slightly more strictly: the CLI
48
- * carries a key back to the provider's own API, and this surface does not,
49
- * because a form with a blank field is a weaker statement of intent than a
50
- * typed command.
51
- *
52
- * That rule is about a key MOVING, so it only applies where there is one to
53
- * move. A config written by `jev setup --key-from-env` stores no key — a hook
54
- * reads `FAILPROOFAI_JEV_API_KEY` at the moment it runs — and its endpoint,
55
- * provider and mode are therefore editable here with the token field left
56
- * blank: nothing travels anywhere it had not already been sent, and the key
57
- * stays where its owner put it, outside the file. Asking for a token instead
58
- * would be asking them to abandon that choice in order to change an endpoint,
59
- * and the refusal did it while naming "the stored token" — a thing that
60
- * deliberately does not exist in such a file.
61
- *
62
- * That includes a file the loader called too open. Re-saving it is the only
63
- * remedy the panel has for those permissions — the write is 0600 and it
64
- * tightens the directory — and there is no stored key to withhold, so refusing
65
- * would leave the file broken and buy nothing: the endpoint that gets written is
66
- * the one in the form, which the person can see and change, above the loader's
67
- * own warning about the file. For a file that DOES store a key the refusal
68
- * stands, because re-typing the token is what says "this key, for this
69
- * endpoint".
70
- *
71
- * `--key-from-env` is inferred from the file being updated rather than asked
72
- * for again, which is the one place this path is laxer than `jev setup`: the CLI
73
- * makes you re-state `--key-from-env` when the provider changes. A form that
74
- * offers no such flag would have no way to say it.
75
- *
76
- * ## What a save does NOT touch
77
- *
78
- * Only the fields the panel sends. Every other field in the file — `model`, a
79
- * `timeoutMs` set from the CLI, anything a newer failproofai wrote — is carried
80
- * over untouched. This is not a nicety. `model` decides which model id the
81
- * request names, and a self-hosted or gateway endpoint that must be told its
82
- * model stops answering anything at all once it is dropped — while the panel,
83
- * whose write passed validation, reports success. A form must not be able to
84
- * delete a field it does not show.
85
- *
86
- * The merge below is `jev setup`'s, field for field: spread the existing file
87
- * when the provider is unchanged, carry `mode` and `timeoutMs` across when it
88
- * is not, and set only what was named — `setOrClear` in `src/hooks/jev-cli.ts`,
89
- * where a flag that was not given leaves its field alone. It is written out
90
- * again here rather than called because that path is a terminal command
91
- * (`argv` in, rendered lines out, its own key prompt) that lives in the hook
92
- * bundle, and because this surface's key rule is deliberately stricter. What
93
- * keeps the two from drifting is a test that runs both over the same file and
94
- * compares the bytes: `__tests__/actions/update-jev-config.test.ts`, "agrees
95
- * with `jev setup` about what an update keeps". Extracting one shared merge
96
- * would be better still, and needs `src/hooks/semantic/jev-config.ts` to own
97
- * it.
98
- */
99
-
100
- import { chmodSync, existsSync, statSync, unlinkSync } from "node:fs";
101
- import { dirname } from "node:path";
102
- import { headers } from "next/headers";
103
- import { writeJsonAtomically } from "@/lib/atomic-write";
104
- import {
105
- hostnameFromHostHeader,
106
- isLoopbackHostname,
107
- resolveDashboardHost,
108
- } from "@/lib/dashboard-host";
109
- import {
110
- JEV_PROVIDER_KINDS,
111
- jevConfigPath,
112
- readJevConfigFileForUpdate,
113
- validateApiKey,
114
- validateBaseUrl,
115
- validateJevConfig,
116
- } from "@/src/hooks/semantic/jev-config";
117
- import { getJevSettingsAction, type JevSettingsView } from "./get-jev-config";
118
-
119
- /**
120
- * What the panel sends — the four fields the form owns, and the token.
121
- *
122
- * Every field is a string; "" means "not set". There is deliberately no `model`:
123
- * the form does not show one, so it has nothing to say about it, and a field
124
- * this type does not carry is a field `saveJevConfigAction` cannot clear.
125
- */
126
- export interface JevConfigInput {
127
- provider: string;
128
- /** "" routes to the provider's own API. */
129
- baseUrl: string;
130
- /** Cloudflare only. */
131
- accountId: string;
132
- /** "shadow" | "enforce". */
133
- mode: string;
134
- /** "" keeps the key where it is: the stored one, or the environment's. */
135
- token: string;
136
- }
137
-
138
- export type JevWriteResult =
139
- | { ok: true; view: JevSettingsView }
140
- /**
141
- * Returned, never thrown. Next masks a thrown server-action error before the
142
- * browser sees it — the client gets an opaque digest and no message — so a
143
- * validation problem the user could act on would arrive as "something went
144
- * wrong". The same reasoning as `SetAutoAuditResult` next door.
145
- */
146
- | {
147
- ok: false;
148
- problem: string;
149
- /** The one failure whose remedy is "type the token again", so the panel can say so on the field. */
150
- needsToken?: true;
151
- };
152
-
153
- /**
154
- * The refusal text for every cross-origin shape, deliberately identical.
155
- *
156
- * Naming which check failed is a probing aid on an unauthenticated surface, and
157
- * the legitimate caller — the dashboard's own page — can never see this string.
158
- */
159
- const CROSS_ORIGIN_REFUSAL =
160
- "this request did not come from the dashboard in your browser, so nothing was written.";
161
-
162
- /** Validation-only placeholder for a config whose key comes from the environment. Never written. */
163
- const ENV_KEY_STAND_IN = "env-key-stand-in";
164
-
165
- /**
166
- * Refuse anything that is not a same-machine, same-origin call.
167
- *
168
- * A transcription of `proxy.ts`'s rule, built from the same
169
- * `lib/dashboard-host` helpers rather than its own idea of loopback:
170
- *
171
- * - on a loopback bind the `Host` must be loopback (this is what defeats DNS
172
- * rebinding, whose whole trick is arriving with an attacker-controlled Host
173
- * that its own Origin then matches);
174
- * - a mutating call with an `Origin` must have one whose full authority
175
- * equals that Host — another app on localhost:3000 is a different origin;
176
- * - no `Origin` at all is a non-browser caller, allowed only on a loopback
177
- * bind, where it is necessarily a local process that could edit
178
- * `jev.json` directly anyway. On a deliberately non-loopback bind
179
- * (`--host`, `FAILPROOFAI_DASHBOARD_HOST`) that describes every curl on the
180
- * network segment, so it is refused.
181
- */
182
- async function crossOriginRefusal(): Promise<string | null> {
183
- let h: Headers;
184
- try {
185
- h = await headers();
186
- } catch {
187
- // No request context at all. Nothing legitimate reaches these actions that
188
- // way, and a write of a credential is not the place to assume otherwise.
189
- return CROSS_ORIGIN_REFUSAL;
190
- }
191
- const bindHost = resolveDashboardHost(undefined, process.env.FAILPROOFAI_DASHBOARD_HOST);
192
- const boundToLoopback = isLoopbackHostname(bindHost);
193
- const hostHeader = h.get("host");
194
-
195
- if (boundToLoopback) {
196
- if (!hostHeader || !isLoopbackHostname(hostnameFromHostHeader(hostHeader))) {
197
- return CROSS_ORIGIN_REFUSAL;
198
- }
199
- }
200
-
201
- const origin = h.get("origin");
202
- if (!origin) return boundToLoopback ? null : CROSS_ORIGIN_REFUSAL;
203
-
204
- let originHost: string | null = null;
205
- try {
206
- // "null" (sandboxed iframes, some redirects) is a real Origin value; the
207
- // URL constructor throws on it, which is the behaviour we want.
208
- originHost = new URL(origin).host.toLowerCase();
209
- } catch {
210
- originHost = null;
211
- }
212
- return originHost && originHost === (hostHeader ?? "").toLowerCase() ? null : CROSS_ORIGIN_REFUSAL;
213
- }
214
-
215
- /** A base URL reduced to the thing that decides whether a key may travel: its origin. */
216
- function originOf(raw: string): string | null {
217
- if (!raw) return null;
218
- const r = validateBaseUrl(raw);
219
- if (!r.ok) return null;
220
- try {
221
- const o = new URL(r.value).origin;
222
- return o === "null" ? null : o;
223
- } catch {
224
- return null;
225
- }
226
- }
227
-
228
- /**
229
- * `~/.failproofai` at the umask is group-writable on a umask-002 machine, and a
230
- * directory others can write into defeats the file's 0600 — they unlink it and
231
- * leave their own, which every check on the file then passes. The one command
232
- * that puts a key there takes those bits off, so the one PAGE that does must
233
- * too. Exactly the write bits the loader refuses and no more.
234
- */
235
- function tightenConfigDir(path: string): void {
236
- if (process.platform === "win32") return;
237
- const dir = dirname(path);
238
- try {
239
- const before = statSync(dir).mode & 0o777;
240
- if ((before & 0o022) !== 0) chmodSync(dir, before & ~0o022);
241
- } catch {
242
- // Not fatal: the loader reports a directory it will not read from, and the
243
- // panel shows that reason.
244
- }
245
- }
246
-
247
- /**
248
- * Save the Jev configuration, exactly as `failproofai jev setup` would.
249
- *
250
- * Returns the re-read view on success rather than echoing the input, so the
251
- * panel confirms against what is actually on disk — including the permissions,
252
- * the resolved endpoint and the provider default model it did not type.
253
- */
254
- export async function saveJevConfigAction(input: JevConfigInput): Promise<JevWriteResult> {
255
- const refusal = await crossOriginRefusal();
256
- if (refusal) return { ok: false, problem: refusal };
257
-
258
- const provider = input.provider.trim();
259
- if (!(JEV_PROVIDER_KINDS as readonly string[]).includes(provider)) {
260
- return { ok: false, problem: `provider must be one of ${JEV_PROVIDER_KINDS.join(", ")}` };
261
- }
262
-
263
- const baseUrl = input.baseUrl.trim();
264
- if (baseUrl) {
265
- // Checked here, before anything is decided about the token, so an
266
- // unparseable URL is reported as an unparseable URL rather than as "that
267
- // endpoint is not the one the token was given for" — which is what a URL
268
- // that resolves to no origin would otherwise look like below.
269
- const url = validateBaseUrl(baseUrl);
270
- if (!url.ok) return { ok: false, problem: url.problem };
271
- }
272
-
273
- const existingFile = readJevConfigFileForUpdate();
274
- const existing = existingFile?.raw ?? null;
275
- const sameProvider = existing !== null && existing.provider === provider;
276
-
277
- // Same provider: update in place, keeping every field not named here —
278
- // `model`, a `timeoutMs` set from the CLI, and ones a newer failproofai wrote,
279
- // none of which this form knows about or may drop. A different provider starts
280
- // over: a key, model or URL for one gateway means nothing to another. Mode and
281
- // timeout are provider-neutral, so they carry across, exactly as `jev setup`
282
- // carries them.
283
- const next: Record<string, unknown> = sameProvider ? { ...existing } : {};
284
- if (!sameProvider && existing) {
285
- if (existing.mode !== undefined) next.mode = existing.mode;
286
- if (existing.timeoutMs !== undefined) next.timeoutMs = existing.timeoutMs;
287
- }
288
- next.provider = provider;
289
-
290
- if (baseUrl) next.baseUrl = baseUrl;
291
- else delete next.baseUrl;
292
-
293
- // `model` is NOT touched here, and that is the point: `JevConfigInput` has no
294
- // model, so the spread above is the whole story for it. The CLI's `setOrClear`
295
- // clears a field only for `--model default`, which is a thing a person typed;
296
- // an empty input from a form that never offered the field is not.
297
-
298
- const accountId = input.accountId.trim();
299
- if (provider === "cloudflare") {
300
- if (accountId) next.accountId = accountId;
301
- else delete next.accountId;
302
- } else {
303
- // An account id means nothing anywhere else, and leaving a stale one behind
304
- // would show up in `jev status` as a field this provider ignores.
305
- delete next.accountId;
306
- }
307
-
308
- if (input.mode === "shadow" || input.mode === "enforce") next.mode = input.mode;
309
-
310
- // Where the key may travel. Unchanged provider AND unchanged origin, from a
311
- // file only its owner could have written — anything else asks again.
312
- const routeHeld =
313
- sameProvider &&
314
- existingFile?.tooOpen !== true &&
315
- originOf(baseUrl) === originOf(typeof existing?.baseUrl === "string" ? existing.baseUrl : "");
316
-
317
- /** Whether the file has a key in it at all. */
318
- const storesKey = typeof existing?.apiKey === "string" && existing.apiKey !== "";
319
-
320
- /**
321
- * Whether the file being updated is one whose owner chose to keep the key OUT
322
- * of it — `jev setup --key-from-env`, which the loader reports as
323
- * `key-missing`, or as `ok` with `keySource: "env"` where the variable is set.
324
- *
325
- * Every refusal below is about a STORED key being carried somewhere it was not
326
- * issued for, and there is none here: a hook reads
327
- * `FAILPROOFAI_JEV_API_KEY` at the moment it runs, so the endpoint, the
328
- * provider and the mode can all be edited with the token field left blank and
329
- * nothing moves.
330
- *
331
- * It is the loader's own validator that decides, with a stand-in in the one
332
- * slot that is deliberately empty — so a file that is merely BROKEN, and a
333
- * machine with no file at all, are not mistaken for a deliberate choice and
334
- * silently saved without any key. Those still ask for the token.
335
- */
336
- const keyFromEnvConfig =
337
- existing !== null && !storesKey && validateJevConfig(existing, ENV_KEY_STAND_IN).ok;
338
-
339
- const token = input.token.trim();
340
- if (token) {
341
- const bad = validateApiKey(token);
342
- if (bad) return { ok: false, problem: bad, needsToken: true };
343
- next.apiKey = token;
344
- } else if (!routeHeld && !keyFromEnvConfig) {
345
- return {
346
- ok: false,
347
- needsToken: true,
348
- problem: !storesKey
349
- ? // Nothing stored to carry and no deliberate absence to preserve: the
350
- // only thing missing is a key, and no sentence here may imply there
351
- // is one on disk.
352
- "enter the token for this provider."
353
- : sameProvider && existingFile?.tooOpen === true
354
- ? // The loader's "someone else may have chosen this endpoint" case. The
355
- // stored token is not carried anywhere from a file other users could
356
- // have written, whatever endpoint it names.
357
- `${jevConfigPath()} was open to other users, so the endpoint it names may not be one you chose and its stored token is not reused. check the endpoint above, then enter the token for it.`
358
- : sameProvider
359
- ? "that endpoint is not the one the stored token was given for, so it is not sent there. enter the token for it."
360
- : "enter the token for this provider.",
361
- };
362
- }
363
- // Otherwise the key stays exactly where it is: a stored one is carried over by
364
- // the spread above, and a config that takes it from the environment keeps
365
- // taking it from the environment.
366
-
367
- // A config with no stored key takes it from `FAILPROOFAI_JEV_API_KEY` when a
368
- // hook runs. That is a shape `jev setup --key-from-env` writes and this
369
- // surface preserves but never creates, so the rest of the file still has to
370
- // be checked — hence a stand-in in the one slot that is deliberately empty.
371
- // It is never written and never sent.
372
- const keyFromEnv = next.apiKey === undefined;
373
- const checked = validateJevConfig(next, keyFromEnv ? ENV_KEY_STAND_IN : null);
374
- if (!checked.ok) {
375
- return {
376
- ok: false,
377
- problem: checked.problem,
378
- ...(checked.missingKey === true ? { needsToken: true as const } : {}),
379
- };
380
- }
381
-
382
- const path = jevConfigPath();
383
- try {
384
- writeJsonAtomically(path, next, { mode: 0o600, dirMode: 0o700 });
385
- } catch (err) {
386
- return {
387
- ok: false,
388
- problem: `could not write ${path} (${(err as NodeJS.ErrnoException).code ?? "error"}).`,
389
- };
390
- }
391
- tightenConfigDir(path);
392
-
393
- return { ok: true, view: await getJevSettingsAction() };
394
- }
395
-
396
- /**
397
- * Delete `~/.failproofai/jev.json`. Hooks go back to the regex engine on the
398
- * very next tool call — the loader reads the file per event, so there is
399
- * nothing to restart and nothing to un-cache.
400
- *
401
- * Removing a file that is not there succeeds: the user asked for Jev to be off,
402
- * and it is.
403
- */
404
- export async function removeJevConfigAction(): Promise<JevWriteResult> {
405
- const refusal = await crossOriginRefusal();
406
- if (refusal) return { ok: false, problem: refusal };
407
-
408
- const path = jevConfigPath();
409
- if (existsSync(path)) {
410
- try {
411
- unlinkSync(path);
412
- } catch (err) {
413
- return {
414
- ok: false,
415
- problem: `could not remove ${path} (${(err as NodeJS.ErrnoException).code ?? "error"}).`,
416
- };
417
- }
418
- }
419
- return { ok: true, view: await getJevSettingsAction() };
420
- }
@@ -1,96 +0,0 @@
1
- "use client";
2
-
3
- /**
4
- * The activity view's rendering of what Jev (the two-tier evaluator) did on a
5
- * row.
6
- *
7
- * Only the rows where Jev changed or could have changed something get a pill:
8
- * a clear (a regex deny Jev overruled), a fallback (Jev's answer was not used —
9
- * unavailable, truncated or mismatched — and the regex policies decided alone),
10
- * and a shadow-mode row where Jev disagreed with what was enforced. A fallback
11
- * where Jev did answer (the call was truncated to fit the envelope) and its
12
- * unapplied verdict was stricter than what was enforced gets a louder fallback
13
- * pill; the collector ships that row on its own for the same reason.
14
- *
15
- * An ordinary Jev allow gets none — on a configured machine
16
- * that is nearly every row, and a pill on all of them marks nothing. Nor does a
17
- * hard deny Jev was never consulted on, or a call no semantic policy applied
18
- * to: the detail panel says so, but the row is an ordinary regex result.
19
- */
20
- import { describeJevActivity, jevOutcome, sanitizeJevActivity, type JevActivityFields } from "@/src/hooks/jev-activity";
21
-
22
- type JevRow = JevActivityFields & { decision?: string };
23
-
24
- const SEVERITY: Record<string, number> = { allow: 0, instruct: 1, deny: 2 };
25
-
26
- /** Which pill a row gets, if any. Exported for tests. */
27
- export function jevPillKind(
28
- item: JevRow,
29
- ): "cleared" | "would-clear" | "fallback" | "fallback-stricter" | "shadow-stricter" | null {
30
- const e = sanitizeJevActivity(item);
31
- const outcome = jevOutcome(e);
32
- if (outcome === null || outcome === "not-consulted" || outcome === "no-request") return null;
33
- const jevWasStricter = () => (SEVERITY[e.jevDecision ?? "allow"] ?? 0) > (SEVERITY[item.decision ?? "allow"] ?? 0);
34
- if (outcome === "fallback") return e.jevDecision !== undefined && jevWasStricter() ? "fallback-stricter" : "fallback";
35
- const cleared = (e.jevCleared ?? []).length > 0;
36
- if (e.jevMode === "shadow") {
37
- if (cleared) return "would-clear";
38
- return jevWasStricter() ? "shadow-stricter" : null;
39
- }
40
- return cleared ? "cleared" : null;
41
- }
42
-
43
- const PILLS = {
44
- cleared: {
45
- label: "jev cleared",
46
- title: "Jev reviewed a reviewable policy's block and cleared it",
47
- className: "border-sky-500/40 bg-sky-500/10 text-sky-600 dark:text-sky-400",
48
- },
49
- "would-clear": {
50
- label: "jev shadow",
51
- title: "Shadow mode: Jev would have cleared a block here; the regex result was enforced",
52
- className: "border-sky-500/30 bg-sky-500/5 text-sky-600/80 dark:text-sky-400/80",
53
- },
54
- "shadow-stricter": {
55
- label: "jev shadow",
56
- title: "Shadow mode: Jev would have been stricter here; the regex result was enforced",
57
- className: "border-sky-500/30 bg-sky-500/5 text-sky-600/80 dark:text-sky-400/80",
58
- },
59
- "fallback-stricter": {
60
- label: "jev fallback",
61
- title: "Jev answered but its answer was not applied (e.g. the call was truncated); it would have been stricter than the regex result",
62
- className: "border-amber-500/40 bg-amber-500/10 text-amber-600 dark:text-amber-400",
63
- },
64
- fallback: {
65
- label: "jev fallback",
66
- title: "Jev's answer was not used for this call (unavailable, truncated or mismatched); the regex policies decided alone",
67
- className: "border-muted-foreground/30 bg-muted/40 text-muted-foreground",
68
- },
69
- } as const;
70
-
71
- /** Marks a row where Jev cleared, fell back, or (in shadow mode) disagreed. */
72
- export function JevPill({ item }: { item: JevRow }) {
73
- const kind = jevPillKind(item);
74
- if (!kind) return null;
75
- const pill = PILLS[kind];
76
- return (
77
- <span
78
- title={pill.title}
79
- className={`ml-1.5 inline-flex items-center rounded px-1.5 py-0.5 text-[0.6rem] font-medium uppercase tracking-wide border ${pill.className}`}
80
- >
81
- {pill.label}
82
- </span>
83
- );
84
- }
85
-
86
- /** The detail-panel line: what Jev said, cleared, or why it fell back. */
87
- export function JevNote({ item }: { item: JevRow }) {
88
- const facts = describeJevActivity(item);
89
- if (!facts) return null;
90
- return (
91
- <div className="sm:col-span-2 lg:col-span-3">
92
- <span className="text-muted-foreground">Semantic review: </span>
93
- <span className="font-mono text-foreground">{facts.join(" · ")}</span>
94
- </div>
95
- );
96
- }