failproofai 1.0.7-beta.1 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +7 -8
- 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 +5 -7
- 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 +6 -6
- 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 +11 -13
- 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 +7 -8
- 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 +7 -7
- 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 +6 -7
- 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 +8 -41
- package/.next/standalone/.next/server/app/settings/page.js +9 -12
- 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/{[externals]__1j-zsg5._.js → [externals]__1_bftcl._.js} +1 -1
- package/.next/standalone/.next/server/chunks/{[externals]__19_pzeq._.js → [externals]__1msfs-h._.js} +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1bf34x4._.js → [root-of-the-server]__1_r2rbg._.js} +7 -5
- package/.next/standalone/.next/server/chunks/_09dz7xv._.js +21 -21
- 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/{_1q5i8mb._.js → _1c3k-8x._.js} +2 -2
- package/.next/standalone/.next/server/chunks/_1ek68ln._.js +16 -16
- 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_0iu54mz._.js +3 -0
- package/.next/standalone/.next/server/chunks/src_hooks_custom-hooks-loader_ts_0lnb3n3._.js +2 -4
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0-_ki57._.js +4 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__013jr2b._.js +4 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01wy8d-._.js +4 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02npjtd._.js +4 -0
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0yxwl6j._.js → [root-of-the-server]__0bd3mje._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0cg-bgc._.js +5 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0cpu_mj._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1mf3zp6._.js → [root-of-the-server]__0cxe_2_._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0da85px._.js +4 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ftmoxc._.js +4 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0p-5p8u._.js +4 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0u3w0ll._.js +22 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__17d_ffl._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__19d9tgz._.js +5 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1ctpynv._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1jiwfsj._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1p2otjt._.js +4 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1phc187._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_06imw3p._.js +5 -0
- package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_1w_5l7t._.js → _0h_douw._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_214wgrp._.js → _1-i_gzc._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{_0bn2oo8._.js → _166t73i._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_1q46vxx._.js → _1_qswah._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{_1gb0ifp._.js → _1es2j7i._.js} +5 -5
- package/.next/standalone/.next/server/chunks/ssr/_1u8-lu2._.js +3 -0
- 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_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 +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_next_dist_18_d8l1._.js → node_modules_next_dist_0drixxt._.js} +4 -4
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1cv9_c4._.js +10 -0
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_builtin-policies_ts_09j2ndl._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_fp-home_ts_0je3xkv._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_pack-cli_ts_0t7me65._.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 +23 -56
- package/.next/standalone/.next/static/chunks/094xgi4owxaqf.js +1 -0
- package/.next/standalone/.next/static/chunks/0__8a7m868fvf.js +1 -0
- package/.next/standalone/.next/static/chunks/{12tvm75t5ffui.js → 0o6qlkgubtoex.js} +1 -1
- package/.next/standalone/.next/static/chunks/13i7-9is-vhys.js +1 -0
- package/.next/standalone/.next/static/chunks/1rz20_pz828f3.js +6 -0
- package/.next/standalone/.next/static/chunks/2k9f4tyv04809.css +1 -0
- package/.next/standalone/.next/static/chunks/{0vmd180qfntfb.js → 2klitrtzpaoe0.js} +1 -1
- package/.next/standalone/.next/static/chunks/{258668t68du6b.js → 2mdh397ghgnvv.js} +1 -1
- package/.next/standalone/.next/static/chunks/2rshywgeqsyzk.css +2 -0
- package/.next/standalone/.next/static/chunks/3pzx4chkhko9k.js +1 -0
- package/.next/standalone/.next/static/chunks/{0qrbdkv9qmvli.js → 3rh5o7e16irrm.js} +1 -1
- package/.next/standalone/.next/static/chunks/{29fql3nbnfc9q.js → 43ufqrz8qo3h-.js} +1 -1
- package/.next/standalone/SECURITY.md +53 -0
- package/.next/standalone/app/actions/pack-actions.ts +0 -12
- package/.next/standalone/app/policies/hooks-client.tsx +0 -9
- package/.next/standalone/app/settings/page.tsx +1 -20
- package/.next/standalone/app/settings/settings-client.tsx +1 -27
- package/.next/standalone/app/settings/settings.css +0 -79
- package/.next/standalone/package.json +9 -9
- 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 +133 -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 +261 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-4/package.json +16 -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 +156 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/ai-5/package.json +16 -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 +344 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-0.3/package.json +19 -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 +441 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/langchain-dup-core/package.json +19 -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 +6797 -0
- package/.next/standalone/sdk/typescript/integration/fixtures/mastra-0/package.json +24 -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/bin/failproofai.mjs +2 -115
- package/dist/cli.mjs +6538 -13686
- package/dist/index.js +1 -19
- package/dist/worker.mjs +2085 -8012
- package/package.json +9 -9
- package/pi-extension/index.ts +0 -11
- package/scripts/build-policy-pack.mjs +2 -39
- package/src/hooks/builtin-policies.ts +3 -21
- package/src/hooks/cloud-enrollment-cli.ts +1 -1
- package/src/hooks/cloud-managed-policies.ts +0 -22
- package/src/hooks/custom-hooks-loader.ts +7 -45
- package/src/hooks/custom-hooks-registry.ts +1 -45
- package/src/hooks/first-run-gate.ts +0 -5
- package/src/hooks/fp-home.ts +0 -23
- package/src/hooks/handler.ts +6 -265
- package/src/hooks/hook-activity-store.ts +1 -105
- package/src/hooks/hook-telemetry.ts +0 -41
- package/src/hooks/loader-utils.ts +0 -6
- package/src/hooks/pack-cli.ts +17 -278
- package/src/hooks/pack-manifest.ts +7 -479
- package/src/hooks/pack-store.ts +10 -156
- package/src/hooks/policy-catalog.ts +0 -65
- package/src/hooks/policy-evaluator.ts +796 -940
- package/src/hooks/policy-registry.ts +0 -25
- package/src/hooks/policy-types.ts +0 -126
- package/src/hooks/worker-server.ts +26 -119
- package/src/index.ts +0 -6
- package/.next/standalone/.next/server/chunks/src_hooks_01frwmb._.js +0 -5
- package/.next/standalone/.next/server/chunks/src_hooks_18qtd42._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01bmjsj._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__04usis8._.js +0 -4
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__056wjo4._.js +0 -4
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__059yza8._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0eip4_k._.js +0 -22
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0n0xg95._.js +0 -4
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0qcb0mg._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0qxnccm._.js +0 -5
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0rwtwpm._.js +0 -4
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s_yomn._.js +0 -4
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0soxz2z._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0yrsbd_._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11mayhe._.js +0 -4
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__13d-wb6._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1dinjii._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1pprgri._.js +0 -4
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1q4p5b8._.js +0 -4
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1qiz0e4._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_042cgl1._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_0bqoto4._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_0uyu3jf._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_1feuvhb._.js +0 -5
- package/.next/standalone/.next/server/chunks/ssr/app_actions_get-scheduled-audit_ts_0ei9sni._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/app_settings_02tf1h4._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_0w6mzq5._.js +0 -151
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_095a_79._.js +0 -5
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_15t8kqj._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_18k8rl0._.js +0 -12
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1fm2w5z._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1j0zy3v._.js +0 -3
- package/.next/standalone/.next/static/chunks/0cd-_8-c-m1ea.js +0 -6
- package/.next/standalone/.next/static/chunks/0uldbut9y2-e8.js +0 -1
- package/.next/standalone/.next/static/chunks/1u5zsejmgrir_.js +0 -1
- package/.next/standalone/.next/static/chunks/285spx855h_3r.css +0 -2
- package/.next/standalone/.next/static/chunks/2qv4hshejedtx.css +0 -1
- 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/app/actions/get-jev-config.ts +0 -409
- package/.next/standalone/app/actions/update-jev-config.ts +0 -420
- package/.next/standalone/app/components/jev-notices.tsx +0 -96
- package/.next/standalone/app/settings/jev-panel.tsx +0 -469
- package/src/hooks/effective-reviewers.ts +0 -79
- package/src/hooks/jev-activity.ts +0 -385
- package/src/hooks/jev-cli.ts +0 -1193
- package/src/hooks/policy-authority.ts +0 -333
- package/src/hooks/policy-reviewability.ts +0 -229
- package/src/hooks/semantic/combine.ts +0 -541
- package/src/hooks/semantic/compile.ts +0 -176
- package/src/hooks/semantic/decide.ts +0 -392
- package/src/hooks/semantic/envelope.ts +0 -1296
- package/src/hooks/semantic/evaluator.ts +0 -547
- package/src/hooks/semantic/facts.ts +0 -292
- package/src/hooks/semantic/intent.ts +0 -1190
- package/src/hooks/semantic/jev-client.ts +0 -643
- package/src/hooks/semantic/jev-config.ts +0 -594
- package/src/hooks/semantic/jev-review.ts +0 -374
- package/src/hooks/semantic/jev-stats.ts +0 -289
- package/src/hooks/semantic/jev-throttle.ts +0 -421
- package/src/hooks/semantic/pack-policies.ts +0 -251
- package/src/hooks/semantic/policies.ts +0 -596
- package/src/hooks/semantic/precondition-names.ts +0 -60
- package/src/hooks/semantic/preconditions.ts +0 -58
- package/src/hooks/semantic/redact.ts +0 -2910
- package/src/hooks/semantic/types.ts +0 -145
- package/src/hooks/semver-precedence.ts +0 -128
- /package/.next/standalone/.next/static/{T8YAYM9h_64fKv705vug7 → PgeWCHmyVbjRznv2VO7KF}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{T8YAYM9h_64fKv705vug7 → PgeWCHmyVbjRznv2VO7KF}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{T8YAYM9h_64fKv705vug7 → PgeWCHmyVbjRznv2VO7KF}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
+
|
|
7
|
+
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
8
|
+
|
|
9
|
+
import { resolveEsm } from "../src/node-require.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Which copy of a dual-published framework an adapter patches.
|
|
13
|
+
*
|
|
14
|
+
* The first release resolved every framework with `createRequire`, which can
|
|
15
|
+
* only name the CommonJS build — so in an ES-module application, the default
|
|
16
|
+
* for a new TypeScript project, `instrument()` patched a copy nothing used and
|
|
17
|
+
* recorded nothing. These tests build a fake dual package on disk and run
|
|
18
|
+
* `requireModuleCopies` from REAL entry points of each module system, because
|
|
19
|
+
* "which module system is the entry" is a property of the process and cannot be
|
|
20
|
+
* faked from inside a test runner.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
24
|
+
let app: string;
|
|
25
|
+
|
|
26
|
+
function write(path: string, text: string): void {
|
|
27
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
28
|
+
writeFileSync(path, text);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A copy that says which build it is and records that it was loaded. */
|
|
32
|
+
const copy = (marker: string, esm: boolean): string =>
|
|
33
|
+
esm
|
|
34
|
+
? `globalThis.__loaded = [...(globalThis.__loaded ?? []), "${marker}"];\nexport const marker = "${marker}";\nexport class Thing {}\n`
|
|
35
|
+
: `globalThis.__loaded = [...(globalThis.__loaded ?? []), "${marker}"];\nexports.marker = "${marker}";\nexports.Thing = class Thing {};\n`;
|
|
36
|
+
|
|
37
|
+
beforeAll(() => {
|
|
38
|
+
app = mkdtempSync(join(tmpdir(), "failproofai-copies-"));
|
|
39
|
+
const modules = join(app, "node_modules");
|
|
40
|
+
|
|
41
|
+
// A dual package with a root entry, a subpath and a pattern, conditions
|
|
42
|
+
// nested the way real frameworks publish them (`@langchain/core` does
|
|
43
|
+
// exactly `{ import: { types, default }, require: { types, default } }`).
|
|
44
|
+
write(
|
|
45
|
+
join(modules, "dualfw", "package.json"),
|
|
46
|
+
JSON.stringify({
|
|
47
|
+
name: "dualfw",
|
|
48
|
+
version: "1.2.3",
|
|
49
|
+
exports: {
|
|
50
|
+
".": { import: { types: "./x.d.ts", default: "./esm/index.js" }, require: "./cjs/index.cjs" },
|
|
51
|
+
"./callbacks/manager": { import: "./esm/manager.js", require: "./cjs/manager.cjs" },
|
|
52
|
+
"./tools/*": { node: { import: "./esm/tools/*.js", require: "./cjs/tools/*.cjs" } },
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
write(join(modules, "dualfw", "esm", "index.js"), copy("esm", true));
|
|
57
|
+
write(join(modules, "dualfw", "cjs", "index.cjs"), copy("cjs", false));
|
|
58
|
+
write(join(modules, "dualfw", "esm", "manager.js"), copy("esm-manager", true));
|
|
59
|
+
write(join(modules, "dualfw", "cjs", "manager.cjs"), copy("cjs-manager", false));
|
|
60
|
+
write(join(modules, "dualfw", "esm", "tools", "search.js"), copy("esm-search", true));
|
|
61
|
+
write(join(modules, "dualfw", "cjs", "tools", "search.cjs"), copy("cjs-search", false));
|
|
62
|
+
|
|
63
|
+
// ESM-only: no `require` condition, so CommonJS resolution cannot find it.
|
|
64
|
+
write(
|
|
65
|
+
join(modules, "@scope", "esmonly", "package.json"),
|
|
66
|
+
JSON.stringify({ name: "@scope/esmonly", exports: { ".": { import: "./index.js" } } }),
|
|
67
|
+
);
|
|
68
|
+
write(join(modules, "@scope", "esmonly", "index.js"), copy("esmonly", true));
|
|
69
|
+
|
|
70
|
+
// No exports map: Node reads `main` for both, so there is one copy.
|
|
71
|
+
write(join(modules, "plainfw", "package.json"), JSON.stringify({ name: "plainfw", main: "main.js" }));
|
|
72
|
+
write(join(modules, "plainfw", "main.js"), copy("plain", false));
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
afterAll(() => {
|
|
76
|
+
rmSync(app, { recursive: true, force: true });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe("resolveEsm", () => {
|
|
80
|
+
const inApp = <T>(fn: () => T): T => {
|
|
81
|
+
const cwd = process.cwd();
|
|
82
|
+
process.chdir(app);
|
|
83
|
+
try {
|
|
84
|
+
return fn();
|
|
85
|
+
} finally {
|
|
86
|
+
process.chdir(cwd);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
it("names the import build of a dual package, root and subpath", () => {
|
|
91
|
+
inApp(() => {
|
|
92
|
+
expect(resolveEsm("dualfw")).toBe(join(app, "node_modules", "dualfw", "esm", "index.js"));
|
|
93
|
+
expect(resolveEsm("dualfw/callbacks/manager")).toBe(
|
|
94
|
+
join(app, "node_modules", "dualfw", "esm", "manager.js"),
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("expands a subpath pattern through nested conditions", () => {
|
|
100
|
+
inApp(() => {
|
|
101
|
+
expect(resolveEsm("dualfw/tools/search")).toBe(
|
|
102
|
+
join(app, "node_modules", "dualfw", "esm", "tools", "search.js"),
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("finds an ESM-only package that CommonJS resolution cannot", () => {
|
|
108
|
+
inApp(() => {
|
|
109
|
+
expect(resolveEsm("@scope/esmonly")).toBe(join(app, "node_modules", "@scope", "esmonly", "index.js"));
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("returns null where there is no separate ESM copy or no such module", () => {
|
|
114
|
+
inApp(() => {
|
|
115
|
+
expect(resolveEsm("plainfw")).toBeNull();
|
|
116
|
+
expect(resolveEsm("dualfw/not-exported")).toBeNull();
|
|
117
|
+
expect(resolveEsm("not-installed-anywhere")).toBeNull();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe("requireModuleCopies", () => {
|
|
123
|
+
/** Run `body` in a fresh process whose ENTRY is an ES module or CommonJS. */
|
|
124
|
+
const run = (entry: "esm" | "cjs", body: string, where: { dir?: string; cwd?: string } = {}): string[] => {
|
|
125
|
+
const compat =
|
|
126
|
+
entry === "esm"
|
|
127
|
+
? pathToFileURL(join(root, "dist", "esm", "integrations", "compat.js")).href
|
|
128
|
+
: join(root, "dist", "cjs", "integrations", "compat.js");
|
|
129
|
+
const file = join(where.dir ?? app, entry === "esm" ? "main.mjs" : "main.cjs");
|
|
130
|
+
const header =
|
|
131
|
+
entry === "esm"
|
|
132
|
+
? `import { createRequire } from "node:module";\nimport * as compat from ${JSON.stringify(compat)};\nconst require = createRequire(import.meta.url);\n`
|
|
133
|
+
: `const compat = require(${JSON.stringify(compat)});\n`;
|
|
134
|
+
write(
|
|
135
|
+
file,
|
|
136
|
+
`${header}(async () => {\n${body}\nconsole.log(JSON.stringify({ result, loaded: globalThis.__loaded ?? [] }));\n})().catch((e) => { console.log(JSON.stringify({ error: String(e.message) })); });\n`,
|
|
137
|
+
);
|
|
138
|
+
const child = spawnSync(process.execPath, [file], { cwd: where.cwd ?? app, encoding: "utf8" });
|
|
139
|
+
expect(child.stderr).toBe("");
|
|
140
|
+
const parsed = JSON.parse(child.stdout.trim()) as { result?: string[]; loaded?: string[]; error?: string };
|
|
141
|
+
if (parsed.error !== undefined) return [`error: ${parsed.error}`];
|
|
142
|
+
return [...parsed.result!, "|", ...parsed.loaded!];
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const markers = 'const result = (await compat.requireModuleCopies(SPEC, "npm i x")).map((m) => m.marker);';
|
|
146
|
+
|
|
147
|
+
it("patches the ES-module copy for an ES-module app, and loads nothing else", () => {
|
|
148
|
+
expect(run("esm", markers.replace("SPEC", '"dualfw"'))).toEqual(["esm", "|", "esm"]);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("also patches the CommonJS copy when something already required it", () => {
|
|
152
|
+
const body = `require("dualfw");\n${markers.replace("SPEC", '"dualfw"')}`;
|
|
153
|
+
expect(run("esm", body)).toEqual(["esm", "cjs", "|", "cjs", "esm"]);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("patches the CommonJS copy for a CommonJS app, without loading the ESM build", () => {
|
|
157
|
+
expect(run("cjs", markers.replace("SPEC", '"dualfw"'))).toEqual(["cjs", "|", "cjs"]);
|
|
158
|
+
expect(run("cjs", markers.replace("SPEC", '"dualfw/callbacks/manager"'))).toEqual([
|
|
159
|
+
"cjs-manager",
|
|
160
|
+
"|",
|
|
161
|
+
"cjs-manager",
|
|
162
|
+
]);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("uses the one copy an ESM-only or exports-less package has", () => {
|
|
166
|
+
expect(run("esm", markers.replace("SPEC", '"@scope/esmonly"'))).toEqual(["esmonly", "|", "esmonly"]);
|
|
167
|
+
expect(run("cjs", markers.replace("SPEC", '"@scope/esmonly"'))).toEqual(["esmonly", "|", "esmonly"]);
|
|
168
|
+
expect(run("esm", markers.replace("SPEC", '"plainfw"'))).toEqual(["plain", "|", "plain"]);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("finds the framework from the entry script when the service runs from /", () => {
|
|
172
|
+
// systemd with no WorkingDirectory=, a container with WORKDIR unset.
|
|
173
|
+
expect(run("esm", markers.replace("SPEC", '"dualfw"'), { cwd: "/" })).toEqual(["esm", "|", "esm"]);
|
|
174
|
+
expect(run("cjs", markers.replace("SPEC", '"dualfw"'), { cwd: "/" })).toEqual(["cjs", "|", "cjs"]);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it("patches the app's own nested copy, not the one a monorepo root hoists", () => {
|
|
178
|
+
// root/node_modules/dualfw is the hoisted copy; root/apps/web has its own.
|
|
179
|
+
const web = join(app, "apps", "web");
|
|
180
|
+
const nested = join(web, "node_modules", "dualfw");
|
|
181
|
+
write(
|
|
182
|
+
join(nested, "package.json"),
|
|
183
|
+
JSON.stringify({ name: "dualfw", exports: { ".": { import: "./esm.js", require: "./cjs.cjs" } } }),
|
|
184
|
+
);
|
|
185
|
+
write(join(nested, "esm.js"), copy("nested-esm", true));
|
|
186
|
+
write(join(nested, "cjs.cjs"), copy("nested-cjs", false));
|
|
187
|
+
// Started from the monorepo root, as a root-level script runner does.
|
|
188
|
+
expect(run("esm", markers.replace("SPEC", '"dualfw"'), { dir: web, cwd: app })).toEqual([
|
|
189
|
+
"nested-esm",
|
|
190
|
+
"|",
|
|
191
|
+
"nested-esm",
|
|
192
|
+
]);
|
|
193
|
+
expect(run("cjs", markers.replace("SPEC", '"dualfw"'), { dir: web, cwd: app })).toEqual([
|
|
194
|
+
"nested-cjs",
|
|
195
|
+
"|",
|
|
196
|
+
"nested-cjs",
|
|
197
|
+
]);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("throws with the install command when the framework is absent", () => {
|
|
201
|
+
const [line] = run("esm", markers.replace("SPEC", '"not-installed-anywhere"'));
|
|
202
|
+
expect(line).toMatch(/not importable\. Install it with: {2}npm i x/);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { readFileSync, readdirSync } from "node:fs";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
|
|
7
|
+
import * as edge from "../src/edge/index.js";
|
|
8
|
+
import { EDGE_NOTICE, resetNotice } from "../src/edge/notice.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The no-op build an Edge / Worker runtime or a browser bundle gets through the
|
|
12
|
+
* `edge-light` / `workerd` / `worker` / `browser` export conditions.
|
|
13
|
+
*
|
|
14
|
+
* Found by `integration/nextjs.test.ts`: a Next.js route with
|
|
15
|
+
* `export const runtime = "edge"` importing the SDK failed `next build`
|
|
16
|
+
* outright — "Native module not found: node:fs" — because the real entry
|
|
17
|
+
* statically imports Node builtins and an ES module cannot catch that.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
21
|
+
const edgeDir = join(root, "src", "edge");
|
|
22
|
+
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
resetNotice();
|
|
25
|
+
vi.restoreAllMocks();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("the edge build's imports", () => {
|
|
29
|
+
it("imports no Node builtin and nothing from the Node build but VERSION and types", () => {
|
|
30
|
+
for (const file of readdirSync(edgeDir).filter((name) => name.endsWith(".ts"))) {
|
|
31
|
+
const source = readFileSync(join(edgeDir, file), "utf8");
|
|
32
|
+
const imports = [...source.matchAll(/^import\s+(type\s+)?[^;]*?from\s+"([^"]+)";/gms)].map((m) => ({
|
|
33
|
+
typeOnly: m[1] !== undefined,
|
|
34
|
+
from: m[2]!,
|
|
35
|
+
}));
|
|
36
|
+
for (const { typeOnly, from } of imports) {
|
|
37
|
+
if (typeOnly) continue;
|
|
38
|
+
const allowed = from.startsWith("./") || from === "../version.js";
|
|
39
|
+
expect(allowed, `${file} imports ${from} at run time`).toBe(true);
|
|
40
|
+
}
|
|
41
|
+
expect(source, file).not.toMatch(/\bprocess\./);
|
|
42
|
+
expect(source, file).not.toMatch(/require\(/);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Exports of the Node build that are internals (test helpers, parsing
|
|
49
|
+
* functions) rather than API; an edge module need not mirror them. Anything
|
|
50
|
+
* NOT listed here must exist in the edge build, or an Edge import of it is a
|
|
51
|
+
* link error — the crash this build exists to prevent.
|
|
52
|
+
*/
|
|
53
|
+
const INTERNAL: Record<string, string[]> = {
|
|
54
|
+
index: [],
|
|
55
|
+
ai: ["toolCallsOf", "_internals", "usageTokens", "stopReasonOf", "responseContent"],
|
|
56
|
+
langchain: [
|
|
57
|
+
"ABANDONED_ROOT_GRACE_MS",
|
|
58
|
+
"PAUSED_SESSION_TTL_MS",
|
|
59
|
+
"_stats",
|
|
60
|
+
"captureLimitOf",
|
|
61
|
+
"interruptIdOf",
|
|
62
|
+
"isCancellation",
|
|
63
|
+
"isControlFlow",
|
|
64
|
+
"nodeOf",
|
|
65
|
+
"normalizeMessages",
|
|
66
|
+
"resetOrphanWarning",
|
|
67
|
+
"promptOf",
|
|
68
|
+
"readOptions",
|
|
69
|
+
"summarizeDocuments",
|
|
70
|
+
"toolOutput",
|
|
71
|
+
"usageOf",
|
|
72
|
+
],
|
|
73
|
+
mastra: ["_internals"],
|
|
74
|
+
llamaindex: ["BELOW_VERSION", "MIN_VERSION", "eventCallerStorage", "parseOptions", "summarizeNodes", "usageOf"],
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const PAIRS: Array<[string, () => Promise<Record<string, unknown>>, () => Promise<Record<string, unknown>>]> = [
|
|
78
|
+
["index", () => import("../src/index.js"), () => import("../src/edge/index.js")],
|
|
79
|
+
["ai", () => import("../src/integrations/ai.js"), () => import("../src/edge/ai.js")],
|
|
80
|
+
["langchain", () => import("../src/integrations/langchain.js"), () => import("../src/edge/langchain.js")],
|
|
81
|
+
["mastra", () => import("../src/integrations/mastra.js"), () => import("../src/edge/mastra.js")],
|
|
82
|
+
["llamaindex", () => import("../src/integrations/llamaindex.js"), () => import("../src/edge/llamaindex.js")],
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
describe.each(PAIRS)("the edge %s module", (name, loadReal, loadEdge) => {
|
|
86
|
+
it("exports every public name the Node build does, as the same kind of value", async () => {
|
|
87
|
+
const real = await loadReal();
|
|
88
|
+
const noop = await loadEdge();
|
|
89
|
+
const missing: string[] = [];
|
|
90
|
+
for (const key of Object.keys(real)) {
|
|
91
|
+
if (INTERNAL[name]!.includes(key)) continue;
|
|
92
|
+
if (!(key in noop)) missing.push(key);
|
|
93
|
+
else expect(typeof noop[key], `${name}.${key}`).toBe(typeof real[key]);
|
|
94
|
+
}
|
|
95
|
+
expect(missing).toEqual([]);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("is what every edge export condition selects", () => {
|
|
99
|
+
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8")) as {
|
|
100
|
+
exports: Record<string, Record<string, unknown>>;
|
|
101
|
+
};
|
|
102
|
+
const entry = manifest.exports[name === "index" ? "." : `./${name}`]!;
|
|
103
|
+
const conditions = Object.keys(entry);
|
|
104
|
+
// Ahead of import/require: a bundler takes the FIRST condition it matches.
|
|
105
|
+
expect(conditions.slice(0, 4)).toEqual(["edge-light", "workerd", "worker", "browser"]);
|
|
106
|
+
for (const condition of conditions.slice(0, 4)) {
|
|
107
|
+
expect(entry[condition]).toEqual({
|
|
108
|
+
import: { types: expect.any(String), default: `./dist/esm/edge/${name}.js` },
|
|
109
|
+
require: { types: expect.any(String), default: `./dist/cjs/edge/${name}.js` },
|
|
110
|
+
});
|
|
111
|
+
// The REAL declarations, so code that compiles for Node compiles here.
|
|
112
|
+
const real = name === "index" ? "index" : `integrations/${name}`;
|
|
113
|
+
expect((entry[condition] as { import: { types: string } }).import.types).toBe(`./dist/esm/${real}.d.ts`);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe("the edge build's behaviour", () => {
|
|
119
|
+
it("runs scope bodies and returns their values, recording nothing", async () => {
|
|
120
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
121
|
+
const out = await edge.session({ sessionId: "s-1" }, (sessionId) =>
|
|
122
|
+
edge.agent("planner", { goal: "g" }, (identity) =>
|
|
123
|
+
edge.toolCall("search", { toolCallId: "call-1", input: { q: 1 } }, (call) => {
|
|
124
|
+
call.output = 42;
|
|
125
|
+
return { sessionId, agent: identity.agentId, call: call.id, assigned: call.outputAssigned };
|
|
126
|
+
}),
|
|
127
|
+
),
|
|
128
|
+
);
|
|
129
|
+
expect(out).toEqual({ sessionId: "s-1", agent: "planner", call: "call-1", assigned: true });
|
|
130
|
+
expect(edge.session(() => "no options")).toBe("no options");
|
|
131
|
+
expect(await edge.agent("a", async () => 7)).toBe(7);
|
|
132
|
+
|
|
133
|
+
const scope = edge.agent.open("planner");
|
|
134
|
+
expect(scope.agentId).toBe("planner");
|
|
135
|
+
scope.dispose();
|
|
136
|
+
edge.session.open().dispose();
|
|
137
|
+
edge.toolCall.open("t").dispose();
|
|
138
|
+
|
|
139
|
+
for (const method of Object.keys(edge.event)) {
|
|
140
|
+
expect(() => (edge.event as unknown as Record<string, (o: unknown) => void>)[method]!({})).not.toThrow();
|
|
141
|
+
}
|
|
142
|
+
expect(Object.keys(edge.event)).toHaveLength(15);
|
|
143
|
+
await expect(edge.flush()).resolves.toBeUndefined();
|
|
144
|
+
expect(await edge.instrument()).toEqual([]);
|
|
145
|
+
expect(await (edge.instrument as (name: string) => Promise<unknown[]>)("langchain")).toEqual([]);
|
|
146
|
+
expect(edge.uninstrument()).toEqual([]);
|
|
147
|
+
expect(edge.current().sessionId).toBeNull();
|
|
148
|
+
expect(edge.AUTO).toBe(Symbol.for("failproofai.AUTO"));
|
|
149
|
+
|
|
150
|
+
// Said once, on first use — and it says nothing is recorded.
|
|
151
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
152
|
+
expect(warn.mock.calls[0]![0]).toBe(`[failproofai-sdk] ${EDGE_NOTICE}`);
|
|
153
|
+
expect(EDGE_NOTICE).toContain("NOTHING is recorded");
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("is silent when merely imported", async () => {
|
|
157
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
158
|
+
await import("../src/edge/ai.js");
|
|
159
|
+
expect(warn).not.toHaveBeenCalled();
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it("hands the frameworks values they accept and that record nothing", async () => {
|
|
163
|
+
vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
164
|
+
const ai = await import("../src/edge/ai.js");
|
|
165
|
+
expect(ai.telemetry({ functionId: "f" })).toEqual({ isEnabled: false, functionId: "f" });
|
|
166
|
+
const model = { modelId: "m" };
|
|
167
|
+
expect(await ai.wrapModel(model)).toBe(model);
|
|
168
|
+
const mw = ai.middleware();
|
|
169
|
+
expect(await mw.wrapGenerate({ doGenerate: async () => "generated" })).toBe("generated");
|
|
170
|
+
expect(await mw.wrapStream({ doStream: async () => "streamed" })).toBe("streamed");
|
|
171
|
+
const tool = { execute: () => 1 };
|
|
172
|
+
expect(ai.wrapTool("t", tool)).toBe(tool);
|
|
173
|
+
expect(ai.tracer().startActiveSpan("x", (span: { isRecording(): boolean }) => span.isRecording())).toBe(false);
|
|
174
|
+
|
|
175
|
+
const langchain = await import("../src/edge/langchain.js");
|
|
176
|
+
expect(typeof langchain.langchainHandler()).toBe("object");
|
|
177
|
+
const mastra = await import("../src/edge/mastra.js");
|
|
178
|
+
expect(mastra.workflow("w", () => "ran")).toBe("ran");
|
|
179
|
+
expect(mastra.wrapTool(tool)).toBe(tool);
|
|
180
|
+
const llamaindex = await import("../src/edge/llamaindex.js");
|
|
181
|
+
expect(typeof llamaindex.attach()).toBe("function");
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { EvaluatorAPIError, EvaluatorClient } from "../src/evaluator/client.js";
|
|
4
|
+
import { PROTOCOL_VERSION } from "../src/evaluator/protocol.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Four properties in here are security or correctness, not style:
|
|
8
|
+
* redirects are refused, every URL is pinned to the configured origin,
|
|
9
|
+
* responses are bounded WHILE they are read, and `claim` is never retried.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function jsonResponse(body: unknown, status = 200): Response {
|
|
13
|
+
return new Response(JSON.stringify(body), {
|
|
14
|
+
status,
|
|
15
|
+
headers: { "content-type": "application/json" },
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function makeClient(options: Partial<ConstructorParameters<typeof EvaluatorClient>[0]> = {}) {
|
|
20
|
+
const fetchImpl = vi.fn(async () =>
|
|
21
|
+
jsonResponse({
|
|
22
|
+
protocol_version: PROTOCOL_VERSION,
|
|
23
|
+
evaluator_instance_id: "i1",
|
|
24
|
+
evaluator_kind: "customer",
|
|
25
|
+
heartbeat_interval_seconds: 30,
|
|
26
|
+
lease_duration_seconds: 120,
|
|
27
|
+
poll_interval_seconds: 10,
|
|
28
|
+
claim_limit: 4,
|
|
29
|
+
disabled_definitions: [],
|
|
30
|
+
}),
|
|
31
|
+
);
|
|
32
|
+
const client = new EvaluatorClient({
|
|
33
|
+
baseUrl: "https://api.example.test",
|
|
34
|
+
credential: "token",
|
|
35
|
+
fetchImpl: fetchImpl,
|
|
36
|
+
sleep: async () => undefined,
|
|
37
|
+
...options,
|
|
38
|
+
});
|
|
39
|
+
return { client, fetchImpl };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe("construction", () => {
|
|
43
|
+
it("refuses plaintext http to a non-loopback host", () => {
|
|
44
|
+
expect(() => new EvaluatorClient({ baseUrl: "http://api.example.test", credential: "t" })).toThrow(
|
|
45
|
+
/must use https unless it targets loopback/,
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("allows http to loopback, where there is no network to eavesdrop", () => {
|
|
50
|
+
for (const host of ["http://localhost:8020", "http://127.0.0.1:8020", "http://[::1]:8020"]) {
|
|
51
|
+
expect(() => new EvaluatorClient({ baseUrl: host, credential: "t" })).not.toThrow();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("refuses a credential that would let a header be injected", () => {
|
|
56
|
+
expect(() =>
|
|
57
|
+
new EvaluatorClient({ baseUrl: "https://a.test", credential: "tok\r\nX-Evil: 1" }),
|
|
58
|
+
).toThrow(/control characters/);
|
|
59
|
+
expect(() => new EvaluatorClient({ baseUrl: "https://a.test", credential: " " })).toThrow(
|
|
60
|
+
/must not be empty/,
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("refuses a non-absolute base url", () => {
|
|
65
|
+
expect(() => new EvaluatorClient({ baseUrl: "/v1", credential: "t" })).toThrow(
|
|
66
|
+
/absolute http\(s\) URL/,
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("requests", () => {
|
|
72
|
+
it("sends the bearer credential and refuses redirects", async () => {
|
|
73
|
+
const { client, fetchImpl } = makeClient();
|
|
74
|
+
await client.register({
|
|
75
|
+
workerId: "w1",
|
|
76
|
+
sdkVersion: "0",
|
|
77
|
+
catalogRevision: "sha256:0",
|
|
78
|
+
maxConcurrency: 1,
|
|
79
|
+
definitions: [],
|
|
80
|
+
});
|
|
81
|
+
const [, init] = fetchImpl.mock.calls[0] as unknown as [string, RequestInit];
|
|
82
|
+
expect((init.headers as Record<string, string>).Authorization).toBe("Bearer token");
|
|
83
|
+
// Following a redirect would carry the Authorization header to wherever it
|
|
84
|
+
// points, which turns a misconfigured server into credential exfiltration.
|
|
85
|
+
expect(init.redirect).toBe("error");
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("refuses a server-supplied URL outside the configured origin", async () => {
|
|
89
|
+
const { client } = makeClient();
|
|
90
|
+
await expect(
|
|
91
|
+
client.transcript(
|
|
92
|
+
{
|
|
93
|
+
assignmentId: "a1",
|
|
94
|
+
leaseGeneration: 1,
|
|
95
|
+
leaseExpiresAt: "",
|
|
96
|
+
sessionId: "s",
|
|
97
|
+
sessionRevisionId: "r",
|
|
98
|
+
agentId: "main",
|
|
99
|
+
environment: "dev",
|
|
100
|
+
triggerReason: "x",
|
|
101
|
+
eventCount: 0,
|
|
102
|
+
transcriptUrl: "https://attacker.test/transcript",
|
|
103
|
+
definitionsUrl: "",
|
|
104
|
+
},
|
|
105
|
+
"w1",
|
|
106
|
+
),
|
|
107
|
+
).rejects.toThrow(/outside the configured API origin/);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("retries a retryable status and stops at the cap", async () => {
|
|
111
|
+
const fetchImpl = vi.fn(async () => jsonResponse({}, 503));
|
|
112
|
+
const client = new EvaluatorClient({
|
|
113
|
+
baseUrl: "https://api.example.test",
|
|
114
|
+
credential: "t",
|
|
115
|
+
maxRetries: 2,
|
|
116
|
+
fetchImpl: fetchImpl,
|
|
117
|
+
sleep: async () => undefined,
|
|
118
|
+
});
|
|
119
|
+
await expect(
|
|
120
|
+
client.register({
|
|
121
|
+
workerId: "w1",
|
|
122
|
+
sdkVersion: "0",
|
|
123
|
+
catalogRevision: "sha256:0",
|
|
124
|
+
maxConcurrency: 1,
|
|
125
|
+
definitions: [],
|
|
126
|
+
}),
|
|
127
|
+
).rejects.toThrow(EvaluatorAPIError);
|
|
128
|
+
expect(fetchImpl).toHaveBeenCalledTimes(3);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("does not retry a non-retryable status", async () => {
|
|
132
|
+
const fetchImpl = vi.fn(async () =>
|
|
133
|
+
jsonResponse(
|
|
134
|
+
{
|
|
135
|
+
protocol_version: PROTOCOL_VERSION,
|
|
136
|
+
error: { code: "invalid_credentials", message: "nope", retryable: false, request_id: "r" },
|
|
137
|
+
},
|
|
138
|
+
401,
|
|
139
|
+
),
|
|
140
|
+
);
|
|
141
|
+
const client = new EvaluatorClient({
|
|
142
|
+
baseUrl: "https://api.example.test",
|
|
143
|
+
credential: "t",
|
|
144
|
+
fetchImpl: fetchImpl,
|
|
145
|
+
sleep: async () => undefined,
|
|
146
|
+
});
|
|
147
|
+
await expect(
|
|
148
|
+
client.register({
|
|
149
|
+
workerId: "w1",
|
|
150
|
+
sdkVersion: "0",
|
|
151
|
+
catalogRevision: "sha256:0",
|
|
152
|
+
maxConcurrency: 1,
|
|
153
|
+
definitions: [],
|
|
154
|
+
}),
|
|
155
|
+
).rejects.toMatchObject({ code: "invalid_credentials", retryable: false });
|
|
156
|
+
expect(fetchImpl).toHaveBeenCalledTimes(1);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("NEVER retries a claim, because a lost response may already have leased work", async () => {
|
|
160
|
+
const fetchImpl = vi.fn(async () => jsonResponse({}, 503));
|
|
161
|
+
const client = new EvaluatorClient({
|
|
162
|
+
baseUrl: "https://api.example.test",
|
|
163
|
+
credential: "t",
|
|
164
|
+
maxRetries: 5,
|
|
165
|
+
fetchImpl: fetchImpl,
|
|
166
|
+
sleep: async () => undefined,
|
|
167
|
+
});
|
|
168
|
+
await expect(
|
|
169
|
+
client.claim({ workerId: "w1", catalogRevision: "sha256:0", capacity: 1 }),
|
|
170
|
+
).rejects.toThrow();
|
|
171
|
+
expect(fetchImpl).toHaveBeenCalledTimes(1);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("reports a non-JSON body as an invalid response rather than crashing", async () => {
|
|
175
|
+
const fetchImpl = vi.fn(async () => new Response("<html>gateway</html>", { status: 200 }));
|
|
176
|
+
const client = new EvaluatorClient({
|
|
177
|
+
baseUrl: "https://api.example.test",
|
|
178
|
+
credential: "t",
|
|
179
|
+
fetchImpl: fetchImpl,
|
|
180
|
+
sleep: async () => undefined,
|
|
181
|
+
});
|
|
182
|
+
await expect(
|
|
183
|
+
client.register({
|
|
184
|
+
workerId: "w1",
|
|
185
|
+
sdkVersion: "0",
|
|
186
|
+
catalogRevision: "sha256:0",
|
|
187
|
+
maxConcurrency: 1,
|
|
188
|
+
definitions: [],
|
|
189
|
+
}),
|
|
190
|
+
).rejects.toMatchObject({ code: "invalid_response" });
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("stops reading a body past the limit instead of buffering it whole", async () => {
|
|
194
|
+
const huge = "x".repeat(4 * 1024 * 1024);
|
|
195
|
+
const fetchImpl = vi.fn(async () => jsonResponse({ padding: huge }));
|
|
196
|
+
const client = new EvaluatorClient({
|
|
197
|
+
baseUrl: "https://api.example.test",
|
|
198
|
+
credential: "t",
|
|
199
|
+
fetchImpl: fetchImpl,
|
|
200
|
+
sleep: async () => undefined,
|
|
201
|
+
});
|
|
202
|
+
await expect(
|
|
203
|
+
client.register({
|
|
204
|
+
workerId: "w1",
|
|
205
|
+
sdkVersion: "0",
|
|
206
|
+
catalogRevision: "sha256:0",
|
|
207
|
+
maxConcurrency: 1,
|
|
208
|
+
definitions: [],
|
|
209
|
+
}),
|
|
210
|
+
).rejects.toMatchObject({ code: "response_too_large" });
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("classifies a transport failure as retryable", async () => {
|
|
214
|
+
const fetchImpl = vi.fn(async () => {
|
|
215
|
+
throw new Error("ECONNREFUSED");
|
|
216
|
+
});
|
|
217
|
+
const client = new EvaluatorClient({
|
|
218
|
+
baseUrl: "https://api.example.test",
|
|
219
|
+
credential: "t",
|
|
220
|
+
maxRetries: 0,
|
|
221
|
+
fetchImpl: fetchImpl,
|
|
222
|
+
sleep: async () => undefined,
|
|
223
|
+
});
|
|
224
|
+
await expect(
|
|
225
|
+
client.register({
|
|
226
|
+
workerId: "w1",
|
|
227
|
+
sdkVersion: "0",
|
|
228
|
+
catalogRevision: "sha256:0",
|
|
229
|
+
maxConcurrency: 1,
|
|
230
|
+
definitions: [],
|
|
231
|
+
}),
|
|
232
|
+
).rejects.toMatchObject({ code: "transport_error", retryable: true });
|
|
233
|
+
});
|
|
234
|
+
});
|