failproofai 1.0.6-beta.0 → 1.0.6-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +14 -14
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
- 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 +4 -4
- package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +14 -14
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +13 -13
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +14 -14
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
- package/.next/standalone/.next/server/app/policies/page.js +6 -5
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -4
- package/.next/standalone/.next/server/app/settings/page.js +3 -2
- package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zlqo2t._.js +1 -1
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__112b4go._.js → [root-of-the-server]__1_r2rbg._.js} +4 -4
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1anxb5k._.js +1 -1
- package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
- package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0-_ki57._.js +4 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__013jr2b._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__01wy8d-._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__02npjtd._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0576iuy._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0bym1os._.js → [root-of-the-server]__0cg-bgc._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0da85px._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0ftmoxc._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0p-5p8u._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__00y9ww2._.js → [root-of-the-server]__0u3w0ll._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1p2otjt._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1py795m._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1i26dsw._.js → [root-of-the-server]__1x3j9mj._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_06imw3p._.js +5 -0
- package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_0lbwa8m._.js → _0qlygw6._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{_09hs6ms._.js → _1_ddpm3._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_14c6q09._.js → _1_qswah._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_1es2j7i._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1u8-lu2._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1zopuov._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +12 -11
- package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +19 -19
- package/.next/standalone/.next/static/chunks/{03n_qjih7-w6q.js → 02vwr5js1x28j.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3d3hzhcnns6ww.js → 06fjx8-0_qufs.js} +1 -1
- package/.next/standalone/.next/static/chunks/{17pjz_h45j10c.js → 0cbvytf8epn34.js} +1 -1
- package/.next/standalone/.next/static/chunks/{1ekh-hj_iom84.js → 0y227_ohdqwvn.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0vanab2g65op_.js → 1p4xauf-zu6zk.js} +1 -1
- package/.next/standalone/.next/static/chunks/{1so_3s0q4c4j1.js → 1qf2uiipatr80.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3iasus89n8mg1.js → 1uc_s_dftgxiq.js} +1 -1
- package/.next/standalone/.next/static/chunks/{44_cj1_i_aa2z.js → 27_bwbg8sv6vj.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2u0kol_boahtv.js → 2x776s0x3n_tu.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3_vesf83-0903.js → 3ht0xsco46pul.js} +1 -1
- package/.next/standalone/hermes-plugin/README.md +6 -1
- package/.next/standalone/hermes-plugin/client.py +22 -6
- package/.next/standalone/lib/hermes-profiles.ts +67 -19
- package/.next/standalone/lib/hermes-sessions.ts +3 -2
- package/.next/standalone/package.json +9 -9
- package/.next/standalone/server.js +1 -1
- package/dist/cli.mjs +273 -220
- package/dist/worker.mjs +62 -32
- package/hermes-plugin/README.md +6 -1
- package/hermes-plugin/client.py +22 -6
- package/lib/hermes-profiles.ts +67 -19
- package/lib/hermes-sessions.ts +3 -2
- package/package.json +9 -9
- package/src/hooks/integrations.ts +7 -0
- package/src/hooks/manager.ts +24 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0oa1lav._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0s740oi._.js +0 -6
- /package/.next/standalone/.next/static/{-7OT2NwGPxAu-skEL_Xee → QCNYz2yCxxdeggg1k0iEq}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{-7OT2NwGPxAu-skEL_Xee → QCNYz2yCxxdeggg1k0iEq}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{-7OT2NwGPxAu-skEL_Xee → QCNYz2yCxxdeggg1k0iEq}/_ssgManifest.js +0 -0
package/dist/cli.mjs
CHANGED
|
@@ -29,7 +29,7 @@ var __esm = (fn, res, err) => () => {
|
|
|
29
29
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
30
|
|
|
31
31
|
// package.json
|
|
32
|
-
var version2 = "1.0.6-beta.
|
|
32
|
+
var version2 = "1.0.6-beta.1", package_default;
|
|
33
33
|
var init_package = __esm(() => {
|
|
34
34
|
package_default = {
|
|
35
35
|
name: "failproofai",
|
|
@@ -155,16 +155,16 @@ var init_package = __esm(() => {
|
|
|
155
155
|
browserslist: "4.28.8"
|
|
156
156
|
},
|
|
157
157
|
optionalDependencies: {
|
|
158
|
-
"@failproofai/failproofaid-linux-x64": "1.0.6-beta.
|
|
159
|
-
"@failproofai/failproofaid-linux-arm64": "1.0.6-beta.
|
|
160
|
-
"@failproofai/failproofaid-darwin-x64": "1.0.6-beta.
|
|
161
|
-
"@failproofai/failproofaid-darwin-arm64": "1.0.6-beta.
|
|
158
|
+
"@failproofai/failproofaid-linux-x64": "1.0.6-beta.1",
|
|
159
|
+
"@failproofai/failproofaid-linux-arm64": "1.0.6-beta.1",
|
|
160
|
+
"@failproofai/failproofaid-darwin-x64": "1.0.6-beta.1",
|
|
161
|
+
"@failproofai/failproofaid-darwin-arm64": "1.0.6-beta.1"
|
|
162
162
|
},
|
|
163
163
|
failproofaidBinaries: {
|
|
164
|
-
"linux-x64": "
|
|
165
|
-
"linux-arm64": "
|
|
166
|
-
"darwin-x64": "
|
|
167
|
-
"darwin-arm64": "
|
|
164
|
+
"linux-x64": "b6f877cd407c3322ff8ad2f98a096b6ea15b0bd1d63de6276c689368345c1cd2",
|
|
165
|
+
"linux-arm64": "0da90a816b9dc707efe9b82176923cbf0f00026179c816e34eaad362ce2c0fa4",
|
|
166
|
+
"darwin-x64": "bcbec488353fa04a1953a87cad15054e4796117cac4fd60b17fb1c87d62b7b1e",
|
|
167
|
+
"darwin-arm64": "6830989a91a27642cdcc63fcfad529c69c0deb3f3abcf5ad40fd3516289b451d"
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
170
|
});
|
|
@@ -11518,36 +11518,66 @@ var init_dist = __esm(() => {
|
|
|
11518
11518
|
});
|
|
11519
11519
|
|
|
11520
11520
|
// lib/hermes-profiles.ts
|
|
11521
|
-
import { readdirSync } from "node:fs";
|
|
11521
|
+
import { existsSync as existsSync6, readdirSync } from "node:fs";
|
|
11522
11522
|
import { homedir as homedir4 } from "node:os";
|
|
11523
11523
|
import { basename, dirname as dirname3, join as join3, resolve as resolve6 } from "node:path";
|
|
11524
11524
|
function hermesRoot() {
|
|
11525
11525
|
const env = (process.env.HERMES_HOME || "").trim();
|
|
11526
11526
|
if (env) {
|
|
11527
|
-
|
|
11527
|
+
let home = resolve6(env);
|
|
11528
11528
|
const parent = dirname3(home);
|
|
11529
11529
|
if (basename(parent) === PROFILES_DIR)
|
|
11530
|
-
|
|
11530
|
+
home = dirname3(parent);
|
|
11531
|
+
const base = basename(home);
|
|
11532
|
+
if (base === STANDARD_HOME || base.startsWith(SIBLING_HOME_PREFIX)) {
|
|
11533
|
+
return join3(dirname3(home), STANDARD_HOME);
|
|
11534
|
+
}
|
|
11531
11535
|
return home;
|
|
11532
11536
|
}
|
|
11533
|
-
return join3(homedir4(),
|
|
11537
|
+
return join3(homedir4(), STANDARD_HOME);
|
|
11538
|
+
}
|
|
11539
|
+
function uniqueProfileName(preferred, seen) {
|
|
11540
|
+
if (!seen.has(preferred))
|
|
11541
|
+
return preferred;
|
|
11542
|
+
const base = `${preferred}-home`;
|
|
11543
|
+
if (!seen.has(base))
|
|
11544
|
+
return base;
|
|
11545
|
+
let suffix = 2;
|
|
11546
|
+
while (seen.has(`${base}-${suffix}`))
|
|
11547
|
+
suffix += 1;
|
|
11548
|
+
return `${base}-${suffix}`;
|
|
11534
11549
|
}
|
|
11535
11550
|
function listHermesProfiles() {
|
|
11536
11551
|
const root = hermesRoot();
|
|
11537
11552
|
const out = [{ name: HERMES_DEFAULT_PROFILE, home: root }];
|
|
11538
11553
|
const seen = new Set([HERMES_DEFAULT_PROFILE]);
|
|
11539
|
-
let names;
|
|
11554
|
+
let names = [];
|
|
11540
11555
|
try {
|
|
11541
11556
|
names = readdirSync(join3(root, PROFILES_DIR), { withFileTypes: true }).filter((e) => (e.isDirectory() || e.isSymbolicLink()) && !e.name.startsWith(".")).map((e) => e.name).sort();
|
|
11542
|
-
} catch {
|
|
11543
|
-
return out;
|
|
11544
|
-
}
|
|
11557
|
+
} catch {}
|
|
11545
11558
|
for (const name of names) {
|
|
11546
11559
|
if (seen.has(name))
|
|
11547
11560
|
continue;
|
|
11548
11561
|
seen.add(name);
|
|
11549
11562
|
out.push({ name, home: join3(root, PROFILES_DIR, name) });
|
|
11550
11563
|
}
|
|
11564
|
+
if (basename(root) !== STANDARD_HOME)
|
|
11565
|
+
return out;
|
|
11566
|
+
let siblings = [];
|
|
11567
|
+
const parent = dirname3(root);
|
|
11568
|
+
try {
|
|
11569
|
+
siblings = readdirSync(parent, { withFileTypes: true }).filter((entry) => (entry.isDirectory() || entry.isSymbolicLink()) && entry.name.startsWith(SIBLING_HOME_PREFIX) && entry.name.length > SIBLING_HOME_PREFIX.length && existsSync6(join3(parent, entry.name, "config.yaml"))).map((entry) => ({
|
|
11570
|
+
name: entry.name.slice(SIBLING_HOME_PREFIX.length),
|
|
11571
|
+
home: join3(parent, entry.name)
|
|
11572
|
+
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
11573
|
+
} catch {
|
|
11574
|
+
return out;
|
|
11575
|
+
}
|
|
11576
|
+
for (const sibling of siblings) {
|
|
11577
|
+
const name = uniqueProfileName(sibling.name, seen);
|
|
11578
|
+
seen.add(name);
|
|
11579
|
+
out.push({ name, home: sibling.home });
|
|
11580
|
+
}
|
|
11551
11581
|
return out;
|
|
11552
11582
|
}
|
|
11553
11583
|
function hermesProjectName(profile, source) {
|
|
@@ -11573,11 +11603,11 @@ function hermesProjectNameCandidates(name) {
|
|
|
11573
11603
|
out.push({ profile: HERMES_DEFAULT_PROFILE, source: rest });
|
|
11574
11604
|
return out;
|
|
11575
11605
|
}
|
|
11576
|
-
var PROFILES_DIR = "profiles", HERMES_DEFAULT_PROFILE = "default";
|
|
11606
|
+
var PROFILES_DIR = "profiles", STANDARD_HOME = ".hermes", SIBLING_HOME_PREFIX = ".hermes-", HERMES_DEFAULT_PROFILE = "default";
|
|
11577
11607
|
var init_hermes_profiles = () => {};
|
|
11578
11608
|
|
|
11579
11609
|
// lib/openclaw-profiles.ts
|
|
11580
|
-
import { existsSync as
|
|
11610
|
+
import { existsSync as existsSync7, readdirSync as readdirSync2 } from "node:fs";
|
|
11581
11611
|
import { homedir as homedir5 } from "node:os";
|
|
11582
11612
|
import { basename as basename2, dirname as dirname4, join as join4, resolve as resolve7 } from "node:path";
|
|
11583
11613
|
function openclawProfileHome() {
|
|
@@ -11609,7 +11639,7 @@ function listOpenClawProfiles() {
|
|
|
11609
11639
|
} catch {
|
|
11610
11640
|
return out;
|
|
11611
11641
|
}
|
|
11612
|
-
const named = entries.filter((entry) => (entry.isDirectory() || entry.isSymbolicLink()) && entry.name.startsWith(".openclaw-") && entry.name.length > ".openclaw-".length &&
|
|
11642
|
+
const named = entries.filter((entry) => (entry.isDirectory() || entry.isSymbolicLink()) && entry.name.startsWith(".openclaw-") && entry.name.length > ".openclaw-".length && existsSync7(join4(parent, entry.name, "openclaw.json"))).map((entry) => ({
|
|
11613
11643
|
name: entry.name.slice(".openclaw-".length),
|
|
11614
11644
|
home: join4(parent, entry.name)
|
|
11615
11645
|
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -11625,7 +11655,7 @@ import {
|
|
|
11625
11655
|
cpSync,
|
|
11626
11656
|
readFileSync as readFileSync5,
|
|
11627
11657
|
writeFileSync as writeFileSync3,
|
|
11628
|
-
existsSync as
|
|
11658
|
+
existsSync as existsSync8,
|
|
11629
11659
|
lstatSync,
|
|
11630
11660
|
mkdirSync as mkdirSync4,
|
|
11631
11661
|
renameSync as renameSync2,
|
|
@@ -11636,7 +11666,7 @@ import { resolve as resolve8, dirname as dirname5 } from "node:path";
|
|
|
11636
11666
|
import { fileURLToPath } from "node:url";
|
|
11637
11667
|
import { homedir as homedir6 } from "node:os";
|
|
11638
11668
|
function readJsonFile(path) {
|
|
11639
|
-
if (!
|
|
11669
|
+
if (!existsSync8(path))
|
|
11640
11670
|
return {};
|
|
11641
11671
|
const raw = readFileSync5(path, "utf8");
|
|
11642
11672
|
return JSON.parse(raw);
|
|
@@ -11648,7 +11678,7 @@ function writeJsonFile(path, data) {
|
|
|
11648
11678
|
}
|
|
11649
11679
|
function readYamlDoc(path) {
|
|
11650
11680
|
try {
|
|
11651
|
-
return
|
|
11681
|
+
return existsSync8(path) ? $parseDocument(readFileSync5(path, "utf8")) : $parseDocument("");
|
|
11652
11682
|
} catch {
|
|
11653
11683
|
return $parseDocument("");
|
|
11654
11684
|
}
|
|
@@ -11947,9 +11977,9 @@ function hasManagedHermesPlugin(settingsPath) {
|
|
|
11947
11977
|
try {
|
|
11948
11978
|
if (lstatSync(pluginPath).isSymbolicLink())
|
|
11949
11979
|
return false;
|
|
11950
|
-
if (!
|
|
11980
|
+
if (!existsSync8(resolve8(pluginPath, HERMES_PLUGIN_MARKER)))
|
|
11951
11981
|
return false;
|
|
11952
|
-
return HERMES_PLUGIN_FILES.every((file) =>
|
|
11982
|
+
return HERMES_PLUGIN_FILES.every((file) => existsSync8(resolve8(pluginPath, file)));
|
|
11953
11983
|
} catch {
|
|
11954
11984
|
return false;
|
|
11955
11985
|
}
|
|
@@ -11957,7 +11987,7 @@ function hasManagedHermesPlugin(settingsPath) {
|
|
|
11957
11987
|
function hasHermesPluginMarker(settingsPath) {
|
|
11958
11988
|
const pluginPath = hermesPluginPathForSettings(settingsPath);
|
|
11959
11989
|
try {
|
|
11960
|
-
return !lstatSync(pluginPath).isSymbolicLink() &&
|
|
11990
|
+
return !lstatSync(pluginPath).isSymbolicLink() && existsSync8(resolve8(pluginPath, HERMES_PLUGIN_MARKER));
|
|
11961
11991
|
} catch {
|
|
11962
11992
|
return false;
|
|
11963
11993
|
}
|
|
@@ -11965,13 +11995,13 @@ function hasHermesPluginMarker(settingsPath) {
|
|
|
11965
11995
|
function installHermesPlugin(settingsPath) {
|
|
11966
11996
|
const source = getHermesPluginSourcePath();
|
|
11967
11997
|
for (const file of HERMES_PLUGIN_FILES) {
|
|
11968
|
-
if (!
|
|
11998
|
+
if (!existsSync8(resolve8(source, file))) {
|
|
11969
11999
|
throw new Error(`Hermes plugin asset is missing from the failproofai package: ${file}`);
|
|
11970
12000
|
}
|
|
11971
12001
|
}
|
|
11972
12002
|
const destination = hermesPluginPathForSettings(settingsPath);
|
|
11973
|
-
if (
|
|
11974
|
-
if (lstatSync(destination).isSymbolicLink() || !
|
|
12003
|
+
if (existsSync8(destination)) {
|
|
12004
|
+
if (lstatSync(destination).isSymbolicLink() || !existsSync8(resolve8(destination, HERMES_PLUGIN_MARKER))) {
|
|
11975
12005
|
throw new Error(`Refusing to overwrite an unmanaged Hermes plugin at ${destination}. ` + `Move it aside or install FailproofAI under a different Hermes profile.`);
|
|
11976
12006
|
}
|
|
11977
12007
|
}
|
|
@@ -11986,7 +12016,7 @@ function installHermesPlugin(settingsPath) {
|
|
|
11986
12016
|
cpSync(resolve8(source, file), resolve8(temporary, file));
|
|
11987
12017
|
}
|
|
11988
12018
|
writeFileSync3(resolve8(temporary, HERMES_PLUGIN_MARKER), "Managed by failproofai. Remove with `failproofai policies --uninstall --cli hermes`.\n", { encoding: "utf8", mode: 384 });
|
|
11989
|
-
if (
|
|
12019
|
+
if (existsSync8(destination)) {
|
|
11990
12020
|
renameSync2(destination, backup);
|
|
11991
12021
|
movedExisting = true;
|
|
11992
12022
|
}
|
|
@@ -11995,7 +12025,7 @@ function installHermesPlugin(settingsPath) {
|
|
|
11995
12025
|
rmSync2(backup, { recursive: true, force: true });
|
|
11996
12026
|
} catch (err) {
|
|
11997
12027
|
rmSync2(temporary, { recursive: true, force: true });
|
|
11998
|
-
if (movedExisting && !
|
|
12028
|
+
if (movedExisting && !existsSync8(destination) && existsSync8(backup)) {
|
|
11999
12029
|
renameSync2(backup, destination);
|
|
12000
12030
|
}
|
|
12001
12031
|
throw err;
|
|
@@ -12036,7 +12066,7 @@ function removeLegacyHermesHooks(doc) {
|
|
|
12036
12066
|
return removed;
|
|
12037
12067
|
}
|
|
12038
12068
|
function hermesConfigState(settingsPath) {
|
|
12039
|
-
if (!
|
|
12069
|
+
if (!existsSync8(settingsPath)) {
|
|
12040
12070
|
return { pluginEnabled: false, legacyShellHookPresent: false };
|
|
12041
12071
|
}
|
|
12042
12072
|
const doc = readYamlDoc(settingsPath);
|
|
@@ -12200,7 +12230,7 @@ var init_integrations = __esm(() => {
|
|
|
12200
12230
|
},
|
|
12201
12231
|
hooksInstalledInSettings(scope, cwd) {
|
|
12202
12232
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12203
|
-
if (!
|
|
12233
|
+
if (!existsSync8(settingsPath))
|
|
12204
12234
|
return false;
|
|
12205
12235
|
try {
|
|
12206
12236
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12316,7 +12346,7 @@ var init_integrations = __esm(() => {
|
|
|
12316
12346
|
},
|
|
12317
12347
|
hooksInstalledInSettings(scope, cwd) {
|
|
12318
12348
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12319
|
-
if (!
|
|
12349
|
+
if (!existsSync8(settingsPath))
|
|
12320
12350
|
return false;
|
|
12321
12351
|
try {
|
|
12322
12352
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12430,7 +12460,7 @@ var init_integrations = __esm(() => {
|
|
|
12430
12460
|
},
|
|
12431
12461
|
hooksInstalledInSettings(scope, cwd) {
|
|
12432
12462
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12433
|
-
if (!
|
|
12463
|
+
if (!existsSync8(settingsPath))
|
|
12434
12464
|
return false;
|
|
12435
12465
|
try {
|
|
12436
12466
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12533,7 +12563,7 @@ var init_integrations = __esm(() => {
|
|
|
12533
12563
|
},
|
|
12534
12564
|
hooksInstalledInSettings(scope, cwd) {
|
|
12535
12565
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12536
|
-
if (!
|
|
12566
|
+
if (!existsSync8(settingsPath))
|
|
12537
12567
|
return false;
|
|
12538
12568
|
try {
|
|
12539
12569
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12617,7 +12647,7 @@ var init_integrations = __esm(() => {
|
|
|
12617
12647
|
}
|
|
12618
12648
|
this.writeSettings(settingsPath, settings);
|
|
12619
12649
|
const pluginPath = opencodePluginFilePath(settingsPath);
|
|
12620
|
-
if (
|
|
12650
|
+
if (existsSync8(pluginPath)) {
|
|
12621
12651
|
try {
|
|
12622
12652
|
const content = readFileSync5(pluginPath, "utf8");
|
|
12623
12653
|
if (content.includes(FAILPROOFAI_HOOK_MARKER)) {
|
|
@@ -12631,7 +12661,7 @@ var init_integrations = __esm(() => {
|
|
|
12631
12661
|
},
|
|
12632
12662
|
hooksInstalledInSettings(scope, cwd) {
|
|
12633
12663
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12634
|
-
if (!
|
|
12664
|
+
if (!existsSync8(settingsPath))
|
|
12635
12665
|
return false;
|
|
12636
12666
|
try {
|
|
12637
12667
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12641,7 +12671,7 @@ var init_integrations = __esm(() => {
|
|
|
12641
12671
|
if (!hasEntry)
|
|
12642
12672
|
return false;
|
|
12643
12673
|
const pluginPath = opencodePluginFilePath(settingsPath);
|
|
12644
|
-
if (!
|
|
12674
|
+
if (!existsSync8(pluginPath))
|
|
12645
12675
|
return false;
|
|
12646
12676
|
const content = readFileSync5(pluginPath, "utf8");
|
|
12647
12677
|
return content.includes(FAILPROOFAI_HOOK_MARKER);
|
|
@@ -12708,7 +12738,7 @@ var init_integrations = __esm(() => {
|
|
|
12708
12738
|
}
|
|
12709
12739
|
},
|
|
12710
12740
|
removeHooksFromFile(settingsPath) {
|
|
12711
|
-
if (!
|
|
12741
|
+
if (!existsSync8(settingsPath))
|
|
12712
12742
|
return 0;
|
|
12713
12743
|
const settings = this.readSettings(settingsPath);
|
|
12714
12744
|
if (!Array.isArray(settings.packages))
|
|
@@ -12723,7 +12753,7 @@ var init_integrations = __esm(() => {
|
|
|
12723
12753
|
},
|
|
12724
12754
|
hooksInstalledInSettings(scope, cwd) {
|
|
12725
12755
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12726
|
-
if (!
|
|
12756
|
+
if (!existsSync8(settingsPath))
|
|
12727
12757
|
return false;
|
|
12728
12758
|
try {
|
|
12729
12759
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12742,6 +12772,7 @@ var init_integrations = __esm(() => {
|
|
|
12742
12772
|
hermes = {
|
|
12743
12773
|
id: "hermes",
|
|
12744
12774
|
displayName: "Hermes",
|
|
12775
|
+
requiresHealthyDaemon: true,
|
|
12745
12776
|
scopes: HERMES_HOOK_SCOPES,
|
|
12746
12777
|
eventTypes: HERMES_HOOK_EVENT_TYPES,
|
|
12747
12778
|
getSettingsPath() {
|
|
@@ -12876,7 +12907,7 @@ var init_integrations = __esm(() => {
|
|
|
12876
12907
|
hooks.allowConversationAccess = true;
|
|
12877
12908
|
},
|
|
12878
12909
|
removeHooksFromFile(settingsPath) {
|
|
12879
|
-
if (!
|
|
12910
|
+
if (!existsSync8(settingsPath))
|
|
12880
12911
|
return 0;
|
|
12881
12912
|
const settings = this.readSettings(settingsPath);
|
|
12882
12913
|
const plugins = settings.plugins;
|
|
@@ -12906,7 +12937,7 @@ var init_integrations = __esm(() => {
|
|
|
12906
12937
|
hooksInstalledInSettings(scope, cwd) {
|
|
12907
12938
|
const settingsPaths = settingsPathsFor(this, scope, cwd);
|
|
12908
12939
|
return settingsPaths.length > 0 && settingsPaths.every((settingsPath) => {
|
|
12909
|
-
if (!
|
|
12940
|
+
if (!existsSync8(settingsPath))
|
|
12910
12941
|
return false;
|
|
12911
12942
|
try {
|
|
12912
12943
|
const settings = this.readSettings(settingsPath);
|
|
@@ -13004,7 +13035,7 @@ var init_integrations = __esm(() => {
|
|
|
13004
13035
|
},
|
|
13005
13036
|
hooksInstalledInSettings(scope, cwd) {
|
|
13006
13037
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
13007
|
-
if (!
|
|
13038
|
+
if (!existsSync8(settingsPath))
|
|
13008
13039
|
return false;
|
|
13009
13040
|
try {
|
|
13010
13041
|
const settings = this.readSettings(settingsPath);
|
|
@@ -13110,7 +13141,7 @@ var init_integrations = __esm(() => {
|
|
|
13110
13141
|
},
|
|
13111
13142
|
hooksInstalledInSettings(scope, cwd) {
|
|
13112
13143
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
13113
|
-
if (!
|
|
13144
|
+
if (!existsSync8(settingsPath))
|
|
13114
13145
|
return false;
|
|
13115
13146
|
try {
|
|
13116
13147
|
const settings = this.readSettings(settingsPath);
|
|
@@ -13249,7 +13280,7 @@ var init_integrations = __esm(() => {
|
|
|
13249
13280
|
},
|
|
13250
13281
|
hooksInstalledInSettings(scope, cwd) {
|
|
13251
13282
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
13252
|
-
if (!
|
|
13283
|
+
if (!existsSync8(settingsPath))
|
|
13253
13284
|
return false;
|
|
13254
13285
|
try {
|
|
13255
13286
|
const settings = this.readSettings(settingsPath);
|
|
@@ -13355,7 +13386,7 @@ var init_integrations = __esm(() => {
|
|
|
13355
13386
|
},
|
|
13356
13387
|
hooksInstalledInSettings(scope, cwd) {
|
|
13357
13388
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
13358
|
-
if (!
|
|
13389
|
+
if (!existsSync8(settingsPath))
|
|
13359
13390
|
return false;
|
|
13360
13391
|
try {
|
|
13361
13392
|
const settings = this.readSettings(settingsPath);
|
|
@@ -13746,12 +13777,12 @@ var init_telemetry_id2 = __esm(() => {
|
|
|
13746
13777
|
// src/hooks/custom-hooks-loader.ts
|
|
13747
13778
|
import { resolve as resolve10, isAbsolute as isAbsolute2, basename as basename3 } from "node:path";
|
|
13748
13779
|
import { randomUUID } from "crypto";
|
|
13749
|
-
import { existsSync as
|
|
13780
|
+
import { existsSync as existsSync9, readdirSync as readdirSync3 } from "node:fs";
|
|
13750
13781
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
13751
13782
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
13752
13783
|
import { createHash as createHash4 } from "node:crypto";
|
|
13753
13784
|
function discoverPolicyFiles(dir) {
|
|
13754
|
-
if (!
|
|
13785
|
+
if (!existsSync9(dir))
|
|
13755
13786
|
return [];
|
|
13756
13787
|
try {
|
|
13757
13788
|
const entries = readdirSync3(dir, { withFileTypes: true });
|
|
@@ -13761,7 +13792,7 @@ function discoverPolicyFiles(dir) {
|
|
|
13761
13792
|
}
|
|
13762
13793
|
}
|
|
13763
13794
|
function findSkippedPolicyFiles(dir) {
|
|
13764
|
-
if (!
|
|
13795
|
+
if (!existsSync9(dir))
|
|
13765
13796
|
return [];
|
|
13766
13797
|
try {
|
|
13767
13798
|
return readdirSync3(dir, { withFileTypes: true }).filter((e) => e.isFile() && LOADABLE_EXT_RE.test(e.name) && !CONVENTION_FILE_RE.test(e.name) && !e.name.endsWith(".d.ts") && !isTmpArtifact(e.name)).map((e) => e.name).sort((a, b) => a.localeCompare(b));
|
|
@@ -13848,7 +13879,7 @@ async function loadCustomHooks(customPoliciesPath, opts) {
|
|
|
13848
13879
|
if (!customPoliciesPath)
|
|
13849
13880
|
return [];
|
|
13850
13881
|
const absPath = isAbsolute2(customPoliciesPath) ? customPoliciesPath : resolve10(opts?.sessionCwd ?? process.cwd(), customPoliciesPath);
|
|
13851
|
-
if (!
|
|
13882
|
+
if (!existsSync9(absPath)) {
|
|
13852
13883
|
if (opts?.strict)
|
|
13853
13884
|
throw new Error(`Custom hooks file not found: ${absPath}`);
|
|
13854
13885
|
hookLogWarn(`customPoliciesPath not found: ${absPath}`);
|
|
@@ -13934,7 +13965,7 @@ async function loadAllCustomHooks(customPoliciesPaths, opts) {
|
|
|
13934
13965
|
const absPath = resolve10(projectRoot, customPoliciesPath);
|
|
13935
13966
|
const cloudManaged = cloudManagedByPath.get(absPath);
|
|
13936
13967
|
const pack = packByPath.get(absPath);
|
|
13937
|
-
if (
|
|
13968
|
+
if (existsSync9(absPath)) {
|
|
13938
13969
|
if (!loadedPaths.has(absPath)) {
|
|
13939
13970
|
loadedPaths.add(absPath);
|
|
13940
13971
|
const hooksBefore = getCustomHooks().length;
|
|
@@ -15002,7 +15033,7 @@ var init_pack_cli = __esm(() => {
|
|
|
15002
15033
|
|
|
15003
15034
|
// src/hooks/pack-store.ts
|
|
15004
15035
|
import { createHash as createHash5 } from "node:crypto";
|
|
15005
|
-
import { existsSync as
|
|
15036
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync as renameSync3, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "node:fs";
|
|
15006
15037
|
import { dirname as dirname7, resolve as resolve11 } from "node:path";
|
|
15007
15038
|
function baseUrl() {
|
|
15008
15039
|
return (process.env.FAILPROOFAI_PACK_BASE_URL || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
@@ -15352,7 +15383,7 @@ async function addPack(source, opts) {
|
|
|
15352
15383
|
const root = packsRoot();
|
|
15353
15384
|
const artifactRel = `artifacts/${fetched.artifactDigest}.mjs`;
|
|
15354
15385
|
const artifactAbs = resolve11(root, artifactRel);
|
|
15355
|
-
if (!
|
|
15386
|
+
if (!existsSync10(artifactAbs))
|
|
15356
15387
|
writeAtomic(artifactAbs, fetched.artifact);
|
|
15357
15388
|
try {
|
|
15358
15389
|
await verifyArtifactRegisters(artifactAbs, available);
|
|
@@ -15395,7 +15426,7 @@ async function addPack(source, opts) {
|
|
|
15395
15426
|
}
|
|
15396
15427
|
function setPackPolicyEnabled(packId, name, on) {
|
|
15397
15428
|
const manifestPath = resolve11(packsRoot(), "installed.json");
|
|
15398
|
-
if (!
|
|
15429
|
+
if (!existsSync10(manifestPath))
|
|
15399
15430
|
return { ok: false, reason: "no packs are installed" };
|
|
15400
15431
|
let raw;
|
|
15401
15432
|
try {
|
|
@@ -15429,7 +15460,7 @@ function bareId(value) {
|
|
|
15429
15460
|
}
|
|
15430
15461
|
function removePack(id) {
|
|
15431
15462
|
const manifestPath = resolve11(packsRoot(), "installed.json");
|
|
15432
|
-
if (!
|
|
15463
|
+
if (!existsSync10(manifestPath))
|
|
15433
15464
|
return null;
|
|
15434
15465
|
let raw;
|
|
15435
15466
|
try {
|
|
@@ -15454,7 +15485,7 @@ function removePack(id) {
|
|
|
15454
15485
|
function upsertInstalled(record, carryAbsorbedSelection = true) {
|
|
15455
15486
|
const manifestPath = resolve11(packsRoot(), "installed.json");
|
|
15456
15487
|
let packs = [];
|
|
15457
|
-
if (
|
|
15488
|
+
if (existsSync10(manifestPath)) {
|
|
15458
15489
|
try {
|
|
15459
15490
|
const raw = JSON.parse(readFileSync6(manifestPath, "utf8"));
|
|
15460
15491
|
if (Array.isArray(raw.packs))
|
|
@@ -16300,13 +16331,13 @@ import {
|
|
|
16300
16331
|
renameSync as renameSync4,
|
|
16301
16332
|
readdirSync as readdirSync4,
|
|
16302
16333
|
mkdirSync as mkdirSync6,
|
|
16303
|
-
existsSync as
|
|
16334
|
+
existsSync as existsSync11,
|
|
16304
16335
|
statSync as statSync5,
|
|
16305
16336
|
unlinkSync as unlinkSync2
|
|
16306
16337
|
} from "node:fs";
|
|
16307
16338
|
import { join as join6 } from "node:path";
|
|
16308
16339
|
function ensureDir() {
|
|
16309
|
-
if (!
|
|
16340
|
+
if (!existsSync11(storeDirValue())) {
|
|
16310
16341
|
mkdirSync6(storeDirValue(), { recursive: true });
|
|
16311
16342
|
}
|
|
16312
16343
|
}
|
|
@@ -16429,7 +16460,7 @@ function rebuildHookActivityStats() {
|
|
|
16429
16460
|
let sawAny = false;
|
|
16430
16461
|
for (const file of files) {
|
|
16431
16462
|
const path = join6(storeDirValue(), file);
|
|
16432
|
-
if (!
|
|
16463
|
+
if (!existsSync11(path))
|
|
16433
16464
|
continue;
|
|
16434
16465
|
sawAny = true;
|
|
16435
16466
|
for (const entry of readJsonlFile(path))
|
|
@@ -16498,7 +16529,7 @@ var init_hook_activity_store = __esm(() => {
|
|
|
16498
16529
|
});
|
|
16499
16530
|
|
|
16500
16531
|
// src/hooks/delivery-health.ts
|
|
16501
|
-
import { existsSync as
|
|
16532
|
+
import { existsSync as existsSync12, readdirSync as readdirSync5, statSync as statSync6 } from "node:fs";
|
|
16502
16533
|
import { join as join7 } from "node:path";
|
|
16503
16534
|
function parseParkedName(name) {
|
|
16504
16535
|
const poison = name.endsWith(POISON_SUFFIX);
|
|
@@ -16527,7 +16558,7 @@ function parseParkedName(name) {
|
|
|
16527
16558
|
}
|
|
16528
16559
|
function deliveryHealth(home, now = Date.now()) {
|
|
16529
16560
|
const dir = failedDir(home);
|
|
16530
|
-
if (!
|
|
16561
|
+
if (!existsSync12(dir))
|
|
16531
16562
|
return EMPTY;
|
|
16532
16563
|
let entries;
|
|
16533
16564
|
try {
|
|
@@ -17292,7 +17323,7 @@ var init_cursor_projects = __esm(() => {
|
|
|
17292
17323
|
});
|
|
17293
17324
|
|
|
17294
17325
|
// lib/sqlite-reader.ts
|
|
17295
|
-
import { existsSync as
|
|
17326
|
+
import { existsSync as existsSync13, readFileSync as readFileSync8, statSync as statSync7 } from "node:fs";
|
|
17296
17327
|
import initSqlJs from "sql.js/dist/sql-asm.js";
|
|
17297
17328
|
async function tryNodeSqlite(dbPath) {
|
|
17298
17329
|
try {
|
|
@@ -17450,7 +17481,7 @@ async function trySqlJs(dbPath) {
|
|
|
17450
17481
|
}
|
|
17451
17482
|
}
|
|
17452
17483
|
async function openSqliteReadonly(dbPath, options = {}) {
|
|
17453
|
-
if (!
|
|
17484
|
+
if (!existsSync13(dbPath))
|
|
17454
17485
|
return null;
|
|
17455
17486
|
if (!options.forcePortable) {
|
|
17456
17487
|
const native = await tryNodeSqlite(dbPath);
|
|
@@ -18111,7 +18142,7 @@ var init_hermes_projects = __esm(() => {
|
|
|
18111
18142
|
});
|
|
18112
18143
|
|
|
18113
18144
|
// lib/openclaw-db.ts
|
|
18114
|
-
import { existsSync as
|
|
18145
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
18115
18146
|
import { join as join15 } from "node:path";
|
|
18116
18147
|
function str(value) {
|
|
18117
18148
|
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
@@ -18131,7 +18162,7 @@ function listOpenClawDatabases(home, agentIds) {
|
|
|
18131
18162
|
const out = [];
|
|
18132
18163
|
for (const agentId of agentIds) {
|
|
18133
18164
|
const dbPath = join15(home, "agents", agentId, "agent", DB_NAME);
|
|
18134
|
-
if (
|
|
18165
|
+
if (existsSync14(dbPath))
|
|
18135
18166
|
out.push({ agentId, dbPath });
|
|
18136
18167
|
}
|
|
18137
18168
|
return out;
|
|
@@ -20317,13 +20348,13 @@ var init_log_entries = __esm(() => {
|
|
|
20317
20348
|
});
|
|
20318
20349
|
|
|
20319
20350
|
// lib/codex-sessions.ts
|
|
20320
|
-
import { readFileSync as readFileSync10, readdirSync as readdirSync9, existsSync as
|
|
20351
|
+
import { readFileSync as readFileSync10, readdirSync as readdirSync9, existsSync as existsSync15, writeFileSync as writeFileSync6, mkdirSync as mkdirSync7, statSync as statSync11 } from "node:fs";
|
|
20321
20352
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
20322
20353
|
import { dirname as dirname8, join as join26 } from "node:path";
|
|
20323
20354
|
import { homedir as homedir18 } from "node:os";
|
|
20324
20355
|
function readCache() {
|
|
20325
20356
|
try {
|
|
20326
|
-
if (!
|
|
20357
|
+
if (!existsSync15(CACHE_PATH))
|
|
20327
20358
|
return {};
|
|
20328
20359
|
return JSON.parse(readFileSync10(CACHE_PATH, "utf-8"));
|
|
20329
20360
|
} catch {
|
|
@@ -20351,7 +20382,7 @@ function dirSearch(dir, sessionId) {
|
|
|
20351
20382
|
function findCodexTranscript(sessionId) {
|
|
20352
20383
|
const cache = readCache();
|
|
20353
20384
|
const cached = cache[sessionId];
|
|
20354
|
-
if (cached &&
|
|
20385
|
+
if (cached && existsSync15(cached))
|
|
20355
20386
|
return cached;
|
|
20356
20387
|
const root = join26(homedir18(), ".codex", "sessions");
|
|
20357
20388
|
const today = new Date;
|
|
@@ -20645,7 +20676,7 @@ var init_resolve_permission_mode = __esm(() => {
|
|
|
20645
20676
|
});
|
|
20646
20677
|
|
|
20647
20678
|
// lib/copilot-sessions.ts
|
|
20648
|
-
import { readFileSync as readFileSync12, readdirSync as readdirSync10, existsSync as
|
|
20679
|
+
import { readFileSync as readFileSync12, readdirSync as readdirSync10, existsSync as existsSync16, statSync as statSync12 } from "node:fs";
|
|
20649
20680
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
20650
20681
|
import { join as join27, resolve as resolve13, sep as sep2 } from "node:path";
|
|
20651
20682
|
import { homedir as homedir19 } from "node:os";
|
|
@@ -20674,13 +20705,13 @@ function findCopilotTranscript(sessionId) {
|
|
|
20674
20705
|
const candidate = resolveSessionFile(sessionId, "events.jsonl");
|
|
20675
20706
|
if (!candidate)
|
|
20676
20707
|
return null;
|
|
20677
|
-
return
|
|
20708
|
+
return existsSync16(candidate) ? candidate : null;
|
|
20678
20709
|
}
|
|
20679
20710
|
function findCopilotWorkspace(sessionId) {
|
|
20680
20711
|
const candidate = resolveSessionFile(sessionId, "workspace.yaml");
|
|
20681
20712
|
if (!candidate)
|
|
20682
20713
|
return null;
|
|
20683
|
-
return
|
|
20714
|
+
return existsSync16(candidate) ? candidate : null;
|
|
20684
20715
|
}
|
|
20685
20716
|
function readYamlScalar(path, key) {
|
|
20686
20717
|
try {
|
|
@@ -20862,7 +20893,7 @@ var init_copilot_sessions = __esm(() => {
|
|
|
20862
20893
|
});
|
|
20863
20894
|
|
|
20864
20895
|
// lib/cursor-sessions.ts
|
|
20865
|
-
import { readFileSync as readFileSync13, readdirSync as readdirSync11, existsSync as
|
|
20896
|
+
import { readFileSync as readFileSync13, readdirSync as readdirSync11, existsSync as existsSync17, statSync as statSync13 } from "node:fs";
|
|
20866
20897
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
20867
20898
|
import { basename as basename4, join as join28, resolve as resolve14, sep as sep3 } from "node:path";
|
|
20868
20899
|
import { homedir as homedir20 } from "node:os";
|
|
@@ -20885,7 +20916,7 @@ function getCursorSessionDir(sessionId) {
|
|
|
20885
20916
|
const transcriptRoot = resolve14(projectsRoot, entry.name, NEW_AGENT_TRANSCRIPTS_DIR2);
|
|
20886
20917
|
if (candidate === transcriptRoot || !candidate.startsWith(`${transcriptRoot}${sep3}`))
|
|
20887
20918
|
continue;
|
|
20888
|
-
if (
|
|
20919
|
+
if (existsSync17(candidate))
|
|
20889
20920
|
return candidate;
|
|
20890
20921
|
}
|
|
20891
20922
|
for (const sub of LEGACY_SESSION_ROOT_CANDIDATES2) {
|
|
@@ -20893,7 +20924,7 @@ function getCursorSessionDir(sessionId) {
|
|
|
20893
20924
|
const candidate = resolve14(root, sessionId);
|
|
20894
20925
|
if (candidate === root || !candidate.startsWith(`${root}${sep3}`))
|
|
20895
20926
|
continue;
|
|
20896
|
-
if (
|
|
20927
|
+
if (existsSync17(candidate))
|
|
20897
20928
|
return candidate;
|
|
20898
20929
|
}
|
|
20899
20930
|
return null;
|
|
@@ -20903,11 +20934,11 @@ function findCursorTranscript(sessionId) {
|
|
|
20903
20934
|
if (!dir)
|
|
20904
20935
|
return null;
|
|
20905
20936
|
const newCandidate = join28(dir, `${basename4(dir)}.jsonl`);
|
|
20906
|
-
if (
|
|
20937
|
+
if (existsSync17(newCandidate))
|
|
20907
20938
|
return newCandidate;
|
|
20908
20939
|
for (const name of LEGACY_TRANSCRIPT_FILE_CANDIDATES2) {
|
|
20909
20940
|
const candidate = join28(dir, name);
|
|
20910
|
-
if (
|
|
20941
|
+
if (existsSync17(candidate))
|
|
20911
20942
|
return candidate;
|
|
20912
20943
|
}
|
|
20913
20944
|
return null;
|
|
@@ -21118,7 +21149,7 @@ var init_cursor_sessions = __esm(() => {
|
|
|
21118
21149
|
});
|
|
21119
21150
|
|
|
21120
21151
|
// lib/pi-sessions.ts
|
|
21121
|
-
import { readFileSync as readFileSync14, readdirSync as readdirSync12, existsSync as
|
|
21152
|
+
import { readFileSync as readFileSync14, readdirSync as readdirSync12, existsSync as existsSync18, statSync as statSync14 } from "node:fs";
|
|
21122
21153
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
21123
21154
|
import { join as join29, resolve as resolve15, sep as sep4 } from "node:path";
|
|
21124
21155
|
import { homedir as homedir21 } from "node:os";
|
|
@@ -21155,7 +21186,7 @@ function findPiTranscript(sessionId) {
|
|
|
21155
21186
|
const candidate = resolve15(cwdPath, f);
|
|
21156
21187
|
if (!candidate.startsWith(`${cwdPath}${sep4}`))
|
|
21157
21188
|
continue;
|
|
21158
|
-
if (
|
|
21189
|
+
if (existsSync18(candidate))
|
|
21159
21190
|
return candidate;
|
|
21160
21191
|
}
|
|
21161
21192
|
}
|
|
@@ -21561,7 +21592,7 @@ var init_pack_failclosed = __esm(() => {
|
|
|
21561
21592
|
// lib/atomic-write.ts
|
|
21562
21593
|
import {
|
|
21563
21594
|
chmodSync as chmodSync2,
|
|
21564
|
-
existsSync as
|
|
21595
|
+
existsSync as existsSync19,
|
|
21565
21596
|
mkdirSync as mkdirSync8,
|
|
21566
21597
|
renameSync as renameSync5,
|
|
21567
21598
|
rmSync as rmSync4,
|
|
@@ -21574,7 +21605,7 @@ function writeJsonAtomically(filePath, value, opts = {}) {
|
|
|
21574
21605
|
const mode = opts.mode ?? 384;
|
|
21575
21606
|
const dirMode = opts.dirMode ?? 448;
|
|
21576
21607
|
const dir = dirname9(filePath);
|
|
21577
|
-
if (!
|
|
21608
|
+
if (!existsSync19(dir))
|
|
21578
21609
|
mkdirSync8(dir, { recursive: true, mode: dirMode });
|
|
21579
21610
|
const tmp = `${filePath}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
21580
21611
|
try {
|
|
@@ -21598,7 +21629,7 @@ function writeJsonAtomically(filePath, value, opts = {}) {
|
|
|
21598
21629
|
var init_atomic_write = () => {};
|
|
21599
21630
|
|
|
21600
21631
|
// src/hooks/session-pause.ts
|
|
21601
|
-
import { existsSync as
|
|
21632
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync9, readdirSync as readdirSync13, readFileSync as readFileSync15, rmSync as rmSync5 } from "node:fs";
|
|
21602
21633
|
import { createHash as createHash6 } from "node:crypto";
|
|
21603
21634
|
import { join as join30, resolve as resolve16 } from "node:path";
|
|
21604
21635
|
function pauseStateDir() {
|
|
@@ -21665,7 +21696,7 @@ function readActivePause(sessionId, now = Date.now()) {
|
|
|
21665
21696
|
return null;
|
|
21666
21697
|
try {
|
|
21667
21698
|
const path = pauseFilePath(sessionId);
|
|
21668
|
-
if (!
|
|
21699
|
+
if (!existsSync20(path))
|
|
21669
21700
|
return null;
|
|
21670
21701
|
const stored = parseStored(JSON.parse(readFileSync15(path, "utf8")));
|
|
21671
21702
|
if (!stored)
|
|
@@ -21696,7 +21727,7 @@ function writePause(opts) {
|
|
|
21696
21727
|
}
|
|
21697
21728
|
function clearPause(sessionId) {
|
|
21698
21729
|
const path = pauseFilePath(sessionId);
|
|
21699
|
-
if (!
|
|
21730
|
+
if (!existsSync20(path))
|
|
21700
21731
|
return false;
|
|
21701
21732
|
try {
|
|
21702
21733
|
rmSync5(path);
|
|
@@ -21707,7 +21738,7 @@ function clearPause(sessionId) {
|
|
|
21707
21738
|
}
|
|
21708
21739
|
function listActivePauses(now = Date.now()) {
|
|
21709
21740
|
const dir = pauseStateDir();
|
|
21710
|
-
if (!
|
|
21741
|
+
if (!existsSync20(dir))
|
|
21711
21742
|
return [];
|
|
21712
21743
|
const out = [];
|
|
21713
21744
|
let names;
|
|
@@ -21761,7 +21792,7 @@ var init_session_pause = __esm(() => {
|
|
|
21761
21792
|
import { createHash as createHash7 } from "node:crypto";
|
|
21762
21793
|
import {
|
|
21763
21794
|
chmodSync as chmodSync3,
|
|
21764
|
-
existsSync as
|
|
21795
|
+
existsSync as existsSync21,
|
|
21765
21796
|
mkdirSync as mkdirSync10,
|
|
21766
21797
|
readdirSync as readdirSync14,
|
|
21767
21798
|
readFileSync as readFileSync16,
|
|
@@ -21813,7 +21844,7 @@ function platformPackageBinary(dir) {
|
|
|
21813
21844
|
return null;
|
|
21814
21845
|
}
|
|
21815
21846
|
const candidate = resolve17(dir, "bin", "failproofaid");
|
|
21816
|
-
return
|
|
21847
|
+
return existsSync21(candidate) ? candidate : null;
|
|
21817
21848
|
}
|
|
21818
21849
|
function pruneOldDaemonBinaries(keep = 2) {
|
|
21819
21850
|
const removed = [];
|
|
@@ -21891,7 +21922,7 @@ function digestFor2(manifest, assetName) {
|
|
|
21891
21922
|
}
|
|
21892
21923
|
async function downloadFailproofaidBinary(key) {
|
|
21893
21924
|
const target = installedBinaryPath();
|
|
21894
|
-
if (
|
|
21925
|
+
if (existsSync21(target))
|
|
21895
21926
|
return { path: target };
|
|
21896
21927
|
if (process.env.FAILPROOFAI_NO_DOWNLOAD) {
|
|
21897
21928
|
return { error: "daemon downloads are disabled (FAILPROOFAI_NO_DOWNLOAD)" };
|
|
@@ -21925,10 +21956,10 @@ var init_daemon_download = __esm(() => {
|
|
|
21925
21956
|
|
|
21926
21957
|
// src/hooks/daemon-client.ts
|
|
21927
21958
|
import { createConnection as createConnection2 } from "node:net";
|
|
21928
|
-
import { existsSync as
|
|
21959
|
+
import { existsSync as existsSync22 } from "node:fs";
|
|
21929
21960
|
function daemonSocketPresent() {
|
|
21930
21961
|
try {
|
|
21931
|
-
return
|
|
21962
|
+
return existsSync22(socketPath2());
|
|
21932
21963
|
} catch {
|
|
21933
21964
|
return false;
|
|
21934
21965
|
}
|
|
@@ -22054,7 +22085,7 @@ var init_daemon_client2 = __esm(() => {
|
|
|
22054
22085
|
|
|
22055
22086
|
// src/hooks/daemon-service.ts
|
|
22056
22087
|
import {
|
|
22057
|
-
existsSync as
|
|
22088
|
+
existsSync as existsSync23,
|
|
22058
22089
|
mkdirSync as mkdirSync11,
|
|
22059
22090
|
mkdtempSync,
|
|
22060
22091
|
readFileSync as readFileSync17,
|
|
@@ -22085,13 +22116,13 @@ function resolveFailproofaidBinaryPath() {
|
|
|
22085
22116
|
if (process.env.FAILPROOFAI_DAEMON_BINARY)
|
|
22086
22117
|
return process.env.FAILPROOFAI_DAEMON_BINARY;
|
|
22087
22118
|
const downloaded = installedBinaryPath();
|
|
22088
|
-
if (
|
|
22119
|
+
if (existsSync23(downloaded))
|
|
22089
22120
|
return downloaded;
|
|
22090
22121
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
22091
22122
|
if (packageRoot) {
|
|
22092
22123
|
for (const profile of ["release", "debug"]) {
|
|
22093
22124
|
const candidate = resolve18(packageRoot, "target", profile, "failproofaid");
|
|
22094
|
-
if (
|
|
22125
|
+
if (existsSync23(candidate))
|
|
22095
22126
|
return candidate;
|
|
22096
22127
|
}
|
|
22097
22128
|
}
|
|
@@ -22122,7 +22153,7 @@ function resolveWorkerCommand() {
|
|
|
22122
22153
|
if (!packageRoot)
|
|
22123
22154
|
return null;
|
|
22124
22155
|
const workerScript = resolve18(packageRoot, "dist", "worker.mjs");
|
|
22125
|
-
if (!
|
|
22156
|
+
if (!existsSync23(workerScript))
|
|
22126
22157
|
return null;
|
|
22127
22158
|
return `${shellQuote(process.execPath)} ${shellQuote(workerScript)}`;
|
|
22128
22159
|
}
|
|
@@ -22133,7 +22164,7 @@ function resolveCliCommand() {
|
|
|
22133
22164
|
if (!packageRoot)
|
|
22134
22165
|
return null;
|
|
22135
22166
|
const cliScript = resolve18(packageRoot, "dist", "cli.mjs");
|
|
22136
|
-
if (!
|
|
22167
|
+
if (!existsSync23(cliScript))
|
|
22137
22168
|
return null;
|
|
22138
22169
|
return `${shellQuote(process.execPath)} ${shellQuote(cliScript)}`;
|
|
22139
22170
|
}
|
|
@@ -22147,7 +22178,7 @@ function workerScriptPath() {
|
|
|
22147
22178
|
if (!packageRoot)
|
|
22148
22179
|
return null;
|
|
22149
22180
|
const workerScript = resolve18(packageRoot, "dist", "worker.mjs");
|
|
22150
|
-
return
|
|
22181
|
+
return existsSync23(workerScript) ? workerScript : null;
|
|
22151
22182
|
}
|
|
22152
22183
|
function assertUnitSafe(value, field) {
|
|
22153
22184
|
if (UNIT_UNSAFE_RE.test(value)) {
|
|
@@ -22246,7 +22277,7 @@ function removeLegacyUserService() {
|
|
|
22246
22277
|
try {
|
|
22247
22278
|
if (process.platform === "linux") {
|
|
22248
22279
|
const legacy = legacySystemdUserUnitPath();
|
|
22249
|
-
if (!
|
|
22280
|
+
if (!existsSync23(legacy))
|
|
22250
22281
|
return;
|
|
22251
22282
|
try {
|
|
22252
22283
|
execFileSync2("systemctl", ["--user", "disable", "--now", "failproofaid.service"], {
|
|
@@ -22263,7 +22294,7 @@ function removeLegacyUserService() {
|
|
|
22263
22294
|
} catch {}
|
|
22264
22295
|
} else {
|
|
22265
22296
|
const legacyAgent = legacyLaunchAgentPlistPath();
|
|
22266
|
-
if (
|
|
22297
|
+
if (existsSync23(legacyAgent)) {
|
|
22267
22298
|
try {
|
|
22268
22299
|
execFileSync2("launchctl", ["unload", "-w", legacyAgent], {
|
|
22269
22300
|
stdio: "ignore",
|
|
@@ -22273,7 +22304,7 @@ function removeLegacyUserService() {
|
|
|
22273
22304
|
unlinkSync3(legacyAgent);
|
|
22274
22305
|
}
|
|
22275
22306
|
const legacyDaemon = legacySharedLaunchDaemonPath();
|
|
22276
|
-
if (
|
|
22307
|
+
if (existsSync23(legacyDaemon)) {
|
|
22277
22308
|
try {
|
|
22278
22309
|
runPrivileged("launchctl", ["unload", "-w", legacyDaemon]);
|
|
22279
22310
|
} catch {}
|
|
@@ -22290,7 +22321,7 @@ function systemdUnitContents(binaryPath, workerCmd, cliCmd = null) {
|
|
|
22290
22321
|
const user = assertUnitSafe(serviceUser(), "User");
|
|
22291
22322
|
assertUnitSafe(binaryPath, "ExecStart");
|
|
22292
22323
|
assertUnitSafe(homedir22(), "HOME");
|
|
22293
|
-
const conditionPaths = [binaryPath, workerScriptPath()].filter((p) => typeof p === "string" &&
|
|
22324
|
+
const conditionPaths = [binaryPath, workerScriptPath()].filter((p) => typeof p === "string" && existsSync23(p));
|
|
22294
22325
|
const conditionLines = conditionPaths.map((p) => `ConditionPathExists=${assertUnitSafe(p, "ConditionPathExists")}
|
|
22295
22326
|
`).join("");
|
|
22296
22327
|
return `[Unit]
|
|
@@ -22485,7 +22516,7 @@ function readInstalledServiceDefinition() {
|
|
|
22485
22516
|
if (!isDaemonSupportedPlatform())
|
|
22486
22517
|
return null;
|
|
22487
22518
|
const path = daemonServiceFilePath();
|
|
22488
|
-
if (!path || !
|
|
22519
|
+
if (!path || !existsSync23(path))
|
|
22489
22520
|
return null;
|
|
22490
22521
|
try {
|
|
22491
22522
|
return readFileSync17(path, "utf8");
|
|
@@ -22621,7 +22652,7 @@ async function uninstallDaemonService() {
|
|
|
22621
22652
|
try {
|
|
22622
22653
|
if (process.platform === "linux") {
|
|
22623
22654
|
const unitPath = systemdUnitPath();
|
|
22624
|
-
if (!
|
|
22655
|
+
if (!existsSync23(unitPath))
|
|
22625
22656
|
return;
|
|
22626
22657
|
try {
|
|
22627
22658
|
runPrivileged("systemctl", ["disable", "--now", systemdUnitName()]);
|
|
@@ -22632,7 +22663,7 @@ async function uninstallDaemonService() {
|
|
|
22632
22663
|
} catch {}
|
|
22633
22664
|
} else {
|
|
22634
22665
|
const plistPath = launchdPlistPath();
|
|
22635
|
-
if (!
|
|
22666
|
+
if (!existsSync23(plistPath))
|
|
22636
22667
|
return;
|
|
22637
22668
|
try {
|
|
22638
22669
|
runPrivileged("launchctl", ["unload", "-w", plistPath]);
|
|
@@ -22649,7 +22680,7 @@ function daemonVersionSkew() {
|
|
|
22649
22680
|
const recorded = readVersionFile()?.daemon;
|
|
22650
22681
|
if (!recorded)
|
|
22651
22682
|
return null;
|
|
22652
|
-
if (!
|
|
22683
|
+
if (!existsSync23(installedBinaryPath(recorded)))
|
|
22653
22684
|
return null;
|
|
22654
22685
|
return recorded === version2 ? null : { installed: recorded, expected: version2 };
|
|
22655
22686
|
}
|
|
@@ -22667,7 +22698,7 @@ function daemonServiceStatus() {
|
|
|
22667
22698
|
if (!isDaemonSupportedPlatform())
|
|
22668
22699
|
return "unsupported-platform";
|
|
22669
22700
|
if (process.platform === "linux") {
|
|
22670
|
-
if (!
|
|
22701
|
+
if (!existsSync23(systemdUnitPath()))
|
|
22671
22702
|
return "not-installed";
|
|
22672
22703
|
try {
|
|
22673
22704
|
const out = execFileSync2("systemctl", ["is-active", systemdUnitName()], {
|
|
@@ -22680,7 +22711,7 @@ function daemonServiceStatus() {
|
|
|
22680
22711
|
}
|
|
22681
22712
|
}
|
|
22682
22713
|
const plistPath = launchdPlistPath();
|
|
22683
|
-
if (!
|
|
22714
|
+
if (!existsSync23(plistPath))
|
|
22684
22715
|
return "not-installed";
|
|
22685
22716
|
try {
|
|
22686
22717
|
const root = typeof process.getuid === "function" && process.getuid() === 0;
|
|
@@ -22712,7 +22743,7 @@ var init_daemon_service = __esm(() => {
|
|
|
22712
22743
|
// src/hooks/fp-reset.ts
|
|
22713
22744
|
import {
|
|
22714
22745
|
copyFileSync,
|
|
22715
|
-
existsSync as
|
|
22746
|
+
existsSync as existsSync24,
|
|
22716
22747
|
mkdirSync as mkdirSync12,
|
|
22717
22748
|
readFileSync as readFileSync18,
|
|
22718
22749
|
readdirSync as readdirSync15,
|
|
@@ -22725,7 +22756,7 @@ import {
|
|
|
22725
22756
|
import { dirname as dirname11, isAbsolute as isAbsolute3, relative as relative4, resolve as resolve19 } from "node:path";
|
|
22726
22757
|
function migrateConventionPolicies() {
|
|
22727
22758
|
const from = legacy.customPoliciesDir();
|
|
22728
|
-
if (!
|
|
22759
|
+
if (!existsSync24(from))
|
|
22729
22760
|
return [];
|
|
22730
22761
|
const moved = [];
|
|
22731
22762
|
const mergeInto = (dir, dest, prefix) => {
|
|
@@ -22746,7 +22777,7 @@ function migrateConventionPolicies() {
|
|
|
22746
22777
|
const source = resolve19(dir, entry.name);
|
|
22747
22778
|
const target = resolve19(dest, entry.name);
|
|
22748
22779
|
const name = `${prefix}${entry.name}`;
|
|
22749
|
-
if (!
|
|
22780
|
+
if (!existsSync24(target)) {
|
|
22750
22781
|
try {
|
|
22751
22782
|
renameSync7(source, target);
|
|
22752
22783
|
moved.push(name);
|
|
@@ -22773,7 +22804,7 @@ function migrateLegacySpool() {
|
|
|
22773
22804
|
[legacy.spoolDir(), spoolDir()],
|
|
22774
22805
|
[legacy.failedDir(), failedDir()]
|
|
22775
22806
|
]) {
|
|
22776
|
-
if (!
|
|
22807
|
+
if (!existsSync24(from))
|
|
22777
22808
|
continue;
|
|
22778
22809
|
try {
|
|
22779
22810
|
mkdirSync12(to, { recursive: true });
|
|
@@ -22782,7 +22813,7 @@ function migrateLegacySpool() {
|
|
|
22782
22813
|
continue;
|
|
22783
22814
|
let name = entry.name;
|
|
22784
22815
|
let n = 0;
|
|
22785
|
-
while (
|
|
22816
|
+
while (existsSync24(resolve19(to, name)))
|
|
22786
22817
|
name = `legacy-${n++}-${entry.name}`;
|
|
22787
22818
|
try {
|
|
22788
22819
|
renameSync7(resolve19(from, entry.name), resolve19(to, name));
|
|
@@ -22800,7 +22831,7 @@ function migrateLegacySpool() {
|
|
|
22800
22831
|
}
|
|
22801
22832
|
function migrateHookActivity() {
|
|
22802
22833
|
const from = legacy.hookActivityDir();
|
|
22803
|
-
if (!
|
|
22834
|
+
if (!existsSync24(from))
|
|
22804
22835
|
return [];
|
|
22805
22836
|
const moved = [];
|
|
22806
22837
|
try {
|
|
@@ -22815,7 +22846,7 @@ function migrateHookActivity() {
|
|
|
22815
22846
|
const source = resolve19(from, entry.name);
|
|
22816
22847
|
let name = entry.name === "current.jsonl" ? `page-${stamp}-${seq++}.jsonl` : entry.name;
|
|
22817
22848
|
let target = resolve19(to, name);
|
|
22818
|
-
while (
|
|
22849
|
+
while (existsSync24(target)) {
|
|
22819
22850
|
name = `page-${stamp}-${seq++}.jsonl`;
|
|
22820
22851
|
target = resolve19(to, name);
|
|
22821
22852
|
}
|
|
@@ -22866,7 +22897,7 @@ function retirePolicyConfigKeys() {
|
|
|
22866
22897
|
}
|
|
22867
22898
|
function readCarriedPolicyConfig() {
|
|
22868
22899
|
const from = resolve19(legacy.localPoliciesDir(), "policies-config.json");
|
|
22869
|
-
if (!
|
|
22900
|
+
if (!existsSync24(from))
|
|
22870
22901
|
return null;
|
|
22871
22902
|
let parsed;
|
|
22872
22903
|
try {
|
|
@@ -22930,7 +22961,7 @@ function writeCarriedPolicyConfig(carried) {
|
|
|
22930
22961
|
}
|
|
22931
22962
|
function readCarriedTelemetryOptOut() {
|
|
22932
22963
|
const from = legacy.configToml();
|
|
22933
|
-
if (!
|
|
22964
|
+
if (!existsSync24(from))
|
|
22934
22965
|
return false;
|
|
22935
22966
|
try {
|
|
22936
22967
|
const text = readFileSync18(from, "utf8");
|
|
@@ -22985,7 +23016,7 @@ function parseLegacyToml(text) {
|
|
|
22985
23016
|
}
|
|
22986
23017
|
function readCarriedLegacyConfig() {
|
|
22987
23018
|
const from = legacy.configToml();
|
|
22988
|
-
if (!
|
|
23019
|
+
if (!existsSync24(from))
|
|
22989
23020
|
return null;
|
|
22990
23021
|
try {
|
|
22991
23022
|
return projectConfig(parseLegacyToml(readFileSync18(from, "utf8")));
|
|
@@ -22995,7 +23026,7 @@ function readCarriedLegacyConfig() {
|
|
|
22995
23026
|
}
|
|
22996
23027
|
function readCarriedLegacyCredentials() {
|
|
22997
23028
|
const toml = legacy.credentialsToml();
|
|
22998
|
-
if (
|
|
23029
|
+
if (existsSync24(toml)) {
|
|
22999
23030
|
try {
|
|
23000
23031
|
const creds = projectCredentials(parseLegacyToml(readFileSync18(toml, "utf8")));
|
|
23001
23032
|
if (Object.keys(creds).length > 0)
|
|
@@ -23038,7 +23069,7 @@ function resetHome(from, to = LAYOUT_VERSION) {
|
|
|
23038
23069
|
const spooled = migrateLegacySpool();
|
|
23039
23070
|
const removed = [];
|
|
23040
23071
|
for (const path of resettablePaths()) {
|
|
23041
|
-
if (!
|
|
23072
|
+
if (!existsSync24(path))
|
|
23042
23073
|
continue;
|
|
23043
23074
|
try {
|
|
23044
23075
|
rmSync8(path, { recursive: true, force: true });
|
|
@@ -23063,7 +23094,7 @@ function layoutWarningForHook() {
|
|
|
23063
23094
|
if (state.kind === "future") {
|
|
23064
23095
|
return `[failproofai] this directory was written by a newer version (layout ${state.found} vs ${LAYOUT_VERSION}) — policies are NOT being enforced. ` + `Upgrade failproofai.`;
|
|
23065
23096
|
}
|
|
23066
|
-
if (
|
|
23097
|
+
if (existsSync24(globalPolicyConfigFile()))
|
|
23067
23098
|
return null;
|
|
23068
23099
|
return `[failproofai] setup predates this version — global policies are NOT being enforced. ` + `Run \`failproofai config\` to re-create it.`;
|
|
23069
23100
|
}
|
|
@@ -24124,14 +24155,14 @@ var init_collector_config = __esm(() => {
|
|
|
24124
24155
|
});
|
|
24125
24156
|
|
|
24126
24157
|
// src/hooks/flush-cli.ts
|
|
24127
|
-
import { existsSync as
|
|
24158
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync13, writeFileSync as writeFileSync11, readdirSync as readdirSync16 } from "node:fs";
|
|
24128
24159
|
import { dirname as dirname12, join as join31 } from "node:path";
|
|
24129
24160
|
function flushRequestPath(home) {
|
|
24130
24161
|
return join31(failproofaiHome(home), "state", "flush-request.json");
|
|
24131
24162
|
}
|
|
24132
24163
|
function spoolDirs(home) {
|
|
24133
24164
|
const root = spoolDir(home);
|
|
24134
|
-
if (!
|
|
24165
|
+
if (!existsSync25(root))
|
|
24135
24166
|
return [];
|
|
24136
24167
|
try {
|
|
24137
24168
|
return readdirSync16(root, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== "failed").map((e) => join31(root, e.name));
|
|
@@ -24235,7 +24266,7 @@ var init_flush_cli = __esm(() => {
|
|
|
24235
24266
|
import {
|
|
24236
24267
|
chmodSync as chmodSync4,
|
|
24237
24268
|
copyFileSync as copyFileSync2,
|
|
24238
|
-
existsSync as
|
|
24269
|
+
existsSync as existsSync26,
|
|
24239
24270
|
mkdirSync as mkdirSync14,
|
|
24240
24271
|
readFileSync as readFileSync19,
|
|
24241
24272
|
renameSync as renameSync8,
|
|
@@ -24258,9 +24289,9 @@ function migrateToLayout4() {
|
|
|
24258
24289
|
}
|
|
24259
24290
|
const migrated = [];
|
|
24260
24291
|
for (const { from, to } of moves) {
|
|
24261
|
-
if (!
|
|
24292
|
+
if (!existsSync26(from))
|
|
24262
24293
|
continue;
|
|
24263
|
-
if (
|
|
24294
|
+
if (existsSync26(to)) {
|
|
24264
24295
|
rmSync9(from, { force: true });
|
|
24265
24296
|
continue;
|
|
24266
24297
|
}
|
|
@@ -24281,7 +24312,7 @@ function migrateToLayout4() {
|
|
|
24281
24312
|
migrated.push(`${basename5(from)} → audit/${basename5(to)}`);
|
|
24282
24313
|
}
|
|
24283
24314
|
for (const secret of [auditSessionFile()]) {
|
|
24284
|
-
if (!
|
|
24315
|
+
if (!existsSync26(secret))
|
|
24285
24316
|
continue;
|
|
24286
24317
|
try {
|
|
24287
24318
|
chmodSync4(secret, 384);
|
|
@@ -24329,10 +24360,10 @@ function pruneMigratedCredentials(from) {
|
|
|
24329
24360
|
for (let layout = from;layout < LAYOUT_VERSION; layout++) {
|
|
24330
24361
|
for (const { as, landsAt } of PRUNED_AFTER_SUCCESS) {
|
|
24331
24362
|
try {
|
|
24332
|
-
if (!
|
|
24363
|
+
if (!existsSync26(landsAt()))
|
|
24333
24364
|
continue;
|
|
24334
24365
|
const copy = resolve20(migrationBackupDir(layout), as);
|
|
24335
|
-
if (!
|
|
24366
|
+
if (!existsSync26(copy))
|
|
24336
24367
|
continue;
|
|
24337
24368
|
rmSync9(copy, { force: true });
|
|
24338
24369
|
pruned.push(as);
|
|
@@ -24345,7 +24376,7 @@ function filesToBackUp() {
|
|
|
24345
24376
|
const seen = new Map;
|
|
24346
24377
|
for (const f of [...BACKED_UP, ...BACKED_UP_LEGACY]) {
|
|
24347
24378
|
const path = f.at();
|
|
24348
|
-
if (
|
|
24379
|
+
if (existsSync26(path))
|
|
24349
24380
|
seen.set(path, backupNameOf(f));
|
|
24350
24381
|
}
|
|
24351
24382
|
return [...seen].map(([path, as]) => ({ path, as }));
|
|
@@ -24735,7 +24766,7 @@ var NAMESPACE3 = "failproofai-telemetry-v1", API_KEY3 = "phc_Ac1Ww1GqKc0z1SyrRWb
|
|
|
24735
24766
|
var init_install_telemetry = () => {};
|
|
24736
24767
|
|
|
24737
24768
|
// lib/install-check.ts
|
|
24738
|
-
import { existsSync as
|
|
24769
|
+
import { existsSync as existsSync27, readFileSync as readFileSync21, writeFileSync as writeFileSync14, mkdirSync as mkdirSync16 } from "node:fs";
|
|
24739
24770
|
import { dirname as dirname14, resolve as resolve21 } from "node:path";
|
|
24740
24771
|
import { platform as platform2, arch as arch2, release, homedir as homedir24, hostname as hostname2 } from "node:os";
|
|
24741
24772
|
import { createHmac as createHmac2 } from "node:crypto";
|
|
@@ -24791,7 +24822,7 @@ function compareSemver(a, b) {
|
|
|
24791
24822
|
}
|
|
24792
24823
|
function checkHooks() {
|
|
24793
24824
|
const hooksConfigPath = globalPolicyConfigFile();
|
|
24794
|
-
if (!
|
|
24825
|
+
if (!existsSync27(hooksConfigPath)) {
|
|
24795
24826
|
return { configured: false, registered: false, policyCount: 0 };
|
|
24796
24827
|
}
|
|
24797
24828
|
let config;
|
|
@@ -24805,7 +24836,7 @@ function checkHooks() {
|
|
|
24805
24836
|
}
|
|
24806
24837
|
const policyCount = config.enabledPolicies.length;
|
|
24807
24838
|
const settingsPath = resolve21(homedir24(), ".claude", "settings.json");
|
|
24808
|
-
if (!
|
|
24839
|
+
if (!existsSync27(settingsPath))
|
|
24809
24840
|
return { configured: true, registered: false, policyCount };
|
|
24810
24841
|
let settings;
|
|
24811
24842
|
try {
|
|
@@ -24833,7 +24864,7 @@ async function maybeReportInstall(version) {
|
|
|
24833
24864
|
const versionFile = lastVersionPath();
|
|
24834
24865
|
let previousVersion = null;
|
|
24835
24866
|
try {
|
|
24836
|
-
if (
|
|
24867
|
+
if (existsSync27(versionFile)) {
|
|
24837
24868
|
previousVersion = readFileSync21(versionFile, "utf8").trim() || null;
|
|
24838
24869
|
}
|
|
24839
24870
|
} catch {}
|
|
@@ -24921,7 +24952,7 @@ var init_cli_error = __esm(() => {
|
|
|
24921
24952
|
|
|
24922
24953
|
// src/hooks/manager.ts
|
|
24923
24954
|
import { execSync as execSync6 } from "node:child_process";
|
|
24924
|
-
import { existsSync as
|
|
24955
|
+
import { existsSync as existsSync28 } from "node:fs";
|
|
24925
24956
|
import { resolve as resolve22, basename as basename6 } from "node:path";
|
|
24926
24957
|
import { platform as platform3, arch as arch3, release as release2, hostname as hostname3 } from "node:os";
|
|
24927
24958
|
function getSettingsPath(scope, cwd) {
|
|
@@ -25108,8 +25139,11 @@ async function installHooksImpl(policyNames, scope = "user", cwd, includeBeta =
|
|
|
25108
25139
|
}
|
|
25109
25140
|
}
|
|
25110
25141
|
const selectedClis = cli && cli.length > 0 ? [...new Set(cli)] : ["claude"];
|
|
25111
|
-
|
|
25112
|
-
|
|
25142
|
+
const selectedIntegrations = selectedClis.map((cliId) => ({
|
|
25143
|
+
cliId,
|
|
25144
|
+
integration: getIntegration(cliId)
|
|
25145
|
+
}));
|
|
25146
|
+
for (const { cliId, integration } of selectedIntegrations) {
|
|
25113
25147
|
if (!integration.scopes.includes(scope)) {
|
|
25114
25148
|
try {
|
|
25115
25149
|
await trackHookEvent2(getInstanceId2(), "scope_validation_failed", {
|
|
@@ -25121,6 +25155,13 @@ async function installHooksImpl(policyNames, scope = "user", cwd, includeBeta =
|
|
|
25121
25155
|
throw new CliError(`Scope "${scope}" is not supported by ${integration.displayName}. ` + `Valid scopes: ${integration.scopes.join(", ")}`);
|
|
25122
25156
|
}
|
|
25123
25157
|
}
|
|
25158
|
+
const daemonRequiredBy = selectedIntegrations.map(({ integration }) => integration).filter((integration) => integration.requiresHealthyDaemon);
|
|
25159
|
+
if (daemonRequiredBy.length > 0 && !await probeDaemonEndToEnd()) {
|
|
25160
|
+
const names = daemonRequiredBy.map((integration) => integration.displayName).join(", ");
|
|
25161
|
+
const verb = daemonRequiredBy.length === 1 ? "requires" : "require";
|
|
25162
|
+
throw new CliError(`${names} ${verb} a healthy failproofaid daemon before FailproofAI enforcement can be enabled.
|
|
25163
|
+
` + "Run `failproofai config` to install and configure the daemon, then retry.");
|
|
25164
|
+
}
|
|
25124
25165
|
const binaryPath = resolveFailproofaiBinary();
|
|
25125
25166
|
const previousConfig = readScopedHooksConfig(scope, cwd);
|
|
25126
25167
|
const previousEnabled = new Set(previousConfig.enabledPolicies);
|
|
@@ -25143,7 +25184,7 @@ async function installHooksImpl(policyNames, scope = "user", cwd, includeBeta =
|
|
|
25143
25184
|
} else if (customPoliciesPath && (typeof customPoliciesPath === "string" || customPoliciesPath.length > 0)) {
|
|
25144
25185
|
const incoming = (typeof customPoliciesPath === "string" ? [customPoliciesPath] : customPoliciesPath).map((path) => resolve22(path));
|
|
25145
25186
|
const carried = (previousConfig.customPoliciesPaths ?? (previousConfig.customPoliciesPath ? [previousConfig.customPoliciesPath] : [])).map((path) => resolve22(path)).filter((path) => {
|
|
25146
|
-
if (
|
|
25187
|
+
if (existsSync28(path))
|
|
25147
25188
|
return true;
|
|
25148
25189
|
console.log(`Dropping custom policies path (file no longer exists): ${path}`);
|
|
25149
25190
|
return false;
|
|
@@ -25371,7 +25412,7 @@ async function removeHooks(policyNames, scope = "user", cwd, opts) {
|
|
|
25371
25412
|
const scopesToRemove = scope === "all" ? [...integration.scopes] : integration.scopes.includes(scope) ? [scope] : [];
|
|
25372
25413
|
for (const s of scopesToRemove) {
|
|
25373
25414
|
const settingsPaths = settingsPathsFor(integration, s, cwd);
|
|
25374
|
-
const existing = cliId === "hermes" ? settingsPaths : settingsPaths.filter((p) =>
|
|
25415
|
+
const existing = cliId === "hermes" ? settingsPaths : settingsPaths.filter((p) => existsSync28(p));
|
|
25375
25416
|
if (existing.length === 0) {
|
|
25376
25417
|
if (scope !== "all" && selectedClis.length === 1) {
|
|
25377
25418
|
console.log("No settings file found. Nothing to remove.");
|
|
@@ -25454,6 +25495,7 @@ var init_manager = __esm(() => {
|
|
|
25454
25495
|
init_pack_store();
|
|
25455
25496
|
init_pack_manifest();
|
|
25456
25497
|
init_policy_evaluator();
|
|
25498
|
+
init_daemon_service();
|
|
25457
25499
|
init_tui();
|
|
25458
25500
|
VALID_POLICY_NAMES = new Set(BUILTIN_POLICIES.map((p) => p.name));
|
|
25459
25501
|
});
|
|
@@ -25474,7 +25516,7 @@ var DEFAULT_FETCH_TIMEOUT_MS = 15000;
|
|
|
25474
25516
|
|
|
25475
25517
|
// src/hooks/cloud-enrollment.ts
|
|
25476
25518
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
25477
|
-
import { existsSync as
|
|
25519
|
+
import { existsSync as existsSync29, readFileSync as readFileSync22, rmSync as rmSync10 } from "node:fs";
|
|
25478
25520
|
import { hostname as hostname4 } from "node:os";
|
|
25479
25521
|
function cloudCredentialPath() {
|
|
25480
25522
|
return process.env.FAILPROOFAI_CLOUD_CREDENTIALS ?? credentialsFile();
|
|
@@ -25513,7 +25555,7 @@ function readCloudCredentials() {
|
|
|
25513
25555
|
if (!usingJsonOverride())
|
|
25514
25556
|
return readCredentials().cloud ?? null;
|
|
25515
25557
|
const path = cloudCredentialPath();
|
|
25516
|
-
if (!
|
|
25558
|
+
if (!existsSync29(path))
|
|
25517
25559
|
return null;
|
|
25518
25560
|
try {
|
|
25519
25561
|
const raw = JSON.parse(readFileSync22(path, "utf8"));
|
|
@@ -25555,7 +25597,7 @@ function resolveMachineLabel(explicit) {
|
|
|
25555
25597
|
function clearCloudCredentials() {
|
|
25556
25598
|
if (usingJsonOverride()) {
|
|
25557
25599
|
const path = cloudCredentialPath();
|
|
25558
|
-
if (!
|
|
25600
|
+
if (!existsSync29(path))
|
|
25559
25601
|
return false;
|
|
25560
25602
|
try {
|
|
25561
25603
|
rmSync10(path);
|
|
@@ -25806,7 +25848,7 @@ var init_cloud_connection = __esm(() => {
|
|
|
25806
25848
|
});
|
|
25807
25849
|
|
|
25808
25850
|
// src/hooks/setup-state.ts
|
|
25809
|
-
import { existsSync as
|
|
25851
|
+
import { existsSync as existsSync30, realpathSync as realpathSync2, statSync as statSync18 } from "node:fs";
|
|
25810
25852
|
import { dirname as dirname15, resolve as resolve23 } from "node:path";
|
|
25811
25853
|
import { homedir as homedir25 } from "node:os";
|
|
25812
25854
|
function globalConfigPath(home = homedir25()) {
|
|
@@ -25863,10 +25905,10 @@ function detectSetupState(cwd = process.cwd(), home = homedir25()) {
|
|
|
25863
25905
|
cwd: resolvedCwd,
|
|
25864
25906
|
home: resolvedHome,
|
|
25865
25907
|
projectRoot,
|
|
25866
|
-
hasGlobalConfig:
|
|
25867
|
-
hasProjectConfig: projectRoot !== resolvedHome &&
|
|
25908
|
+
hasGlobalConfig: existsSync30(globalConfigPath(resolvedHome)),
|
|
25909
|
+
hasProjectConfig: projectRoot !== resolvedHome && existsSync30(projectConfigPath(projectRoot)),
|
|
25868
25910
|
hasGlobalHooks: hasGlobalHooksInstalled(),
|
|
25869
|
-
hasLegacyMarker:
|
|
25911
|
+
hasLegacyMarker: existsSync30(legacyMarkerPath(resolvedHome)),
|
|
25870
25912
|
inHomeDir: resolvedCwd === resolvedHome
|
|
25871
25913
|
};
|
|
25872
25914
|
}
|
|
@@ -25883,11 +25925,11 @@ var init_setup_state = __esm(() => {
|
|
|
25883
25925
|
});
|
|
25884
25926
|
|
|
25885
25927
|
// src/hooks/onboarding-attempt.ts
|
|
25886
|
-
import { existsSync as
|
|
25928
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync17, readFileSync as readFileSync23, rmSync as rmSync11, writeFileSync as writeFileSync15 } from "node:fs";
|
|
25887
25929
|
import { dirname as dirname16 } from "node:path";
|
|
25888
25930
|
function readOnboardingAttempt() {
|
|
25889
25931
|
const path = onboardingAttemptFile();
|
|
25890
|
-
if (!
|
|
25932
|
+
if (!existsSync31(path))
|
|
25891
25933
|
return null;
|
|
25892
25934
|
try {
|
|
25893
25935
|
const raw = JSON.parse(readFileSync23(path, "utf8"));
|
|
@@ -26020,7 +26062,7 @@ var init_onboarding_lock = __esm(() => {
|
|
|
26020
26062
|
});
|
|
26021
26063
|
|
|
26022
26064
|
// lib/claude-sessions.ts
|
|
26023
|
-
import { readdirSync as readdirSync17, statSync as statSync19, existsSync as
|
|
26065
|
+
import { readdirSync as readdirSync17, statSync as statSync19, existsSync as existsSync32 } from "node:fs";
|
|
26024
26066
|
import { join as join34, basename as basename7 } from "node:path";
|
|
26025
26067
|
function getClaudeProjectsRoot() {
|
|
26026
26068
|
return getClaudeProjectsPath();
|
|
@@ -26067,7 +26109,7 @@ function listClaudeTranscripts(project) {
|
|
|
26067
26109
|
} catch {}
|
|
26068
26110
|
} else if (entry.isDirectory() && UUID_RE2.test(entry.name)) {
|
|
26069
26111
|
const subDir = join34(project.path, entry.name, "subagents");
|
|
26070
|
-
if (!
|
|
26112
|
+
if (!existsSync32(subDir))
|
|
26071
26113
|
continue;
|
|
26072
26114
|
let subEntries;
|
|
26073
26115
|
try {
|
|
@@ -27410,7 +27452,7 @@ var init_features = __esm(() => {
|
|
|
27410
27452
|
|
|
27411
27453
|
// src/audit/cache.ts
|
|
27412
27454
|
import { createHash as createHash8 } from "node:crypto";
|
|
27413
|
-
import { existsSync as
|
|
27455
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync19, readFileSync as readFileSync25, writeFileSync as writeFileSync17, chmodSync as chmodSync5, openSync, readSync, closeSync } from "node:fs";
|
|
27414
27456
|
import { join as join35 } from "node:path";
|
|
27415
27457
|
function getEngineVersion() {
|
|
27416
27458
|
if (cachedEngineVersion)
|
|
@@ -27471,7 +27513,7 @@ function readCachedTranscript(transcriptPath, mtimeMs, sizeBytes) {
|
|
|
27471
27513
|
if (sizeBytes === 0)
|
|
27472
27514
|
return null;
|
|
27473
27515
|
const cachePath = getCachePathFor(transcriptPath);
|
|
27474
|
-
if (!
|
|
27516
|
+
if (!existsSync33(cachePath))
|
|
27475
27517
|
return null;
|
|
27476
27518
|
try {
|
|
27477
27519
|
const raw = readFileSync25(cachePath, "utf-8");
|
|
@@ -28091,7 +28133,7 @@ var init_audit_lock = __esm(() => {
|
|
|
28091
28133
|
});
|
|
28092
28134
|
|
|
28093
28135
|
// src/audit/dashboard-cache.ts
|
|
28094
|
-
import { existsSync as
|
|
28136
|
+
import { existsSync as existsSync34, readFileSync as readFileSync27 } from "node:fs";
|
|
28095
28137
|
function getCachePath() {
|
|
28096
28138
|
return auditDashboardFile();
|
|
28097
28139
|
}
|
|
@@ -28111,7 +28153,7 @@ function writeDashboardCache(params, result) {
|
|
|
28111
28153
|
}
|
|
28112
28154
|
function readDashboardCacheMeta() {
|
|
28113
28155
|
const cachePath = getCachePath();
|
|
28114
|
-
if (!
|
|
28156
|
+
if (!existsSync34(cachePath))
|
|
28115
28157
|
return null;
|
|
28116
28158
|
try {
|
|
28117
28159
|
const raw = readFileSync27(cachePath, "utf-8");
|
|
@@ -28338,7 +28380,7 @@ var init_api_server_client = __esm(() => {
|
|
|
28338
28380
|
});
|
|
28339
28381
|
|
|
28340
28382
|
// lib/auth/auth-store.ts
|
|
28341
|
-
import { existsSync as
|
|
28383
|
+
import { existsSync as existsSync35, readFileSync as readFileSync28, readdirSync as readdirSync18, rmSync as rmSync13 } from "node:fs";
|
|
28342
28384
|
import { join as join36, resolve as resolve24 } from "node:path";
|
|
28343
28385
|
function getAuthFilePath() {
|
|
28344
28386
|
const override = process.env.FAILPROOFAI_AUTH_DIR;
|
|
@@ -28346,7 +28388,7 @@ function getAuthFilePath() {
|
|
|
28346
28388
|
}
|
|
28347
28389
|
function readAuth() {
|
|
28348
28390
|
const p = getAuthFilePath();
|
|
28349
|
-
if (!
|
|
28391
|
+
if (!existsSync35(p))
|
|
28350
28392
|
return null;
|
|
28351
28393
|
try {
|
|
28352
28394
|
const raw = readFileSync28(p, "utf-8");
|
|
@@ -28373,17 +28415,17 @@ function writeAuth(auth) {
|
|
|
28373
28415
|
}
|
|
28374
28416
|
function deleteAuth() {
|
|
28375
28417
|
const p = getAuthFilePath();
|
|
28376
|
-
if (
|
|
28418
|
+
if (existsSync35(p))
|
|
28377
28419
|
rmSync13(p, { force: true });
|
|
28378
28420
|
try {
|
|
28379
28421
|
const root = migrationsDir();
|
|
28380
|
-
if (!
|
|
28422
|
+
if (!existsSync35(root))
|
|
28381
28423
|
return;
|
|
28382
28424
|
for (const entry of readdirSync18(root)) {
|
|
28383
28425
|
if (!entry.startsWith("backup-layout"))
|
|
28384
28426
|
continue;
|
|
28385
28427
|
const copy = resolve24(root, entry, "auth.json");
|
|
28386
|
-
if (
|
|
28428
|
+
if (existsSync35(copy))
|
|
28387
28429
|
rmSync13(copy, { force: true });
|
|
28388
28430
|
}
|
|
28389
28431
|
} catch {}
|
|
@@ -28634,12 +28676,12 @@ var init_harm_report = __esm(() => {
|
|
|
28634
28676
|
});
|
|
28635
28677
|
|
|
28636
28678
|
// src/audit/machine-store.ts
|
|
28637
|
-
import { existsSync as
|
|
28679
|
+
import { existsSync as existsSync36, readFileSync as readFileSync29, rmSync as rmSync14 } from "node:fs";
|
|
28638
28680
|
import { hostname as hostname5 } from "node:os";
|
|
28639
28681
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
28640
28682
|
function readMachineIdentity(home) {
|
|
28641
28683
|
const path = auditMachineFile(home);
|
|
28642
|
-
if (!
|
|
28684
|
+
if (!existsSync36(path))
|
|
28643
28685
|
return null;
|
|
28644
28686
|
try {
|
|
28645
28687
|
const parsed = JSON.parse(readFileSync29(path, "utf8"));
|
|
@@ -28964,7 +29006,7 @@ var init_cli = __esm(() => {
|
|
|
28964
29006
|
});
|
|
28965
29007
|
|
|
28966
29008
|
// src/hooks/configure-wizard.ts
|
|
28967
|
-
import { existsSync as
|
|
29009
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync21, writeFileSync as writeFileSync19, readFileSync as readFileSync30 } from "node:fs";
|
|
28968
29010
|
import { homedir as homedir28 } from "node:os";
|
|
28969
29011
|
import { dirname as dirname17, resolve as resolve25, sep as sep5 } from "node:path";
|
|
28970
29012
|
async function emit(event, props) {
|
|
@@ -28989,7 +29031,7 @@ function setCustomPoliciesEnabled(scope, cwd, enabled) {
|
|
|
28989
29031
|
const path = getConfigPathForScope(scope, cwd);
|
|
28990
29032
|
let config = {};
|
|
28991
29033
|
try {
|
|
28992
|
-
if (
|
|
29034
|
+
if (existsSync37(path))
|
|
28993
29035
|
config = JSON.parse(readFileSync30(path, "utf8"));
|
|
28994
29036
|
} catch {
|
|
28995
29037
|
return;
|
|
@@ -29626,14 +29668,14 @@ var init_configure_wizard = __esm(() => {
|
|
|
29626
29668
|
});
|
|
29627
29669
|
|
|
29628
29670
|
// src/hooks/flush-cli.ts
|
|
29629
|
-
import { existsSync as
|
|
29671
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync22, writeFileSync as writeFileSync20, readdirSync as readdirSync19 } from "node:fs";
|
|
29630
29672
|
import { dirname as dirname18, join as join37 } from "node:path";
|
|
29631
29673
|
function flushRequestPath2(home) {
|
|
29632
29674
|
return join37(failproofaiHome(home), "state", "flush-request.json");
|
|
29633
29675
|
}
|
|
29634
29676
|
function spoolDirs2(home) {
|
|
29635
29677
|
const root = spoolDir(home);
|
|
29636
|
-
if (!
|
|
29678
|
+
if (!existsSync38(root))
|
|
29637
29679
|
return [];
|
|
29638
29680
|
try {
|
|
29639
29681
|
return readdirSync19(root, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== "failed").map((e) => join37(root, e.name));
|
|
@@ -29734,7 +29776,7 @@ var init_flush_cli2 = __esm(() => {
|
|
|
29734
29776
|
});
|
|
29735
29777
|
|
|
29736
29778
|
// src/hooks/backfill-cli.ts
|
|
29737
|
-
import { existsSync as
|
|
29779
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync23, writeFileSync as writeFileSync21, readdirSync as readdirSync20, statSync as statSync24 } from "node:fs";
|
|
29738
29780
|
import { dirname as dirname19, join as join38 } from "node:path";
|
|
29739
29781
|
function backfillRequestPath(home) {
|
|
29740
29782
|
return join38(failproofaiHome(home), "state", "backfill-request.json");
|
|
@@ -29743,7 +29785,7 @@ function surveySessions(sinceMs, homeDir) {
|
|
|
29743
29785
|
const out = [];
|
|
29744
29786
|
for (const { cli, dir } of SESSION_DIRS) {
|
|
29745
29787
|
const root = join38(homeDir, dir);
|
|
29746
|
-
if (!
|
|
29788
|
+
if (!existsSync39(root))
|
|
29747
29789
|
continue;
|
|
29748
29790
|
let files = 0;
|
|
29749
29791
|
let newest = 0;
|
|
@@ -29781,7 +29823,7 @@ function runBackfillCommand(opts = {}) {
|
|
|
29781
29823
|
const now = opts.now ?? Date.now();
|
|
29782
29824
|
const sinceMs = opts.sinceMs ?? now - DEFAULT_BACKFILL_DAYS * 24 * 60 * 60 * 1000;
|
|
29783
29825
|
const home = failproofaiHome();
|
|
29784
|
-
if (!
|
|
29826
|
+
if (!existsSync39(home)) {
|
|
29785
29827
|
return {
|
|
29786
29828
|
exitCode: 1,
|
|
29787
29829
|
lines: [`No failproofai home at ${home}. Run \`failproofai config\` first.`]
|
|
@@ -30112,7 +30154,7 @@ var init_harness_cli = __esm(() => {
|
|
|
30112
30154
|
});
|
|
30113
30155
|
|
|
30114
30156
|
// src/hooks/fp-config.ts
|
|
30115
|
-
import { chmodSync as chmodSync6, existsSync as
|
|
30157
|
+
import { chmodSync as chmodSync6, existsSync as existsSync40, mkdirSync as mkdirSync24, readFileSync as readFileSync31, statSync as statSync25, writeFileSync as writeFileSync22 } from "node:fs";
|
|
30116
30158
|
function detectLayout2() {
|
|
30117
30159
|
const raw = readVersionFile2();
|
|
30118
30160
|
if (raw) {
|
|
@@ -30120,17 +30162,17 @@ function detectLayout2() {
|
|
|
30120
30162
|
return { kind: "current", version: raw };
|
|
30121
30163
|
return raw.layout > LAYOUT_VERSION ? { kind: "future", found: raw.layout } : { kind: "stale", found: raw.layout };
|
|
30122
30164
|
}
|
|
30123
|
-
if (
|
|
30165
|
+
if (existsSync40(configFile())) {
|
|
30124
30166
|
const layoutThreePositions = [
|
|
30125
30167
|
legacy.authJson(),
|
|
30126
30168
|
legacy.nextAudit(),
|
|
30127
30169
|
legacy.auditSchedule()
|
|
30128
30170
|
];
|
|
30129
|
-
if (layoutThreePositions.some((p) =>
|
|
30171
|
+
if (layoutThreePositions.some((p) => existsSync40(p)))
|
|
30130
30172
|
return { kind: "stale", found: 3 };
|
|
30131
30173
|
return { kind: "current", version: { layout: LAYOUT_VERSION, cli: "" }, inferred: true };
|
|
30132
30174
|
}
|
|
30133
|
-
if (
|
|
30175
|
+
if (existsSync40(legacy.configToml()))
|
|
30134
30176
|
return { kind: "stale", found: 2 };
|
|
30135
30177
|
const layoutOneMarkers = [
|
|
30136
30178
|
legacy.policyConfig(),
|
|
@@ -30141,7 +30183,7 @@ function detectLayout2() {
|
|
|
30141
30183
|
legacy.ingestCredentials(),
|
|
30142
30184
|
legacy.auditDashboard()
|
|
30143
30185
|
];
|
|
30144
|
-
return layoutOneMarkers.some((p) =>
|
|
30186
|
+
return layoutOneMarkers.some((p) => existsSync40(p)) ? { kind: "stale", found: 1 } : { kind: "absent" };
|
|
30145
30187
|
}
|
|
30146
30188
|
function readLegacyTomlVersion2(text) {
|
|
30147
30189
|
const layout = Number(/^\s*layout\s*=\s*(\d+)\s*$/m.exec(text)?.[1]);
|
|
@@ -30184,7 +30226,7 @@ var init_fp_home2 = () => {};
|
|
|
30184
30226
|
import {
|
|
30185
30227
|
chmodSync as chmodSync7,
|
|
30186
30228
|
copyFileSync as copyFileSync3,
|
|
30187
|
-
existsSync as
|
|
30229
|
+
existsSync as existsSync41,
|
|
30188
30230
|
mkdirSync as mkdirSync25,
|
|
30189
30231
|
readFileSync as readFileSync32,
|
|
30190
30232
|
renameSync as renameSync9,
|
|
@@ -30207,9 +30249,9 @@ function migrateToLayout42() {
|
|
|
30207
30249
|
}
|
|
30208
30250
|
const migrated = [];
|
|
30209
30251
|
for (const { from, to } of moves) {
|
|
30210
|
-
if (!
|
|
30252
|
+
if (!existsSync41(from))
|
|
30211
30253
|
continue;
|
|
30212
|
-
if (
|
|
30254
|
+
if (existsSync41(to)) {
|
|
30213
30255
|
rmSync15(from, { force: true });
|
|
30214
30256
|
continue;
|
|
30215
30257
|
}
|
|
@@ -30230,7 +30272,7 @@ function migrateToLayout42() {
|
|
|
30230
30272
|
migrated.push(`${basename8(from)} → audit/${basename8(to)}`);
|
|
30231
30273
|
}
|
|
30232
30274
|
for (const secret of [auditSessionFile()]) {
|
|
30233
|
-
if (!
|
|
30275
|
+
if (!existsSync41(secret))
|
|
30234
30276
|
continue;
|
|
30235
30277
|
try {
|
|
30236
30278
|
chmodSync7(secret, 384);
|
|
@@ -30278,10 +30320,10 @@ function pruneMigratedCredentials2(from) {
|
|
|
30278
30320
|
for (let layout = from;layout < LAYOUT_VERSION; layout++) {
|
|
30279
30321
|
for (const { as, landsAt } of PRUNED_AFTER_SUCCESS2) {
|
|
30280
30322
|
try {
|
|
30281
|
-
if (!
|
|
30323
|
+
if (!existsSync41(landsAt()))
|
|
30282
30324
|
continue;
|
|
30283
30325
|
const copy = resolve27(migrationBackupDir(layout), as);
|
|
30284
|
-
if (!
|
|
30326
|
+
if (!existsSync41(copy))
|
|
30285
30327
|
continue;
|
|
30286
30328
|
rmSync15(copy, { force: true });
|
|
30287
30329
|
pruned.push(as);
|
|
@@ -30294,7 +30336,7 @@ function filesToBackUp2() {
|
|
|
30294
30336
|
const seen = new Map;
|
|
30295
30337
|
for (const f of [...BACKED_UP2, ...BACKED_UP_LEGACY2]) {
|
|
30296
30338
|
const path = f.at();
|
|
30297
|
-
if (
|
|
30339
|
+
if (existsSync41(path))
|
|
30298
30340
|
seen.set(path, backupNameOf2(f));
|
|
30299
30341
|
}
|
|
30300
30342
|
return [...seen].map(([path, as]) => ({ path, as }));
|
|
@@ -30448,7 +30490,7 @@ var init_migrations2 = __esm(() => {
|
|
|
30448
30490
|
|
|
30449
30491
|
// src/hooks/daemon-service.ts
|
|
30450
30492
|
import {
|
|
30451
|
-
existsSync as
|
|
30493
|
+
existsSync as existsSync42,
|
|
30452
30494
|
mkdirSync as mkdirSync26,
|
|
30453
30495
|
mkdtempSync as mkdtempSync2,
|
|
30454
30496
|
readFileSync as readFileSync33,
|
|
@@ -30473,13 +30515,13 @@ function resolveFailproofaidBinaryPath2() {
|
|
|
30473
30515
|
if (process.env.FAILPROOFAI_DAEMON_BINARY)
|
|
30474
30516
|
return process.env.FAILPROOFAI_DAEMON_BINARY;
|
|
30475
30517
|
const downloaded = installedBinaryPath();
|
|
30476
|
-
if (
|
|
30518
|
+
if (existsSync42(downloaded))
|
|
30477
30519
|
return downloaded;
|
|
30478
30520
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
30479
30521
|
if (packageRoot) {
|
|
30480
30522
|
for (const profile of ["release", "debug"]) {
|
|
30481
30523
|
const candidate = resolve28(packageRoot, "target", profile, "failproofaid");
|
|
30482
|
-
if (
|
|
30524
|
+
if (existsSync42(candidate))
|
|
30483
30525
|
return candidate;
|
|
30484
30526
|
}
|
|
30485
30527
|
}
|
|
@@ -30510,7 +30552,7 @@ function resolveWorkerCommand2() {
|
|
|
30510
30552
|
if (!packageRoot)
|
|
30511
30553
|
return null;
|
|
30512
30554
|
const workerScript = resolve28(packageRoot, "dist", "worker.mjs");
|
|
30513
|
-
if (!
|
|
30555
|
+
if (!existsSync42(workerScript))
|
|
30514
30556
|
return null;
|
|
30515
30557
|
return `${shellQuote2(process.execPath)} ${shellQuote2(workerScript)}`;
|
|
30516
30558
|
}
|
|
@@ -30521,7 +30563,7 @@ function resolveCliCommand2() {
|
|
|
30521
30563
|
if (!packageRoot)
|
|
30522
30564
|
return null;
|
|
30523
30565
|
const cliScript = resolve28(packageRoot, "dist", "cli.mjs");
|
|
30524
|
-
if (!
|
|
30566
|
+
if (!existsSync42(cliScript))
|
|
30525
30567
|
return null;
|
|
30526
30568
|
return `${shellQuote2(process.execPath)} ${shellQuote2(cliScript)}`;
|
|
30527
30569
|
}
|
|
@@ -30535,7 +30577,7 @@ function workerScriptPath2() {
|
|
|
30535
30577
|
if (!packageRoot)
|
|
30536
30578
|
return null;
|
|
30537
30579
|
const workerScript = resolve28(packageRoot, "dist", "worker.mjs");
|
|
30538
|
-
return
|
|
30580
|
+
return existsSync42(workerScript) ? workerScript : null;
|
|
30539
30581
|
}
|
|
30540
30582
|
function assertUnitSafe2(value, field) {
|
|
30541
30583
|
if (UNIT_UNSAFE_RE2.test(value)) {
|
|
@@ -30624,7 +30666,7 @@ function removeLegacyUserService2() {
|
|
|
30624
30666
|
try {
|
|
30625
30667
|
if (process.platform === "linux") {
|
|
30626
30668
|
const legacy = legacySystemdUserUnitPath2();
|
|
30627
|
-
if (!
|
|
30669
|
+
if (!existsSync42(legacy))
|
|
30628
30670
|
return;
|
|
30629
30671
|
try {
|
|
30630
30672
|
execFileSync3("systemctl", ["--user", "disable", "--now", "failproofaid.service"], {
|
|
@@ -30641,7 +30683,7 @@ function removeLegacyUserService2() {
|
|
|
30641
30683
|
} catch {}
|
|
30642
30684
|
} else {
|
|
30643
30685
|
const legacyAgent = legacyLaunchAgentPlistPath2();
|
|
30644
|
-
if (
|
|
30686
|
+
if (existsSync42(legacyAgent)) {
|
|
30645
30687
|
try {
|
|
30646
30688
|
execFileSync3("launchctl", ["unload", "-w", legacyAgent], {
|
|
30647
30689
|
stdio: "ignore",
|
|
@@ -30651,7 +30693,7 @@ function removeLegacyUserService2() {
|
|
|
30651
30693
|
unlinkSync5(legacyAgent);
|
|
30652
30694
|
}
|
|
30653
30695
|
const legacyDaemon = legacySharedLaunchDaemonPath2();
|
|
30654
|
-
if (
|
|
30696
|
+
if (existsSync42(legacyDaemon)) {
|
|
30655
30697
|
try {
|
|
30656
30698
|
runPrivileged2("launchctl", ["unload", "-w", legacyDaemon]);
|
|
30657
30699
|
} catch {}
|
|
@@ -30668,7 +30710,7 @@ function systemdUnitContents2(binaryPath, workerCmd, cliCmd = null) {
|
|
|
30668
30710
|
const user = assertUnitSafe2(serviceUser2(), "User");
|
|
30669
30711
|
assertUnitSafe2(binaryPath, "ExecStart");
|
|
30670
30712
|
assertUnitSafe2(homedir30(), "HOME");
|
|
30671
|
-
const conditionPaths = [binaryPath, workerScriptPath2()].filter((p) => typeof p === "string" &&
|
|
30713
|
+
const conditionPaths = [binaryPath, workerScriptPath2()].filter((p) => typeof p === "string" && existsSync42(p));
|
|
30672
30714
|
const conditionLines = conditionPaths.map((p) => `ConditionPathExists=${assertUnitSafe2(p, "ConditionPathExists")}
|
|
30673
30715
|
`).join("");
|
|
30674
30716
|
return `[Unit]
|
|
@@ -30873,7 +30915,7 @@ function daemonServiceStatus2() {
|
|
|
30873
30915
|
if (!isDaemonSupportedPlatform2())
|
|
30874
30916
|
return "unsupported-platform";
|
|
30875
30917
|
if (process.platform === "linux") {
|
|
30876
|
-
if (!
|
|
30918
|
+
if (!existsSync42(systemdUnitPath2()))
|
|
30877
30919
|
return "not-installed";
|
|
30878
30920
|
try {
|
|
30879
30921
|
const out = execFileSync3("systemctl", ["is-active", systemdUnitName2()], {
|
|
@@ -30886,7 +30928,7 @@ function daemonServiceStatus2() {
|
|
|
30886
30928
|
}
|
|
30887
30929
|
}
|
|
30888
30930
|
const plistPath = launchdPlistPath2();
|
|
30889
|
-
if (!
|
|
30931
|
+
if (!existsSync42(plistPath))
|
|
30890
30932
|
return "not-installed";
|
|
30891
30933
|
try {
|
|
30892
30934
|
const root = typeof process.getuid === "function" && process.getuid() === 0;
|
|
@@ -30916,7 +30958,7 @@ var init_daemon_service2 = __esm(() => {
|
|
|
30916
30958
|
});
|
|
30917
30959
|
|
|
30918
30960
|
// src/hooks/uninstall-cli.ts
|
|
30919
|
-
import { existsSync as
|
|
30961
|
+
import { existsSync as existsSync43, rmSync as rmSync17 } from "node:fs";
|
|
30920
30962
|
function survey(cwd) {
|
|
30921
30963
|
const clis = [];
|
|
30922
30964
|
for (const id of listInstallableIds()) {
|
|
@@ -30937,9 +30979,9 @@ function survey(cwd) {
|
|
|
30937
30979
|
return {
|
|
30938
30980
|
clis,
|
|
30939
30981
|
servicePath,
|
|
30940
|
-
serviceInstalled: !!servicePath &&
|
|
30982
|
+
serviceInstalled: !!servicePath && existsSync43(servicePath),
|
|
30941
30983
|
daemonConfigured,
|
|
30942
|
-
homeExists:
|
|
30984
|
+
homeExists: existsSync43(failproofaiHome())
|
|
30943
30985
|
};
|
|
30944
30986
|
}
|
|
30945
30987
|
async function runUninstallCommand(opts = {}) {
|
|
@@ -31037,7 +31079,7 @@ async function runUninstallCommand(opts = {}) {
|
|
|
31037
31079
|
} catch {}
|
|
31038
31080
|
try {
|
|
31039
31081
|
await uninstallDaemonService();
|
|
31040
|
-
if (found.servicePath &&
|
|
31082
|
+
if (found.servicePath && existsSync43(found.servicePath)) {
|
|
31041
31083
|
failures.push(`the service at ${found.servicePath} is still there (most often: no sudo). ` + `Remove it with the commands below.`);
|
|
31042
31084
|
} else {
|
|
31043
31085
|
lines.push(`✓ stopped and removed the daemon service`);
|
|
@@ -31060,7 +31102,7 @@ async function runUninstallCommand(opts = {}) {
|
|
|
31060
31102
|
lines.push(``, `Not everything could be removed:`);
|
|
31061
31103
|
for (const f of failures)
|
|
31062
31104
|
lines.push(` ✗ ${f}`);
|
|
31063
|
-
if (found.servicePath &&
|
|
31105
|
+
if (found.servicePath && existsSync43(found.servicePath)) {
|
|
31064
31106
|
lines.push(``, `To remove the service by hand:`, ...manualServiceRemoval(found.servicePath), ``, `(\`${daemonStatusCommand()}\` shows its current state.)`);
|
|
31065
31107
|
}
|
|
31066
31108
|
return { exitCode: 1, lines, planLines, purged };
|
|
@@ -31094,7 +31136,7 @@ var init_uninstall_cli = __esm(() => {
|
|
|
31094
31136
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
31095
31137
|
import { homedir as homedir31, tmpdir as tmpdir4 } from "node:os";
|
|
31096
31138
|
import { createHash as createHash9 } from "node:crypto";
|
|
31097
|
-
import { copyFileSync as copyFileSync4, existsSync as
|
|
31139
|
+
import { copyFileSync as copyFileSync4, existsSync as existsSync44, mkdirSync as mkdirSync27, mkdtempSync as mkdtempSync3, readFileSync as readFileSync34, readdirSync as readdirSync21, realpathSync as realpathSync3, rmSync as rmSync18, statSync as statSync26, writeFileSync as writeFileSync25 } from "node:fs";
|
|
31098
31140
|
import { basename as basename9, dirname as dirname21, isAbsolute as isAbsolute4, join as join40, relative as relative5, resolve as resolve29, sep as sep6 } from "node:path";
|
|
31099
31141
|
function parseList(rest, flag) {
|
|
31100
31142
|
const idx = rest.findIndex((a) => a === flag || a.startsWith(`${flag}=`));
|
|
@@ -31209,7 +31251,7 @@ async function build(rest) {
|
|
|
31209
31251
|
return fail2([err instanceof Error ? err.message : String(err)]);
|
|
31210
31252
|
}
|
|
31211
31253
|
const entryPath = resolve29(entry);
|
|
31212
|
-
if (!
|
|
31254
|
+
if (!existsSync44(entryPath))
|
|
31213
31255
|
return fail2([`No such file: ${entryPath}`]);
|
|
31214
31256
|
const source = readFileSync34(entryPath, "utf8");
|
|
31215
31257
|
const localImport = /(?:^|\n)\s*(?:import|export)[^;\n]*from\s+["'](\.[^"']*)["']/.exec(source);
|
|
@@ -31404,7 +31446,7 @@ async function scaffold(target) {
|
|
|
31404
31446
|
chosen = answer.trim();
|
|
31405
31447
|
}
|
|
31406
31448
|
const path = resolve29(withPolicyExtension(chosen ?? "my-policies"));
|
|
31407
|
-
if (
|
|
31449
|
+
if (existsSync44(path)) {
|
|
31408
31450
|
return fail2([`${path} already exists — name a different file, or edit that one.`]);
|
|
31409
31451
|
}
|
|
31410
31452
|
mkdirSync27(resolve29(path, ".."), { recursive: true });
|
|
@@ -32902,7 +32944,7 @@ var init_install_prompt = __esm(() => {
|
|
|
32902
32944
|
|
|
32903
32945
|
// src/hooks/manager.ts
|
|
32904
32946
|
import { execSync as execSync7 } from "node:child_process";
|
|
32905
|
-
import { existsSync as
|
|
32947
|
+
import { existsSync as existsSync45 } from "node:fs";
|
|
32906
32948
|
import { resolve as resolve30, basename as basename10 } from "node:path";
|
|
32907
32949
|
import { platform as platform4, arch as arch4, release as release3, hostname as hostname6 } from "node:os";
|
|
32908
32950
|
function getSettingsPath2(scope, cwd) {
|
|
@@ -33089,8 +33131,11 @@ async function installHooksImpl2(policyNames, scope = "user", cwd, includeBeta =
|
|
|
33089
33131
|
}
|
|
33090
33132
|
}
|
|
33091
33133
|
const selectedClis = cli && cli.length > 0 ? [...new Set(cli)] : ["claude"];
|
|
33092
|
-
|
|
33093
|
-
|
|
33134
|
+
const selectedIntegrations = selectedClis.map((cliId) => ({
|
|
33135
|
+
cliId,
|
|
33136
|
+
integration: getIntegration(cliId)
|
|
33137
|
+
}));
|
|
33138
|
+
for (const { cliId, integration } of selectedIntegrations) {
|
|
33094
33139
|
if (!integration.scopes.includes(scope)) {
|
|
33095
33140
|
try {
|
|
33096
33141
|
await trackHookEvent2(getInstanceId2(), "scope_validation_failed", {
|
|
@@ -33102,6 +33147,13 @@ async function installHooksImpl2(policyNames, scope = "user", cwd, includeBeta =
|
|
|
33102
33147
|
throw new CliError(`Scope "${scope}" is not supported by ${integration.displayName}. ` + `Valid scopes: ${integration.scopes.join(", ")}`);
|
|
33103
33148
|
}
|
|
33104
33149
|
}
|
|
33150
|
+
const daemonRequiredBy = selectedIntegrations.map(({ integration }) => integration).filter((integration) => integration.requiresHealthyDaemon);
|
|
33151
|
+
if (daemonRequiredBy.length > 0 && !await probeDaemonEndToEnd()) {
|
|
33152
|
+
const names = daemonRequiredBy.map((integration) => integration.displayName).join(", ");
|
|
33153
|
+
const verb = daemonRequiredBy.length === 1 ? "requires" : "require";
|
|
33154
|
+
throw new CliError(`${names} ${verb} a healthy failproofaid daemon before FailproofAI enforcement can be enabled.
|
|
33155
|
+
` + "Run `failproofai config` to install and configure the daemon, then retry.");
|
|
33156
|
+
}
|
|
33105
33157
|
const binaryPath = resolveFailproofaiBinary2();
|
|
33106
33158
|
const previousConfig = readScopedHooksConfig(scope, cwd);
|
|
33107
33159
|
const previousEnabled = new Set(previousConfig.enabledPolicies);
|
|
@@ -33124,7 +33176,7 @@ async function installHooksImpl2(policyNames, scope = "user", cwd, includeBeta =
|
|
|
33124
33176
|
} else if (customPoliciesPath && (typeof customPoliciesPath === "string" || customPoliciesPath.length > 0)) {
|
|
33125
33177
|
const incoming = (typeof customPoliciesPath === "string" ? [customPoliciesPath] : customPoliciesPath).map((path) => resolve30(path));
|
|
33126
33178
|
const carried = (previousConfig.customPoliciesPaths ?? (previousConfig.customPoliciesPath ? [previousConfig.customPoliciesPath] : [])).map((path) => resolve30(path)).filter((path) => {
|
|
33127
|
-
if (
|
|
33179
|
+
if (existsSync45(path))
|
|
33128
33180
|
return true;
|
|
33129
33181
|
console.log(`Dropping custom policies path (file no longer exists): ${path}`);
|
|
33130
33182
|
return false;
|
|
@@ -33352,7 +33404,7 @@ async function removeHooks2(policyNames, scope = "user", cwd, opts) {
|
|
|
33352
33404
|
const scopesToRemove = scope === "all" ? [...integration.scopes] : integration.scopes.includes(scope) ? [scope] : [];
|
|
33353
33405
|
for (const s of scopesToRemove) {
|
|
33354
33406
|
const settingsPaths = settingsPathsFor(integration, s, cwd);
|
|
33355
|
-
const existing = cliId === "hermes" ? settingsPaths : settingsPaths.filter((p) =>
|
|
33407
|
+
const existing = cliId === "hermes" ? settingsPaths : settingsPaths.filter((p) => existsSync45(p));
|
|
33356
33408
|
if (existing.length === 0) {
|
|
33357
33409
|
if (scope !== "all" && selectedClis.length === 1) {
|
|
33358
33410
|
console.log("No settings file found. Nothing to remove.");
|
|
@@ -33498,7 +33550,7 @@ async function listHooks(cwd) {
|
|
|
33498
33550
|
for (const path of explicitPaths) {
|
|
33499
33551
|
const absPath = resolve30(findProjectConfigDir(cwd ?? process.cwd()), path);
|
|
33500
33552
|
groups.push(note(absPath, opts));
|
|
33501
|
-
if (!
|
|
33553
|
+
if (!existsSync45(absPath)) {
|
|
33502
33554
|
groups.push(warning([`file not found: ${absPath}`], opts));
|
|
33503
33555
|
continue;
|
|
33504
33556
|
}
|
|
@@ -33625,6 +33677,7 @@ var init_manager2 = __esm(() => {
|
|
|
33625
33677
|
init_pack_store();
|
|
33626
33678
|
init_pack_manifest();
|
|
33627
33679
|
init_policy_evaluator();
|
|
33680
|
+
init_daemon_service();
|
|
33628
33681
|
init_tui();
|
|
33629
33682
|
VALID_POLICY_NAMES2 = new Set(BUILTIN_POLICIES.map((p) => p.name));
|
|
33630
33683
|
});
|
|
@@ -34060,19 +34113,19 @@ function parseScriptArgs(argv) {
|
|
|
34060
34113
|
var init_parse_script_args = () => {};
|
|
34061
34114
|
|
|
34062
34115
|
// scripts/install-diagnosis.mjs
|
|
34063
|
-
import { existsSync as
|
|
34116
|
+
import { existsSync as existsSync46, readFileSync as readFileSync36, realpathSync as realpathSync4 } from "node:fs";
|
|
34064
34117
|
import { dirname as dirname22, resolve as resolve32 } from "node:path";
|
|
34065
34118
|
import { homedir as homedir32, platform as platform5 } from "node:os";
|
|
34066
34119
|
import { spawnSync } from "node:child_process";
|
|
34067
34120
|
function findPackageRoot(start) {
|
|
34068
34121
|
try {
|
|
34069
34122
|
let dir = realpathSync4(start);
|
|
34070
|
-
if (
|
|
34123
|
+
if (existsSync46(dir) && !existsSync46(resolve32(dir, "package.json"))) {
|
|
34071
34124
|
dir = dirname22(dir);
|
|
34072
34125
|
}
|
|
34073
34126
|
while (true) {
|
|
34074
34127
|
const pkgPath = resolve32(dir, "package.json");
|
|
34075
|
-
if (
|
|
34128
|
+
if (existsSync46(pkgPath)) {
|
|
34076
34129
|
try {
|
|
34077
34130
|
const pkg = JSON.parse(readFileSync36(pkgPath, "utf8"));
|
|
34078
34131
|
if (pkg.name === PKG_NAME)
|
|
@@ -34119,7 +34172,7 @@ function locateNpmGlobal() {
|
|
|
34119
34172
|
if (!root)
|
|
34120
34173
|
return null;
|
|
34121
34174
|
const candidate = resolve32(root, PKG_NAME);
|
|
34122
|
-
return
|
|
34175
|
+
return existsSync46(resolve32(candidate, "package.json")) ? candidate : null;
|
|
34123
34176
|
} catch {
|
|
34124
34177
|
return null;
|
|
34125
34178
|
}
|
|
@@ -34127,7 +34180,7 @@ function locateNpmGlobal() {
|
|
|
34127
34180
|
function locateBunGlobal() {
|
|
34128
34181
|
try {
|
|
34129
34182
|
const candidate = resolve32(homedir32(), ".bun", "install", "global", "node_modules", PKG_NAME);
|
|
34130
|
-
return
|
|
34183
|
+
return existsSync46(resolve32(candidate, "package.json")) ? candidate : null;
|
|
34131
34184
|
} catch {
|
|
34132
34185
|
return null;
|
|
34133
34186
|
}
|
|
@@ -34230,7 +34283,7 @@ var init_dashboard_host = __esm(() => {
|
|
|
34230
34283
|
|
|
34231
34284
|
// scripts/launch.ts
|
|
34232
34285
|
import { spawn as spawn2 } from "child_process";
|
|
34233
|
-
import { realpathSync as realpathSync5, existsSync as
|
|
34286
|
+
import { realpathSync as realpathSync5, existsSync as existsSync47 } from "node:fs";
|
|
34234
34287
|
import { resolve as resolve33, dirname as dirname23 } from "node:path";
|
|
34235
34288
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
34236
34289
|
import { createInterface } from "node:readline";
|
|
@@ -34257,7 +34310,7 @@ function launch(mode) {
|
|
|
34257
34310
|
cmd = "node";
|
|
34258
34311
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ?? resolve33(dirname23(realpathSync5(fileURLToPath2(import.meta.url))), "..");
|
|
34259
34312
|
const serverJsPath = resolve33(packageRoot, ".next/standalone/server.js");
|
|
34260
|
-
if (!
|
|
34313
|
+
if (!existsSync47(serverJsPath)) {
|
|
34261
34314
|
let shadowMessage = null;
|
|
34262
34315
|
try {
|
|
34263
34316
|
const diag = diagnoseShadow({ selfPackageRoot: packageRoot, selfVersion: version2 });
|
|
@@ -35015,7 +35068,7 @@ import {
|
|
|
35015
35068
|
cpSync as cpSync2,
|
|
35016
35069
|
readFileSync as readFileSync37,
|
|
35017
35070
|
writeFileSync as writeFileSync26,
|
|
35018
|
-
existsSync as
|
|
35071
|
+
existsSync as existsSync48,
|
|
35019
35072
|
lstatSync as lstatSync2,
|
|
35020
35073
|
mkdirSync as mkdirSync28,
|
|
35021
35074
|
renameSync as renameSync10,
|
|
@@ -35025,7 +35078,7 @@ import {
|
|
|
35025
35078
|
import { resolve as resolve34, dirname as dirname24 } from "node:path";
|
|
35026
35079
|
function readYamlDoc2(path) {
|
|
35027
35080
|
try {
|
|
35028
|
-
return
|
|
35081
|
+
return existsSync48(path) ? $parseDocument(readFileSync37(path, "utf8")) : $parseDocument("");
|
|
35029
35082
|
} catch {
|
|
35030
35083
|
return $parseDocument("");
|
|
35031
35084
|
}
|
|
@@ -35047,15 +35100,15 @@ function hasManagedHermesPlugin2(settingsPath) {
|
|
|
35047
35100
|
try {
|
|
35048
35101
|
if (lstatSync2(pluginPath).isSymbolicLink())
|
|
35049
35102
|
return false;
|
|
35050
|
-
if (!
|
|
35103
|
+
if (!existsSync48(resolve34(pluginPath, HERMES_PLUGIN_MARKER2)))
|
|
35051
35104
|
return false;
|
|
35052
|
-
return HERMES_PLUGIN_FILES2.every((file) =>
|
|
35105
|
+
return HERMES_PLUGIN_FILES2.every((file) => existsSync48(resolve34(pluginPath, file)));
|
|
35053
35106
|
} catch {
|
|
35054
35107
|
return false;
|
|
35055
35108
|
}
|
|
35056
35109
|
}
|
|
35057
35110
|
function hermesConfigState2(settingsPath) {
|
|
35058
|
-
if (!
|
|
35111
|
+
if (!existsSync48(settingsPath)) {
|
|
35059
35112
|
return { pluginEnabled: false, legacyShellHookPresent: false };
|
|
35060
35113
|
}
|
|
35061
35114
|
const doc = readYamlDoc2(settingsPath);
|
|
@@ -35084,7 +35137,7 @@ function hermesProfileHealth() {
|
|
|
35084
35137
|
});
|
|
35085
35138
|
}
|
|
35086
35139
|
function hermesProfileStatusRows() {
|
|
35087
|
-
return hermesProfileHealth().filter((profile) =>
|
|
35140
|
+
return hermesProfileHealth().filter((profile) => existsSync48(profile.home)).map((profile) => {
|
|
35088
35141
|
const problems = [];
|
|
35089
35142
|
if (!profile.pluginInstalled)
|
|
35090
35143
|
problems.push("plugin files missing or incomplete");
|
|
@@ -35110,7 +35163,7 @@ var init_integrations2 = __esm(() => {
|
|
|
35110
35163
|
|
|
35111
35164
|
// scripts/launch.ts
|
|
35112
35165
|
import { spawn as spawn3 } from "child_process";
|
|
35113
|
-
import { realpathSync as realpathSync6, existsSync as
|
|
35166
|
+
import { realpathSync as realpathSync6, existsSync as existsSync49 } from "node:fs";
|
|
35114
35167
|
import { resolve as resolve35, dirname as dirname25 } from "node:path";
|
|
35115
35168
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
35116
35169
|
import { createInterface as createInterface2 } from "node:readline";
|
|
@@ -35137,7 +35190,7 @@ function launch2(mode) {
|
|
|
35137
35190
|
cmd = "node";
|
|
35138
35191
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ?? resolve35(dirname25(realpathSync6(fileURLToPath3(import.meta.url))), "..");
|
|
35139
35192
|
const serverJsPath = resolve35(packageRoot, ".next/standalone/server.js");
|
|
35140
|
-
if (!
|
|
35193
|
+
if (!existsSync49(serverJsPath)) {
|
|
35141
35194
|
let shadowMessage = null;
|
|
35142
35195
|
try {
|
|
35143
35196
|
const diag = diagnoseShadow({ selfPackageRoot: packageRoot, selfVersion: version2 });
|
|
@@ -35237,7 +35290,7 @@ import { realpathSync as realpathSync7 } from "fs";
|
|
|
35237
35290
|
import { dirname as dirname26, resolve as resolve36 } from "path";
|
|
35238
35291
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
35239
35292
|
// package.json
|
|
35240
|
-
var version = "1.0.6-beta.
|
|
35293
|
+
var version = "1.0.6-beta.1";
|
|
35241
35294
|
|
|
35242
35295
|
// bin/failproofai.mjs
|
|
35243
35296
|
if (!process.env.FAILPROOFAI_PACKAGE_ROOT) {
|