failproofai 0.0.2 → 0.0.3
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/.claude/settings.json +316 -0
- package/.next/standalone/.failproofai/policies/workflow-policies.mjs +62 -0
- package/.next/standalone/.failproofai/policies-config.json +39 -0
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +5 -5
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +3 -1
- package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +2 -2
- 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 +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/build-manifest.json +2 -2
- 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 +2 -2
- package/.next/standalone/.next/server/app/_not-found.rsc +17 -17
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +17 -17
- package/.next/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +11 -11
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +16 -16
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +16 -16
- package/.next/standalone/.next/server/app/index.segments/_head.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +11 -11
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/page/build-manifest.json +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/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +8 -8
- 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/build-manifest.json +2 -2
- 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/build-manifest.json +2 -2
- 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/build-manifest.json +2 -2
- 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/chunks/[root-of-the-server]__0g72weg._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0kjo7d_._.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_05pz9._._.js +1 -1
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_0z7w.hh._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__12kr5~_._.js → [root-of-the-server]__03kiqd5._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__092s1ta._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__09icjsf._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0qo8503._.js → [root-of-the-server]__0bo8s~-._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0g.lg8b._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0h..k-e._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0okos0k._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0w6l33k._.js +9 -9
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__11pa2ra._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__12t-wym._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_10lm7or._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_0xerkr6._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_0q-m0y-._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0a_7sdg.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0ef3uwk.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0j79~gv.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0pbja1x.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_0r6o0i2.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_11y81~_.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_12or2kf.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_0mebn66._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +5 -5
- package/.next/standalone/.next/server/pages/404.html +2 -2
- 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 +9 -9
- package/.next/standalone/.next/static/chunks/{0x-625~1vx1lu.js → 02t9.s735hqyq.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0ov60i6md~37t.js → 03oepxbqx6o8~.js} +2 -2
- package/.next/standalone/.next/static/chunks/{031pa5~qfzt~_.js → 09e7drilkf1sn.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0y~0creqvl5wx.js → 0cwft44dh9bww.js} +1 -1
- package/.next/standalone/.next/static/chunks/{06og.7e9nkpjh.js → 0e2uz2g026ckb.js} +1 -1
- package/.next/standalone/.next/static/chunks/0gu_a.a80ritd.css +1 -0
- package/.next/standalone/.next/static/chunks/{15wf7x-e.8ia3.js → 0h5kbvg~.xf.v.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0_4y_t03jn2nq.js → 0od..umlku4bb.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0cvffh-pbsv5u.js → 0xbwzy4dl87-0.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0c_ljlxa._4lc.js → 18cl6wups7ouq.js} +2 -2
- package/.next/standalone/.next/static/chunks/{turbopack-0uc5y~g6h.n7-.js → turbopack-0r26pc8h0y_-e.js} +1 -1
- package/.next/standalone/CHANGELOG.md +103 -0
- package/.next/standalone/CLAUDE.md +28 -0
- package/.next/standalone/Dockerfile.docs +12 -0
- package/.next/standalone/README.md +95 -49
- package/.next/standalone/app/components/session-hooks-panel.tsx +14 -1
- package/.next/standalone/app/policies/hooks-client.tsx +14 -1
- package/.next/standalone/bin/failproofai.mjs +5 -0
- package/.next/standalone/bun.lock +76 -63
- package/.next/standalone/components/navbar.tsx +5 -0
- package/.next/standalone/dist/cli.mjs +539 -90
- package/.next/standalone/dist/index.js +2 -2
- package/.next/standalone/docs/ar/architecture.mdx +333 -0
- package/.next/standalone/docs/ar/built-in-policies.mdx +566 -0
- package/.next/standalone/docs/ar/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/ar/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/ar/cli/hook.mdx +31 -0
- package/.next/standalone/docs/ar/cli/install-policies.mdx +49 -0
- package/.next/standalone/docs/ar/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/ar/cli/remove-policies.mdx +45 -0
- package/.next/standalone/docs/ar/cli/version.mdx +13 -0
- package/.next/standalone/docs/ar/configuration.mdx +223 -0
- package/.next/standalone/docs/ar/custom-policies.mdx +359 -0
- package/.next/standalone/docs/ar/dashboard.mdx +142 -0
- package/.next/standalone/docs/ar/examples.mdx +254 -0
- package/.next/standalone/docs/ar/for-agents.mdx +39 -0
- package/.next/standalone/docs/ar/getting-started.mdx +134 -0
- package/.next/standalone/docs/ar/introduction.mdx +58 -0
- package/.next/standalone/docs/ar/package-aliases.mdx +82 -0
- package/.next/standalone/docs/ar/testing.mdx +261 -0
- package/.next/standalone/docs/{architecture.md → architecture.mdx} +40 -23
- package/.next/standalone/docs/{built-in-policies.md → built-in-policies.mdx} +151 -13
- package/.next/standalone/docs/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/cli/hook.mdx +30 -0
- package/.next/standalone/docs/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/cli/version.mdx +12 -0
- package/.next/standalone/docs/{configuration.md → configuration.mdx} +62 -16
- package/.next/standalone/docs/custom-policies.mdx +357 -0
- package/.next/standalone/docs/{dashboard.md → dashboard.mdx} +26 -29
- package/.next/standalone/docs/de/architecture.mdx +332 -0
- package/.next/standalone/docs/de/built-in-policies.mdx +564 -0
- package/.next/standalone/docs/de/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/de/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/de/cli/hook.mdx +30 -0
- package/.next/standalone/docs/de/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/de/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/de/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/de/cli/version.mdx +12 -0
- package/.next/standalone/docs/de/configuration.mdx +222 -0
- package/.next/standalone/docs/de/custom-policies.mdx +357 -0
- package/.next/standalone/docs/de/dashboard.mdx +142 -0
- package/.next/standalone/docs/de/examples.mdx +253 -0
- package/.next/standalone/docs/de/for-agents.mdx +38 -0
- package/.next/standalone/docs/de/getting-started.mdx +134 -0
- package/.next/standalone/docs/de/introduction.mdx +57 -0
- package/.next/standalone/docs/de/package-aliases.mdx +82 -0
- package/.next/standalone/docs/de/testing.mdx +260 -0
- package/.next/standalone/docs/docs.json +938 -24
- package/.next/standalone/docs/es/architecture.mdx +332 -0
- package/.next/standalone/docs/es/built-in-policies.mdx +564 -0
- package/.next/standalone/docs/es/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/es/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/es/cli/hook.mdx +30 -0
- package/.next/standalone/docs/es/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/es/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/es/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/es/cli/version.mdx +12 -0
- package/.next/standalone/docs/es/configuration.mdx +222 -0
- package/.next/standalone/docs/es/custom-policies.mdx +357 -0
- package/.next/standalone/docs/es/dashboard.mdx +142 -0
- package/.next/standalone/docs/es/examples.mdx +253 -0
- package/.next/standalone/docs/es/for-agents.mdx +38 -0
- package/.next/standalone/docs/es/getting-started.mdx +134 -0
- package/.next/standalone/docs/es/introduction.mdx +57 -0
- package/.next/standalone/docs/es/package-aliases.mdx +82 -0
- package/.next/standalone/docs/es/testing.mdx +260 -0
- package/.next/standalone/docs/examples.mdx +253 -0
- package/.next/standalone/docs/for-agents.mdx +38 -0
- package/.next/standalone/docs/fr/architecture.mdx +332 -0
- package/.next/standalone/docs/fr/built-in-policies.mdx +564 -0
- package/.next/standalone/docs/fr/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/fr/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/fr/cli/hook.mdx +30 -0
- package/.next/standalone/docs/fr/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/fr/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/fr/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/fr/cli/version.mdx +12 -0
- package/.next/standalone/docs/fr/configuration.mdx +222 -0
- package/.next/standalone/docs/fr/custom-policies.mdx +357 -0
- package/.next/standalone/docs/fr/dashboard.mdx +142 -0
- package/.next/standalone/docs/fr/examples.mdx +253 -0
- package/.next/standalone/docs/fr/for-agents.mdx +38 -0
- package/.next/standalone/docs/fr/getting-started.mdx +134 -0
- package/.next/standalone/docs/fr/introduction.mdx +57 -0
- package/.next/standalone/docs/fr/package-aliases.mdx +82 -0
- package/.next/standalone/docs/fr/testing.mdx +260 -0
- package/.next/standalone/docs/getting-started.mdx +134 -0
- package/.next/standalone/docs/he/architecture.mdx +333 -0
- package/.next/standalone/docs/he/built-in-policies.mdx +564 -0
- package/.next/standalone/docs/he/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/he/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/he/cli/hook.mdx +30 -0
- package/.next/standalone/docs/he/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/he/cli/list-policies.mdx +32 -0
- package/.next/standalone/docs/he/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/he/cli/version.mdx +12 -0
- package/.next/standalone/docs/he/configuration.mdx +222 -0
- package/.next/standalone/docs/he/custom-policies.mdx +357 -0
- package/.next/standalone/docs/he/dashboard.mdx +142 -0
- package/.next/standalone/docs/he/examples.mdx +253 -0
- package/.next/standalone/docs/he/for-agents.mdx +38 -0
- package/.next/standalone/docs/he/getting-started.mdx +135 -0
- package/.next/standalone/docs/he/introduction.mdx +57 -0
- package/.next/standalone/docs/he/package-aliases.mdx +82 -0
- package/.next/standalone/docs/he/testing.mdx +260 -0
- package/.next/standalone/docs/hi/architecture.mdx +334 -0
- package/.next/standalone/docs/hi/built-in-policies.mdx +564 -0
- package/.next/standalone/docs/hi/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/hi/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/hi/cli/hook.mdx +30 -0
- package/.next/standalone/docs/hi/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/hi/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/hi/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/hi/cli/version.mdx +12 -0
- package/.next/standalone/docs/hi/configuration.mdx +222 -0
- package/.next/standalone/docs/hi/custom-policies.mdx +357 -0
- package/.next/standalone/docs/hi/dashboard.mdx +142 -0
- package/.next/standalone/docs/hi/examples.mdx +255 -0
- package/.next/standalone/docs/hi/for-agents.mdx +38 -0
- package/.next/standalone/docs/hi/getting-started.mdx +134 -0
- package/.next/standalone/docs/hi/introduction.mdx +57 -0
- package/.next/standalone/docs/hi/package-aliases.mdx +82 -0
- package/.next/standalone/docs/hi/testing.mdx +260 -0
- package/.next/standalone/docs/i18n/README.ar.md +312 -0
- package/.next/standalone/docs/i18n/README.de.md +307 -0
- package/.next/standalone/docs/i18n/README.es.md +307 -0
- package/.next/standalone/docs/i18n/README.fr.md +307 -0
- package/.next/standalone/docs/i18n/README.he.md +312 -0
- package/.next/standalone/docs/i18n/README.hi.md +307 -0
- package/.next/standalone/docs/i18n/README.it.md +307 -0
- package/.next/standalone/docs/i18n/README.ja.md +307 -0
- package/.next/standalone/docs/i18n/README.ko.md +307 -0
- package/.next/standalone/docs/i18n/README.pt-br.md +307 -0
- package/.next/standalone/docs/i18n/README.ru.md +308 -0
- package/.next/standalone/docs/i18n/README.tr.md +308 -0
- package/.next/standalone/docs/i18n/README.vi.md +308 -0
- package/.next/standalone/docs/i18n/README.zh.md +307 -0
- package/.next/standalone/docs/introduction.mdx +57 -0
- package/.next/standalone/docs/it/architecture.mdx +333 -0
- package/.next/standalone/docs/it/built-in-policies.mdx +564 -0
- package/.next/standalone/docs/it/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/it/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/it/cli/hook.mdx +30 -0
- package/.next/standalone/docs/it/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/it/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/it/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/it/cli/version.mdx +12 -0
- package/.next/standalone/docs/it/configuration.mdx +223 -0
- package/.next/standalone/docs/it/custom-policies.mdx +358 -0
- package/.next/standalone/docs/it/dashboard.mdx +142 -0
- package/.next/standalone/docs/it/examples.mdx +253 -0
- package/.next/standalone/docs/it/for-agents.mdx +38 -0
- package/.next/standalone/docs/it/getting-started.mdx +134 -0
- package/.next/standalone/docs/it/introduction.mdx +57 -0
- package/.next/standalone/docs/it/package-aliases.mdx +82 -0
- package/.next/standalone/docs/it/testing.mdx +260 -0
- package/.next/standalone/docs/ja/architecture.mdx +332 -0
- package/.next/standalone/docs/ja/built-in-policies.mdx +562 -0
- package/.next/standalone/docs/ja/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/ja/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/ja/cli/hook.mdx +30 -0
- package/.next/standalone/docs/ja/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/ja/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/ja/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/ja/cli/version.mdx +12 -0
- package/.next/standalone/docs/ja/configuration.mdx +222 -0
- package/.next/standalone/docs/ja/custom-policies.mdx +357 -0
- package/.next/standalone/docs/ja/dashboard.mdx +142 -0
- package/.next/standalone/docs/ja/examples.mdx +253 -0
- package/.next/standalone/docs/ja/for-agents.mdx +38 -0
- package/.next/standalone/docs/ja/getting-started.mdx +134 -0
- package/.next/standalone/docs/ja/introduction.mdx +57 -0
- package/.next/standalone/docs/ja/package-aliases.mdx +82 -0
- package/.next/standalone/docs/ja/testing.mdx +260 -0
- package/.next/standalone/docs/ko/architecture.mdx +332 -0
- package/.next/standalone/docs/ko/built-in-policies.mdx +562 -0
- package/.next/standalone/docs/ko/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/ko/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/ko/cli/hook.mdx +30 -0
- package/.next/standalone/docs/ko/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/ko/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/ko/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/ko/cli/version.mdx +12 -0
- package/.next/standalone/docs/ko/configuration.mdx +222 -0
- package/.next/standalone/docs/ko/custom-policies.mdx +357 -0
- package/.next/standalone/docs/ko/dashboard.mdx +142 -0
- package/.next/standalone/docs/ko/examples.mdx +253 -0
- package/.next/standalone/docs/ko/for-agents.mdx +38 -0
- package/.next/standalone/docs/ko/getting-started.mdx +134 -0
- package/.next/standalone/docs/ko/introduction.mdx +57 -0
- package/.next/standalone/docs/ko/package-aliases.mdx +82 -0
- package/.next/standalone/docs/ko/testing.mdx +260 -0
- package/.next/standalone/docs/logo/dark.svg +21 -0
- package/.next/standalone/docs/logo/light.svg +21 -0
- package/.next/standalone/docs/{package-aliases.md → package-aliases.mdx} +5 -5
- package/.next/standalone/docs/pt-br/architecture.mdx +332 -0
- package/.next/standalone/docs/pt-br/built-in-policies.mdx +564 -0
- package/.next/standalone/docs/pt-br/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/pt-br/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/pt-br/cli/hook.mdx +30 -0
- package/.next/standalone/docs/pt-br/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/pt-br/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/pt-br/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/pt-br/cli/version.mdx +12 -0
- package/.next/standalone/docs/pt-br/configuration.mdx +222 -0
- package/.next/standalone/docs/pt-br/custom-policies.mdx +357 -0
- package/.next/standalone/docs/pt-br/dashboard.mdx +142 -0
- package/.next/standalone/docs/pt-br/examples.mdx +253 -0
- package/.next/standalone/docs/pt-br/for-agents.mdx +38 -0
- package/.next/standalone/docs/pt-br/getting-started.mdx +134 -0
- package/.next/standalone/docs/pt-br/introduction.mdx +57 -0
- package/.next/standalone/docs/pt-br/package-aliases.mdx +82 -0
- package/.next/standalone/docs/pt-br/testing.mdx +260 -0
- package/.next/standalone/docs/ru/architecture.mdx +334 -0
- package/.next/standalone/docs/ru/built-in-policies.mdx +562 -0
- package/.next/standalone/docs/ru/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/ru/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/ru/cli/hook.mdx +30 -0
- package/.next/standalone/docs/ru/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/ru/cli/list-policies.mdx +32 -0
- package/.next/standalone/docs/ru/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/ru/cli/version.mdx +12 -0
- package/.next/standalone/docs/ru/configuration.mdx +223 -0
- package/.next/standalone/docs/ru/custom-policies.mdx +357 -0
- package/.next/standalone/docs/ru/dashboard.mdx +142 -0
- package/.next/standalone/docs/ru/examples.mdx +254 -0
- package/.next/standalone/docs/ru/for-agents.mdx +38 -0
- package/.next/standalone/docs/ru/getting-started.mdx +134 -0
- package/.next/standalone/docs/ru/introduction.mdx +57 -0
- package/.next/standalone/docs/ru/package-aliases.mdx +82 -0
- package/.next/standalone/docs/ru/testing.mdx +260 -0
- package/.next/standalone/docs/{testing.md → testing.mdx} +11 -11
- package/.next/standalone/docs/tr/architecture.mdx +333 -0
- package/.next/standalone/docs/tr/built-in-policies.mdx +562 -0
- package/.next/standalone/docs/tr/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/tr/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/tr/cli/hook.mdx +30 -0
- package/.next/standalone/docs/tr/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/tr/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/tr/cli/remove-policies.mdx +45 -0
- package/.next/standalone/docs/tr/cli/version.mdx +12 -0
- package/.next/standalone/docs/tr/configuration.mdx +223 -0
- package/.next/standalone/docs/tr/custom-policies.mdx +357 -0
- package/.next/standalone/docs/tr/dashboard.mdx +142 -0
- package/.next/standalone/docs/tr/examples.mdx +253 -0
- package/.next/standalone/docs/tr/for-agents.mdx +38 -0
- package/.next/standalone/docs/tr/getting-started.mdx +134 -0
- package/.next/standalone/docs/tr/introduction.mdx +57 -0
- package/.next/standalone/docs/tr/package-aliases.mdx +82 -0
- package/.next/standalone/docs/tr/testing.mdx +260 -0
- package/.next/standalone/docs/vi/architecture.mdx +333 -0
- package/.next/standalone/docs/vi/built-in-policies.mdx +564 -0
- package/.next/standalone/docs/vi/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/vi/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/vi/cli/hook.mdx +30 -0
- package/.next/standalone/docs/vi/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/vi/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/vi/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/vi/cli/version.mdx +13 -0
- package/.next/standalone/docs/vi/configuration.mdx +222 -0
- package/.next/standalone/docs/vi/custom-policies.mdx +357 -0
- package/.next/standalone/docs/vi/dashboard.mdx +142 -0
- package/.next/standalone/docs/vi/examples.mdx +253 -0
- package/.next/standalone/docs/vi/for-agents.mdx +38 -0
- package/.next/standalone/docs/vi/getting-started.mdx +134 -0
- package/.next/standalone/docs/vi/introduction.mdx +57 -0
- package/.next/standalone/docs/vi/package-aliases.mdx +82 -0
- package/.next/standalone/docs/vi/testing.mdx +260 -0
- package/.next/standalone/docs/zh/architecture.mdx +332 -0
- package/.next/standalone/docs/zh/built-in-policies.mdx +562 -0
- package/.next/standalone/docs/zh/cli/dashboard.mdx +28 -0
- package/.next/standalone/docs/zh/cli/environment-variables.mdx +34 -0
- package/.next/standalone/docs/zh/cli/hook.mdx +30 -0
- package/.next/standalone/docs/zh/cli/install-policies.mdx +48 -0
- package/.next/standalone/docs/zh/cli/list-policies.mdx +31 -0
- package/.next/standalone/docs/zh/cli/remove-policies.mdx +44 -0
- package/.next/standalone/docs/zh/cli/version.mdx +12 -0
- package/.next/standalone/docs/zh/configuration.mdx +222 -0
- package/.next/standalone/docs/zh/custom-policies.mdx +357 -0
- package/.next/standalone/docs/zh/dashboard.mdx +142 -0
- package/.next/standalone/docs/zh/examples.mdx +253 -0
- package/.next/standalone/docs/zh/for-agents.mdx +38 -0
- package/.next/standalone/docs/zh/getting-started.mdx +134 -0
- package/.next/standalone/docs/zh/introduction.mdx +57 -0
- package/.next/standalone/docs/zh/package-aliases.mdx +82 -0
- package/.next/standalone/docs/zh/testing.mdx +260 -0
- package/.next/standalone/examples/convention-policies/security-policies.mjs +40 -0
- package/.next/standalone/examples/convention-policies/workflow-policies.mjs +41 -0
- package/.next/standalone/next.config.ts +5 -3
- package/.next/standalone/node_modules/@next/env/package.json +1 -1
- package/.next/standalone/node_modules/next/dist/build/swc/index.js +1 -1
- package/.next/standalone/node_modules/next/dist/compiled/jsonwebtoken/index.js +2 -2
- package/.next/standalone/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +1 -1
- package/.next/standalone/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +1 -1
- package/.next/standalone/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +1 -1
- package/.next/standalone/node_modules/next/dist/lib/patch-incorrect-lockfile.js +3 -3
- package/.next/standalone/node_modules/next/dist/server/config.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +7 -2
- package/.next/standalone/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/lib/app-info-log.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/lib/start-server.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/render.js +20 -19
- package/.next/standalone/node_modules/next/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- package/.next/standalone/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
- package/.next/standalone/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
- package/.next/standalone/node_modules/next/dist/telemetry/events/version.js +2 -2
- package/.next/standalone/node_modules/next/package.json +15 -15
- package/.next/standalone/node_modules/react/cjs/react.development.js +1 -1
- package/.next/standalone/node_modules/react/cjs/react.production.js +1 -1
- package/.next/standalone/node_modules/react/package.json +1 -1
- package/.next/standalone/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.js +1 -1
- package/.next/standalone/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.js +1 -1
- package/.next/standalone/node_modules/react-dom/cjs/react-dom-server.browser.production.js +3 -3
- package/.next/standalone/node_modules/react-dom/cjs/react-dom-server.edge.production.js +3 -3
- package/.next/standalone/node_modules/react-dom/cjs/react-dom-server.node.production.js +3 -3
- package/.next/standalone/node_modules/react-dom/cjs/react-dom.production.js +1 -1
- package/.next/standalone/node_modules/react-dom/package.json +2 -2
- package/.next/standalone/package.json +13 -10
- package/.next/standalone/scripts/translate-docs/cache.ts +62 -0
- package/.next/standalone/scripts/translate-docs/cli.ts +357 -0
- package/.next/standalone/scripts/translate-docs/config.ts +248 -0
- package/.next/standalone/scripts/translate-docs/mdx-translator.ts +153 -0
- package/.next/standalone/scripts/translate-docs/mintlify-nav.ts +107 -0
- package/.next/standalone/scripts/translate-docs/readme-translator.ts +154 -0
- package/.next/standalone/scripts/translate-docs/translator.ts +68 -0
- package/.next/standalone/scripts/translate-docs/types.ts +43 -0
- package/.next/standalone/server.js +1 -1
- package/.next/standalone/skills-lock.json +10 -0
- package/.next/standalone/src/hooks/builtin-policies.ts +405 -25
- package/.next/standalone/src/hooks/custom-hooks-loader.ts +165 -21
- package/.next/standalone/src/hooks/handler.ts +33 -6
- package/.next/standalone/src/hooks/hook-activity-store.ts +6 -1
- package/.next/standalone/src/hooks/hooks-config.ts +47 -2
- package/.next/standalone/src/hooks/llm-client.ts +2 -2
- package/.next/standalone/src/hooks/loader-utils.ts +4 -4
- package/.next/standalone/src/hooks/manager.ts +67 -16
- package/.next/standalone/src/hooks/policy-evaluator.ts +58 -19
- package/.next/standalone/src/hooks/policy-helpers.ts +2 -2
- package/.next/standalone/vitest.config.e2e.mts +3 -0
- package/.next/standalone/vitest.config.mts +3 -0
- package/README.md +95 -49
- package/bin/failproofai.mjs +5 -0
- package/dist/cli.mjs +539 -90
- package/dist/index.js +2 -2
- package/package.json +13 -10
- package/scripts/translate-docs/cache.ts +62 -0
- package/scripts/translate-docs/cli.ts +357 -0
- package/scripts/translate-docs/config.ts +248 -0
- package/scripts/translate-docs/mdx-translator.ts +153 -0
- package/scripts/translate-docs/mintlify-nav.ts +107 -0
- package/scripts/translate-docs/readme-translator.ts +154 -0
- package/scripts/translate-docs/translator.ts +68 -0
- package/scripts/translate-docs/types.ts +43 -0
- package/src/hooks/builtin-policies.ts +405 -25
- package/src/hooks/custom-hooks-loader.ts +165 -21
- package/src/hooks/handler.ts +33 -6
- package/src/hooks/hook-activity-store.ts +6 -1
- package/src/hooks/hooks-config.ts +47 -2
- package/src/hooks/llm-client.ts +2 -2
- package/src/hooks/loader-utils.ts +4 -4
- package/src/hooks/manager.ts +67 -16
- package/src/hooks/policy-evaluator.ts +58 -19
- package/src/hooks/policy-helpers.ts +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__02nt~6d._.js +0 -3
- package/.next/standalone/.next/static/chunks/15jpradyu_531.css +0 -1
- package/.next/standalone/docs/cli-reference.md +0 -175
- package/.next/standalone/docs/custom-hooks.md +0 -261
- package/.next/standalone/docs/getting-started.md +0 -128
- package/.next/standalone/docs/introduction.md +0 -47
- /package/.next/standalone/.next/static/{WS-OQSqL1Lp1w_obXfjvl → En9eEShUkUjgeYbY9v6Gy}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{WS-OQSqL1Lp1w_obXfjvl → En9eEShUkUjgeYbY9v6Gy}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{WS-OQSqL1Lp1w_obXfjvl → En9eEShUkUjgeYbY9v6Gy}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
> **⚠️** This is an auto-generated translation. For the latest version, see the [English README](../../README.md). Community corrections welcome!
|
|
2
|
+
|
|
3
|
+
[🇺🇸 English](../../README.md) | **🇨🇳 简体中文** | [🇯🇵 日本語](README.ja.md) | [🇰🇷 한국어](README.ko.md) | [🇪🇸 Español](README.es.md) | [🇧🇷 Português](README.pt-br.md) | [🇩🇪 Deutsch](README.de.md) | [🇫🇷 Français](README.fr.md) | [🇷🇺 Русский](README.ru.md) | [🇮🇳 हिन्दी](README.hi.md) | [🇹🇷 Türkçe](README.tr.md) | [🇻🇳 Tiếng Việt](README.vi.md) | [🇮🇹 Italiano](README.it.md) | [🇸🇦 العربية](README.ar.md) | [🇮🇱 עברית](README.he.md)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
______ _ __ ____ ___ ____
|
|
9
|
+
/ ____/___ _(_) /___ _________ ____ / __/ / | / _/
|
|
10
|
+
/ /_ / __ `/ / / __ \/ ___/ __ \/ __ \/ /_ / /| | / /
|
|
11
|
+
/ __/ / /_/ / / / /_/ / / / /_/ / /_/ / __/ / ___ |_/ /
|
|
12
|
+
/_/ \__,_/_/_/ .___/_/ \____/\____/_/ /_/ |_/___/
|
|
13
|
+
/_/
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
# Failproof AI
|
|
17
|
+
|
|
18
|
+
[](https://befailproof.ai)
|
|
19
|
+
[](https://www.npmjs.com/package/failproofai)
|
|
20
|
+
[](LICENSE)
|
|
21
|
+
[](https://github.com/exospherehost/failproofai/actions)
|
|
22
|
+
[](https://join.slack.com/t/failproofai/shared_invite/zt-3v63b7k5e-O3NBHmj8X6n9gZSGDx6ggQ)
|
|
23
|
+
|
|
24
|
+
**翻译版本**: [简体中文](docs/i18n/README.zh.md) | [日本語](docs/i18n/README.ja.md) | [한국어](docs/i18n/README.ko.md) | [Español](docs/i18n/README.es.md) | [Português](docs/i18n/README.pt-br.md) | [Deutsch](docs/i18n/README.de.md) | [Français](docs/i18n/README.fr.md) | [Русский](docs/i18n/README.ru.md) | [हिन्दी](docs/i18n/README.hi.md) | [Türkçe](docs/i18n/README.tr.md) | [Tiếng Việt](docs/i18n/README.vi.md) | [Italiano](docs/i18n/README.it.md) | [العربية](docs/i18n/README.ar.md) | [עברית](docs/i18n/README.he.md)
|
|
25
|
+
|
|
26
|
+
管理策略的最简便方式,让你的 AI 智能体保持可靠、专注任务、自主运行——适用于 **Claude Code** 和 **Agents SDK**。
|
|
27
|
+
|
|
28
|
+
- **30 条内置策略** - 开箱即用,覆盖常见的智能体故障模式。拦截破坏性命令、防止密钥泄露、将智能体限制在项目边界内、检测循环等。
|
|
29
|
+
- **自定义策略** - 用 JavaScript 编写你自己的可靠性规则。使用 `allow`/`deny`/`instruct` API 强制执行规范、防止漂移、控制操作或与外部系统集成。
|
|
30
|
+
- **简易配置** - 无需编写代码即可调整任意策略。按项目或全局设置允许列表、受保护分支、阈值,三级配置自动合并。
|
|
31
|
+
- **智能体监控** - 查看智能体在你离开期间的所有操作。浏览会话、检查每次工具调用,精确回顾策略触发的位置。
|
|
32
|
+
|
|
33
|
+
一切均在本地运行——数据不会离开你的机器。
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 系统要求
|
|
38
|
+
|
|
39
|
+
- Node.js >= 20.9.0
|
|
40
|
+
- Bun >= 1.3.0(可选——仅在开发或从源码构建时需要)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 安装
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install -g failproofai
|
|
48
|
+
# 或
|
|
49
|
+
bun add -g failproofai
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## 快速开始
|
|
55
|
+
|
|
56
|
+
### 1. 全局启用策略
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
failproofai policies --install
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
将 hook 条目写入 `~/.claude/settings.json`。Claude Code 此后将在每次工具调用前后调用 failproofai。
|
|
63
|
+
|
|
64
|
+
### 2. 启动控制台
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
failproofai
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
打开 `http://localhost:8020`——浏览会话、查看日志、管理策略。
|
|
71
|
+
|
|
72
|
+
### 3. 查看当前启用的策略
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
failproofai policies
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 策略安装
|
|
81
|
+
|
|
82
|
+
### 作用域
|
|
83
|
+
|
|
84
|
+
| 作用域 | 命令 | 写入位置 |
|
|
85
|
+
|--------|------|---------|
|
|
86
|
+
| 全局(默认) | `failproofai policies --install` | `~/.claude/settings.json` |
|
|
87
|
+
| 项目级 | `failproofai policies --install --scope project` | `.claude/settings.json` |
|
|
88
|
+
| 本地级 | `failproofai policies --install --scope local` | `.claude/settings.local.json` |
|
|
89
|
+
|
|
90
|
+
### 安装指定策略
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
failproofai policies --install block-sudo block-rm-rf sanitize-api-keys
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 移除策略
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
failproofai policies --uninstall
|
|
100
|
+
# 或针对特定作用域:
|
|
101
|
+
failproofai policies --uninstall --scope project
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 配置
|
|
107
|
+
|
|
108
|
+
策略配置存储在 `~/.failproofai/policies-config.json`(全局)或项目目录下的 `.failproofai/policies-config.json`(项目级)。
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"enabledPolicies": [
|
|
113
|
+
"block-sudo",
|
|
114
|
+
"block-rm-rf",
|
|
115
|
+
"sanitize-api-keys",
|
|
116
|
+
"block-push-master",
|
|
117
|
+
"block-env-files",
|
|
118
|
+
"block-read-outside-cwd"
|
|
119
|
+
],
|
|
120
|
+
"policyParams": {
|
|
121
|
+
"block-sudo": {
|
|
122
|
+
"allowPatterns": ["sudo systemctl status", "sudo journalctl"],
|
|
123
|
+
"hint": "Use apt-get directly without sudo."
|
|
124
|
+
},
|
|
125
|
+
"block-push-master": {
|
|
126
|
+
"protectedBranches": ["main", "release", "prod"],
|
|
127
|
+
"hint": "Try creating a fresh branch instead."
|
|
128
|
+
},
|
|
129
|
+
"sanitize-api-keys": {
|
|
130
|
+
"additionalPatterns": [
|
|
131
|
+
{ "regex": "myco_[A-Za-z0-9]{32}", "label": "MyCo API key" }
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
"warn-large-file-write": {
|
|
135
|
+
"thresholdKb": 512
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**三级配置作用域**自动合并(项目级 → 本地级 → 全局级)。完整合并规则参见 [docs/configuration.mdx](docs/configuration.mdx)。
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 内置策略
|
|
146
|
+
|
|
147
|
+
| 策略 | 说明 | 可配置项 |
|
|
148
|
+
|------|------|:---:|
|
|
149
|
+
| `block-sudo` | 阻止智能体运行特权系统命令 | `allowPatterns` |
|
|
150
|
+
| `block-rm-rf` | 防止意外递归删除文件 | `allowPaths` |
|
|
151
|
+
| `block-curl-pipe-sh` | 阻止智能体将不可信脚本通过管道传给 shell | |
|
|
152
|
+
| `block-failproofai-commands` | 阻止自我卸载 | |
|
|
153
|
+
| `sanitize-jwt` | 防止 JWT 令牌泄露到智能体上下文中 | |
|
|
154
|
+
| `sanitize-api-keys` | 防止 API 密钥泄露到智能体上下文中 | `additionalPatterns` |
|
|
155
|
+
| `sanitize-connection-strings` | 防止数据库凭据泄露到智能体上下文中 | |
|
|
156
|
+
| `sanitize-private-key-content` | 从输出中删除 PEM 私钥块 | |
|
|
157
|
+
| `sanitize-bearer-tokens` | 从输出中删除 Authorization Bearer 令牌 | |
|
|
158
|
+
| `block-env-files` | 阻止智能体读取 .env 文件 | |
|
|
159
|
+
| `protect-env-vars` | 阻止智能体打印环境变量 | |
|
|
160
|
+
| `block-read-outside-cwd` | 将智能体限制在项目边界内 | `allowPaths` |
|
|
161
|
+
| `block-secrets-write` | 阻止向私钥和证书文件写入 | `additionalPatterns` |
|
|
162
|
+
| `block-push-master` | 防止意外推送到 main/master | `protectedBranches` |
|
|
163
|
+
| `block-work-on-main` | 禁止智能体操作受保护分支 | `protectedBranches` |
|
|
164
|
+
| `block-force-push` | 阻止 `git push --force` | |
|
|
165
|
+
| `warn-git-amend` | 在修改提交前提醒智能体 | |
|
|
166
|
+
| `warn-git-stash-drop` | 在丢弃储藏区前提醒智能体 | |
|
|
167
|
+
| `warn-all-files-staged` | 捕获意外的 `git add -A` | |
|
|
168
|
+
| `warn-destructive-sql` | 在执行前捕获 DROP/DELETE SQL | |
|
|
169
|
+
| `warn-schema-alteration` | 在执行前捕获 ALTER TABLE | |
|
|
170
|
+
| `warn-large-file-write` | 捕获意外的大文件写入 | `thresholdKb` |
|
|
171
|
+
| `warn-package-publish` | 捕获意外的 `npm publish` | |
|
|
172
|
+
| `warn-background-process` | 捕获意外启动的后台进程 | |
|
|
173
|
+
| `warn-global-package-install` | 捕获意外的全局包安装 | |
|
|
174
|
+
| …以及更多 | | |
|
|
175
|
+
|
|
176
|
+
完整策略详情和参数参考:[docs/built-in-policies.mdx](docs/built-in-policies.mdx)
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 自定义策略
|
|
181
|
+
|
|
182
|
+
编写你自己的策略,使智能体保持可靠并专注任务:
|
|
183
|
+
|
|
184
|
+
```js
|
|
185
|
+
import { customPolicies, allow, deny, instruct } from "failproofai";
|
|
186
|
+
|
|
187
|
+
customPolicies.add({
|
|
188
|
+
name: "no-production-writes",
|
|
189
|
+
description: "Block writes to paths containing 'production'",
|
|
190
|
+
match: { events: ["PreToolUse"] },
|
|
191
|
+
fn: async (ctx) => {
|
|
192
|
+
if (!["Write", "Edit"].includes(ctx.toolName ?? "")) return allow();
|
|
193
|
+
const path = ctx.toolInput?.file_path ?? "";
|
|
194
|
+
if (path.includes("production")) return deny("Writes to production paths are blocked");
|
|
195
|
+
return allow();
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
通过以下命令安装:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
failproofai policies --install --custom ./my-policies.js
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### 决策辅助函数
|
|
207
|
+
|
|
208
|
+
| 函数 | 效果 |
|
|
209
|
+
|------|------|
|
|
210
|
+
| `allow()` | 允许该操作 |
|
|
211
|
+
| `allow(message)` | 允许并向 Claude 发送信息性上下文 *(beta)* |
|
|
212
|
+
| `deny(message)` | 阻止该操作;消息将显示给 Claude |
|
|
213
|
+
| `instruct(message)` | 向 Claude 的提示词添加上下文;不会阻止操作 |
|
|
214
|
+
|
|
215
|
+
### 上下文对象(`ctx`)
|
|
216
|
+
|
|
217
|
+
| 字段 | 类型 | 说明 |
|
|
218
|
+
|------|------|------|
|
|
219
|
+
| `eventType` | `string` | `"PreToolUse"`、`"PostToolUse"`、`"Notification"`、`"Stop"` |
|
|
220
|
+
| `toolName` | `string` | 被调用的工具(`"Bash"`、`"Write"`、`"Read"` 等) |
|
|
221
|
+
| `toolInput` | `object` | 工具的输入参数 |
|
|
222
|
+
| `payload` | `object` | 完整的原始事件载荷 |
|
|
223
|
+
| `session.cwd` | `string` | Claude Code 会话的工作目录 |
|
|
224
|
+
| `session.sessionId` | `string` | 会话标识符 |
|
|
225
|
+
| `session.transcriptPath` | `string` | 会话记录文件的路径 |
|
|
226
|
+
|
|
227
|
+
自定义 hook 支持传递性本地导入、async/await,以及访问 `process.env`。错误采用放行处理(记录到 `~/.failproofai/hook.log`,内置策略继续执行)。完整指南参见 [docs/custom-hooks.mdx](docs/custom-hooks.mdx)。
|
|
228
|
+
|
|
229
|
+
### 基于约定的策略(v0.0.2-beta.7+)
|
|
230
|
+
|
|
231
|
+
将 `*policies.{js,mjs,ts}` 文件放入 `.failproofai/policies/` 目录,它们将自动加载——无需 `--custom` 标志或配置变更。就像 git hooks 一样:放入文件即可生效。
|
|
232
|
+
|
|
233
|
+
```text
|
|
234
|
+
# 项目级——提交到 git,与团队共享
|
|
235
|
+
.failproofai/policies/security-policies.mjs
|
|
236
|
+
.failproofai/policies/workflow-policies.mjs
|
|
237
|
+
|
|
238
|
+
# 用户级——个人专属,适用于所有项目
|
|
239
|
+
~/.failproofai/policies/my-policies.mjs
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
两个级别均会加载(取并集)。文件在各目录内按字母顺序加载。使用 `01-`、`02-` 等前缀来控制加载顺序。即用型示例参见 [examples/convention-policies/](examples/convention-policies/)。
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 遥测
|
|
247
|
+
|
|
248
|
+
Failproof AI 通过 PostHog 收集匿名使用遥测数据,用于了解功能使用情况。会话内容、文件名、工具输入或任何个人信息均不会被发送。
|
|
249
|
+
|
|
250
|
+
禁用遥测:
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
FAILPROOFAI_TELEMETRY_DISABLED=1 failproofai
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 文档
|
|
259
|
+
|
|
260
|
+
| 指南 | 说明 |
|
|
261
|
+
|------|------|
|
|
262
|
+
| [快速入门](docs/getting-started.mdx) | 安装与初步使用 |
|
|
263
|
+
| [内置策略](docs/built-in-policies.mdx) | 全部 30 条内置策略及其参数 |
|
|
264
|
+
| [自定义策略](docs/custom-policies.mdx) | 编写你自己的策略 |
|
|
265
|
+
| [配置](docs/configuration.mdx) | 配置文件格式与作用域合并规则 |
|
|
266
|
+
| [控制台](docs/dashboard.mdx) | 监控会话并查看策略活动 |
|
|
267
|
+
| [架构](docs/architecture.mdx) | hook 系统的工作原理 |
|
|
268
|
+
| [测试](docs/testing.mdx) | 运行测试与编写新测试 |
|
|
269
|
+
|
|
270
|
+
### 本地运行文档
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
docker build -f Dockerfile.docs -t failproofai-docs .
|
|
274
|
+
docker run --rm -p 3000:3000 failproofai-docs
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
在 `http://localhost:3000` 打开 Mintlify 文档站点。挂载 docs 目录后,容器会监听文件变更:
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
docker run --rm -p 3000:3000 -v $(pwd)/docs:/app/docs failproofai-docs
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## 致 failproofai 贡献者的说明
|
|
286
|
+
|
|
287
|
+
本仓库的 `.claude/settings.json` 使用 `bun ./bin/failproofai.mjs --hook <EventType>` 而非标准的 `npx -y failproofai` 命令。这是因为在 failproofai 项目内部运行 `npx -y failproofai` 会产生自引用冲突。
|
|
288
|
+
|
|
289
|
+
对于所有其他仓库,推荐的方式是使用 `npx -y failproofai`,通过以下命令安装:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
failproofai policies --install --scope project
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## 贡献指南
|
|
296
|
+
|
|
297
|
+
参见 [CONTRIBUTING.md](CONTRIBUTING.md)。
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## 许可证
|
|
302
|
+
|
|
303
|
+
参见 [LICENSE](LICENSE)。
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
由 **ExosphereHost: 智能体可靠性研究实验室** 构建与维护。我们通过自研智能体、软件和专业知识,帮助企业和初创公司提升 AI 智能体的可靠性。了解更多,请访问 [exosphere.host](https://exosphere.host)。
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Failproof AI
|
|
3
|
+
description: "Manage hooks and policies that keep your AI agents reliable and running autonomously"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/failproofai)
|
|
7
|
+
|
|
8
|
+
Hooks and policies that keep your AI agents reliable and running autonomously - for **Claude Code** and the **Agents SDK**.
|
|
9
|
+
|
|
10
|
+
AI agents fail in predictable ways. They run destructive commands, leak secrets, drift off-task, get stuck in loops, or push directly to main. Left unattended, small failures cascade.
|
|
11
|
+
|
|
12
|
+
Failproof AI solves this with **policies** - rules that hook into every agent tool call and can **detect failures**, **mitigate them** (block, instruct, sanitize), and **alert you** when something needs attention. A local dashboard lets you review everything afterward.
|
|
13
|
+
|
|
14
|
+
Everything runs locally. No data leaves your machine.
|
|
15
|
+
|
|
16
|
+
## Get started
|
|
17
|
+
|
|
18
|
+
<CardGroup cols={2}>
|
|
19
|
+
|
|
20
|
+
<Card title="26 built-in policies" icon="shield" href="/built-in-policies">
|
|
21
|
+
Block destructive commands, prevent secret leakage, keep agents inside project boundaries, and more - out of the box.
|
|
22
|
+
</Card>
|
|
23
|
+
|
|
24
|
+
<Card title="Custom policies" icon="code" href="/custom-policies">
|
|
25
|
+
Write your own rules in JavaScript with a simple allow / deny / instruct API.
|
|
26
|
+
</Card>
|
|
27
|
+
|
|
28
|
+
<Card title="Agent monitor" icon="chart-line" href="/dashboard">
|
|
29
|
+
See what your agents did while you were away. Browse sessions, inspect tool calls, review where policies fired.
|
|
30
|
+
</Card>
|
|
31
|
+
|
|
32
|
+
<Card title="Easy configuration" icon="gear" href="/configuration">
|
|
33
|
+
Tune any policy without code. Set allowlists, protected branches, or thresholds per-project or globally.
|
|
34
|
+
</Card>
|
|
35
|
+
|
|
36
|
+
</CardGroup>
|
|
37
|
+
|
|
38
|
+
## Quick start
|
|
39
|
+
|
|
40
|
+
<CodeGroup>
|
|
41
|
+
|
|
42
|
+
```bash npm
|
|
43
|
+
npm install -g failproofai
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```bash bun
|
|
47
|
+
bun add -g failproofai
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
</CodeGroup>
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
failproofai policies --install # enable policies
|
|
54
|
+
failproofai # launch the dashboard
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
See the [Getting started](/getting-started) guide for the full walkthrough.
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
---
|
|
2
|
+
---
|
|
3
|
+
title: Architettura
|
|
4
|
+
description: "Come il gestore di hook, il caricamento della configurazione e la valutazione delle politiche funzionano internamente"
|
|
5
|
+
icon: sitemap
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Questo documento spiega come failproofai funziona internamente: come il sistema di hook intercetta le chiamate agli strumenti dell'agente, come viene caricata e unita la configurazione, come vengono valutate le politiche e come il dashboard monitora l'attività dell'agente.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Panoramica
|
|
13
|
+
|
|
14
|
+
failproofai ha due sottosistemi indipendenti:
|
|
15
|
+
|
|
16
|
+
1. **Gestore di hook** - Un veloce subprocess CLI che Claude Code richiama ad ogni chiamata dello strumento dell'agente. Valuta le politiche e restituisce una decisione.
|
|
17
|
+
2. **Agent Monitor (Dashboard)** - Un'applicazione web Next.js per il monitoraggio delle sessioni dell'agente e la gestione delle politiche.
|
|
18
|
+
|
|
19
|
+
Entrambi i sottosistemi condividono file di configurazione in `~/.failproofai/` e nella directory `.failproofai/` del progetto, ma vengono eseguiti come processi separati e comunicano solo tramite il filesystem.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Gestore di hook
|
|
24
|
+
|
|
25
|
+
### Integrazione con Claude Code
|
|
26
|
+
|
|
27
|
+
Quando esegui `failproofai policies --install`, scrive voci come questa in `~/.claude/settings.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"hooks": {
|
|
32
|
+
"PreToolUse": [
|
|
33
|
+
{
|
|
34
|
+
"matcher": "",
|
|
35
|
+
"hooks": [
|
|
36
|
+
{
|
|
37
|
+
"type": "command",
|
|
38
|
+
"command": "failproofai --hook PreToolUse"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"PostToolUse": [ ... ]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Claude Code quindi richiama `failproofai --hook PreToolUse` come subprocess prima di ogni chiamata allo strumento, passando un payload JSON su stdin.
|
|
49
|
+
|
|
50
|
+
### Formato del payload
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"session_id": "abc123",
|
|
55
|
+
"transcript_path": "/home/user/.claude/projects/myproject/sessions/abc123.jsonl",
|
|
56
|
+
"cwd": "/home/user/myproject",
|
|
57
|
+
"permission_mode": "default",
|
|
58
|
+
"hook_event_name": "PreToolUse",
|
|
59
|
+
"tool_name": "Bash",
|
|
60
|
+
"tool_input": { "command": "sudo apt install nodejs" }
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Per eventi `PostToolUse`, il payload contiene anche `tool_result` con l'output dello strumento.
|
|
65
|
+
|
|
66
|
+
Il gestore applica un limite di 1 MB per stdin. I payload che superano questo limite vengono scartati e tutte le politiche consentono implicitamente.
|
|
67
|
+
|
|
68
|
+
### Formato della risposta
|
|
69
|
+
|
|
70
|
+
**Deny (PreToolUse):**
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"hookSpecificOutput": {
|
|
74
|
+
"permissionDecision": "deny",
|
|
75
|
+
"permissionDecisionReason": "Blocked by failproofai: sudo command blocked"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Deny (PostToolUse):**
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"hookSpecificOutput": {
|
|
84
|
+
"additionalContext": "Blocked by failproofai because: API key detected in output"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Instruct (qualsiasi evento tranne Stop):**
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"hookSpecificOutput": {
|
|
93
|
+
"additionalContext": "Instruction from failproofai: Verify tests pass before committing."
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Evento Stop instruct:**
|
|
99
|
+
- Exit code: `2`
|
|
100
|
+
- Motivo scritto su stderr (non stdout)
|
|
101
|
+
|
|
102
|
+
**Allow:**
|
|
103
|
+
- Exit code: `0`
|
|
104
|
+
- Stdout vuoto
|
|
105
|
+
|
|
106
|
+
**Allow con messaggio (beta):**
|
|
107
|
+
|
|
108
|
+
A partire da v0.0.2-beta.3, `allow(message)` consente a una politica di inviare un contesto informativo a Claude anche quando l'operazione è consentita. Il gestore di hook scrive il seguente JSON su **stdout** (non in un file di configurazione — questa è la risposta del gestore a Claude Code, proprio come le risposte deny e instruct sopra):
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
// Written to stdout by the hook handler process
|
|
112
|
+
{
|
|
113
|
+
"hookSpecificOutput": {
|
|
114
|
+
"additionalContext": "All CI checks passed on branch 'feat/my-feature'."
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
- Exit code: `0` (l'operazione è consentita)
|
|
119
|
+
- Quando più politiche restituiscono `allow` con un messaggio, i loro messaggi vengono uniti con newline in una singola stringa `additionalContext`
|
|
120
|
+
- Se nessuna politica fornisce un messaggio, stdout è vuoto (come prima)
|
|
121
|
+
|
|
122
|
+
### Pipeline di elaborazione
|
|
123
|
+
|
|
124
|
+
`src/hooks/handler.ts` implementa la pipeline completa:
|
|
125
|
+
|
|
126
|
+
```text
|
|
127
|
+
stdin JSON
|
|
128
|
+
→ parse payload (max 1 MB)
|
|
129
|
+
→ extract session metadata (session_id, cwd, tool_name, tool_input, etc.)
|
|
130
|
+
→ readMergedHooksConfig(cwd) ← merges project + local + global config
|
|
131
|
+
→ register enabled builtin policies with resolved params
|
|
132
|
+
→ load custom policies from customPoliciesPath (if set)
|
|
133
|
+
→ register custom policies into policy registry
|
|
134
|
+
→ evaluate all policies (builtins first, then custom)
|
|
135
|
+
→ first deny short-circuits
|
|
136
|
+
→ instruct decisions accumulate
|
|
137
|
+
→ allow messages accumulate
|
|
138
|
+
→ write JSON decision to stdout
|
|
139
|
+
→ persist event to ~/.failproofai/hook-activity.jsonl
|
|
140
|
+
→ exit
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
L'intero processo viene eseguito in meno di 100ms per i payload tipici senza chiamate LLM.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Caricamento della configurazione
|
|
148
|
+
|
|
149
|
+
`src/hooks/hooks-config.ts` implementa il caricamento della configurazione a tre ambiti.
|
|
150
|
+
|
|
151
|
+
```text
|
|
152
|
+
[1] {cwd}/.failproofai/policies-config.json ← project (highest priority)
|
|
153
|
+
[2] {cwd}/.failproofai/policies-config.local.json ← local
|
|
154
|
+
[3] ~/.failproofai/policies-config.json ← global (lowest priority)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Logica di unione:
|
|
158
|
+
- `enabledPolicies` - unione deduplicate tra tutti e tre i file
|
|
159
|
+
- `policyParams` - per ogni politica, il primo file che la definisce vince completamente
|
|
160
|
+
- `customPoliciesPath` - il primo file che la definisce vince
|
|
161
|
+
- `llm` - il primo file che la definisce vince
|
|
162
|
+
|
|
163
|
+
Il dashboard web utilizza `readHooksConfig()` (solo globale) per lettura e scrittura, poiché non viene richiamato con un cwd di progetto.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Valutazione delle politiche
|
|
168
|
+
|
|
169
|
+
`src/hooks/policy-evaluator.ts` esegue le politiche in ordine.
|
|
170
|
+
|
|
171
|
+
Per ogni politica:
|
|
172
|
+
|
|
173
|
+
1. Cerca lo schema `params` della politica (se ne ha uno).
|
|
174
|
+
2. Legge `policyParams[policy.name]` dalla configurazione unita.
|
|
175
|
+
3. Unisce i valori forniti dall'utente sui valori predefiniti dello schema per produrre `ctx.params`.
|
|
176
|
+
4. Chiama `policy.fn(ctx)` con il contesto risolto.
|
|
177
|
+
5. Se il risultato è `deny`, ferma immediatamente e restituisci quella decisione.
|
|
178
|
+
6. Se il risultato è `instruct`, accumula il messaggio e continua.
|
|
179
|
+
7. Se il risultato è `allow`, continua alla politica successiva.
|
|
180
|
+
|
|
181
|
+
Dopo che tutte le politiche vengono eseguite:
|
|
182
|
+
- Se è stato restituito qualsiasi `deny`, emetti la risposta di deny.
|
|
183
|
+
- Se sono stati raccolti risultati `instruct`, emetti una singola risposta instruct con tutti i messaggi uniti.
|
|
184
|
+
- Altrimenti, emetti una risposta allow (stdout vuoto, exit 0).
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Politiche integrate
|
|
189
|
+
|
|
190
|
+
`src/hooks/builtin-policies.ts` definisce tutte le 26 politiche integrate come oggetti `BuiltinPolicyDefinition`:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
interface BuiltinPolicyDefinition {
|
|
194
|
+
name: string;
|
|
195
|
+
description: string;
|
|
196
|
+
fn: (ctx: PolicyContext) => PolicyResult;
|
|
197
|
+
match: {
|
|
198
|
+
events: HookEventType[];
|
|
199
|
+
tools?: string[];
|
|
200
|
+
};
|
|
201
|
+
defaultEnabled: boolean;
|
|
202
|
+
category: string;
|
|
203
|
+
beta?: boolean;
|
|
204
|
+
params?: PolicyParamsSchema;
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Le politiche che accettano `params` dichiarano un `PolicyParamsSchema` con tipi e valori predefiniti per ogni parametro. L'evaluator di politiche inietta i valori risolti in `ctx.params` prima di chiamare `fn`. Le funzioni di politica leggono `ctx.params` senza null-guarding perché i valori predefiniti vengono sempre applicati per primi.
|
|
209
|
+
|
|
210
|
+
Il pattern matching all'interno delle politiche utilizza token di comando parsati (argv), non corrispondenza di stringhe grezze. Questo previene il bypass tramite iniezione di operatori shell (ad esempio, un pattern per `sudo systemctl status *` non può essere bypassato aggiungendo `; rm -rf /` al comando).
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Politiche personalizzate
|
|
215
|
+
|
|
216
|
+
`src/hooks/custom-hooks-registry.ts` implementa un registro supportato da `globalThis`:
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
const REGISTRY_KEY = "__failproofai_custom_hooks__";
|
|
220
|
+
|
|
221
|
+
export const customPolicies = {
|
|
222
|
+
add(hook: CustomHook): void { ... }
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export function getCustomHooks(): CustomHook[] { ... }
|
|
226
|
+
export function clearCustomHooks(): void { ... } // used in tests
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
`src/hooks/custom-hooks-loader.ts` carica il file di politica dell'utente:
|
|
230
|
+
|
|
231
|
+
1. Leggi `customPoliciesPath` dalla configurazione; salta se assente.
|
|
232
|
+
2. Risolvi al percorso assoluto; verifica che il file esista.
|
|
233
|
+
3. Riscrivi tutti gli import `from "failproofai"` al percorso dist effettivo in modo che `customPolicies` si risolva nello stesso registro `globalThis`.
|
|
234
|
+
4. Riscrivi ricorsivamente gli import locali transitivi per garantire la compatibilità ESM.
|
|
235
|
+
5. Scrivi file `.mjs` temporanei e `import()` il file di entry.
|
|
236
|
+
6. Chiama `getCustomHooks()` per recuperare gli hook registrati.
|
|
237
|
+
7. Pulisci tutti i file temporanei in un blocco `finally`.
|
|
238
|
+
|
|
239
|
+
In caso di errore (file non trovato, errore di sintassi, errore di import), l'errore viene registrato in `~/.failproofai/hook.log` e il loader restituisce un array vuoto. Le politiche integrate non sono interessate.
|
|
240
|
+
|
|
241
|
+
Le politiche personalizzate vengono valutate dopo tutte le politiche integrate. Un `deny` di politica personalizzata continua a cortocircuitare ulteriori politiche personalizzate (ma tutte le integrate sono già state eseguite a questo punto).
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Logging dell'attività
|
|
246
|
+
|
|
247
|
+
Dopo ogni evento di hook, il gestore aggiunge una riga JSONL a `~/.failproofai/hook-activity.jsonl`:
|
|
248
|
+
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"timestamp": "2026-04-06T12:34:56.789Z",
|
|
252
|
+
"sessionId": "abc123",
|
|
253
|
+
"eventType": "PreToolUse",
|
|
254
|
+
"toolName": "Bash",
|
|
255
|
+
"policyName": "block-sudo",
|
|
256
|
+
"decision": "deny",
|
|
257
|
+
"reason": "sudo command blocked by failproofai",
|
|
258
|
+
"durationMs": 12
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Una riga per ogni politica che ha preso una decisione non-allow. Le decisioni allow non vengono registrate (per mantenere il file piccolo).
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Architettura del dashboard
|
|
267
|
+
|
|
268
|
+
Il dashboard è un'applicazione **Next.js 16** che utilizza l'App Router con React Server Components e Server Actions.
|
|
269
|
+
|
|
270
|
+
```text
|
|
271
|
+
app/
|
|
272
|
+
layout.tsx ← Root layout (theme, telemetry, nav)
|
|
273
|
+
projects/page.tsx ← Server component: list all Claude projects
|
|
274
|
+
project/[name]/page.tsx ← Server component: list sessions in a project
|
|
275
|
+
project/[name]/session/
|
|
276
|
+
[sessionId]/page.tsx ← Server component: render session viewer
|
|
277
|
+
policies/page.tsx ← Client component: policy management + activity log
|
|
278
|
+
actions/
|
|
279
|
+
get-hooks-config.ts ← Read config + policy list
|
|
280
|
+
update-hooks-config.ts ← Toggle policy on/off
|
|
281
|
+
update-policy-params.ts ← Update policy parameters
|
|
282
|
+
get-hook-activity.ts ← Paginate/search activity log
|
|
283
|
+
install-hooks-web.ts ← Install/remove hooks from the browser
|
|
284
|
+
api/
|
|
285
|
+
download/[project]/[session]/route.ts ← Export session as ZIP/JSONL
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Flusso di dati:**
|
|
289
|
+
|
|
290
|
+
- I componenti pagina chiamano `lib/projects.ts` e `lib/log-entries.ts` per leggere i dati di progetto/sessione direttamente dal filesystem (nessun livello API per le letture).
|
|
291
|
+
- La pagina Policies utilizza Server Actions per tutte le mutazioni (toggle, aggiornamento params, installa/rimuovi).
|
|
292
|
+
- Il visualizzatore di sessione parsifica il formato di trascritto JSONL di Claude e renderizza una timeline di messaggi e chiamate di strumenti.
|
|
293
|
+
|
|
294
|
+
**Decisioni di design chiave:**
|
|
295
|
+
|
|
296
|
+
- Nessun database - tutto lo stato persistente è in file semplici (`~/.failproofai/`, `~/.claude/projects/`).
|
|
297
|
+
- Server Actions per mutazioni - nessuna API REST necessaria per le operazioni CRUD.
|
|
298
|
+
- React Server Components per pagine di lettura - caricamento iniziale più veloce, nessun bundle client per il recupero dati.
|
|
299
|
+
- Componenti client solo dove è necessaria l'interattività (toggle di politiche, ricerca attività, visualizzatore di log).
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## Layout dei file
|
|
304
|
+
|
|
305
|
+
```text
|
|
306
|
+
failproofai/
|
|
307
|
+
├── bin/
|
|
308
|
+
│ └── failproofai.mjs # CLI router (hook / dashboard / install / etc.)
|
|
309
|
+
├── src/hooks/
|
|
310
|
+
│ ├── handler.ts # Hook event pipeline
|
|
311
|
+
│ ├── builtin-policies.ts # 26 policy definitions
|
|
312
|
+
│ ├── policy-evaluator.ts # Policy execution engine
|
|
313
|
+
│ ├── policy-registry.ts # Policy registration and lookup
|
|
314
|
+
│ ├── policy-types.ts # TypeScript interfaces
|
|
315
|
+
│ ├── hooks-config.ts # Multi-scope config loading
|
|
316
|
+
│ ├── custom-hooks-registry.ts # globalThis-backed hook registry
|
|
317
|
+
│ ├── custom-hooks-loader.ts # ESM loader for user JS hooks
|
|
318
|
+
│ ├── manager.ts # install / remove / list operations
|
|
319
|
+
│ ├── install-prompt.ts # Interactive policy selection prompt
|
|
320
|
+
│ ├── hook-logger.ts # Logging to hook.log
|
|
321
|
+
│ ├── hook-activity-store.ts # Persist activity to hook-activity.jsonl
|
|
322
|
+
│ └── llm-client.ts # LLM API client (for AI-powered policies)
|
|
323
|
+
├── app/ # Next.js dashboard (pages + server actions)
|
|
324
|
+
├── lib/ # Shared utilities
|
|
325
|
+
│ ├── projects.ts # Enumerate Claude projects from filesystem
|
|
326
|
+
│ ├── log-entries.ts # Parse Claude transcript JSONL format
|
|
327
|
+
│ ├── paths.ts # Resolve system paths
|
|
328
|
+
│ └── ...
|
|
329
|
+
├── components/ # Shared React UI components
|
|
330
|
+
├── contexts/ # React context providers (theme, auto-refresh, telemetry)
|
|
331
|
+
├── examples/ # Example custom hook files
|
|
332
|
+
└── __tests__/ # Unit and E2E tests
|
|
333
|
+
```
|