failproofai 1.0.14 → 1.0.16-beta.0
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 +23 -23
- 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/build-manifest.json +3 -3
- 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 +2 -2
- 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 +2 -2
- 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 +3 -3
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +4 -4
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- 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 +22 -21
- 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/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page.js +4 -3
- 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 +4 -4
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page/build-manifest.json +3 -3
- 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 +3 -3
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
- package/.next/standalone/.next/server/app/policies/page.js +8 -7
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +8 -8
- package/.next/standalone/.next/server/app/settings/page.js +8 -7
- package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__048f1wnr8pysf._.js +4 -4
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1oclamblhzhrf._.js +1 -1
- package/.next/standalone/.next/server/chunks/_0tovk6q0miud6._.js +1 -1
- package/.next/standalone/.next/server/chunks/_0trp3ycqv17cl._.js +1 -1
- package/.next/standalone/.next/server/chunks/_1vslkoe35wok6._.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_01r25oigsgz07._.js +1 -1
- package/.next/standalone/.next/server/chunks/node_modules_posthog-node_dist_entrypoints_index_node_mjs_09z9-p77cu37y._.js +1 -1
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4vkpxxu7._.js +1 -1
- package/.next/standalone/.next/server/chunks/src_hooks_0fmclqlaj83-2._.js +5 -0
- package/.next/standalone/.next/server/chunks/src_hooks_15j31lnj-km9r._.js +3 -0
- package/.next/standalone/.next/server/chunks/src_hooks_daemon-client_ts_0il_yu1zc0291._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__08ch3staq3ejw._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0bigvy9xmv2ka._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ezoipo-r7_5k._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0h86bl2qf0k_o._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0pia5h3p8re4c._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0t76rmc_vci18._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1vofkb2oq7p7e._.js → [root-of-the-server]__0tayeyopslkf1._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1-ey9fgesfbc0._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__15usvs-ms-0hf._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__16gb3_92zvk5x._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1avi2kypusyb_._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1r7drlqli-ado._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1vxwetblyf8vp._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0eoura3_9gjb-._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0f-kswpk5hx7v._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_0pedwblqdoh58._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1_ozgifqv1ssi._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1djqs9i27e4kg._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1v4_ul3sj2lq_._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo5_vm5f.js +5 -5
- package/.next/standalone/.next/server/chunks/ssr/app_actions_get-scheduled-audit_ts_0ei9snixb5fd-._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47q0xq5w._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_components_project-list_tsx_1ke6anr0vt64h._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x33jqb6._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpcz0uxur._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_settings_02tf1h47jmhhd._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_html-to-image_es_index_0r9i9nq3-ei-l.js → node_modules_html-to-image_es_index_0wgfci23_yqs_.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_0bz67659f5z-3._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_next_dist_1khq67j4vo9y4._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_11bnuznb72p7z._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/package_json_[json]_cjs_013tntikdft59._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1-ytegsicaf2d._.js +5 -0
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_1euxn1va7c5gq._.js +5 -0
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_daemon-client_ts_0k41_i7jg6ndv._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_daemon-service_ts_0ibufora3s_bw._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_effective-reviewers_ts_1h4wtvo55j16x._.js +3 -0
- package/.next/standalone/.next/server/middleware-build-manifest.js +23 -23
- 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/preview-props.json +3 -3
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +23 -23
- package/.next/standalone/.next/static/chunks/0fqjv13piwa6z.js +1 -0
- package/.next/standalone/.next/static/chunks/{435eshlryosz1.js → 0y9qczsccrmmf.js} +1 -1
- package/.next/standalone/.next/static/chunks/{110hwwc6agsr8.js → 0z70k3nof30ws.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3hk5y4kny2ktd.js → 167exo9u6npy3.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2zlfhyqvlvf7o.js → 1xwh61k4505md.js} +1 -1
- package/.next/standalone/.next/static/chunks/24nikgpkr0qas.js +1 -0
- package/.next/standalone/.next/static/chunks/{2wh64znsc_mo2.js → 2ayu58wi805x4.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0tiuj32d-qcy3.js → 2swcvie6i54dn.js} +1 -1
- package/.next/standalone/.next/static/chunks/2xx-2wehe-kwl.js +1 -0
- package/.next/standalone/.next/static/chunks/{2wye36b3mbzpa.js → 34rjkinfk6d4p.js} +1 -1
- package/.next/standalone/.next/static/chunks/{1i9zuw01f0ogt.js → 3r-j6pmqrq4l1.js} +2 -2
- package/.next/standalone/.next/static/chunks/3tfcj166ki-08.js +1 -0
- package/.next/standalone/.next/static/chunks/3uj5quosl7j_x.js +6 -0
- package/.next/standalone/assets/logos/failproof-dark.png +0 -0
- package/.next/standalone/assets/logos/failproof-light.png +0 -0
- package/.next/standalone/fp-cloud-cli/CHANGELOG.md +24 -3
- package/.next/standalone/fp-cloud-cli/fp_cli/_version.py +1 -1
- package/.next/standalone/fp-cloud-cli/uv.lock +6 -6
- package/.next/standalone/hermes-plugin/client.py +97 -37
- package/.next/standalone/hermes-plugin/plugin.yaml +1 -1
- 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/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/app-route-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/app-render/async-local-storage.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/base-http/node.js +7 -2
- 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 +2 -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/router-server.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/lib/trace/tracer.js +1 -1
- package/.next/standalone/node_modules/next/dist/server/use-cache/use-cache-wrapper.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 +10 -10
- package/.next/standalone/package.json +10 -10
- package/.next/standalone/sdk/python/uv.lock +18 -18
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/package-lock.json +40 -40
- package/.next/standalone/sdk/typescript/integration/fixtures/nextjs/package.json +1 -1
- package/.next/standalone/server.js +1 -1
- package/README.md +174 -83
- package/bin/failproofai.mjs +66 -90
- package/dist/cli.mjs +1422 -1490
- package/dist/worker.mjs +19 -4
- package/hermes-plugin/client.py +97 -37
- package/hermes-plugin/plugin.yaml +1 -1
- package/openclaw-plugin/daemon-client.js +157 -32
- package/openclaw-plugin/hooks.js +16 -1
- package/package.json +10 -10
- package/pi-extension/index.ts +2 -0
- package/src/hooks/cloud-managed-policies.ts +22 -0
- package/src/hooks/config-status.ts +34 -21
- package/src/hooks/configure-wizard.ts +16 -3
- package/src/hooks/daemon-client.ts +59 -16
- package/src/hooks/daemon-service.ts +167 -19
- package/src/hooks/delivery-health.ts +10 -0
- package/src/hooks/fp-home.ts +8 -0
- package/src/hooks/fp-reset.ts +8 -2
- package/src/hooks/gateway-restart.ts +248 -0
- package/src/hooks/handler.ts +39 -2
- package/src/hooks/hermes-update.ts +18 -2
- package/src/hooks/hook-activity-store.ts +5 -0
- package/src/hooks/manager.ts +43 -9
- package/src/hooks/shell-quote.ts +19 -0
- package/src/hooks/update-run.ts +276 -0
- package/.next/standalone/.next/server/chunks/src_hooks_0_em82s16zfym._.js +0 -5
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1xwr4hi-on27i._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/_0p1cb69sml__f._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_0agdmptetetdt._.js +0 -5
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_0mdwgjisv4fub._.js +0 -5
- package/.next/standalone/.next/static/chunks/107jrtkeylnrv.js +0 -6
- package/.next/standalone/.next/static/chunks/19e9khxgv8fb8.js +0 -1
- package/.next/standalone/.next/static/chunks/2codb6nb412m9.js +0 -1
- package/.next/standalone/.next/static/chunks/2maurwweshrsj.js +0 -1
- package/.next/standalone/.next/static/chunks/3v49ogp389dun.js +0 -1
- /package/.next/standalone/.next/static/{-iBiSmrLiylRKLAg77zlQ → _rnWxsoAWV0JPMURamq78}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{-iBiSmrLiylRKLAg77zlQ → _rnWxsoAWV0JPMURamq78}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{-iBiSmrLiylRKLAg77zlQ → _rnWxsoAWV0JPMURamq78}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The steps that finish an npm upgrade on this machine, shared by
|
|
3
|
+
* `failproofai update` and by `failproofai config`.
|
|
4
|
+
*
|
|
5
|
+
* `update` runs all of them. `config` runs them after a setup that applied,
|
|
6
|
+
* when this CLI version has not finished them here yet (`updatedVersionFile`):
|
|
7
|
+
* the first setup after `npm i -g failproofai` (or on a fresh machine) would
|
|
8
|
+
* otherwise leave a running Hermes or OpenClaw gateway on the plugin it loaded
|
|
9
|
+
* before, or with no plugin at all, until someone thought to run `update`.
|
|
10
|
+
* Setup has already brought the daemon to this version and the CLI entry has
|
|
11
|
+
* already migrated the home, so `config` skips those two.
|
|
12
|
+
*/
|
|
13
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
14
|
+
import { dirname } from "node:path";
|
|
15
|
+
import { updatedVersionFile } from "./fp-home";
|
|
16
|
+
import type { GatewayRestart } from "./gateway-restart";
|
|
17
|
+
|
|
18
|
+
export interface UpdateStepsOptions {
|
|
19
|
+
/** Migrate the home layout (`update`); `config` relies on the CLI entry's. */
|
|
20
|
+
layout: boolean;
|
|
21
|
+
/** Bring the daemon to this CLI's version (`update` without --no-daemon). */
|
|
22
|
+
daemon: boolean;
|
|
23
|
+
/** Restart running, service-managed Hermes and OpenClaw gateways. */
|
|
24
|
+
restart: boolean;
|
|
25
|
+
/** Say the daemon was skipped on purpose (`update --no-daemon`). */
|
|
26
|
+
noteSkippedDaemon?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface UpdateStepsResult {
|
|
30
|
+
/** Report lines, grouped by step with blank lines between. */
|
|
31
|
+
lines: string[];
|
|
32
|
+
ok: boolean;
|
|
33
|
+
/** True when the layout is NEWER than this CLI: nothing else ran. */
|
|
34
|
+
futureLayout?: { found: number; speaks: number };
|
|
35
|
+
migrationsRan: number;
|
|
36
|
+
migrationFailed: boolean;
|
|
37
|
+
hermesOk: boolean;
|
|
38
|
+
hermesMigrated: number;
|
|
39
|
+
/** Something a person should see: a migration, a daemon change, a restart. */
|
|
40
|
+
changed: boolean;
|
|
41
|
+
/** Every gateway restart attempted, Hermes and OpenClaw, in report order. */
|
|
42
|
+
restarts: GatewayRestart[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function runUpdateSteps(opts: UpdateStepsOptions): Promise<UpdateStepsResult> {
|
|
46
|
+
const lines: string[] = [];
|
|
47
|
+
let migrationsRan = 0;
|
|
48
|
+
let migrationFailed = false;
|
|
49
|
+
let changed = false;
|
|
50
|
+
|
|
51
|
+
if (opts.layout) {
|
|
52
|
+
const { detectLayout } = await import("./fp-config");
|
|
53
|
+
const { LAYOUT_VERSION } = await import("./fp-home");
|
|
54
|
+
const { runMigrations } = await import("./migrations");
|
|
55
|
+
const state = detectLayout();
|
|
56
|
+
if (state.kind === "future") {
|
|
57
|
+
return {
|
|
58
|
+
lines: [],
|
|
59
|
+
ok: false,
|
|
60
|
+
futureLayout: { found: state.found, speaks: LAYOUT_VERSION },
|
|
61
|
+
migrationsRan: 0,
|
|
62
|
+
migrationFailed: false,
|
|
63
|
+
hermesOk: true,
|
|
64
|
+
hermesMigrated: 0,
|
|
65
|
+
changed: false,
|
|
66
|
+
restarts: [],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (state.kind === "stale") {
|
|
70
|
+
const run = runMigrations(state.found);
|
|
71
|
+
migrationsRan = run.steps.length;
|
|
72
|
+
migrationFailed = Boolean(run.failed);
|
|
73
|
+
changed = changed || migrationsRan > 0;
|
|
74
|
+
for (const step of run.steps) {
|
|
75
|
+
lines.push(` ${step.ok ? "migrated" : "FAILED "} layout ${step.from} → ${step.to}`);
|
|
76
|
+
}
|
|
77
|
+
if (run.backedUp.length > 0) lines.push("", `Saved first: ${run.backedUp.join(", ")}`);
|
|
78
|
+
// Each failing half marks its own line (the daemon's lines arrive with
|
|
79
|
+
// their ✕ already): the report opens on whatever ran first, often a
|
|
80
|
+
// success, and printReport's guess would put the ✕ there.
|
|
81
|
+
if (run.failed) {
|
|
82
|
+
lines.push(
|
|
83
|
+
"",
|
|
84
|
+
`✕ Step ${run.failed.from} → ${run.failed.to} did not finish: ${run.failed.error}`,
|
|
85
|
+
` The home is still marked layout ${state.found} and will be retried.`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
lines.push(`Home is at layout ${LAYOUT_VERSION}; no migration was needed.`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// The daemon is refreshed even when a step failed, and deliberately: the
|
|
94
|
+
// binary and the layout are independent halves, and leaving a version-skewed
|
|
95
|
+
// daemon behind on top of a failed migration is strictly worse than fixing
|
|
96
|
+
// the half that can be fixed. The exit code still reports the failure.
|
|
97
|
+
let daemonOk = true;
|
|
98
|
+
const svc = await import("./daemon-service");
|
|
99
|
+
if (opts.noteSkippedDaemon) {
|
|
100
|
+
lines.push("", "Skipped the daemon (--no-daemon). Its version may not match this CLI.");
|
|
101
|
+
} else if (opts.daemon) {
|
|
102
|
+
if (!svc.isDaemonSupportedPlatform()) {
|
|
103
|
+
lines.push("", `failproofaid does not run on ${process.platform}; nothing to update.`);
|
|
104
|
+
} else {
|
|
105
|
+
// `refreshDaemonToCliVersion` answers "is there a service at all" itself,
|
|
106
|
+
// so there is no separate installed check to get out of step with it.
|
|
107
|
+
const result = await svc.refreshDaemonToCliVersion();
|
|
108
|
+
lines.push("", ...result.lines);
|
|
109
|
+
daemonOk = result.ok;
|
|
110
|
+
changed = changed || !result.lines.some((l) => /nothing to update/.test(l));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Hermes is migrated AFTER the daemon, and gated on what the daemon that is
|
|
115
|
+
// now running can do: the native plugin needs `policyEvaluation`, which
|
|
116
|
+
// ≤1.0.5 daemons lack, so when the swap above could not happen (a sudo
|
|
117
|
+
// system service with no sudo) the shell hooks stay and this fails loudly.
|
|
118
|
+
// Gateways are restarted only onto a daemon that is current AND running:
|
|
119
|
+
// "nothing to update" on a machine with no service, or an unsupported
|
|
120
|
+
// platform, is also `daemonOk`.
|
|
121
|
+
const restartsGateways =
|
|
122
|
+
opts.restart && daemonOk && svc.isDaemonSupportedPlatform() && svc.daemonServiceStatus() === "running";
|
|
123
|
+
let hermesOk = true;
|
|
124
|
+
let hermesMigrated = 0;
|
|
125
|
+
const restarts: GatewayRestart[] = [];
|
|
126
|
+
try {
|
|
127
|
+
const { runHermesUpdateMigration } = await import("./hermes-update");
|
|
128
|
+
const restart = await import("./gateway-restart");
|
|
129
|
+
const hermesResult = await runHermesUpdateMigration({
|
|
130
|
+
daemonSupportsPolicyEvaluation: () => svc.probeDaemonPolicyEvaluation(),
|
|
131
|
+
restartGateway: restartsGateways
|
|
132
|
+
? (p) => {
|
|
133
|
+
const r = restart.restartHermesGateway(p);
|
|
134
|
+
restarts.push(r);
|
|
135
|
+
return r;
|
|
136
|
+
}
|
|
137
|
+
: undefined,
|
|
138
|
+
});
|
|
139
|
+
if (hermesResult.lines.length > 0) {
|
|
140
|
+
// Its lines open on a "Hermes:" heading over one row per profile; on a
|
|
141
|
+
// failure the heading carries the ✕ and the rows say which profile.
|
|
142
|
+
const [heading, ...rest] = hermesResult.lines;
|
|
143
|
+
lines.push("", hermesResult.ok ? heading : `✕ ${heading}`, ...rest);
|
|
144
|
+
}
|
|
145
|
+
hermesOk = hermesResult.ok;
|
|
146
|
+
hermesMigrated = hermesResult.profiles.filter((p) => p.status === "migrated").length;
|
|
147
|
+
// "already current" with no gateway touched is not news.
|
|
148
|
+
changed =
|
|
149
|
+
changed || !hermesOk || hermesMigrated > 0 || mentionsGateway(hermesResult.lines);
|
|
150
|
+
} catch (err) {
|
|
151
|
+
lines.push("", `✕ Hermes migration failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
152
|
+
hermesOk = false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (restartsGateways) {
|
|
156
|
+
try {
|
|
157
|
+
const restart = await import("./gateway-restart");
|
|
158
|
+
const openclaw = restart.restartOpenClawGateways();
|
|
159
|
+
restarts.push(...openclaw);
|
|
160
|
+
const restartLines = restart.openclawRestartLines(openclaw);
|
|
161
|
+
if (restartLines.length > 0) {
|
|
162
|
+
lines.push("", ...restartLines);
|
|
163
|
+
changed = true;
|
|
164
|
+
}
|
|
165
|
+
} catch {
|
|
166
|
+
// Restarting is a convenience; the update itself already succeeded.
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
lines,
|
|
172
|
+
ok: daemonOk && !migrationFailed && hermesOk,
|
|
173
|
+
migrationsRan,
|
|
174
|
+
migrationFailed,
|
|
175
|
+
hermesOk,
|
|
176
|
+
hermesMigrated,
|
|
177
|
+
changed,
|
|
178
|
+
restarts,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* `config`'s whole report of these steps: one line, or nothing. Built from
|
|
184
|
+
* update's own row words ("gateway restarting", "restart the gateway"), so
|
|
185
|
+
* setup gains no new wording and no second report.
|
|
186
|
+
*/
|
|
187
|
+
export function setupGatewayLine(restarts: GatewayRestart[]): { ok: boolean; text: string } | null {
|
|
188
|
+
const named = (r: GatewayRestart) => `${r.host}/${r.profile}`;
|
|
189
|
+
const manual = restarts.filter((r) => r.status === "not-supervised" || r.status === "failed").map(named);
|
|
190
|
+
if (manual.length > 0) return { ok: false, text: `${manual.join(", ")}: restart the gateway` };
|
|
191
|
+
const restarting = restarts.filter((r) => r.status === "restarting").map(named);
|
|
192
|
+
if (restarting.length > 0) return { ok: true, text: `${restarting.join(", ")}: gateway restarting` };
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** A Hermes or OpenClaw profile whose gateway loads FailproofAI's plugin when it starts. */
|
|
197
|
+
export interface PluggedProfile {
|
|
198
|
+
host: "hermes" | "openclaw";
|
|
199
|
+
name: string;
|
|
200
|
+
home: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export async function pluggedProfiles(): Promise<PluggedProfile[]> {
|
|
204
|
+
const { hermesProfileHealth } = await import("./integrations");
|
|
205
|
+
const { openclawProfilesUsingFailproofai } = await import("./gateway-restart");
|
|
206
|
+
return [
|
|
207
|
+
...hermesProfileHealth()
|
|
208
|
+
.filter((p) => p.pluginInstalled && p.pluginEnabled && !p.pluginDisabled)
|
|
209
|
+
.map((p): PluggedProfile => ({ host: "hermes", name: p.name, home: p.home })),
|
|
210
|
+
...openclawProfilesUsingFailproofai().map((p): PluggedProfile => ({ host: "openclaw", ...p })),
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface NewlyPluggedDeps {
|
|
215
|
+
plugged?: () => Promise<PluggedProfile[]>;
|
|
216
|
+
daemonRunning?: () => Promise<boolean>;
|
|
217
|
+
restartHermes?: (p: { name: string; home: string }) => GatewayRestart;
|
|
218
|
+
restartOpenClaw?: (p: { name: string; home: string }) => GatewayRestart;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Restart the gateways of profiles this setup run plugged in, given
|
|
223
|
+
* `pluggedProfiles()` from before it. A profile created after the version's
|
|
224
|
+
* first setup gets the plugin on disk, but its gateway is already running and
|
|
225
|
+
* would go on without it, unchecked, until something restarted it.
|
|
226
|
+
*/
|
|
227
|
+
export async function restartNewlyPlugged(
|
|
228
|
+
before: PluggedProfile[],
|
|
229
|
+
deps: NewlyPluggedDeps = {},
|
|
230
|
+
): Promise<GatewayRestart[]> {
|
|
231
|
+
const key = (p: PluggedProfile) => `${p.host}/${p.name}`;
|
|
232
|
+
const had = new Set(before.map(key));
|
|
233
|
+
const fresh = (await (deps.plugged ?? pluggedProfiles)()).filter((p) => !had.has(key(p)));
|
|
234
|
+
if (fresh.length === 0) return [];
|
|
235
|
+
const daemonRunning =
|
|
236
|
+
deps.daemonRunning ??
|
|
237
|
+
(async () => {
|
|
238
|
+
const svc = await import("./daemon-service");
|
|
239
|
+
return svc.isDaemonSupportedPlatform() && svc.daemonServiceStatus() === "running";
|
|
240
|
+
});
|
|
241
|
+
if (!(await daemonRunning())) return [];
|
|
242
|
+
const restart = await import("./gateway-restart");
|
|
243
|
+
const hermes = deps.restartHermes ?? ((p) => restart.restartHermesGateway(p));
|
|
244
|
+
const openclaw = deps.restartOpenClaw ?? ((p) => restart.restartOpenClawGateway(p));
|
|
245
|
+
return fresh.map((p) => (p.host === "hermes" ? hermes(p) : openclaw(p)));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function mentionsGateway(lines: string[]): boolean {
|
|
249
|
+
return lines.some((l) => /gateway/.test(l));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** The CLI version whose upgrade steps last finished here, or null. */
|
|
253
|
+
export function readUpdatedVersion(home?: string): string | null {
|
|
254
|
+
try {
|
|
255
|
+
const v = readFileSync(updatedVersionFile(home), "utf8").trim();
|
|
256
|
+
return v.length > 0 ? v : null;
|
|
257
|
+
} catch {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Record that this version's upgrade steps finished. Best effort. */
|
|
263
|
+
export function markUpdated(version: string, home?: string): void {
|
|
264
|
+
try {
|
|
265
|
+
const file = updatedVersionFile(home);
|
|
266
|
+
if (!existsSync(dirname(file))) mkdirSync(dirname(file), { recursive: true, mode: 0o700 });
|
|
267
|
+
writeFileSync(file, `${version}\n`, { mode: 0o600 });
|
|
268
|
+
} catch {
|
|
269
|
+
// A missing marker only means the next setup runs these steps again.
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Whether `config` should run the upgrade steps after a setup that applied. */
|
|
274
|
+
export function setupNeedsUpdateSteps(version: string, home?: string): boolean {
|
|
275
|
+
return readUpdatedVersion(home) !== version;
|
|
276
|
+
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
module.exports=[16560,38441,e=>{"use strict";let t=["claude","codex","copilot","cursor","opencode","pi","hermes","openclaw","factory","devin","antigravity","goose"],r=["SessionStart","SessionEnd","UserPromptSubmit","PreToolUse","PermissionRequest","PermissionDenied","PostToolUse","PostToolUseFailure","Notification","SubagentStart","SubagentStop","TaskCreated","TaskCompleted","Stop","StopFailure","TeammateIdle","InstructionsLoaded","ConfigChange","CwdChanged","FileChanged","WorktreeCreate","WorktreeRemove","PreCompact","PostCompact","Elicitation","ElicitationResult","UserPromptExpansion","PostToolBatch","Setup"].filter(e=>"WorktreeCreate"!==e);e.s(["X",0,["PreToolUse","PostToolUse","PreInvocation","Stop"],"m",0,["user","project"],"H",0,{Bash:{CommandLine:"command",Cwd:"cwd"},Write:{Path:"file_path",Content:"content",TargetFile:"file_path",CodeContent:"content"},Edit:{Path:"file_path",Target:"old_string",Replacement:"new_string",TargetFile:"file_path"},Read:{Path:"file_path",TargetFile:"file_path",AbsolutePath:"file_path",File:"file_path"}},"I",0,{run_command:"Bash",write_to_file:"Write",write_file:"Write",read_file:"Read",view_file:"Read",edit_file:"Edit",replace_file_content:"Edit",list_dir:"LS",find_by_name:"Glob",grep_search:"Grep",read_url_content:"WebFetch",search_web:"WebSearch"},"J",0,r,"p",0,{session_start:"SessionStart",pre_tool_use:"PreToolUse",permission_request:"PermissionRequest",post_tool_use:"PostToolUse",user_prompt_submit:"UserPromptSubmit",stop:"Stop",subagent_start:"SubagentStart",pre_compact:"PreCompact",post_compact:"PostCompact",subagent_stop:"SubagentStop"},"W",0,["session_start","pre_tool_use","permission_request","post_tool_use","user_prompt_submit","stop","subagent_start","pre_compact","post_compact","subagent_stop"],"L",0,["user","project"],"j",0,{apply_patch:"Edit",write_stdin:"Bash"},"d",0,["SessionStart","SessionEnd","UserPromptSubmit","PreToolUse","PostToolUse","Stop","SubagentStop","PostToolUseFailure","ErrorOccurred","PreCompact","PermissionRequest","Notification"],"w",0,["user","project"],"U",0,{Read:{path:"file_path"},Write:{path:"file_path",file_text:"content"},Edit:{path:"file_path",old_str:"old_string",new_str:"new_string"}},"s",0,{bash:"Bash",powershell:"Bash",list_bash:"Bash",read_bash:"Bash",stop_bash:"Bash",write_bash:"Bash",list_powershell:"Bash",read_powershell:"Bash",stop_powershell:"Bash",write_powershell:"Bash",read:"Read",view:"Read",show_file:"Read",write:"Write",create:"Write",edit:"Edit",apply_patch:"Edit",str_replace_editor:"Edit",glob:"Glob",grep:"Grep",rg:"Grep",ls:"LS",web_fetch:"WebFetch"},"t",0,["sessionStart","sessionEnd","beforeSubmitPrompt","preToolUse","postToolUse","stop","subagentStop"],"Y",0,["user","project"],"D",0,{Shell:"Bash"},"E",0,["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","PermissionRequest","Stop","SessionEnd"],"c",0,["user","project"],"u",0,{exec:"Bash"},"n",0,["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","Notification","Stop","SubagentStop","PreCompact","SessionEnd"],"B",0,["user","project"],"r",0,{Execute:"Bash",Read:"Read",Edit:"Edit",Create:"Write",Grep:"Grep",Glob:"Glob",LS:"LS",FetchUrl:"WebFetch",WebSearch:"WebSearch",TodoWrite:"TodoWrite",Task:"Task"},"Z",0,"__failproofai_hook__","i",0,["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","SessionEnd"],"x",0,["user","project"],"M",0,{Read:{path:"file_path",source:"file_path"},Write:{path:"file_path"},Edit:{path:"file_path"},LS:{path:"file_path"}},"K",0,{shell:"Bash",write:"Write",edit:"Edit",view:"Read",read_image:"Read",glob:"Glob",grep:"Grep",tree:"LS",delegate:"Task",todo__todo_write:"TodoWrite"},"y",0,["pre_tool_call","post_tool_call","on_session_start","on_session_end","subagent_stop"],"N",0,["user"],"z",0,{Read:{path:"file_path"},Write:{path:"file_path"},Edit:{path:"file_path"}},"C",0,{terminal:"Bash",bash:"Bash",read_file:"Read",write_file:"Write",patch:"Edit",web_search:"WebSearch",web_extract:"WebFetch",search_files:"Grep",todo:"TodoWrite",todo_list:"TodoWrite",process_manage:"process",cronjob_manage:"cronjob"},"F",0,["user","project","local"],"_",0,t,"P",0,["before_tool_call","after_tool_call","before_agent_run","before_agent_finalize","session_start","session_end","subagent_ended","before_compaction"],"G",0,["user"],"v",0,{Read:{path:"file_path"},Write:{path:"file_path"},Edit:{path:"file_path"}},"e",0,{exec:"Bash",read:"Read",write:"Write",edit:"Edit",grep:"Grep",glob:"Glob",web_search:"WebSearch",web_fetch:"WebFetch"},"f",0,["tool.execute.before","tool.execute.after","session.created","session.deleted","session.idle","message.updated","permission.ask"],"O",0,["user","project"],"k",0,{Read:{filePath:"file_path"},Write:{filePath:"file_path"},Edit:{filePath:"file_path",oldString:"old_string",newString:"new_string",replaceAll:"replace_all"}},"A",0,{bash:"Bash",read:"Read",write:"Write",edit:"Edit",apply_patch:"Edit",glob:"Glob",grep:"Grep",list:"LS",webfetch:"WebFetch",websearch:"WebSearch",todowrite:"TodoWrite",todoread:"TodoRead"},"Q",0,["session_start","session_shutdown","input","tool_call","user_bash","tool_result","agent_end"],"R",0,["user","project"],"V",0,{Read:{path:"file_path"},Write:{path:"file_path"},Edit:{path:"file_path"}},"S",0,{bash:"Bash",read:"Read",write:"Write",edit:"Edit",glob:"Glob",grep:"Grep"}],38441);let i=/^agt_[0-9a-f]{16,32}$/,o=new Set(t);e.s(["i",0,function(e,t){return void 0===e||!!(!(!t||"object"!=typeof t||Array.isArray(t))&&Object.keys(t).every(e=>"integration"===e||"instanceId"===e)&&"string"==typeof t.integration&&o.has(t.integration)&&"string"==typeof t.instanceId&&i.test(t.instanceId))&&e.some(e=>e.integration===t.integration&&(void 0===e.instanceId||e.instanceId===t.instanceId))},"P",0,function(e,t){if(null==e)return;if(t<3||!Array.isArray(e)||e.length<1||e.length>32)throw Error("invalid agentTargets in cloud-managed active manifest");let r=new Set;return e.map(e=>{if(!e||"object"!=typeof e||Array.isArray(e)||Object.keys(e).some(e=>"integration"!==e&&"instanceId"!==e)||"string"!=typeof e.integration||!o.has(e.integration)||void 0!==e.instanceId&&("string"!=typeof e.instanceId||!i.test(e.instanceId)))throw Error("invalid agentTargets in cloud-managed active manifest");let t=`${e.integration}\0${e.instanceId??""}`;if(r.has(t))throw Error("duplicate agentTargets in cloud-managed active manifest");return r.add(t),{integration:e.integration,...void 0!==e.instanceId?{instanceId:e.instanceId}:{}}})}],16560)},16774,99891,98901,52306,e=>{"use strict";let t;var r=e.i(66680),i=e.i(2157),o=e.i(50227),a=e.i(24214),n=e.i(79857),s=e.i(16560);e.i(97348);let l=new Set(["destructive-deletion","production-infra-change","git-history-rewrite","push-to-protected-branch","commit-on-protected-branch","secret-exposure","credential-exfiltration","remote-code-execution","privilege-escalation","database-destruction","read-outside-workspace","agent-config-tampering","system-modification","env-secrets-dump","external-destructive-action","external-data-egress"]),c=new Set,d=e=>"string"==typeof e&&e.length>0;function f(e){let t={};("hard"===e.authority||"reviewable"===e.authority)&&(t.authority=e.authority);let r=e.reviewedBy;return Array.isArray(r)&&r.length>0&&r.every(d)&&(t.reviewedBy=[...r]),t}e.s(["_",0,c,"g",0,l,"i",0,f,"d",0,function(e,t=c,r){let i=e?.authority==="reviewable";if(!e||"hard"==(!0!==e.alwaysOn&&"reviewable"===e.authority&&Array.isArray(e.reviewedBy)&&e.reviewedBy.filter(e=>"string"==typeof e&&e.length>0).length>0?"reviewable":"hard")){var o;return i?{authority:"hard",downgraded:!0===(o=e).alwaysOn?"it is alwaysOn, and the self-protection guard is never reviewable":Array.isArray(o.reviewedBy)&&0!==o.reviewedBy.length?"reviewedBy is not a list of semantic policy names":"reviewedBy does not name any semantic policy"}:{authority:"hard"}}let a=e.reviewedBy;if(!a.every(d))return{authority:"hard",downgraded:"reviewedBy is not a list of semantic policy names"};let n=a.filter(e=>!t.has(e));return 0!==t.size||n.some(e=>r?.has(e))?n.length>0?{authority:"hard",downgraded:`reviewedBy names ${n.map(e=>(function(e,t,r){let i=JSON.stringify(e),o=r?.get(e);if(o)return`${i}, which packs ${o.join(" and ")} declare differently, so it is asked for neither`;if(t===l)return`${i}, which is not a semantic policy in this build`;let a=[...t].sort(),n=a.length>6?`${a.slice(0,6).join(", ")} and ${a.length-6} more`:a.join(", ");return`${i}, which is not among the Jev checks it is judged against (${n})`})(e,t,r)).join("; ")}`}:{authority:"reviewable",reviewedBy:[...new Set(a)]}:{authority:"hard"}}],99891);let p=[1,2,3],h=null;function u(){if(function(){try{let e=JSON.parse((0,i.readFileSync)((0,n.y)(),"utf8"));if(!e||"object"!=typeof e||Array.isArray(e))return!1;let t=e.mode;return!!t&&"object"==typeof t&&!Array.isArray(t)&&"oss"===t.kind}catch{return!1}}()){h=null;return}let e=(0,o.resolve)(process.env.FAILPROOFAI_CLOUD_POLICY_DIR??(0,n.I)(),"active.json"),t=function(e){try{let t=(0,i.statSync)(e,{bigint:!0});return`${t.dev}:${t.ino}:${t.mode}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`}catch(t){let e=t.code;if("ENOENT"===e||"ENOTDIR"===e)return null;throw t}}(e);if(null===t){h=null;return}if(h&&h.path===e&&h.version===t)return h.value;let r=JSON.parse((0,i.readFileSync)(e,"utf8"));return h={path:e,version:t,value:r},r}let m=/^cloud:[^/]+\/./,y=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/,g=/^(?:0|[1-9]\d*)$/;function b(e){if("string"!=typeof e)return null;let t=y.exec(e);return t?{major:Number(t[1]),minor:Number(t[2]),patch:Number(t[3]),prerelease:void 0===t[4]?[]:t[4].split(".").map(e=>g.test(e)?Number(e):e)}:null}let w=(e,t)=>e<t?-1:+(e>t),_=["always","protected_branch","in_git_repo","has_paths","paths_outside_project","system_or_root_paths"];function v(e){return"string"==typeof e&&_.includes(e)}e.s(["B",0,_,"M",0,v],98901);let $=[1],S=/^[a-f0-9]{64}$/,E=/^[A-Za-z0-9._-]{1,64}\/[A-Za-z0-9._-]{1,64}$/,A=/^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/,P=/^[0-9a-f]{7,40}$/,O=/^[A-Za-z0-9._-]{1,128}$/,j=/^[a-z][a-z0-9_]{0,31}$/,k=new Set(["exempt","user_asked"]),T=new Set(["shell","write","read","network","other"]),R=new Set(["string","number","boolean","string[]","pattern[]"]);function I(e,t,r,i){if("string"!=typeof r||0===r.length)throw Error(`${e} is missing ${t}`);if(r.length>i)throw Error(`${e} has a ${t} of ${r.length} characters, over the ${i}-character cap`);return r}function F(e,t,r){let i;if(!t||"object"!=typeof t||Array.isArray(t))throw Error(`${e} is not an object`);if(null!==r)i=r;else{if("string"!=typeof t.id||!j.test(t.id))throw Error(`${e} has an unsafe id ${JSON.stringify(t.id)}`);if(k.has(t.id))throw Error(`${e} uses the reserved probe id ${JSON.stringify(t.id)}`);i=t.id}let o=I(e,"instructions",t.instructions,600);if(void 0===t.criteria)return{id:i,instructions:o};if(!t.criteria||"object"!=typeof t.criteria||Array.isArray(t.criteria))throw Error(`${e} has criteria that is not an object`);let a=t.criteria;return{id:i,instructions:o,criteria:{true:I(e,"criteria.true",a.true,300),false:I(e,"criteria.false",a.false,300)}}}function W(){let e,t=process.env.FAILPROOFAI_PACK_DIR?(0,o.resolve)(process.env.FAILPROOFAI_PACK_DIR,"installed.json"):(0,n.v)();if(!(0,i.existsSync)(t))return{packs:[],errors:[]};try{e=JSON.parse((0,i.readFileSync)(t,"utf8"))}catch(e){return{packs:[],errors:[{id:null,reason:`unreadable pack manifest: ${C(e)}`}]}}if(!e||"object"!=typeof e)return{packs:[],errors:[{id:null,reason:"pack manifest is not an object"}]};let s=e;if(!$.includes(s.schemaVersion))return{packs:[],errors:[{id:null,reason:`unsupported pack manifest schema ${String(s.schemaVersion)} (supported: ${$.join(", ")})`}]};if(!Array.isArray(s.packs))return{packs:[],errors:[{id:null,reason:"pack manifest packs is not an array"}]};let l=process.env.FAILPROOFAI_PACK_DIR??(0,n.n)(),c=[],d=[],p=[],h=new Set;for(let e of s.packs){let t=e&&"object"==typeof e&&"string"==typeof e.id?e.id:null,n=[];try{let t=function(e,t,n){if(!t||"object"!=typeof t)throw Error("pack entry is not an object");let s=function(e){if("string"!=typeof e.id||!E.test(e.id))throw Error(`unsafe pack id ${JSON.stringify(e.id)}`);if("string"!=typeof e.version||!A.test(e.version))throw Error(`invalid version for pack ${e.id}`);if(void 0!==e.effect&&"enforce"!==e.effect&&"observe"!==e.effect)throw Error(`unknown effect ${JSON.stringify(e.effect)} for pack ${e.id}`);let t="string"==typeof e.commit&&P.test(e.commit.trim().toLowerCase())?e.commit.trim().toLowerCase():void 0;return{id:e.id,version:e.version,effect:e.effect??"enforce",...t?{commit:t}:{}}}(t);if("string"!=typeof t.source||0===t.source.length)throw Error(`pack ${t.id} has no source`);if("string"!=typeof t.sha256||!S.test(t.sha256))throw Error(`invalid SHA-256 for pack ${t.id}`);let l=s.effect,c=function(e,t,r=a.version){if(void 0===t)return{kind:"satisfied"};let i=function(e,t){let r=b(e),i=b(t);return r&&i?w(r.major,i.major)||w(r.minor,i.minor)||w(r.patch,i.patch)||function(e,t){if(0===e.length&&0===t.length)return 0;if(0===e.length)return 1;if(0===t.length)return -1;for(let r=0;r<Math.min(e.length,t.length);r++){let i=e[r],o=t[r];if(i===o)continue;let a="number"==typeof i,n="number"==typeof o;if(a!==n)return a?-1:1;if(a&&n)return w(i,o);return i<o?-1:1}return w(e.length,t.length)}(r.prerelease,i.prerelease):null}(r,t);return null===i?{kind:"unreadable",reason:`pack ${e} declares minCliVersion ${JSON.stringify(t)}, which is not a version this CLI can compare against its own (${r}) — the requirement was ignored`}:i<0?{kind:"too-old",reason:`pack ${e} needs failproofai ${String(t)} or newer and this is ${r} — run \`npm i -g "failproofai@>=${String(t)}" && failproofai update\``}:{kind:"satisfied",declared:t}}(s.id,t.minCliVersion);if("too-old"===c.kind)throw Error(c.reason);"unreadable"===c.kind&&n.push(c.reason);let d=function(e,t){if(!t||(0,o.isAbsolute)(t))throw Error(`unsafe managed policy path ${JSON.stringify(t)}`);let r=(0,o.resolve)(e,t),a=(0,o.relative)(e,r);if(a.startsWith("..")||(0,o.isAbsolute)(a))throw Error(`managed policy path escapes its root: ${JSON.stringify(t)}`);let n=(0,i.realpathSync)(e),s=(0,i.realpathSync)(r),l=(0,o.relative)(n,s);if(l.startsWith("..")||(0,o.isAbsolute)(l))throw Error(`managed policy symlink escapes its root: ${JSON.stringify(t)}`);return s}(e,t.entry),p=(0,r.createHash)("sha256").update((0,i.readFileSync)(d)).digest("hex");if(p!==t.sha256)throw Error(`pack ${t.id} failed integrity verification: expected ${t.sha256}, got ${p}`);if(!Array.isArray(t.policies))throw Error(`pack ${t.id} policies is not an array`);let h=t.policies.map((e,r)=>(function(e,t,r,i){let o=`${e} policy #${r}`;if(!t||"object"!=typeof t)throw Error(`${o} is not an object`);let a=t.name;if("string"!=typeof a||!O.test(a))throw Error(`${o} has an unsafe name ${JSON.stringify(a)}`);if("alwaysOn"in t)throw Error(`${o} declares alwaysOn, which packs may not set`);if("string"!=typeof t.description||0===t.description.length)throw Error(`${o} is missing a description`);if("string"!=typeof t.category||0===t.category.length)throw Error(`${o} is missing a category`);if("boolean"!=typeof t.defaultEnabled)throw Error(`${o} is missing defaultEnabled`);if(!t.match||"object"!=typeof t.match)throw Error(`${o} is missing a match`);let n=t.match;for(let e of["events","toolNames"]){let t=n[e];if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e||0===e.length)))throw Error(`${o} has a match.${e} that is not a list of names`)}let s=f(t),l=["authority","reviewedBy"].filter(e=>e in t&&!(e in s));if("params"in t){let e=function(e){if(!e||"object"!=typeof e||Array.isArray(e))return"params is not an object";for(let[t,r]of Object.entries(e)){if(0===t.length)return"params has an empty parameter name";if(!r||"object"!=typeof r||Array.isArray(r))return`params.${t} is not an object`;if("string"!=typeof r.type||!R.has(r.type))return`params.${t} has type ${JSON.stringify(r.type)}, which is not one of ${[...R].join(", ")}`;if("string"!=typeof r.description||0===r.description.length)return`params.${t} is missing a description`;if(!("default"in r))return`params.${t} is missing a default`}}(t.params);e&&(i?.push(`${o} declares a params schema that was dropped: ${e}`),l.push("params"))}return l.length>0?Object.fromEntries(Object.entries(t).filter(([e])=>!l.includes(e))):t})(t.id,e,r,n)),u=new Set;for(let e of h){if(u.has(e.name))throw Error(`pack ${t.id} declares ${e.name} twice`);u.add(e.name)}let m=null;if(void 0!==t.enabled){if(!Array.isArray(t.enabled)||t.enabled.some(e=>"string"!=typeof e))throw Error(`pack ${t.id} enabled is not an array of names`);m=t.enabled.filter(e=>u.has(e))}let y=null;if(void 0!==t.clis){if(!Array.isArray(t.clis)||t.clis.some(e=>"string"!=typeof e))throw Error(`pack ${t.id} clis is not an array of agent names`);y=t.clis}return{clis:y,id:s.id,version:s.version,source:t.source,path:d,sha256:t.sha256,effect:l,policies:h,semantic:function(e,t,r){if(void 0===t)return[];if(!Array.isArray(t))return r.push(`pack ${e} semantic is not an array, so none of it was loaded`),[];let i=[],o=new Set;for(let[a,n]of t.entries()){if(i.length>=24){r.push(`pack ${e} declares more than 24 semantic policies; the ${t.length-24} past that cap were dropped`);break}try{let t=function(e,t,r){let i=`${e} semantic policy #${r}`;if(!t||"object"!=typeof t||Array.isArray(t))throw Error(`${i} is not an object`);let o=t.name;if("string"!=typeof o||!O.test(o))throw Error(`${i} has an unsafe name ${JSON.stringify(o)}`);if("alwaysOn"in t)throw Error(`${i} declares alwaysOn, which packs may not set`);let a=I(`${e} semantic policy ${o}`,"title",t.title,120),n=`${e} semantic policy ${o}`;if(!Array.isArray(t.appliesTo)||0===t.appliesTo.length)throw Error(`${n} has no appliesTo tool classes`);let s=t.appliesTo.find(e=>"string"!=typeof e||!T.has(e));if(void 0!==s)throw Error(`${n} applies to ${JSON.stringify(s)}, which is not a tool class (${[...T].join(", ")})`);if("deny"!==t.mode&&"instruct"!==t.mode)throw Error(`${n} has mode ${JSON.stringify(t.mode)}, which must be "deny" or "instruct"`);if("boolean"!=typeof t.userCanOverride)throw Error(`${n} is missing userCanOverride, which has no default`);if(!Array.isArray(t.probes)||0===t.probes.length)throw Error(`${n} declares no probes`);if(t.probes.length>6)throw Error(`${n} declares ${t.probes.length} probes, over the cap of 6`);let l=t.probes.map((e,t)=>F(`${n} probe #${t}`,e,null)),c=new Set;for(let e of l){if(c.has(e.id))throw Error(`${n} declares probe ${e.id} twice`);c.add(e.id)}let d=void 0===t.exempt?void 0:F(`${n} exempt`,t.exempt,"exempt");if(void 0!==t.precondition&&!v(t.precondition))throw Error(`${n} names precondition ${JSON.stringify(t.precondition)}, which this build does not have (${_.join(", ")})`);let f=I(n,"guidance",t.guidance,600);return{name:o,title:a,appliesTo:t.appliesTo,mode:t.mode,userCanOverride:t.userCanOverride,probes:l,...d?{exempt:d}:{},...void 0!==t.precondition?{precondition:t.precondition}:{},guidance:f}}(e,n,a);if(o.has(t.name))throw Error(`pack ${e} declares semantic policy ${t.name} twice`);o.add(t.name),i.push(t)}catch(e){r.push(C(e))}}return i}(s.id,t.semantic,n),..."satisfied"===c.kind&&c.declared?{minCliVersion:c.declared}:{},enabled:m}}(l,e,n);if(h.has(t.id))throw Error(`duplicate pack id ${t.id}`);h.add(t.id),c.push(t),p.push(...n)}catch(i){let r=e&&("observe"===e.effect||"enforce"===e.effect)?e.effect:"enforce";d.push({id:t,reason:C(i),effect:r,...Array.isArray(e?.policies)?{declared:function(e){let t=[];for(let r of e)r&&"object"==typeof r&&"string"==typeof r.name&&r.match&&"object"==typeof r.match&&t.push(r);return t}(e.policies)}:{},...Array.isArray(e?.policies)&&0===e.policies.length?{semanticOnly:!0}:{},...Array.isArray(e?.clis)&&e.clis.every(e=>"string"==typeof e)?{clis:e.clis}:{}})}}return{packs:c,errors:d,...p.length>0?{warnings:p}:{}}}function C(e){return e instanceof Error?e.message:String(e)}e.s(["f",0,W],52306);let B=null,N=null;function L(e){let t=new Map,r=new Map;for(let i of e)for(let e of i.semantic??[]){if(U(i,e.name))continue;let o=function e(t){if(Array.isArray(t))return`[${t.map(e).join(",")}]`;if(null!==t&&"object"==typeof t){let r=Object.entries(t).filter(([,e])=>void 0!==e).sort(([e],[t])=>e<t?-1:+(e>t));return`{${r.map(([t,r])=>`${JSON.stringify(t)}:${e(r)}`).join(",")}}`}return JSON.stringify(t)??"null"}(e),a=t.get(e.name);if(void 0===a){t.set(e.name,{form:o,ids:[i.id]});continue}a.ids.push(i.id),a.form!==o&&r.set(e.name,a.ids)}return r}function U(e,t){return l.has(t)&&!/^github:FailproofAI\//i.test(e.source??"")}e.s(["j",0,function(){if(B)return B;let e=c;try{var r,i,o;let a,n,s=(r=W().packs,i=t,r.filter(e=>"observe"!==e.effect&&!(i&&Array.isArray(e.clis)&&e.clis.length>0&&!e.clis.includes(i))));(o=s,a=L(o),n=o.flatMap(e=>(e.semantic??[]).filter(t=>!U(e,t.name)).map(e=>e.name)).filter(e=>!a.has(e)),e=0===n.length?c:new Set(n)).size,L(s)}catch{}try{let t=function(e,t){let r=[];for(let i of e){let e=function(e,t){return"reviewable"!==e.authority?e.authority?{authority:e.authority}:{}:"observe"===e.effect||"observe"!==t&&"enforce"!==t?{authority:"hard"}:{authority:"reviewable",reviewedBy:(e.reviewedBy??[]).map(t=>{var r;return m.test(t)?t:(r=e.id,`cloud:${r}/${t}`)})}}(i,t);"reviewable"===e.authority&&r.push(...e.reviewedBy??[])}return r}(function(e=null){try{let t=u();if(void 0===t)return[];let r=function(e){if(!e||"object"!=typeof e)throw Error("active manifest is not an object");if(!p.includes(e.schemaVersion))throw Error(`unsupported active manifest schema ${String(e.schemaVersion)} (supported: ${p.join(", ")})`);let t=e.deployment??e.generation;if(!Number.isSafeInteger(t)||(t??-1)<0)throw Error("active manifest deployment is invalid");if(!Array.isArray(e.policies))throw Error("active manifest policies is not an array");let r=e.policies.map(e=>({...e,version:e.version??e.revision}));return{schemaVersion:e.schemaVersion,deployment:t,policies:r}}(t);return r.policies.flatMap(t=>{if("string"!=typeof t.id)return[];let i=(0,s.P)(t.agentTargets,r.schemaVersion);return(0,s.i)(i,e)?[{id:t.id,effect:"observe"===t.effect?"observe":"enforce",...i?{agentTargets:i}:{},...f(t)}]:[]})}catch{return[]}}(N),function(){try{var e;return e=function(){let e=u();if(void 0===e)return null;if(!e||"object"!=typeof e||Array.isArray(e))throw Error("active manifest is not an object");if(!p.includes(e.schemaVersion))throw Error(`unsupported active manifest schema ${String(e.schemaVersion)}`);return e}()?.jevMode,"off"===e||"observe"===e||"enforce"===e?e:null}catch{return null}}());t.length>0&&(e=new Set([...e,...t]))}catch{}return B=e,e},"Z",0,function(e,r=null){B=null,t=e,N=r}],16774)},97348,e=>{"use strict";var t=e.i(2157),r=e.i(50227),i=e.i(79857);let o={info:0,warn:1,error:2},a=(0,i.A)(),n=!1,s="warn",l=!1,c=a;function d(e){return!function(){if(n)return;n=!0;let e=(process.env.FAILPROOFAI_LOG_LEVEL??"").toLowerCase();("info"===e||"warn"===e||"error"===e)&&(s=e);let t=(process.env.FAILPROOFAI_HOOK_LOG_FILE??"").trim();t&&(l=!0,"1"!==t&&"true"!==t&&(c=t))}(),o[e]>=o[s]}function f(e,t){process.stderr.write(`[failproofai:hook] ${e} ${t}
|
|
2
|
-
`)}function p(e,i){if(l)try{(0,t.existsSync)(c)||(0,t.mkdirSync)(c,{recursive:!0});let o=(0,r.join)(c,"hooks.log");try{if((0,t.statSync)(o).size>=524288){let e=`hooks-${Date.now()}.log`;(0,t.renameSync)(o,(0,r.join)(c,e))}}catch{}let a=new Date().toISOString(),n=`[${a}] ${e} ${i}
|
|
3
|
-
`;(0,t.appendFileSync)(o,n,"utf-8")}catch{}}e.s(["F",0,function(e){d("error")&&(f("ERROR",e),p("ERROR",e))},"Q",0,function(e){d("info")&&(f("INFO",e),p("INFO",e))},"g",0,function(e){d("warn")&&(f("WARN",e),p("WARN",e))}])},73136,49335,e=>{"use strict";var t=e.i(2157),r=e.i(50227),i=e.i(60526),o=e.i(97348),a=e.i(79857);function n(e){if(!(0,t.existsSync)(e))return{};try{let r=(0,t.readFileSync)(e,"utf8");return JSON.parse(r)}catch(t){return(0,o.g)(`failed to parse config at ${e}: ${t instanceof Error?t.message:String(t)}`),{}}}e.s(["f",0,function(e){let o=function(e){let o=(0,i.homedir)(),a=(0,r.resolve)(e);for(;a!==o;){let e=(0,r.resolve)(a,".failproofai");try{if((0,t.statSync)(e).isDirectory())return a}catch{}let i=(0,r.dirname)(a);if(i===a)break;a=i}return(0,r.resolve)(e)}(e??process.cwd()),s=(0,r.resolve)(o,".failproofai","policies-config.json"),l=(0,r.resolve)(o,".failproofai","policies-config.local.json"),c=(0,a.O)(),d=n(s),f=n(l),p=n(c),h=new Set([...d.enabledPolicies??[],...f.enabledPolicies??[],...p.enabledPolicies??[]]),u={};for(let e of[d,f,p])if(e.policyParams)for(let[t,r]of Object.entries(e.policyParams))t in u||(u[t]=r);let m=[d,f,p].map(e=>void 0!==e.customPoliciesPaths?e.customPoliciesPaths:void 0!==e.customPoliciesPath?[e.customPoliciesPath]:void 0).find(e=>void 0!==e),y=new Set([...d.disabledCustomPolicies??[],...f.disabledCustomPolicies??[],...p.disabledCustomPolicies??[]]),g=d.customPoliciesEnabled??f.customPoliciesEnabled??p.customPoliciesEnabled,b=d.llm??f.llm??p.llm;return{enabledPolicies:[...h],...Object.keys(u).length>0?{policyParams:u}:{},...void 0!==m?{customPoliciesPaths:m}:{},...y.size?{disabledCustomPolicies:[...y]}:{},...void 0!==g?{customPoliciesEnabled:g}:{},...void 0!==b?{llm:b}:{}}}],73136);var s=e.i(24214),l=e.i(28067),c=e.i(17694);let d=l._,f=new Set;async function p(e,t,r){let i=JSON.stringify({api_key:process.env.FAILPROOFAI_POSTHOG_KEY??d,event:t,distinct_id:e,properties:{...r,$lib:"failproofai-hooks",failproofai_version:s.version,product:l.W}});try{await fetch(process.env.FAILPROOFAI_POSTHOG_HOST?`${process.env.FAILPROOFAI_POSTHOG_HOST}/capture/`:"https://us.i.posthog.com/capture/",{method:"POST",headers:{"Content-Type":"application/json"},body:i,signal:AbortSignal.timeout(5e3)})}catch{}}async function h(e,t,r){if(!(0,c.f)())return;let i=p(e,t,r);f.add(i),i.finally(()=>f.delete(i)),await i}e.s(["f",0,h],49335)}];
|
|
4
|
-
|
|
5
|
-
//# sourceMappingURL=src_hooks_0_em82s16zfym._.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
module.exports=[18622,(a,b,c)=>{b.exports=a.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},20635,(a,b,c)=>{b.exports=a.x("next/dist/server/app-render/action-async-storage.external.js",()=>require("next/dist/server/app-render/action-async-storage.external.js"))},24725,(a,b,c)=>{b.exports=a.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},43285,(a,b,c)=>{b.exports=a.x("next/dist/server/app-render/dynamic-access-async-storage.external.js",()=>require("next/dist/server/app-render/dynamic-access-async-storage.external.js"))},56704,(a,b,c)=>{b.exports=a.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(a,b,c)=>{b.exports=a.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},59043,(a,b,c)=>{b.exports=a.x("next/dist/server/runtime-reacts.external.js",()=>require("next/dist/server/runtime-reacts.external.js"))},10412,a=>{"use strict";var b=a.i(5050);let c=(0,b.createServerReference)("00f160f7e37d748cb0b50b0f1d93806541edb8f466",b.callServer,void 0,b.findSourceMapURL,"getTelemetryConfig");a.s(["f",0,c])},3171,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(10412),e=a.i(66036);a.s(["default",0,function({error:a,reset:f}){return(0,c.useEffect)(()=>{(0,d.f)().then(b=>{(0,e.$)(b),(0,e.L)("client_error",{error_message:a.message,error_name:a.name,error_digest:a.digest,boundary:"global"})}).catch(()=>{})},[a]),(0,b.jsx)("html",{children:(0,b.jsx)("body",{children:(0,b.jsx)("main",{style:{minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"#031035",color:"#f8fafc",fontFamily:"system-ui, sans-serif"},children:(0,b.jsxs)("div",{style:{textAlign:"center",padding:"2rem",border:"1px solid rgba(239,68,68,0.4)",borderRadius:"0.5rem",maxWidth:"500px"},children:[(0,b.jsx)("h2",{style:{color:"#ef4444",marginBottom:"0.5rem",fontSize:"1.25rem"},children:"Something went wrong"}),(0,b.jsx)("p",{style:{color:"#94a3b8",marginBottom:"1.5rem"},children:a.message||"An unexpected error occurred."}),(0,b.jsx)("button",{onClick:f,style:{padding:"0.5rem 1.25rem",background:"#3b82f6",color:"white",border:"none",borderRadius:"0.375rem",cursor:"pointer",fontSize:"0.875rem"},children:"Try again"})]})})})})}])},66036,a=>{"use strict";a.s(["L",0,function(a,b){},"$",0,function(a){}])},5050,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={callServer:function(){return f.callServer},createServerReference:function(){return h.createServerReference},findSourceMapURL:function(){return g.findSourceMapURL}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(20611),g=a.r(1722),h=a.r(38783)},42602,(a,b,c)=>{"use strict";b.exports=a.r(18622)},9270,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.AppRouterContext},36313,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.HooksClientContext},18341,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored.contexts.ServerInsertedHtml},82283,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored["react-ssr"].ReactDOM},87924,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored["react-ssr"].ReactJsxRuntime},38783,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored["react-ssr"].ReactServerDOMTurbopackClient},72131,(a,b,c)=>{"use strict";b.exports=a.r(42602).vendored["react-ssr"].React}];
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=%5Broot-of-the-server%5D__1xwr4hi-on27i._.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
module.exports=[10412,a=>{"use strict";var b=a.i(5050);let c=(0,b.createServerReference)("00f160f7e37d748cb0b50b0f1d93806541edb8f466",b.callServer,void 0,b.findSourceMapURL,"getTelemetryConfig");a.s(["f",0,c])},18952,a=>{"use strict";var b=a.i(87924),c=a.i(72131);let d=[],e=0,f=new Set;function g(){for(let a of f)a()}function h(a){return f.add(a),()=>f.delete(a)}function i(){return d}function j({message:a}){let[d,e]=(0,c.useState)(!1);return(0,c.useEffect)(()=>{requestAnimationFrame(()=>e(!0));let a=setTimeout(()=>e(!1),2e3);return()=>clearTimeout(a)},[]),(0,b.jsx)("div",{className:`bg-card border border-border text-foreground text-sm px-4 py-2 rounded-lg shadow-lg transition-opacity duration-300 ${d?"opacity-100":"opacity-0"}`,children:a})}a.s(["Toaster",0,function(){let a=(0,c.useSyncExternalStore)(h,i,i);return(0,b.jsx)("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:a.map(a=>(0,b.jsx)(j,{message:a.message},a.id))})},"toast",0,function(a){let b=e++;d=[...d,{id:b,message:a}],g(),setTimeout(()=>{d=d.filter(a=>a.id!==b),g()},2500)}])},10765,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(50944),e=a.i(10412),f=a.i(66036);let g=(0,c.createContext)(void 0);a.s(["PostHogProvider",0,function({children:a}){let h=(0,d.usePathname)(),i=(0,c.useRef)(null),j=(0,c.useRef)(!1);(0,c.useEffect)(()=>{let a=!1;return(0,e.f)().then(b=>{a||((0,f.$)(b),j.current=!0,(0,f.L)("$pageview"),i.current=window.location.pathname)}),()=>{a=!0}},[]),(0,c.useEffect)(()=>{j.current&&i.current!==h&&(i.current=h,(0,f.L)("$pageview"))},[h]);let k=c.default.useCallback((a,b)=>{(0,f.L)(a,b)},[]);return(0,b.jsx)(g.Provider,{value:{capture:k},children:a})},"usePostHog",0,function(){let a=(0,c.useContext)(g);if(void 0===a)throw Error("usePostHog must be used within a PostHogProvider");return a}])},66036,a=>{"use strict";a.s(["L",0,function(a,b){},"$",0,function(a){}])},5050,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={callServer:function(){return f.callServer},createServerReference:function(){return h.createServerReference},findSourceMapURL:function(){return g.findSourceMapURL}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(20611),g=a.r(1722),h=a.r(38783)}];
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=_0p1cb69sml__f._.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
module.exports=[86017,91997,a=>{"use strict";let b=["claude","codex","copilot","cursor","opencode","pi","hermes","openclaw","factory","devin","antigravity","goose"],c=["SessionStart","SessionEnd","UserPromptSubmit","PreToolUse","PermissionRequest","PermissionDenied","PostToolUse","PostToolUseFailure","Notification","SubagentStart","SubagentStop","TaskCreated","TaskCompleted","Stop","StopFailure","TeammateIdle","InstructionsLoaded","ConfigChange","CwdChanged","FileChanged","WorktreeCreate","WorktreeRemove","PreCompact","PostCompact","Elicitation","ElicitationResult","UserPromptExpansion","PostToolBatch","Setup"].filter(a=>"WorktreeCreate"!==a);a.s(["X",0,["PreToolUse","PostToolUse","PreInvocation","Stop"],"m",0,["user","project"],"I",0,c,"p",0,{session_start:"SessionStart",pre_tool_use:"PreToolUse",permission_request:"PermissionRequest",post_tool_use:"PostToolUse",user_prompt_submit:"UserPromptSubmit",stop:"Stop",subagent_start:"SubagentStart",pre_compact:"PreCompact",post_compact:"PostCompact",subagent_stop:"SubagentStop"},"W",0,["session_start","pre_tool_use","permission_request","post_tool_use","user_prompt_submit","stop","subagent_start","pre_compact","post_compact","subagent_stop"],"L",0,["user","project"],"d",0,["SessionStart","SessionEnd","UserPromptSubmit","PreToolUse","PostToolUse","Stop","SubagentStop","PostToolUseFailure","ErrorOccurred","PreCompact","PermissionRequest","Notification"],"w",0,["user","project"],"s",0,["sessionStart","sessionEnd","beforeSubmitPrompt","preToolUse","postToolUse","stop","subagentStop"],"Y",0,["user","project"],"D",0,["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","PermissionRequest","Stop","SessionEnd"],"c",0,["user","project"],"n",0,["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","Notification","Stop","SubagentStop","PreCompact","SessionEnd"],"B",0,["user","project"],"Z",0,"__failproofai_hook__","i",0,["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","SessionEnd"],"x",0,["user","project"],"y",0,["pre_tool_call","post_tool_call","on_session_start","on_session_end","subagent_stop"],"M",0,["user"],"F",0,["user","project","local"],"z",0,b,"P",0,["before_tool_call","after_tool_call","before_agent_run","before_agent_finalize","session_start","session_end","subagent_ended","before_compaction"],"E",0,["user"],"e",0,["tool.execute.before","tool.execute.after","session.created","session.deleted","session.idle","message.updated","permission.ask"],"O",0,["user","project"],"J",0,["session_start","session_shutdown","input","tool_call","user_bash","tool_result","agent_end"],"G",0,["user","project"]],91997);let d=/^agt_[0-9a-f]{16,32}$/,e=new Set(b);a.s(["f",0,function(a,b){if(null==a)return;if(b<3||!Array.isArray(a)||a.length<1||a.length>32)throw Error("invalid agentTargets in cloud-managed active manifest");let c=new Set;return a.map(a=>{if(!a||"object"!=typeof a||Array.isArray(a)||Object.keys(a).some(a=>"integration"!==a&&"instanceId"!==a)||"string"!=typeof a.integration||!e.has(a.integration)||void 0!==a.instanceId&&("string"!=typeof a.instanceId||!d.test(a.instanceId)))throw Error("invalid agentTargets in cloud-managed active manifest");let b=`${a.integration}\0${a.instanceId??""}`;if(c.has(b))throw Error("duplicate agentTargets in cloud-managed active manifest");return c.add(b),{integration:a.integration,...void 0!==a.instanceId?{instanceId:a.instanceId}:{}}})}],86017)},86304,91609,89790,68561,48630,9909,a=>{"use strict";var b=a.i(66680),c=a.i(2157),d=a.i(50227),e=a.i(12072),f=a.i(75818),g=a.i(86017);a.i(10695);let h=new Set(["destructive-deletion","production-infra-change","git-history-rewrite","push-to-protected-branch","commit-on-protected-branch","secret-exposure","credential-exfiltration","remote-code-execution","privilege-escalation","database-destruction","read-outside-workspace","agent-config-tampering","system-modification","env-secrets-dump","external-destructive-action","external-data-egress"]),i=new Set,j=a=>"string"==typeof a&&a.length>0;function k(a){let b={};("hard"===a.authority||"reviewable"===a.authority)&&(b.authority=a.authority);let c=a.reviewedBy;return Array.isArray(c)&&c.length>0&&c.every(j)&&(b.reviewedBy=[...c]),b}a.s(["g",0,h,"i",0,k,"d",0,function(a,b=i,c){let d=a?.authority==="reviewable";if(!a||"hard"==(!0!==a.alwaysOn&&"reviewable"===a.authority&&Array.isArray(a.reviewedBy)&&a.reviewedBy.filter(a=>"string"==typeof a&&a.length>0).length>0?"reviewable":"hard")){var e;return d?{authority:"hard",downgraded:!0===(e=a).alwaysOn?"it is alwaysOn, and the self-protection guard is never reviewable":Array.isArray(e.reviewedBy)&&0!==e.reviewedBy.length?"reviewedBy is not a list of semantic policy names":"reviewedBy does not name any semantic policy"}:{authority:"hard"}}let f=a.reviewedBy;if(!f.every(j))return{authority:"hard",downgraded:"reviewedBy is not a list of semantic policy names"};let g=f.filter(a=>!b.has(a));return 0!==b.size||g.some(a=>c?.has(a))?g.length>0?{authority:"hard",downgraded:`reviewedBy names ${g.map(a=>(function(a,b,c){let d=JSON.stringify(a),e=c?.get(a);if(e)return`${d}, which packs ${e.join(" and ")} declare differently, so it is asked for neither`;if(b===h)return`${d}, which is not a semantic policy in this build`;let f=[...b].sort(),g=f.length>6?`${f.slice(0,6).join(", ")} and ${f.length-6} more`:f.join(", ");return`${d}, which is not among the Jev checks it is judged against (${g})`})(a,b,c)).join("; ")}`}:{authority:"reviewable",reviewedBy:[...new Set(f)]}:{authority:"hard"}}],91609);let l=[1,2,3],m=/^[a-f0-9]{64}$/,n=/^[A-Za-z0-9._-]{1,128}$/;function o(){return process.env.FAILPROOFAI_CLOUD_POLICY_DIR??(0,f.I)()}function p(a,b){if(!b||(0,d.isAbsolute)(b))throw Error(`unsafe managed policy path ${JSON.stringify(b)}`);let e=(0,d.resolve)(a,b),f=(0,d.relative)(a,e);if(f.startsWith("..")||(0,d.isAbsolute)(f))throw Error(`managed policy path escapes its root: ${JSON.stringify(b)}`);let g=(0,c.realpathSync)(a),h=(0,c.realpathSync)(e),i=(0,d.relative)(g,h);if(i.startsWith("..")||(0,d.isAbsolute)(i))throw Error(`managed policy symlink escapes its root: ${JSON.stringify(b)}`);return h}let q=null;function r(){if(function(){try{let a=JSON.parse((0,c.readFileSync)((0,f.y)(),"utf8"));if(!a||"object"!=typeof a||Array.isArray(a))return!1;let b=a.mode;return!!b&&"object"==typeof b&&!Array.isArray(b)&&"oss"===b.kind}catch{return!1}}()){q=null;return}let a=(0,d.resolve)(o(),"active.json"),b=function(a){try{let b=(0,c.statSync)(a,{bigint:!0});return`${b.dev}:${b.ino}:${b.mode}:${b.size}:${b.mtimeNs}:${b.ctimeNs}`}catch(b){let a=b.code;if("ENOENT"===a||"ENOTDIR"===a)return null;throw b}}(a);if(null===b){q=null;return}if(q&&q.path===a&&q.version===b)return q.value;let e=JSON.parse((0,c.readFileSync)(a,"utf8"));return q={path:a,version:b,value:e},e}let s=/^cloud:[^/]+\/./;function t(a,b){return"reviewable"!==a.authority?a.authority?{authority:a.authority}:{}:"observe"===a.effect||"observe"!==b&&"enforce"!==b?{authority:"hard"}:{authority:"reviewable",reviewedBy:(a.reviewedBy??[]).map(b=>{var c;return s.test(b)?b:(c=a.id,`cloud:${c}/${b}`)})}}a.s(["i",0,t,"O",0,function(a,b){let c=[];for(let d of a){let a=t(d,b);"reviewable"===a.authority&&c.push(...a.reviewedBy??[])}return c},"h",0,function(){return function(a){let d,e=o();try{d=r()}catch(a){throw Error(`failed to read cloud-managed active manifest: ${a instanceof Error?a.message:String(a)}`)}if(void 0===d)return[];let f=function(a){if(!a||"object"!=typeof a)throw Error("active manifest is not an object");if(!l.includes(a.schemaVersion))throw Error(`unsupported active manifest schema ${String(a.schemaVersion)} (supported: ${l.join(", ")})`);let b=a.deployment??a.generation;if(!Number.isSafeInteger(b)||(b??-1)<0)throw Error("active manifest deployment is invalid");if(!Array.isArray(a.policies))throw Error("active manifest policies is not an array");let c=a.policies.map(a=>({...a,version:a.version??a.revision}));return{schemaVersion:a.schemaVersion,deployment:b,policies:c}}(d),h=f.policies.filter(b=>a((0,g.f)(b.agentTargets,f.schemaVersion))),i=new Set;return h.map(a=>{if(!n.test(a.id)||"."===a.id||".."===a.id)throw Error(`unsafe cloud-managed policy id ${JSON.stringify(a.id)}`);if(!Number.isSafeInteger(a.version)||a.version<0)throw Error(`invalid version for cloud-managed policy ${a.id}`);if(!m.test(a.sha256))throw Error(`invalid SHA-256 for cloud-managed policy ${a.id}`);if(i.has(a.id))throw Error(`duplicate cloud-managed policy id ${a.id}`);i.add(a.id);let d=p(e,a.path),h=(0,c.readFileSync)(d),j=(0,b.createHash)("sha256").update(h).digest("hex");if(j!==a.sha256)throw Error(`cloud-managed policy ${a.id} failed integrity verification: expected ${a.sha256}, got ${j}`);if(void 0!==a.effect&&"enforce"!==a.effect&&"observe"!==a.effect)throw Error(`unknown effect ${JSON.stringify(a.effect)} for cloud-managed policy ${a.id}`);return{id:a.id,version:a.version,effect:a.effect??"enforce",sha256:a.sha256,path:d,deployment:f.deployment,...(0,g.f)(a.agentTargets,f.schemaVersion)?{agentTargets:(0,g.f)(a.agentTargets,f.schemaVersion)}:{},...k(a)}})}(()=>!0)},"D",0,function(){try{var a;return a=function(){let a=r();if(void 0===a)return null;if(!a||"object"!=typeof a||Array.isArray(a))throw Error("active manifest is not an object");if(!l.includes(a.schemaVersion))throw Error(`unsupported active manifest schema ${String(a.schemaVersion)}`);return a}()?.jevMode,"off"===a||"observe"===a||"enforce"===a?a:null}catch{return null}},"t",0,p],89790);let u=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/,v=/^(?:0|[1-9]\d*)$/;function w(a){if("string"!=typeof a)return null;let b=u.exec(a);return b?{major:Number(b[1]),minor:Number(b[2]),patch:Number(b[3]),prerelease:void 0===b[4]?[]:b[4].split(".").map(a=>v.test(a)?Number(a):a)}:null}let x=(a,b)=>a<b?-1:+(a>b);function y(a,b){let c=w(a),d=w(b);return c&&d?x(c.major,d.major)||x(c.minor,d.minor)||x(c.patch,d.patch)||function(a,b){if(0===a.length&&0===b.length)return 0;if(0===a.length)return 1;if(0===b.length)return -1;for(let c=0;c<Math.min(a.length,b.length);c++){let d=a[c],e=b[c];if(d===e)continue;let f="number"==typeof d,g="number"==typeof e;if(f!==g)return f?-1:1;if(f&&g)return x(d,e);return d<e?-1:1}return x(a.length,b.length)}(c.prerelease,d.prerelease):null}a.s(["f",0,y],68561);let z=["always","protected_branch","in_git_repo","has_paths","paths_outside_project","system_or_root_paths"];function A(a){return"string"==typeof a&&z.includes(a)}a.s(["B",0,z,"M",0,A],48630);let B=[1],C=/^[a-f0-9]{64}$/,D=/^[A-Za-z0-9._-]{1,64}\/[A-Za-z0-9._-]{1,64}$/,E=/^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/,F=/^[0-9a-f]{7,40}$/,G=/^[A-Za-z0-9._-]{1,128}$/,H=/^[a-z][a-z0-9_]{0,31}$/,I=new Set(["exempt","user_asked"]),J=new Set(["shell","write","read","network","other"]);function K(){return process.env.FAILPROOFAI_PACK_DIR??(0,f.n)()}function L(a){if("string"!=typeof a.id||!D.test(a.id))throw Error(`unsafe pack id ${JSON.stringify(a.id)}`);if("string"!=typeof a.version||!E.test(a.version))throw Error(`invalid version for pack ${a.id}`);if(void 0!==a.effect&&"enforce"!==a.effect&&"observe"!==a.effect)throw Error(`unknown effect ${JSON.stringify(a.effect)} for pack ${a.id}`);let b="string"==typeof a.commit&&F.test(a.commit.trim().toLowerCase())?a.commit.trim().toLowerCase():void 0;return{id:a.id,version:a.version,effect:a.effect??"enforce",...b?{commit:b}:{}}}function M(){return process.env.FAILPROOFAI_PACK_DIR?(0,d.resolve)(process.env.FAILPROOFAI_PACK_DIR,"installed.json"):(0,f.v)()}let N=new Set(["string","number","boolean","string[]","pattern[]"]);function O(a,b,c,d){let e=`${a} policy #${c}`;if(!b||"object"!=typeof b)throw Error(`${e} is not an object`);let f=b.name;if("string"!=typeof f||!G.test(f))throw Error(`${e} has an unsafe name ${JSON.stringify(f)}`);if("alwaysOn"in b)throw Error(`${e} declares alwaysOn, which packs may not set`);if("string"!=typeof b.description||0===b.description.length)throw Error(`${e} is missing a description`);if("string"!=typeof b.category||0===b.category.length)throw Error(`${e} is missing a category`);if("boolean"!=typeof b.defaultEnabled)throw Error(`${e} is missing defaultEnabled`);if(!b.match||"object"!=typeof b.match)throw Error(`${e} is missing a match`);let g=b.match;for(let a of["events","toolNames"]){let b=g[a];if(void 0!==b&&(!Array.isArray(b)||b.some(a=>"string"!=typeof a||0===a.length)))throw Error(`${e} has a match.${a} that is not a list of names`)}let h=k(b),i=["authority","reviewedBy"].filter(a=>a in b&&!(a in h));if("params"in b){let a=function(a){if(!a||"object"!=typeof a||Array.isArray(a))return"params is not an object";for(let[b,c]of Object.entries(a)){if(0===b.length)return"params has an empty parameter name";if(!c||"object"!=typeof c||Array.isArray(c))return`params.${b} is not an object`;if("string"!=typeof c.type||!N.has(c.type))return`params.${b} has type ${JSON.stringify(c.type)}, which is not one of ${[...N].join(", ")}`;if("string"!=typeof c.description||0===c.description.length)return`params.${b} is missing a description`;if(!("default"in c))return`params.${b} is missing a default`}}(b.params);a&&(d?.push(`${e} declares a params schema that was dropped: ${a}`),i.push("params"))}return i.length>0?Object.fromEntries(Object.entries(b).filter(([a])=>!i.includes(a))):b}function P(a,b,c=e.version){if(void 0===b)return{kind:"satisfied"};let d=y(c,b);return null===d?{kind:"unreadable",reason:`pack ${a} declares minCliVersion ${JSON.stringify(b)}, which is not a version this CLI can compare against its own (${c}) — the requirement was ignored`}:d<0?{kind:"too-old",reason:`pack ${a} needs failproofai ${String(b)} or newer and this is ${c} — run \`npm i -g "failproofai@>=${String(b)}" && failproofai update\``}:{kind:"satisfied",declared:b}}function Q(a,b,c,d){if("string"!=typeof c||0===c.length)throw Error(`${a} is missing ${b}`);if(c.length>d)throw Error(`${a} has a ${b} of ${c.length} characters, over the ${d}-character cap`);return c}function R(a,b,c){let d;if(!b||"object"!=typeof b||Array.isArray(b))throw Error(`${a} is not an object`);if(null!==c)d=c;else{if("string"!=typeof b.id||!H.test(b.id))throw Error(`${a} has an unsafe id ${JSON.stringify(b.id)}`);if(I.has(b.id))throw Error(`${a} uses the reserved probe id ${JSON.stringify(b.id)}`);d=b.id}let e=Q(a,"instructions",b.instructions,600);if(void 0===b.criteria)return{id:d,instructions:e};if(!b.criteria||"object"!=typeof b.criteria||Array.isArray(b.criteria))throw Error(`${a} has criteria that is not an object`);let f=b.criteria;return{id:d,instructions:e,criteria:{true:Q(a,"criteria.true",f.true,300),false:Q(a,"criteria.false",f.false,300)}}}function S(a,b,c){let d=`${a} semantic policy #${c}`;if(!b||"object"!=typeof b||Array.isArray(b))throw Error(`${d} is not an object`);let e=b.name;if("string"!=typeof e||!G.test(e))throw Error(`${d} has an unsafe name ${JSON.stringify(e)}`);if("alwaysOn"in b)throw Error(`${d} declares alwaysOn, which packs may not set`);let f=Q(`${a} semantic policy ${e}`,"title",b.title,120),g=`${a} semantic policy ${e}`;if(!Array.isArray(b.appliesTo)||0===b.appliesTo.length)throw Error(`${g} has no appliesTo tool classes`);let h=b.appliesTo.find(a=>"string"!=typeof a||!J.has(a));if(void 0!==h)throw Error(`${g} applies to ${JSON.stringify(h)}, which is not a tool class (${[...J].join(", ")})`);if("deny"!==b.mode&&"instruct"!==b.mode)throw Error(`${g} has mode ${JSON.stringify(b.mode)}, which must be "deny" or "instruct"`);if("boolean"!=typeof b.userCanOverride)throw Error(`${g} is missing userCanOverride, which has no default`);if(!Array.isArray(b.probes)||0===b.probes.length)throw Error(`${g} declares no probes`);if(b.probes.length>6)throw Error(`${g} declares ${b.probes.length} probes, over the cap of 6`);let i=b.probes.map((a,b)=>R(`${g} probe #${b}`,a,null)),j=new Set;for(let a of i){if(j.has(a.id))throw Error(`${g} declares probe ${a.id} twice`);j.add(a.id)}let k=void 0===b.exempt?void 0:R(`${g} exempt`,b.exempt,"exempt");if(void 0!==b.precondition&&!A(b.precondition))throw Error(`${g} names precondition ${JSON.stringify(b.precondition)}, which this build does not have (${z.join(", ")})`);let l=Q(g,"guidance",b.guidance,600);return{name:e,title:f,appliesTo:b.appliesTo,mode:b.mode,userCanOverride:b.userCanOverride,probes:i,...k?{exempt:k}:{},...void 0!==b.precondition?{precondition:b.precondition}:{},guidance:l}}function T(a){return a instanceof Error?a.message:String(a)}function U(a){return/^github:FailproofAI\//i.test(a.source??"")}function V(a,b){return h.has(b)&&!U(a)}a.s(["P",0,24,"r",0,F,"T",0,P,"Q",0,function(){try{let a=JSON.parse((0,c.readFileSync)(M(),"utf8"));if(!Array.isArray(a.packs))return!1;return a.packs.some(a=>!!a&&"object"==typeof a&&Array.isArray(a.policies)&&a.policies.length>0)}catch{return!1}},"E",0,function(a){return a.semantic??[]},"N",0,K,"$",0,L,"Z",0,O,"U",0,S,"V",0,function(){let a,d=M();if(!(0,c.existsSync)(d))return{packs:[],errors:[]};try{a=JSON.parse((0,c.readFileSync)(d,"utf8"))}catch(a){return{packs:[],errors:[{id:null,reason:`unreadable pack manifest: ${T(a)}`}]}}if(!a||"object"!=typeof a)return{packs:[],errors:[{id:null,reason:"pack manifest is not an object"}]};let e=a;if(!B.includes(e.schemaVersion))return{packs:[],errors:[{id:null,reason:`unsupported pack manifest schema ${String(e.schemaVersion)} (supported: ${B.join(", ")})`}]};if(!Array.isArray(e.packs))return{packs:[],errors:[{id:null,reason:"pack manifest packs is not an array"}]};let f=K(),g=[],h=[],i=[],j=new Set;for(let a of e.packs){let d=a&&"object"==typeof a&&"string"==typeof a.id?a.id:null,e=[];try{let d=function(a,d,e){if(!d||"object"!=typeof d)throw Error("pack entry is not an object");let f=L(d);if("string"!=typeof d.source||0===d.source.length)throw Error(`pack ${d.id} has no source`);if("string"!=typeof d.sha256||!C.test(d.sha256))throw Error(`invalid SHA-256 for pack ${d.id}`);let g=f.effect,h=P(f.id,d.minCliVersion);if("too-old"===h.kind)throw Error(h.reason);"unreadable"===h.kind&&e.push(h.reason);let i=p(a,d.entry),j=(0,b.createHash)("sha256").update((0,c.readFileSync)(i)).digest("hex");if(j!==d.sha256)throw Error(`pack ${d.id} failed integrity verification: expected ${d.sha256}, got ${j}`);if(!Array.isArray(d.policies))throw Error(`pack ${d.id} policies is not an array`);let k=d.policies.map((a,b)=>O(d.id,a,b,e)),l=new Set;for(let a of k){if(l.has(a.name))throw Error(`pack ${d.id} declares ${a.name} twice`);l.add(a.name)}let m=null;if(void 0!==d.enabled){if(!Array.isArray(d.enabled)||d.enabled.some(a=>"string"!=typeof a))throw Error(`pack ${d.id} enabled is not an array of names`);m=d.enabled.filter(a=>l.has(a))}let n=null;if(void 0!==d.clis){if(!Array.isArray(d.clis)||d.clis.some(a=>"string"!=typeof a))throw Error(`pack ${d.id} clis is not an array of agent names`);n=d.clis}return{clis:n,id:f.id,version:f.version,source:d.source,path:i,sha256:d.sha256,effect:g,policies:k,semantic:function(a,b,c){if(void 0===b)return[];if(!Array.isArray(b))return c.push(`pack ${a} semantic is not an array, so none of it was loaded`),[];let d=[],e=new Set;for(let[f,g]of b.entries()){if(d.length>=24){c.push(`pack ${a} declares more than 24 semantic policies; the ${b.length-24} past that cap were dropped`);break}try{let b=S(a,g,f);if(e.has(b.name))throw Error(`pack ${a} declares semantic policy ${b.name} twice`);e.add(b.name),d.push(b)}catch(a){c.push(T(a))}}return d}(f.id,d.semantic,e),..."satisfied"===h.kind&&h.declared?{minCliVersion:h.declared}:{},enabled:m}}(f,a,e);if(j.has(d.id))throw Error(`duplicate pack id ${d.id}`);j.add(d.id),g.push(d),i.push(...e)}catch(c){let b=a&&("observe"===a.effect||"enforce"===a.effect)?a.effect:"enforce";h.push({id:d,reason:T(c),effect:b,...Array.isArray(a?.policies)?{declared:function(a){let b=[];for(let c of a)c&&"object"==typeof c&&"string"==typeof c.name&&c.match&&"object"==typeof c.match&&b.push(c);return b}(a.policies)}:{},...Array.isArray(a?.policies)&&0===a.policies.length?{semanticOnly:!0}:{},...Array.isArray(a?.clis)&&a.clis.every(a=>"string"==typeof a)?{clis:a.clis}:{}})}}return{packs:g,errors:h,...i.length>0?{warnings:i}:{}}},"M",0,function(a){return a.exempt?[...a.probes,a.exempt]:a.probes}],9909),a.s(["v",0,function(a){let b=new Map,c=new Map;for(let d of a)for(let a of d.semantic??[]){if(V(d,a.name))continue;let e=function a(b){if(Array.isArray(b))return`[${b.map(a).join(",")}]`;if(null!==b&&"object"==typeof b){let c=Object.entries(b).filter(([,a])=>void 0!==a).sort(([a],[b])=>a<b?-1:+(a>b));return`{${c.map(([b,c])=>`${JSON.stringify(b)}:${a(c)}`).join(",")}}`}return JSON.stringify(b)??"null"}(a),f=b.get(a.name);if(void 0===f){b.set(a.name,{form:e,ids:[d.id]});continue}f.ids.push(d.id),f.form!==e&&c.set(a.name,f.ids)}return c},"g",0,U,"B",0,V,"r",0,function(a,b){return a.filter(a=>"observe"!==a.effect&&!(b&&Array.isArray(a.clis)&&a.clis.length>0&&!a.clis.includes(b)))}],86304)},10695,a=>{"use strict";var b=a.i(2157),c=a.i(50227),d=a.i(75818);let e={info:0,warn:1,error:2},f=(0,d.A)(),g=!1,h="warn",i=!1,j=f;function k(a){return!function(){if(g)return;g=!0;let a=(process.env.FAILPROOFAI_LOG_LEVEL??"").toLowerCase();("info"===a||"warn"===a||"error"===a)&&(h=a);let b=(process.env.FAILPROOFAI_HOOK_LOG_FILE??"").trim();b&&(i=!0,"1"!==b&&"true"!==b&&(j=b))}(),e[a]>=e[h]}function l(a,b){process.stderr.write(`[failproofai:hook] ${a} ${b}
|
|
2
|
-
`)}function m(a,d){if(i)try{(0,b.existsSync)(j)||(0,b.mkdirSync)(j,{recursive:!0});let e=(0,c.join)(j,"hooks.log");try{if((0,b.statSync)(e).size>=524288){let a=`hooks-${Date.now()}.log`;(0,b.renameSync)(e,(0,c.join)(j,a))}}catch{}let f=new Date().toISOString(),g=`[${f}] ${a} ${d}
|
|
3
|
-
`;(0,b.appendFileSync)(e,g,"utf-8")}catch{}}a.s(["F",0,function(a){k("error")&&(l("ERROR",a),m("ERROR",a))},"g",0,function(a){k("warn")&&(l("WARN",a),m("WARN",a))}])}];
|
|
4
|
-
|
|
5
|
-
//# sourceMappingURL=src_hooks_0agdmptetetdt._.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
module.exports=[86017,91997,a=>{"use strict";let b=["claude","codex","copilot","cursor","opencode","pi","hermes","openclaw","factory","devin","antigravity","goose"],c=["SessionStart","SessionEnd","UserPromptSubmit","PreToolUse","PermissionRequest","PermissionDenied","PostToolUse","PostToolUseFailure","Notification","SubagentStart","SubagentStop","TaskCreated","TaskCompleted","Stop","StopFailure","TeammateIdle","InstructionsLoaded","ConfigChange","CwdChanged","FileChanged","WorktreeCreate","WorktreeRemove","PreCompact","PostCompact","Elicitation","ElicitationResult","UserPromptExpansion","PostToolBatch","Setup"].filter(a=>"WorktreeCreate"!==a);a.s(["X",0,["PreToolUse","PostToolUse","PreInvocation","Stop"],"m",0,["user","project"],"I",0,c,"p",0,{session_start:"SessionStart",pre_tool_use:"PreToolUse",permission_request:"PermissionRequest",post_tool_use:"PostToolUse",user_prompt_submit:"UserPromptSubmit",stop:"Stop",subagent_start:"SubagentStart",pre_compact:"PreCompact",post_compact:"PostCompact",subagent_stop:"SubagentStop"},"W",0,["session_start","pre_tool_use","permission_request","post_tool_use","user_prompt_submit","stop","subagent_start","pre_compact","post_compact","subagent_stop"],"L",0,["user","project"],"d",0,["SessionStart","SessionEnd","UserPromptSubmit","PreToolUse","PostToolUse","Stop","SubagentStop","PostToolUseFailure","ErrorOccurred","PreCompact","PermissionRequest","Notification"],"w",0,["user","project"],"s",0,["sessionStart","sessionEnd","beforeSubmitPrompt","preToolUse","postToolUse","stop","subagentStop"],"Y",0,["user","project"],"D",0,["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","PermissionRequest","Stop","SessionEnd"],"c",0,["user","project"],"n",0,["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","Notification","Stop","SubagentStop","PreCompact","SessionEnd"],"B",0,["user","project"],"Z",0,"__failproofai_hook__","i",0,["SessionStart","UserPromptSubmit","PreToolUse","PostToolUse","SessionEnd"],"x",0,["user","project"],"y",0,["pre_tool_call","post_tool_call","on_session_start","on_session_end","subagent_stop"],"M",0,["user"],"F",0,["user","project","local"],"z",0,b,"P",0,["before_tool_call","after_tool_call","before_agent_run","before_agent_finalize","session_start","session_end","subagent_ended","before_compaction"],"E",0,["user"],"e",0,["tool.execute.before","tool.execute.after","session.created","session.deleted","session.idle","message.updated","permission.ask"],"O",0,["user","project"],"J",0,["session_start","session_shutdown","input","tool_call","user_bash","tool_result","agent_end"],"G",0,["user","project"]],91997);let d=/^agt_[0-9a-f]{16,32}$/,e=new Set(b);a.s(["f",0,function(a,b){if(null==a)return;if(b<3||!Array.isArray(a)||a.length<1||a.length>32)throw Error("invalid agentTargets in cloud-managed active manifest");let c=new Set;return a.map(a=>{if(!a||"object"!=typeof a||Array.isArray(a)||Object.keys(a).some(a=>"integration"!==a&&"instanceId"!==a)||"string"!=typeof a.integration||!e.has(a.integration)||void 0!==a.instanceId&&("string"!=typeof a.instanceId||!d.test(a.instanceId)))throw Error("invalid agentTargets in cloud-managed active manifest");let b=`${a.integration}\0${a.instanceId??""}`;if(c.has(b))throw Error("duplicate agentTargets in cloud-managed active manifest");return c.add(b),{integration:a.integration,...void 0!==a.instanceId?{instanceId:a.instanceId}:{}}})}],86017)},86304,91609,89790,68561,48630,9909,a=>{"use strict";var b=a.i(66680),c=a.i(2157),d=a.i(50227),e=a.i(12072),f=a.i(75818),g=a.i(86017);a.i(10695);let h=new Set(["destructive-deletion","production-infra-change","git-history-rewrite","push-to-protected-branch","commit-on-protected-branch","secret-exposure","credential-exfiltration","remote-code-execution","privilege-escalation","database-destruction","read-outside-workspace","agent-config-tampering","system-modification","env-secrets-dump","external-destructive-action","external-data-egress"]),i=new Set,j=a=>"string"==typeof a&&a.length>0;function k(a){let b={};("hard"===a.authority||"reviewable"===a.authority)&&(b.authority=a.authority);let c=a.reviewedBy;return Array.isArray(c)&&c.length>0&&c.every(j)&&(b.reviewedBy=[...c]),b}a.s(["g",0,h,"i",0,k,"d",0,function(a,b=i,c){let d=a?.authority==="reviewable";if(!a||"hard"==(!0!==a.alwaysOn&&"reviewable"===a.authority&&Array.isArray(a.reviewedBy)&&a.reviewedBy.filter(a=>"string"==typeof a&&a.length>0).length>0?"reviewable":"hard")){var e;return d?{authority:"hard",downgraded:!0===(e=a).alwaysOn?"it is alwaysOn, and the self-protection guard is never reviewable":Array.isArray(e.reviewedBy)&&0!==e.reviewedBy.length?"reviewedBy is not a list of semantic policy names":"reviewedBy does not name any semantic policy"}:{authority:"hard"}}let f=a.reviewedBy;if(!f.every(j))return{authority:"hard",downgraded:"reviewedBy is not a list of semantic policy names"};let g=f.filter(a=>!b.has(a));return 0!==b.size||g.some(a=>c?.has(a))?g.length>0?{authority:"hard",downgraded:`reviewedBy names ${g.map(a=>(function(a,b,c){let d=JSON.stringify(a),e=c?.get(a);if(e)return`${d}, which packs ${e.join(" and ")} declare differently, so it is asked for neither`;if(b===h)return`${d}, which is not a semantic policy in this build`;let f=[...b].sort(),g=f.length>6?`${f.slice(0,6).join(", ")} and ${f.length-6} more`:f.join(", ");return`${d}, which is not among the Jev checks it is judged against (${g})`})(a,b,c)).join("; ")}`}:{authority:"reviewable",reviewedBy:[...new Set(f)]}:{authority:"hard"}}],91609);let l=[1,2,3],m=/^[a-f0-9]{64}$/,n=/^[A-Za-z0-9._-]{1,128}$/;function o(){return process.env.FAILPROOFAI_CLOUD_POLICY_DIR??(0,f.I)()}function p(a,b){if(!b||(0,d.isAbsolute)(b))throw Error(`unsafe managed policy path ${JSON.stringify(b)}`);let e=(0,d.resolve)(a,b),f=(0,d.relative)(a,e);if(f.startsWith("..")||(0,d.isAbsolute)(f))throw Error(`managed policy path escapes its root: ${JSON.stringify(b)}`);let g=(0,c.realpathSync)(a),h=(0,c.realpathSync)(e),i=(0,d.relative)(g,h);if(i.startsWith("..")||(0,d.isAbsolute)(i))throw Error(`managed policy symlink escapes its root: ${JSON.stringify(b)}`);return h}let q=null;function r(){if(function(){try{let a=JSON.parse((0,c.readFileSync)((0,f.y)(),"utf8"));if(!a||"object"!=typeof a||Array.isArray(a))return!1;let b=a.mode;return!!b&&"object"==typeof b&&!Array.isArray(b)&&"oss"===b.kind}catch{return!1}}()){q=null;return}let a=(0,d.resolve)(o(),"active.json"),b=function(a){try{let b=(0,c.statSync)(a,{bigint:!0});return`${b.dev}:${b.ino}:${b.mode}:${b.size}:${b.mtimeNs}:${b.ctimeNs}`}catch(b){let a=b.code;if("ENOENT"===a||"ENOTDIR"===a)return null;throw b}}(a);if(null===b){q=null;return}if(q&&q.path===a&&q.version===b)return q.value;let e=JSON.parse((0,c.readFileSync)(a,"utf8"));return q={path:a,version:b,value:e},e}let s=/^cloud:[^/]+\/./;function t(a,b){return"reviewable"!==a.authority?a.authority?{authority:a.authority}:{}:"observe"===a.effect||"observe"!==b&&"enforce"!==b?{authority:"hard"}:{authority:"reviewable",reviewedBy:(a.reviewedBy??[]).map(b=>{var c;return s.test(b)?b:(c=a.id,`cloud:${c}/${b}`)})}}a.s(["i",0,t,"O",0,function(a,b){let c=[];for(let d of a){let a=t(d,b);"reviewable"===a.authority&&c.push(...a.reviewedBy??[])}return c},"h",0,function(){return function(a){let d,e=o();try{d=r()}catch(a){throw Error(`failed to read cloud-managed active manifest: ${a instanceof Error?a.message:String(a)}`)}if(void 0===d)return[];let f=function(a){if(!a||"object"!=typeof a)throw Error("active manifest is not an object");if(!l.includes(a.schemaVersion))throw Error(`unsupported active manifest schema ${String(a.schemaVersion)} (supported: ${l.join(", ")})`);let b=a.deployment??a.generation;if(!Number.isSafeInteger(b)||(b??-1)<0)throw Error("active manifest deployment is invalid");if(!Array.isArray(a.policies))throw Error("active manifest policies is not an array");let c=a.policies.map(a=>({...a,version:a.version??a.revision}));return{schemaVersion:a.schemaVersion,deployment:b,policies:c}}(d),h=f.policies.filter(b=>a((0,g.f)(b.agentTargets,f.schemaVersion))),i=new Set;return h.map(a=>{if(!n.test(a.id)||"."===a.id||".."===a.id)throw Error(`unsafe cloud-managed policy id ${JSON.stringify(a.id)}`);if(!Number.isSafeInteger(a.version)||a.version<0)throw Error(`invalid version for cloud-managed policy ${a.id}`);if(!m.test(a.sha256))throw Error(`invalid SHA-256 for cloud-managed policy ${a.id}`);if(i.has(a.id))throw Error(`duplicate cloud-managed policy id ${a.id}`);i.add(a.id);let d=p(e,a.path),h=(0,c.readFileSync)(d),j=(0,b.createHash)("sha256").update(h).digest("hex");if(j!==a.sha256)throw Error(`cloud-managed policy ${a.id} failed integrity verification: expected ${a.sha256}, got ${j}`);if(void 0!==a.effect&&"enforce"!==a.effect&&"observe"!==a.effect)throw Error(`unknown effect ${JSON.stringify(a.effect)} for cloud-managed policy ${a.id}`);return{id:a.id,version:a.version,effect:a.effect??"enforce",sha256:a.sha256,path:d,deployment:f.deployment,...(0,g.f)(a.agentTargets,f.schemaVersion)?{agentTargets:(0,g.f)(a.agentTargets,f.schemaVersion)}:{},...k(a)}})}(()=>!0)},"D",0,function(){try{var a;return a=function(){let a=r();if(void 0===a)return null;if(!a||"object"!=typeof a||Array.isArray(a))throw Error("active manifest is not an object");if(!l.includes(a.schemaVersion))throw Error(`unsupported active manifest schema ${String(a.schemaVersion)}`);return a}()?.jevMode,"off"===a||"observe"===a||"enforce"===a?a:null}catch{return null}},"t",0,p],89790);let u=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/,v=/^(?:0|[1-9]\d*)$/;function w(a){if("string"!=typeof a)return null;let b=u.exec(a);return b?{major:Number(b[1]),minor:Number(b[2]),patch:Number(b[3]),prerelease:void 0===b[4]?[]:b[4].split(".").map(a=>v.test(a)?Number(a):a)}:null}let x=(a,b)=>a<b?-1:+(a>b);function y(a,b){let c=w(a),d=w(b);return c&&d?x(c.major,d.major)||x(c.minor,d.minor)||x(c.patch,d.patch)||function(a,b){if(0===a.length&&0===b.length)return 0;if(0===a.length)return 1;if(0===b.length)return -1;for(let c=0;c<Math.min(a.length,b.length);c++){let d=a[c],e=b[c];if(d===e)continue;let f="number"==typeof d,g="number"==typeof e;if(f!==g)return f?-1:1;if(f&&g)return x(d,e);return d<e?-1:1}return x(a.length,b.length)}(c.prerelease,d.prerelease):null}a.s(["f",0,y],68561);let z=["always","protected_branch","in_git_repo","has_paths","paths_outside_project","system_or_root_paths"];function A(a){return"string"==typeof a&&z.includes(a)}a.s(["B",0,z,"M",0,A],48630);let B=[1],C=/^[a-f0-9]{64}$/,D=/^[A-Za-z0-9._-]{1,64}\/[A-Za-z0-9._-]{1,64}$/,E=/^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$/,F=/^[0-9a-f]{7,40}$/,G=/^[A-Za-z0-9._-]{1,128}$/,H=/^[a-z][a-z0-9_]{0,31}$/,I=new Set(["exempt","user_asked"]),J=new Set(["shell","write","read","network","other"]);function K(){return process.env.FAILPROOFAI_PACK_DIR??(0,f.n)()}function L(a){if("string"!=typeof a.id||!D.test(a.id))throw Error(`unsafe pack id ${JSON.stringify(a.id)}`);if("string"!=typeof a.version||!E.test(a.version))throw Error(`invalid version for pack ${a.id}`);if(void 0!==a.effect&&"enforce"!==a.effect&&"observe"!==a.effect)throw Error(`unknown effect ${JSON.stringify(a.effect)} for pack ${a.id}`);let b="string"==typeof a.commit&&F.test(a.commit.trim().toLowerCase())?a.commit.trim().toLowerCase():void 0;return{id:a.id,version:a.version,effect:a.effect??"enforce",...b?{commit:b}:{}}}function M(){return process.env.FAILPROOFAI_PACK_DIR?(0,d.resolve)(process.env.FAILPROOFAI_PACK_DIR,"installed.json"):(0,f.v)()}let N=new Set(["string","number","boolean","string[]","pattern[]"]);function O(a,b,c,d){let e=`${a} policy #${c}`;if(!b||"object"!=typeof b)throw Error(`${e} is not an object`);let f=b.name;if("string"!=typeof f||!G.test(f))throw Error(`${e} has an unsafe name ${JSON.stringify(f)}`);if("alwaysOn"in b)throw Error(`${e} declares alwaysOn, which packs may not set`);if("string"!=typeof b.description||0===b.description.length)throw Error(`${e} is missing a description`);if("string"!=typeof b.category||0===b.category.length)throw Error(`${e} is missing a category`);if("boolean"!=typeof b.defaultEnabled)throw Error(`${e} is missing defaultEnabled`);if(!b.match||"object"!=typeof b.match)throw Error(`${e} is missing a match`);let g=b.match;for(let a of["events","toolNames"]){let b=g[a];if(void 0!==b&&(!Array.isArray(b)||b.some(a=>"string"!=typeof a||0===a.length)))throw Error(`${e} has a match.${a} that is not a list of names`)}let h=k(b),i=["authority","reviewedBy"].filter(a=>a in b&&!(a in h));if("params"in b){let a=function(a){if(!a||"object"!=typeof a||Array.isArray(a))return"params is not an object";for(let[b,c]of Object.entries(a)){if(0===b.length)return"params has an empty parameter name";if(!c||"object"!=typeof c||Array.isArray(c))return`params.${b} is not an object`;if("string"!=typeof c.type||!N.has(c.type))return`params.${b} has type ${JSON.stringify(c.type)}, which is not one of ${[...N].join(", ")}`;if("string"!=typeof c.description||0===c.description.length)return`params.${b} is missing a description`;if(!("default"in c))return`params.${b} is missing a default`}}(b.params);a&&(d?.push(`${e} declares a params schema that was dropped: ${a}`),i.push("params"))}return i.length>0?Object.fromEntries(Object.entries(b).filter(([a])=>!i.includes(a))):b}function P(a,b,c=e.version){if(void 0===b)return{kind:"satisfied"};let d=y(c,b);return null===d?{kind:"unreadable",reason:`pack ${a} declares minCliVersion ${JSON.stringify(b)}, which is not a version this CLI can compare against its own (${c}) — the requirement was ignored`}:d<0?{kind:"too-old",reason:`pack ${a} needs failproofai ${String(b)} or newer and this is ${c} — run \`npm i -g "failproofai@>=${String(b)}" && failproofai update\``}:{kind:"satisfied",declared:b}}function Q(a,b,c,d){if("string"!=typeof c||0===c.length)throw Error(`${a} is missing ${b}`);if(c.length>d)throw Error(`${a} has a ${b} of ${c.length} characters, over the ${d}-character cap`);return c}function R(a,b,c){let d;if(!b||"object"!=typeof b||Array.isArray(b))throw Error(`${a} is not an object`);if(null!==c)d=c;else{if("string"!=typeof b.id||!H.test(b.id))throw Error(`${a} has an unsafe id ${JSON.stringify(b.id)}`);if(I.has(b.id))throw Error(`${a} uses the reserved probe id ${JSON.stringify(b.id)}`);d=b.id}let e=Q(a,"instructions",b.instructions,600);if(void 0===b.criteria)return{id:d,instructions:e};if(!b.criteria||"object"!=typeof b.criteria||Array.isArray(b.criteria))throw Error(`${a} has criteria that is not an object`);let f=b.criteria;return{id:d,instructions:e,criteria:{true:Q(a,"criteria.true",f.true,300),false:Q(a,"criteria.false",f.false,300)}}}function S(a,b,c){let d=`${a} semantic policy #${c}`;if(!b||"object"!=typeof b||Array.isArray(b))throw Error(`${d} is not an object`);let e=b.name;if("string"!=typeof e||!G.test(e))throw Error(`${d} has an unsafe name ${JSON.stringify(e)}`);if("alwaysOn"in b)throw Error(`${d} declares alwaysOn, which packs may not set`);let f=Q(`${a} semantic policy ${e}`,"title",b.title,120),g=`${a} semantic policy ${e}`;if(!Array.isArray(b.appliesTo)||0===b.appliesTo.length)throw Error(`${g} has no appliesTo tool classes`);let h=b.appliesTo.find(a=>"string"!=typeof a||!J.has(a));if(void 0!==h)throw Error(`${g} applies to ${JSON.stringify(h)}, which is not a tool class (${[...J].join(", ")})`);if("deny"!==b.mode&&"instruct"!==b.mode)throw Error(`${g} has mode ${JSON.stringify(b.mode)}, which must be "deny" or "instruct"`);if("boolean"!=typeof b.userCanOverride)throw Error(`${g} is missing userCanOverride, which has no default`);if(!Array.isArray(b.probes)||0===b.probes.length)throw Error(`${g} declares no probes`);if(b.probes.length>6)throw Error(`${g} declares ${b.probes.length} probes, over the cap of 6`);let i=b.probes.map((a,b)=>R(`${g} probe #${b}`,a,null)),j=new Set;for(let a of i){if(j.has(a.id))throw Error(`${g} declares probe ${a.id} twice`);j.add(a.id)}let k=void 0===b.exempt?void 0:R(`${g} exempt`,b.exempt,"exempt");if(void 0!==b.precondition&&!A(b.precondition))throw Error(`${g} names precondition ${JSON.stringify(b.precondition)}, which this build does not have (${z.join(", ")})`);let l=Q(g,"guidance",b.guidance,600);return{name:e,title:f,appliesTo:b.appliesTo,mode:b.mode,userCanOverride:b.userCanOverride,probes:i,...k?{exempt:k}:{},...void 0!==b.precondition?{precondition:b.precondition}:{},guidance:l}}function T(a){return a instanceof Error?a.message:String(a)}function U(a){return/^github:FailproofAI\//i.test(a.source??"")}function V(a,b){return h.has(b)&&!U(a)}a.s(["P",0,24,"r",0,F,"T",0,P,"Q",0,function(){try{let a=JSON.parse((0,c.readFileSync)(M(),"utf8"));if(!Array.isArray(a.packs))return!1;return a.packs.some(a=>!!a&&"object"==typeof a&&Array.isArray(a.policies)&&a.policies.length>0)}catch{return!1}},"E",0,function(a){return a.semantic??[]},"N",0,K,"$",0,L,"Z",0,O,"U",0,S,"V",0,function(){let a,d=M();if(!(0,c.existsSync)(d))return{packs:[],errors:[]};try{a=JSON.parse((0,c.readFileSync)(d,"utf8"))}catch(a){return{packs:[],errors:[{id:null,reason:`unreadable pack manifest: ${T(a)}`}]}}if(!a||"object"!=typeof a)return{packs:[],errors:[{id:null,reason:"pack manifest is not an object"}]};let e=a;if(!B.includes(e.schemaVersion))return{packs:[],errors:[{id:null,reason:`unsupported pack manifest schema ${String(e.schemaVersion)} (supported: ${B.join(", ")})`}]};if(!Array.isArray(e.packs))return{packs:[],errors:[{id:null,reason:"pack manifest packs is not an array"}]};let f=K(),g=[],h=[],i=[],j=new Set;for(let a of e.packs){let d=a&&"object"==typeof a&&"string"==typeof a.id?a.id:null,e=[];try{let d=function(a,d,e){if(!d||"object"!=typeof d)throw Error("pack entry is not an object");let f=L(d);if("string"!=typeof d.source||0===d.source.length)throw Error(`pack ${d.id} has no source`);if("string"!=typeof d.sha256||!C.test(d.sha256))throw Error(`invalid SHA-256 for pack ${d.id}`);let g=f.effect,h=P(f.id,d.minCliVersion);if("too-old"===h.kind)throw Error(h.reason);"unreadable"===h.kind&&e.push(h.reason);let i=p(a,d.entry),j=(0,b.createHash)("sha256").update((0,c.readFileSync)(i)).digest("hex");if(j!==d.sha256)throw Error(`pack ${d.id} failed integrity verification: expected ${d.sha256}, got ${j}`);if(!Array.isArray(d.policies))throw Error(`pack ${d.id} policies is not an array`);let k=d.policies.map((a,b)=>O(d.id,a,b,e)),l=new Set;for(let a of k){if(l.has(a.name))throw Error(`pack ${d.id} declares ${a.name} twice`);l.add(a.name)}let m=null;if(void 0!==d.enabled){if(!Array.isArray(d.enabled)||d.enabled.some(a=>"string"!=typeof a))throw Error(`pack ${d.id} enabled is not an array of names`);m=d.enabled.filter(a=>l.has(a))}let n=null;if(void 0!==d.clis){if(!Array.isArray(d.clis)||d.clis.some(a=>"string"!=typeof a))throw Error(`pack ${d.id} clis is not an array of agent names`);n=d.clis}return{clis:n,id:f.id,version:f.version,source:d.source,path:i,sha256:d.sha256,effect:g,policies:k,semantic:function(a,b,c){if(void 0===b)return[];if(!Array.isArray(b))return c.push(`pack ${a} semantic is not an array, so none of it was loaded`),[];let d=[],e=new Set;for(let[f,g]of b.entries()){if(d.length>=24){c.push(`pack ${a} declares more than 24 semantic policies; the ${b.length-24} past that cap were dropped`);break}try{let b=S(a,g,f);if(e.has(b.name))throw Error(`pack ${a} declares semantic policy ${b.name} twice`);e.add(b.name),d.push(b)}catch(a){c.push(T(a))}}return d}(f.id,d.semantic,e),..."satisfied"===h.kind&&h.declared?{minCliVersion:h.declared}:{},enabled:m}}(f,a,e);if(j.has(d.id))throw Error(`duplicate pack id ${d.id}`);j.add(d.id),g.push(d),i.push(...e)}catch(c){let b=a&&("observe"===a.effect||"enforce"===a.effect)?a.effect:"enforce";h.push({id:d,reason:T(c),effect:b,...Array.isArray(a?.policies)?{declared:function(a){let b=[];for(let c of a)c&&"object"==typeof c&&"string"==typeof c.name&&c.match&&"object"==typeof c.match&&b.push(c);return b}(a.policies)}:{},...Array.isArray(a?.policies)&&0===a.policies.length?{semanticOnly:!0}:{},...Array.isArray(a?.clis)&&a.clis.every(a=>"string"==typeof a)?{clis:a.clis}:{}})}}return{packs:g,errors:h,...i.length>0?{warnings:i}:{}}},"M",0,function(a){return a.exempt?[...a.probes,a.exempt]:a.probes}],9909),a.s(["v",0,function(a){let b=new Map,c=new Map;for(let d of a)for(let a of d.semantic??[]){if(V(d,a.name))continue;let e=function a(b){if(Array.isArray(b))return`[${b.map(a).join(",")}]`;if(null!==b&&"object"==typeof b){let c=Object.entries(b).filter(([,a])=>void 0!==a).sort(([a],[b])=>a<b?-1:+(a>b));return`{${c.map(([b,c])=>`${JSON.stringify(b)}:${a(c)}`).join(",")}}`}return JSON.stringify(b)??"null"}(a),f=b.get(a.name);if(void 0===f){b.set(a.name,{form:e,ids:[d.id]});continue}f.ids.push(d.id),f.form!==e&&c.set(a.name,f.ids)}return c},"g",0,U,"B",0,V,"r",0,function(a,b){return a.filter(a=>"observe"!==a.effect&&!(b&&Array.isArray(a.clis)&&a.clis.length>0&&!a.clis.includes(b)))}],86304)},10695,a=>{"use strict";var b=a.i(2157),c=a.i(50227),d=a.i(75818);let e={info:0,warn:1,error:2},f=(0,d.A)(),g=!1,h="warn",i=!1,j=f;function k(a){return!function(){if(g)return;g=!0;let a=(process.env.FAILPROOFAI_LOG_LEVEL??"").toLowerCase();("info"===a||"warn"===a||"error"===a)&&(h=a);let b=(process.env.FAILPROOFAI_HOOK_LOG_FILE??"").trim();b&&(i=!0,"1"!==b&&"true"!==b&&(j=b))}(),e[a]>=e[h]}function l(a,b){process.stderr.write(`[failproofai:hook] ${a} ${b}
|
|
2
|
-
`)}function m(a,d){if(i)try{(0,b.existsSync)(j)||(0,b.mkdirSync)(j,{recursive:!0});let e=(0,c.join)(j,"hooks.log");try{if((0,b.statSync)(e).size>=524288){let a=`hooks-${Date.now()}.log`;(0,b.renameSync)(e,(0,c.join)(j,a))}}catch{}let f=new Date().toISOString(),g=`[${f}] ${a} ${d}
|
|
3
|
-
`;(0,b.appendFileSync)(e,g,"utf-8")}catch{}}a.s(["F",0,function(a){k("error")&&(l("ERROR",a),m("ERROR",a))},"g",0,function(a){k("warn")&&(l("WARN",a),m("WARN",a))}])}];
|
|
4
|
-
|
|
5
|
-
//# sourceMappingURL=src_hooks_0mdwgjisv4fub._.js.map
|