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,177 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The release scheme for `@failproofai/sdk`, and the only place it is written
|
|
4
|
+
* down.
|
|
5
|
+
*
|
|
6
|
+
* The publish workflow calls this rather than restating the arithmetic, for the
|
|
7
|
+
* same reason `scripts/python-version.py` exists on the Python side: a release
|
|
8
|
+
* rule spelled out in YAML is a release rule nothing can test.
|
|
9
|
+
*
|
|
10
|
+
* ## The scheme
|
|
11
|
+
*
|
|
12
|
+
* | from | next |
|
|
13
|
+
* |-----------------------|-------------------------|
|
|
14
|
+
* | beta `X.Y.Z-beta.N` | `X.Y.Z-beta.(N+1)` |
|
|
15
|
+
* | stable `X.Y.Z` | `X.Y.(Z+1)-beta.0` |
|
|
16
|
+
*
|
|
17
|
+
* The same rule `publish.yml` applies to the `failproofai` npm package. Unlike
|
|
18
|
+
* PyPI, npm HAS dist-tags, so a pre-release publishes behind `beta` and a bare
|
|
19
|
+
* `npm install @failproofai/sdk` never resolves it — which is why a prerelease
|
|
20
|
+
* here is a cheaper mistake than one on PyPI, and why the guard rails below are
|
|
21
|
+
* about not BURNING a version rather than about not shipping one.
|
|
22
|
+
*
|
|
23
|
+
* ## Commands
|
|
24
|
+
*
|
|
25
|
+
* resolve print the version in src/version.ts, and what follows it
|
|
26
|
+
* write <version> move src/version.ts and package.json to <version>
|
|
27
|
+
* changelog <version> print that version's CHANGELOG section
|
|
28
|
+
*
|
|
29
|
+
* Node's standard library only: this runs in the preflight job, which installs
|
|
30
|
+
* nothing precisely so that no third-party code decides whether a release may
|
|
31
|
+
* proceed.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
35
|
+
import { dirname, join } from "node:path";
|
|
36
|
+
import { fileURLToPath } from "node:url";
|
|
37
|
+
|
|
38
|
+
const root = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
39
|
+
const VERSION_FILE = join(root, "src/version.ts");
|
|
40
|
+
const MANIFEST_FILE = join(root, "package.json");
|
|
41
|
+
const CHANGELOG_FILE = join(root, "CHANGELOG.md");
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Only canonical spellings are accepted.
|
|
45
|
+
*
|
|
46
|
+
* `1.2.3-beta.01`, `v1.2.3` and `1.2.3-beta` are all things a human types and
|
|
47
|
+
* npm stores as something else or refuses outright. Every consumer in the
|
|
48
|
+
* pipeline compares version STRINGS — this file, the tarball name, the dist-tag
|
|
49
|
+
* and the "is this published" query — so a spelling that round-trips
|
|
50
|
+
* differently is a release that half-succeeds.
|
|
51
|
+
*/
|
|
52
|
+
const CANONICAL = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-beta\.(0|[1-9]\d*))?$/;
|
|
53
|
+
|
|
54
|
+
function fail(message) {
|
|
55
|
+
process.stderr.write(`release: ${message}\n`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function readVersion() {
|
|
60
|
+
const source = readFileSync(VERSION_FILE, "utf8");
|
|
61
|
+
const match = /export const VERSION = "([^"]+)";/.exec(source);
|
|
62
|
+
if (match === null) fail(`could not find VERSION in ${VERSION_FILE}`);
|
|
63
|
+
return match[1];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function parse(version) {
|
|
67
|
+
const match = CANONICAL.exec(version);
|
|
68
|
+
if (match === null) {
|
|
69
|
+
fail(
|
|
70
|
+
`${version} is not a canonical version. This package uses X.Y.Z or ` +
|
|
71
|
+
"X.Y.Z-beta.N with no leading zeroes and no other pre-release kinds — " +
|
|
72
|
+
"anything else stores on npm as a different string than the one in the " +
|
|
73
|
+
"source, and the pipeline compares strings.",
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
major: Number(match[1]),
|
|
78
|
+
minor: Number(match[2]),
|
|
79
|
+
patch: Number(match[3]),
|
|
80
|
+
beta: match[5] === undefined ? null : Number(match[5]),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function next(version) {
|
|
85
|
+
const { major, minor, patch, beta } = parse(version);
|
|
86
|
+
return beta === null
|
|
87
|
+
? `${major}.${minor}.${patch + 1}-beta.0`
|
|
88
|
+
: `${major}.${minor}.${patch}-beta.${beta + 1}`;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The CHANGELOG section for `version`, which becomes the GitHub Release body.
|
|
93
|
+
*
|
|
94
|
+
* A release whose section is missing or empty is refused before anything is
|
|
95
|
+
* built. A published version nobody can read the changes for is a version that
|
|
96
|
+
* may as well not have shipped.
|
|
97
|
+
*/
|
|
98
|
+
function changelogSection(version) {
|
|
99
|
+
const lines = readFileSync(CHANGELOG_FILE, "utf8").split("\n");
|
|
100
|
+
const heading = new RegExp(`^## ${version.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\b`);
|
|
101
|
+
const start = lines.findIndex((line) => heading.test(line));
|
|
102
|
+
if (start === -1) {
|
|
103
|
+
fail(
|
|
104
|
+
`CHANGELOG.md has no "## ${version} — <date>" section. Add one before releasing; ` +
|
|
105
|
+
"it becomes the GitHub Release body.",
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
const rest = lines.slice(start + 1);
|
|
109
|
+
const end = rest.findIndex((line) => line.startsWith("## "));
|
|
110
|
+
const body = (end === -1 ? rest : rest.slice(0, end)).join("\n").trim();
|
|
111
|
+
if (body === "") fail(`CHANGELOG.md's "## ${version}" section is empty.`);
|
|
112
|
+
return body;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function write(version) {
|
|
116
|
+
parse(version);
|
|
117
|
+
const source = readFileSync(VERSION_FILE, "utf8");
|
|
118
|
+
writeFileSync(
|
|
119
|
+
VERSION_FILE,
|
|
120
|
+
source.replace(/export const VERSION = "[^"]+";/, `export const VERSION = "${version}";`),
|
|
121
|
+
);
|
|
122
|
+
const manifest = readFileSync(MANIFEST_FILE, "utf8");
|
|
123
|
+
// A targeted replacement rather than a parse-and-re-serialise: rewriting the
|
|
124
|
+
// whole manifest would reformat every line and make the release commit
|
|
125
|
+
// unreadable in review.
|
|
126
|
+
const replaced = manifest.replace(/("version":\s*")[^"]+(")/, `$1${version}$2`);
|
|
127
|
+
if (replaced === manifest) fail("could not find a version field in package.json");
|
|
128
|
+
writeFileSync(MANIFEST_FILE, replaced);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function emit(name, value) {
|
|
132
|
+
const file = process.env.GITHUB_OUTPUT;
|
|
133
|
+
const multiline = value.includes("\n");
|
|
134
|
+
const line = multiline
|
|
135
|
+
? `${name}<<__RELEASE_EOF__\n${value}\n__RELEASE_EOF__\n`
|
|
136
|
+
: `${name}=${value}\n`;
|
|
137
|
+
if (file) writeFileSync(file, line, { flag: "a" });
|
|
138
|
+
process.stdout.write(multiline ? `${name}:\n${value}\n` : `${name}=${value}\n`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const [command, argument] = process.argv.slice(2);
|
|
142
|
+
|
|
143
|
+
switch (command) {
|
|
144
|
+
case "resolve": {
|
|
145
|
+
const version = readVersion();
|
|
146
|
+
parse(version);
|
|
147
|
+
const manifest = JSON.parse(readFileSync(MANIFEST_FILE, "utf8"));
|
|
148
|
+
if (manifest.version !== version) {
|
|
149
|
+
fail(
|
|
150
|
+
`package.json says ${manifest.version} but src/version.ts says ${version}. ` +
|
|
151
|
+
"They are read by different consumers and must agree.",
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
emit("version", version);
|
|
155
|
+
emit("next_version", next(version));
|
|
156
|
+
emit("is_prerelease", String(parse(version).beta !== null));
|
|
157
|
+
emit("dist_tag", parse(version).beta === null ? "latest" : "beta");
|
|
158
|
+
emit("tag", `ts-sdk-v${version}`);
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
case "write": {
|
|
162
|
+
if (!argument) fail("write needs a version");
|
|
163
|
+
write(argument);
|
|
164
|
+
process.stdout.write(`release: moved to ${argument}\n`);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case "changelog": {
|
|
168
|
+
emit("body", changelogSection(argument ?? readVersion()));
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case "next": {
|
|
172
|
+
process.stdout.write(`${next(argument ?? readVersion())}\n`);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
default:
|
|
176
|
+
fail("usage: release.mjs resolve | write <version> | changelog [version] | next [version]");
|
|
177
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event timestamps: wall-clock milliseconds, with the microsecond digits used
|
|
3
|
+
* to keep emission order inside a millisecond.
|
|
4
|
+
*
|
|
5
|
+
* The wire format has six fractional digits (the Python SDK writes real
|
|
6
|
+
* microseconds), and the dashboard orders a session's events by that field.
|
|
7
|
+
* JavaScript's wall clock resolves to the millisecond, and a fast agent emits
|
|
8
|
+
* `model_response`, `tool_use`, `tool_result` and the next `model_request`
|
|
9
|
+
* inside one — so with the last three digits always `000` they tied, and the
|
|
10
|
+
* dashboard showed a `tool_result` before its own `tool_use`.
|
|
11
|
+
*
|
|
12
|
+
* So each stamp is `max(wall µs, previous + 1)`. The digits below the
|
|
13
|
+
* millisecond are a sequence, not a measurement — nothing here claims a
|
|
14
|
+
* precision the clock does not have — and the millisecond part is still the
|
|
15
|
+
* wall clock. The sequence is process-wide and shared through `globalThis`, so
|
|
16
|
+
* the ESM and CommonJS copies of this package loaded into one process (the
|
|
17
|
+
* dual-package case the adapters already handle) cannot interleave two
|
|
18
|
+
* sequences.
|
|
19
|
+
*
|
|
20
|
+
* A wall clock that steps BACK (NTP, a VM resume) is followed, not fought: if
|
|
21
|
+
* the sequence is more than a second ahead of the wall, it re-anchors. Holding
|
|
22
|
+
* `previous + 1` instead would freeze every timestamp at the old time for as
|
|
23
|
+
* long as the step was — an hour's step, an hour of events stamped with one
|
|
24
|
+
* instant.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const KEY = Symbol.for("@failproofai/sdk.clock");
|
|
28
|
+
const MAX_LEAD_MICROS = 1_000_000;
|
|
29
|
+
|
|
30
|
+
interface ClockState {
|
|
31
|
+
last: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function state(): ClockState {
|
|
35
|
+
const holder = globalThis as unknown as Record<symbol, ClockState | undefined>;
|
|
36
|
+
let found = holder[KEY];
|
|
37
|
+
if (found === undefined) {
|
|
38
|
+
found = { last: 0 };
|
|
39
|
+
holder[KEY] = found;
|
|
40
|
+
}
|
|
41
|
+
return found;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Microseconds since the epoch, strictly increasing within the process. */
|
|
45
|
+
export function nowMicros(): number {
|
|
46
|
+
const clock = state();
|
|
47
|
+
const wall = Date.now() * 1000;
|
|
48
|
+
const next = wall > clock.last || clock.last - wall > MAX_LEAD_MICROS ? wall : clock.last + 1;
|
|
49
|
+
clock.last = next;
|
|
50
|
+
return next;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** `2026-09-23T12:34:56.123456Z`: six fractional digits, as the ingest parser expects. */
|
|
54
|
+
export function formatMicros(micros: number): string {
|
|
55
|
+
const ms = Math.floor(micros / 1000);
|
|
56
|
+
const sub = String(micros - ms * 1000).padStart(3, "0");
|
|
57
|
+
return `${new Date(ms).toISOString().slice(0, -1)}${sub}Z`;
|
|
58
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient run identity, carried on an `AsyncLocalStorage`.
|
|
3
|
+
*
|
|
4
|
+
* Without this the SDK would have no ambient session: every `event.*` call
|
|
5
|
+
* would take `sessionId` and `agentId` as required arguments and nothing would
|
|
6
|
+
* propagate them. Threading both through every function that might emit an
|
|
7
|
+
* event is what makes instrumentation sprawl into a diff nobody wants to
|
|
8
|
+
* review. `session()` / `agent()` bind them instead.
|
|
9
|
+
*
|
|
10
|
+
* ## Why `AsyncLocalStorage` and not a module-level variable
|
|
11
|
+
*
|
|
12
|
+
* An agent process runs many logical runs at once — a server handling
|
|
13
|
+
* concurrent requests, a supervisor fanning out to sub-agents. A plain variable
|
|
14
|
+
* is shared by all of them, so the last writer wins and every event after it is
|
|
15
|
+
* attributed to the wrong run. `AsyncLocalStorage` is Node's equivalent of
|
|
16
|
+
* Python's `contextvars`: the value follows the async call tree through
|
|
17
|
+
* `await`, `.then()`, timers and `EventEmitter` callbacks created inside the
|
|
18
|
+
* scope, and two concurrent branches see two different values.
|
|
19
|
+
*
|
|
20
|
+
* ## Why the stack is a frozen array
|
|
21
|
+
*
|
|
22
|
+
* `agentStack` is replaced, never mutated. A store object is shared BY
|
|
23
|
+
* REFERENCE with every async branch below it, so `push()` in one branch would
|
|
24
|
+
* mutate the value every sibling sees — which is exactly the cross-run event
|
|
25
|
+
* mixing this module exists to prevent, wearing an `AsyncLocalStorage` costume.
|
|
26
|
+
* It passes every single-branch test.
|
|
27
|
+
*
|
|
28
|
+
* There is deliberately no separate `agentId` slot: the top of the stack IS the
|
|
29
|
+
* current agent id, so the two cannot drift apart, and `parentId` is the entry
|
|
30
|
+
* beneath it.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
34
|
+
|
|
35
|
+
import { logger } from "./logger.js";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The agent id used when events are emitted with a session bound but no agent
|
|
39
|
+
* scope. "main" is the convention the skill and the reference integrations
|
|
40
|
+
* already teach, so an un-scoped event lands somewhere sensible rather than
|
|
41
|
+
* throwing.
|
|
42
|
+
*/
|
|
43
|
+
export const DEFAULT_AGENT_ID = "main";
|
|
44
|
+
|
|
45
|
+
/** The run identity in scope. Never null — check `sessionId === null` instead. */
|
|
46
|
+
export interface Identity {
|
|
47
|
+
readonly sessionId: string | null;
|
|
48
|
+
readonly agentId: string | null;
|
|
49
|
+
readonly parentId: string | null;
|
|
50
|
+
readonly depth: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface Store {
|
|
54
|
+
readonly sessionId: string | null;
|
|
55
|
+
readonly agentStack: readonly string[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const EMPTY_STORE: Store = Object.freeze({
|
|
59
|
+
sessionId: null,
|
|
60
|
+
agentStack: Object.freeze([]),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const storage = new AsyncLocalStorage<Store>();
|
|
64
|
+
|
|
65
|
+
function read(): Store {
|
|
66
|
+
return storage.getStore() ?? EMPTY_STORE;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The identity bound to the current context.
|
|
71
|
+
*
|
|
72
|
+
* `current().sessionId === null` means nothing is bound — either no scope was
|
|
73
|
+
* entered, or this callback escaped the async context that entered one (see
|
|
74
|
+
* `propagate`).
|
|
75
|
+
*/
|
|
76
|
+
export function current(): Identity {
|
|
77
|
+
const { sessionId: sid, agentStack: stack } = read();
|
|
78
|
+
return {
|
|
79
|
+
sessionId: sid,
|
|
80
|
+
agentId: stack.length > 0 ? stack[stack.length - 1]! : null,
|
|
81
|
+
parentId: stack.length >= 2 ? stack[stack.length - 2]! : null,
|
|
82
|
+
depth: stack.length,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The bound session id, or null. Hot path — allocates no Identity. */
|
|
87
|
+
export function sessionId(): string | null {
|
|
88
|
+
return read().sessionId;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The current agent id, falling back to `DEFAULT_AGENT_ID`. */
|
|
92
|
+
export function agentId(): string {
|
|
93
|
+
const { agentStack: stack } = read();
|
|
94
|
+
return stack.length > 0 ? stack[stack.length - 1]! : DEFAULT_AGENT_ID;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The enclosing agent id, or null at depth 0 or 1. */
|
|
98
|
+
export function parentAgentId(): string | null {
|
|
99
|
+
const { agentStack: stack } = read();
|
|
100
|
+
return stack.length >= 2 ? stack[stack.length - 2]! : null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function snapshot(): Store {
|
|
104
|
+
return read();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function withSessionBound(store: Store, sid: string): Store {
|
|
108
|
+
return { sessionId: sid, agentStack: store.agentStack };
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function withAgentPushed(store: Store, aid: string): Store {
|
|
112
|
+
return { sessionId: store.sessionId, agentStack: Object.freeze([...store.agentStack, aid]) };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Run `fn` with `store` bound. The clean form: nothing to unwind, ever. */
|
|
116
|
+
export function runWith<T>(store: Store, fn: () => T): T {
|
|
117
|
+
return storage.run(store, fn);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Bind `store` for the REMAINDER of the current async context and return what
|
|
122
|
+
* was bound before.
|
|
123
|
+
*
|
|
124
|
+
* This is the `using`-statement half of the API, and it is strictly weaker than
|
|
125
|
+
* `runWith`: the binding escapes upward into the caller's context, so it has to
|
|
126
|
+
* be undone by hand. `scopes.ts` does that in a `[Symbol.dispose]`, which the
|
|
127
|
+
* runtime guarantees runs at the end of the block — including on `throw` and
|
|
128
|
+
* `return`.
|
|
129
|
+
*
|
|
130
|
+
* The hazard it cannot fix is a scope entered in one async context and disposed
|
|
131
|
+
* in another: `enterWith` in the disposing context cannot reach the context the
|
|
132
|
+
* value was bound in, so the frame stays bound there. `noteCrossContextExit`
|
|
133
|
+
* below is how that gets reported.
|
|
134
|
+
*/
|
|
135
|
+
export function enterWith(store: Store): Store {
|
|
136
|
+
const previous = read();
|
|
137
|
+
storage.enterWith(store);
|
|
138
|
+
return previous;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Deduplicates the cross-context warning — it fires from a scope exit. */
|
|
142
|
+
let warnedCrossContext = false;
|
|
143
|
+
|
|
144
|
+
export function resetCrossContextWarning(): void {
|
|
145
|
+
warnedCrossContext = false;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Report, once, that a scope could not be unwound where it was entered.
|
|
150
|
+
*
|
|
151
|
+
* WARNING, not debug. The consequence is not cosmetic: the frame the scope
|
|
152
|
+
* pushed stays bound in whatever context it was set in, so identity is wrong
|
|
153
|
+
* for everything that follows there. The caller cannot discover that any other
|
|
154
|
+
* way — there is no exception, and the events look plausible.
|
|
155
|
+
*/
|
|
156
|
+
export function noteCrossContextExit(): void {
|
|
157
|
+
if (warnedCrossContext) return;
|
|
158
|
+
warnedCrossContext = true;
|
|
159
|
+
logger.warn(
|
|
160
|
+
"a scope was entered in one async context and exited in another, so its identity " +
|
|
161
|
+
"could not be unwound and later events in the entering context may be attributed " +
|
|
162
|
+
"to it. The usual cause is a `using` scope spanning a `yield` in an async " +
|
|
163
|
+
"generator; pass sessionId/agentId explicitly there, or use the callback form " +
|
|
164
|
+
"(`await agent('name', fn)`), which cannot reach this state.",
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Remove ONE frame for `aid` from a stack, innermost first.
|
|
170
|
+
*
|
|
171
|
+
* The fallback for a scope that cannot be unwound by restoring the previous
|
|
172
|
+
* store. Removes a single occurrence rather than every match, because the same
|
|
173
|
+
* agent id may legitimately be on the stack twice (a recursive agent), and
|
|
174
|
+
* dropping both would corrupt the outer one to fix the inner.
|
|
175
|
+
*/
|
|
176
|
+
export function withAgentDiscarded(store: Store, aid: string): Store {
|
|
177
|
+
const stack = store.agentStack;
|
|
178
|
+
for (let i = stack.length - 1; i >= 0; i -= 1) {
|
|
179
|
+
if (stack[i] === aid) {
|
|
180
|
+
return {
|
|
181
|
+
sessionId: store.sessionId,
|
|
182
|
+
agentStack: Object.freeze([...stack.slice(0, i), ...stack.slice(i + 1)]),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return store;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Wrap `fn` so it runs with the identity bound *right now*.
|
|
191
|
+
*
|
|
192
|
+
* queue.push(propagate(work));
|
|
193
|
+
* emitter.on("done", propagate(onDone));
|
|
194
|
+
* new Worker(url).on("message", propagate(handle));
|
|
195
|
+
*
|
|
196
|
+
* `AsyncLocalStorage` already follows `await`, `.then()`, `setTimeout` and any
|
|
197
|
+
* callback CREATED inside a scope, so most code needs nothing. This is for the
|
|
198
|
+
* cases where it genuinely cannot: a callback stored during one run and invoked
|
|
199
|
+
* during another (a module-level registry, a connection pool's handler), work
|
|
200
|
+
* handed to a `worker_threads` boundary, or anything re-entered from a native
|
|
201
|
+
* addon that does not carry async context.
|
|
202
|
+
*
|
|
203
|
+
* It snapshots VALUES rather than capturing the store object, so re-entering it
|
|
204
|
+
* twice — a retried job, a handler invoked per message — binds the same
|
|
205
|
+
* identity each time instead of inheriting whatever the previous call left.
|
|
206
|
+
*/
|
|
207
|
+
export function propagate<Args extends unknown[], Result>(
|
|
208
|
+
fn: (...args: Args) => Result,
|
|
209
|
+
): (...args: Args) => Result {
|
|
210
|
+
const captured = snapshot();
|
|
211
|
+
return function failproofaiPropagated(this: unknown, ...args: Args): Result {
|
|
212
|
+
return storage.run(captured, () => fn.apply(this, args));
|
|
213
|
+
};
|
|
214
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A framework adapter that installs nothing — see `src/edge/index.ts`. */
|
|
2
|
+
|
|
3
|
+
import { notice } from "./notice.js";
|
|
4
|
+
|
|
5
|
+
export function noopAdapter(name: string): {
|
|
6
|
+
name: string;
|
|
7
|
+
install(): Promise<void>;
|
|
8
|
+
uninstall(): void;
|
|
9
|
+
} {
|
|
10
|
+
return {
|
|
11
|
+
name,
|
|
12
|
+
install() {
|
|
13
|
+
notice();
|
|
14
|
+
return Promise.resolve();
|
|
15
|
+
},
|
|
16
|
+
uninstall() {},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@failproofai/sdk/ai` for runtimes with no filesystem — see `./index.ts`.
|
|
3
|
+
*
|
|
4
|
+
* Every helper hands the Vercel AI SDK something it accepts and that records
|
|
5
|
+
* nothing: `telemetry()` returns telemetry settings with `isEnabled: false`,
|
|
6
|
+
* the middleware passes calls straight through, the wrappers return what they
|
|
7
|
+
* were given.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { noopAdapter } from "./adapter.js";
|
|
11
|
+
import { notice } from "./notice.js";
|
|
12
|
+
|
|
13
|
+
type AttributeValue = string | number | boolean | Array<string | number | boolean>;
|
|
14
|
+
|
|
15
|
+
/** A span that records nothing, for a caller holding the tracer directly. */
|
|
16
|
+
export class FailproofSpan {
|
|
17
|
+
readonly attributes: Record<string, AttributeValue> = {};
|
|
18
|
+
spanContext() {
|
|
19
|
+
return { traceId: "0".repeat(32), spanId: "0".repeat(16), traceFlags: 0 };
|
|
20
|
+
}
|
|
21
|
+
setAttribute(): this {
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
setAttributes(): this {
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
addEvent(): this {
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
addLink(): this {
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
addLinks(): this {
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
setStatus(): this {
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
updateName(): this {
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
recordException(): void {}
|
|
43
|
+
isRecording(): boolean {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
end(): void {}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class FailproofTracer {
|
|
50
|
+
startSpan(): FailproofSpan {
|
|
51
|
+
return new FailproofSpan();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
startActiveSpan(_name: string, ...rest: unknown[]): unknown {
|
|
55
|
+
const fn = rest[rest.length - 1] as (span: FailproofSpan) => unknown;
|
|
56
|
+
return fn(new FailproofSpan());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function telemetry(
|
|
61
|
+
options: { functionId?: string; metadata?: Record<string, AttributeValue> } = {},
|
|
62
|
+
): { isEnabled: false; functionId?: string; metadata?: Record<string, AttributeValue> } {
|
|
63
|
+
notice();
|
|
64
|
+
return {
|
|
65
|
+
isEnabled: false,
|
|
66
|
+
...(options.functionId === undefined ? {} : { functionId: options.functionId }),
|
|
67
|
+
...(options.metadata === undefined ? {} : { metadata: options.metadata }),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function tracer(): FailproofTracer {
|
|
72
|
+
notice();
|
|
73
|
+
return new FailproofTracer();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const ignore = (): void => {};
|
|
77
|
+
|
|
78
|
+
/** The v7 telemetry integration, with every hook a no-op. */
|
|
79
|
+
export const integration = Object.freeze({
|
|
80
|
+
onStart: ignore,
|
|
81
|
+
onLanguageModelCallStart: ignore,
|
|
82
|
+
onLanguageModelCallEnd: ignore,
|
|
83
|
+
onObjectStepStart: ignore,
|
|
84
|
+
onObjectStepEnd: ignore,
|
|
85
|
+
onEmbedStart: ignore,
|
|
86
|
+
onEmbedEnd: ignore,
|
|
87
|
+
onToolExecutionStart: ignore,
|
|
88
|
+
onToolExecutionEnd: ignore,
|
|
89
|
+
onEnd: ignore,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export function middleware() {
|
|
93
|
+
notice();
|
|
94
|
+
return {
|
|
95
|
+
specificationVersion: "v3" as const,
|
|
96
|
+
wrapGenerate: async <R>({ doGenerate }: { doGenerate: () => PromiseLike<R> }): Promise<R> => await doGenerate(),
|
|
97
|
+
wrapStream: async <R>({ doStream }: { doStream: () => PromiseLike<R> }): Promise<R> => await doStream(),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function wrapModel<T>(model: T): Promise<T> {
|
|
102
|
+
notice();
|
|
103
|
+
return Promise.resolve(model);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function wrapTool<T>(_toolName: string, tool: T): T {
|
|
107
|
+
notice();
|
|
108
|
+
return tool;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function wrapTools<T>(tools: T): T {
|
|
112
|
+
notice();
|
|
113
|
+
return tools;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const adapter = noopAdapter("ai");
|