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,386 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import { FORMATS, count, describeTrace, ofType, runAgent, traceViolations, type Event } from "./harness.js";
4
+
5
+ /**
6
+ * Mastra, every commonly used surface beyond a bare `new Agent().generate()`,
7
+ * against real 0.x and 1.x releases in both module systems. The mapping each
8
+ * case expects is the one `src/integrations/mastra.ts` documents; the cases in
9
+ * `mastra.test.ts` cover the core loop, errors and the instrument lifecycle.
10
+ *
11
+ * Every model here is a mock that answers from what it is ASKED (the city in
12
+ * the question, whether the last message is a tool result, which schema the
13
+ * call requests), so concurrent runs, memory, networks and structured output
14
+ * can share one without a script going out of step. Nothing reaches a
15
+ * network; the MCP server is a local stdio child process.
16
+ */
17
+
18
+ const FIXTURES = ["mastra-1", "mastra-0"] as const;
19
+
20
+ const CITIES = ["Paris", "Rome", "Oslo", "Lima", "Cairo", "Tokyo", "Quito", "Dakar", "Hanoi", "Perth"];
21
+
22
+ /** One line per event: `agent_id type [hook|tool]`. */
23
+ const shape = (events: Event[]): string[] =>
24
+ events.map((e) => [e.agent_id, e.type, (e.hook_name ?? e.tool_name ?? "") as string].join(" ").trim());
25
+
26
+ const loop = (agent: string, tool = "weather"): string[] => [
27
+ `${agent} agent_start`,
28
+ `${agent} model_request`,
29
+ `${agent} model_response`,
30
+ `${agent} tool_use ${tool}`,
31
+ `${agent} tool_result ${tool}`,
32
+ `${agent} model_request`,
33
+ `${agent} model_response`,
34
+ `${agent} agent_end`,
35
+ ];
36
+
37
+ const sessions = (events: Event[]): string[] => [...new Set(events.map((e) => e.session_id))];
38
+
39
+ const bySession = (events: Event[]): Event[][] => sessions(events).map((id) => events.filter((e) => e.session_id === id));
40
+
41
+ const hooks = (flow: string, ...steps: string[]): string[] =>
42
+ steps.flatMap((step) => [`${flow} hook_triggered ${step}`, `${flow} hook_completed ${step}`]);
43
+
44
+ describe.each(FIXTURES)("%s", (fixture) => {
45
+ const zero = fixture === "mastra-0";
46
+
47
+ describe.each(FORMATS)("as %s", (format) => {
48
+ const run = (scenario: string) => {
49
+ const result = runAgent(fixture, format, scenario);
50
+ expect(result.status, describeTrace(result)).toBe(0);
51
+ expect(traceViolations(result.events), describeTrace(result)).toEqual([]);
52
+ return result;
53
+ };
54
+
55
+ it("records an agent and a workflow fetched back from a Mastra instance", () => {
56
+ const result = run("mastra-instance");
57
+ expect(shape(result.events), describeTrace(result)).toEqual([
58
+ ...loop("weather-agent"),
59
+ "weather-flow agent_start",
60
+ ...hooks("weather-flow", "fetch-city"),
61
+ "weather-flow hook_triggered ask-agent",
62
+ ...loop("weather-agent"),
63
+ "weather-flow hook_completed ask-agent",
64
+ "weather-flow agent_end",
65
+ ]);
66
+ expect(sessions(result.events)).toHaveLength(2);
67
+ });
68
+
69
+ it("keeps 10 concurrent runs of one Agent apart in one session", () => {
70
+ const result = run("concurrent");
71
+ expect(sessions(result.events)).toEqual(["req-1"]);
72
+ expect(count(result.events, "agent_start")).toBe(10);
73
+ expect(count(result.events, "agent_end")).toBe(10);
74
+ expect(count(result.events, "model_request")).toBe(20);
75
+ expect(count(result.events, "model_response")).toBe(20);
76
+ const uses = ofType(result.events, "tool_use");
77
+ expect(uses.map((e) => (e.input as { city: string }).city).sort()).toEqual([...CITIES].sort());
78
+ expect(new Set(uses.map((e) => e.tool_call_id)).size).toBe(10);
79
+ for (const end of ofType(result.events, "agent_end")) expect(end.outcome).toBe("success");
80
+ expect(new Set(ofType(result.events, "agent_start").map((e) => e.goal)).size).toBe(10);
81
+ });
82
+
83
+ it("keeps 10 concurrent runs of one Agent (generate and stream) apart across sessions", () => {
84
+ const result = run("concurrent-sessions");
85
+ const perSession = bySession(result.events);
86
+ expect(perSession).toHaveLength(10);
87
+ const seen: string[] = [];
88
+ for (const events of perSession) {
89
+ expect(shape(events), describeTrace(result)).toEqual(loop("weather-agent"));
90
+ // Every event of the run is about the run's own city: nothing crossed.
91
+ const city = /in ([A-Z][a-z]+)/.exec(String(events[0]!.goal))![1]!;
92
+ seen.push(city);
93
+ expect((ofType(events, "tool_use")[0]!.input as { city: string }).city).toBe(city);
94
+ expect(ofType(events, "tool_result")[0]!.output).toEqual({ city, forecast: "sunny" });
95
+ expect(ofType(events, "model_response")[1]!.content).toBe(`It is sunny in ${city}.`);
96
+ for (const request of ofType(events, "model_request")) {
97
+ expect(JSON.stringify(request.messages)).toContain(city);
98
+ for (const other of CITIES.filter((c) => c !== city)) {
99
+ expect(JSON.stringify(request.messages)).not.toContain(other);
100
+ }
101
+ }
102
+ }
103
+ expect(seen.sort()).toEqual([...CITIES].sort());
104
+ });
105
+
106
+ it("makes a memory thread the session of every run on it", () => {
107
+ const result = run("memory");
108
+ expect(sessions(result.events)).toEqual(["thread-42"]);
109
+ const starts = ofType(result.events, "agent_start");
110
+ expect(starts.map((e) => e.goal)).toEqual(["What is the weather in Paris?", "And what is the weather in Rome?"]);
111
+ for (const start of starts) expect(start).toMatchObject({ fw_thread_id: "thread-42", fw_resource_id: "user-7" });
112
+ expect(count(result.events, "agent_end")).toBe(2);
113
+ expect(ofType(result.events, "tool_use").map((e) => (e.input as { city: string }).city)).toEqual(["Paris", "Rome"]);
114
+ // 0.x titles a new thread with the agent's own model: a real call,
115
+ // recorded on the run that made it.
116
+ expect(count(result.events, "model_request")).toBe(zero ? 5 : 4);
117
+ // Memory is real: the second run's first request carries the first run.
118
+ const second = result.events.findIndex((e) => e.type === "agent_start" && e.goal !== starts[0]!.goal);
119
+ const recalled = result.events.slice(second).find((e) => e.type === "model_request")!;
120
+ expect(JSON.stringify(recalled.messages)).toContain("What is the weather in Paris?");
121
+ });
122
+
123
+ it("lets an enclosing session scope win over the memory thread", () => {
124
+ const result = run("memory-scoped");
125
+ expect(sessions(result.events)).toEqual(["req-1"]);
126
+ expect(ofType(result.events, "agent_start")[0]).toMatchObject({ fw_thread_id: "thread-42" });
127
+ });
128
+
129
+ it("records a branch as the branch taken", () => {
130
+ const result = run("wf-branch");
131
+ expect(shape(result.events), describeTrace(result)).toEqual([
132
+ "branch-flow agent_start",
133
+ ...hooks("branch-flow", "city", "sunny"),
134
+ "branch-flow agent_end",
135
+ ]);
136
+ });
137
+
138
+ it("records parallel steps each as a hook", () => {
139
+ const result = run("wf-parallel");
140
+ expect(shape(result.events), describeTrace(result)).toEqual([
141
+ "parallel-flow agent_start",
142
+ ...hooks("parallel-flow", "city"),
143
+ "parallel-flow hook_triggered high",
144
+ "parallel-flow hook_triggered low",
145
+ "parallel-flow hook_completed high",
146
+ "parallel-flow hook_completed low",
147
+ "parallel-flow agent_end",
148
+ ]);
149
+ });
150
+
151
+ it("records every iteration of a dowhile and a foreach", () => {
152
+ const result = run("wf-loop");
153
+ expect(shape(result.events), describeTrace(result)).toEqual([
154
+ "loop-flow agent_start",
155
+ ...hooks("loop-flow", "count", "count", "count", "cities", "answer", "answer"),
156
+ "loop-flow agent_end",
157
+ ]);
158
+ expect(new Set(ofType(result.events, "hook_triggered").map((e) => e.hook_id)).size).toBe(6);
159
+ });
160
+
161
+ it("nests a nested workflow under the step that runs it", () => {
162
+ const result = run("wf-nested");
163
+ expect(shape(result.events), describeTrace(result)).toEqual([
164
+ "outer-flow agent_start",
165
+ "outer-flow hook_triggered inner-flow",
166
+ "inner-flow agent_start",
167
+ ...hooks("inner-flow", "pick-city", "answer"),
168
+ "inner-flow agent_end",
169
+ "outer-flow hook_completed inner-flow",
170
+ "outer-flow agent_end",
171
+ ]);
172
+ expect(ofType(result.events, "agent_start")[1]!.parent_id).toBe("outer-flow");
173
+ });
174
+
175
+ it("nests an agent used as a step (createStep(agent)) under the workflow", () => {
176
+ const result = run("wf-agent-step");
177
+ expect(shape(result.events), describeTrace(result)).toEqual([
178
+ "agent-step-flow agent_start",
179
+ ...hooks("agent-step-flow", "to-prompt"),
180
+ "agent-step-flow hook_triggered weather-agent",
181
+ ...loop("weather-agent"),
182
+ "agent-step-flow hook_completed weather-agent",
183
+ "agent-step-flow agent_end",
184
+ ]);
185
+ expect(ofType(result.events, "agent_start")[1]!.parent_id).toBe("agent-step-flow");
186
+ });
187
+
188
+ it("records a streamed workflow run (run.stream()) exactly like an awaited one", () => {
189
+ const result = run("wf-stream");
190
+ expect(shape(result.events), describeTrace(result)).toEqual([
191
+ "agent-step-flow agent_start",
192
+ ...hooks("agent-step-flow", "to-prompt"),
193
+ "agent-step-flow hook_triggered weather-agent",
194
+ ...loop("weather-agent"),
195
+ "agent-step-flow hook_completed weather-agent",
196
+ "agent-step-flow agent_end",
197
+ ]);
198
+ expect(ofType(result.events, "agent_end").at(-1)!.outcome).toBe("success");
199
+ });
200
+
201
+ it("records suspend / resume as a human wait on ONE workflow span", () => {
202
+ const result = run("wf-suspend");
203
+ expect(shape(result.events), describeTrace(result)).toEqual([
204
+ "approval-flow agent_start",
205
+ ...hooks("approval-flow", "city", "approve"),
206
+ "approval-flow human_wait",
207
+ "approval-flow agent_pause",
208
+ "approval-flow agent_resume",
209
+ "approval-flow human_input",
210
+ ...hooks("approval-flow", "approve", "done"),
211
+ "approval-flow agent_end",
212
+ ]);
213
+ const runId = String(ofType(result.events, "agent_start")[0]!.fw_workflow_run_id);
214
+ expect(sessions(result.events)).toEqual([runId]);
215
+ const pauseId = `${runId}:approve`;
216
+ expect(ofType(result.events, "human_wait")[0]).toMatchObject({ input_id: pauseId, prompt: "Look up Paris?" });
217
+ expect(ofType(result.events, "agent_pause")[0]).toMatchObject({ pause_id: pauseId });
218
+ expect(ofType(result.events, "agent_resume")[0]).toMatchObject({ pause_id: pauseId });
219
+ expect(ofType(result.events, "human_input")[0]).toMatchObject({ input_id: pauseId, response: '{"approved":true}' });
220
+ expect(ofType(result.events, "hook_completed")[1]!.outcome).toBe("suspended");
221
+ expect(ofType(result.events, "agent_end")[0]!.outcome).toBe("success");
222
+ expect(result.stdout).toContain('"status":"suspended"');
223
+ expect(result.stdout).toContain('"answer":"sunny in Paris"');
224
+ });
225
+
226
+ it("records a run through input and output processors exactly as one without", () => {
227
+ const result = run("processors");
228
+ expect(shape(result.events), describeTrace(result)).toEqual([...loop("weather-agent"), ...loop("weather-agent")]);
229
+ expect(sessions(result.events)).toHaveLength(2);
230
+ expect(result.stdout).toContain('"answers":["It is sunny in Paris.","It is sunny in Paris."]');
231
+ });
232
+
233
+ it("closes a run an input processor blocks, rejected — generate and stream", () => {
234
+ const result = run("tripwire");
235
+ expect(shape(result.events), describeTrace(result)).toEqual([
236
+ "weather-agent agent_start",
237
+ "weather-agent agent_end",
238
+ "weather-agent agent_start",
239
+ "weather-agent agent_end",
240
+ ]);
241
+ expect(ofType(result.events, "agent_end").map((e) => e.outcome)).toEqual(["rejected", "rejected"]);
242
+ });
243
+
244
+ // 0.x's output offers no end signal for a stream an OUTPUT processor
245
+ // blocks (no callback fires, no `_waitUntilFinished`), so there its agent
246
+ // stays open until uninstrument() — a known limitation.
247
+ it.skipIf(zero)("closes a stream an output processor blocks, rejected, with its model step", () => {
248
+ const result = run("tripwire-output");
249
+ expect(shape(result.events), describeTrace(result)).toEqual([
250
+ "weather-agent agent_start",
251
+ "weather-agent model_request",
252
+ "weather-agent model_response",
253
+ "weather-agent agent_end",
254
+ ]);
255
+ expect(ofType(result.events, "model_response")[0]).toMatchObject({ input_tokens: 9, output_tokens: 4 });
256
+ expect(ofType(result.events, "agent_end")[0]!.outcome).toBe("rejected");
257
+ });
258
+
259
+ // The manual finding "Mastra streams from OpenAI-compatible providers carry
260
+ // no tokens": Mastra's own model never asks for streamed usage, so there is
261
+ // nothing to record — and when the stream does carry it, it is recorded.
262
+ it("records a streamed OpenAI-compatible step's tokens only when the stream carries them", () => {
263
+ const result = run("usage-openai-compatible");
264
+ const report = JSON.parse(result.stdout.trim().split("\n").at(-1)!) as {
265
+ mastraStreamTokens: number;
266
+ mastraGenerateTokens: number;
267
+ requests: Array<{ stream?: boolean; streamOptions?: unknown }>;
268
+ };
269
+ // The streamed request did not ask (no `stream_options`), and Mastra
270
+ // itself reports zero; the non-streamed call reports the real count.
271
+ expect(report.requests[0]).toEqual({ stream: true });
272
+ expect(report.mastraStreamTokens).toBe(0);
273
+ expect(report.mastraGenerateTokens).toBe(17);
274
+ const responses = ofType(result.events, "model_response");
275
+ expect(responses.map((e) => [e.input_tokens, e.output_tokens])).toEqual([
276
+ [undefined, undefined],
277
+ [17, 5],
278
+ ]);
279
+
280
+ const always = runAgent(fixture, format, "usage-openai-compatible", { USAGE_ALWAYS: "1" });
281
+ expect(always.status, describeTrace(always)).toBe(0);
282
+ expect(ofType(always.events, "model_response").map((e) => [e.input_tokens, e.output_tokens])).toEqual([
283
+ [17, 5],
284
+ [17, 5],
285
+ ]);
286
+ });
287
+
288
+ it("records an MCP tool (listTools) under its namespaced MCP name", () => {
289
+ const result = run("mcp");
290
+ expect(shape(result.events), describeTrace(result)).toEqual(loop("weather-agent", "weatherServer_forecast"));
291
+ expect(ofType(result.events, "tool_use")[0]!.input).toEqual({ city: "Paris" });
292
+ expect(JSON.stringify(ofType(result.events, "tool_result")[0]!.output)).toContain("Forecast for Paris: sunny");
293
+ expect(ofType(result.events, "tool_result")[0]!.error).toBeUndefined();
294
+ });
295
+
296
+ it("records an MCP tool passed as a toolset under the name the model called", () => {
297
+ const result = run("mcp-toolsets");
298
+ expect(shape(result.events), describeTrace(result)).toEqual(loop("weather-agent", "forecast"));
299
+ const call = (ofType(result.events, "model_response")[0]!.fw_tool_calls as Array<{ name: string }>)[0]!;
300
+ expect(call.name).toBe("forecast");
301
+ expect(JSON.stringify(ofType(result.events, "tool_result")[0]!.output)).toContain("Forecast for Paris: sunny");
302
+ });
303
+
304
+ it("records structured output (generate and stream) as one model step each", () => {
305
+ const result = run("structured");
306
+ const one = [
307
+ "weather-agent agent_start",
308
+ "weather-agent model_request",
309
+ "weather-agent model_response",
310
+ "weather-agent agent_end",
311
+ ];
312
+ expect(shape(result.events), describeTrace(result)).toEqual([...one, ...one]);
313
+ for (const response of ofType(result.events, "model_response")) {
314
+ expect(response).toMatchObject({ input_tokens: 15, output_tokens: 6 });
315
+ expect(JSON.parse(String(response.content))).toEqual({ city: "Paris", forecast: "sunny" });
316
+ }
317
+ expect(result.stdout).toContain('"object":{"city":"Paris","forecast":"sunny"}');
318
+ });
319
+
320
+ it("nests structuring by a second model as its own agent, inside the run", () => {
321
+ const result = run("structured-model");
322
+ expect(shape(result.events), describeTrace(result)).toEqual([
323
+ ...loop("weather-agent").slice(0, -1),
324
+ "structured-output-structurer agent_start",
325
+ "structured-output-structurer model_request",
326
+ "structured-output-structurer model_response",
327
+ "structured-output-structurer agent_end",
328
+ "weather-agent agent_end",
329
+ ]);
330
+ const structurer = ofType(result.events, "agent_start")[1]!;
331
+ expect(structurer.parent_id).toBe("weather-agent");
332
+ expect(ofType(result.events, "model_response")[2]).toMatchObject({ model: "structuring-model", input_tokens: 30 });
333
+ });
334
+
335
+ it("records a one-step run whose tool fails: one model step, the failure on the tool", () => {
336
+ const result = run("maxsteps-tool-error");
337
+ expect(shape(result.events), describeTrace(result)).toEqual(loop("weather-agent").filter((_, i) => i !== 5 && i !== 6));
338
+ expect(String(ofType(result.events, "tool_result")[0]!.error)).toMatch(/tool exploded/);
339
+ expect(ofType(result.events, "agent_end")[0]!.outcome).toBe("success");
340
+ expect(count(result.events, "error")).toBe(0);
341
+ });
342
+
343
+ it("nests an agent a tool runs by hand under that tool call", () => {
344
+ const result = run("agent-in-tool");
345
+ expect(shape(result.events), describeTrace(result)).toEqual([
346
+ "boss agent_start",
347
+ "boss model_request",
348
+ "boss model_response",
349
+ "boss tool_use ask-helper",
350
+ ...loop("helper"),
351
+ "boss tool_result ask-helper",
352
+ "boss model_request",
353
+ "boss model_response",
354
+ "boss agent_end",
355
+ ]);
356
+ expect(sessions(result.events)).toHaveLength(1);
357
+ expect(ofType(result.events, "agent_start")[1]!.parent_id).toBe("boss");
358
+ });
359
+
360
+ it("records an agent network as one agent: its router's steps, its delegate nested", () => {
361
+ const result = run("network");
362
+ // 0.x titles the network's new memory thread with the router's model.
363
+ const title = zero ? ["planner model_request", "planner model_response"] : [];
364
+ expect(shape(result.events), describeTrace(result)).toEqual([
365
+ "planner agent_start",
366
+ ...title,
367
+ "planner model_request",
368
+ "planner model_response",
369
+ ...loop("helper"),
370
+ "planner model_request",
371
+ "planner model_response",
372
+ "planner agent_end",
373
+ ]);
374
+ expect(sessions(result.events)).toEqual(["thread-net"]);
375
+ const [planner, helper] = ofType(result.events, "agent_start");
376
+ expect(planner).toMatchObject({ fw_method: "network", fw_thread_id: "thread-net" });
377
+ expect(helper!.parent_id).toBe("planner");
378
+ const tokens = ofType(result.events, "model_response")
379
+ .filter((e) => e.agent_id === "planner")
380
+ .map((e) => [e.input_tokens, e.output_tokens]);
381
+ expect(tokens).toEqual([...(zero ? [[5, 3]] : []), [50, 10], [40, 6]]);
382
+ expect(ofType(result.events, "agent_end").at(-1)!.outcome).toBe("success");
383
+ expect(result.stdout).toContain('"status":"success"');
384
+ });
385
+ });
386
+ });