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
package/src/hooks/handler.ts
CHANGED
|
@@ -24,26 +24,18 @@ import {
|
|
|
24
24
|
OPENCLAW_EVENT_MAP,
|
|
25
25
|
ANTIGRAVITY_EVENT_MAP,
|
|
26
26
|
} from "./types";
|
|
27
|
-
import { existsSync } from "node:fs";
|
|
28
27
|
import { canonicalizeToolName, canonicalizeToolInput } from "./tool-name-canonicalize";
|
|
29
28
|
import { normalizeCliPayload } from "./normalize-cli-payload";
|
|
30
29
|
import type { PolicyFunction, PolicyResult, HooksConfig } from "./policy-types";
|
|
31
30
|
import { readMergedHooksConfig } from "./hooks-config";
|
|
32
31
|
import { registerBuiltinPolicies } from "./builtin-policies";
|
|
33
32
|
import { evaluatePolicies } from "./policy-evaluator";
|
|
34
|
-
// Types only: the semantic (Jev) modules are loaded with a dynamic import, and
|
|
35
|
-
// only once a Jev config exists, so an unconfigured machine never loads them.
|
|
36
|
-
import type { TwoTierReview } from "./semantic/combine";
|
|
37
|
-
import type { JevActivityFields } from "./semantic/combine";
|
|
38
|
-
import type { JevConfig } from "./semantic/jev-config";
|
|
39
33
|
import { clearPolicies, registerPolicy, getPoliciesForEvent } from "./policy-registry";
|
|
40
34
|
import { loadAllCustomHooks } from "./custom-hooks-loader";
|
|
41
|
-
import { authorityDeclarationFor, resolvePolicyAuthority, warnAuthority } from "./policy-authority";
|
|
42
35
|
import type { CustomHook } from "./policy-types";
|
|
43
36
|
import { persistHookActivity } from "./hook-activity-store";
|
|
44
37
|
import { deliveryHealth, deliveryHealthLine } from "./delivery-health";
|
|
45
38
|
import { trackHookEvent, flushHookTelemetry } from "./hook-telemetry";
|
|
46
|
-
import * as hookTelemetry from "./hook-telemetry";
|
|
47
39
|
import { resolveCwd } from "./resolve-cwd";
|
|
48
40
|
import { resolvePermissionMode } from "./resolve-permission-mode";
|
|
49
41
|
import { resolveTranscriptPath } from "./resolve-transcript-path";
|
|
@@ -54,7 +46,6 @@ import { readActiveCloudManagedPolicies, type CloudManagedPolicyArtifact } from
|
|
|
54
46
|
import { hasInstalledPacks, readInstalledPacks, type PackError, type ResolvedPack } from "./pack-manifest";
|
|
55
47
|
import { missingGuards, packFailureReason, combinedGuardMatch, guardsCover } from "./pack-failclosed";
|
|
56
48
|
import { readActivePause, type ActivePause } from "./session-pause";
|
|
57
|
-
import { jevConfigFile } from "./fp-home";
|
|
58
49
|
import { layoutWarningForHook } from "./fp-reset";
|
|
59
50
|
|
|
60
51
|
/**
|
|
@@ -162,16 +153,6 @@ export interface EvaluateHookEventOptions {
|
|
|
162
153
|
* written for.
|
|
163
154
|
*/
|
|
164
155
|
fallbackCwd?: string;
|
|
165
|
-
/**
|
|
166
|
-
* The warm worker's hook into its request queue. Called at most once, and
|
|
167
|
-
* only on the two-tier path, at the point this evaluation stops reading the
|
|
168
|
-
* process-global policy registry and starts waiting on Jev's network answer
|
|
169
|
-
* — so the next queued hook can run instead of every hook on the machine
|
|
170
|
-
* queueing behind that round trip. After it is called nothing in this
|
|
171
|
-
* evaluation reads the registry again. The one-shot path has no queue and
|
|
172
|
-
* leaves it unset.
|
|
173
|
-
*/
|
|
174
|
-
releaseRegistry?: () => void;
|
|
175
156
|
}
|
|
176
157
|
|
|
177
158
|
/**
|
|
@@ -205,211 +186,6 @@ async function runObserved(
|
|
|
205
186
|
}
|
|
206
187
|
}
|
|
207
188
|
|
|
208
|
-
// ── Two-tier (Jev) opt-in ────────────────────────────────────────────────────
|
|
209
|
-
//
|
|
210
|
-
// Jev reviews a call only when ALL of these hold, and the regex engine runs
|
|
211
|
-
// alone — exactly as it did before two tiers existed — otherwise:
|
|
212
|
-
//
|
|
213
|
-
// - a valid BYOK config exists (`~/.failproofai/jev.json`, global only);
|
|
214
|
-
// - `FAILPROOFAI_EVALUATOR` is not `legacy` (see "Turning Jev off" below);
|
|
215
|
-
// - this is not the fail-closed `forceDecision` path and no session pause is
|
|
216
|
-
// active — a pause suspends local policy, and Jev must not become a way to
|
|
217
|
-
// evaluate what the pause switched off;
|
|
218
|
-
// - the event is a gate (`PreToolUse` / `PermissionRequest`) for a named tool
|
|
219
|
-
// that the AGENT requested (see `isHumanAuthoredGate`).
|
|
220
|
-
//
|
|
221
|
-
// There is no cloud-deployment exclusion: cloud policies default to `hard`, so
|
|
222
|
-
// Jev can only make a centrally managed machine stricter, never weaker.
|
|
223
|
-
//
|
|
224
|
-
// Turning Jev off. The switch that works everywhere is the config file itself:
|
|
225
|
-
// it is read on every event, here, in whichever process evaluates — the
|
|
226
|
-
// daemon's warm worker included — so `failproofai jev remove` (or a `mode:
|
|
227
|
-
// "shadow"` config, which keeps enforcing the regex result) applies from the
|
|
228
|
-
// next tool call, with no restart. `FAILPROOFAI_EVALUATOR=legacy` is the dev
|
|
229
|
-
// escape hatch, read from the EVALUATING process's environment: it covers a
|
|
230
|
-
// one-shot hook (no daemon) and a worker whose own environment sets it, but
|
|
231
|
-
// not a variable exported in a shell on a daemon machine — the daemon
|
|
232
|
-
// forwards a hook's event, cli, stdin and cwd to the worker, never the hook
|
|
233
|
-
// process's environment. `failproofai jev status` says so when it sees the
|
|
234
|
-
// variable. A per-session switch for daemon machines would be a new field in
|
|
235
|
-
// the daemon protocol; there is none today.
|
|
236
|
-
|
|
237
|
-
/** The two gate events Jev reviews. Everything else is regex-only. */
|
|
238
|
-
const JEV_GATE_EVENTS: ReadonlySet<string> = new Set(["PreToolUse", "PermissionRequest"]);
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* A gate event that carries a command the HUMAN typed, not one the agent
|
|
242
|
-
* requested: Pi's `user_bash` (`!cmd` at Pi's prompt) canonicalizes to
|
|
243
|
-
* `PreToolUse` like an agent's `tool_call`. Jev judges an agent's request
|
|
244
|
-
* against what the human asked for, and says so to the model ("A coding agent
|
|
245
|
-
* has REQUESTED the tool call"); the human's own command is the human asking,
|
|
246
|
-
* and never appears in `user_said`, so Jev would judge it as an unrequested
|
|
247
|
-
* agent action and could block the human's own command. The regex policies
|
|
248
|
-
* still run on it exactly as they always have.
|
|
249
|
-
*/
|
|
250
|
-
function isHumanAuthoredGate(rawEventType: string | undefined, cli: IntegrationType): boolean {
|
|
251
|
-
return cli === "pi" && rawEventType === "user_bash";
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function jevForcedOff(opts: EvaluateHookEventOptions | undefined): boolean {
|
|
255
|
-
return process.env.FAILPROOFAI_EVALUATOR === "legacy" || !!opts?.forceDecision;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* The BYOK config (with the build's default mode, D2), or null (Jev off). A
|
|
260
|
-
* config that cannot be read is off, never a failure. Logged at info, like
|
|
261
|
-
* every configured-but-broken Jev path: warn-level lines reach the hook's
|
|
262
|
-
* stderr, which is the deny text itself on some CLIs (Factory's exit 2).
|
|
263
|
-
* `failproofai jev status` is where a broken config is made visible.
|
|
264
|
-
*
|
|
265
|
-
* The file is checked for BEFORE the import, and that order is the point. With
|
|
266
|
-
* no `jev.json` the answer is null however the module would have read it — so
|
|
267
|
-
* the stat decides it, and a machine that never configured Jev never evaluates
|
|
268
|
-
* a line of the semantic modules to be told what their absence already says.
|
|
269
|
-
* The same stat-rather-than-load trade `warnAuthority` makes, for the same
|
|
270
|
-
* reason. It short-circuits nothing but a null `loadJevConfig` would have
|
|
271
|
-
* returned itself: that function reads this path, and an absent file, an
|
|
272
|
-
* unreadable directory above it and a path that is not a file are all null
|
|
273
|
-
* there too.
|
|
274
|
-
*/
|
|
275
|
-
async function readJevConfig(): Promise<{ config: JevConfig; defaultMode: TwoTierReview["mode"] } | null> {
|
|
276
|
-
try {
|
|
277
|
-
if (!existsSync(jevConfigFile())) return null;
|
|
278
|
-
const { loadJevConfig, DEFAULT_JEV_MODE } = await import("./semantic/jev-config");
|
|
279
|
-
const config = loadJevConfig();
|
|
280
|
-
return config ? { config, defaultMode: DEFAULT_JEV_MODE } : null;
|
|
281
|
-
} catch (err) {
|
|
282
|
-
hookLogInfo(
|
|
283
|
-
`Jev config could not be read (${err instanceof Error ? err.message : String(err)}); the regex engine decides alone`,
|
|
284
|
-
);
|
|
285
|
-
return null;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Start Jev's review of this call — before the regex policies run, so the two
|
|
291
|
-
* proceed in parallel — or return null for the regex-only path.
|
|
292
|
-
*/
|
|
293
|
-
async function startTwoTier(
|
|
294
|
-
canonicalEventType: string,
|
|
295
|
-
parsed: Record<string, unknown>,
|
|
296
|
-
session: SessionMetadata,
|
|
297
|
-
cli: IntegrationType,
|
|
298
|
-
opts: EvaluateHookEventOptions | undefined,
|
|
299
|
-
activePause: ActivePause | null,
|
|
300
|
-
): Promise<TwoTierReview | null> {
|
|
301
|
-
if (!JEV_GATE_EVENTS.has(canonicalEventType)) return null;
|
|
302
|
-
if (isHumanAuthoredGate(session.rawHookEventName, cli)) return null;
|
|
303
|
-
if (typeof parsed.tool_name !== "string" || parsed.tool_name.length === 0) return null;
|
|
304
|
-
if (jevForcedOff(opts) || activePause) return null;
|
|
305
|
-
const loaded = await readJevConfig();
|
|
306
|
-
if (!loaded) return null;
|
|
307
|
-
const cfg = loaded.config;
|
|
308
|
-
try {
|
|
309
|
-
const { startJevReview } = await import("./semantic/jev-review");
|
|
310
|
-
return startJevReview(cfg, {
|
|
311
|
-
eventType: canonicalEventType,
|
|
312
|
-
toolName: parsed.tool_name,
|
|
313
|
-
toolInput: parsed.tool_input,
|
|
314
|
-
cwd: session.cwd,
|
|
315
|
-
permissionMode: session.permissionMode,
|
|
316
|
-
sessionId: session.sessionId,
|
|
317
|
-
cli,
|
|
318
|
-
});
|
|
319
|
-
} catch (err) {
|
|
320
|
-
// Configured but unable to start: that is a fallback, and it is recorded
|
|
321
|
-
// as one — every regex verdict hard, the regex result final. Recorded as
|
|
322
|
-
// `error`, one of the reason codes the activity store and the collector
|
|
323
|
-
// know (T8's closed list); an unknown code would ship as `other`. Logged
|
|
324
|
-
// at info, off the hook's stderr (see `readJevConfig`); the activity row
|
|
325
|
-
// carries the fallback.
|
|
326
|
-
hookLogInfo(`Jev review could not start (${err instanceof Error ? err.message : String(err)})`);
|
|
327
|
-
return {
|
|
328
|
-
mode: cfg.mode === "shadow" || cfg.mode === "enforce" ? cfg.mode : loaded.defaultMode,
|
|
329
|
-
review: Promise.resolve({ kind: "fallback", reason: "error", latencyMs: null, model: null }),
|
|
330
|
-
abort: () => {},
|
|
331
|
-
authorityOf: () => ({ authority: "hard", reviewedBy: [] }),
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* The Jev properties for `hook_policy_triggered`, from T8's
|
|
338
|
-
* `jevTelemetryProperties` (decisions, reason codes, policy and model names,
|
|
339
|
-
* a latency — never command or prompt text). `{}` when the two-tier path did
|
|
340
|
-
* not run, so an unconfigured machine's event is unchanged, and `{}` when the
|
|
341
|
-
* helper is not in this build (it is T8's, not a §7 contract) or throws:
|
|
342
|
-
* telemetry never costs a hook its answer.
|
|
343
|
-
*
|
|
344
|
-
* Only its `jev_`-prefixed keys are kept. These are spread into an event whose
|
|
345
|
-
* core properties (`decision`, `policy_name`, `event_type`, …) are what the
|
|
346
|
-
* rollout is read from, and a helper owned by another task must not be able to
|
|
347
|
-
* overwrite one of them — silently, and only on two-tier machines — by
|
|
348
|
-
* emitting a key of that name. The helper is treated as untrusted in every
|
|
349
|
-
* other respect (absent, non-object, throwing); this is the same guard for
|
|
350
|
-
* what it returns.
|
|
351
|
-
*/
|
|
352
|
-
function jevTelemetry(activity: JevActivityFields | undefined): Record<string, unknown> {
|
|
353
|
-
if (!activity) return {};
|
|
354
|
-
try {
|
|
355
|
-
const build = (hookTelemetry as unknown as { jevTelemetryProperties?: (entry: JevActivityFields) => unknown })
|
|
356
|
-
.jevTelemetryProperties;
|
|
357
|
-
const props = typeof build === "function" ? build(activity) : null;
|
|
358
|
-
if (!props || typeof props !== "object" || Array.isArray(props)) return {};
|
|
359
|
-
return Object.fromEntries(Object.entries(props as Record<string, unknown>).filter(([key]) => key.startsWith("jev_")));
|
|
360
|
-
} catch {
|
|
361
|
-
return {};
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Record what the human just typed, for Jev to judge later calls against.
|
|
367
|
-
* Only when Jev is configured. Every canonical `UserPromptSubmit` is passed,
|
|
368
|
-
* except a prompt a policy denied on a CLI where that deny is known to hold
|
|
369
|
-
* (`ENFORCEMENT_CAPABILITY` says `block`): the agent never receives that
|
|
370
|
-
* prompt, so it cannot be what the agent is working on. Where a prompt deny
|
|
371
|
-
* is only observed — Goose, OpenCode, Antigravity — or not verified, the
|
|
372
|
-
* agent does get the prompt, and it is passed like any other. Which CLIs'
|
|
373
|
-
* prompt events count as human is decided inside `captureIntent` (T4).
|
|
374
|
-
* Never throws; a failure is logged at info (see `readJevConfig`).
|
|
375
|
-
*
|
|
376
|
-
* `captureIntent` gets the whole normalized payload (`payload`): the prompt
|
|
377
|
-
* text is in a different field on some harnesses (Goose: `message`), and the
|
|
378
|
-
* marks that tell a human's prompt from a subagent's or an extension's are
|
|
379
|
-
* elsewhere in it. `prompt` is §7's original field, still read by the
|
|
380
|
-
* contract stub; T4's implementation reads `payload` and ignores it.
|
|
381
|
-
*/
|
|
382
|
-
async function captureJevIntent(
|
|
383
|
-
canonicalEventType: string,
|
|
384
|
-
decision: "allow" | "deny" | "instruct",
|
|
385
|
-
parsed: Record<string, unknown>,
|
|
386
|
-
session: SessionMetadata,
|
|
387
|
-
cli: IntegrationType,
|
|
388
|
-
opts: EvaluateHookEventOptions | undefined,
|
|
389
|
-
): Promise<void> {
|
|
390
|
-
if (canonicalEventType !== "UserPromptSubmit" || jevForcedOff(opts)) return;
|
|
391
|
-
try {
|
|
392
|
-
if (!(await readJevConfig())) return;
|
|
393
|
-
if (decision === "deny") {
|
|
394
|
-
const { ENFORCEMENT_CAPABILITY } = await import("./enforcement-capability");
|
|
395
|
-
if (ENFORCEMENT_CAPABILITY[cli]?.UserPromptSubmit === "block") return;
|
|
396
|
-
}
|
|
397
|
-
const { captureIntent } = await import("./semantic/intent");
|
|
398
|
-
// Built first, then passed: the one object satisfies §7's shape and T4's.
|
|
399
|
-
const event = {
|
|
400
|
-
eventType: canonicalEventType,
|
|
401
|
-
sessionId: session.sessionId,
|
|
402
|
-
transcriptPath: session.transcriptPath,
|
|
403
|
-
cli,
|
|
404
|
-
payload: parsed,
|
|
405
|
-
prompt: parsed.prompt,
|
|
406
|
-
};
|
|
407
|
-
captureIntent(event);
|
|
408
|
-
} catch (err) {
|
|
409
|
-
hookLogInfo(`Jev intent capture failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
189
|
/**
|
|
414
190
|
* The core hook-evaluation logic, decoupled from process stdin/stdout so it
|
|
415
191
|
* can be called repeatedly inside a long-lived process (the daemon's warm
|
|
@@ -785,14 +561,6 @@ export async function evaluateHookEvent(
|
|
|
785
561
|
...(cloudManaged ? { cloudPolicyId: cloudManaged.id, cloudVersion: cloudManaged.version } : {}),
|
|
786
562
|
...(pack ? { packId: pack.id, packVersion: pack.version } : {}),
|
|
787
563
|
});
|
|
788
|
-
// Whether Jev may clear this policy's verdict. The cloud assignment or
|
|
789
|
-
// the pack manifest declares it for those routes, the hook itself only
|
|
790
|
-
// for the user's own files; anything unclear registers as hard. Said
|
|
791
|
-
// aloud when a `reviewable` claim is refused and Jev is configured, so
|
|
792
|
-
// an author is not left wondering why Jev never clears it.
|
|
793
|
-
const authority = authorityDeclarationFor(hook, { cloudManaged, pack });
|
|
794
|
-
const refused = resolvePolicyAuthority(authority).downgraded;
|
|
795
|
-
if (refused) warnAuthority(`${registeredName} asks to be reviewable, but ${refused} — it stays hard`);
|
|
796
564
|
registerPolicy(
|
|
797
565
|
registeredName,
|
|
798
566
|
hook.description ?? "",
|
|
@@ -804,7 +572,6 @@ export async function evaluateHookEvent(
|
|
|
804
572
|
// configured. Matched by the pack's own name for the policy, which is
|
|
805
573
|
// the name before the `pack/<id>@<version>/` prefix is applied.
|
|
806
574
|
pack?.policies.find((p) => p.name === hook.name)?.params,
|
|
807
|
-
authority,
|
|
808
575
|
);
|
|
809
576
|
}
|
|
810
577
|
|
|
@@ -893,40 +660,19 @@ export async function evaluateHookEvent(
|
|
|
893
660
|
);
|
|
894
661
|
}
|
|
895
662
|
|
|
896
|
-
// Two-tier: when a Jev config exists and this is a gate, Jev's request
|
|
897
|
-
// starts HERE, before any regex policy runs, and evaluatePolicies combines
|
|
898
|
-
// the two (see semantic/combine.ts). Otherwise this is null and the call
|
|
899
|
-
// below is exactly the regex-only evaluation it always was.
|
|
900
|
-
const twoTier = await startTwoTier(canonicalEventType, parsed, session, cli, opts, activePause);
|
|
901
|
-
// On the two-tier path the registry is read for the activity row BEFORE
|
|
902
|
-
// evaluating, because evaluatePolicies may hand the registry back to the
|
|
903
|
-
// warm worker's queue (`releaseRegistry`) while it waits on Jev, and the
|
|
904
|
-
// next request's clearPolicies() could then run under this one. Same
|
|
905
|
-
// cached lookup, same answer: nothing between here and there registers.
|
|
906
|
-
const matchedBeforeRelease = twoTier
|
|
907
|
-
? getPoliciesForEvent(canonicalEventType, parsed.tool_name as string | undefined).map((p) => p.name)
|
|
908
|
-
: null;
|
|
909
|
-
|
|
910
663
|
// Evaluate policies (use canonical PascalCase event type)
|
|
911
|
-
const result =
|
|
912
|
-
? await evaluatePolicies(canonicalEventType, parsed, session, config, {
|
|
913
|
-
...twoTier,
|
|
914
|
-
releaseRegistry: opts?.releaseRegistry,
|
|
915
|
-
})
|
|
916
|
-
: await evaluatePolicies(canonicalEventType, parsed, session, config);
|
|
664
|
+
const result = await evaluatePolicies(canonicalEventType, parsed, session, config);
|
|
917
665
|
const durationMs = Math.round(performance.now() - startTime);
|
|
918
666
|
hookLogInfo(`result=${result.decision} policy=${result.policyName ?? "none"} duration=${durationMs}ms`);
|
|
919
667
|
|
|
920
|
-
await captureJevIntent(canonicalEventType, result.decision, parsed, session, cli, opts);
|
|
921
|
-
|
|
922
668
|
// Which policies actually ran for this event, regardless of how they
|
|
923
669
|
// decided. `result.policyName` names only the decider — null on a plain
|
|
924
670
|
// allow — so without this a row cannot tell "your policy ran and allowed"
|
|
925
671
|
// from "no policy covers this event". The lookup is the same cached call
|
|
926
672
|
// the evaluator already made, so it costs nothing.
|
|
927
|
-
const matchedPolicies =
|
|
928
|
-
|
|
929
|
-
|
|
673
|
+
const matchedPolicies = getPoliciesForEvent(canonicalEventType, parsed.tool_name as string | undefined).map(
|
|
674
|
+
(p) => p.name,
|
|
675
|
+
);
|
|
930
676
|
|
|
931
677
|
// Persist activity to disk (visible in /policies activity tab)
|
|
932
678
|
const activityEntry = {
|
|
@@ -940,8 +686,6 @@ export async function evaluateHookEvent(
|
|
|
940
686
|
decision: result.decision,
|
|
941
687
|
reason: result.reason,
|
|
942
688
|
durationMs,
|
|
943
|
-
// How Jev took part (§7 fields). Absent unless the two-tier path ran.
|
|
944
|
-
...(result.twoTier ? result.twoTier.activity : {}),
|
|
945
689
|
sessionId: session.sessionId,
|
|
946
690
|
transcriptPath: session.transcriptPath,
|
|
947
691
|
cwd: session.cwd,
|
|
@@ -949,10 +693,8 @@ export async function evaluateHookEvent(
|
|
|
949
693
|
hookEventName: session.hookEventName,
|
|
950
694
|
// Attribution. A builtin is anything registered that is not in the map,
|
|
951
695
|
// so its absence is meaningful rather than missing — but only when a
|
|
952
|
-
// policy actually decided; a plain allow names nobody.
|
|
953
|
-
|
|
954
|
-
// say so, and claiming "builtin" here would be false.
|
|
955
|
-
...(result.policyName && !result.twoTier?.decidedByJev
|
|
696
|
+
// policy actually decided; a plain allow names nobody.
|
|
697
|
+
...(result.policyName
|
|
956
698
|
? (() => {
|
|
957
699
|
const attribution = policyAttribution.get(result.policyName);
|
|
958
700
|
return {
|
|
@@ -1009,7 +751,6 @@ export async function evaluateHookEvent(
|
|
|
1009
751
|
convention_scope: conventionScope,
|
|
1010
752
|
has_custom_params: hasCustomParams,
|
|
1011
753
|
param_keys_overridden: paramKeysOverridden,
|
|
1012
|
-
...jevTelemetry(result.twoTier?.activity),
|
|
1013
754
|
});
|
|
1014
755
|
// Deny/instruct is exactly the response the daemon's warm worker
|
|
1015
756
|
// needs to return fast — a live network POST to PostHog on this path
|
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
import { join } from "node:path";
|
|
25
25
|
import type { IntegrationType } from "./types";
|
|
26
26
|
import { hookActivityDir } from "./fp-home";
|
|
27
|
-
import { sanitizeJevActivity } from "./jev-activity";
|
|
28
27
|
|
|
29
28
|
export const PAGE_SIZE = 25;
|
|
30
29
|
|
|
@@ -77,36 +76,6 @@ export interface HookActivityEntry {
|
|
|
77
76
|
matchedPolicies?: string[];
|
|
78
77
|
decision: "allow" | "deny" | "instruct";
|
|
79
78
|
reason: string | null;
|
|
80
|
-
/**
|
|
81
|
-
* The Jev (two-tier) fields. Present only when a Jev config (BYOK) exists and
|
|
82
|
-
* the call was a PreToolUse / PermissionRequest gate. Absent means the regex
|
|
83
|
-
* engine decided alone, exactly as before these fields existed.
|
|
84
|
-
*
|
|
85
|
-
* `evaluator`: `jev` (the two-tier path ran) or `jev-fallback` (Jev was
|
|
86
|
-
* unavailable, truncated or mismatched, so the regex result stood;
|
|
87
|
-
* `jevFallbackReason` says why). `jev` alone does NOT mean Jev answered:
|
|
88
|
-
* when a hard policy denies, Jev is aborted and the row carries
|
|
89
|
-
* `{ evaluator: "jev", jevMode }` and no other Jev field; when no semantic
|
|
90
|
-
* policy applies to the call, no request is sent and the row carries
|
|
91
|
-
* `{ evaluator: "jev", jevDecision: "allow", jevMode }`. Read a row with
|
|
92
|
-
* `jevOutcome` (`jev-activity.ts`): answered, fallback, not-consulted or
|
|
93
|
-
* no-request.
|
|
94
|
-
*
|
|
95
|
-
* Validated on write by `persistHookActivity` (see `jev-activity.ts`): an
|
|
96
|
-
* invalid value is dropped field by field, and `jevFallbackReason` is stored
|
|
97
|
-
* as a known code (`timeout`, `http-429`, `error`, …) or `other`, never free
|
|
98
|
-
* text. The collector ships these fields to FailproofAI Cloud.
|
|
99
|
-
*/
|
|
100
|
-
evaluator?: "jev" | "jev-fallback";
|
|
101
|
-
/** Jev's own verdict, before combining with the regex results. */
|
|
102
|
-
jevDecision?: "allow" | "instruct" | "deny";
|
|
103
|
-
/** Reviewable policies whose deny/instruct Jev cleared. */
|
|
104
|
-
jevCleared?: string[];
|
|
105
|
-
jevFallbackReason?: string;
|
|
106
|
-
jevLatencyMs?: number;
|
|
107
|
-
jevModel?: string;
|
|
108
|
-
/** `shadow` logs Jev but enforces the regex result; `enforce` applies the combine rules. */
|
|
109
|
-
jevMode?: "shadow" | "enforce";
|
|
110
79
|
durationMs: number;
|
|
111
80
|
sessionId?: string;
|
|
112
81
|
transcriptPath?: string;
|
|
@@ -225,13 +194,7 @@ function releaseLock(): void {
|
|
|
225
194
|
|
|
226
195
|
// ── Writing (synchronous — hook handler is short-lived) ──
|
|
227
196
|
|
|
228
|
-
export function persistHookActivity(
|
|
229
|
-
// The Jev fields are validated here, at the one door every row passes
|
|
230
|
-
// through, rather than trusted from the caller: they are shipped off the
|
|
231
|
-
// machine by the collector, and a fallback reason is the one field that can
|
|
232
|
-
// carry free text (see jev-activity.ts). A row with no Jev fields is written
|
|
233
|
-
// exactly as given.
|
|
234
|
-
const entry = sanitizeJevActivity(input);
|
|
197
|
+
export function persistHookActivity(entry: HookActivityEntry): void {
|
|
235
198
|
ensureDir();
|
|
236
199
|
acquireLock();
|
|
237
200
|
try {
|
|
@@ -434,72 +397,6 @@ export function getAllHookActivityEntries(): HookActivityEntry[] {
|
|
|
434
397
|
return [...currentEntries, ...archiveEntries];
|
|
435
398
|
}
|
|
436
399
|
|
|
437
|
-
/** See {@link getHookActivityEntriesSince}. */
|
|
438
|
-
export const ROTATION_CLOCK_SLACK_MS = 10 * 60 * 1000;
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Every entry stamped at or after `sinceMs`, newest first — without reading the
|
|
442
|
-
* whole history.
|
|
443
|
-
*
|
|
444
|
-
* Pages are never pruned, so a long-lived machine has hundreds of them, and a
|
|
445
|
-
* windowed question ("how did Jev do in the last day") should not pay for all
|
|
446
|
-
* of them. It does not have to: an entry's timestamp is taken before it is
|
|
447
|
-
* appended, and a page is only renamed to `page-<rotatedAt>-<seq>` after its
|
|
448
|
-
* last append, so every entry in a page is at or before `rotatedAt`. Archives
|
|
449
|
-
* are listed newest first, so once one was rotated before the window opened,
|
|
450
|
-
* it and every older page lie wholly outside it and reading stops there.
|
|
451
|
-
*
|
|
452
|
-
* `current.jsonl` and the newest pages can still hold entries just outside the
|
|
453
|
-
* window (two hook processes race to append), hence the per-entry filter.
|
|
454
|
-
* The stop is taken with {@link ROTATION_CLOCK_SLACK_MS} to spare, so a clock
|
|
455
|
-
* stepped back a few minutes between two writes costs one extra page read
|
|
456
|
-
* rather than silently dropping rows from the window.
|
|
457
|
-
*
|
|
458
|
-
* No row is returned twice, although this reads without the writers' lock. A
|
|
459
|
-
* hook process can rotate `current.jsonl` into a new page between this reading
|
|
460
|
-
* `current.jsonl` and listing the pages, and that page then holds the rows just
|
|
461
|
-
* read. So the pages are listed once before `current.jsonl` is read; a page
|
|
462
|
-
* that appears only in the second listing was rotated during the read, and any
|
|
463
|
-
* of its rows that were also in `current.jsonl` are skipped. (A page rotated
|
|
464
|
-
* before the read holds none of them: `current.jsonl` was fresh by then.)
|
|
465
|
-
*/
|
|
466
|
-
export function getHookActivityEntriesSince(sinceMs: number): HookActivityEntry[] {
|
|
467
|
-
ensureDir();
|
|
468
|
-
const dir = storeDirValue();
|
|
469
|
-
const inWindow = (e: HookActivityEntry) => typeof e.timestamp === "number" && e.timestamp >= sinceMs;
|
|
470
|
-
const listedBefore = new Set(getArchiveFiles());
|
|
471
|
-
sinceReadProbe?.("before-current");
|
|
472
|
-
const current = readJsonlFile(join(dir, CURRENT_FILE));
|
|
473
|
-
sinceReadProbe?.("after-current");
|
|
474
|
-
const readFromCurrent = new Map<string, number>();
|
|
475
|
-
for (const e of current) {
|
|
476
|
-
const key = JSON.stringify(e);
|
|
477
|
-
readFromCurrent.set(key, (readFromCurrent.get(key) ?? 0) + 1);
|
|
478
|
-
}
|
|
479
|
-
const notReadYet = (e: HookActivityEntry): boolean => {
|
|
480
|
-
const key = JSON.stringify(e);
|
|
481
|
-
const n = readFromCurrent.get(key) ?? 0;
|
|
482
|
-
if (n === 0) return true;
|
|
483
|
-
readFromCurrent.set(key, n - 1);
|
|
484
|
-
return false;
|
|
485
|
-
};
|
|
486
|
-
const out = current.reverse().filter(inWindow);
|
|
487
|
-
for (const file of getArchiveFiles()) {
|
|
488
|
-
const rotatedAt = parseInt(file.slice(5, -6).split("-")[0], 10);
|
|
489
|
-
if (Number.isFinite(rotatedAt) && rotatedAt < sinceMs - ROTATION_CLOCK_SLACK_MS) break;
|
|
490
|
-
let entries = readJsonlFile(join(dir, file));
|
|
491
|
-
if (!listedBefore.has(file)) entries = entries.filter(notReadYet);
|
|
492
|
-
out.push(...entries.reverse().filter(inWindow));
|
|
493
|
-
}
|
|
494
|
-
return out;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
/** Test-only: runs between the reads of {@link getHookActivityEntriesSince}, to land a rotation exactly there. */
|
|
498
|
-
let sinceReadProbe: ((phase: "before-current" | "after-current") => void) | null = null;
|
|
499
|
-
export function _setSinceReadProbeForTest(probe: ((phase: "before-current" | "after-current") => void) | null): void {
|
|
500
|
-
sinceReadProbe = probe;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
400
|
|
|
504
401
|
export function searchHookActivity(
|
|
505
402
|
filters: HookActivityFilters,
|
|
@@ -622,7 +519,6 @@ function getArchiveFiles(): string[] {
|
|
|
622
519
|
|
|
623
520
|
export function _resetForTest(testDir?: string): void {
|
|
624
521
|
rotateSeq = 0;
|
|
625
|
-
sinceReadProbe = null;
|
|
626
522
|
// null, not the default path: clearing the override lets the getter re-read
|
|
627
523
|
// FAILPROOFAI_HOME, which a test may have changed since this module loaded.
|
|
628
524
|
storeDirOverride = testDir ?? null;
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import { version } from "../../package.json";
|
|
9
9
|
import { POSTHOG_API_KEY, POSTHOG_PRODUCT } from "../posthog-key";
|
|
10
10
|
import { isTelemetryEnabled } from "../../lib/telemetry-enabled";
|
|
11
|
-
import { jevOutcome, sanitizeJevActivity, type JevActivityFields } from "./jev-activity";
|
|
12
11
|
|
|
13
12
|
const API_KEY = POSTHOG_API_KEY;
|
|
14
13
|
const CAPTURE_URL = "https://us.i.posthog.com/capture/";
|
|
@@ -87,43 +86,3 @@ export async function flushHookTelemetry(): Promise<void> {
|
|
|
87
86
|
await Promise.allSettled([...pending]);
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* The Jev (two-tier evaluator) properties for a hook telemetry event, built
|
|
93
|
-
* from the activity row's Jev fields — or `{}` when Jev was not involved, so
|
|
94
|
-
* spreading this into an event changes nothing on an unconfigured machine.
|
|
95
|
-
*
|
|
96
|
-
* Same rule as every other hook property: decisions, reason codes, policy and
|
|
97
|
-
* model names, and a latency — never command or prompt text. The row's fields
|
|
98
|
-
* go through the same normaliser the activity store applies on write, so a
|
|
99
|
-
* free-text fallback reason is reduced to its code here too.
|
|
100
|
-
*
|
|
101
|
-
* A call a hard policy denied before Jev's answer was read carries
|
|
102
|
-
* `jev_outcome: "not-consulted"`, and a call no semantic policy applied to (no
|
|
103
|
-
* request sent) `jev_outcome: "no-request"`; neither carries a Jev verdict,
|
|
104
|
-
* clears, latency or model: `jev_evaluator: "jev"` alone does not mean Jev
|
|
105
|
-
* answered (see `jevOutcome`).
|
|
106
|
-
*
|
|
107
|
-
* Meant to be spread into `hook_policy_triggered` by the handler:
|
|
108
|
-
* `{ ...existingProps, ...jevTelemetryProperties(activityEntry) }`.
|
|
109
|
-
*/
|
|
110
|
-
export function jevTelemetryProperties(entry: JevActivityFields): Record<string, unknown> {
|
|
111
|
-
const e = sanitizeJevActivity(entry);
|
|
112
|
-
const outcome = jevOutcome(e);
|
|
113
|
-
if (outcome === null) return {};
|
|
114
|
-
const props: Record<string, unknown> = { jev_evaluator: e.evaluator };
|
|
115
|
-
if (e.jevMode) props.jev_mode = e.jevMode;
|
|
116
|
-
if (outcome === "not-consulted" || outcome === "no-request") {
|
|
117
|
-
props.jev_outcome = outcome;
|
|
118
|
-
return props;
|
|
119
|
-
}
|
|
120
|
-
if (e.jevDecision) props.jev_decision = e.jevDecision;
|
|
121
|
-
if (e.jevCleared) {
|
|
122
|
-
props.jev_cleared = e.jevCleared;
|
|
123
|
-
props.jev_cleared_count = e.jevCleared.length;
|
|
124
|
-
}
|
|
125
|
-
if (e.jevFallbackReason) props.jev_fallback_reason = e.jevFallbackReason;
|
|
126
|
-
if (e.jevLatencyMs !== undefined) props.jev_latency_ms = e.jevLatencyMs;
|
|
127
|
-
if (e.jevModel) props.jev_model = e.jevModel;
|
|
128
|
-
return props;
|
|
129
|
-
}
|
|
@@ -191,13 +191,7 @@ export async function createEsmShim(
|
|
|
191
191
|
const shimCode = [
|
|
192
192
|
`import _cjs from '${distUrl}';`,
|
|
193
193
|
`export const customPolicies = _cjs.customPolicies;`,
|
|
194
|
-
// Every name a policy file may import has to be listed HERE as well as in
|
|
195
|
-
// `src/index.ts`: this shim is an ESM module, so importing a name it does not
|
|
196
|
-
// declare is a link-time error, not an undefined at runtime. A pack entry
|
|
197
|
-
// calling `semanticPolicies.add` would fail to load entirely.
|
|
198
|
-
`export const semanticPolicies = _cjs.semanticPolicies;`,
|
|
199
194
|
`export const getCustomHooks = _cjs.getCustomHooks;`,
|
|
200
|
-
`export const getSemanticRegistrations = _cjs.getSemanticRegistrations;`,
|
|
201
195
|
`export const clearCustomHooks = _cjs.clearCustomHooks;`,
|
|
202
196
|
`export const allow = _cjs.allow;`,
|
|
203
197
|
`export const deny = _cjs.deny;`,
|