failproofai 1.0.7-beta.0 → 1.0.7-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  6. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  7. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  10. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
  11. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.rsc +15 -15
  18. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +15 -15
  19. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +14 -14
  20. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  21. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
  30. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  32. package/.next/standalone/.next/server/app/index.html +1 -1
  33. package/.next/standalone/.next/server/app/index.rsc +15 -15
  34. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +14 -14
  35. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +15 -15
  36. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  37. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  38. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  40. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
  41. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  43. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  44. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  46. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  47. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  48. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  50. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  51. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  53. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +7 -7
  54. package/.next/standalone/.next/server/app/settings/page.js +2 -2
  55. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  57. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0l3yhx4._.js +2 -2
  58. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
  59. package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
  60. package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
  61. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
  62. package/.next/standalone/.next/server/chunks/src_hooks_18qtd42._.js +1 -1
  63. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__04usis8._.js +2 -2
  64. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__056wjo4._.js +2 -2
  65. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1p28m0u._.js → [root-of-the-server]__0l44ual._.js} +2 -2
  66. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0n0xg95._.js +2 -2
  67. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0rwtwpm._.js +2 -2
  68. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s_yomn._.js +2 -2
  69. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11mayhe._.js +2 -2
  70. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1pprgri._.js +2 -2
  71. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1q4p5b8._.js +2 -2
  72. package/.next/standalone/.next/server/chunks/ssr/_042cgl1._.js +1 -1
  73. package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
  74. package/.next/standalone/.next/server/chunks/ssr/_0bqoto4._.js +1 -1
  75. package/.next/standalone/.next/server/chunks/ssr/{_0cf1olg._.js → _1mel6y1._.js} +2 -2
  76. package/.next/standalone/.next/server/chunks/ssr/{_135-c3y._.js → _1v-jvrv._.js} +1 -1
  77. package/.next/standalone/.next/server/chunks/ssr/_1zopuov._.js +1 -1
  78. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +2 -2
  79. package/.next/standalone/.next/server/chunks/ssr/app_actions_get-scheduled-audit_ts_0ei9sni._.js +1 -1
  80. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
  81. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
  82. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
  83. package/.next/standalone/.next/server/chunks/ssr/app_settings_02tf1h4._.js +1 -1
  84. package/.next/standalone/.next/server/chunks/ssr/src_hooks_15t8kqj._.js +1 -1
  85. package/.next/standalone/.next/server/chunks/ssr/src_hooks_1fm2w5z._.js +1 -1
  86. package/.next/standalone/.next/server/chunks/ssr/src_hooks_1j0zy3v._.js +1 -1
  87. package/.next/standalone/.next/server/chunks/ssr/src_hooks_builtin-policies_ts_09j2ndl._.js +1 -1
  88. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  89. package/.next/standalone/.next/server/pages/404.html +1 -1
  90. package/.next/standalone/.next/server/pages/500.html +1 -1
  91. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  92. package/.next/standalone/.next/server/server-reference-manifest.json +22 -22
  93. package/.next/standalone/.next/static/chunks/043j99m8ykg__.css +2 -0
  94. package/.next/standalone/.next/static/chunks/{0289oapk24zql.js → 0fqd7m_u81mi5.js} +1 -1
  95. package/.next/standalone/.next/static/chunks/{2tqszh84mp_2l.js → 129ag2bw93bdh.js} +1 -1
  96. package/.next/standalone/.next/static/chunks/{0pyy9m5cm8zku.js → 1qd741hzlmjbo.js} +1 -1
  97. package/.next/standalone/.next/static/chunks/{3vwnzfx9q80yl.js → 2_pltstd8-xgs.js} +1 -1
  98. package/.next/standalone/.next/static/chunks/{3vp7c3knkh8mr.js → 2c8j9l6j_b1ci.js} +1 -1
  99. package/.next/standalone/.next/static/chunks/3-k569wzcli8q.js +1 -0
  100. package/.next/standalone/.next/static/chunks/{3cdkxrukvlvul.js → 3brze37td_wnc.js} +1 -1
  101. package/.next/standalone/.next/static/chunks/{3dnd-_29uiaj3.js → 3otmypm6j_xfo.js} +2 -2
  102. package/.next/standalone/.next/static/chunks/{00i9thnpht4l1.js → 3ugmd_7dyn0id.js} +1 -1
  103. package/.next/standalone/.next/static/chunks/3yxro_r2_o9ad.js +69 -0
  104. package/.next/standalone/PROBE-FOLLOWUP.md +186 -0
  105. package/.next/standalone/app/actions/get-jev-config.ts +38 -23
  106. package/.next/standalone/app/actions/update-jev-config.ts +1 -1
  107. package/.next/standalone/app/settings/jev-panel.tsx +33 -29
  108. package/.next/standalone/package.json +10 -10
  109. package/.next/standalone/sdk/python/skill/SKILL.md +60 -14
  110. package/.next/standalone/sdk/python/skill/agents/openai.yaml +2 -1
  111. package/.next/standalone/sdk/python/skill/references/evaluator.md +255 -0
  112. package/.next/standalone/sdk/python/skill/references/events.md +17 -8
  113. package/.next/standalone/sdk/python/skill/references/frameworks.md +3 -0
  114. package/.next/standalone/sdk/python/skill/references/install.md +3 -0
  115. package/.next/standalone/sdk/python/skill/references/integration.md +6 -2
  116. package/.next/standalone/sdk/python/skill/references/typescript.md +568 -0
  117. package/.next/standalone/sdk/typescript/CHANGELOG.md +119 -0
  118. package/.next/standalone/sdk/typescript/LICENSE +42 -0
  119. package/.next/standalone/sdk/typescript/README.md +552 -0
  120. package/.next/standalone/sdk/typescript/eslint.config.mjs +59 -0
  121. package/.next/standalone/sdk/typescript/examples/research-agent.ts +197 -0
  122. package/.next/standalone/sdk/typescript/integration/ai.test.ts +920 -0
  123. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/agent.ts +337 -0
  124. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/package-lock.json +281 -0
  125. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/package.json +13 -0
  126. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/surfaces.ts +605 -0
  127. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/tsconfig.json +12 -0
  128. package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/tsconfig.surfaces.json +4 -0
  129. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/agent.ts +342 -0
  130. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/package-lock.json +168 -0
  131. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/package.json +13 -0
  132. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/surfaces.ts +628 -0
  133. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/tsconfig.json +12 -0
  134. package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/tsconfig.surfaces.json +4 -0
  135. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/agent.ts +346 -0
  136. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/package-lock.json +156 -0
  137. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/package.json +13 -0
  138. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/surfaces.ts +651 -0
  139. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/tsconfig.json +12 -0
  140. package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/tsconfig.surfaces.json +4 -0
  141. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/agent.ts +350 -0
  142. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/package-lock.json +153 -0
  143. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/package.json +13 -0
  144. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/surfaces.ts +651 -0
  145. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/tsconfig.json +12 -0
  146. package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/tsconfig.surfaces.json +4 -0
  147. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/agent.ts +623 -0
  148. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/package-lock.json +463 -0
  149. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/package.json +15 -0
  150. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/tsconfig.json +12 -0
  151. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/agent-v1.ts +99 -0
  152. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/agent.ts +623 -0
  153. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/package-lock.json +336 -0
  154. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/package.json +15 -0
  155. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/tsconfig.json +12 -0
  156. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/agent.ts +96 -0
  157. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/package-lock.json +579 -0
  158. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/package.json +15 -0
  159. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/tsconfig.json +12 -0
  160. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/vendor/lc-weather-provider/index.cjs +53 -0
  161. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/vendor/lc-weather-provider/index.mjs +55 -0
  162. package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/vendor/lc-weather-provider/package.json +18 -0
  163. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/agent.ts +659 -0
  164. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/package-lock.json +635 -0
  165. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/package.json +15 -0
  166. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/tsconfig.json +12 -0
  167. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/agent.ts +659 -0
  168. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/package-lock.json +553 -0
  169. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/package.json +15 -0
  170. package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/tsconfig.json +12 -0
  171. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/agent.ts +877 -0
  172. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/mcp-server.mjs +66 -0
  173. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/package-lock.json +6417 -0
  174. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/package.json +15 -0
  175. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/tsconfig.json +12 -0
  176. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/agent.ts +872 -0
  177. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/mcp-server.mjs +66 -0
  178. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/package-lock.json +2540 -0
  179. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/package.json +15 -0
  180. package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/tsconfig.json +12 -0
  181. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/actions.ts +18 -0
  182. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/ai/route.ts +42 -0
  183. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/edge/route.ts +29 -0
  184. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/langgraph/route.ts +21 -0
  185. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/llamaindex/route.ts +11 -0
  186. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/mastra/route.ts +19 -0
  187. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/status/route.ts +7 -0
  188. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/layout.tsx +9 -0
  189. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/page.tsx +15 -0
  190. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/instrumentation.ts +15 -0
  191. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/ai.ts +61 -0
  192. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/langgraph.ts +68 -0
  193. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/llamaindex.ts +98 -0
  194. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/mastra.ts +90 -0
  195. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/next.config.ts +52 -0
  196. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/package-lock.json +4343 -0
  197. package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/package.json +28 -0
  198. package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/agent.ts +51 -0
  199. package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/deno-npm.ts +76 -0
  200. package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/package-lock.json +484 -0
  201. package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/package.json +15 -0
  202. package/.next/standalone/sdk/typescript/integration/fixtures/types/agent.ts +79 -0
  203. package/.next/standalone/sdk/typescript/integration/fixtures/types/package-lock.json +740 -0
  204. package/.next/standalone/sdk/typescript/integration/fixtures/types/package.json +11 -0
  205. package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/agent.ts +197 -0
  206. package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/package-lock.json +70 -0
  207. package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/package.json +12 -0
  208. package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/tsconfig.json +12 -0
  209. package/.next/standalone/sdk/typescript/integration/global-setup.ts +29 -0
  210. package/.next/standalone/sdk/typescript/integration/harness.ts +451 -0
  211. package/.next/standalone/sdk/typescript/integration/langchain.test.ts +682 -0
  212. package/.next/standalone/sdk/typescript/integration/llamaindex.test.ts +709 -0
  213. package/.next/standalone/sdk/typescript/integration/mastra-coverage.test.ts +386 -0
  214. package/.next/standalone/sdk/typescript/integration/mastra.test.ts +311 -0
  215. package/.next/standalone/sdk/typescript/integration/nextjs.test.ts +341 -0
  216. package/.next/standalone/sdk/typescript/integration/runtime-parity.ts +180 -0
  217. package/.next/standalone/sdk/typescript/integration/runtimes.bun.test.ts +15 -0
  218. package/.next/standalone/sdk/typescript/integration/runtimes.core.test.ts +113 -0
  219. package/.next/standalone/sdk/typescript/integration/runtimes.deno.test.ts +19 -0
  220. package/.next/standalone/sdk/typescript/integration/types.test.ts +141 -0
  221. package/.next/standalone/sdk/typescript/integration/vanilla.test.ts +255 -0
  222. package/.next/standalone/sdk/typescript/package-lock.json +2640 -0
  223. package/.next/standalone/sdk/typescript/package.json +401 -0
  224. package/.next/standalone/sdk/typescript/scripts/finalize-build.mjs +123 -0
  225. package/.next/standalone/sdk/typescript/scripts/release.mjs +177 -0
  226. package/.next/standalone/sdk/typescript/src/clock.ts +58 -0
  227. package/.next/standalone/sdk/typescript/src/context.ts +214 -0
  228. package/.next/standalone/sdk/typescript/src/edge/adapter.ts +18 -0
  229. package/.next/standalone/sdk/typescript/src/edge/ai.ts +116 -0
  230. package/.next/standalone/sdk/typescript/src/edge/index.ts +238 -0
  231. package/.next/standalone/sdk/typescript/src/edge/langchain.ts +18 -0
  232. package/.next/standalone/sdk/typescript/src/edge/llamaindex.ts +12 -0
  233. package/.next/standalone/sdk/typescript/src/edge/mastra.ts +17 -0
  234. package/.next/standalone/sdk/typescript/src/edge/notice.ts +33 -0
  235. package/.next/standalone/sdk/typescript/src/environment.ts +75 -0
  236. package/.next/standalone/sdk/typescript/src/evaluator/authoring.ts +480 -0
  237. package/.next/standalone/sdk/typescript/src/evaluator/cli.ts +96 -0
  238. package/.next/standalone/sdk/typescript/src/evaluator/client.ts +421 -0
  239. package/.next/standalone/sdk/typescript/src/evaluator/expression.ts +1292 -0
  240. package/.next/standalone/sdk/typescript/src/evaluator/index.ts +144 -0
  241. package/.next/standalone/sdk/typescript/src/evaluator/protocol.ts +747 -0
  242. package/.next/standalone/sdk/typescript/src/evaluator/runtime.ts +930 -0
  243. package/.next/standalone/sdk/typescript/src/evaluator/sandbox-worker.ts +171 -0
  244. package/.next/standalone/sdk/typescript/src/evaluator/source-limits.ts +27 -0
  245. package/.next/standalone/sdk/typescript/src/evaluator/source.ts +509 -0
  246. package/.next/standalone/sdk/typescript/src/events.ts +879 -0
  247. package/.next/standalone/sdk/typescript/src/exit.ts +117 -0
  248. package/.next/standalone/sdk/typescript/src/index.ts +186 -0
  249. package/.next/standalone/sdk/typescript/src/integrations/ai.ts +1566 -0
  250. package/.next/standalone/sdk/typescript/src/integrations/compat.ts +322 -0
  251. package/.next/standalone/sdk/typescript/src/integrations/core.ts +1321 -0
  252. package/.next/standalone/sdk/typescript/src/integrations/index.ts +355 -0
  253. package/.next/standalone/sdk/typescript/src/integrations/langchain.ts +2340 -0
  254. package/.next/standalone/sdk/typescript/src/integrations/llamaindex.ts +2111 -0
  255. package/.next/standalone/sdk/typescript/src/integrations/mastra.ts +1802 -0
  256. package/.next/standalone/sdk/typescript/src/logger.ts +98 -0
  257. package/.next/standalone/sdk/typescript/src/next.ts +115 -0
  258. package/.next/standalone/sdk/typescript/src/node-require.ts +446 -0
  259. package/.next/standalone/sdk/typescript/src/redact.ts +305 -0
  260. package/.next/standalone/sdk/typescript/src/resolver.ts +120 -0
  261. package/.next/standalone/sdk/typescript/src/runtime.ts +29 -0
  262. package/.next/standalone/sdk/typescript/src/schema.ts +410 -0
  263. package/.next/standalone/sdk/typescript/src/scopes.ts +701 -0
  264. package/.next/standalone/sdk/typescript/src/shared.ts +33 -0
  265. package/.next/standalone/sdk/typescript/src/version.ts +5 -0
  266. package/.next/standalone/sdk/typescript/src/writer.ts +934 -0
  267. package/.next/standalone/sdk/typescript/test/adapters.test.ts +397 -0
  268. package/.next/standalone/sdk/typescript/test/ai.test.ts +1076 -0
  269. package/.next/standalone/sdk/typescript/test/copies.test.ts +204 -0
  270. package/.next/standalone/sdk/typescript/test/edge.test.ts +183 -0
  271. package/.next/standalone/sdk/typescript/test/evaluator-client.test.ts +234 -0
  272. package/.next/standalone/sdk/typescript/test/evaluator-protocol.test.ts +225 -0
  273. package/.next/standalone/sdk/typescript/test/events.test.ts +193 -0
  274. package/.next/standalone/sdk/typescript/test/expression.test.ts +181 -0
  275. package/.next/standalone/sdk/typescript/test/global-setup.ts +26 -0
  276. package/.next/standalone/sdk/typescript/test/helpers.ts +130 -0
  277. package/.next/standalone/sdk/typescript/test/integrations.test.ts +369 -0
  278. package/.next/standalone/sdk/typescript/test/langchain-copies.test.ts +204 -0
  279. package/.next/standalone/sdk/typescript/test/langchain.test.ts +999 -0
  280. package/.next/standalone/sdk/typescript/test/llamaindex.test.ts +1760 -0
  281. package/.next/standalone/sdk/typescript/test/mastra-coverage.test.ts +501 -0
  282. package/.next/standalone/sdk/typescript/test/mastra-lifecycle.test.ts +479 -0
  283. package/.next/standalone/sdk/typescript/test/mastra.test.ts +285 -0
  284. package/.next/standalone/sdk/typescript/test/next.test.ts +109 -0
  285. package/.next/standalone/sdk/typescript/test/packaging.test.ts +312 -0
  286. package/.next/standalone/sdk/typescript/test/redaction.test.ts +171 -0
  287. package/.next/standalone/sdk/typescript/test/runtimes.test.ts +101 -0
  288. package/.next/standalone/sdk/typescript/test/sandbox.test.ts +189 -0
  289. package/.next/standalone/sdk/typescript/test/scopes.test.ts +271 -0
  290. package/.next/standalone/sdk/typescript/test/setup.ts +19 -0
  291. package/.next/standalone/sdk/typescript/test/skill-snippets.test.ts +73 -0
  292. package/.next/standalone/sdk/typescript/test/spool-contract.test.ts +124 -0
  293. package/.next/standalone/sdk/typescript/test/tracker-bounds.test.ts +191 -0
  294. package/.next/standalone/sdk/typescript/test/wire-format.test.ts +214 -0
  295. package/.next/standalone/sdk/typescript/test/writer.test.ts +407 -0
  296. package/.next/standalone/sdk/typescript/tsconfig.build.json +15 -0
  297. package/.next/standalone/sdk/typescript/tsconfig.cjs.json +19 -0
  298. package/.next/standalone/sdk/typescript/tsconfig.json +28 -0
  299. package/.next/standalone/sdk/typescript/vitest.config.ts +33 -0
  300. package/.next/standalone/sdk/typescript/vitest.integration.config.ts +23 -0
  301. package/.next/standalone/server.js +1 -1
  302. package/README.md +2 -2
  303. package/dist/cli.mjs +225 -30
  304. package/dist/worker.mjs +120 -14
  305. package/package.json +10 -10
  306. package/scripts/build-policy-pack.mjs +14 -0
  307. package/src/audit/features.ts +3 -2
  308. package/src/hooks/builtin-policies.ts +156 -5
  309. package/src/hooks/jev-cli.ts +57 -1
  310. package/src/hooks/manager.ts +1 -1
  311. package/src/hooks/pack-cli.ts +191 -24
  312. package/src/hooks/pack-store.ts +1 -1
  313. package/src/hooks/policy-catalog.ts +148 -9
  314. package/src/hooks/types.ts +1 -1
  315. package/.next/standalone/.next/static/chunks/15heikmy3yjzc.js +0 -1
  316. package/.next/standalone/.next/static/chunks/285spx855h_3r.css +0 -2
  317. package/.next/standalone/.next/static/chunks/2plg9qae1yejv.js +0 -69
  318. /package/.next/standalone/.next/static/{qbVI48kgBOf9CTOKcFIk2 → gbEOjBgZAxF2UIUwZVHNu}/_buildManifest.js +0 -0
  319. /package/.next/standalone/.next/static/{qbVI48kgBOf9CTOKcFIk2 → gbEOjBgZAxF2UIUwZVHNu}/_clientMiddlewareManifest.js +0 -0
  320. /package/.next/standalone/.next/static/{qbVI48kgBOf9CTOKcFIk2 → gbEOjBgZAxF2UIUwZVHNu}/_ssgManifest.js +0 -0
@@ -0,0 +1,204 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
6
+
7
+ import { afterAll, beforeAll, describe, expect, it } from "vitest";
8
+
9
+ import { resolveEsm } from "../src/node-require.js";
10
+
11
+ /**
12
+ * Which copy of a dual-published framework an adapter patches.
13
+ *
14
+ * The first release resolved every framework with `createRequire`, which can
15
+ * only name the CommonJS build — so in an ES-module application, the default
16
+ * for a new TypeScript project, `instrument()` patched a copy nothing used and
17
+ * recorded nothing. These tests build a fake dual package on disk and run
18
+ * `requireModuleCopies` from REAL entry points of each module system, because
19
+ * "which module system is the entry" is a property of the process and cannot be
20
+ * faked from inside a test runner.
21
+ */
22
+
23
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
24
+ let app: string;
25
+
26
+ function write(path: string, text: string): void {
27
+ mkdirSync(dirname(path), { recursive: true });
28
+ writeFileSync(path, text);
29
+ }
30
+
31
+ /** A copy that says which build it is and records that it was loaded. */
32
+ const copy = (marker: string, esm: boolean): string =>
33
+ esm
34
+ ? `globalThis.__loaded = [...(globalThis.__loaded ?? []), "${marker}"];\nexport const marker = "${marker}";\nexport class Thing {}\n`
35
+ : `globalThis.__loaded = [...(globalThis.__loaded ?? []), "${marker}"];\nexports.marker = "${marker}";\nexports.Thing = class Thing {};\n`;
36
+
37
+ beforeAll(() => {
38
+ app = mkdtempSync(join(tmpdir(), "failproofai-copies-"));
39
+ const modules = join(app, "node_modules");
40
+
41
+ // A dual package with a root entry, a subpath and a pattern, conditions
42
+ // nested the way real frameworks publish them (`@langchain/core` does
43
+ // exactly `{ import: { types, default }, require: { types, default } }`).
44
+ write(
45
+ join(modules, "dualfw", "package.json"),
46
+ JSON.stringify({
47
+ name: "dualfw",
48
+ version: "1.2.3",
49
+ exports: {
50
+ ".": { import: { types: "./x.d.ts", default: "./esm/index.js" }, require: "./cjs/index.cjs" },
51
+ "./callbacks/manager": { import: "./esm/manager.js", require: "./cjs/manager.cjs" },
52
+ "./tools/*": { node: { import: "./esm/tools/*.js", require: "./cjs/tools/*.cjs" } },
53
+ },
54
+ }),
55
+ );
56
+ write(join(modules, "dualfw", "esm", "index.js"), copy("esm", true));
57
+ write(join(modules, "dualfw", "cjs", "index.cjs"), copy("cjs", false));
58
+ write(join(modules, "dualfw", "esm", "manager.js"), copy("esm-manager", true));
59
+ write(join(modules, "dualfw", "cjs", "manager.cjs"), copy("cjs-manager", false));
60
+ write(join(modules, "dualfw", "esm", "tools", "search.js"), copy("esm-search", true));
61
+ write(join(modules, "dualfw", "cjs", "tools", "search.cjs"), copy("cjs-search", false));
62
+
63
+ // ESM-only: no `require` condition, so CommonJS resolution cannot find it.
64
+ write(
65
+ join(modules, "@scope", "esmonly", "package.json"),
66
+ JSON.stringify({ name: "@scope/esmonly", exports: { ".": { import: "./index.js" } } }),
67
+ );
68
+ write(join(modules, "@scope", "esmonly", "index.js"), copy("esmonly", true));
69
+
70
+ // No exports map: Node reads `main` for both, so there is one copy.
71
+ write(join(modules, "plainfw", "package.json"), JSON.stringify({ name: "plainfw", main: "main.js" }));
72
+ write(join(modules, "plainfw", "main.js"), copy("plain", false));
73
+ });
74
+
75
+ afterAll(() => {
76
+ rmSync(app, { recursive: true, force: true });
77
+ });
78
+
79
+ describe("resolveEsm", () => {
80
+ const inApp = <T>(fn: () => T): T => {
81
+ const cwd = process.cwd();
82
+ process.chdir(app);
83
+ try {
84
+ return fn();
85
+ } finally {
86
+ process.chdir(cwd);
87
+ }
88
+ };
89
+
90
+ it("names the import build of a dual package, root and subpath", () => {
91
+ inApp(() => {
92
+ expect(resolveEsm("dualfw")).toBe(join(app, "node_modules", "dualfw", "esm", "index.js"));
93
+ expect(resolveEsm("dualfw/callbacks/manager")).toBe(
94
+ join(app, "node_modules", "dualfw", "esm", "manager.js"),
95
+ );
96
+ });
97
+ });
98
+
99
+ it("expands a subpath pattern through nested conditions", () => {
100
+ inApp(() => {
101
+ expect(resolveEsm("dualfw/tools/search")).toBe(
102
+ join(app, "node_modules", "dualfw", "esm", "tools", "search.js"),
103
+ );
104
+ });
105
+ });
106
+
107
+ it("finds an ESM-only package that CommonJS resolution cannot", () => {
108
+ inApp(() => {
109
+ expect(resolveEsm("@scope/esmonly")).toBe(join(app, "node_modules", "@scope", "esmonly", "index.js"));
110
+ });
111
+ });
112
+
113
+ it("returns null where there is no separate ESM copy or no such module", () => {
114
+ inApp(() => {
115
+ expect(resolveEsm("plainfw")).toBeNull();
116
+ expect(resolveEsm("dualfw/not-exported")).toBeNull();
117
+ expect(resolveEsm("not-installed-anywhere")).toBeNull();
118
+ });
119
+ });
120
+ });
121
+
122
+ describe("requireModuleCopies", () => {
123
+ /** Run `body` in a fresh process whose ENTRY is an ES module or CommonJS. */
124
+ const run = (entry: "esm" | "cjs", body: string, where: { dir?: string; cwd?: string } = {}): string[] => {
125
+ const compat =
126
+ entry === "esm"
127
+ ? pathToFileURL(join(root, "dist", "esm", "integrations", "compat.js")).href
128
+ : join(root, "dist", "cjs", "integrations", "compat.js");
129
+ const file = join(where.dir ?? app, entry === "esm" ? "main.mjs" : "main.cjs");
130
+ const header =
131
+ entry === "esm"
132
+ ? `import { createRequire } from "node:module";\nimport * as compat from ${JSON.stringify(compat)};\nconst require = createRequire(import.meta.url);\n`
133
+ : `const compat = require(${JSON.stringify(compat)});\n`;
134
+ write(
135
+ file,
136
+ `${header}(async () => {\n${body}\nconsole.log(JSON.stringify({ result, loaded: globalThis.__loaded ?? [] }));\n})().catch((e) => { console.log(JSON.stringify({ error: String(e.message) })); });\n`,
137
+ );
138
+ const child = spawnSync(process.execPath, [file], { cwd: where.cwd ?? app, encoding: "utf8" });
139
+ expect(child.stderr).toBe("");
140
+ const parsed = JSON.parse(child.stdout.trim()) as { result?: string[]; loaded?: string[]; error?: string };
141
+ if (parsed.error !== undefined) return [`error: ${parsed.error}`];
142
+ return [...parsed.result!, "|", ...parsed.loaded!];
143
+ };
144
+
145
+ const markers = 'const result = (await compat.requireModuleCopies(SPEC, "npm i x")).map((m) => m.marker);';
146
+
147
+ it("patches the ES-module copy for an ES-module app, and loads nothing else", () => {
148
+ expect(run("esm", markers.replace("SPEC", '"dualfw"'))).toEqual(["esm", "|", "esm"]);
149
+ });
150
+
151
+ it("also patches the CommonJS copy when something already required it", () => {
152
+ const body = `require("dualfw");\n${markers.replace("SPEC", '"dualfw"')}`;
153
+ expect(run("esm", body)).toEqual(["esm", "cjs", "|", "cjs", "esm"]);
154
+ });
155
+
156
+ it("patches the CommonJS copy for a CommonJS app, without loading the ESM build", () => {
157
+ expect(run("cjs", markers.replace("SPEC", '"dualfw"'))).toEqual(["cjs", "|", "cjs"]);
158
+ expect(run("cjs", markers.replace("SPEC", '"dualfw/callbacks/manager"'))).toEqual([
159
+ "cjs-manager",
160
+ "|",
161
+ "cjs-manager",
162
+ ]);
163
+ });
164
+
165
+ it("uses the one copy an ESM-only or exports-less package has", () => {
166
+ expect(run("esm", markers.replace("SPEC", '"@scope/esmonly"'))).toEqual(["esmonly", "|", "esmonly"]);
167
+ expect(run("cjs", markers.replace("SPEC", '"@scope/esmonly"'))).toEqual(["esmonly", "|", "esmonly"]);
168
+ expect(run("esm", markers.replace("SPEC", '"plainfw"'))).toEqual(["plain", "|", "plain"]);
169
+ });
170
+
171
+ it("finds the framework from the entry script when the service runs from /", () => {
172
+ // systemd with no WorkingDirectory=, a container with WORKDIR unset.
173
+ expect(run("esm", markers.replace("SPEC", '"dualfw"'), { cwd: "/" })).toEqual(["esm", "|", "esm"]);
174
+ expect(run("cjs", markers.replace("SPEC", '"dualfw"'), { cwd: "/" })).toEqual(["cjs", "|", "cjs"]);
175
+ });
176
+
177
+ it("patches the app's own nested copy, not the one a monorepo root hoists", () => {
178
+ // root/node_modules/dualfw is the hoisted copy; root/apps/web has its own.
179
+ const web = join(app, "apps", "web");
180
+ const nested = join(web, "node_modules", "dualfw");
181
+ write(
182
+ join(nested, "package.json"),
183
+ JSON.stringify({ name: "dualfw", exports: { ".": { import: "./esm.js", require: "./cjs.cjs" } } }),
184
+ );
185
+ write(join(nested, "esm.js"), copy("nested-esm", true));
186
+ write(join(nested, "cjs.cjs"), copy("nested-cjs", false));
187
+ // Started from the monorepo root, as a root-level script runner does.
188
+ expect(run("esm", markers.replace("SPEC", '"dualfw"'), { dir: web, cwd: app })).toEqual([
189
+ "nested-esm",
190
+ "|",
191
+ "nested-esm",
192
+ ]);
193
+ expect(run("cjs", markers.replace("SPEC", '"dualfw"'), { dir: web, cwd: app })).toEqual([
194
+ "nested-cjs",
195
+ "|",
196
+ "nested-cjs",
197
+ ]);
198
+ });
199
+
200
+ it("throws with the install command when the framework is absent", () => {
201
+ const [line] = run("esm", markers.replace("SPEC", '"not-installed-anywhere"'));
202
+ expect(line).toMatch(/not importable\. Install it with: {2}npm i x/);
203
+ });
204
+ });
@@ -0,0 +1,183 @@
1
+ import { readFileSync, readdirSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ import { afterEach, describe, expect, it, vi } from "vitest";
6
+
7
+ import * as edge from "../src/edge/index.js";
8
+ import { EDGE_NOTICE, resetNotice } from "../src/edge/notice.js";
9
+
10
+ /**
11
+ * The no-op build an Edge / Worker runtime or a browser bundle gets through the
12
+ * `edge-light` / `workerd` / `worker` / `browser` export conditions.
13
+ *
14
+ * Found by `integration/nextjs.test.ts`: a Next.js route with
15
+ * `export const runtime = "edge"` importing the SDK failed `next build`
16
+ * outright — "Native module not found: node:fs" — because the real entry
17
+ * statically imports Node builtins and an ES module cannot catch that.
18
+ */
19
+
20
+ const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
21
+ const edgeDir = join(root, "src", "edge");
22
+
23
+ afterEach(() => {
24
+ resetNotice();
25
+ vi.restoreAllMocks();
26
+ });
27
+
28
+ describe("the edge build's imports", () => {
29
+ it("imports no Node builtin and nothing from the Node build but VERSION and types", () => {
30
+ for (const file of readdirSync(edgeDir).filter((name) => name.endsWith(".ts"))) {
31
+ const source = readFileSync(join(edgeDir, file), "utf8");
32
+ const imports = [...source.matchAll(/^import\s+(type\s+)?[^;]*?from\s+"([^"]+)";/gms)].map((m) => ({
33
+ typeOnly: m[1] !== undefined,
34
+ from: m[2]!,
35
+ }));
36
+ for (const { typeOnly, from } of imports) {
37
+ if (typeOnly) continue;
38
+ const allowed = from.startsWith("./") || from === "../version.js";
39
+ expect(allowed, `${file} imports ${from} at run time`).toBe(true);
40
+ }
41
+ expect(source, file).not.toMatch(/\bprocess\./);
42
+ expect(source, file).not.toMatch(/require\(/);
43
+ }
44
+ });
45
+ });
46
+
47
+ /**
48
+ * Exports of the Node build that are internals (test helpers, parsing
49
+ * functions) rather than API; an edge module need not mirror them. Anything
50
+ * NOT listed here must exist in the edge build, or an Edge import of it is a
51
+ * link error — the crash this build exists to prevent.
52
+ */
53
+ const INTERNAL: Record<string, string[]> = {
54
+ index: [],
55
+ ai: ["toolCallsOf", "_internals", "usageTokens", "stopReasonOf", "responseContent"],
56
+ langchain: [
57
+ "ABANDONED_ROOT_GRACE_MS",
58
+ "PAUSED_SESSION_TTL_MS",
59
+ "_stats",
60
+ "captureLimitOf",
61
+ "interruptIdOf",
62
+ "isCancellation",
63
+ "isControlFlow",
64
+ "nodeOf",
65
+ "normalizeMessages",
66
+ "resetOrphanWarning",
67
+ "promptOf",
68
+ "readOptions",
69
+ "summarizeDocuments",
70
+ "toolOutput",
71
+ "usageOf",
72
+ ],
73
+ mastra: ["_internals"],
74
+ llamaindex: ["BELOW_VERSION", "MIN_VERSION", "eventCallerStorage", "parseOptions", "summarizeNodes", "usageOf"],
75
+ };
76
+
77
+ const PAIRS: Array<[string, () => Promise<Record<string, unknown>>, () => Promise<Record<string, unknown>>]> = [
78
+ ["index", () => import("../src/index.js"), () => import("../src/edge/index.js")],
79
+ ["ai", () => import("../src/integrations/ai.js"), () => import("../src/edge/ai.js")],
80
+ ["langchain", () => import("../src/integrations/langchain.js"), () => import("../src/edge/langchain.js")],
81
+ ["mastra", () => import("../src/integrations/mastra.js"), () => import("../src/edge/mastra.js")],
82
+ ["llamaindex", () => import("../src/integrations/llamaindex.js"), () => import("../src/edge/llamaindex.js")],
83
+ ];
84
+
85
+ describe.each(PAIRS)("the edge %s module", (name, loadReal, loadEdge) => {
86
+ it("exports every public name the Node build does, as the same kind of value", async () => {
87
+ const real = await loadReal();
88
+ const noop = await loadEdge();
89
+ const missing: string[] = [];
90
+ for (const key of Object.keys(real)) {
91
+ if (INTERNAL[name]!.includes(key)) continue;
92
+ if (!(key in noop)) missing.push(key);
93
+ else expect(typeof noop[key], `${name}.${key}`).toBe(typeof real[key]);
94
+ }
95
+ expect(missing).toEqual([]);
96
+ });
97
+
98
+ it("is what every edge export condition selects", () => {
99
+ const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8")) as {
100
+ exports: Record<string, Record<string, unknown>>;
101
+ };
102
+ const entry = manifest.exports[name === "index" ? "." : `./${name}`]!;
103
+ const conditions = Object.keys(entry);
104
+ // Ahead of import/require: a bundler takes the FIRST condition it matches.
105
+ expect(conditions.slice(0, 4)).toEqual(["edge-light", "workerd", "worker", "browser"]);
106
+ for (const condition of conditions.slice(0, 4)) {
107
+ expect(entry[condition]).toEqual({
108
+ import: { types: expect.any(String), default: `./dist/esm/edge/${name}.js` },
109
+ require: { types: expect.any(String), default: `./dist/cjs/edge/${name}.js` },
110
+ });
111
+ // The REAL declarations, so code that compiles for Node compiles here.
112
+ const real = name === "index" ? "index" : `integrations/${name}`;
113
+ expect((entry[condition] as { import: { types: string } }).import.types).toBe(`./dist/esm/${real}.d.ts`);
114
+ }
115
+ });
116
+ });
117
+
118
+ describe("the edge build's behaviour", () => {
119
+ it("runs scope bodies and returns their values, recording nothing", async () => {
120
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
121
+ const out = await edge.session({ sessionId: "s-1" }, (sessionId) =>
122
+ edge.agent("planner", { goal: "g" }, (identity) =>
123
+ edge.toolCall("search", { toolCallId: "call-1", input: { q: 1 } }, (call) => {
124
+ call.output = 42;
125
+ return { sessionId, agent: identity.agentId, call: call.id, assigned: call.outputAssigned };
126
+ }),
127
+ ),
128
+ );
129
+ expect(out).toEqual({ sessionId: "s-1", agent: "planner", call: "call-1", assigned: true });
130
+ expect(edge.session(() => "no options")).toBe("no options");
131
+ expect(await edge.agent("a", async () => 7)).toBe(7);
132
+
133
+ const scope = edge.agent.open("planner");
134
+ expect(scope.agentId).toBe("planner");
135
+ scope.dispose();
136
+ edge.session.open().dispose();
137
+ edge.toolCall.open("t").dispose();
138
+
139
+ for (const method of Object.keys(edge.event)) {
140
+ expect(() => (edge.event as unknown as Record<string, (o: unknown) => void>)[method]!({})).not.toThrow();
141
+ }
142
+ expect(Object.keys(edge.event)).toHaveLength(15);
143
+ await expect(edge.flush()).resolves.toBeUndefined();
144
+ expect(await edge.instrument()).toEqual([]);
145
+ expect(await (edge.instrument as (name: string) => Promise<unknown[]>)("langchain")).toEqual([]);
146
+ expect(edge.uninstrument()).toEqual([]);
147
+ expect(edge.current().sessionId).toBeNull();
148
+ expect(edge.AUTO).toBe(Symbol.for("failproofai.AUTO"));
149
+
150
+ // Said once, on first use — and it says nothing is recorded.
151
+ expect(warn).toHaveBeenCalledTimes(1);
152
+ expect(warn.mock.calls[0]![0]).toBe(`[failproofai-sdk] ${EDGE_NOTICE}`);
153
+ expect(EDGE_NOTICE).toContain("NOTHING is recorded");
154
+ });
155
+
156
+ it("is silent when merely imported", async () => {
157
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
158
+ await import("../src/edge/ai.js");
159
+ expect(warn).not.toHaveBeenCalled();
160
+ });
161
+
162
+ it("hands the frameworks values they accept and that record nothing", async () => {
163
+ vi.spyOn(console, "warn").mockImplementation(() => {});
164
+ const ai = await import("../src/edge/ai.js");
165
+ expect(ai.telemetry({ functionId: "f" })).toEqual({ isEnabled: false, functionId: "f" });
166
+ const model = { modelId: "m" };
167
+ expect(await ai.wrapModel(model)).toBe(model);
168
+ const mw = ai.middleware();
169
+ expect(await mw.wrapGenerate({ doGenerate: async () => "generated" })).toBe("generated");
170
+ expect(await mw.wrapStream({ doStream: async () => "streamed" })).toBe("streamed");
171
+ const tool = { execute: () => 1 };
172
+ expect(ai.wrapTool("t", tool)).toBe(tool);
173
+ expect(ai.tracer().startActiveSpan("x", (span: { isRecording(): boolean }) => span.isRecording())).toBe(false);
174
+
175
+ const langchain = await import("../src/edge/langchain.js");
176
+ expect(typeof langchain.langchainHandler()).toBe("object");
177
+ const mastra = await import("../src/edge/mastra.js");
178
+ expect(mastra.workflow("w", () => "ran")).toBe("ran");
179
+ expect(mastra.wrapTool(tool)).toBe(tool);
180
+ const llamaindex = await import("../src/edge/llamaindex.js");
181
+ expect(typeof llamaindex.attach()).toBe("function");
182
+ });
183
+ });
@@ -0,0 +1,234 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+
3
+ import { EvaluatorAPIError, EvaluatorClient } from "../src/evaluator/client.js";
4
+ import { PROTOCOL_VERSION } from "../src/evaluator/protocol.js";
5
+
6
+ /**
7
+ * Four properties in here are security or correctness, not style:
8
+ * redirects are refused, every URL is pinned to the configured origin,
9
+ * responses are bounded WHILE they are read, and `claim` is never retried.
10
+ */
11
+
12
+ function jsonResponse(body: unknown, status = 200): Response {
13
+ return new Response(JSON.stringify(body), {
14
+ status,
15
+ headers: { "content-type": "application/json" },
16
+ });
17
+ }
18
+
19
+ function makeClient(options: Partial<ConstructorParameters<typeof EvaluatorClient>[0]> = {}) {
20
+ const fetchImpl = vi.fn(async () =>
21
+ jsonResponse({
22
+ protocol_version: PROTOCOL_VERSION,
23
+ evaluator_instance_id: "i1",
24
+ evaluator_kind: "customer",
25
+ heartbeat_interval_seconds: 30,
26
+ lease_duration_seconds: 120,
27
+ poll_interval_seconds: 10,
28
+ claim_limit: 4,
29
+ disabled_definitions: [],
30
+ }),
31
+ );
32
+ const client = new EvaluatorClient({
33
+ baseUrl: "https://api.example.test",
34
+ credential: "token",
35
+ fetchImpl: fetchImpl,
36
+ sleep: async () => undefined,
37
+ ...options,
38
+ });
39
+ return { client, fetchImpl };
40
+ }
41
+
42
+ describe("construction", () => {
43
+ it("refuses plaintext http to a non-loopback host", () => {
44
+ expect(() => new EvaluatorClient({ baseUrl: "http://api.example.test", credential: "t" })).toThrow(
45
+ /must use https unless it targets loopback/,
46
+ );
47
+ });
48
+
49
+ it("allows http to loopback, where there is no network to eavesdrop", () => {
50
+ for (const host of ["http://localhost:8020", "http://127.0.0.1:8020", "http://[::1]:8020"]) {
51
+ expect(() => new EvaluatorClient({ baseUrl: host, credential: "t" })).not.toThrow();
52
+ }
53
+ });
54
+
55
+ it("refuses a credential that would let a header be injected", () => {
56
+ expect(() =>
57
+ new EvaluatorClient({ baseUrl: "https://a.test", credential: "tok\r\nX-Evil: 1" }),
58
+ ).toThrow(/control characters/);
59
+ expect(() => new EvaluatorClient({ baseUrl: "https://a.test", credential: " " })).toThrow(
60
+ /must not be empty/,
61
+ );
62
+ });
63
+
64
+ it("refuses a non-absolute base url", () => {
65
+ expect(() => new EvaluatorClient({ baseUrl: "/v1", credential: "t" })).toThrow(
66
+ /absolute http\(s\) URL/,
67
+ );
68
+ });
69
+ });
70
+
71
+ describe("requests", () => {
72
+ it("sends the bearer credential and refuses redirects", async () => {
73
+ const { client, fetchImpl } = makeClient();
74
+ await client.register({
75
+ workerId: "w1",
76
+ sdkVersion: "0",
77
+ catalogRevision: "sha256:0",
78
+ maxConcurrency: 1,
79
+ definitions: [],
80
+ });
81
+ const [, init] = fetchImpl.mock.calls[0] as unknown as [string, RequestInit];
82
+ expect((init.headers as Record<string, string>).Authorization).toBe("Bearer token");
83
+ // Following a redirect would carry the Authorization header to wherever it
84
+ // points, which turns a misconfigured server into credential exfiltration.
85
+ expect(init.redirect).toBe("error");
86
+ });
87
+
88
+ it("refuses a server-supplied URL outside the configured origin", async () => {
89
+ const { client } = makeClient();
90
+ await expect(
91
+ client.transcript(
92
+ {
93
+ assignmentId: "a1",
94
+ leaseGeneration: 1,
95
+ leaseExpiresAt: "",
96
+ sessionId: "s",
97
+ sessionRevisionId: "r",
98
+ agentId: "main",
99
+ environment: "dev",
100
+ triggerReason: "x",
101
+ eventCount: 0,
102
+ transcriptUrl: "https://attacker.test/transcript",
103
+ definitionsUrl: "",
104
+ },
105
+ "w1",
106
+ ),
107
+ ).rejects.toThrow(/outside the configured API origin/);
108
+ });
109
+
110
+ it("retries a retryable status and stops at the cap", async () => {
111
+ const fetchImpl = vi.fn(async () => jsonResponse({}, 503));
112
+ const client = new EvaluatorClient({
113
+ baseUrl: "https://api.example.test",
114
+ credential: "t",
115
+ maxRetries: 2,
116
+ fetchImpl: fetchImpl,
117
+ sleep: async () => undefined,
118
+ });
119
+ await expect(
120
+ client.register({
121
+ workerId: "w1",
122
+ sdkVersion: "0",
123
+ catalogRevision: "sha256:0",
124
+ maxConcurrency: 1,
125
+ definitions: [],
126
+ }),
127
+ ).rejects.toThrow(EvaluatorAPIError);
128
+ expect(fetchImpl).toHaveBeenCalledTimes(3);
129
+ });
130
+
131
+ it("does not retry a non-retryable status", async () => {
132
+ const fetchImpl = vi.fn(async () =>
133
+ jsonResponse(
134
+ {
135
+ protocol_version: PROTOCOL_VERSION,
136
+ error: { code: "invalid_credentials", message: "nope", retryable: false, request_id: "r" },
137
+ },
138
+ 401,
139
+ ),
140
+ );
141
+ const client = new EvaluatorClient({
142
+ baseUrl: "https://api.example.test",
143
+ credential: "t",
144
+ fetchImpl: fetchImpl,
145
+ sleep: async () => undefined,
146
+ });
147
+ await expect(
148
+ client.register({
149
+ workerId: "w1",
150
+ sdkVersion: "0",
151
+ catalogRevision: "sha256:0",
152
+ maxConcurrency: 1,
153
+ definitions: [],
154
+ }),
155
+ ).rejects.toMatchObject({ code: "invalid_credentials", retryable: false });
156
+ expect(fetchImpl).toHaveBeenCalledTimes(1);
157
+ });
158
+
159
+ it("NEVER retries a claim, because a lost response may already have leased work", async () => {
160
+ const fetchImpl = vi.fn(async () => jsonResponse({}, 503));
161
+ const client = new EvaluatorClient({
162
+ baseUrl: "https://api.example.test",
163
+ credential: "t",
164
+ maxRetries: 5,
165
+ fetchImpl: fetchImpl,
166
+ sleep: async () => undefined,
167
+ });
168
+ await expect(
169
+ client.claim({ workerId: "w1", catalogRevision: "sha256:0", capacity: 1 }),
170
+ ).rejects.toThrow();
171
+ expect(fetchImpl).toHaveBeenCalledTimes(1);
172
+ });
173
+
174
+ it("reports a non-JSON body as an invalid response rather than crashing", async () => {
175
+ const fetchImpl = vi.fn(async () => new Response("<html>gateway</html>", { status: 200 }));
176
+ const client = new EvaluatorClient({
177
+ baseUrl: "https://api.example.test",
178
+ credential: "t",
179
+ fetchImpl: fetchImpl,
180
+ sleep: async () => undefined,
181
+ });
182
+ await expect(
183
+ client.register({
184
+ workerId: "w1",
185
+ sdkVersion: "0",
186
+ catalogRevision: "sha256:0",
187
+ maxConcurrency: 1,
188
+ definitions: [],
189
+ }),
190
+ ).rejects.toMatchObject({ code: "invalid_response" });
191
+ });
192
+
193
+ it("stops reading a body past the limit instead of buffering it whole", async () => {
194
+ const huge = "x".repeat(4 * 1024 * 1024);
195
+ const fetchImpl = vi.fn(async () => jsonResponse({ padding: huge }));
196
+ const client = new EvaluatorClient({
197
+ baseUrl: "https://api.example.test",
198
+ credential: "t",
199
+ fetchImpl: fetchImpl,
200
+ sleep: async () => undefined,
201
+ });
202
+ await expect(
203
+ client.register({
204
+ workerId: "w1",
205
+ sdkVersion: "0",
206
+ catalogRevision: "sha256:0",
207
+ maxConcurrency: 1,
208
+ definitions: [],
209
+ }),
210
+ ).rejects.toMatchObject({ code: "response_too_large" });
211
+ });
212
+
213
+ it("classifies a transport failure as retryable", async () => {
214
+ const fetchImpl = vi.fn(async () => {
215
+ throw new Error("ECONNREFUSED");
216
+ });
217
+ const client = new EvaluatorClient({
218
+ baseUrl: "https://api.example.test",
219
+ credential: "t",
220
+ maxRetries: 0,
221
+ fetchImpl: fetchImpl,
222
+ sleep: async () => undefined,
223
+ });
224
+ await expect(
225
+ client.register({
226
+ workerId: "w1",
227
+ sdkVersion: "0",
228
+ catalogRevision: "sha256:0",
229
+ maxConcurrency: 1,
230
+ definitions: [],
231
+ }),
232
+ ).rejects.toMatchObject({ code: "transport_error", retryable: true });
233
+ });
234
+ });