failproofai 1.0.7-beta.1 → 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.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +15 -15
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +15 -15
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +14 -14
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +15 -15
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +14 -14
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +15 -15
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +7 -7
- package/.next/standalone/.next/server/app/settings/page.js +2 -2
- package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0l3yhx4._.js +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
- package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
- package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_09z9-p7._.js +1 -1
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
- package/.next/standalone/.next/server/chunks/src_hooks_18qtd42._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__04usis8._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__056wjo4._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0yxwl6j._.js → [root-of-the-server]__0l44ual._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0n0xg95._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0rwtwpm._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s_yomn._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11mayhe._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1pprgri._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1q4p5b8._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_042cgl1._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0bqoto4._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_214wgrp._.js → _1mel6y1._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{_0bn2oo8._.js → _1v-jvrv._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1zopuov._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_actions_get-scheduled-audit_ts_0ei9sni._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_settings_02tf1h4._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_15t8kqj._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1fm2w5z._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1j0zy3v._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_builtin-policies_ts_09j2ndl._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +22 -22
- package/.next/standalone/.next/static/chunks/043j99m8ykg__.css +2 -0
- package/.next/standalone/.next/static/chunks/0fqd7m_u81mi5.js +1 -0
- package/.next/standalone/.next/static/chunks/129ag2bw93bdh.js +1 -0
- package/.next/standalone/.next/static/chunks/{29fql3nbnfc9q.js → 1qd741hzlmjbo.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0vmd180qfntfb.js → 2_pltstd8-xgs.js} +1 -1
- package/.next/standalone/.next/static/chunks/{1u5zsejmgrir_.js → 2c8j9l6j_b1ci.js} +1 -1
- package/.next/standalone/.next/static/chunks/3-k569wzcli8q.js +1 -0
- package/.next/standalone/.next/static/chunks/{258668t68du6b.js → 3brze37td_wnc.js} +1 -1
- package/.next/standalone/.next/static/chunks/3otmypm6j_xfo.js +6 -0
- package/.next/standalone/.next/static/chunks/{12tvm75t5ffui.js → 3ugmd_7dyn0id.js} +1 -1
- package/.next/standalone/.next/static/chunks/3yxro_r2_o9ad.js +69 -0
- package/.next/standalone/PROBE-FOLLOWUP.md +186 -0
- package/.next/standalone/app/actions/get-jev-config.ts +38 -23
- package/.next/standalone/app/actions/update-jev-config.ts +1 -1
- package/.next/standalone/app/settings/jev-panel.tsx +33 -29
- package/.next/standalone/package.json +10 -10
- package/.next/standalone/sdk/python/skill/SKILL.md +60 -14
- package/.next/standalone/sdk/python/skill/agents/openai.yaml +2 -1
- package/.next/standalone/sdk/python/skill/references/evaluator.md +255 -0
- package/.next/standalone/sdk/python/skill/references/events.md +17 -8
- package/.next/standalone/sdk/python/skill/references/frameworks.md +3 -0
- package/.next/standalone/sdk/python/skill/references/install.md +3 -0
- package/.next/standalone/sdk/python/skill/references/integration.md +6 -2
- package/.next/standalone/sdk/python/skill/references/typescript.md +568 -0
- package/.next/standalone/sdk/typescript/CHANGELOG.md +119 -0
- package/.next/standalone/sdk/typescript/LICENSE +42 -0
- package/.next/standalone/sdk/typescript/README.md +552 -0
- package/.next/standalone/sdk/typescript/eslint.config.mjs +59 -0
- package/.next/standalone/sdk/typescript/examples/research-agent.ts +197 -0
- package/.next/standalone/sdk/typescript/integration/ai.test.ts +920 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/agent.ts +337 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/package-lock.json +281 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/package.json +13 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/surfaces.ts +605 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/tsconfig.surfaces.json +4 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/agent.ts +342 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/package-lock.json +168 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/package.json +13 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/surfaces.ts +628 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/tsconfig.surfaces.json +4 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/agent.ts +346 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/package-lock.json +156 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/package.json +13 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/surfaces.ts +651 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-6/tsconfig.surfaces.json +4 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/agent.ts +350 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/package-lock.json +153 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/package.json +13 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/surfaces.ts +651 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-7/tsconfig.surfaces.json +4 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/agent.ts +623 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/package-lock.json +463 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/package.json +15 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/agent-v1.ts +99 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/agent.ts +623 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/package-lock.json +336 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/package.json +15 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-1/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/agent.ts +96 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/package-lock.json +579 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/package.json +15 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/vendor/lc-weather-provider/index.cjs +53 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/vendor/lc-weather-provider/index.mjs +55 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/vendor/lc-weather-provider/package.json +18 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/agent.ts +659 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/package-lock.json +635 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/package.json +15 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.11/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/agent.ts +659 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/package-lock.json +553 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/package.json +15 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/llamaindex-0.12/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/agent.ts +877 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/mcp-server.mjs +66 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/package-lock.json +6417 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/package.json +15 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/agent.ts +872 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/mcp-server.mjs +66 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/package-lock.json +2540 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/package.json +15 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-1/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/actions.ts +18 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/ai/route.ts +42 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/edge/route.ts +29 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/langgraph/route.ts +21 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/llamaindex/route.ts +11 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/mastra/route.ts +19 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/status/route.ts +7 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/layout.tsx +9 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/page.tsx +15 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/instrumentation.ts +15 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/ai.ts +61 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/langgraph.ts +68 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/llamaindex.ts +98 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/lib/mastra.ts +90 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/next.config.ts +52 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/package-lock.json +4343 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/package.json +28 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/agent.ts +51 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/deno-npm.ts +76 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/package-lock.json +484 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/runtimes/package.json +15 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/types/agent.ts +79 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/types/package-lock.json +740 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/types/package.json +11 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/agent.ts +197 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/package-lock.json +70 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/package.json +12 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/vanilla/tsconfig.json +12 -0
- package/.next/standalone/sdk/typescript/integration/global-setup.ts +29 -0
- package/.next/standalone/sdk/typescript/integration/harness.ts +451 -0
- package/.next/standalone/sdk/typescript/integration/langchain.test.ts +682 -0
- package/.next/standalone/sdk/typescript/integration/llamaindex.test.ts +709 -0
- package/.next/standalone/sdk/typescript/integration/mastra-coverage.test.ts +386 -0
- package/.next/standalone/sdk/typescript/integration/mastra.test.ts +311 -0
- package/.next/standalone/sdk/typescript/integration/nextjs.test.ts +341 -0
- package/.next/standalone/sdk/typescript/integration/runtime-parity.ts +180 -0
- package/.next/standalone/sdk/typescript/integration/runtimes.bun.test.ts +15 -0
- package/.next/standalone/sdk/typescript/integration/runtimes.core.test.ts +113 -0
- package/.next/standalone/sdk/typescript/integration/runtimes.deno.test.ts +19 -0
- package/.next/standalone/sdk/typescript/integration/types.test.ts +141 -0
- package/.next/standalone/sdk/typescript/integration/vanilla.test.ts +255 -0
- package/.next/standalone/sdk/typescript/package-lock.json +2640 -0
- package/.next/standalone/sdk/typescript/package.json +401 -0
- package/.next/standalone/sdk/typescript/scripts/finalize-build.mjs +123 -0
- package/.next/standalone/sdk/typescript/scripts/release.mjs +177 -0
- package/.next/standalone/sdk/typescript/src/clock.ts +58 -0
- package/.next/standalone/sdk/typescript/src/context.ts +214 -0
- package/.next/standalone/sdk/typescript/src/edge/adapter.ts +18 -0
- package/.next/standalone/sdk/typescript/src/edge/ai.ts +116 -0
- package/.next/standalone/sdk/typescript/src/edge/index.ts +238 -0
- package/.next/standalone/sdk/typescript/src/edge/langchain.ts +18 -0
- package/.next/standalone/sdk/typescript/src/edge/llamaindex.ts +12 -0
- package/.next/standalone/sdk/typescript/src/edge/mastra.ts +17 -0
- package/.next/standalone/sdk/typescript/src/edge/notice.ts +33 -0
- package/.next/standalone/sdk/typescript/src/environment.ts +75 -0
- package/.next/standalone/sdk/typescript/src/evaluator/authoring.ts +480 -0
- package/.next/standalone/sdk/typescript/src/evaluator/cli.ts +96 -0
- package/.next/standalone/sdk/typescript/src/evaluator/client.ts +421 -0
- package/.next/standalone/sdk/typescript/src/evaluator/expression.ts +1292 -0
- package/.next/standalone/sdk/typescript/src/evaluator/index.ts +144 -0
- package/.next/standalone/sdk/typescript/src/evaluator/protocol.ts +747 -0
- package/.next/standalone/sdk/typescript/src/evaluator/runtime.ts +930 -0
- package/.next/standalone/sdk/typescript/src/evaluator/sandbox-worker.ts +171 -0
- package/.next/standalone/sdk/typescript/src/evaluator/source-limits.ts +27 -0
- package/.next/standalone/sdk/typescript/src/evaluator/source.ts +509 -0
- package/.next/standalone/sdk/typescript/src/events.ts +879 -0
- package/.next/standalone/sdk/typescript/src/exit.ts +117 -0
- package/.next/standalone/sdk/typescript/src/index.ts +186 -0
- package/.next/standalone/sdk/typescript/src/integrations/ai.ts +1566 -0
- package/.next/standalone/sdk/typescript/src/integrations/compat.ts +322 -0
- package/.next/standalone/sdk/typescript/src/integrations/core.ts +1321 -0
- package/.next/standalone/sdk/typescript/src/integrations/index.ts +355 -0
- package/.next/standalone/sdk/typescript/src/integrations/langchain.ts +2340 -0
- package/.next/standalone/sdk/typescript/src/integrations/llamaindex.ts +2111 -0
- package/.next/standalone/sdk/typescript/src/integrations/mastra.ts +1802 -0
- package/.next/standalone/sdk/typescript/src/logger.ts +98 -0
- package/.next/standalone/sdk/typescript/src/next.ts +115 -0
- package/.next/standalone/sdk/typescript/src/node-require.ts +446 -0
- package/.next/standalone/sdk/typescript/src/redact.ts +305 -0
- package/.next/standalone/sdk/typescript/src/resolver.ts +120 -0
- package/.next/standalone/sdk/typescript/src/runtime.ts +29 -0
- package/.next/standalone/sdk/typescript/src/schema.ts +410 -0
- package/.next/standalone/sdk/typescript/src/scopes.ts +701 -0
- package/.next/standalone/sdk/typescript/src/shared.ts +33 -0
- package/.next/standalone/sdk/typescript/src/version.ts +5 -0
- package/.next/standalone/sdk/typescript/src/writer.ts +934 -0
- package/.next/standalone/sdk/typescript/test/adapters.test.ts +397 -0
- package/.next/standalone/sdk/typescript/test/ai.test.ts +1076 -0
- package/.next/standalone/sdk/typescript/test/copies.test.ts +204 -0
- package/.next/standalone/sdk/typescript/test/edge.test.ts +183 -0
- package/.next/standalone/sdk/typescript/test/evaluator-client.test.ts +234 -0
- package/.next/standalone/sdk/typescript/test/evaluator-protocol.test.ts +225 -0
- package/.next/standalone/sdk/typescript/test/events.test.ts +193 -0
- package/.next/standalone/sdk/typescript/test/expression.test.ts +181 -0
- package/.next/standalone/sdk/typescript/test/global-setup.ts +26 -0
- package/.next/standalone/sdk/typescript/test/helpers.ts +130 -0
- package/.next/standalone/sdk/typescript/test/integrations.test.ts +369 -0
- package/.next/standalone/sdk/typescript/test/langchain-copies.test.ts +204 -0
- package/.next/standalone/sdk/typescript/test/langchain.test.ts +999 -0
- package/.next/standalone/sdk/typescript/test/llamaindex.test.ts +1760 -0
- package/.next/standalone/sdk/typescript/test/mastra-coverage.test.ts +501 -0
- package/.next/standalone/sdk/typescript/test/mastra-lifecycle.test.ts +479 -0
- package/.next/standalone/sdk/typescript/test/mastra.test.ts +285 -0
- package/.next/standalone/sdk/typescript/test/next.test.ts +109 -0
- package/.next/standalone/sdk/typescript/test/packaging.test.ts +312 -0
- package/.next/standalone/sdk/typescript/test/redaction.test.ts +171 -0
- package/.next/standalone/sdk/typescript/test/runtimes.test.ts +101 -0
- package/.next/standalone/sdk/typescript/test/sandbox.test.ts +189 -0
- package/.next/standalone/sdk/typescript/test/scopes.test.ts +271 -0
- package/.next/standalone/sdk/typescript/test/setup.ts +19 -0
- package/.next/standalone/sdk/typescript/test/skill-snippets.test.ts +73 -0
- package/.next/standalone/sdk/typescript/test/spool-contract.test.ts +124 -0
- package/.next/standalone/sdk/typescript/test/tracker-bounds.test.ts +191 -0
- package/.next/standalone/sdk/typescript/test/wire-format.test.ts +214 -0
- package/.next/standalone/sdk/typescript/test/writer.test.ts +407 -0
- package/.next/standalone/sdk/typescript/tsconfig.build.json +15 -0
- package/.next/standalone/sdk/typescript/tsconfig.cjs.json +19 -0
- package/.next/standalone/sdk/typescript/tsconfig.json +28 -0
- package/.next/standalone/sdk/typescript/vitest.config.ts +33 -0
- package/.next/standalone/sdk/typescript/vitest.integration.config.ts +23 -0
- package/.next/standalone/server.js +1 -1
- package/README.md +2 -2
- package/dist/cli.mjs +208 -27
- package/dist/worker.mjs +120 -14
- package/package.json +10 -10
- package/scripts/build-policy-pack.mjs +14 -0
- package/src/audit/features.ts +3 -2
- package/src/hooks/builtin-policies.ts +156 -5
- package/src/hooks/jev-cli.ts +57 -1
- package/src/hooks/manager.ts +1 -1
- package/src/hooks/pack-cli.ts +150 -18
- package/src/hooks/pack-store.ts +1 -1
- package/src/hooks/policy-catalog.ts +148 -9
- package/src/hooks/types.ts +1 -1
- package/.next/standalone/.next/static/chunks/0cd-_8-c-m1ea.js +0 -6
- package/.next/standalone/.next/static/chunks/0qrbdkv9qmvli.js +0 -69
- package/.next/standalone/.next/static/chunks/0uldbut9y2-e8.js +0 -1
- package/.next/standalone/.next/static/chunks/285spx855h_3r.css +0 -2
- package/.next/standalone/.next/static/chunks/2vkvu9-opa_1z.js +0 -1
- package/.next/standalone/.next/static/chunks/37lhv7wa3ywt6.js +0 -1
- /package/.next/standalone/.next/static/{T8YAYM9h_64fKv705vug7 → gbEOjBgZAxF2UIUwZVHNu}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{T8YAYM9h_64fKv705vug7 → gbEOjBgZAxF2UIUwZVHNu}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{T8YAYM9h_64fKv705vug7 → gbEOjBgZAxF2UIUwZVHNu}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "failproofai-it-mastra-1",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Integration fixture: Mastra 1.x (@mastra/core) against the packed @failproofai/sdk.",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@mastra/core": "1.68.0",
|
|
8
|
+
"@mastra/mcp": "2.0.0",
|
|
9
|
+
"@mastra/memory": "1.31.0",
|
|
10
|
+
"zod": "4.6.5"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@types/node": "22.20.4"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
|
|
3
|
+
import { telemetry } from "@failproofai/sdk/ai";
|
|
4
|
+
import { generateText } from "ai";
|
|
5
|
+
|
|
6
|
+
import { loop, scripted, tools } from "../lib/ai";
|
|
7
|
+
|
|
8
|
+
/** A server action running an agent (twin: ai-7 `generate`). */
|
|
9
|
+
export async function askWeather(): Promise<string> {
|
|
10
|
+
const { text } = await generateText({
|
|
11
|
+
model: scripted(),
|
|
12
|
+
prompt: "Weather in Paris?",
|
|
13
|
+
tools: tools(),
|
|
14
|
+
...loop,
|
|
15
|
+
experimental_telemetry: telemetry({ functionId: "weather-agent" }),
|
|
16
|
+
});
|
|
17
|
+
return text;
|
|
18
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { telemetry } from "@failproofai/sdk/ai";
|
|
2
|
+
import { generateText, streamText } from "ai";
|
|
3
|
+
|
|
4
|
+
import { loop, scripted, tools } from "../../../lib/ai";
|
|
5
|
+
|
|
6
|
+
export const dynamic = "force-dynamic";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `?mode=telemetry` generateText, call-site `telemetry()` (twin: ai-7 `generate`)
|
|
10
|
+
* `?mode=instrument` generateText, `instrument()` + isEnabled (twin: ai-7 `instrument`)
|
|
11
|
+
* `?mode=stream` streamText → toUIMessageStreamResponse(),
|
|
12
|
+
* call-site `telemetry()` (twin: ai-7 `stream`)
|
|
13
|
+
* `?mode=instrument-stream` the same through `instrument()` (twin: ai-7 `instrument-stream`)
|
|
14
|
+
*
|
|
15
|
+
* The streaming modes return the stream itself, as a chat route does: the
|
|
16
|
+
* model is still producing when the handler returns.
|
|
17
|
+
*/
|
|
18
|
+
export async function GET(request: Request): Promise<Response> {
|
|
19
|
+
const mode = new URL(request.url).searchParams.get("mode") ?? "telemetry";
|
|
20
|
+
const viaInstrument = mode.startsWith("instrument");
|
|
21
|
+
const settings = viaInstrument
|
|
22
|
+
? { isEnabled: true as const, functionId: "weather-agent" }
|
|
23
|
+
: telemetry({ functionId: "weather-agent" });
|
|
24
|
+
if (mode.endsWith("stream")) {
|
|
25
|
+
const result = streamText({
|
|
26
|
+
model: scripted(),
|
|
27
|
+
prompt: "Weather in Rome?",
|
|
28
|
+
tools: tools(),
|
|
29
|
+
...loop,
|
|
30
|
+
experimental_telemetry: settings,
|
|
31
|
+
});
|
|
32
|
+
return result.toUIMessageStreamResponse();
|
|
33
|
+
}
|
|
34
|
+
const { text } = await generateText({
|
|
35
|
+
model: scripted(),
|
|
36
|
+
prompt: "Weather in Paris?",
|
|
37
|
+
tools: tools(),
|
|
38
|
+
...loop,
|
|
39
|
+
experimental_telemetry: settings,
|
|
40
|
+
});
|
|
41
|
+
return Response.json({ text });
|
|
42
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as failproofai from "@failproofai/sdk";
|
|
2
|
+
|
|
3
|
+
export const runtime = "edge";
|
|
4
|
+
export const dynamic = "force-dynamic";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The SDK in the Edge runtime: no filesystem, so no spool. Importing it must
|
|
8
|
+
* not take the route down; what each call does instead is what this reports.
|
|
9
|
+
*/
|
|
10
|
+
export async function GET(): Promise<Response> {
|
|
11
|
+
const outcome: Record<string, unknown> = { imported: typeof failproofai.event === "object" };
|
|
12
|
+
try {
|
|
13
|
+
failproofai.session({ sessionId: "edge-session" }, () =>
|
|
14
|
+
failproofai.agent("edge-agent", () => {
|
|
15
|
+
failproofai.event.modelRequest({ model: "mock-model", requestId: "r-1" });
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
outcome.emitted = true;
|
|
19
|
+
} catch (error) {
|
|
20
|
+
outcome.emitted = String(error);
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
await failproofai.flush();
|
|
24
|
+
outcome.flushed = true;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
outcome.flushed = String(error);
|
|
27
|
+
}
|
|
28
|
+
return Response.json(outcome);
|
|
29
|
+
}
|
package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/langgraph/route.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { langchainHandler } from "@failproofai/sdk/langchain";
|
|
2
|
+
|
|
3
|
+
import { ScriptedModel, buildGraph, question } from "../../../lib/langgraph";
|
|
4
|
+
|
|
5
|
+
export const dynamic = "force-dynamic";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `?mode=instrument` — relies on `instrument()` from instrumentation.ts
|
|
9
|
+
* (twin: langchain-1 `graph`).
|
|
10
|
+
* `?mode=handler` — passes the call-site handler, no patching
|
|
11
|
+
* (twin: langchain-1 `handler`).
|
|
12
|
+
*/
|
|
13
|
+
export async function GET(request: Request): Promise<Response> {
|
|
14
|
+
const mode = new URL(request.url).searchParams.get("mode") ?? "instrument";
|
|
15
|
+
const graph = buildGraph(new ScriptedModel());
|
|
16
|
+
const out =
|
|
17
|
+
mode === "handler"
|
|
18
|
+
? await graph.invoke(question(), { callbacks: [langchainHandler() as never] })
|
|
19
|
+
: await graph.invoke(question());
|
|
20
|
+
return Response.json({ answer: out.messages.at(-1)?.content });
|
|
21
|
+
}
|
package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/app/api/llamaindex/route.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { agent } from "@llamaindex/workflow";
|
|
2
|
+
|
|
3
|
+
import { QUESTION, ScriptedLLM, getWeather } from "../../../lib/llamaindex";
|
|
4
|
+
|
|
5
|
+
export const dynamic = "force-dynamic";
|
|
6
|
+
|
|
7
|
+
/** A LlamaIndex agent workflow through `instrument()` (twin: llamaindex-0.12 `workflow`). */
|
|
8
|
+
export async function GET(): Promise<Response> {
|
|
9
|
+
const out = await agent({ llm: new ScriptedLLM(), tools: [getWeather] }).run(QUESTION);
|
|
10
|
+
return Response.json({ answer: out.data.result });
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { wrapTool } from "@failproofai/sdk/mastra";
|
|
2
|
+
|
|
3
|
+
import { question, weather, weatherAgent } from "../../../lib/mastra";
|
|
4
|
+
|
|
5
|
+
export const dynamic = "force-dynamic";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `?mode=instrument` — Agent.generate() through `instrument()` (twin: mastra-1 `generate`).
|
|
9
|
+
* `?mode=wraptool` — the call-site `wrapTool()` (twin: mastra-1 `wraptool`).
|
|
10
|
+
*/
|
|
11
|
+
export async function GET(request: Request): Promise<Response> {
|
|
12
|
+
const mode = new URL(request.url).searchParams.get("mode") ?? "instrument";
|
|
13
|
+
if (mode === "wraptool") {
|
|
14
|
+
const tool = wrapTool(weather);
|
|
15
|
+
return Response.json({ out: await tool.execute!({ city: "Rome" }, {} as never) });
|
|
16
|
+
}
|
|
17
|
+
const out = await weatherAgent().generate(question);
|
|
18
|
+
return Response.json({ answer: out.text });
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const dynamic = "force-dynamic";
|
|
2
|
+
|
|
3
|
+
/** What instrumentation.ts's `instrument()` returned, and whether it ran at all. */
|
|
4
|
+
export function GET(): Response {
|
|
5
|
+
const instrumented = (globalThis as { __failproofaiInstrumented?: string[] }).__failproofaiInstrumented ?? null;
|
|
6
|
+
return Response.json({ instrumented, runtime: process.env.NEXT_RUNTIME ?? null });
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { askWeather } from "./actions";
|
|
2
|
+
|
|
3
|
+
export const dynamic = "force-dynamic";
|
|
4
|
+
|
|
5
|
+
export default function Page() {
|
|
6
|
+
async function submit(): Promise<void> {
|
|
7
|
+
"use server";
|
|
8
|
+
await askWeather();
|
|
9
|
+
}
|
|
10
|
+
return (
|
|
11
|
+
<form action={submit}>
|
|
12
|
+
<button type="submit">Ask</button>
|
|
13
|
+
</form>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js's documented startup hook: `register()` runs once per server process,
|
|
3
|
+
* before any request is handled. The place the README should tell Next users
|
|
4
|
+
* to call `instrument()`.
|
|
5
|
+
*
|
|
6
|
+
* `NEXT_RUNTIME` guards the Node-only work: Next also evaluates this file for
|
|
7
|
+
* the Edge runtime, where the SDK has no filesystem to spool to.
|
|
8
|
+
*/
|
|
9
|
+
export async function register(): Promise<void> {
|
|
10
|
+
if (process.env.NEXT_RUNTIME !== "nodejs") return;
|
|
11
|
+
if (process.env.FAILPROOFAI_IT_INSTRUMENT === "0") return;
|
|
12
|
+
const failproofai = await import("@failproofai/sdk");
|
|
13
|
+
const instrumented = await failproofai.instrument();
|
|
14
|
+
(globalThis as { __failproofaiInstrumented?: string[] }).__failproofaiInstrumented = instrumented;
|
|
15
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// The ai-7 fixture's scripted model and tool, verbatim, so a route's trace can
|
|
2
|
+
// be compared with that fixture's trace under plain Node.
|
|
3
|
+
import { simulateReadableStream, stepCountIs, tool } from "ai";
|
|
4
|
+
import { MockLanguageModelV4 } from "ai/test";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
type StreamPart = Awaited<ReturnType<MockLanguageModelV4["doStream"]>>["stream"] extends ReadableStream<infer P> ? P : never;
|
|
8
|
+
|
|
9
|
+
const usage = (input: number, output: number) => ({
|
|
10
|
+
inputTokens: { total: input, noCache: input, cacheRead: undefined, cacheWrite: undefined },
|
|
11
|
+
outputTokens: { total: output, text: output, reasoning: undefined },
|
|
12
|
+
});
|
|
13
|
+
const finish = (reason: "stop" | "tool-calls") => ({ unified: reason, raw: reason });
|
|
14
|
+
|
|
15
|
+
export function scripted() {
|
|
16
|
+
let generated = 0;
|
|
17
|
+
let streamed = 0;
|
|
18
|
+
return new MockLanguageModelV4({
|
|
19
|
+
provider: "mock-provider",
|
|
20
|
+
modelId: "mock-model",
|
|
21
|
+
doGenerate: async () => {
|
|
22
|
+
generated += 1;
|
|
23
|
+
if (generated === 1) {
|
|
24
|
+
return {
|
|
25
|
+
content: [{ type: "tool-call", toolCallId: "call-1", toolName: "weather", input: '{"city":"Paris"}' }],
|
|
26
|
+
finishReason: finish("tool-calls"),
|
|
27
|
+
usage: usage(11, 7),
|
|
28
|
+
warnings: [],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return { content: [{ type: "text", text: "It is 20C in Paris." }], finishReason: finish("stop"), usage: usage(23, 9), warnings: [] };
|
|
32
|
+
},
|
|
33
|
+
doStream: async () => {
|
|
34
|
+
streamed += 1;
|
|
35
|
+
const text = (id: string, ...deltas: string[]): StreamPart[] => [
|
|
36
|
+
{ type: "text-start", id },
|
|
37
|
+
...deltas.map((delta): StreamPart => ({ type: "text-delta", id, delta })),
|
|
38
|
+
{ type: "text-end", id },
|
|
39
|
+
];
|
|
40
|
+
const chunks: StreamPart[] =
|
|
41
|
+
streamed === 1
|
|
42
|
+
? [
|
|
43
|
+
{ type: "stream-start", warnings: [] },
|
|
44
|
+
{ type: "tool-call", toolCallId: "call-s1", toolName: "weather", input: '{"city":"Rome"}' },
|
|
45
|
+
{ type: "finish", finishReason: finish("tool-calls"), usage: usage(13, 4) },
|
|
46
|
+
]
|
|
47
|
+
: [{ type: "stream-start", warnings: [] }, ...text("t", "Rome is ", "25C."), { type: "finish", finishReason: finish("stop"), usage: usage(30, 6) }];
|
|
48
|
+
return { stream: simulateReadableStream({ chunks }) };
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const tools = () => ({
|
|
54
|
+
weather: tool({
|
|
55
|
+
description: "Current weather for a city",
|
|
56
|
+
inputSchema: z.object({ city: z.string() }),
|
|
57
|
+
execute: async ({ city }: { city: string }) => ({ city, celsius: city === "Paris" ? 20 : 25 }),
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const loop = { stopWhen: stepCountIs(4) };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// The langchain-1 fixture's graph and scripted model, verbatim, so a route's
|
|
2
|
+
// trace can be compared with that fixture's trace under plain Node.
|
|
3
|
+
import { BaseChatModel, type BaseChatModelParams } from "@langchain/core/language_models/chat_models";
|
|
4
|
+
import { AIMessage, HumanMessage, type BaseMessage } from "@langchain/core/messages";
|
|
5
|
+
import type { ChatResult } from "@langchain/core/outputs";
|
|
6
|
+
import { tool } from "@langchain/core/tools";
|
|
7
|
+
import { END, MessagesAnnotation, START, StateGraph } from "@langchain/langgraph";
|
|
8
|
+
import { ToolNode } from "@langchain/langgraph/prebuilt";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
|
|
11
|
+
export class ScriptedModel extends BaseChatModel {
|
|
12
|
+
calls = 0;
|
|
13
|
+
|
|
14
|
+
constructor(fields: BaseChatModelParams = {}) {
|
|
15
|
+
super(fields);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
_llmType(): string {
|
|
19
|
+
return "scripted";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override bindTools(): this {
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async _generate(messages: BaseMessage[]): Promise<ChatResult> {
|
|
27
|
+
this.calls += 1;
|
|
28
|
+
const answered = messages.some((m) => m.getType() === "tool");
|
|
29
|
+
const message = answered
|
|
30
|
+
? new AIMessage({
|
|
31
|
+
content: "It is sunny in Paris.",
|
|
32
|
+
usage_metadata: { input_tokens: 30, output_tokens: 7, total_tokens: 37 },
|
|
33
|
+
response_metadata: { finish_reason: "stop" },
|
|
34
|
+
})
|
|
35
|
+
: new AIMessage({
|
|
36
|
+
content: "",
|
|
37
|
+
tool_calls: [{ id: "call_1", name: "get_weather", args: { city: "Paris" }, type: "tool_call" }],
|
|
38
|
+
usage_metadata: { input_tokens: 12, output_tokens: 5, total_tokens: 17 },
|
|
39
|
+
response_metadata: { finish_reason: "tool_calls" },
|
|
40
|
+
});
|
|
41
|
+
return { generations: [{ text: typeof message.content === "string" ? message.content : "", message }] };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const getWeather = tool(async ({ city }: { city: string }) => `sunny in ${city}`, {
|
|
46
|
+
name: "get_weather",
|
|
47
|
+
description: "Current weather for a city",
|
|
48
|
+
schema: z.object({ city: z.string() }),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export function buildGraph(model: ScriptedModel) {
|
|
52
|
+
const callModel = async (state: typeof MessagesAnnotation.State) => ({
|
|
53
|
+
messages: [await model.invoke(state.messages)],
|
|
54
|
+
});
|
|
55
|
+
const route = (state: typeof MessagesAnnotation.State) => {
|
|
56
|
+
const last = state.messages[state.messages.length - 1] as AIMessage;
|
|
57
|
+
return last.tool_calls?.length ? "tools" : END;
|
|
58
|
+
};
|
|
59
|
+
return new StateGraph(MessagesAnnotation)
|
|
60
|
+
.addNode("agent", callModel)
|
|
61
|
+
.addNode("tools", new ToolNode([getWeather]))
|
|
62
|
+
.addEdge(START, "agent")
|
|
63
|
+
.addConditionalEdges("agent", route, ["tools", END])
|
|
64
|
+
.addEdge("tools", "agent")
|
|
65
|
+
.compile({ name: "weather_graph" });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const question = () => ({ messages: [new HumanMessage("weather?")] });
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// The llamaindex-0.12 fixture's scripted LLM and tool, so a route's trace can
|
|
2
|
+
// be compared with that fixture's `workflow` trace under plain Node.
|
|
3
|
+
//
|
|
4
|
+
// One difference, in spelling only: the fixture decorates `chat` with
|
|
5
|
+
// `@wrapEventCaller @wrapLLMEvent`, and Next's compiler does not take standard
|
|
6
|
+
// decorators. They are applied here by hand — the same two functions, in the
|
|
7
|
+
// same order, with the context object a decorator receives.
|
|
8
|
+
import { wrapEventCaller, wrapLLMEvent } from "@llamaindex/core/decorator";
|
|
9
|
+
import {
|
|
10
|
+
ToolCallLLM,
|
|
11
|
+
type ChatMessage,
|
|
12
|
+
type ChatResponse,
|
|
13
|
+
type ChatResponseChunk,
|
|
14
|
+
type LLMChatParamsNonStreaming,
|
|
15
|
+
type LLMChatParamsStreaming,
|
|
16
|
+
type LLMMetadata,
|
|
17
|
+
type ToolCallLLMMessageOptions,
|
|
18
|
+
} from "@llamaindex/core/llms";
|
|
19
|
+
import { tool } from "llamaindex";
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
|
|
22
|
+
type Options = ToolCallLLMMessageOptions;
|
|
23
|
+
|
|
24
|
+
interface Turn {
|
|
25
|
+
tool?: { name: string; input: Record<string, unknown>; id: string };
|
|
26
|
+
text?: string;
|
|
27
|
+
usage: { prompt_tokens: number; completion_tokens: number };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const weatherTurns = (): Turn[] => [
|
|
31
|
+
{ tool: { name: "get_weather", input: { city: "Paris" }, id: "call_1" }, usage: { prompt_tokens: 12, completion_tokens: 5 } },
|
|
32
|
+
{ text: "It is sunny in Paris.", usage: { prompt_tokens: 30, completion_tokens: 7 } },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const initializers: Array<(this: unknown) => void> = [];
|
|
36
|
+
|
|
37
|
+
export class ScriptedLLM extends ToolCallLLM {
|
|
38
|
+
supportToolCall = true;
|
|
39
|
+
metadata: LLMMetadata = {
|
|
40
|
+
model: "scripted-1",
|
|
41
|
+
temperature: 0,
|
|
42
|
+
topP: 1,
|
|
43
|
+
contextWindow: 4096,
|
|
44
|
+
tokenizer: undefined,
|
|
45
|
+
structuredOutput: false,
|
|
46
|
+
};
|
|
47
|
+
private readonly turns: Turn[];
|
|
48
|
+
|
|
49
|
+
constructor(turns: Turn[] = weatherTurns()) {
|
|
50
|
+
super();
|
|
51
|
+
this.turns = turns;
|
|
52
|
+
for (const init of initializers) init.call(this);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
chat(params: LLMChatParamsStreaming<object, Options>): Promise<AsyncIterable<ChatResponseChunk<Options>>>;
|
|
56
|
+
chat(params: LLMChatParamsNonStreaming<object, Options>): Promise<ChatResponse<Options>>;
|
|
57
|
+
async chat(
|
|
58
|
+
params: LLMChatParamsStreaming<object, Options> | LLMChatParamsNonStreaming<object, Options>,
|
|
59
|
+
): Promise<AsyncIterable<ChatResponseChunk<Options>> | ChatResponse<Options>> {
|
|
60
|
+
const turn = this.turns.shift() ?? { text: "done", usage: { prompt_tokens: 1, completion_tokens: 1 } };
|
|
61
|
+
const options: Options = turn.tool ? { toolCall: [turn.tool] } : {};
|
|
62
|
+
const message: ChatMessage<Options> = { role: "assistant", content: turn.text ?? "", options };
|
|
63
|
+
if (params.stream) {
|
|
64
|
+
return (async function* (): AsyncGenerator<ChatResponseChunk<Options>> {
|
|
65
|
+
yield { delta: turn.text ?? "", raw: { choices: [{ delta: {} }] }, options };
|
|
66
|
+
yield { delta: "", raw: { choices: [], usage: turn.usage }, options: {} };
|
|
67
|
+
})();
|
|
68
|
+
}
|
|
69
|
+
return { message, raw: { choices: [{ finish_reason: turn.tool ? "tool_calls" : "stop" }], usage: turn.usage } };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
const context = {
|
|
75
|
+
kind: "method",
|
|
76
|
+
name: "chat",
|
|
77
|
+
static: false,
|
|
78
|
+
private: false,
|
|
79
|
+
access: { has: () => true, get: () => undefined },
|
|
80
|
+
metadata: {},
|
|
81
|
+
addInitializer: (init: (this: unknown) => void) => void initializers.push(init),
|
|
82
|
+
} as never;
|
|
83
|
+
const proto = ScriptedLLM.prototype as unknown as { chat: (...args: unknown[]) => unknown };
|
|
84
|
+
// `@wrapEventCaller @wrapLLMEvent` applies bottom-up: wrapLLMEvent first.
|
|
85
|
+
proto.chat = (wrapEventCaller as (m: unknown, c: never) => typeof proto.chat)(
|
|
86
|
+
(wrapLLMEvent as (m: unknown, c: never) => typeof proto.chat)(proto.chat, context),
|
|
87
|
+
context,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const getWeather = tool({
|
|
92
|
+
name: "get_weather",
|
|
93
|
+
description: "Current weather for a city",
|
|
94
|
+
parameters: z.object({ city: z.string() }),
|
|
95
|
+
execute: ({ city }) => `sunny in ${city}`,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
export const QUESTION = "weather in Paris?";
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// The mastra-1 fixture's scripted model, tool and agent, verbatim (minus the
|
|
2
|
+
// gate/failure options no route uses), so a route's trace can be compared with
|
|
3
|
+
// that fixture's trace under plain Node.
|
|
4
|
+
import { Agent } from "@mastra/core/agent";
|
|
5
|
+
import { createTool } from "@mastra/core/tools";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
|
|
8
|
+
type Turn = { tool: string; input: Record<string, unknown>; usage: [number, number] } | { text: string; usage: [number, number] };
|
|
9
|
+
|
|
10
|
+
function scriptedModel(turns: Turn[]) {
|
|
11
|
+
let calls = 0;
|
|
12
|
+
const next = (): Turn => turns[calls++ % turns.length]!;
|
|
13
|
+
const usage = ([input, output]: [number, number]) => ({
|
|
14
|
+
inputTokens: input,
|
|
15
|
+
outputTokens: output,
|
|
16
|
+
totalTokens: input + output,
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
specificationVersion: "v2" as const,
|
|
20
|
+
provider: "scripted",
|
|
21
|
+
modelId: "scripted-model",
|
|
22
|
+
supportedUrls: {},
|
|
23
|
+
async doGenerate() {
|
|
24
|
+
const turn = next();
|
|
25
|
+
return "tool" in turn
|
|
26
|
+
? {
|
|
27
|
+
content: [{ type: "tool-call" as const, toolCallId: `call_${calls}`, toolName: turn.tool, input: JSON.stringify(turn.input) }],
|
|
28
|
+
finishReason: "tool-calls" as const,
|
|
29
|
+
usage: usage(turn.usage),
|
|
30
|
+
warnings: [],
|
|
31
|
+
}
|
|
32
|
+
: {
|
|
33
|
+
content: [{ type: "text" as const, text: turn.text }],
|
|
34
|
+
finishReason: "stop" as const,
|
|
35
|
+
usage: usage(turn.usage),
|
|
36
|
+
warnings: [],
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
async doStream() {
|
|
40
|
+
const turn = next();
|
|
41
|
+
const parts: unknown[] = [
|
|
42
|
+
{ type: "stream-start", warnings: [] },
|
|
43
|
+
{ type: "response-metadata", id: `resp_${calls}`, modelId: "scripted-model", timestamp: new Date(0) },
|
|
44
|
+
];
|
|
45
|
+
if ("tool" in turn) {
|
|
46
|
+
parts.push({ type: "tool-call", toolCallId: `call_${calls}`, toolName: turn.tool, input: JSON.stringify(turn.input) });
|
|
47
|
+
parts.push({ type: "finish", finishReason: "tool-calls", usage: usage(turn.usage) });
|
|
48
|
+
} else {
|
|
49
|
+
parts.push({ type: "text-start", id: "t" });
|
|
50
|
+
const cut = turn.text.indexOf(" ", turn.text.length / 2) + 1;
|
|
51
|
+
for (const delta of [turn.text.slice(0, cut), turn.text.slice(cut)]) {
|
|
52
|
+
parts.push({ type: "text-delta", id: "t", delta });
|
|
53
|
+
}
|
|
54
|
+
parts.push({ type: "text-end", id: "t" });
|
|
55
|
+
parts.push({ type: "finish", finishReason: "stop", usage: usage(turn.usage) });
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
stream: new ReadableStream({
|
|
59
|
+
start(controller) {
|
|
60
|
+
for (const part of parts) controller.enqueue(part);
|
|
61
|
+
controller.close();
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const WEATHER_TURNS: Turn[] = [
|
|
70
|
+
{ tool: "weather", input: { city: "Paris" }, usage: [11, 7] },
|
|
71
|
+
{ text: "It is sunny in Paris.", usage: [23, 9] },
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
export const weather = createTool({
|
|
75
|
+
id: "weather",
|
|
76
|
+
description: "Current weather for a city",
|
|
77
|
+
inputSchema: z.object({ city: z.string() }),
|
|
78
|
+
execute: async (input: { city: string }) => ({ city: input.city, forecast: "sunny" }),
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const weatherAgent = () =>
|
|
82
|
+
new Agent({
|
|
83
|
+
id: "weather-agent",
|
|
84
|
+
name: "weather-agent",
|
|
85
|
+
instructions: "Answer weather questions.",
|
|
86
|
+
model: scriptedModel(WEATHER_TURNS) as never,
|
|
87
|
+
tools: { weather },
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
export const question = "What is the weather in Paris?";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { dirname } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
import { withFailproofai } from "@failproofai/sdk/next";
|
|
5
|
+
import type { NextConfig } from "next";
|
|
6
|
+
|
|
7
|
+
const root = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* One app, built several ways by `nextjs.test.ts`, each into its own distDir:
|
|
11
|
+
*
|
|
12
|
+
* FAILPROOFAI_IT_NEXT_EXTERNAL=1 the frameworks (and the SDK) are listed in
|
|
13
|
+
* `serverExternalPackages`, so the server
|
|
14
|
+
* loads them from node_modules at run time
|
|
15
|
+
* (with `import()`, under both bundlers). Unset: Next's DEFAULT, which bundles
|
|
16
|
+
* all four — none of them is on Next's
|
|
17
|
+
* built-in external list.
|
|
18
|
+
*
|
|
19
|
+
* Every build includes `app/api/edge/route.ts`, an Edge-runtime route that
|
|
20
|
+
* imports the SDK: an SDK whose import broke the Edge runtime fails the build.
|
|
21
|
+
*/
|
|
22
|
+
const external = process.env.FAILPROOFAI_IT_NEXT_EXTERNAL === "1";
|
|
23
|
+
/**
|
|
24
|
+
* FAILPROOFAI_IT_NEXT_WRAP=1 the documented setup: the app lists nothing
|
|
25
|
+
* itself and exports `withFailproofai(config)`.
|
|
26
|
+
*/
|
|
27
|
+
const wrap = process.env.FAILPROOFAI_IT_NEXT_WRAP === "1";
|
|
28
|
+
|
|
29
|
+
const config: NextConfig = {
|
|
30
|
+
distDir: process.env.FAILPROOFAI_IT_NEXT_DIST ?? ".next",
|
|
31
|
+
serverExternalPackages: external
|
|
32
|
+
? [
|
|
33
|
+
"@failproofai/sdk",
|
|
34
|
+
"@langchain/core",
|
|
35
|
+
"@langchain/langgraph",
|
|
36
|
+
"ai",
|
|
37
|
+
"@mastra/core",
|
|
38
|
+
"llamaindex",
|
|
39
|
+
"@llamaindex/core",
|
|
40
|
+
"@llamaindex/workflow",
|
|
41
|
+
]
|
|
42
|
+
: [],
|
|
43
|
+
// The build is about what runs, not about the fixtures' types (which the
|
|
44
|
+
// framework fixtures typecheck on their own).
|
|
45
|
+
typescript: { ignoreBuildErrors: true },
|
|
46
|
+
// This fixture sits inside a repo with other lockfiles; without these, Next
|
|
47
|
+
// guesses the workspace root from them and traces files from the wrong one.
|
|
48
|
+
outputFileTracingRoot: root,
|
|
49
|
+
turbopack: { root },
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default wrap ? withFailproofai(config) : config;
|