failproofai 1.0.5-beta.1 → 1.0.5
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 +6 -6
- package/.next/standalone/.next/prerender-manifest.json +4 -4
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +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/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +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.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page.js.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/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
- package/.next/standalone/.next/server/app/policies/page.js +1 -1
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page/build-manifest.json +3 -3
- package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -4
- 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/_09dz7xv._.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/_1vslkoe._.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]__00y9ww2._.js +1 -1
- 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]__0n_lxhg._.js → [root-of-the-server]__0bym1os._.js} +1 -1
- 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]__0oa1lav._.js +1 -1
- 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]__0s740oi._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0sz_5na._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__05g1k7_._.js → [root-of-the-server]__15k-dqb._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1ctpynv._.js +1 -1
- 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]__1u6sn69._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_17noq1a._.js → _0guaevg._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_1_ozgif._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_0iv28v5._.js → _1b78kcp._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1es2j7i._.js +2 -2
- 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 +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/lib_codex-projects_ts_0pqlw37._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +6 -6
- 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/{0qytob94jbzs6.js → 021ydrq6rhpsi.js} +1 -1
- package/.next/standalone/.next/static/chunks/{26tf_lpco5n-v.js → 0y8_1s45gbqmn.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2b014kj28p0vz.js → 11s_v03ub6nss.js} +1 -1
- package/.next/standalone/.next/static/chunks/14b3ezufe5411.js +1 -0
- package/.next/standalone/.next/static/chunks/{3kltzmx9k_t6x.js → 1c6aptmytnu6q.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3vjaz4hld9oo8.js → 1oskk7pdo8aon.js} +1 -1
- package/.next/standalone/.next/static/chunks/{074xcclgow3yh.js → 1vb33xa6j9y2q.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3pmi7qhtmniku.js → 252xreaecy80h.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3_fnbc-v5r-9e.js → 2xycd6mjg00fb.js} +1 -1
- package/.next/standalone/.next/static/chunks/{41ejnuj2d9g7_.js → 2zafgs90r_leq.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3q1rji38vuvr4.js → 3bleyy40s99f2.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3qxl_gibq3bas.js → 3w46euc60dx39.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-1xgsp63yhrdu5.js → turbopack-3p73obe0xmrxm.js} +1 -1
- package/.next/standalone/lib/openclaw-profiles.ts +78 -0
- package/.next/standalone/lib/openclaw-projects.ts +3 -3
- package/.next/standalone/lib/sqlite-reader.ts +165 -9
- package/.next/standalone/package.json +9 -9
- package/.next/standalone/server.js +1 -1
- package/dist/cli.mjs +845 -684
- package/dist/worker.mjs +129 -17
- package/lib/openclaw-profiles.ts +78 -0
- package/lib/openclaw-projects.ts +3 -3
- package/lib/sqlite-reader.ts +165 -9
- package/openclaw-plugin/index.js +13 -7
- package/openclaw-plugin/workspace-context.js +93 -0
- package/package.json +9 -9
- package/src/hooks/integrations.ts +22 -14
- package/.next/standalone/.next/static/chunks/25cn9xpv4r1ow.js +0 -1
- /package/.next/standalone/.next/static/{Qexks15mjEoPt6cN3D2jb → uFpAs_vIXSo6qBzmkXPWD}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{Qexks15mjEoPt6cN3D2jb → uFpAs_vIXSo6qBzmkXPWD}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{Qexks15mjEoPt6cN3D2jb → uFpAs_vIXSo6qBzmkXPWD}/_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.5
|
|
32
|
+
var version2 = "1.0.5", package_default;
|
|
33
33
|
var init_package = __esm(() => {
|
|
34
34
|
package_default = {
|
|
35
35
|
name: "failproofai",
|
|
@@ -154,16 +154,16 @@ var init_package = __esm(() => {
|
|
|
154
154
|
browserslist: "4.28.8"
|
|
155
155
|
},
|
|
156
156
|
optionalDependencies: {
|
|
157
|
-
"@failproofai/failproofaid-linux-x64": "1.0.5
|
|
158
|
-
"@failproofai/failproofaid-linux-arm64": "1.0.5
|
|
159
|
-
"@failproofai/failproofaid-darwin-x64": "1.0.5
|
|
160
|
-
"@failproofai/failproofaid-darwin-arm64": "1.0.5
|
|
157
|
+
"@failproofai/failproofaid-linux-x64": "1.0.5",
|
|
158
|
+
"@failproofai/failproofaid-linux-arm64": "1.0.5",
|
|
159
|
+
"@failproofai/failproofaid-darwin-x64": "1.0.5",
|
|
160
|
+
"@failproofai/failproofaid-darwin-arm64": "1.0.5"
|
|
161
161
|
},
|
|
162
162
|
failproofaidBinaries: {
|
|
163
|
-
"linux-x64": "
|
|
164
|
-
"linux-arm64": "
|
|
165
|
-
"darwin-x64": "
|
|
166
|
-
"darwin-arm64": "
|
|
163
|
+
"linux-x64": "5fb4c8a993af9279e46306803c68d6650ea57290bbd7ec92795a7f7b696bb506",
|
|
164
|
+
"linux-arm64": "21c502073649d9c12710fc2707b9dee08b7ac1528b8544b85a755017c8fdff0e",
|
|
165
|
+
"darwin-x64": "5e02c2f4887793c64f5553d8d00fd21507f88dce1a6869ca1aca2f6468129373",
|
|
166
|
+
"darwin-arm64": "65be288a3485ca86869580a036e6c7e9b7b5660a6589143b375586b6c28b5c84"
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
169
|
});
|
|
@@ -11574,32 +11574,75 @@ function hermesProjectNameCandidates(name) {
|
|
|
11574
11574
|
var PROFILES_DIR = "profiles", HERMES_DEFAULT_PROFILE = "default";
|
|
11575
11575
|
var init_hermes_profiles = () => {};
|
|
11576
11576
|
|
|
11577
|
+
// lib/openclaw-profiles.ts
|
|
11578
|
+
import { existsSync as existsSync6, readdirSync as readdirSync2 } from "node:fs";
|
|
11579
|
+
import { homedir as homedir5 } from "node:os";
|
|
11580
|
+
import { basename as basename2, dirname as dirname4, join as join4, resolve as resolve7 } from "node:path";
|
|
11581
|
+
function openclawProfileHome() {
|
|
11582
|
+
const stateDir = (process.env.OPENCLAW_STATE_DIR ?? "").trim();
|
|
11583
|
+
if (stateDir)
|
|
11584
|
+
return resolve7(stateDir);
|
|
11585
|
+
const openclawHome = (process.env.OPENCLAW_HOME ?? "").trim();
|
|
11586
|
+
if (openclawHome)
|
|
11587
|
+
return resolve7(openclawHome);
|
|
11588
|
+
const configPath = (process.env.OPENCLAW_CONFIG_PATH || "").trim();
|
|
11589
|
+
if (configPath)
|
|
11590
|
+
return dirname4(resolve7(configPath));
|
|
11591
|
+
return join4(homedir5(), ".openclaw");
|
|
11592
|
+
}
|
|
11593
|
+
function listOpenClawProfiles() {
|
|
11594
|
+
const activeHome = openclawProfileHome();
|
|
11595
|
+
const activeBase = basename2(activeHome);
|
|
11596
|
+
if (activeBase !== ".openclaw" && !activeBase.startsWith(".openclaw-")) {
|
|
11597
|
+
return [{ name: OPENCLAW_DEFAULT_PROFILE, home: activeHome }];
|
|
11598
|
+
}
|
|
11599
|
+
const parent = dirname4(activeHome);
|
|
11600
|
+
const defaultHome = join4(parent, ".openclaw");
|
|
11601
|
+
const out = [
|
|
11602
|
+
{ name: OPENCLAW_DEFAULT_PROFILE, home: defaultHome }
|
|
11603
|
+
];
|
|
11604
|
+
let entries;
|
|
11605
|
+
try {
|
|
11606
|
+
entries = readdirSync2(parent, { withFileTypes: true });
|
|
11607
|
+
} catch {
|
|
11608
|
+
return out;
|
|
11609
|
+
}
|
|
11610
|
+
const named = entries.filter((entry) => (entry.isDirectory() || entry.isSymbolicLink()) && entry.name.startsWith(".openclaw-") && entry.name.length > ".openclaw-".length && existsSync6(join4(parent, entry.name, "openclaw.json"))).map((entry) => ({
|
|
11611
|
+
name: entry.name.slice(".openclaw-".length),
|
|
11612
|
+
home: join4(parent, entry.name)
|
|
11613
|
+
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
11614
|
+
out.push(...named);
|
|
11615
|
+
return out;
|
|
11616
|
+
}
|
|
11617
|
+
var OPENCLAW_DEFAULT_PROFILE = "default";
|
|
11618
|
+
var init_openclaw_profiles = () => {};
|
|
11619
|
+
|
|
11577
11620
|
// src/hooks/integrations.ts
|
|
11578
11621
|
import { execSync as execSync3 } from "node:child_process";
|
|
11579
|
-
import { readFileSync as readFileSync5, writeFileSync as writeFileSync3, existsSync as
|
|
11580
|
-
import { resolve as
|
|
11622
|
+
import { readFileSync as readFileSync5, writeFileSync as writeFileSync3, existsSync as existsSync7, mkdirSync as mkdirSync4, unlinkSync } from "node:fs";
|
|
11623
|
+
import { resolve as resolve8, dirname as dirname5 } from "node:path";
|
|
11581
11624
|
import { fileURLToPath } from "node:url";
|
|
11582
|
-
import { homedir as
|
|
11625
|
+
import { homedir as homedir6 } from "node:os";
|
|
11583
11626
|
function readJsonFile(path) {
|
|
11584
|
-
if (!
|
|
11627
|
+
if (!existsSync7(path))
|
|
11585
11628
|
return {};
|
|
11586
11629
|
const raw = readFileSync5(path, "utf8");
|
|
11587
11630
|
return JSON.parse(raw);
|
|
11588
11631
|
}
|
|
11589
11632
|
function writeJsonFile(path, data) {
|
|
11590
|
-
mkdirSync4(
|
|
11633
|
+
mkdirSync4(dirname5(path), { recursive: true });
|
|
11591
11634
|
writeFileSync3(path, JSON.stringify(data, null, 2) + `
|
|
11592
11635
|
`, "utf8");
|
|
11593
11636
|
}
|
|
11594
11637
|
function readYamlDoc(path) {
|
|
11595
11638
|
try {
|
|
11596
|
-
return
|
|
11639
|
+
return existsSync7(path) ? $parseDocument(readFileSync5(path, "utf8")) : $parseDocument("");
|
|
11597
11640
|
} catch {
|
|
11598
11641
|
return $parseDocument("");
|
|
11599
11642
|
}
|
|
11600
11643
|
}
|
|
11601
11644
|
function writeYamlDoc(path, doc) {
|
|
11602
|
-
mkdirSync4(
|
|
11645
|
+
mkdirSync4(dirname5(path), { recursive: true });
|
|
11603
11646
|
writeFileSync3(path, doc.toString(), "utf8");
|
|
11604
11647
|
}
|
|
11605
11648
|
function isMarkedHook(hook) {
|
|
@@ -11643,7 +11686,7 @@ function isMarkedCopilotHook(hook) {
|
|
|
11643
11686
|
return false;
|
|
11644
11687
|
}
|
|
11645
11688
|
function opencodePluginFilePath(settingsPath) {
|
|
11646
|
-
return
|
|
11689
|
+
return resolve8(dirname5(settingsPath), "plugins", "failproofai.mjs");
|
|
11647
11690
|
}
|
|
11648
11691
|
function buildOpenCodePluginShim(binaryPath, scope) {
|
|
11649
11692
|
const useNpx = scope === "project";
|
|
@@ -11858,8 +11901,8 @@ export default async function failproofaiPlugin({ client, directory }) {
|
|
|
11858
11901
|
function getPiExtensionPath() {
|
|
11859
11902
|
const fromEnv = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
11860
11903
|
if (fromEnv)
|
|
11861
|
-
return
|
|
11862
|
-
return
|
|
11904
|
+
return resolve8(fromEnv, "pi-extension");
|
|
11905
|
+
return resolve8(fileURLToPath(import.meta.url), "..", "..", "..", "pi-extension");
|
|
11863
11906
|
}
|
|
11864
11907
|
function isFailproofaiPiEntry(source) {
|
|
11865
11908
|
if (typeof source !== "string")
|
|
@@ -11870,8 +11913,8 @@ function isFailproofaiPiEntry(source) {
|
|
|
11870
11913
|
}
|
|
11871
11914
|
function makePiProjectRelativeEntry(extPath) {
|
|
11872
11915
|
const cwd = process.cwd();
|
|
11873
|
-
const cwdResolved =
|
|
11874
|
-
const extResolved =
|
|
11916
|
+
const cwdResolved = resolve8(cwd);
|
|
11917
|
+
const extResolved = resolve8(extPath);
|
|
11875
11918
|
if (extResolved.startsWith(cwdResolved + "/") || extResolved === cwdResolved) {
|
|
11876
11919
|
const fromSettingsDir = "../" + extResolved.slice(cwdResolved.length + 1);
|
|
11877
11920
|
return fromSettingsDir;
|
|
@@ -11879,7 +11922,7 @@ function makePiProjectRelativeEntry(extPath) {
|
|
|
11879
11922
|
return extResolved;
|
|
11880
11923
|
}
|
|
11881
11924
|
function hermesConfigHasHooks(settingsPath) {
|
|
11882
|
-
if (!
|
|
11925
|
+
if (!existsSync7(settingsPath))
|
|
11883
11926
|
return false;
|
|
11884
11927
|
try {
|
|
11885
11928
|
const doc = readYamlDoc(settingsPath);
|
|
@@ -11897,8 +11940,8 @@ function hermesConfigHasHooks(settingsPath) {
|
|
|
11897
11940
|
function getOpenClawPluginPath() {
|
|
11898
11941
|
const fromEnv = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
11899
11942
|
if (fromEnv)
|
|
11900
|
-
return
|
|
11901
|
-
return
|
|
11943
|
+
return resolve8(fromEnv, "openclaw-plugin");
|
|
11944
|
+
return resolve8(fileURLToPath(import.meta.url), "..", "..", "..", "openclaw-plugin");
|
|
11902
11945
|
}
|
|
11903
11946
|
function isFailproofaiOpenClawPath(p) {
|
|
11904
11947
|
if (typeof p !== "string")
|
|
@@ -11928,6 +11971,7 @@ var claudeCode, codex, copilot, cursor, OPENCODE_PLUGIN_REL_PATH = "./plugins/fa
|
|
|
11928
11971
|
var init_integrations = __esm(() => {
|
|
11929
11972
|
init_dist();
|
|
11930
11973
|
init_hermes_profiles();
|
|
11974
|
+
init_openclaw_profiles();
|
|
11931
11975
|
init_types();
|
|
11932
11976
|
claudeCode = {
|
|
11933
11977
|
id: "claude",
|
|
@@ -11935,14 +11979,14 @@ var init_integrations = __esm(() => {
|
|
|
11935
11979
|
scopes: HOOK_SCOPES,
|
|
11936
11980
|
eventTypes: CLAUDE_INSTALL_EVENT_TYPES,
|
|
11937
11981
|
getSettingsPath(scope, cwd) {
|
|
11938
|
-
const base = cwd ?
|
|
11982
|
+
const base = cwd ? resolve8(cwd) : process.cwd();
|
|
11939
11983
|
switch (scope) {
|
|
11940
11984
|
case "user":
|
|
11941
|
-
return
|
|
11985
|
+
return resolve8(homedir6(), ".claude", "settings.json");
|
|
11942
11986
|
case "project":
|
|
11943
|
-
return
|
|
11987
|
+
return resolve8(base, ".claude", "settings.json");
|
|
11944
11988
|
case "local":
|
|
11945
|
-
return
|
|
11989
|
+
return resolve8(base, ".claude", "settings.local.json");
|
|
11946
11990
|
}
|
|
11947
11991
|
},
|
|
11948
11992
|
readSettings(settingsPath) {
|
|
@@ -12038,7 +12082,7 @@ var init_integrations = __esm(() => {
|
|
|
12038
12082
|
},
|
|
12039
12083
|
hooksInstalledInSettings(scope, cwd) {
|
|
12040
12084
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12041
|
-
if (!
|
|
12085
|
+
if (!existsSync7(settingsPath))
|
|
12042
12086
|
return false;
|
|
12043
12087
|
try {
|
|
12044
12088
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12067,14 +12111,14 @@ var init_integrations = __esm(() => {
|
|
|
12067
12111
|
scopes: CODEX_HOOK_SCOPES,
|
|
12068
12112
|
eventTypes: CODEX_HOOK_EVENT_TYPES,
|
|
12069
12113
|
getSettingsPath(scope, cwd) {
|
|
12070
|
-
const base = cwd ?
|
|
12114
|
+
const base = cwd ? resolve8(cwd) : process.cwd();
|
|
12071
12115
|
switch (scope) {
|
|
12072
12116
|
case "user":
|
|
12073
|
-
return
|
|
12117
|
+
return resolve8(homedir6(), ".codex", "hooks.json");
|
|
12074
12118
|
case "project":
|
|
12075
|
-
return
|
|
12119
|
+
return resolve8(base, ".codex", "hooks.json");
|
|
12076
12120
|
case "local":
|
|
12077
|
-
return
|
|
12121
|
+
return resolve8(base, ".codex", "hooks.json");
|
|
12078
12122
|
}
|
|
12079
12123
|
},
|
|
12080
12124
|
readSettings(settingsPath) {
|
|
@@ -12154,7 +12198,7 @@ var init_integrations = __esm(() => {
|
|
|
12154
12198
|
},
|
|
12155
12199
|
hooksInstalledInSettings(scope, cwd) {
|
|
12156
12200
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12157
|
-
if (!
|
|
12201
|
+
if (!existsSync7(settingsPath))
|
|
12158
12202
|
return false;
|
|
12159
12203
|
try {
|
|
12160
12204
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12183,14 +12227,14 @@ var init_integrations = __esm(() => {
|
|
|
12183
12227
|
scopes: COPILOT_HOOK_SCOPES,
|
|
12184
12228
|
eventTypes: COPILOT_HOOK_EVENT_TYPES,
|
|
12185
12229
|
getSettingsPath(scope, cwd) {
|
|
12186
|
-
const base = cwd ?
|
|
12230
|
+
const base = cwd ? resolve8(cwd) : process.cwd();
|
|
12187
12231
|
switch (scope) {
|
|
12188
12232
|
case "user":
|
|
12189
|
-
return
|
|
12233
|
+
return resolve8(homedir6(), ".copilot", "hooks", "failproofai.json");
|
|
12190
12234
|
case "project":
|
|
12191
|
-
return
|
|
12235
|
+
return resolve8(base, ".github", "hooks", "failproofai.json");
|
|
12192
12236
|
case "local":
|
|
12193
|
-
return
|
|
12237
|
+
return resolve8(base, ".github", "hooks", "failproofai.json");
|
|
12194
12238
|
}
|
|
12195
12239
|
},
|
|
12196
12240
|
readSettings(settingsPath) {
|
|
@@ -12268,7 +12312,7 @@ var init_integrations = __esm(() => {
|
|
|
12268
12312
|
},
|
|
12269
12313
|
hooksInstalledInSettings(scope, cwd) {
|
|
12270
12314
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12271
|
-
if (!
|
|
12315
|
+
if (!existsSync7(settingsPath))
|
|
12272
12316
|
return false;
|
|
12273
12317
|
try {
|
|
12274
12318
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12297,14 +12341,14 @@ var init_integrations = __esm(() => {
|
|
|
12297
12341
|
scopes: CURSOR_HOOK_SCOPES,
|
|
12298
12342
|
eventTypes: CURSOR_HOOK_EVENT_TYPES,
|
|
12299
12343
|
getSettingsPath(scope, cwd) {
|
|
12300
|
-
const base = cwd ?
|
|
12344
|
+
const base = cwd ? resolve8(cwd) : process.cwd();
|
|
12301
12345
|
switch (scope) {
|
|
12302
12346
|
case "user":
|
|
12303
|
-
return
|
|
12347
|
+
return resolve8(homedir6(), ".cursor", "hooks.json");
|
|
12304
12348
|
case "project":
|
|
12305
|
-
return
|
|
12349
|
+
return resolve8(base, ".cursor", "hooks.json");
|
|
12306
12350
|
case "local":
|
|
12307
|
-
return
|
|
12351
|
+
return resolve8(base, ".cursor", "hooks.json");
|
|
12308
12352
|
}
|
|
12309
12353
|
},
|
|
12310
12354
|
readSettings(settingsPath) {
|
|
@@ -12371,7 +12415,7 @@ var init_integrations = __esm(() => {
|
|
|
12371
12415
|
},
|
|
12372
12416
|
hooksInstalledInSettings(scope, cwd) {
|
|
12373
12417
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12374
|
-
if (!
|
|
12418
|
+
if (!existsSync7(settingsPath))
|
|
12375
12419
|
return false;
|
|
12376
12420
|
try {
|
|
12377
12421
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12396,14 +12440,14 @@ var init_integrations = __esm(() => {
|
|
|
12396
12440
|
scopes: OPENCODE_HOOK_SCOPES,
|
|
12397
12441
|
eventTypes: OPENCODE_HOOK_EVENT_TYPES,
|
|
12398
12442
|
getSettingsPath(scope, cwd) {
|
|
12399
|
-
const base = cwd ?
|
|
12443
|
+
const base = cwd ? resolve8(cwd) : process.cwd();
|
|
12400
12444
|
switch (scope) {
|
|
12401
12445
|
case "user":
|
|
12402
|
-
return
|
|
12446
|
+
return resolve8(homedir6(), ".config", "opencode", "opencode.json");
|
|
12403
12447
|
case "project":
|
|
12404
|
-
return
|
|
12448
|
+
return resolve8(base, ".opencode", "opencode.json");
|
|
12405
12449
|
case "local":
|
|
12406
|
-
return
|
|
12450
|
+
return resolve8(base, ".opencode", "opencode.json");
|
|
12407
12451
|
}
|
|
12408
12452
|
},
|
|
12409
12453
|
readSettings(settingsPath) {
|
|
@@ -12414,7 +12458,7 @@ var init_integrations = __esm(() => {
|
|
|
12414
12458
|
},
|
|
12415
12459
|
buildHookEntry(_binaryPath, _eventType, scope) {
|
|
12416
12460
|
if (scope === "user") {
|
|
12417
|
-
const abs =
|
|
12461
|
+
const abs = resolve8(homedir6(), ".config", "opencode", "plugins", "failproofai.mjs");
|
|
12418
12462
|
return { spec: `file://${abs}`, [FAILPROOFAI_HOOK_MARKER]: true };
|
|
12419
12463
|
}
|
|
12420
12464
|
return { spec: OPENCODE_PLUGIN_REL_PATH, [FAILPROOFAI_HOOK_MARKER]: true };
|
|
@@ -12429,9 +12473,9 @@ var init_integrations = __esm(() => {
|
|
|
12429
12473
|
writeHookEntries(settings, binaryPath, scope) {
|
|
12430
12474
|
const s = settings;
|
|
12431
12475
|
const effectiveScope = scope ?? "project";
|
|
12432
|
-
const settingsPath = effectiveScope === "user" ?
|
|
12476
|
+
const settingsPath = effectiveScope === "user" ? resolve8(homedir6(), ".config", "opencode", "opencode.json") : resolve8(process.cwd(), ".opencode", "opencode.json");
|
|
12433
12477
|
const pluginPath = opencodePluginFilePath(settingsPath);
|
|
12434
|
-
mkdirSync4(
|
|
12478
|
+
mkdirSync4(dirname5(pluginPath), { recursive: true });
|
|
12435
12479
|
writeFileSync3(pluginPath, buildOpenCodePluginShim(binaryPath, effectiveScope), "utf8");
|
|
12436
12480
|
if (!Array.isArray(s.plugin))
|
|
12437
12481
|
s.plugin = [];
|
|
@@ -12455,7 +12499,7 @@ var init_integrations = __esm(() => {
|
|
|
12455
12499
|
}
|
|
12456
12500
|
this.writeSettings(settingsPath, settings);
|
|
12457
12501
|
const pluginPath = opencodePluginFilePath(settingsPath);
|
|
12458
|
-
if (
|
|
12502
|
+
if (existsSync7(pluginPath)) {
|
|
12459
12503
|
try {
|
|
12460
12504
|
const content = readFileSync5(pluginPath, "utf8");
|
|
12461
12505
|
if (content.includes(FAILPROOFAI_HOOK_MARKER)) {
|
|
@@ -12469,7 +12513,7 @@ var init_integrations = __esm(() => {
|
|
|
12469
12513
|
},
|
|
12470
12514
|
hooksInstalledInSettings(scope, cwd) {
|
|
12471
12515
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12472
|
-
if (!
|
|
12516
|
+
if (!existsSync7(settingsPath))
|
|
12473
12517
|
return false;
|
|
12474
12518
|
try {
|
|
12475
12519
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12479,7 +12523,7 @@ var init_integrations = __esm(() => {
|
|
|
12479
12523
|
if (!hasEntry)
|
|
12480
12524
|
return false;
|
|
12481
12525
|
const pluginPath = opencodePluginFilePath(settingsPath);
|
|
12482
|
-
if (!
|
|
12526
|
+
if (!existsSync7(pluginPath))
|
|
12483
12527
|
return false;
|
|
12484
12528
|
const content = readFileSync5(pluginPath, "utf8");
|
|
12485
12529
|
return content.includes(FAILPROOFAI_HOOK_MARKER);
|
|
@@ -12497,14 +12541,14 @@ var init_integrations = __esm(() => {
|
|
|
12497
12541
|
scopes: PI_HOOK_SCOPES,
|
|
12498
12542
|
eventTypes: PI_HOOK_EVENT_TYPES,
|
|
12499
12543
|
getSettingsPath(scope, cwd) {
|
|
12500
|
-
const base = cwd ?
|
|
12544
|
+
const base = cwd ? resolve8(cwd) : process.cwd();
|
|
12501
12545
|
switch (scope) {
|
|
12502
12546
|
case "user":
|
|
12503
|
-
return
|
|
12547
|
+
return resolve8(homedir6(), ".pi", "agent", "settings.json");
|
|
12504
12548
|
case "project":
|
|
12505
|
-
return
|
|
12549
|
+
return resolve8(base, ".pi", "settings.json");
|
|
12506
12550
|
case "local":
|
|
12507
|
-
return
|
|
12551
|
+
return resolve8(base, ".pi", "settings.json");
|
|
12508
12552
|
}
|
|
12509
12553
|
},
|
|
12510
12554
|
readSettings(settingsPath) {
|
|
@@ -12546,7 +12590,7 @@ var init_integrations = __esm(() => {
|
|
|
12546
12590
|
}
|
|
12547
12591
|
},
|
|
12548
12592
|
removeHooksFromFile(settingsPath) {
|
|
12549
|
-
if (!
|
|
12593
|
+
if (!existsSync7(settingsPath))
|
|
12550
12594
|
return 0;
|
|
12551
12595
|
const settings = this.readSettings(settingsPath);
|
|
12552
12596
|
if (!Array.isArray(settings.packages))
|
|
@@ -12561,7 +12605,7 @@ var init_integrations = __esm(() => {
|
|
|
12561
12605
|
},
|
|
12562
12606
|
hooksInstalledInSettings(scope, cwd) {
|
|
12563
12607
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12564
|
-
if (!
|
|
12608
|
+
if (!existsSync7(settingsPath))
|
|
12565
12609
|
return false;
|
|
12566
12610
|
try {
|
|
12567
12611
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12582,10 +12626,10 @@ var init_integrations = __esm(() => {
|
|
|
12582
12626
|
scopes: HERMES_HOOK_SCOPES,
|
|
12583
12627
|
eventTypes: HERMES_HOOK_EVENT_TYPES,
|
|
12584
12628
|
getSettingsPath() {
|
|
12585
|
-
return
|
|
12629
|
+
return resolve8(hermesRoot(), "config.yaml");
|
|
12586
12630
|
},
|
|
12587
12631
|
getSettingsPaths() {
|
|
12588
|
-
return listHermesProfiles().map((p) =>
|
|
12632
|
+
return listHermesProfiles().map((p) => resolve8(p.home, "config.yaml"));
|
|
12589
12633
|
},
|
|
12590
12634
|
readSettings(settingsPath) {
|
|
12591
12635
|
return readYamlDoc(settingsPath);
|
|
@@ -12620,7 +12664,7 @@ var init_integrations = __esm(() => {
|
|
|
12620
12664
|
doc.set("hooks_auto_accept", true);
|
|
12621
12665
|
},
|
|
12622
12666
|
removeHooksFromFile(settingsPath) {
|
|
12623
|
-
if (!
|
|
12667
|
+
if (!existsSync7(settingsPath))
|
|
12624
12668
|
return 0;
|
|
12625
12669
|
const doc = readYamlDoc(settingsPath);
|
|
12626
12670
|
const js = doc.toJS() ?? {};
|
|
@@ -12665,7 +12709,10 @@ var init_integrations = __esm(() => {
|
|
|
12665
12709
|
scopes: OPENCLAW_HOOK_SCOPES,
|
|
12666
12710
|
eventTypes: OPENCLAW_HOOK_EVENT_TYPES,
|
|
12667
12711
|
getSettingsPath() {
|
|
12668
|
-
return
|
|
12712
|
+
return resolve8(listOpenClawProfiles()[0].home, "openclaw.json");
|
|
12713
|
+
},
|
|
12714
|
+
getSettingsPaths() {
|
|
12715
|
+
return listOpenClawProfiles().map((profile) => resolve8(profile.home, "openclaw.json"));
|
|
12669
12716
|
},
|
|
12670
12717
|
readSettings(settingsPath) {
|
|
12671
12718
|
return readJsonFile(settingsPath);
|
|
@@ -12710,7 +12757,7 @@ var init_integrations = __esm(() => {
|
|
|
12710
12757
|
hooks.allowConversationAccess = true;
|
|
12711
12758
|
},
|
|
12712
12759
|
removeHooksFromFile(settingsPath) {
|
|
12713
|
-
if (!
|
|
12760
|
+
if (!existsSync7(settingsPath))
|
|
12714
12761
|
return 0;
|
|
12715
12762
|
const settings = this.readSettings(settingsPath);
|
|
12716
12763
|
const plugins = settings.plugins;
|
|
@@ -12738,18 +12785,20 @@ var init_integrations = __esm(() => {
|
|
|
12738
12785
|
return removed;
|
|
12739
12786
|
},
|
|
12740
12787
|
hooksInstalledInSettings(scope, cwd) {
|
|
12741
|
-
const
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12788
|
+
const settingsPaths = settingsPathsFor(this, scope, cwd);
|
|
12789
|
+
return settingsPaths.length > 0 && settingsPaths.every((settingsPath) => {
|
|
12790
|
+
if (!existsSync7(settingsPath))
|
|
12791
|
+
return false;
|
|
12792
|
+
try {
|
|
12793
|
+
const settings = this.readSettings(settingsPath);
|
|
12794
|
+
const paths = settings.plugins?.load?.paths;
|
|
12795
|
+
const pathPresent = Array.isArray(paths) && paths.some((p) => isFailproofaiOpenClawPath(p));
|
|
12796
|
+
const entryEnabled = settings.plugins?.entries?.[OPENCLAW_PLUGIN_ID]?.enabled === true;
|
|
12797
|
+
return pathPresent && entryEnabled;
|
|
12798
|
+
} catch {
|
|
12799
|
+
return false;
|
|
12800
|
+
}
|
|
12801
|
+
});
|
|
12753
12802
|
},
|
|
12754
12803
|
detectInstalled() {
|
|
12755
12804
|
return binaryExists("openclaw");
|
|
@@ -12761,14 +12810,14 @@ var init_integrations = __esm(() => {
|
|
|
12761
12810
|
scopes: FACTORY_HOOK_SCOPES,
|
|
12762
12811
|
eventTypes: FACTORY_HOOK_EVENT_TYPES,
|
|
12763
12812
|
getSettingsPath(scope, cwd) {
|
|
12764
|
-
const base = cwd ?
|
|
12813
|
+
const base = cwd ? resolve8(cwd) : process.cwd();
|
|
12765
12814
|
switch (scope) {
|
|
12766
12815
|
case "user":
|
|
12767
|
-
return
|
|
12816
|
+
return resolve8(homedir6(), ".factory", "hooks.json");
|
|
12768
12817
|
case "project":
|
|
12769
|
-
return
|
|
12818
|
+
return resolve8(base, ".factory", "hooks.json");
|
|
12770
12819
|
case "local":
|
|
12771
|
-
return
|
|
12820
|
+
return resolve8(base, ".factory", "hooks.json");
|
|
12772
12821
|
}
|
|
12773
12822
|
},
|
|
12774
12823
|
readSettings(settingsPath) {
|
|
@@ -12836,7 +12885,7 @@ var init_integrations = __esm(() => {
|
|
|
12836
12885
|
},
|
|
12837
12886
|
hooksInstalledInSettings(scope, cwd) {
|
|
12838
12887
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12839
|
-
if (!
|
|
12888
|
+
if (!existsSync7(settingsPath))
|
|
12840
12889
|
return false;
|
|
12841
12890
|
try {
|
|
12842
12891
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12863,14 +12912,14 @@ var init_integrations = __esm(() => {
|
|
|
12863
12912
|
scopes: DEVIN_HOOK_SCOPES,
|
|
12864
12913
|
eventTypes: DEVIN_HOOK_EVENT_TYPES,
|
|
12865
12914
|
getSettingsPath(scope, cwd) {
|
|
12866
|
-
const base = cwd ?
|
|
12915
|
+
const base = cwd ? resolve8(cwd) : process.cwd();
|
|
12867
12916
|
switch (scope) {
|
|
12868
12917
|
case "user":
|
|
12869
|
-
return
|
|
12918
|
+
return resolve8(homedir6(), ".config", "devin", "config.json");
|
|
12870
12919
|
case "project":
|
|
12871
|
-
return
|
|
12920
|
+
return resolve8(base, ".devin", "config.json");
|
|
12872
12921
|
case "local":
|
|
12873
|
-
return
|
|
12922
|
+
return resolve8(base, ".devin", "config.json");
|
|
12874
12923
|
}
|
|
12875
12924
|
},
|
|
12876
12925
|
readSettings(settingsPath) {
|
|
@@ -12942,7 +12991,7 @@ var init_integrations = __esm(() => {
|
|
|
12942
12991
|
},
|
|
12943
12992
|
hooksInstalledInSettings(scope, cwd) {
|
|
12944
12993
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
12945
|
-
if (!
|
|
12994
|
+
if (!existsSync7(settingsPath))
|
|
12946
12995
|
return false;
|
|
12947
12996
|
try {
|
|
12948
12997
|
const settings = this.readSettings(settingsPath);
|
|
@@ -12972,14 +13021,14 @@ var init_integrations = __esm(() => {
|
|
|
12972
13021
|
scopes: ANTIGRAVITY_HOOK_SCOPES,
|
|
12973
13022
|
eventTypes: ANTIGRAVITY_HOOK_EVENT_TYPES,
|
|
12974
13023
|
getSettingsPath(scope, cwd) {
|
|
12975
|
-
const base = cwd ?
|
|
13024
|
+
const base = cwd ? resolve8(cwd) : process.cwd();
|
|
12976
13025
|
switch (scope) {
|
|
12977
13026
|
case "user":
|
|
12978
|
-
return
|
|
13027
|
+
return resolve8(homedir6(), ".gemini", "config", "hooks.json");
|
|
12979
13028
|
case "project":
|
|
12980
|
-
return
|
|
13029
|
+
return resolve8(base, ".agents", "hooks.json");
|
|
12981
13030
|
case "local":
|
|
12982
|
-
return
|
|
13031
|
+
return resolve8(base, ".agents", "hooks.json");
|
|
12983
13032
|
}
|
|
12984
13033
|
},
|
|
12985
13034
|
readSettings(settingsPath) {
|
|
@@ -13081,7 +13130,7 @@ var init_integrations = __esm(() => {
|
|
|
13081
13130
|
},
|
|
13082
13131
|
hooksInstalledInSettings(scope, cwd) {
|
|
13083
13132
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
13084
|
-
if (!
|
|
13133
|
+
if (!existsSync7(settingsPath))
|
|
13085
13134
|
return false;
|
|
13086
13135
|
try {
|
|
13087
13136
|
const settings = this.readSettings(settingsPath);
|
|
@@ -13113,14 +13162,14 @@ var init_integrations = __esm(() => {
|
|
|
13113
13162
|
scopes: GOOSE_HOOK_SCOPES,
|
|
13114
13163
|
eventTypes: GOOSE_HOOK_EVENT_TYPES,
|
|
13115
13164
|
getSettingsPath(scope, cwd) {
|
|
13116
|
-
const base = cwd ?
|
|
13165
|
+
const base = cwd ? resolve8(cwd) : process.cwd();
|
|
13117
13166
|
switch (scope) {
|
|
13118
13167
|
case "user":
|
|
13119
|
-
return
|
|
13168
|
+
return resolve8(homedir6(), ".agents", "plugins", "failproofai", "hooks", "hooks.json");
|
|
13120
13169
|
case "project":
|
|
13121
|
-
return
|
|
13170
|
+
return resolve8(base, ".agents", "plugins", "failproofai", "hooks", "hooks.json");
|
|
13122
13171
|
case "local":
|
|
13123
|
-
return
|
|
13172
|
+
return resolve8(base, ".agents", "plugins", "failproofai", "hooks", "hooks.json");
|
|
13124
13173
|
}
|
|
13125
13174
|
},
|
|
13126
13175
|
readSettings(settingsPath) {
|
|
@@ -13187,7 +13236,7 @@ var init_integrations = __esm(() => {
|
|
|
13187
13236
|
},
|
|
13188
13237
|
hooksInstalledInSettings(scope, cwd) {
|
|
13189
13238
|
const settingsPath = this.getSettingsPath(scope, cwd);
|
|
13190
|
-
if (!
|
|
13239
|
+
if (!existsSync7(settingsPath))
|
|
13191
13240
|
return false;
|
|
13192
13241
|
try {
|
|
13193
13242
|
const settings = this.readSettings(settingsPath);
|
|
@@ -13252,7 +13301,7 @@ var init_custom_hooks_registry = __esm(() => {
|
|
|
13252
13301
|
// src/hooks/loader-utils.ts
|
|
13253
13302
|
import { readFile as readFile2, writeFile as writeFile2, unlink, access, mkdir, lstat } from "fs/promises";
|
|
13254
13303
|
import { tmpdir } from "os";
|
|
13255
|
-
import { resolve as
|
|
13304
|
+
import { resolve as resolve9, dirname as dirname6, relative as relative2, join as join5 } from "path";
|
|
13256
13305
|
import { pathToFileURL } from "url";
|
|
13257
13306
|
import { createHash as createHash3 } from "crypto";
|
|
13258
13307
|
function isTmpArtifact(name) {
|
|
@@ -13265,7 +13314,7 @@ async function sweepStaleTmpArtifacts(dir, now = Date.now()) {
|
|
|
13265
13314
|
for (const name of await readdir(dir)) {
|
|
13266
13315
|
if (!isTmpArtifact(name))
|
|
13267
13316
|
continue;
|
|
13268
|
-
const path =
|
|
13317
|
+
const path = resolve9(dir, name);
|
|
13269
13318
|
try {
|
|
13270
13319
|
const info = await stat(path);
|
|
13271
13320
|
if (now - info.mtimeMs < TMP_SWEEP_MIN_AGE_MS)
|
|
@@ -13288,14 +13337,14 @@ async function fileExists(path) {
|
|
|
13288
13337
|
async function findDistIndex() {
|
|
13289
13338
|
const distPath = process.env.FAILPROOFAI_DIST_PATH;
|
|
13290
13339
|
if (distPath) {
|
|
13291
|
-
const candidate =
|
|
13340
|
+
const candidate = resolve9(distPath, "index.js");
|
|
13292
13341
|
if (await fileExists(candidate))
|
|
13293
13342
|
return candidate;
|
|
13294
13343
|
}
|
|
13295
13344
|
const candidates = [
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13345
|
+
resolve9(dirname6(process.execPath), "..", "assets", "dist", "index.js"),
|
|
13346
|
+
resolve9(process.cwd(), "dist", "index.js"),
|
|
13347
|
+
resolve9(process.cwd(), "node_modules", "failproofai", "dist", "index.js")
|
|
13299
13348
|
];
|
|
13300
13349
|
for (const c of candidates) {
|
|
13301
13350
|
if (await fileExists(c))
|
|
@@ -13304,8 +13353,8 @@ async function findDistIndex() {
|
|
|
13304
13353
|
return null;
|
|
13305
13354
|
}
|
|
13306
13355
|
async function resolveLocalImport(fromDir, specifier) {
|
|
13307
|
-
const base =
|
|
13308
|
-
const candidates = [base, `${base}.js`, `${base}.mjs`, `${base}.ts`,
|
|
13356
|
+
const base = resolve9(fromDir, specifier);
|
|
13357
|
+
const candidates = [base, `${base}.js`, `${base}.mjs`, `${base}.ts`, resolve9(base, "index.js")];
|
|
13309
13358
|
for (const c of candidates) {
|
|
13310
13359
|
if (await fileExists(c))
|
|
13311
13360
|
return c;
|
|
@@ -13313,7 +13362,7 @@ async function resolveLocalImport(fromDir, specifier) {
|
|
|
13313
13362
|
return null;
|
|
13314
13363
|
}
|
|
13315
13364
|
async function writeShim(dir, name, code, exclusive) {
|
|
13316
|
-
const shimPath =
|
|
13365
|
+
const shimPath = join5(dir, name);
|
|
13317
13366
|
await writeFile2(shimPath, code, {
|
|
13318
13367
|
encoding: "utf-8",
|
|
13319
13368
|
mode: 384,
|
|
@@ -13382,7 +13431,7 @@ async function rewriteFileTree(entryPath, distUrl, distIndex, tmpSuffix = TMP_SU
|
|
|
13382
13431
|
if (distIndex) {
|
|
13383
13432
|
code = code.replace(/require\s*\(\s*(['"])(?:claudeye|failproofai)\1\s*\)/g, `require('${distIndex.replace(/\\/g, "\\\\")}')`);
|
|
13384
13433
|
}
|
|
13385
|
-
const dir =
|
|
13434
|
+
const dir = dirname6(filePath);
|
|
13386
13435
|
const rewrites = new Map;
|
|
13387
13436
|
for (const re of [LOCAL_IMPORT_RE, LOCAL_REQUIRE_RE]) {
|
|
13388
13437
|
const freshRe = new RegExp(re.source, re.flags);
|
|
@@ -13576,27 +13625,27 @@ var init_telemetry_id2 = __esm(() => {
|
|
|
13576
13625
|
});
|
|
13577
13626
|
|
|
13578
13627
|
// src/hooks/custom-hooks-loader.ts
|
|
13579
|
-
import { resolve as
|
|
13628
|
+
import { resolve as resolve10, isAbsolute as isAbsolute2, basename as basename3 } from "node:path";
|
|
13580
13629
|
import { randomUUID } from "crypto";
|
|
13581
|
-
import { existsSync as
|
|
13630
|
+
import { existsSync as existsSync8, readdirSync as readdirSync3 } from "node:fs";
|
|
13582
13631
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
13583
13632
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
13584
13633
|
import { createHash as createHash4 } from "node:crypto";
|
|
13585
13634
|
function discoverPolicyFiles(dir) {
|
|
13586
|
-
if (!
|
|
13635
|
+
if (!existsSync8(dir))
|
|
13587
13636
|
return [];
|
|
13588
13637
|
try {
|
|
13589
|
-
const entries =
|
|
13590
|
-
return entries.filter((e) => e.isFile() && CONVENTION_FILE_RE.test(e.name)).sort((a, b) => a.name.localeCompare(b.name)).map((e) =>
|
|
13638
|
+
const entries = readdirSync3(dir, { withFileTypes: true });
|
|
13639
|
+
return entries.filter((e) => e.isFile() && CONVENTION_FILE_RE.test(e.name)).sort((a, b) => a.name.localeCompare(b.name)).map((e) => resolve10(dir, e.name));
|
|
13591
13640
|
} catch {
|
|
13592
13641
|
return [];
|
|
13593
13642
|
}
|
|
13594
13643
|
}
|
|
13595
13644
|
function findSkippedPolicyFiles(dir) {
|
|
13596
|
-
if (!
|
|
13645
|
+
if (!existsSync8(dir))
|
|
13597
13646
|
return [];
|
|
13598
13647
|
try {
|
|
13599
|
-
return
|
|
13648
|
+
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));
|
|
13600
13649
|
} catch {
|
|
13601
13650
|
return [];
|
|
13602
13651
|
}
|
|
@@ -13656,7 +13705,7 @@ async function loadSingleFile(absPath, opts) {
|
|
|
13656
13705
|
error_type: errorType,
|
|
13657
13706
|
is_convention: !!opts?.conventionScope,
|
|
13658
13707
|
convention_scope: opts?.conventionScope ?? null,
|
|
13659
|
-
file_basename:
|
|
13708
|
+
file_basename: basename3(absPath)
|
|
13660
13709
|
});
|
|
13661
13710
|
if (opts?.strict)
|
|
13662
13711
|
throw new Error(`Failed to load custom hooks from ${absPath}: ${msg}`);
|
|
@@ -13679,8 +13728,8 @@ async function fingerprintTemporaryTree(tmpFiles, tmpSuffix) {
|
|
|
13679
13728
|
async function loadCustomHooks(customPoliciesPath, opts) {
|
|
13680
13729
|
if (!customPoliciesPath)
|
|
13681
13730
|
return [];
|
|
13682
|
-
const absPath = isAbsolute2(customPoliciesPath) ? customPoliciesPath :
|
|
13683
|
-
if (!
|
|
13731
|
+
const absPath = isAbsolute2(customPoliciesPath) ? customPoliciesPath : resolve10(opts?.sessionCwd ?? process.cwd(), customPoliciesPath);
|
|
13732
|
+
if (!existsSync8(absPath)) {
|
|
13684
13733
|
if (opts?.strict)
|
|
13685
13734
|
throw new Error(`Custom hooks file not found: ${absPath}`);
|
|
13686
13735
|
hookLogWarn(`customPoliciesPath not found: ${absPath}`);
|
|
@@ -13726,7 +13775,7 @@ async function loadAllCustomHooks(customPoliciesPaths, opts) {
|
|
|
13726
13775
|
const loadedPaths = new Set;
|
|
13727
13776
|
const cloudManagedByPath = new Map;
|
|
13728
13777
|
for (const policy of opts?.cloudManagedPolicies ?? []) {
|
|
13729
|
-
const key =
|
|
13778
|
+
const key = resolve10(policy.path);
|
|
13730
13779
|
const existing = cloudManagedByPath.get(key);
|
|
13731
13780
|
if (!existing) {
|
|
13732
13781
|
cloudManagedByPath.set(key, policy);
|
|
@@ -13745,7 +13794,7 @@ async function loadAllCustomHooks(customPoliciesPaths, opts) {
|
|
|
13745
13794
|
const packByPath = new Map;
|
|
13746
13795
|
const packIdsByPath = new Map;
|
|
13747
13796
|
for (const pack of opts?.packs ?? []) {
|
|
13748
|
-
const key =
|
|
13797
|
+
const key = resolve10(pack.path);
|
|
13749
13798
|
packIdsByPath.set(key, [...packIdsByPath.get(key) ?? [], pack.id]);
|
|
13750
13799
|
const existing = packByPath.get(key);
|
|
13751
13800
|
if (!existing) {
|
|
@@ -13763,10 +13812,10 @@ async function loadAllCustomHooks(customPoliciesPaths, opts) {
|
|
|
13763
13812
|
});
|
|
13764
13813
|
}
|
|
13765
13814
|
for (const customPoliciesPath of typeof customPoliciesPaths === "string" ? [customPoliciesPaths] : customPoliciesPaths ?? []) {
|
|
13766
|
-
const absPath =
|
|
13815
|
+
const absPath = resolve10(projectRoot, customPoliciesPath);
|
|
13767
13816
|
const cloudManaged = cloudManagedByPath.get(absPath);
|
|
13768
13817
|
const pack = packByPath.get(absPath);
|
|
13769
|
-
if (
|
|
13818
|
+
if (existsSync8(absPath)) {
|
|
13770
13819
|
if (!loadedPaths.has(absPath)) {
|
|
13771
13820
|
loadedPaths.add(absPath);
|
|
13772
13821
|
const hooksBefore = getCustomHooks().length;
|
|
@@ -13801,7 +13850,7 @@ async function loadAllCustomHooks(customPoliciesPaths, opts) {
|
|
|
13801
13850
|
}
|
|
13802
13851
|
}
|
|
13803
13852
|
const hooksBeforeConvention = getCustomHooks().length;
|
|
13804
|
-
const projectDir =
|
|
13853
|
+
const projectDir = resolve10(projectRoot, ".failproofai", "policies");
|
|
13805
13854
|
const projectScope = projectDir === customPoliciesDir() ? "user" : "project";
|
|
13806
13855
|
if (conventionEnabled) {
|
|
13807
13856
|
sweepStaleTmpArtifacts(projectDir);
|
|
@@ -13815,12 +13864,12 @@ async function loadAllCustomHooks(customPoliciesPaths, opts) {
|
|
|
13815
13864
|
await loadSingleFile(file, { conventionScope: projectScope });
|
|
13816
13865
|
const newHooks = getCustomHooks().slice(hooksBefore);
|
|
13817
13866
|
for (const hook of newHooks) {
|
|
13818
|
-
hook.__policyId = conventionPolicyId(projectScope,
|
|
13867
|
+
hook.__policyId = conventionPolicyId(projectScope, basename3(file), hook.name);
|
|
13819
13868
|
}
|
|
13820
13869
|
if (newHooks.length > 0) {
|
|
13821
13870
|
conventionSources.push({
|
|
13822
13871
|
scope: projectScope,
|
|
13823
|
-
file:
|
|
13872
|
+
file: basename3(file),
|
|
13824
13873
|
hookNames: newHooks.map((h) => h.name)
|
|
13825
13874
|
});
|
|
13826
13875
|
}
|
|
@@ -13837,12 +13886,12 @@ async function loadAllCustomHooks(customPoliciesPaths, opts) {
|
|
|
13837
13886
|
await loadSingleFile(file, { conventionScope: "user" });
|
|
13838
13887
|
const newHooks = getCustomHooks().slice(hooksBefore);
|
|
13839
13888
|
for (const hook of newHooks) {
|
|
13840
|
-
hook.__policyId = conventionPolicyId("user",
|
|
13889
|
+
hook.__policyId = conventionPolicyId("user", basename3(file), hook.name);
|
|
13841
13890
|
}
|
|
13842
13891
|
if (newHooks.length > 0) {
|
|
13843
13892
|
conventionSources.push({
|
|
13844
13893
|
scope: "user",
|
|
13845
|
-
file:
|
|
13894
|
+
file: basename3(file),
|
|
13846
13895
|
hookNames: newHooks.map((h) => h.name)
|
|
13847
13896
|
});
|
|
13848
13897
|
}
|
|
@@ -14834,8 +14883,8 @@ var init_pack_cli = __esm(() => {
|
|
|
14834
14883
|
|
|
14835
14884
|
// src/hooks/pack-store.ts
|
|
14836
14885
|
import { createHash as createHash5 } from "node:crypto";
|
|
14837
|
-
import { existsSync as
|
|
14838
|
-
import { dirname as
|
|
14886
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync5, readFileSync as readFileSync6, renameSync as renameSync2, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
14887
|
+
import { dirname as dirname7, resolve as resolve11 } from "node:path";
|
|
14839
14888
|
function baseUrl() {
|
|
14840
14889
|
return (process.env.FAILPROOFAI_PACK_BASE_URL || DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
14841
14890
|
}
|
|
@@ -15006,7 +15055,7 @@ function sha256(bytes) {
|
|
|
15006
15055
|
function writeAtomic(target, bytes) {
|
|
15007
15056
|
const tempPath = `${target}.${process.pid}.tmp`;
|
|
15008
15057
|
try {
|
|
15009
|
-
mkdirSync5(
|
|
15058
|
+
mkdirSync5(dirname7(target), { recursive: true });
|
|
15010
15059
|
writeFileSync4(tempPath, bytes);
|
|
15011
15060
|
renameSync2(tempPath, target);
|
|
15012
15061
|
} catch (err) {
|
|
@@ -15183,8 +15232,8 @@ async function addPack(source, opts) {
|
|
|
15183
15232
|
const { enabled, reason } = resolveSelection(fetched.policies, opts, prior?.enabled ? prior.enabled.filter((n) => available.includes(n)) : prior?.enabled, Boolean(prior));
|
|
15184
15233
|
const root = packsRoot();
|
|
15185
15234
|
const artifactRel = `artifacts/${fetched.artifactDigest}.mjs`;
|
|
15186
|
-
const artifactAbs =
|
|
15187
|
-
if (!
|
|
15235
|
+
const artifactAbs = resolve11(root, artifactRel);
|
|
15236
|
+
if (!existsSync9(artifactAbs))
|
|
15188
15237
|
writeAtomic(artifactAbs, fetched.artifact);
|
|
15189
15238
|
try {
|
|
15190
15239
|
await verifyArtifactRegisters(artifactAbs, available);
|
|
@@ -15226,8 +15275,8 @@ async function addPack(source, opts) {
|
|
|
15226
15275
|
};
|
|
15227
15276
|
}
|
|
15228
15277
|
function setPackPolicyEnabled(packId, name, on) {
|
|
15229
|
-
const manifestPath =
|
|
15230
|
-
if (!
|
|
15278
|
+
const manifestPath = resolve11(packsRoot(), "installed.json");
|
|
15279
|
+
if (!existsSync9(manifestPath))
|
|
15231
15280
|
return { ok: false, reason: "no packs are installed" };
|
|
15232
15281
|
let raw;
|
|
15233
15282
|
try {
|
|
@@ -15260,8 +15309,8 @@ function bareId(value) {
|
|
|
15260
15309
|
return (at > 0 ? trimmed.slice(0, at) : trimmed).trim();
|
|
15261
15310
|
}
|
|
15262
15311
|
function removePack(id) {
|
|
15263
|
-
const manifestPath =
|
|
15264
|
-
if (!
|
|
15312
|
+
const manifestPath = resolve11(packsRoot(), "installed.json");
|
|
15313
|
+
if (!existsSync9(manifestPath))
|
|
15265
15314
|
return null;
|
|
15266
15315
|
let raw;
|
|
15267
15316
|
try {
|
|
@@ -15284,9 +15333,9 @@ function removePack(id) {
|
|
|
15284
15333
|
return removed.id;
|
|
15285
15334
|
}
|
|
15286
15335
|
function upsertInstalled(record, carryAbsorbedSelection = true) {
|
|
15287
|
-
const manifestPath =
|
|
15336
|
+
const manifestPath = resolve11(packsRoot(), "installed.json");
|
|
15288
15337
|
let packs = [];
|
|
15289
|
-
if (
|
|
15338
|
+
if (existsSync9(manifestPath)) {
|
|
15290
15339
|
try {
|
|
15291
15340
|
const raw = JSON.parse(readFileSync6(manifestPath, "utf8"));
|
|
15292
15341
|
if (Array.isArray(raw.packs))
|
|
@@ -16130,21 +16179,21 @@ import {
|
|
|
16130
16179
|
writeFileSync as writeFileSync5,
|
|
16131
16180
|
appendFileSync as appendFileSync2,
|
|
16132
16181
|
renameSync as renameSync3,
|
|
16133
|
-
readdirSync as
|
|
16182
|
+
readdirSync as readdirSync4,
|
|
16134
16183
|
mkdirSync as mkdirSync6,
|
|
16135
|
-
existsSync as
|
|
16184
|
+
existsSync as existsSync10,
|
|
16136
16185
|
statSync as statSync5,
|
|
16137
16186
|
unlinkSync as unlinkSync2
|
|
16138
16187
|
} from "node:fs";
|
|
16139
|
-
import { join as
|
|
16188
|
+
import { join as join6 } from "node:path";
|
|
16140
16189
|
function ensureDir() {
|
|
16141
|
-
if (!
|
|
16190
|
+
if (!existsSync10(storeDirValue())) {
|
|
16142
16191
|
mkdirSync6(storeDirValue(), { recursive: true });
|
|
16143
16192
|
}
|
|
16144
16193
|
}
|
|
16145
16194
|
function acquireLock() {
|
|
16146
16195
|
ensureDir();
|
|
16147
|
-
const lockPath =
|
|
16196
|
+
const lockPath = join6(storeDirValue(), LOCK_FILE);
|
|
16148
16197
|
const deadline = Date.now() + LOCK_STALE_MS;
|
|
16149
16198
|
while (Date.now() < deadline) {
|
|
16150
16199
|
try {
|
|
@@ -16165,15 +16214,15 @@ function acquireLock() {
|
|
|
16165
16214
|
}
|
|
16166
16215
|
function releaseLock() {
|
|
16167
16216
|
try {
|
|
16168
|
-
unlinkSync2(
|
|
16217
|
+
unlinkSync2(join6(storeDirValue(), LOCK_FILE));
|
|
16169
16218
|
} catch {}
|
|
16170
16219
|
}
|
|
16171
16220
|
function persistHookActivity(entry) {
|
|
16172
16221
|
ensureDir();
|
|
16173
16222
|
acquireLock();
|
|
16174
16223
|
try {
|
|
16175
|
-
const currentPath =
|
|
16176
|
-
const countPath =
|
|
16224
|
+
const currentPath = join6(storeDirValue(), CURRENT_FILE);
|
|
16225
|
+
const countPath = join6(storeDirValue(), COUNT_FILE);
|
|
16177
16226
|
const lineCount = readCount(countPath);
|
|
16178
16227
|
if (lineCount >= PAGE_SIZE) {
|
|
16179
16228
|
try {
|
|
@@ -16193,7 +16242,7 @@ function persistHookActivity(entry) {
|
|
|
16193
16242
|
}
|
|
16194
16243
|
function rotate(currentPath, countPath) {
|
|
16195
16244
|
const archiveName = `page-${Date.now()}-${rotateSeq++}.jsonl`;
|
|
16196
|
-
const archivePath =
|
|
16245
|
+
const archivePath = join6(storeDirValue(), archiveName);
|
|
16197
16246
|
renameSync3(currentPath, archivePath);
|
|
16198
16247
|
writeCount(countPath, 0);
|
|
16199
16248
|
}
|
|
@@ -16219,7 +16268,7 @@ function readFileSafe(filePath) {
|
|
|
16219
16268
|
}
|
|
16220
16269
|
function readStoredStats() {
|
|
16221
16270
|
try {
|
|
16222
|
-
return JSON.parse(readFileSync7(
|
|
16271
|
+
return JSON.parse(readFileSync7(join6(storeDirValue(), STATS_FILE), "utf-8"));
|
|
16223
16272
|
} catch {
|
|
16224
16273
|
return { totalEvents: 0, denyCount: 0, policyMap: {} };
|
|
16225
16274
|
}
|
|
@@ -16237,10 +16286,10 @@ function foldEntry(s, entry) {
|
|
|
16237
16286
|
}
|
|
16238
16287
|
}
|
|
16239
16288
|
function writeStoredStats(s) {
|
|
16240
|
-
const tmpPath =
|
|
16289
|
+
const tmpPath = join6(storeDirValue(), `stats.json.${process.pid}.tmp`);
|
|
16241
16290
|
try {
|
|
16242
16291
|
writeFileSync5(tmpPath, JSON.stringify(s), "utf-8");
|
|
16243
|
-
renameSync3(tmpPath,
|
|
16292
|
+
renameSync3(tmpPath, join6(storeDirValue(), STATS_FILE));
|
|
16244
16293
|
return true;
|
|
16245
16294
|
} catch {
|
|
16246
16295
|
try {
|
|
@@ -16260,8 +16309,8 @@ function rebuildHookActivityStats() {
|
|
|
16260
16309
|
const s = { totalEvents: 0, denyCount: 0, policyMap: {} };
|
|
16261
16310
|
let sawAny = false;
|
|
16262
16311
|
for (const file of files) {
|
|
16263
|
-
const path =
|
|
16264
|
-
if (!
|
|
16312
|
+
const path = join6(storeDirValue(), file);
|
|
16313
|
+
if (!existsSync10(path))
|
|
16265
16314
|
continue;
|
|
16266
16315
|
sawAny = true;
|
|
16267
16316
|
for (const entry of readJsonlFile(path))
|
|
@@ -16273,12 +16322,12 @@ function rebuildHookActivityStats() {
|
|
|
16273
16322
|
}
|
|
16274
16323
|
function getAllHookActivityEntries() {
|
|
16275
16324
|
ensureDir();
|
|
16276
|
-
const currentPath =
|
|
16325
|
+
const currentPath = join6(storeDirValue(), CURRENT_FILE);
|
|
16277
16326
|
const currentEntries = readJsonlFile(currentPath).reverse();
|
|
16278
16327
|
const archives = getArchiveFiles();
|
|
16279
16328
|
const archiveEntries = [];
|
|
16280
16329
|
for (const file of archives) {
|
|
16281
|
-
const entries = readJsonlFile(
|
|
16330
|
+
const entries = readJsonlFile(join6(storeDirValue(), file));
|
|
16282
16331
|
archiveEntries.push(...entries.reverse());
|
|
16283
16332
|
}
|
|
16284
16333
|
return [...currentEntries, ...archiveEntries];
|
|
@@ -16308,7 +16357,7 @@ function readJsonlFile(filePath) {
|
|
|
16308
16357
|
}
|
|
16309
16358
|
function getArchiveFiles() {
|
|
16310
16359
|
try {
|
|
16311
|
-
const files =
|
|
16360
|
+
const files = readdirSync4(storeDirValue());
|
|
16312
16361
|
return files.filter((f) => f.startsWith("page-") && f.endsWith(".jsonl")).sort((a, b) => {
|
|
16313
16362
|
const partsA = a.slice(5, -6).split("-");
|
|
16314
16363
|
const partsB = b.slice(5, -6).split("-");
|
|
@@ -16330,8 +16379,8 @@ var init_hook_activity_store = __esm(() => {
|
|
|
16330
16379
|
});
|
|
16331
16380
|
|
|
16332
16381
|
// src/hooks/delivery-health.ts
|
|
16333
|
-
import { existsSync as
|
|
16334
|
-
import { join as
|
|
16382
|
+
import { existsSync as existsSync11, readdirSync as readdirSync5, statSync as statSync6 } from "node:fs";
|
|
16383
|
+
import { join as join7 } from "node:path";
|
|
16335
16384
|
function parseParkedName(name) {
|
|
16336
16385
|
const poison = name.endsWith(POISON_SUFFIX);
|
|
16337
16386
|
const withoutPoison = poison ? name.slice(0, -POISON_SUFFIX.length) : name;
|
|
@@ -16359,11 +16408,11 @@ function parseParkedName(name) {
|
|
|
16359
16408
|
}
|
|
16360
16409
|
function deliveryHealth(home, now = Date.now()) {
|
|
16361
16410
|
const dir = failedDir(home);
|
|
16362
|
-
if (!
|
|
16411
|
+
if (!existsSync11(dir))
|
|
16363
16412
|
return EMPTY;
|
|
16364
16413
|
let entries;
|
|
16365
16414
|
try {
|
|
16366
|
-
entries =
|
|
16415
|
+
entries = readdirSync5(dir);
|
|
16367
16416
|
} catch {
|
|
16368
16417
|
return EMPTY;
|
|
16369
16418
|
}
|
|
@@ -16384,7 +16433,7 @@ function deliveryHealth(home, now = Date.now()) {
|
|
|
16384
16433
|
credentialRejected += 1;
|
|
16385
16434
|
}
|
|
16386
16435
|
try {
|
|
16387
|
-
const mtime = statSync6(
|
|
16436
|
+
const mtime = statSync6(join7(dir, name)).mtimeMs;
|
|
16388
16437
|
if (oldestMtime === undefined || mtime < oldestMtime)
|
|
16389
16438
|
oldestMtime = mtime;
|
|
16390
16439
|
} catch {}
|
|
@@ -16478,10 +16527,10 @@ function runtimeCache(fn, revalidateSeconds, options) {
|
|
|
16478
16527
|
}
|
|
16479
16528
|
|
|
16480
16529
|
// lib/paths.ts
|
|
16481
|
-
import { homedir as
|
|
16482
|
-
import { join as
|
|
16530
|
+
import { homedir as homedir7 } from "os";
|
|
16531
|
+
import { join as join8 } from "path";
|
|
16483
16532
|
function getDefaultClaudeProjectsPath() {
|
|
16484
|
-
return
|
|
16533
|
+
return join8(homedir7(), ".claude", "projects");
|
|
16485
16534
|
}
|
|
16486
16535
|
function decodeFolderName(name) {
|
|
16487
16536
|
if (/^[A-Za-z]--/.test(name)) {
|
|
@@ -16571,8 +16620,8 @@ __export(exports_codex_projects, {
|
|
|
16571
16620
|
getCodexSessionsByEncodedName: () => getCodexSessionsByEncodedName
|
|
16572
16621
|
});
|
|
16573
16622
|
import { open, readdir } from "node:fs/promises";
|
|
16574
|
-
import { homedir as
|
|
16575
|
-
import { join as
|
|
16623
|
+
import { homedir as homedir8 } from "node:os";
|
|
16624
|
+
import { join as join9 } from "node:path";
|
|
16576
16625
|
async function safeReaddir(dir) {
|
|
16577
16626
|
try {
|
|
16578
16627
|
return await readdir(dir, { withFileTypes: true });
|
|
@@ -16620,7 +16669,7 @@ async function listJsonlFiles(dir) {
|
|
|
16620
16669
|
const entries = await safeReaddir(dir);
|
|
16621
16670
|
if (!entries)
|
|
16622
16671
|
return [];
|
|
16623
|
-
return entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) =>
|
|
16672
|
+
return entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => join9(dir, e.name));
|
|
16624
16673
|
}
|
|
16625
16674
|
async function scanCodexSessions() {
|
|
16626
16675
|
const yearDirs = await safeReaddir(CODEX_SESSIONS_ROOT);
|
|
@@ -16630,19 +16679,19 @@ async function scanCodexSessions() {
|
|
|
16630
16679
|
for (const y of yearDirs) {
|
|
16631
16680
|
if (!y.isDirectory())
|
|
16632
16681
|
continue;
|
|
16633
|
-
const monthDirs = await safeReaddir(
|
|
16682
|
+
const monthDirs = await safeReaddir(join9(CODEX_SESSIONS_ROOT, y.name));
|
|
16634
16683
|
if (!monthDirs)
|
|
16635
16684
|
continue;
|
|
16636
16685
|
for (const m of monthDirs) {
|
|
16637
16686
|
if (!m.isDirectory())
|
|
16638
16687
|
continue;
|
|
16639
|
-
const dayDirs = await safeReaddir(
|
|
16688
|
+
const dayDirs = await safeReaddir(join9(CODEX_SESSIONS_ROOT, y.name, m.name));
|
|
16640
16689
|
if (!dayDirs)
|
|
16641
16690
|
continue;
|
|
16642
16691
|
for (const d of dayDirs) {
|
|
16643
16692
|
if (!d.isDirectory())
|
|
16644
16693
|
continue;
|
|
16645
|
-
const dayPath =
|
|
16694
|
+
const dayPath = join9(CODEX_SESSIONS_ROOT, y.name, m.name, d.name);
|
|
16646
16695
|
filePaths.push(...await listJsonlFiles(dayPath));
|
|
16647
16696
|
}
|
|
16648
16697
|
}
|
|
@@ -16750,7 +16799,7 @@ var CODEX_SESSIONS_ROOT, SESSION_ID_RE, FIRST_LINE_CHUNK_BYTES, cachedScan, getC
|
|
|
16750
16799
|
var init_codex_projects = __esm(() => {
|
|
16751
16800
|
init_paths();
|
|
16752
16801
|
init_logger();
|
|
16753
|
-
CODEX_SESSIONS_ROOT =
|
|
16802
|
+
CODEX_SESSIONS_ROOT = join9(homedir8(), ".codex", "sessions");
|
|
16754
16803
|
SESSION_ID_RE = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
|
|
16755
16804
|
FIRST_LINE_CHUNK_BYTES = 256 * 1024;
|
|
16756
16805
|
cachedScan = runtimeCache(scanCodexSessions, 30);
|
|
@@ -16766,10 +16815,10 @@ __export(exports_copilot_projects, {
|
|
|
16766
16815
|
getCopilotSessionsByEncodedName: () => getCopilotSessionsByEncodedName
|
|
16767
16816
|
});
|
|
16768
16817
|
import { readdir as readdir2, readFile as readFile4, stat } from "node:fs/promises";
|
|
16769
|
-
import { homedir as
|
|
16770
|
-
import { join as
|
|
16818
|
+
import { homedir as homedir9 } from "node:os";
|
|
16819
|
+
import { join as join10 } from "node:path";
|
|
16771
16820
|
function getCopilotSessionStateRoot() {
|
|
16772
|
-
return
|
|
16821
|
+
return join10(process.env.COPILOT_HOME || join10(homedir9(), ".copilot"), "session-state");
|
|
16773
16822
|
}
|
|
16774
16823
|
async function safeReaddir2(dir) {
|
|
16775
16824
|
try {
|
|
@@ -16798,8 +16847,8 @@ async function scanCopilotSessions() {
|
|
|
16798
16847
|
return [];
|
|
16799
16848
|
const candidates = entries.filter((e) => e.isDirectory()).map((e) => ({
|
|
16800
16849
|
sessionId: e.name,
|
|
16801
|
-
workspacePath:
|
|
16802
|
-
eventsPath:
|
|
16850
|
+
workspacePath: join10(root, e.name, "workspace.yaml"),
|
|
16851
|
+
eventsPath: join10(root, e.name, "events.jsonl")
|
|
16803
16852
|
}));
|
|
16804
16853
|
const settled = await batchAll(candidates.map((c) => async () => {
|
|
16805
16854
|
let workspaceText;
|
|
@@ -16910,10 +16959,10 @@ __export(exports_cursor_projects, {
|
|
|
16910
16959
|
getCursorSessionsByEncodedName: () => getCursorSessionsByEncodedName
|
|
16911
16960
|
});
|
|
16912
16961
|
import { readdir as readdir3, readFile as readFile5, stat as stat2 } from "node:fs/promises";
|
|
16913
|
-
import { homedir as
|
|
16914
|
-
import { join as
|
|
16962
|
+
import { homedir as homedir10 } from "node:os";
|
|
16963
|
+
import { join as join11 } from "node:path";
|
|
16915
16964
|
function getCursorHome() {
|
|
16916
|
-
return process.env.CURSOR_HOME ||
|
|
16965
|
+
return process.env.CURSOR_HOME || join11(homedir10(), ".cursor");
|
|
16917
16966
|
}
|
|
16918
16967
|
async function safeReaddir3(dir) {
|
|
16919
16968
|
try {
|
|
@@ -16945,7 +16994,7 @@ function parseCwdFromMetaText(text) {
|
|
|
16945
16994
|
}
|
|
16946
16995
|
async function findFirstUsableMeta(dir, candidates) {
|
|
16947
16996
|
for (const name of candidates) {
|
|
16948
|
-
const path =
|
|
16997
|
+
const path = join11(dir, name);
|
|
16949
16998
|
if (await statMtime2(path) === null)
|
|
16950
16999
|
continue;
|
|
16951
17000
|
let text;
|
|
@@ -16962,7 +17011,7 @@ async function findFirstUsableMeta(dir, candidates) {
|
|
|
16962
17011
|
}
|
|
16963
17012
|
async function findFirstExistingPath(dir, candidates) {
|
|
16964
17013
|
for (const name of candidates) {
|
|
16965
|
-
const path =
|
|
17014
|
+
const path = join11(dir, name);
|
|
16966
17015
|
if (await statMtime2(path) !== null)
|
|
16967
17016
|
return path;
|
|
16968
17017
|
}
|
|
@@ -16972,7 +17021,7 @@ async function scanCursorSessions() {
|
|
|
16972
17021
|
const home = getCursorHome();
|
|
16973
17022
|
const newCandidates = [];
|
|
16974
17023
|
const legacyCandidates = [];
|
|
16975
|
-
const projectsRoot =
|
|
17024
|
+
const projectsRoot = join11(home, NEW_PROJECTS_DIR);
|
|
16976
17025
|
const projectEntries = await safeReaddir3(projectsRoot);
|
|
16977
17026
|
if (projectEntries) {
|
|
16978
17027
|
for (const proj of projectEntries) {
|
|
@@ -16980,7 +17029,7 @@ async function scanCursorSessions() {
|
|
|
16980
17029
|
continue;
|
|
16981
17030
|
const decoded = decodeFolderName(proj.name);
|
|
16982
17031
|
const cwd = decoded.startsWith("/") || /^[A-Za-z]:\//.test(decoded) ? decoded : `/${decoded}`;
|
|
16983
|
-
const transcriptsRoot =
|
|
17032
|
+
const transcriptsRoot = join11(projectsRoot, proj.name, NEW_AGENT_TRANSCRIPTS_DIR);
|
|
16984
17033
|
const sessionDirs = await safeReaddir3(transcriptsRoot);
|
|
16985
17034
|
if (!sessionDirs)
|
|
16986
17035
|
continue;
|
|
@@ -16989,28 +17038,28 @@ async function scanCursorSessions() {
|
|
|
16989
17038
|
continue;
|
|
16990
17039
|
newCandidates.push({
|
|
16991
17040
|
sessionId: sd.name,
|
|
16992
|
-
dir:
|
|
17041
|
+
dir: join11(transcriptsRoot, sd.name),
|
|
16993
17042
|
cwd
|
|
16994
17043
|
});
|
|
16995
17044
|
}
|
|
16996
17045
|
}
|
|
16997
17046
|
}
|
|
16998
17047
|
for (const sub of LEGACY_SESSION_ROOT_CANDIDATES) {
|
|
16999
|
-
const root =
|
|
17048
|
+
const root = join11(home, sub);
|
|
17000
17049
|
const entries = await safeReaddir3(root);
|
|
17001
17050
|
if (!entries)
|
|
17002
17051
|
continue;
|
|
17003
17052
|
for (const e of entries) {
|
|
17004
17053
|
if (!e.isDirectory())
|
|
17005
17054
|
continue;
|
|
17006
|
-
legacyCandidates.push({ sessionId: e.name, dir:
|
|
17055
|
+
legacyCandidates.push({ sessionId: e.name, dir: join11(root, e.name) });
|
|
17007
17056
|
}
|
|
17008
17057
|
}
|
|
17009
17058
|
if (newCandidates.length === 0 && legacyCandidates.length === 0)
|
|
17010
17059
|
return [];
|
|
17011
17060
|
const settled = await batchAll([
|
|
17012
17061
|
...newCandidates.map((c) => async () => {
|
|
17013
|
-
const transcriptPath =
|
|
17062
|
+
const transcriptPath = join11(c.dir, `${c.sessionId}.jsonl`);
|
|
17014
17063
|
const transcriptMtime = await statMtime2(transcriptPath);
|
|
17015
17064
|
if (!transcriptMtime)
|
|
17016
17065
|
return null;
|
|
@@ -17124,7 +17173,7 @@ var init_cursor_projects = __esm(() => {
|
|
|
17124
17173
|
});
|
|
17125
17174
|
|
|
17126
17175
|
// lib/sqlite-reader.ts
|
|
17127
|
-
import { existsSync as
|
|
17176
|
+
import { existsSync as existsSync12, readFileSync as readFileSync8, statSync as statSync7 } from "node:fs";
|
|
17128
17177
|
import initSqlJs from "sql.js/dist/sql-asm.js";
|
|
17129
17178
|
async function tryNodeSqlite(dbPath) {
|
|
17130
17179
|
try {
|
|
@@ -17148,10 +17197,117 @@ function loadSqlJs() {
|
|
|
17148
17197
|
sqlPromise = initSqlJs();
|
|
17149
17198
|
return sqlPromise;
|
|
17150
17199
|
}
|
|
17200
|
+
function fileVersion(path) {
|
|
17201
|
+
const stat = statSync7(path);
|
|
17202
|
+
return { size: stat.size, mtimeMs: stat.mtimeMs, ctimeMs: stat.ctimeMs };
|
|
17203
|
+
}
|
|
17204
|
+
function sameVersion(a, b) {
|
|
17205
|
+
return a.size === b.size && a.mtimeMs === b.mtimeMs && a.ctimeMs === b.ctimeMs;
|
|
17206
|
+
}
|
|
17207
|
+
function sqlitePageSize(db) {
|
|
17208
|
+
if (db.length < 100)
|
|
17209
|
+
return null;
|
|
17210
|
+
if (Buffer.from(db.subarray(0, 16)).toString("binary") !== "SQLite format 3\x00")
|
|
17211
|
+
return null;
|
|
17212
|
+
const encoded = db[16] << 8 | db[17];
|
|
17213
|
+
const pageSize = encoded === 1 ? 65536 : encoded;
|
|
17214
|
+
return pageSize >= 512 && pageSize <= 65536 && (pageSize & pageSize - 1) === 0 ? pageSize : null;
|
|
17215
|
+
}
|
|
17216
|
+
function walChecksum(bytes, offset, length, bigEndian, initial = [0, 0]) {
|
|
17217
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
17218
|
+
let [sum1, sum2] = initial;
|
|
17219
|
+
for (let cursor = offset;cursor < offset + length; cursor += 8) {
|
|
17220
|
+
const first = view.getUint32(cursor, !bigEndian);
|
|
17221
|
+
const second = view.getUint32(cursor + 4, !bigEndian);
|
|
17222
|
+
sum1 = sum1 + first + sum2 >>> 0;
|
|
17223
|
+
sum2 = sum2 + second + sum1 >>> 0;
|
|
17224
|
+
}
|
|
17225
|
+
return [sum1, sum2];
|
|
17226
|
+
}
|
|
17227
|
+
function applyCommittedWal(db, wal) {
|
|
17228
|
+
const pageSize = sqlitePageSize(db);
|
|
17229
|
+
if (pageSize === null || wal.length < 32)
|
|
17230
|
+
return db;
|
|
17231
|
+
const view = new DataView(wal.buffer, wal.byteOffset, wal.byteLength);
|
|
17232
|
+
const magic = view.getUint32(0, false);
|
|
17233
|
+
if (magic !== 931071618 && magic !== 931071619)
|
|
17234
|
+
return db;
|
|
17235
|
+
if (view.getUint32(4, false) !== 3007000)
|
|
17236
|
+
return db;
|
|
17237
|
+
if (view.getUint32(8, false) !== pageSize)
|
|
17238
|
+
return db;
|
|
17239
|
+
const checksumBigEndian = (magic & 1) === 1;
|
|
17240
|
+
let checksum = walChecksum(wal, 0, 24, checksumBigEndian);
|
|
17241
|
+
if (view.getUint32(24, false) !== checksum[0] || view.getUint32(28, false) !== checksum[1]) {
|
|
17242
|
+
return db;
|
|
17243
|
+
}
|
|
17244
|
+
const salt1 = view.getUint32(16, false);
|
|
17245
|
+
const salt2 = view.getUint32(20, false);
|
|
17246
|
+
const frameSize = 24 + pageSize;
|
|
17247
|
+
const frameCount = Math.floor((wal.length - 32) / frameSize);
|
|
17248
|
+
let lastCommit = -1;
|
|
17249
|
+
let committedPages = 0;
|
|
17250
|
+
for (let index = 0;index < frameCount; index += 1) {
|
|
17251
|
+
const offset = 32 + index * frameSize;
|
|
17252
|
+
const pageNumber = view.getUint32(offset, false);
|
|
17253
|
+
if (pageNumber === 0 || view.getUint32(offset + 8, false) !== salt1 || view.getUint32(offset + 12, false) !== salt2) {
|
|
17254
|
+
break;
|
|
17255
|
+
}
|
|
17256
|
+
checksum = walChecksum(wal, offset, 8, checksumBigEndian, checksum);
|
|
17257
|
+
checksum = walChecksum(wal, offset + 24, pageSize, checksumBigEndian, checksum);
|
|
17258
|
+
if (view.getUint32(offset + 16, false) !== checksum[0] || view.getUint32(offset + 20, false) !== checksum[1]) {
|
|
17259
|
+
break;
|
|
17260
|
+
}
|
|
17261
|
+
const databasePages = view.getUint32(offset + 4, false);
|
|
17262
|
+
if (databasePages > 0) {
|
|
17263
|
+
lastCommit = index;
|
|
17264
|
+
committedPages = databasePages;
|
|
17265
|
+
}
|
|
17266
|
+
}
|
|
17267
|
+
if (lastCommit < 0 || committedPages === 0)
|
|
17268
|
+
return db;
|
|
17269
|
+
const targetSize = committedPages * pageSize;
|
|
17270
|
+
if (!Number.isSafeInteger(targetSize) || targetSize > db.length + frameCount * pageSize) {
|
|
17271
|
+
return db;
|
|
17272
|
+
}
|
|
17273
|
+
const snapshot = new Uint8Array(targetSize);
|
|
17274
|
+
snapshot.set(db.subarray(0, targetSize));
|
|
17275
|
+
for (let index = 0;index <= lastCommit; index += 1) {
|
|
17276
|
+
const offset = 32 + index * frameSize;
|
|
17277
|
+
const pageNumber = view.getUint32(offset, false);
|
|
17278
|
+
const destination = (pageNumber - 1) * pageSize;
|
|
17279
|
+
if (destination >= targetSize)
|
|
17280
|
+
continue;
|
|
17281
|
+
snapshot.set(wal.subarray(offset + 24, offset + frameSize), destination);
|
|
17282
|
+
}
|
|
17283
|
+
return snapshot;
|
|
17284
|
+
}
|
|
17285
|
+
function readPortableSnapshot(dbPath) {
|
|
17286
|
+
const walPath = `${dbPath}-wal`;
|
|
17287
|
+
for (let attempt = 0;attempt < 3; attempt += 1) {
|
|
17288
|
+
const before = fileVersion(dbPath);
|
|
17289
|
+
const main = readFileSync8(dbPath);
|
|
17290
|
+
const afterMain = fileVersion(dbPath);
|
|
17291
|
+
if (!sameVersion(before, afterMain))
|
|
17292
|
+
continue;
|
|
17293
|
+
let wal = null;
|
|
17294
|
+
try {
|
|
17295
|
+
wal = readFileSync8(walPath);
|
|
17296
|
+
} catch (error) {
|
|
17297
|
+
if (error.code !== "ENOENT")
|
|
17298
|
+
throw error;
|
|
17299
|
+
}
|
|
17300
|
+
const afterWal = fileVersion(dbPath);
|
|
17301
|
+
if (!sameVersion(before, afterWal))
|
|
17302
|
+
continue;
|
|
17303
|
+
return wal ? applyCommittedWal(main, wal) : main;
|
|
17304
|
+
}
|
|
17305
|
+
throw new Error(`SQLite database changed while reading: ${dbPath}`);
|
|
17306
|
+
}
|
|
17151
17307
|
async function trySqlJs(dbPath) {
|
|
17152
17308
|
try {
|
|
17153
17309
|
const SQL = await loadSqlJs();
|
|
17154
|
-
const db = new SQL.Database(
|
|
17310
|
+
const db = new SQL.Database(readPortableSnapshot(dbPath));
|
|
17155
17311
|
return {
|
|
17156
17312
|
query(sql, params) {
|
|
17157
17313
|
const stmt = db.prepare(sql);
|
|
@@ -17174,22 +17330,27 @@ async function trySqlJs(dbPath) {
|
|
|
17174
17330
|
return null;
|
|
17175
17331
|
}
|
|
17176
17332
|
}
|
|
17177
|
-
async function openSqliteReadonly(dbPath) {
|
|
17178
|
-
if (!
|
|
17333
|
+
async function openSqliteReadonly(dbPath, options = {}) {
|
|
17334
|
+
if (!existsSync12(dbPath))
|
|
17179
17335
|
return null;
|
|
17180
|
-
|
|
17336
|
+
if (!options.forcePortable) {
|
|
17337
|
+
const native = await tryNodeSqlite(dbPath);
|
|
17338
|
+
if (native)
|
|
17339
|
+
return native;
|
|
17340
|
+
}
|
|
17341
|
+
return trySqlJs(dbPath);
|
|
17181
17342
|
}
|
|
17182
17343
|
var sqlPromise = null;
|
|
17183
17344
|
var init_sqlite_reader = () => {};
|
|
17184
17345
|
|
|
17185
17346
|
// lib/opencode-db.ts
|
|
17186
|
-
import { homedir as
|
|
17187
|
-
import { join as
|
|
17347
|
+
import { homedir as homedir11 } from "node:os";
|
|
17348
|
+
import { join as join12 } from "node:path";
|
|
17188
17349
|
function opencodeDbPath() {
|
|
17189
17350
|
if (process.env.OPENCODE_DB_PATH)
|
|
17190
17351
|
return process.env.OPENCODE_DB_PATH;
|
|
17191
|
-
const home = process.env.OPENCODE_HOME ??
|
|
17192
|
-
return
|
|
17352
|
+
const home = process.env.OPENCODE_HOME ?? join12(homedir11(), ".local", "share", "opencode");
|
|
17353
|
+
return join12(home, "opencode.db");
|
|
17193
17354
|
}
|
|
17194
17355
|
async function withOpenCodeDb(fn) {
|
|
17195
17356
|
const db = await openSqliteReadonly(opencodeDbPath());
|
|
@@ -17349,10 +17510,10 @@ __export(exports_pi_projects, {
|
|
|
17349
17510
|
getPiSessionsByEncodedName: () => getPiSessionsByEncodedName
|
|
17350
17511
|
});
|
|
17351
17512
|
import { readdir as readdir4, readFile as readFile6, stat as stat3 } from "node:fs/promises";
|
|
17352
|
-
import { homedir as
|
|
17353
|
-
import { join as
|
|
17513
|
+
import { homedir as homedir12 } from "node:os";
|
|
17514
|
+
import { join as join13 } from "node:path";
|
|
17354
17515
|
function getPiSessionsRoot() {
|
|
17355
|
-
return process.env.PI_SESSIONS_DIR ||
|
|
17516
|
+
return process.env.PI_SESSIONS_DIR || join13(homedir12(), ".pi", "agent", "sessions");
|
|
17356
17517
|
}
|
|
17357
17518
|
async function safeReaddir4(dir) {
|
|
17358
17519
|
try {
|
|
@@ -17400,7 +17561,7 @@ async function scanPiSessions() {
|
|
|
17400
17561
|
for (const cwdDir of cwdDirs) {
|
|
17401
17562
|
if (!cwdDir.isDirectory())
|
|
17402
17563
|
continue;
|
|
17403
|
-
const cwdPath =
|
|
17564
|
+
const cwdPath = join13(root, cwdDir.name);
|
|
17404
17565
|
const sessionFiles = await safeReaddir4(cwdPath);
|
|
17405
17566
|
if (!sessionFiles)
|
|
17406
17567
|
continue;
|
|
@@ -17410,7 +17571,7 @@ async function scanPiSessions() {
|
|
|
17410
17571
|
const m = SESSION_FILE_RE.exec(f.name);
|
|
17411
17572
|
if (!m)
|
|
17412
17573
|
continue;
|
|
17413
|
-
candidates.push({ sessionId: m[1], filePath:
|
|
17574
|
+
candidates.push({ sessionId: m[1], filePath: join13(cwdPath, f.name) });
|
|
17414
17575
|
}
|
|
17415
17576
|
}
|
|
17416
17577
|
if (candidates.length === 0)
|
|
@@ -17532,14 +17693,14 @@ function formatDuration(ms) {
|
|
|
17532
17693
|
}
|
|
17533
17694
|
|
|
17534
17695
|
// lib/hermes-sessions.ts
|
|
17535
|
-
import { join as
|
|
17696
|
+
import { join as join14 } from "node:path";
|
|
17536
17697
|
function hermesDbPaths() {
|
|
17537
17698
|
const override = process.env.HERMES_DB_PATH;
|
|
17538
17699
|
if (override)
|
|
17539
17700
|
return [{ profile: HERMES_DEFAULT_PROFILE, dbPath: override }];
|
|
17540
17701
|
return listHermesProfiles().map((p) => ({
|
|
17541
17702
|
profile: p.name,
|
|
17542
|
-
dbPath:
|
|
17703
|
+
dbPath: join14(p.home, "state.db")
|
|
17543
17704
|
}));
|
|
17544
17705
|
}
|
|
17545
17706
|
function epochToMs(value) {
|
|
@@ -17831,8 +17992,8 @@ var init_hermes_projects = __esm(() => {
|
|
|
17831
17992
|
});
|
|
17832
17993
|
|
|
17833
17994
|
// lib/openclaw-db.ts
|
|
17834
|
-
import { existsSync as
|
|
17835
|
-
import { join as
|
|
17995
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
17996
|
+
import { join as join15 } from "node:path";
|
|
17836
17997
|
function str(value) {
|
|
17837
17998
|
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
17838
17999
|
}
|
|
@@ -17850,8 +18011,8 @@ function syntheticPath(agentId, sessionId) {
|
|
|
17850
18011
|
function listOpenClawDatabases(home, agentIds) {
|
|
17851
18012
|
const out = [];
|
|
17852
18013
|
for (const agentId of agentIds) {
|
|
17853
|
-
const dbPath =
|
|
17854
|
-
if (
|
|
18014
|
+
const dbPath = join15(home, "agents", agentId, "agent", DB_NAME);
|
|
18015
|
+
if (existsSync13(dbPath))
|
|
17855
18016
|
out.push({ agentId, dbPath });
|
|
17856
18017
|
}
|
|
17857
18018
|
return out;
|
|
@@ -17988,11 +18149,11 @@ var init_openclaw_db = __esm(() => {
|
|
|
17988
18149
|
|
|
17989
18150
|
// lib/openclaw-sessions.ts
|
|
17990
18151
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
17991
|
-
import { readdirSync as
|
|
17992
|
-
import { homedir as
|
|
17993
|
-
import { join as
|
|
18152
|
+
import { readdirSync as readdirSync6, statSync as statSync8 } from "node:fs";
|
|
18153
|
+
import { homedir as homedir13 } from "node:os";
|
|
18154
|
+
import { join as join16 } from "node:path";
|
|
17994
18155
|
function openclawHome() {
|
|
17995
|
-
return process.env.OPENCLAW_STATE_DIR || process.env.OPENCLAW_HOME ||
|
|
18156
|
+
return process.env.OPENCLAW_STATE_DIR || process.env.OPENCLAW_HOME || join16(homedir13(), ".openclaw");
|
|
17996
18157
|
}
|
|
17997
18158
|
function isPlainObject3(v) {
|
|
17998
18159
|
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
@@ -18111,25 +18272,25 @@ function openclawLinesToLogEntries(lines, source = "session") {
|
|
|
18111
18272
|
}
|
|
18112
18273
|
function listOpenClawAgents() {
|
|
18113
18274
|
try {
|
|
18114
|
-
return
|
|
18275
|
+
return readdirSync6(join16(openclawHome(), "agents"), { withFileTypes: true }).filter((d) => d.isDirectory() && !d.name.startsWith(".")).map((d) => d.name).sort();
|
|
18115
18276
|
} catch {
|
|
18116
18277
|
return [];
|
|
18117
18278
|
}
|
|
18118
18279
|
}
|
|
18119
18280
|
function listOpenClawTranscripts() {
|
|
18120
|
-
const agentsDir =
|
|
18281
|
+
const agentsDir = join16(openclawHome(), "agents");
|
|
18121
18282
|
const out = [];
|
|
18122
18283
|
let agentIds;
|
|
18123
18284
|
try {
|
|
18124
|
-
agentIds =
|
|
18285
|
+
agentIds = readdirSync6(agentsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
18125
18286
|
} catch {
|
|
18126
18287
|
return out;
|
|
18127
18288
|
}
|
|
18128
18289
|
for (const agentId of agentIds) {
|
|
18129
|
-
const sessionsDir =
|
|
18290
|
+
const sessionsDir = join16(agentsDir, agentId, "sessions");
|
|
18130
18291
|
let files;
|
|
18131
18292
|
try {
|
|
18132
|
-
files =
|
|
18293
|
+
files = readdirSync6(sessionsDir);
|
|
18133
18294
|
} catch {
|
|
18134
18295
|
continue;
|
|
18135
18296
|
}
|
|
@@ -18139,9 +18300,9 @@ function listOpenClawTranscripts() {
|
|
|
18139
18300
|
const sessionId = file.slice(0, -".jsonl".length);
|
|
18140
18301
|
if (!OPENCLAW_SESSION_ID_RE.test(sessionId))
|
|
18141
18302
|
continue;
|
|
18142
|
-
const transcriptPath =
|
|
18303
|
+
const transcriptPath = join16(sessionsDir, file);
|
|
18143
18304
|
try {
|
|
18144
|
-
const st =
|
|
18305
|
+
const st = statSync8(transcriptPath);
|
|
18145
18306
|
out.push({
|
|
18146
18307
|
agentId,
|
|
18147
18308
|
sessionId,
|
|
@@ -18219,13 +18380,13 @@ __export(exports_openclaw_projects, {
|
|
|
18219
18380
|
openClawProjectPath: () => openClawProjectPath
|
|
18220
18381
|
});
|
|
18221
18382
|
import { readFileSync as readFileSync9 } from "node:fs";
|
|
18222
|
-
import { join as
|
|
18383
|
+
import { join as join17 } from "node:path";
|
|
18223
18384
|
function str2(v) {
|
|
18224
18385
|
return typeof v === "string" && v.length > 0 ? v : undefined;
|
|
18225
18386
|
}
|
|
18226
18387
|
function readSessionsIndex(agentId) {
|
|
18227
18388
|
const out = new Map;
|
|
18228
|
-
const indexPath =
|
|
18389
|
+
const indexPath = join17(openclawHome(), "agents", agentId, "sessions", "sessions.json");
|
|
18229
18390
|
let raw;
|
|
18230
18391
|
try {
|
|
18231
18392
|
raw = JSON.parse(readFileSync9(indexPath, "utf-8"));
|
|
@@ -18386,14 +18547,14 @@ var init_openclaw_projects = __esm(() => {
|
|
|
18386
18547
|
|
|
18387
18548
|
// lib/factory-sessions.ts
|
|
18388
18549
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
18389
|
-
import { readdirSync as
|
|
18390
|
-
import { homedir as
|
|
18391
|
-
import { join as
|
|
18550
|
+
import { readdirSync as readdirSync7, statSync as statSync9 } from "node:fs";
|
|
18551
|
+
import { homedir as homedir14 } from "node:os";
|
|
18552
|
+
import { join as join18 } from "node:path";
|
|
18392
18553
|
function factoryHome() {
|
|
18393
|
-
return process.env.FACTORY_HOME ||
|
|
18554
|
+
return process.env.FACTORY_HOME || join18(homedir14(), ".factory");
|
|
18394
18555
|
}
|
|
18395
18556
|
function factorySessionsRoot() {
|
|
18396
|
-
return
|
|
18557
|
+
return join18(factoryHome(), "sessions");
|
|
18397
18558
|
}
|
|
18398
18559
|
function isPlainObject4(v) {
|
|
18399
18560
|
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
@@ -18532,17 +18693,17 @@ function listFactoryTranscripts() {
|
|
|
18532
18693
|
const out = [];
|
|
18533
18694
|
let projectDirs;
|
|
18534
18695
|
try {
|
|
18535
|
-
projectDirs =
|
|
18696
|
+
projectDirs = readdirSync7(root, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
18536
18697
|
} catch {
|
|
18537
18698
|
return out;
|
|
18538
18699
|
}
|
|
18539
18700
|
for (const dir of projectDirs) {
|
|
18540
18701
|
const projectName = dir.name;
|
|
18541
18702
|
const cwd = decodeFolderName(projectName);
|
|
18542
|
-
const projectPath =
|
|
18703
|
+
const projectPath = join18(root, projectName);
|
|
18543
18704
|
let files;
|
|
18544
18705
|
try {
|
|
18545
|
-
files =
|
|
18706
|
+
files = readdirSync7(projectPath);
|
|
18546
18707
|
} catch {
|
|
18547
18708
|
continue;
|
|
18548
18709
|
}
|
|
@@ -18552,9 +18713,9 @@ function listFactoryTranscripts() {
|
|
|
18552
18713
|
const sessionId = file.slice(0, -".jsonl".length);
|
|
18553
18714
|
if (!FACTORY_SESSION_ID_RE.test(sessionId))
|
|
18554
18715
|
continue;
|
|
18555
|
-
const transcriptPath =
|
|
18716
|
+
const transcriptPath = join18(projectPath, file);
|
|
18556
18717
|
try {
|
|
18557
|
-
const st =
|
|
18718
|
+
const st = statSync9(transcriptPath);
|
|
18558
18719
|
out.push({ projectName, cwd, sessionId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
|
|
18559
18720
|
} catch {}
|
|
18560
18721
|
}
|
|
@@ -18675,13 +18836,13 @@ var init_factory_projects = __esm(() => {
|
|
|
18675
18836
|
});
|
|
18676
18837
|
|
|
18677
18838
|
// lib/devin-sessions.ts
|
|
18678
|
-
import { homedir as
|
|
18679
|
-
import { join as
|
|
18839
|
+
import { homedir as homedir15 } from "node:os";
|
|
18840
|
+
import { join as join19 } from "node:path";
|
|
18680
18841
|
function devinHome() {
|
|
18681
|
-
return process.env.DEVIN_HOME ||
|
|
18842
|
+
return process.env.DEVIN_HOME || join19(homedir15(), ".local", "share", "devin");
|
|
18682
18843
|
}
|
|
18683
18844
|
function devinDbPath() {
|
|
18684
|
-
return process.env.DEVIN_DB_PATH ||
|
|
18845
|
+
return process.env.DEVIN_DB_PATH || join19(devinHome(), "cli", "sessions.db");
|
|
18685
18846
|
}
|
|
18686
18847
|
function devinEpochToMs(value) {
|
|
18687
18848
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
@@ -18974,17 +19135,17 @@ var init_devin_projects = __esm(() => {
|
|
|
18974
19135
|
|
|
18975
19136
|
// lib/antigravity-sessions.ts
|
|
18976
19137
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
18977
|
-
import { readdirSync as
|
|
18978
|
-
import { homedir as
|
|
18979
|
-
import { join as
|
|
19138
|
+
import { readdirSync as readdirSync8, statSync as statSync10 } from "node:fs";
|
|
19139
|
+
import { homedir as homedir16 } from "node:os";
|
|
19140
|
+
import { join as join20 } from "node:path";
|
|
18980
19141
|
function antigravityHome() {
|
|
18981
|
-
return process.env.ANTIGRAVITY_HOME ||
|
|
19142
|
+
return process.env.ANTIGRAVITY_HOME || join20(homedir16(), ".gemini", "antigravity-cli");
|
|
18982
19143
|
}
|
|
18983
19144
|
function antigravityBrainRoot() {
|
|
18984
|
-
return
|
|
19145
|
+
return join20(antigravityHome(), "brain");
|
|
18985
19146
|
}
|
|
18986
19147
|
function antigravityTranscriptRelPath() {
|
|
18987
|
-
return
|
|
19148
|
+
return join20(".system_generated", "logs", "transcript_full.jsonl");
|
|
18988
19149
|
}
|
|
18989
19150
|
function isPlainObject6(v) {
|
|
18990
19151
|
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
@@ -19099,7 +19260,7 @@ function listAntigravityTranscripts() {
|
|
|
19099
19260
|
const out = [];
|
|
19100
19261
|
let convoDirs;
|
|
19101
19262
|
try {
|
|
19102
|
-
convoDirs =
|
|
19263
|
+
convoDirs = readdirSync8(root, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
19103
19264
|
} catch {
|
|
19104
19265
|
return out;
|
|
19105
19266
|
}
|
|
@@ -19107,9 +19268,9 @@ function listAntigravityTranscripts() {
|
|
|
19107
19268
|
const conversationId = dir.name;
|
|
19108
19269
|
if (!ANTIGRAVITY_CONVERSATION_ID_RE.test(conversationId))
|
|
19109
19270
|
continue;
|
|
19110
|
-
const transcriptPath =
|
|
19271
|
+
const transcriptPath = join20(root, conversationId, rel);
|
|
19111
19272
|
try {
|
|
19112
|
-
const st =
|
|
19273
|
+
const st = statSync10(transcriptPath);
|
|
19113
19274
|
if (!st.isFile())
|
|
19114
19275
|
continue;
|
|
19115
19276
|
out.push({ conversationId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
|
|
@@ -19120,9 +19281,9 @@ function listAntigravityTranscripts() {
|
|
|
19120
19281
|
function findAntigravityTranscript(conversationId) {
|
|
19121
19282
|
if (!ANTIGRAVITY_CONVERSATION_ID_RE.test(conversationId))
|
|
19122
19283
|
return null;
|
|
19123
|
-
const transcriptPath =
|
|
19284
|
+
const transcriptPath = join20(antigravityBrainRoot(), conversationId, antigravityTranscriptRelPath());
|
|
19124
19285
|
try {
|
|
19125
|
-
if (
|
|
19286
|
+
if (statSync10(transcriptPath).isFile())
|
|
19126
19287
|
return transcriptPath;
|
|
19127
19288
|
} catch {}
|
|
19128
19289
|
return null;
|
|
@@ -19156,9 +19317,9 @@ __export(exports_antigravity_projects, {
|
|
|
19156
19317
|
getAntigravityIndex: () => getAntigravityIndex,
|
|
19157
19318
|
getAntigravityProjects: () => getAntigravityProjects
|
|
19158
19319
|
});
|
|
19159
|
-
import { join as
|
|
19320
|
+
import { join as join21 } from "node:path";
|
|
19160
19321
|
function antigravitySummariesDbPath() {
|
|
19161
|
-
return
|
|
19322
|
+
return join21(antigravityHome(), "conversation_summaries.db");
|
|
19162
19323
|
}
|
|
19163
19324
|
function parseWorkspaceCwd(raw) {
|
|
19164
19325
|
if (!raw)
|
|
@@ -19301,16 +19462,16 @@ var init_antigravity_projects = __esm(() => {
|
|
|
19301
19462
|
});
|
|
19302
19463
|
|
|
19303
19464
|
// lib/goose-sessions.ts
|
|
19304
|
-
import { homedir as
|
|
19305
|
-
import { join as
|
|
19465
|
+
import { homedir as homedir17 } from "node:os";
|
|
19466
|
+
import { join as join22 } from "node:path";
|
|
19306
19467
|
function gooseHome() {
|
|
19307
19468
|
if (process.env.GOOSE_HOME)
|
|
19308
19469
|
return process.env.GOOSE_HOME;
|
|
19309
19470
|
const xdg = process.env.XDG_DATA_HOME;
|
|
19310
|
-
return
|
|
19471
|
+
return join22(xdg && xdg.length > 0 ? xdg : join22(homedir17(), ".local", "share"), "goose");
|
|
19311
19472
|
}
|
|
19312
19473
|
function gooseDbPath() {
|
|
19313
|
-
return process.env.GOOSE_DB_PATH ||
|
|
19474
|
+
return process.env.GOOSE_DB_PATH || join22(gooseHome(), "sessions", "sessions.db");
|
|
19314
19475
|
}
|
|
19315
19476
|
function gooseTimestampToMs(value) {
|
|
19316
19477
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
@@ -19574,7 +19735,7 @@ var init_goose_projects = __esm(() => {
|
|
|
19574
19735
|
|
|
19575
19736
|
// lib/projects.ts
|
|
19576
19737
|
import { readdir as readdir5, stat as stat4 } from "node:fs/promises";
|
|
19577
|
-
import { join as
|
|
19738
|
+
import { join as join23, resolve as resolve12, sep } from "node:path";
|
|
19578
19739
|
async function getMtime(path, label) {
|
|
19579
19740
|
try {
|
|
19580
19741
|
return (await stat4(path)).mtime;
|
|
@@ -19600,7 +19761,7 @@ async function getClaudeProjectFolders() {
|
|
|
19600
19761
|
if (!entries)
|
|
19601
19762
|
return [];
|
|
19602
19763
|
const settled = await batchAll(entries.filter((entry) => entry.isDirectory()).map((entry) => async () => {
|
|
19603
|
-
const folderPath =
|
|
19764
|
+
const folderPath = join23(projectsPath, entry.name);
|
|
19604
19765
|
const mtime = await getMtime(folderPath, entry.name);
|
|
19605
19766
|
return {
|
|
19606
19767
|
name: entry.name,
|
|
@@ -19726,8 +19887,8 @@ function resolveProjectPath(projectName) {
|
|
|
19726
19887
|
throw new RangeError("Empty project name");
|
|
19727
19888
|
if (/^[/\\]/.test(projectName))
|
|
19728
19889
|
throw new RangeError("Absolute project name");
|
|
19729
|
-
const projectsPath =
|
|
19730
|
-
const candidate =
|
|
19890
|
+
const projectsPath = resolve12(getClaudeProjectsPath());
|
|
19891
|
+
const candidate = resolve12(join23(projectsPath, projectName));
|
|
19731
19892
|
if (!candidate.startsWith(projectsPath + sep)) {
|
|
19732
19893
|
throw new RangeError("Project path escapes root");
|
|
19733
19894
|
}
|
|
@@ -19745,7 +19906,7 @@ async function getSessionFiles(projectPath) {
|
|
|
19745
19906
|
return [];
|
|
19746
19907
|
const jsonlEntries = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl") && extractSessionId2(entry.name));
|
|
19747
19908
|
const settled = await batchAll(jsonlEntries.map((entry) => async () => {
|
|
19748
|
-
const filePath =
|
|
19909
|
+
const filePath = join23(projectPath, entry.name);
|
|
19749
19910
|
const mtime = await getMtime(filePath, entry.name);
|
|
19750
19911
|
return {
|
|
19751
19912
|
name: entry.name,
|
|
@@ -19774,13 +19935,13 @@ var init_projects = __esm(() => {
|
|
|
19774
19935
|
|
|
19775
19936
|
// lib/resolve-subagent-path.ts
|
|
19776
19937
|
import { access as access2 } from "fs/promises";
|
|
19777
|
-
import { join as
|
|
19938
|
+
import { join as join24, relative as relative3 } from "path";
|
|
19778
19939
|
async function resolveSubagentPath(projectsPath, projectName, sessionId, agentId) {
|
|
19779
19940
|
const fileName = `agent-${agentId}.jsonl`;
|
|
19780
19941
|
const candidatePaths = [
|
|
19781
|
-
|
|
19782
|
-
|
|
19783
|
-
|
|
19942
|
+
join24(projectsPath, projectName, fileName),
|
|
19943
|
+
join24(projectsPath, projectName, sessionId, fileName),
|
|
19944
|
+
join24(projectsPath, projectName, sessionId, "subagents", fileName)
|
|
19784
19945
|
];
|
|
19785
19946
|
for (const candidatePath of candidatePaths) {
|
|
19786
19947
|
if (relative3(projectsPath, candidatePath).startsWith("..")) {
|
|
@@ -19802,7 +19963,7 @@ var init_resolve_subagent_path = () => {};
|
|
|
19802
19963
|
|
|
19803
19964
|
// lib/log-entries.ts
|
|
19804
19965
|
import { readFile as readFile10 } from "fs/promises";
|
|
19805
|
-
import { join as
|
|
19966
|
+
import { join as join25 } from "path";
|
|
19806
19967
|
function formatTimestamp(date) {
|
|
19807
19968
|
const base = formatDate(date);
|
|
19808
19969
|
const ms = date.getMilliseconds().toString().padStart(3, "0");
|
|
@@ -20000,7 +20161,7 @@ async function parseLogContent(fileContent, source = "session") {
|
|
|
20000
20161
|
async function parseSessionLog(projectName, sessionId) {
|
|
20001
20162
|
const projectDir = resolveProjectPath(projectName);
|
|
20002
20163
|
const projectsPath = getClaudeProjectsPath();
|
|
20003
|
-
const filePath =
|
|
20164
|
+
const filePath = join25(projectDir, `${sessionId}.jsonl`);
|
|
20004
20165
|
const fileContent = await readFile10(filePath, "utf-8");
|
|
20005
20166
|
const { entries: sessionEntries, rawLines: sessionRawLines, subagentIds } = await parseFileContent(fileContent, "session");
|
|
20006
20167
|
if (subagentIds.length === 0) {
|
|
@@ -20037,13 +20198,13 @@ var init_log_entries = __esm(() => {
|
|
|
20037
20198
|
});
|
|
20038
20199
|
|
|
20039
20200
|
// lib/codex-sessions.ts
|
|
20040
|
-
import { readFileSync as readFileSync10, readdirSync as
|
|
20201
|
+
import { readFileSync as readFileSync10, readdirSync as readdirSync9, existsSync as existsSync14, writeFileSync as writeFileSync6, mkdirSync as mkdirSync7, statSync as statSync11 } from "node:fs";
|
|
20041
20202
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
20042
|
-
import { dirname as
|
|
20043
|
-
import { homedir as
|
|
20203
|
+
import { dirname as dirname8, join as join26 } from "node:path";
|
|
20204
|
+
import { homedir as homedir18 } from "node:os";
|
|
20044
20205
|
function readCache() {
|
|
20045
20206
|
try {
|
|
20046
|
-
if (!
|
|
20207
|
+
if (!existsSync14(CACHE_PATH))
|
|
20047
20208
|
return {};
|
|
20048
20209
|
return JSON.parse(readFileSync10(CACHE_PATH, "utf-8"));
|
|
20049
20210
|
} catch {
|
|
@@ -20052,7 +20213,7 @@ function readCache() {
|
|
|
20052
20213
|
}
|
|
20053
20214
|
function writeCacheEntry(sessionId, path) {
|
|
20054
20215
|
try {
|
|
20055
|
-
mkdirSync7(
|
|
20216
|
+
mkdirSync7(dirname8(CACHE_PATH), { recursive: true });
|
|
20056
20217
|
const cache = readCache();
|
|
20057
20218
|
cache[sessionId] = path;
|
|
20058
20219
|
writeFileSync6(CACHE_PATH, JSON.stringify(cache), "utf-8");
|
|
@@ -20060,9 +20221,9 @@ function writeCacheEntry(sessionId, path) {
|
|
|
20060
20221
|
}
|
|
20061
20222
|
function dirSearch(dir, sessionId) {
|
|
20062
20223
|
try {
|
|
20063
|
-
for (const f of
|
|
20224
|
+
for (const f of readdirSync9(dir, { withFileTypes: true })) {
|
|
20064
20225
|
if (f.isFile() && f.name.includes(sessionId) && f.name.endsWith(".jsonl")) {
|
|
20065
|
-
return
|
|
20226
|
+
return join26(dir, f.name);
|
|
20066
20227
|
}
|
|
20067
20228
|
}
|
|
20068
20229
|
} catch {}
|
|
@@ -20071,16 +20232,16 @@ function dirSearch(dir, sessionId) {
|
|
|
20071
20232
|
function findCodexTranscript(sessionId) {
|
|
20072
20233
|
const cache = readCache();
|
|
20073
20234
|
const cached = cache[sessionId];
|
|
20074
|
-
if (cached &&
|
|
20235
|
+
if (cached && existsSync14(cached))
|
|
20075
20236
|
return cached;
|
|
20076
|
-
const root =
|
|
20237
|
+
const root = join26(homedir18(), ".codex", "sessions");
|
|
20077
20238
|
const today = new Date;
|
|
20078
20239
|
const yesterday = new Date(today.getTime() - 24 * 60 * 60 * 1000);
|
|
20079
20240
|
const datedDirs = [today, yesterday].map((d) => {
|
|
20080
20241
|
const y = String(d.getUTCFullYear());
|
|
20081
20242
|
const m = String(d.getUTCMonth() + 1).padStart(2, "0");
|
|
20082
20243
|
const day = String(d.getUTCDate()).padStart(2, "0");
|
|
20083
|
-
return
|
|
20244
|
+
return join26(root, y, m, day);
|
|
20084
20245
|
});
|
|
20085
20246
|
for (const dir of datedDirs) {
|
|
20086
20247
|
const hit = dirSearch(dir, sessionId);
|
|
@@ -20090,16 +20251,16 @@ function findCodexTranscript(sessionId) {
|
|
|
20090
20251
|
}
|
|
20091
20252
|
}
|
|
20092
20253
|
try {
|
|
20093
|
-
for (const y of
|
|
20254
|
+
for (const y of readdirSync9(root, { withFileTypes: true })) {
|
|
20094
20255
|
if (!y.isDirectory())
|
|
20095
20256
|
continue;
|
|
20096
|
-
for (const m of
|
|
20257
|
+
for (const m of readdirSync9(join26(root, y.name), { withFileTypes: true })) {
|
|
20097
20258
|
if (!m.isDirectory())
|
|
20098
20259
|
continue;
|
|
20099
|
-
for (const d of
|
|
20260
|
+
for (const d of readdirSync9(join26(root, y.name, m.name), { withFileTypes: true })) {
|
|
20100
20261
|
if (!d.isDirectory())
|
|
20101
20262
|
continue;
|
|
20102
|
-
const hit = dirSearch(
|
|
20263
|
+
const hit = dirSearch(join26(root, y.name, m.name, d.name), sessionId);
|
|
20103
20264
|
if (hit) {
|
|
20104
20265
|
writeCacheEntry(sessionId, hit);
|
|
20105
20266
|
return hit;
|
|
@@ -20365,21 +20526,21 @@ var init_resolve_permission_mode = __esm(() => {
|
|
|
20365
20526
|
});
|
|
20366
20527
|
|
|
20367
20528
|
// lib/copilot-sessions.ts
|
|
20368
|
-
import { readFileSync as readFileSync12, readdirSync as
|
|
20529
|
+
import { readFileSync as readFileSync12, readdirSync as readdirSync10, existsSync as existsSync15, statSync as statSync12 } from "node:fs";
|
|
20369
20530
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
20370
|
-
import { join as
|
|
20371
|
-
import { homedir as
|
|
20531
|
+
import { join as join27, resolve as resolve13, sep as sep2 } from "node:path";
|
|
20532
|
+
import { homedir as homedir19 } from "node:os";
|
|
20372
20533
|
function getCopilotHome() {
|
|
20373
|
-
return process.env.COPILOT_HOME ||
|
|
20534
|
+
return process.env.COPILOT_HOME || join27(homedir19(), ".copilot");
|
|
20374
20535
|
}
|
|
20375
20536
|
function getCopilotSessionStateRoot2() {
|
|
20376
|
-
return
|
|
20537
|
+
return join27(getCopilotHome(), "session-state");
|
|
20377
20538
|
}
|
|
20378
20539
|
function getCopilotSessionDir(sessionId) {
|
|
20379
20540
|
if (!sessionId)
|
|
20380
20541
|
return null;
|
|
20381
|
-
const root =
|
|
20382
|
-
const candidate =
|
|
20542
|
+
const root = resolve13(getCopilotSessionStateRoot2());
|
|
20543
|
+
const candidate = resolve13(root, sessionId);
|
|
20383
20544
|
if (candidate === root || !candidate.startsWith(`${root}${sep2}`))
|
|
20384
20545
|
return null;
|
|
20385
20546
|
return candidate;
|
|
@@ -20388,19 +20549,19 @@ function resolveSessionFile(sessionId, filename) {
|
|
|
20388
20549
|
const dir = getCopilotSessionDir(sessionId);
|
|
20389
20550
|
if (!dir)
|
|
20390
20551
|
return null;
|
|
20391
|
-
return
|
|
20552
|
+
return join27(dir, filename);
|
|
20392
20553
|
}
|
|
20393
20554
|
function findCopilotTranscript(sessionId) {
|
|
20394
20555
|
const candidate = resolveSessionFile(sessionId, "events.jsonl");
|
|
20395
20556
|
if (!candidate)
|
|
20396
20557
|
return null;
|
|
20397
|
-
return
|
|
20558
|
+
return existsSync15(candidate) ? candidate : null;
|
|
20398
20559
|
}
|
|
20399
20560
|
function findCopilotWorkspace(sessionId) {
|
|
20400
20561
|
const candidate = resolveSessionFile(sessionId, "workspace.yaml");
|
|
20401
20562
|
if (!candidate)
|
|
20402
20563
|
return null;
|
|
20403
|
-
return
|
|
20564
|
+
return existsSync15(candidate) ? candidate : null;
|
|
20404
20565
|
}
|
|
20405
20566
|
function readYamlScalar(path, key) {
|
|
20406
20567
|
try {
|
|
@@ -20582,38 +20743,38 @@ var init_copilot_sessions = __esm(() => {
|
|
|
20582
20743
|
});
|
|
20583
20744
|
|
|
20584
20745
|
// lib/cursor-sessions.ts
|
|
20585
|
-
import { readFileSync as readFileSync13, readdirSync as
|
|
20746
|
+
import { readFileSync as readFileSync13, readdirSync as readdirSync11, existsSync as existsSync16, statSync as statSync13 } from "node:fs";
|
|
20586
20747
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
20587
|
-
import { basename as
|
|
20588
|
-
import { homedir as
|
|
20748
|
+
import { basename as basename4, join as join28, resolve as resolve14, sep as sep3 } from "node:path";
|
|
20749
|
+
import { homedir as homedir20 } from "node:os";
|
|
20589
20750
|
function getCursorHome2() {
|
|
20590
|
-
return process.env.CURSOR_HOME ||
|
|
20751
|
+
return process.env.CURSOR_HOME || join28(homedir20(), ".cursor");
|
|
20591
20752
|
}
|
|
20592
20753
|
function getCursorSessionDir(sessionId) {
|
|
20593
20754
|
if (!sessionId)
|
|
20594
20755
|
return null;
|
|
20595
|
-
const home =
|
|
20596
|
-
const projectsRoot =
|
|
20756
|
+
const home = resolve14(getCursorHome2());
|
|
20757
|
+
const projectsRoot = resolve14(home, NEW_PROJECTS_DIR2);
|
|
20597
20758
|
let projectEntries = [];
|
|
20598
20759
|
try {
|
|
20599
|
-
projectEntries =
|
|
20760
|
+
projectEntries = readdirSync11(projectsRoot, { withFileTypes: true });
|
|
20600
20761
|
} catch {}
|
|
20601
20762
|
for (const entry of projectEntries) {
|
|
20602
20763
|
if (!entry.isDirectory())
|
|
20603
20764
|
continue;
|
|
20604
|
-
const candidate =
|
|
20605
|
-
const transcriptRoot =
|
|
20765
|
+
const candidate = resolve14(projectsRoot, entry.name, NEW_AGENT_TRANSCRIPTS_DIR2, sessionId);
|
|
20766
|
+
const transcriptRoot = resolve14(projectsRoot, entry.name, NEW_AGENT_TRANSCRIPTS_DIR2);
|
|
20606
20767
|
if (candidate === transcriptRoot || !candidate.startsWith(`${transcriptRoot}${sep3}`))
|
|
20607
20768
|
continue;
|
|
20608
|
-
if (
|
|
20769
|
+
if (existsSync16(candidate))
|
|
20609
20770
|
return candidate;
|
|
20610
20771
|
}
|
|
20611
20772
|
for (const sub of LEGACY_SESSION_ROOT_CANDIDATES2) {
|
|
20612
|
-
const root =
|
|
20613
|
-
const candidate =
|
|
20773
|
+
const root = resolve14(home, sub);
|
|
20774
|
+
const candidate = resolve14(root, sessionId);
|
|
20614
20775
|
if (candidate === root || !candidate.startsWith(`${root}${sep3}`))
|
|
20615
20776
|
continue;
|
|
20616
|
-
if (
|
|
20777
|
+
if (existsSync16(candidate))
|
|
20617
20778
|
return candidate;
|
|
20618
20779
|
}
|
|
20619
20780
|
return null;
|
|
@@ -20622,12 +20783,12 @@ function findCursorTranscript(sessionId) {
|
|
|
20622
20783
|
const dir = getCursorSessionDir(sessionId);
|
|
20623
20784
|
if (!dir)
|
|
20624
20785
|
return null;
|
|
20625
|
-
const newCandidate =
|
|
20626
|
-
if (
|
|
20786
|
+
const newCandidate = join28(dir, `${basename4(dir)}.jsonl`);
|
|
20787
|
+
if (existsSync16(newCandidate))
|
|
20627
20788
|
return newCandidate;
|
|
20628
20789
|
for (const name of LEGACY_TRANSCRIPT_FILE_CANDIDATES2) {
|
|
20629
|
-
const candidate =
|
|
20630
|
-
if (
|
|
20790
|
+
const candidate = join28(dir, name);
|
|
20791
|
+
if (existsSync16(candidate))
|
|
20631
20792
|
return candidate;
|
|
20632
20793
|
}
|
|
20633
20794
|
return null;
|
|
@@ -20838,12 +20999,12 @@ var init_cursor_sessions = __esm(() => {
|
|
|
20838
20999
|
});
|
|
20839
21000
|
|
|
20840
21001
|
// lib/pi-sessions.ts
|
|
20841
|
-
import { readFileSync as readFileSync14, readdirSync as
|
|
21002
|
+
import { readFileSync as readFileSync14, readdirSync as readdirSync12, existsSync as existsSync17, statSync as statSync14 } from "node:fs";
|
|
20842
21003
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
20843
|
-
import { join as
|
|
20844
|
-
import { homedir as
|
|
21004
|
+
import { join as join29, resolve as resolve15, sep as sep4 } from "node:path";
|
|
21005
|
+
import { homedir as homedir21 } from "node:os";
|
|
20845
21006
|
function getPiSessionStateRoot() {
|
|
20846
|
-
return process.env.PI_SESSIONS_DIR ||
|
|
21007
|
+
return process.env.PI_SESSIONS_DIR || join29(homedir21(), ".pi", "agent", "sessions");
|
|
20847
21008
|
}
|
|
20848
21009
|
function isSafeSessionId(sessionId) {
|
|
20849
21010
|
return UUID_RE.test(sessionId);
|
|
@@ -20851,20 +21012,20 @@ function isSafeSessionId(sessionId) {
|
|
|
20851
21012
|
function findPiTranscript(sessionId) {
|
|
20852
21013
|
if (!isSafeSessionId(sessionId))
|
|
20853
21014
|
return null;
|
|
20854
|
-
const root =
|
|
21015
|
+
const root = resolve15(getPiSessionStateRoot());
|
|
20855
21016
|
let cwdDirs;
|
|
20856
21017
|
try {
|
|
20857
|
-
cwdDirs =
|
|
21018
|
+
cwdDirs = readdirSync12(root);
|
|
20858
21019
|
} catch {
|
|
20859
21020
|
return null;
|
|
20860
21021
|
}
|
|
20861
21022
|
for (const cwdDir of cwdDirs) {
|
|
20862
|
-
const cwdPath =
|
|
21023
|
+
const cwdPath = resolve15(root, cwdDir);
|
|
20863
21024
|
if (!cwdPath.startsWith(`${root}${sep4}`))
|
|
20864
21025
|
continue;
|
|
20865
21026
|
let files;
|
|
20866
21027
|
try {
|
|
20867
|
-
files =
|
|
21028
|
+
files = readdirSync12(cwdPath);
|
|
20868
21029
|
} catch {
|
|
20869
21030
|
continue;
|
|
20870
21031
|
}
|
|
@@ -20872,10 +21033,10 @@ function findPiTranscript(sessionId) {
|
|
|
20872
21033
|
const m = SESSION_FILE_RE2.exec(f);
|
|
20873
21034
|
if (!m || m[1].toLowerCase() !== sessionId.toLowerCase())
|
|
20874
21035
|
continue;
|
|
20875
|
-
const candidate =
|
|
21036
|
+
const candidate = resolve15(cwdPath, f);
|
|
20876
21037
|
if (!candidate.startsWith(`${cwdPath}${sep4}`))
|
|
20877
21038
|
continue;
|
|
20878
|
-
if (
|
|
21039
|
+
if (existsSync17(candidate))
|
|
20879
21040
|
return candidate;
|
|
20880
21041
|
}
|
|
20881
21042
|
}
|
|
@@ -21281,31 +21442,31 @@ var init_pack_failclosed = __esm(() => {
|
|
|
21281
21442
|
// lib/atomic-write.ts
|
|
21282
21443
|
import {
|
|
21283
21444
|
chmodSync as chmodSync2,
|
|
21284
|
-
existsSync as
|
|
21445
|
+
existsSync as existsSync18,
|
|
21285
21446
|
mkdirSync as mkdirSync8,
|
|
21286
21447
|
renameSync as renameSync4,
|
|
21287
21448
|
rmSync as rmSync3,
|
|
21288
|
-
statSync as
|
|
21449
|
+
statSync as statSync15,
|
|
21289
21450
|
writeFileSync as writeFileSync7
|
|
21290
21451
|
} from "node:fs";
|
|
21291
|
-
import { dirname as
|
|
21452
|
+
import { dirname as dirname9 } from "node:path";
|
|
21292
21453
|
import { randomBytes } from "node:crypto";
|
|
21293
21454
|
function writeJsonAtomically(filePath, value, opts = {}) {
|
|
21294
21455
|
const mode = opts.mode ?? 384;
|
|
21295
21456
|
const dirMode = opts.dirMode ?? 448;
|
|
21296
|
-
const dir =
|
|
21297
|
-
if (!
|
|
21457
|
+
const dir = dirname9(filePath);
|
|
21458
|
+
if (!existsSync18(dir))
|
|
21298
21459
|
mkdirSync8(dir, { recursive: true, mode: dirMode });
|
|
21299
21460
|
const tmp = `${filePath}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
21300
21461
|
try {
|
|
21301
21462
|
writeFileSync7(tmp, JSON.stringify(value, null, 2), { mode });
|
|
21302
21463
|
try {
|
|
21303
|
-
if ((
|
|
21464
|
+
if ((statSync15(tmp).mode & 63) !== 0)
|
|
21304
21465
|
chmodSync2(tmp, mode);
|
|
21305
21466
|
} catch {}
|
|
21306
21467
|
renameSync4(tmp, filePath);
|
|
21307
21468
|
try {
|
|
21308
|
-
if ((
|
|
21469
|
+
if ((statSync15(filePath).mode & 63) !== 0)
|
|
21309
21470
|
chmodSync2(filePath, mode);
|
|
21310
21471
|
} catch {}
|
|
21311
21472
|
} catch (err) {
|
|
@@ -21318,18 +21479,18 @@ function writeJsonAtomically(filePath, value, opts = {}) {
|
|
|
21318
21479
|
var init_atomic_write = () => {};
|
|
21319
21480
|
|
|
21320
21481
|
// src/hooks/session-pause.ts
|
|
21321
|
-
import { existsSync as
|
|
21482
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync9, readdirSync as readdirSync13, readFileSync as readFileSync15, rmSync as rmSync4 } from "node:fs";
|
|
21322
21483
|
import { createHash as createHash6 } from "node:crypto";
|
|
21323
|
-
import { join as
|
|
21484
|
+
import { join as join30, resolve as resolve16 } from "node:path";
|
|
21324
21485
|
function pauseStateDir() {
|
|
21325
21486
|
const override = process.env.FAILPROOFAI_STATE_DIR;
|
|
21326
21487
|
if (override)
|
|
21327
|
-
return
|
|
21488
|
+
return resolve16(override, "sessions");
|
|
21328
21489
|
return sessionPauseDir();
|
|
21329
21490
|
}
|
|
21330
21491
|
function pauseFilePath(sessionId) {
|
|
21331
21492
|
const digest = createHash6("sha256").update(sessionId).digest("hex").slice(0, 32);
|
|
21332
|
-
return
|
|
21493
|
+
return join30(pauseStateDir(), `${digest}.json`);
|
|
21333
21494
|
}
|
|
21334
21495
|
function parsePauseDuration(input, ceilingMs = PAUSE_CEILING_MS) {
|
|
21335
21496
|
if (input === undefined || input === "")
|
|
@@ -21385,7 +21546,7 @@ function readActivePause(sessionId, now = Date.now()) {
|
|
|
21385
21546
|
return null;
|
|
21386
21547
|
try {
|
|
21387
21548
|
const path = pauseFilePath(sessionId);
|
|
21388
|
-
if (!
|
|
21549
|
+
if (!existsSync19(path))
|
|
21389
21550
|
return null;
|
|
21390
21551
|
const stored = parseStored(JSON.parse(readFileSync15(path, "utf8")));
|
|
21391
21552
|
if (!stored)
|
|
@@ -21416,7 +21577,7 @@ function writePause(opts) {
|
|
|
21416
21577
|
}
|
|
21417
21578
|
function clearPause(sessionId) {
|
|
21418
21579
|
const path = pauseFilePath(sessionId);
|
|
21419
|
-
if (!
|
|
21580
|
+
if (!existsSync19(path))
|
|
21420
21581
|
return false;
|
|
21421
21582
|
try {
|
|
21422
21583
|
rmSync4(path);
|
|
@@ -21427,12 +21588,12 @@ function clearPause(sessionId) {
|
|
|
21427
21588
|
}
|
|
21428
21589
|
function listActivePauses(now = Date.now()) {
|
|
21429
21590
|
const dir = pauseStateDir();
|
|
21430
|
-
if (!
|
|
21591
|
+
if (!existsSync19(dir))
|
|
21431
21592
|
return [];
|
|
21432
21593
|
const out = [];
|
|
21433
21594
|
let names;
|
|
21434
21595
|
try {
|
|
21435
|
-
names =
|
|
21596
|
+
names = readdirSync13(dir);
|
|
21436
21597
|
} catch {
|
|
21437
21598
|
return [];
|
|
21438
21599
|
}
|
|
@@ -21440,7 +21601,7 @@ function listActivePauses(now = Date.now()) {
|
|
|
21440
21601
|
if (!name.endsWith(".json"))
|
|
21441
21602
|
continue;
|
|
21442
21603
|
try {
|
|
21443
|
-
const stored = parseStored(JSON.parse(readFileSync15(
|
|
21604
|
+
const stored = parseStored(JSON.parse(readFileSync15(join30(dir, name), "utf8")));
|
|
21444
21605
|
if (!stored || stored.expiresAt <= now)
|
|
21445
21606
|
continue;
|
|
21446
21607
|
const { schemaVersion: _ignored, ...pause } = stored;
|
|
@@ -21481,17 +21642,17 @@ var init_session_pause = __esm(() => {
|
|
|
21481
21642
|
import { createHash as createHash7 } from "node:crypto";
|
|
21482
21643
|
import {
|
|
21483
21644
|
chmodSync as chmodSync3,
|
|
21484
|
-
existsSync as
|
|
21645
|
+
existsSync as existsSync20,
|
|
21485
21646
|
mkdirSync as mkdirSync10,
|
|
21486
|
-
readdirSync as
|
|
21647
|
+
readdirSync as readdirSync14,
|
|
21487
21648
|
readFileSync as readFileSync16,
|
|
21488
21649
|
renameSync as renameSync5,
|
|
21489
21650
|
rmSync as rmSync5,
|
|
21490
|
-
statSync as
|
|
21651
|
+
statSync as statSync16,
|
|
21491
21652
|
writeFileSync as writeFileSync8
|
|
21492
21653
|
} from "node:fs";
|
|
21493
21654
|
import { createRequire as createRequire2 } from "node:module";
|
|
21494
|
-
import { dirname as
|
|
21655
|
+
import { dirname as dirname10, resolve as resolve17 } from "node:path";
|
|
21495
21656
|
import { gunzipSync } from "node:zlib";
|
|
21496
21657
|
function baseUrl2() {
|
|
21497
21658
|
return (process.env.FAILPROOFAI_DAEMON_BASE_URL || DEFAULT_BASE_URL2).replace(/\/+$/, "");
|
|
@@ -21500,7 +21661,7 @@ function daemonBinaryDir() {
|
|
|
21500
21661
|
return binDir();
|
|
21501
21662
|
}
|
|
21502
21663
|
function installedBinaryPath(ver = version2) {
|
|
21503
|
-
return
|
|
21664
|
+
return resolve17(daemonBinaryDir(), `failproofaid-${ver}`);
|
|
21504
21665
|
}
|
|
21505
21666
|
function daemonAssetUrl(key, ver = version2) {
|
|
21506
21667
|
return `${baseUrl2()}/v${ver}/failproofaid-${key}.gz`;
|
|
@@ -21517,31 +21678,31 @@ function npmPlatformBinaryPath(key) {
|
|
|
21517
21678
|
return null;
|
|
21518
21679
|
const name = platformPackageName(key);
|
|
21519
21680
|
try {
|
|
21520
|
-
const requireFromRoot = createRequire2(
|
|
21521
|
-
const found = platformPackageBinary(
|
|
21681
|
+
const requireFromRoot = createRequire2(resolve17(packageRoot, "package.json"));
|
|
21682
|
+
const found = platformPackageBinary(dirname10(requireFromRoot.resolve(`${name}/package.json`)));
|
|
21522
21683
|
if (found)
|
|
21523
21684
|
return found;
|
|
21524
21685
|
} catch {}
|
|
21525
|
-
return platformPackageBinary(
|
|
21686
|
+
return platformPackageBinary(resolve17(packageRoot, "node_modules", name));
|
|
21526
21687
|
}
|
|
21527
21688
|
function platformPackageBinary(dir) {
|
|
21528
21689
|
try {
|
|
21529
|
-
const manifest = JSON.parse(readFileSync16(
|
|
21690
|
+
const manifest = JSON.parse(readFileSync16(resolve17(dir, "package.json"), "utf8"));
|
|
21530
21691
|
if (manifest.version !== version2)
|
|
21531
21692
|
return null;
|
|
21532
21693
|
} catch {
|
|
21533
21694
|
return null;
|
|
21534
21695
|
}
|
|
21535
|
-
const candidate =
|
|
21536
|
-
return
|
|
21696
|
+
const candidate = resolve17(dir, "bin", "failproofaid");
|
|
21697
|
+
return existsSync20(candidate) ? candidate : null;
|
|
21537
21698
|
}
|
|
21538
21699
|
function pruneOldDaemonBinaries(keep = 2) {
|
|
21539
21700
|
const removed = [];
|
|
21540
21701
|
try {
|
|
21541
21702
|
const dir = daemonBinaryDir();
|
|
21542
|
-
const entries =
|
|
21543
|
-
const full =
|
|
21544
|
-
return { full, mtime:
|
|
21703
|
+
const entries = readdirSync14(dir).filter((f) => f.startsWith("failproofaid-") && !f.endsWith(".tmp")).map((f) => {
|
|
21704
|
+
const full = resolve17(dir, f);
|
|
21705
|
+
return { full, mtime: statSync16(full).mtimeMs };
|
|
21545
21706
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
21546
21707
|
for (const stale of entries.slice(keep)) {
|
|
21547
21708
|
try {
|
|
@@ -21611,7 +21772,7 @@ function digestFor2(manifest, assetName) {
|
|
|
21611
21772
|
}
|
|
21612
21773
|
async function downloadFailproofaidBinary(key) {
|
|
21613
21774
|
const target = installedBinaryPath();
|
|
21614
|
-
if (
|
|
21775
|
+
if (existsSync20(target))
|
|
21615
21776
|
return { path: target };
|
|
21616
21777
|
if (process.env.FAILPROOFAI_NO_DOWNLOAD) {
|
|
21617
21778
|
return { error: "daemon downloads are disabled (FAILPROOFAI_NO_DOWNLOAD)" };
|
|
@@ -21645,10 +21806,10 @@ var init_daemon_download = __esm(() => {
|
|
|
21645
21806
|
|
|
21646
21807
|
// src/hooks/daemon-client.ts
|
|
21647
21808
|
import { createConnection as createConnection2 } from "node:net";
|
|
21648
|
-
import { existsSync as
|
|
21809
|
+
import { existsSync as existsSync21 } from "node:fs";
|
|
21649
21810
|
function daemonSocketPresent() {
|
|
21650
21811
|
try {
|
|
21651
|
-
return
|
|
21812
|
+
return existsSync21(socketPath2());
|
|
21652
21813
|
} catch {
|
|
21653
21814
|
return false;
|
|
21654
21815
|
}
|
|
@@ -21774,7 +21935,7 @@ var init_daemon_client2 = __esm(() => {
|
|
|
21774
21935
|
|
|
21775
21936
|
// src/hooks/daemon-service.ts
|
|
21776
21937
|
import {
|
|
21777
|
-
existsSync as
|
|
21938
|
+
existsSync as existsSync22,
|
|
21778
21939
|
mkdirSync as mkdirSync11,
|
|
21779
21940
|
mkdtempSync,
|
|
21780
21941
|
readFileSync as readFileSync17,
|
|
@@ -21782,8 +21943,8 @@ import {
|
|
|
21782
21943
|
unlinkSync as unlinkSync3,
|
|
21783
21944
|
rmSync as rmSync6
|
|
21784
21945
|
} from "node:fs";
|
|
21785
|
-
import { homedir as
|
|
21786
|
-
import { resolve as
|
|
21946
|
+
import { homedir as homedir22, tmpdir as tmpdir2, userInfo } from "node:os";
|
|
21947
|
+
import { resolve as resolve18 } from "node:path";
|
|
21787
21948
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
21788
21949
|
function setDaemonConfigured(value, installedVersion) {
|
|
21789
21950
|
try {
|
|
@@ -21805,13 +21966,13 @@ function resolveFailproofaidBinaryPath() {
|
|
|
21805
21966
|
if (process.env.FAILPROOFAI_DAEMON_BINARY)
|
|
21806
21967
|
return process.env.FAILPROOFAI_DAEMON_BINARY;
|
|
21807
21968
|
const downloaded = installedBinaryPath();
|
|
21808
|
-
if (
|
|
21969
|
+
if (existsSync22(downloaded))
|
|
21809
21970
|
return downloaded;
|
|
21810
21971
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
21811
21972
|
if (packageRoot) {
|
|
21812
21973
|
for (const profile of ["release", "debug"]) {
|
|
21813
|
-
const candidate =
|
|
21814
|
-
if (
|
|
21974
|
+
const candidate = resolve18(packageRoot, "target", profile, "failproofaid");
|
|
21975
|
+
if (existsSync22(candidate))
|
|
21815
21976
|
return candidate;
|
|
21816
21977
|
}
|
|
21817
21978
|
}
|
|
@@ -21841,8 +22002,8 @@ function resolveWorkerCommand() {
|
|
|
21841
22002
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
21842
22003
|
if (!packageRoot)
|
|
21843
22004
|
return null;
|
|
21844
|
-
const workerScript =
|
|
21845
|
-
if (!
|
|
22005
|
+
const workerScript = resolve18(packageRoot, "dist", "worker.mjs");
|
|
22006
|
+
if (!existsSync22(workerScript))
|
|
21846
22007
|
return null;
|
|
21847
22008
|
return `${shellQuote(process.execPath)} ${shellQuote(workerScript)}`;
|
|
21848
22009
|
}
|
|
@@ -21852,8 +22013,8 @@ function resolveCliCommand() {
|
|
|
21852
22013
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
21853
22014
|
if (!packageRoot)
|
|
21854
22015
|
return null;
|
|
21855
|
-
const cliScript =
|
|
21856
|
-
if (!
|
|
22016
|
+
const cliScript = resolve18(packageRoot, "dist", "cli.mjs");
|
|
22017
|
+
if (!existsSync22(cliScript))
|
|
21857
22018
|
return null;
|
|
21858
22019
|
return `${shellQuote(process.execPath)} ${shellQuote(cliScript)}`;
|
|
21859
22020
|
}
|
|
@@ -21866,8 +22027,8 @@ function workerScriptPath() {
|
|
|
21866
22027
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
21867
22028
|
if (!packageRoot)
|
|
21868
22029
|
return null;
|
|
21869
|
-
const workerScript =
|
|
21870
|
-
return
|
|
22030
|
+
const workerScript = resolve18(packageRoot, "dist", "worker.mjs");
|
|
22031
|
+
return existsSync22(workerScript) ? workerScript : null;
|
|
21871
22032
|
}
|
|
21872
22033
|
function assertUnitSafe(value, field) {
|
|
21873
22034
|
if (UNIT_UNSAFE_RE.test(value)) {
|
|
@@ -21893,10 +22054,10 @@ function systemdUnitDir() {
|
|
|
21893
22054
|
return process.env.FAILPROOFAI_SYSTEMD_DIR || "/etc/systemd/system";
|
|
21894
22055
|
}
|
|
21895
22056
|
function systemdUnitPath(user = serviceUser()) {
|
|
21896
|
-
return
|
|
22057
|
+
return resolve18(systemdUnitDir(), systemdUnitName(user));
|
|
21897
22058
|
}
|
|
21898
22059
|
function legacySystemdUserUnitPath() {
|
|
21899
|
-
return
|
|
22060
|
+
return resolve18(homedir22(), ".config", "systemd", "user", "failproofaid.service");
|
|
21900
22061
|
}
|
|
21901
22062
|
function launchdLabel(user = serviceUser()) {
|
|
21902
22063
|
return `ai.failproof.failproofaid.${user}`;
|
|
@@ -21905,7 +22066,7 @@ function launchdPlistPath(user = serviceUser()) {
|
|
|
21905
22066
|
return `/Library/LaunchDaemons/${launchdLabel(user)}.plist`;
|
|
21906
22067
|
}
|
|
21907
22068
|
function legacyLaunchAgentPlistPath() {
|
|
21908
|
-
return
|
|
22069
|
+
return resolve18(homedir22(), "Library", "LaunchAgents", "ai.failproof.failproofaid.plist");
|
|
21909
22070
|
}
|
|
21910
22071
|
function legacySharedLaunchDaemonPath() {
|
|
21911
22072
|
return "/Library/LaunchDaemons/ai.failproof.failproofaid.plist";
|
|
@@ -21953,8 +22114,8 @@ function runPrivileged(command, args) {
|
|
|
21953
22114
|
execFileSync2(cmd, argv, { stdio: "ignore", timeout: SERVICE_CMD_TIMEOUT_MS });
|
|
21954
22115
|
}
|
|
21955
22116
|
function writePrivilegedFile(destination, contents, mode = "0644") {
|
|
21956
|
-
const stagingDir = mkdtempSync(
|
|
21957
|
-
const staging =
|
|
22117
|
+
const stagingDir = mkdtempSync(resolve18(tmpdir2(), "failproofaid-stage-"));
|
|
22118
|
+
const staging = resolve18(stagingDir, "service-definition");
|
|
21958
22119
|
try {
|
|
21959
22120
|
writeFileSync9(staging, contents, "utf8");
|
|
21960
22121
|
runPrivileged("install", ["-m", mode, staging, destination]);
|
|
@@ -21966,7 +22127,7 @@ function removeLegacyUserService() {
|
|
|
21966
22127
|
try {
|
|
21967
22128
|
if (process.platform === "linux") {
|
|
21968
22129
|
const legacy = legacySystemdUserUnitPath();
|
|
21969
|
-
if (!
|
|
22130
|
+
if (!existsSync22(legacy))
|
|
21970
22131
|
return;
|
|
21971
22132
|
try {
|
|
21972
22133
|
execFileSync2("systemctl", ["--user", "disable", "--now", "failproofaid.service"], {
|
|
@@ -21983,7 +22144,7 @@ function removeLegacyUserService() {
|
|
|
21983
22144
|
} catch {}
|
|
21984
22145
|
} else {
|
|
21985
22146
|
const legacyAgent = legacyLaunchAgentPlistPath();
|
|
21986
|
-
if (
|
|
22147
|
+
if (existsSync22(legacyAgent)) {
|
|
21987
22148
|
try {
|
|
21988
22149
|
execFileSync2("launchctl", ["unload", "-w", legacyAgent], {
|
|
21989
22150
|
stdio: "ignore",
|
|
@@ -21993,7 +22154,7 @@ function removeLegacyUserService() {
|
|
|
21993
22154
|
unlinkSync3(legacyAgent);
|
|
21994
22155
|
}
|
|
21995
22156
|
const legacyDaemon = legacySharedLaunchDaemonPath();
|
|
21996
|
-
if (
|
|
22157
|
+
if (existsSync22(legacyDaemon)) {
|
|
21997
22158
|
try {
|
|
21998
22159
|
runPrivileged("launchctl", ["unload", "-w", legacyDaemon]);
|
|
21999
22160
|
} catch {}
|
|
@@ -22009,8 +22170,8 @@ function systemdUnitContents(binaryPath, workerCmd, cliCmd = null) {
|
|
|
22009
22170
|
`).join("");
|
|
22010
22171
|
const user = assertUnitSafe(serviceUser(), "User");
|
|
22011
22172
|
assertUnitSafe(binaryPath, "ExecStart");
|
|
22012
|
-
assertUnitSafe(
|
|
22013
|
-
const conditionPaths = [binaryPath, workerScriptPath()].filter((p) => typeof p === "string" &&
|
|
22173
|
+
assertUnitSafe(homedir22(), "HOME");
|
|
22174
|
+
const conditionPaths = [binaryPath, workerScriptPath()].filter((p) => typeof p === "string" && existsSync22(p));
|
|
22014
22175
|
const conditionLines = conditionPaths.map((p) => `ConditionPathExists=${assertUnitSafe(p, "ConditionPathExists")}
|
|
22015
22176
|
`).join("");
|
|
22016
22177
|
return `[Unit]
|
|
@@ -22023,7 +22184,7 @@ User=${user}
|
|
|
22023
22184
|
# Set explicitly rather than relying on systemd deriving it from User=:
|
|
22024
22185
|
# failproofaid stores per-user state and refuses to start without HOME, so this
|
|
22025
22186
|
# required variable is not left to a version-dependent default.
|
|
22026
|
-
Environment="HOME=${
|
|
22187
|
+
Environment="HOME=${homedir22()}"
|
|
22027
22188
|
${envLines}ExecStart=${binaryPath}
|
|
22028
22189
|
Restart=on-failure
|
|
22029
22190
|
RestartSec=2
|
|
@@ -22071,9 +22232,9 @@ ${env.map(([key, value]) => ` <key>${key}</key>
|
|
|
22071
22232
|
<key>UserName</key>
|
|
22072
22233
|
<string>${escapeXml(serviceUser())}</string>
|
|
22073
22234
|
${envBlock} <key>StandardOutPath</key>
|
|
22074
|
-
<string>${escapeXml(
|
|
22235
|
+
<string>${escapeXml(resolve18(logDir, "failproofaid.log"))}</string>
|
|
22075
22236
|
<key>StandardErrorPath</key>
|
|
22076
|
-
<string>${escapeXml(
|
|
22237
|
+
<string>${escapeXml(resolve18(logDir, "failproofaid.err.log"))}</string>
|
|
22077
22238
|
</dict>
|
|
22078
22239
|
</plist>
|
|
22079
22240
|
`;
|
|
@@ -22205,7 +22366,7 @@ function readInstalledServiceDefinition() {
|
|
|
22205
22366
|
if (!isDaemonSupportedPlatform())
|
|
22206
22367
|
return null;
|
|
22207
22368
|
const path = daemonServiceFilePath();
|
|
22208
|
-
if (!path || !
|
|
22369
|
+
if (!path || !existsSync22(path))
|
|
22209
22370
|
return null;
|
|
22210
22371
|
try {
|
|
22211
22372
|
return readFileSync17(path, "utf8");
|
|
@@ -22341,7 +22502,7 @@ async function uninstallDaemonService() {
|
|
|
22341
22502
|
try {
|
|
22342
22503
|
if (process.platform === "linux") {
|
|
22343
22504
|
const unitPath = systemdUnitPath();
|
|
22344
|
-
if (!
|
|
22505
|
+
if (!existsSync22(unitPath))
|
|
22345
22506
|
return;
|
|
22346
22507
|
try {
|
|
22347
22508
|
runPrivileged("systemctl", ["disable", "--now", systemdUnitName()]);
|
|
@@ -22352,7 +22513,7 @@ async function uninstallDaemonService() {
|
|
|
22352
22513
|
} catch {}
|
|
22353
22514
|
} else {
|
|
22354
22515
|
const plistPath = launchdPlistPath();
|
|
22355
|
-
if (!
|
|
22516
|
+
if (!existsSync22(plistPath))
|
|
22356
22517
|
return;
|
|
22357
22518
|
try {
|
|
22358
22519
|
runPrivileged("launchctl", ["unload", "-w", plistPath]);
|
|
@@ -22369,7 +22530,7 @@ function daemonVersionSkew() {
|
|
|
22369
22530
|
const recorded = readVersionFile()?.daemon;
|
|
22370
22531
|
if (!recorded)
|
|
22371
22532
|
return null;
|
|
22372
|
-
if (!
|
|
22533
|
+
if (!existsSync22(installedBinaryPath(recorded)))
|
|
22373
22534
|
return null;
|
|
22374
22535
|
return recorded === version2 ? null : { installed: recorded, expected: version2 };
|
|
22375
22536
|
}
|
|
@@ -22387,7 +22548,7 @@ function daemonServiceStatus() {
|
|
|
22387
22548
|
if (!isDaemonSupportedPlatform())
|
|
22388
22549
|
return "unsupported-platform";
|
|
22389
22550
|
if (process.platform === "linux") {
|
|
22390
|
-
if (!
|
|
22551
|
+
if (!existsSync22(systemdUnitPath()))
|
|
22391
22552
|
return "not-installed";
|
|
22392
22553
|
try {
|
|
22393
22554
|
const out = execFileSync2("systemctl", ["is-active", systemdUnitName()], {
|
|
@@ -22400,7 +22561,7 @@ function daemonServiceStatus() {
|
|
|
22400
22561
|
}
|
|
22401
22562
|
}
|
|
22402
22563
|
const plistPath = launchdPlistPath();
|
|
22403
|
-
if (!
|
|
22564
|
+
if (!existsSync22(plistPath))
|
|
22404
22565
|
return "not-installed";
|
|
22405
22566
|
try {
|
|
22406
22567
|
const root = typeof process.getuid === "function" && process.getuid() === 0;
|
|
@@ -22432,26 +22593,26 @@ var init_daemon_service = __esm(() => {
|
|
|
22432
22593
|
// src/hooks/fp-reset.ts
|
|
22433
22594
|
import {
|
|
22434
22595
|
copyFileSync,
|
|
22435
|
-
existsSync as
|
|
22596
|
+
existsSync as existsSync23,
|
|
22436
22597
|
mkdirSync as mkdirSync12,
|
|
22437
22598
|
readFileSync as readFileSync18,
|
|
22438
|
-
readdirSync as
|
|
22599
|
+
readdirSync as readdirSync15,
|
|
22439
22600
|
renameSync as renameSync6,
|
|
22440
22601
|
rmSync as rmSync7,
|
|
22441
22602
|
rmdirSync,
|
|
22442
|
-
statSync as
|
|
22603
|
+
statSync as statSync17,
|
|
22443
22604
|
writeFileSync as writeFileSync10
|
|
22444
22605
|
} from "node:fs";
|
|
22445
|
-
import { dirname as
|
|
22606
|
+
import { dirname as dirname11, isAbsolute as isAbsolute3, relative as relative4, resolve as resolve19 } from "node:path";
|
|
22446
22607
|
function migrateConventionPolicies() {
|
|
22447
22608
|
const from = legacy.customPoliciesDir();
|
|
22448
|
-
if (!
|
|
22609
|
+
if (!existsSync23(from))
|
|
22449
22610
|
return [];
|
|
22450
22611
|
const moved = [];
|
|
22451
22612
|
const mergeInto = (dir, dest, prefix) => {
|
|
22452
22613
|
let entries;
|
|
22453
22614
|
try {
|
|
22454
|
-
entries =
|
|
22615
|
+
entries = readdirSync15(dir, { withFileTypes: true });
|
|
22455
22616
|
} catch {
|
|
22456
22617
|
return;
|
|
22457
22618
|
}
|
|
@@ -22463,17 +22624,17 @@ function migrateConventionPolicies() {
|
|
|
22463
22624
|
return;
|
|
22464
22625
|
}
|
|
22465
22626
|
for (const entry of entries) {
|
|
22466
|
-
const source =
|
|
22467
|
-
const target =
|
|
22627
|
+
const source = resolve19(dir, entry.name);
|
|
22628
|
+
const target = resolve19(dest, entry.name);
|
|
22468
22629
|
const name = `${prefix}${entry.name}`;
|
|
22469
|
-
if (!
|
|
22630
|
+
if (!existsSync23(target)) {
|
|
22470
22631
|
try {
|
|
22471
22632
|
renameSync6(source, target);
|
|
22472
22633
|
moved.push(name);
|
|
22473
22634
|
} catch {}
|
|
22474
22635
|
continue;
|
|
22475
22636
|
}
|
|
22476
|
-
if (entry.isDirectory() &&
|
|
22637
|
+
if (entry.isDirectory() && statSync17(target).isDirectory()) {
|
|
22477
22638
|
mergeInto(source, target, `${name}/`);
|
|
22478
22639
|
try {
|
|
22479
22640
|
rmdirSync(source);
|
|
@@ -22493,23 +22654,23 @@ function migrateLegacySpool() {
|
|
|
22493
22654
|
[legacy.spoolDir(), spoolDir()],
|
|
22494
22655
|
[legacy.failedDir(), failedDir()]
|
|
22495
22656
|
]) {
|
|
22496
|
-
if (!
|
|
22657
|
+
if (!existsSync23(from))
|
|
22497
22658
|
continue;
|
|
22498
22659
|
try {
|
|
22499
22660
|
mkdirSync12(to, { recursive: true });
|
|
22500
|
-
for (const entry of
|
|
22661
|
+
for (const entry of readdirSync15(from, { withFileTypes: true })) {
|
|
22501
22662
|
if (!entry.isFile())
|
|
22502
22663
|
continue;
|
|
22503
22664
|
let name = entry.name;
|
|
22504
22665
|
let n = 0;
|
|
22505
|
-
while (
|
|
22666
|
+
while (existsSync23(resolve19(to, name)))
|
|
22506
22667
|
name = `legacy-${n++}-${entry.name}`;
|
|
22507
22668
|
try {
|
|
22508
|
-
renameSync6(
|
|
22669
|
+
renameSync6(resolve19(from, entry.name), resolve19(to, name));
|
|
22509
22670
|
moved.push(name);
|
|
22510
22671
|
} catch {
|
|
22511
22672
|
try {
|
|
22512
|
-
copyFileSync(
|
|
22673
|
+
copyFileSync(resolve19(from, entry.name), resolve19(to, name));
|
|
22513
22674
|
moved.push(name);
|
|
22514
22675
|
} catch {}
|
|
22515
22676
|
}
|
|
@@ -22520,11 +22681,11 @@ function migrateLegacySpool() {
|
|
|
22520
22681
|
}
|
|
22521
22682
|
function migrateHookActivity() {
|
|
22522
22683
|
const from = legacy.hookActivityDir();
|
|
22523
|
-
if (!
|
|
22684
|
+
if (!existsSync23(from))
|
|
22524
22685
|
return [];
|
|
22525
22686
|
const moved = [];
|
|
22526
22687
|
try {
|
|
22527
|
-
const entries =
|
|
22688
|
+
const entries = readdirSync15(from, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl"));
|
|
22528
22689
|
if (entries.length === 0)
|
|
22529
22690
|
return [];
|
|
22530
22691
|
const to = hookActivityDir();
|
|
@@ -22532,12 +22693,12 @@ function migrateHookActivity() {
|
|
|
22532
22693
|
const stamp = Date.now();
|
|
22533
22694
|
let seq = 0;
|
|
22534
22695
|
for (const entry of entries) {
|
|
22535
|
-
const source =
|
|
22696
|
+
const source = resolve19(from, entry.name);
|
|
22536
22697
|
let name = entry.name === "current.jsonl" ? `page-${stamp}-${seq++}.jsonl` : entry.name;
|
|
22537
|
-
let target =
|
|
22538
|
-
while (
|
|
22698
|
+
let target = resolve19(to, name);
|
|
22699
|
+
while (existsSync23(target)) {
|
|
22539
22700
|
name = `page-${stamp}-${seq++}.jsonl`;
|
|
22540
|
-
target =
|
|
22701
|
+
target = resolve19(to, name);
|
|
22541
22702
|
}
|
|
22542
22703
|
try {
|
|
22543
22704
|
renameSync6(source, target);
|
|
@@ -22585,8 +22746,8 @@ function retirePolicyConfigKeys() {
|
|
|
22585
22746
|
return [...removed];
|
|
22586
22747
|
}
|
|
22587
22748
|
function readCarriedPolicyConfig() {
|
|
22588
|
-
const from =
|
|
22589
|
-
if (!
|
|
22749
|
+
const from = resolve19(legacy.localPoliciesDir(), "policies-config.json");
|
|
22750
|
+
if (!existsSync23(from))
|
|
22590
22751
|
return null;
|
|
22591
22752
|
let parsed;
|
|
22592
22753
|
try {
|
|
@@ -22615,11 +22776,11 @@ function rewriteCarriedCustomPaths(carried) {
|
|
|
22615
22776
|
const repoint = (value) => {
|
|
22616
22777
|
if (typeof value !== "string" || value === "")
|
|
22617
22778
|
return value;
|
|
22618
|
-
const abs =
|
|
22779
|
+
const abs = resolve19(value);
|
|
22619
22780
|
const rel = relative4(fromDir, abs);
|
|
22620
22781
|
if (rel === "" || rel.startsWith("..") || isAbsolute3(rel))
|
|
22621
22782
|
return value;
|
|
22622
|
-
return
|
|
22783
|
+
return resolve19(toDir, rel);
|
|
22623
22784
|
};
|
|
22624
22785
|
if (Array.isArray(carried.customPoliciesPaths)) {
|
|
22625
22786
|
carried.customPoliciesPaths = carried.customPoliciesPaths.map(repoint);
|
|
@@ -22640,7 +22801,7 @@ function writeCarriedPolicyConfig(carried) {
|
|
|
22640
22801
|
}
|
|
22641
22802
|
} catch {}
|
|
22642
22803
|
try {
|
|
22643
|
-
mkdirSync12(
|
|
22804
|
+
mkdirSync12(dirname11(to), { recursive: true });
|
|
22644
22805
|
writeFileSync10(to, JSON.stringify({ ...existing, ...carried }, null, 2) + `
|
|
22645
22806
|
`, "utf8");
|
|
22646
22807
|
} catch {
|
|
@@ -22650,7 +22811,7 @@ function writeCarriedPolicyConfig(carried) {
|
|
|
22650
22811
|
}
|
|
22651
22812
|
function readCarriedTelemetryOptOut() {
|
|
22652
22813
|
const from = legacy.configToml();
|
|
22653
|
-
if (!
|
|
22814
|
+
if (!existsSync23(from))
|
|
22654
22815
|
return false;
|
|
22655
22816
|
try {
|
|
22656
22817
|
const text = readFileSync18(from, "utf8");
|
|
@@ -22705,7 +22866,7 @@ function parseLegacyToml(text) {
|
|
|
22705
22866
|
}
|
|
22706
22867
|
function readCarriedLegacyConfig() {
|
|
22707
22868
|
const from = legacy.configToml();
|
|
22708
|
-
if (!
|
|
22869
|
+
if (!existsSync23(from))
|
|
22709
22870
|
return null;
|
|
22710
22871
|
try {
|
|
22711
22872
|
return projectConfig(parseLegacyToml(readFileSync18(from, "utf8")));
|
|
@@ -22715,7 +22876,7 @@ function readCarriedLegacyConfig() {
|
|
|
22715
22876
|
}
|
|
22716
22877
|
function readCarriedLegacyCredentials() {
|
|
22717
22878
|
const toml = legacy.credentialsToml();
|
|
22718
|
-
if (
|
|
22879
|
+
if (existsSync23(toml)) {
|
|
22719
22880
|
try {
|
|
22720
22881
|
const creds = projectCredentials(parseLegacyToml(readFileSync18(toml, "utf8")));
|
|
22721
22882
|
if (Object.keys(creds).length > 0)
|
|
@@ -22758,7 +22919,7 @@ function resetHome(from, to = LAYOUT_VERSION) {
|
|
|
22758
22919
|
const spooled = migrateLegacySpool();
|
|
22759
22920
|
const removed = [];
|
|
22760
22921
|
for (const path of resettablePaths()) {
|
|
22761
|
-
if (!
|
|
22922
|
+
if (!existsSync23(path))
|
|
22762
22923
|
continue;
|
|
22763
22924
|
try {
|
|
22764
22925
|
rmSync7(path, { recursive: true, force: true });
|
|
@@ -22783,7 +22944,7 @@ function layoutWarningForHook() {
|
|
|
22783
22944
|
if (state.kind === "future") {
|
|
22784
22945
|
return `[failproofai] this directory was written by a newer version (layout ${state.found} vs ${LAYOUT_VERSION}) — policies are NOT being enforced. ` + `Upgrade failproofai.`;
|
|
22785
22946
|
}
|
|
22786
|
-
if (
|
|
22947
|
+
if (existsSync23(globalPolicyConfigFile()))
|
|
22787
22948
|
return null;
|
|
22788
22949
|
return `[failproofai] setup predates this version — global policies are NOT being enforced. ` + `Run \`failproofai config\` to re-create it.`;
|
|
22789
22950
|
}
|
|
@@ -23831,17 +23992,17 @@ var init_collector_config = __esm(() => {
|
|
|
23831
23992
|
});
|
|
23832
23993
|
|
|
23833
23994
|
// src/hooks/flush-cli.ts
|
|
23834
|
-
import { existsSync as
|
|
23835
|
-
import { dirname as
|
|
23995
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync13, writeFileSync as writeFileSync11, readdirSync as readdirSync16 } from "node:fs";
|
|
23996
|
+
import { dirname as dirname12, join as join31 } from "node:path";
|
|
23836
23997
|
function flushRequestPath(home) {
|
|
23837
|
-
return
|
|
23998
|
+
return join31(failproofaiHome(home), "state", "flush-request.json");
|
|
23838
23999
|
}
|
|
23839
24000
|
function spoolDirs(home) {
|
|
23840
24001
|
const root = spoolDir(home);
|
|
23841
|
-
if (!
|
|
24002
|
+
if (!existsSync24(root))
|
|
23842
24003
|
return [];
|
|
23843
24004
|
try {
|
|
23844
|
-
return
|
|
24005
|
+
return readdirSync16(root, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== "failed").map((e) => join31(root, e.name));
|
|
23845
24006
|
} catch {
|
|
23846
24007
|
return [];
|
|
23847
24008
|
}
|
|
@@ -23850,7 +24011,7 @@ function pendingBatches(home) {
|
|
|
23850
24011
|
let n = 0;
|
|
23851
24012
|
for (const dir of spoolDirs(home)) {
|
|
23852
24013
|
try {
|
|
23853
|
-
n +=
|
|
24014
|
+
n += readdirSync16(dir).filter((f) => f.endsWith(".jsonl")).length;
|
|
23854
24015
|
} catch {}
|
|
23855
24016
|
}
|
|
23856
24017
|
return n;
|
|
@@ -23907,7 +24068,7 @@ async function runFlushCommand(opts = {}) {
|
|
|
23907
24068
|
return { exitCode: 0, pending: 0, lines: ["Nothing spooled — everything already delivered."] };
|
|
23908
24069
|
}
|
|
23909
24070
|
const path = flushRequestPath(home);
|
|
23910
|
-
mkdirSync13(
|
|
24071
|
+
mkdirSync13(dirname12(path), { recursive: true });
|
|
23911
24072
|
writeFileSync11(path, `${JSON.stringify({ requestedAtMs: Date.now() }, null, 2)}
|
|
23912
24073
|
`, {
|
|
23913
24074
|
mode: 384
|
|
@@ -23942,14 +24103,14 @@ var init_flush_cli = __esm(() => {
|
|
|
23942
24103
|
import {
|
|
23943
24104
|
chmodSync as chmodSync4,
|
|
23944
24105
|
copyFileSync as copyFileSync2,
|
|
23945
|
-
existsSync as
|
|
24106
|
+
existsSync as existsSync25,
|
|
23946
24107
|
mkdirSync as mkdirSync14,
|
|
23947
24108
|
readFileSync as readFileSync19,
|
|
23948
24109
|
renameSync as renameSync7,
|
|
23949
24110
|
rmSync as rmSync8,
|
|
23950
24111
|
writeFileSync as writeFileSync12
|
|
23951
24112
|
} from "node:fs";
|
|
23952
|
-
import { basename as
|
|
24113
|
+
import { basename as basename5, dirname as dirname13, join as join32, resolve as resolve20 } from "node:path";
|
|
23953
24114
|
function migrateToLayout4() {
|
|
23954
24115
|
const moves = [
|
|
23955
24116
|
{ from: legacy.authJson(), to: auditSessionFile() },
|
|
@@ -23958,20 +24119,20 @@ function migrateToLayout4() {
|
|
|
23958
24119
|
];
|
|
23959
24120
|
const authDirOverride = process.env.FAILPROOFAI_AUTH_DIR;
|
|
23960
24121
|
if (authDirOverride) {
|
|
23961
|
-
moves.push({ from:
|
|
23962
|
-
from:
|
|
23963
|
-
to:
|
|
24122
|
+
moves.push({ from: join32(authDirOverride, "auth.json"), to: join32(authDirOverride, "session.json") }, {
|
|
24123
|
+
from: join32(authDirOverride, "next-audit.json"),
|
|
24124
|
+
to: join32(authDirOverride, "reminder.json")
|
|
23964
24125
|
});
|
|
23965
24126
|
}
|
|
23966
24127
|
const migrated = [];
|
|
23967
24128
|
for (const { from, to } of moves) {
|
|
23968
|
-
if (!
|
|
24129
|
+
if (!existsSync25(from))
|
|
23969
24130
|
continue;
|
|
23970
|
-
if (
|
|
24131
|
+
if (existsSync25(to)) {
|
|
23971
24132
|
rmSync8(from, { force: true });
|
|
23972
24133
|
continue;
|
|
23973
24134
|
}
|
|
23974
|
-
mkdirSync14(
|
|
24135
|
+
mkdirSync14(dirname13(to), { recursive: true });
|
|
23975
24136
|
try {
|
|
23976
24137
|
renameSync7(from, to);
|
|
23977
24138
|
} catch {
|
|
@@ -23985,10 +24146,10 @@ function migrateToLayout4() {
|
|
|
23985
24146
|
}
|
|
23986
24147
|
rmSync8(from, { force: true });
|
|
23987
24148
|
}
|
|
23988
|
-
migrated.push(`${
|
|
24149
|
+
migrated.push(`${basename5(from)} → audit/${basename5(to)}`);
|
|
23989
24150
|
}
|
|
23990
24151
|
for (const secret of [auditSessionFile()]) {
|
|
23991
|
-
if (!
|
|
24152
|
+
if (!existsSync25(secret))
|
|
23992
24153
|
continue;
|
|
23993
24154
|
try {
|
|
23994
24155
|
chmodSync4(secret, 384);
|
|
@@ -24029,17 +24190,17 @@ function appendLedger(entry) {
|
|
|
24029
24190
|
} catch {}
|
|
24030
24191
|
}
|
|
24031
24192
|
function backupNameOf(f) {
|
|
24032
|
-
return f.as ??
|
|
24193
|
+
return f.as ?? basename5(f.at());
|
|
24033
24194
|
}
|
|
24034
24195
|
function pruneMigratedCredentials(from) {
|
|
24035
24196
|
const pruned = [];
|
|
24036
24197
|
for (let layout = from;layout < LAYOUT_VERSION; layout++) {
|
|
24037
24198
|
for (const { as, landsAt } of PRUNED_AFTER_SUCCESS) {
|
|
24038
24199
|
try {
|
|
24039
|
-
if (!
|
|
24200
|
+
if (!existsSync25(landsAt()))
|
|
24040
24201
|
continue;
|
|
24041
|
-
const copy =
|
|
24042
|
-
if (!
|
|
24202
|
+
const copy = resolve20(migrationBackupDir(layout), as);
|
|
24203
|
+
if (!existsSync25(copy))
|
|
24043
24204
|
continue;
|
|
24044
24205
|
rmSync8(copy, { force: true });
|
|
24045
24206
|
pruned.push(as);
|
|
@@ -24052,7 +24213,7 @@ function filesToBackUp() {
|
|
|
24052
24213
|
const seen = new Map;
|
|
24053
24214
|
for (const f of [...BACKED_UP, ...BACKED_UP_LEGACY]) {
|
|
24054
24215
|
const path = f.at();
|
|
24055
|
-
if (
|
|
24216
|
+
if (existsSync25(path))
|
|
24056
24217
|
seen.set(path, backupNameOf(f));
|
|
24057
24218
|
}
|
|
24058
24219
|
return [...seen].map(([path, as]) => ({ path, as }));
|
|
@@ -24068,7 +24229,7 @@ function backupBeforeMigrating(from) {
|
|
|
24068
24229
|
}
|
|
24069
24230
|
for (const { path: source, as } of filesToBackUp()) {
|
|
24070
24231
|
try {
|
|
24071
|
-
copyFileSync2(source,
|
|
24232
|
+
copyFileSync2(source, resolve20(dir, as));
|
|
24072
24233
|
saved.push(as);
|
|
24073
24234
|
} catch {}
|
|
24074
24235
|
}
|
|
@@ -24178,7 +24339,7 @@ var init_migrations = __esm(() => {
|
|
|
24178
24339
|
{ at: legacy.auditSchedule }
|
|
24179
24340
|
];
|
|
24180
24341
|
PRUNED_AFTER_SUCCESS = [
|
|
24181
|
-
{ as:
|
|
24342
|
+
{ as: basename5(legacy.authJson()), landsAt: auditSessionFile }
|
|
24182
24343
|
];
|
|
24183
24344
|
});
|
|
24184
24345
|
|
|
@@ -24359,14 +24520,14 @@ var init_fp_reset2 = __esm(() => {
|
|
|
24359
24520
|
import { createHmac, randomUUID as randomUUID2 } from "node:crypto";
|
|
24360
24521
|
import { execSync as execSync5 } from "node:child_process";
|
|
24361
24522
|
import { readFileSync as readFileSync20, writeFileSync as writeFileSync13, mkdirSync as mkdirSync15 } from "node:fs";
|
|
24362
|
-
import { homedir as
|
|
24363
|
-
import { join as
|
|
24523
|
+
import { homedir as homedir23, platform, arch, hostname, cpus } from "node:os";
|
|
24524
|
+
import { join as join33 } from "node:path";
|
|
24364
24525
|
function hashToId3(raw) {
|
|
24365
24526
|
return createHmac("sha256", NAMESPACE3).update(raw).digest("hex");
|
|
24366
24527
|
}
|
|
24367
24528
|
function getInstanceId3() {
|
|
24368
|
-
const idDir =
|
|
24369
|
-
const idFile =
|
|
24529
|
+
const idDir = join33(homedir23(), ".failproofai");
|
|
24530
|
+
const idFile = join33(idDir, "instance-id");
|
|
24370
24531
|
try {
|
|
24371
24532
|
const existing = readFileSync20(idFile, "utf-8").trim();
|
|
24372
24533
|
if (existing)
|
|
@@ -24400,7 +24561,7 @@ function getInstanceId3() {
|
|
|
24400
24561
|
try {
|
|
24401
24562
|
const sysProps = [
|
|
24402
24563
|
hostname(),
|
|
24403
|
-
|
|
24564
|
+
homedir23(),
|
|
24404
24565
|
platform(),
|
|
24405
24566
|
arch(),
|
|
24406
24567
|
cpus()[0]?.model ?? ""
|
|
@@ -24442,9 +24603,9 @@ var NAMESPACE3 = "failproofai-telemetry-v1", API_KEY3 = "phc_Ac1Ww1GqKc0z1SyrRWb
|
|
|
24442
24603
|
var init_install_telemetry = () => {};
|
|
24443
24604
|
|
|
24444
24605
|
// lib/install-check.ts
|
|
24445
|
-
import { existsSync as
|
|
24446
|
-
import { dirname as
|
|
24447
|
-
import { platform as platform2, arch as arch2, release, homedir as
|
|
24606
|
+
import { existsSync as existsSync26, readFileSync as readFileSync21, writeFileSync as writeFileSync14, mkdirSync as mkdirSync16 } from "node:fs";
|
|
24607
|
+
import { dirname as dirname14, resolve as resolve21 } from "node:path";
|
|
24608
|
+
import { platform as platform2, arch as arch2, release, homedir as homedir24, hostname as hostname2 } from "node:os";
|
|
24448
24609
|
import { createHmac as createHmac2 } from "node:crypto";
|
|
24449
24610
|
function hashToId4(raw) {
|
|
24450
24611
|
return createHmac2("sha256", NAMESPACE4).update(raw).digest("hex");
|
|
@@ -24498,7 +24659,7 @@ function compareSemver(a, b) {
|
|
|
24498
24659
|
}
|
|
24499
24660
|
function checkHooks() {
|
|
24500
24661
|
const hooksConfigPath = globalPolicyConfigFile();
|
|
24501
|
-
if (!
|
|
24662
|
+
if (!existsSync26(hooksConfigPath)) {
|
|
24502
24663
|
return { configured: false, registered: false, policyCount: 0 };
|
|
24503
24664
|
}
|
|
24504
24665
|
let config;
|
|
@@ -24511,8 +24672,8 @@ function checkHooks() {
|
|
|
24511
24672
|
return { configured: false, registered: false, policyCount: 0 };
|
|
24512
24673
|
}
|
|
24513
24674
|
const policyCount = config.enabledPolicies.length;
|
|
24514
|
-
const settingsPath =
|
|
24515
|
-
if (!
|
|
24675
|
+
const settingsPath = resolve21(homedir24(), ".claude", "settings.json");
|
|
24676
|
+
if (!existsSync26(settingsPath))
|
|
24516
24677
|
return { configured: true, registered: false, policyCount };
|
|
24517
24678
|
let settings;
|
|
24518
24679
|
try {
|
|
@@ -24540,7 +24701,7 @@ async function maybeReportInstall(version) {
|
|
|
24540
24701
|
const versionFile = lastVersionPath();
|
|
24541
24702
|
let previousVersion = null;
|
|
24542
24703
|
try {
|
|
24543
|
-
if (
|
|
24704
|
+
if (existsSync26(versionFile)) {
|
|
24544
24705
|
previousVersion = readFileSync21(versionFile, "utf8").trim() || null;
|
|
24545
24706
|
}
|
|
24546
24707
|
} catch {}
|
|
@@ -24577,7 +24738,7 @@ async function maybeReportInstall(version) {
|
|
|
24577
24738
|
enabled_policy_count: hooks.policyCount
|
|
24578
24739
|
}, { version, timeoutMs: REPORT_TIMEOUT_MS, enabled: telemetryEnabled }));
|
|
24579
24740
|
try {
|
|
24580
|
-
mkdirSync16(
|
|
24741
|
+
mkdirSync16(dirname14(versionFile), { recursive: true });
|
|
24581
24742
|
writeFileSync14(versionFile, version, "utf8");
|
|
24582
24743
|
} catch {}
|
|
24583
24744
|
await Promise.all(events.map((p) => p.catch(() => {})));
|
|
@@ -24628,8 +24789,8 @@ var init_cli_error = __esm(() => {
|
|
|
24628
24789
|
|
|
24629
24790
|
// src/hooks/manager.ts
|
|
24630
24791
|
import { execSync as execSync6 } from "node:child_process";
|
|
24631
|
-
import { existsSync as
|
|
24632
|
-
import { resolve as
|
|
24792
|
+
import { existsSync as existsSync27 } from "node:fs";
|
|
24793
|
+
import { resolve as resolve22, basename as basename6 } from "node:path";
|
|
24633
24794
|
import { platform as platform3, arch as arch3, release as release2, hostname as hostname3 } from "node:os";
|
|
24634
24795
|
function getSettingsPath(scope, cwd) {
|
|
24635
24796
|
return claudeCode.getSettingsPath(scope, cwd);
|
|
@@ -24848,9 +25009,9 @@ async function installHooksImpl(policyNames, scope = "user", cwd, includeBeta =
|
|
|
24848
25009
|
delete configToWrite.customPoliciesPath;
|
|
24849
25010
|
delete configToWrite.customPoliciesPaths;
|
|
24850
25011
|
} else if (customPoliciesPath && (typeof customPoliciesPath === "string" || customPoliciesPath.length > 0)) {
|
|
24851
|
-
const incoming = (typeof customPoliciesPath === "string" ? [customPoliciesPath] : customPoliciesPath).map((path) =>
|
|
24852
|
-
const carried = (previousConfig.customPoliciesPaths ?? (previousConfig.customPoliciesPath ? [previousConfig.customPoliciesPath] : [])).map((path) =>
|
|
24853
|
-
if (
|
|
25012
|
+
const incoming = (typeof customPoliciesPath === "string" ? [customPoliciesPath] : customPoliciesPath).map((path) => resolve22(path));
|
|
25013
|
+
const carried = (previousConfig.customPoliciesPaths ?? (previousConfig.customPoliciesPath ? [previousConfig.customPoliciesPath] : [])).map((path) => resolve22(path)).filter((path) => {
|
|
25014
|
+
if (existsSync27(path))
|
|
24854
25015
|
return true;
|
|
24855
25016
|
console.log(`Dropping custom policies path (file no longer exists): ${path}`);
|
|
24856
25017
|
return false;
|
|
@@ -25073,7 +25234,7 @@ async function removeHooks(policyNames, scope = "user", cwd, opts) {
|
|
|
25073
25234
|
const scopesToRemove = scope === "all" ? [...integration.scopes] : integration.scopes.includes(scope) ? [scope] : [];
|
|
25074
25235
|
for (const s of scopesToRemove) {
|
|
25075
25236
|
const settingsPaths = settingsPathsFor(integration, s, cwd);
|
|
25076
|
-
const existing = settingsPaths.filter((p) =>
|
|
25237
|
+
const existing = settingsPaths.filter((p) => existsSync27(p));
|
|
25077
25238
|
if (existing.length === 0) {
|
|
25078
25239
|
if (scope !== "all" && selectedClis.length === 1) {
|
|
25079
25240
|
console.log("No settings file found. Nothing to remove.");
|
|
@@ -25176,7 +25337,7 @@ var DEFAULT_FETCH_TIMEOUT_MS = 15000;
|
|
|
25176
25337
|
|
|
25177
25338
|
// src/hooks/cloud-enrollment.ts
|
|
25178
25339
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
25179
|
-
import { existsSync as
|
|
25340
|
+
import { existsSync as existsSync28, readFileSync as readFileSync22, rmSync as rmSync9 } from "node:fs";
|
|
25180
25341
|
import { hostname as hostname4 } from "node:os";
|
|
25181
25342
|
function cloudCredentialPath() {
|
|
25182
25343
|
return process.env.FAILPROOFAI_CLOUD_CREDENTIALS ?? credentialsFile();
|
|
@@ -25215,7 +25376,7 @@ function readCloudCredentials() {
|
|
|
25215
25376
|
if (!usingJsonOverride())
|
|
25216
25377
|
return readCredentials().cloud ?? null;
|
|
25217
25378
|
const path = cloudCredentialPath();
|
|
25218
|
-
if (!
|
|
25379
|
+
if (!existsSync28(path))
|
|
25219
25380
|
return null;
|
|
25220
25381
|
try {
|
|
25221
25382
|
const raw = JSON.parse(readFileSync22(path, "utf8"));
|
|
@@ -25257,7 +25418,7 @@ function resolveMachineLabel(explicit) {
|
|
|
25257
25418
|
function clearCloudCredentials() {
|
|
25258
25419
|
if (usingJsonOverride()) {
|
|
25259
25420
|
const path = cloudCredentialPath();
|
|
25260
|
-
if (!
|
|
25421
|
+
if (!existsSync28(path))
|
|
25261
25422
|
return false;
|
|
25262
25423
|
try {
|
|
25263
25424
|
rmSync9(path);
|
|
@@ -25508,37 +25669,37 @@ var init_cloud_connection = __esm(() => {
|
|
|
25508
25669
|
});
|
|
25509
25670
|
|
|
25510
25671
|
// src/hooks/setup-state.ts
|
|
25511
|
-
import { existsSync as
|
|
25512
|
-
import { dirname as
|
|
25513
|
-
import { homedir as
|
|
25514
|
-
function globalConfigPath(home =
|
|
25672
|
+
import { existsSync as existsSync29, realpathSync as realpathSync2, statSync as statSync18 } from "node:fs";
|
|
25673
|
+
import { dirname as dirname15, resolve as resolve23 } from "node:path";
|
|
25674
|
+
import { homedir as homedir25 } from "node:os";
|
|
25675
|
+
function globalConfigPath(home = homedir25()) {
|
|
25515
25676
|
return globalPolicyConfigFile(home);
|
|
25516
25677
|
}
|
|
25517
25678
|
function projectConfigPath(projectRoot) {
|
|
25518
|
-
return
|
|
25679
|
+
return resolve23(projectRoot, ".failproofai", "policies-config.json");
|
|
25519
25680
|
}
|
|
25520
25681
|
function legacyMarkerPath(home) {
|
|
25521
25682
|
return launcherMarker(home);
|
|
25522
25683
|
}
|
|
25523
25684
|
function isDir(path) {
|
|
25524
25685
|
try {
|
|
25525
|
-
return
|
|
25686
|
+
return statSync18(path).isDirectory();
|
|
25526
25687
|
} catch {
|
|
25527
25688
|
return false;
|
|
25528
25689
|
}
|
|
25529
25690
|
}
|
|
25530
|
-
function findProjectRoot(start, home =
|
|
25691
|
+
function findProjectRoot(start, home = homedir25()) {
|
|
25531
25692
|
const resolvedHome = realResolve(home);
|
|
25532
25693
|
let dir = realResolve(start);
|
|
25533
25694
|
while (dir !== resolvedHome) {
|
|
25534
|
-
if (isDir(
|
|
25695
|
+
if (isDir(resolve23(dir, ".failproofai")))
|
|
25535
25696
|
return dir;
|
|
25536
|
-
const parent =
|
|
25697
|
+
const parent = dirname15(dir);
|
|
25537
25698
|
if (parent === dir)
|
|
25538
25699
|
break;
|
|
25539
25700
|
dir = parent;
|
|
25540
25701
|
}
|
|
25541
|
-
return
|
|
25702
|
+
return resolve23(start);
|
|
25542
25703
|
}
|
|
25543
25704
|
function hasGlobalHooksInstalled() {
|
|
25544
25705
|
for (const id of INTEGRATION_TYPES) {
|
|
@@ -25550,14 +25711,14 @@ function hasGlobalHooksInstalled() {
|
|
|
25550
25711
|
return false;
|
|
25551
25712
|
}
|
|
25552
25713
|
function realResolve(path) {
|
|
25553
|
-
const lexical =
|
|
25714
|
+
const lexical = resolve23(path);
|
|
25554
25715
|
try {
|
|
25555
25716
|
return realpathSync2(lexical);
|
|
25556
25717
|
} catch {
|
|
25557
25718
|
return lexical;
|
|
25558
25719
|
}
|
|
25559
25720
|
}
|
|
25560
|
-
function detectSetupState(cwd = process.cwd(), home =
|
|
25721
|
+
function detectSetupState(cwd = process.cwd(), home = homedir25()) {
|
|
25561
25722
|
const resolvedCwd = realResolve(cwd);
|
|
25562
25723
|
const resolvedHome = realResolve(home);
|
|
25563
25724
|
const projectRoot = findProjectRoot(resolvedCwd, resolvedHome);
|
|
@@ -25565,10 +25726,10 @@ function detectSetupState(cwd = process.cwd(), home = homedir24()) {
|
|
|
25565
25726
|
cwd: resolvedCwd,
|
|
25566
25727
|
home: resolvedHome,
|
|
25567
25728
|
projectRoot,
|
|
25568
|
-
hasGlobalConfig:
|
|
25569
|
-
hasProjectConfig: projectRoot !== resolvedHome &&
|
|
25729
|
+
hasGlobalConfig: existsSync29(globalConfigPath(resolvedHome)),
|
|
25730
|
+
hasProjectConfig: projectRoot !== resolvedHome && existsSync29(projectConfigPath(projectRoot)),
|
|
25570
25731
|
hasGlobalHooks: hasGlobalHooksInstalled(),
|
|
25571
|
-
hasLegacyMarker:
|
|
25732
|
+
hasLegacyMarker: existsSync29(legacyMarkerPath(resolvedHome)),
|
|
25572
25733
|
inHomeDir: resolvedCwd === resolvedHome
|
|
25573
25734
|
};
|
|
25574
25735
|
}
|
|
@@ -25585,11 +25746,11 @@ var init_setup_state = __esm(() => {
|
|
|
25585
25746
|
});
|
|
25586
25747
|
|
|
25587
25748
|
// src/hooks/onboarding-attempt.ts
|
|
25588
|
-
import { existsSync as
|
|
25589
|
-
import { dirname as
|
|
25749
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync17, readFileSync as readFileSync23, rmSync as rmSync10, writeFileSync as writeFileSync15 } from "node:fs";
|
|
25750
|
+
import { dirname as dirname16 } from "node:path";
|
|
25590
25751
|
function readOnboardingAttempt() {
|
|
25591
25752
|
const path = onboardingAttemptFile();
|
|
25592
|
-
if (!
|
|
25753
|
+
if (!existsSync30(path))
|
|
25593
25754
|
return null;
|
|
25594
25755
|
try {
|
|
25595
25756
|
const raw = JSON.parse(readFileSync23(path, "utf8"));
|
|
@@ -25611,7 +25772,7 @@ function readOnboardingAttempt() {
|
|
|
25611
25772
|
function recordOnboardingAttempt(reason, cliVersion, daemonStatus, now = Date.now()) {
|
|
25612
25773
|
try {
|
|
25613
25774
|
const path = onboardingAttemptFile();
|
|
25614
|
-
mkdirSync17(
|
|
25775
|
+
mkdirSync17(dirname16(path), { recursive: true });
|
|
25615
25776
|
const record = {
|
|
25616
25777
|
schemaVersion: SCHEMA_VERSION3,
|
|
25617
25778
|
reason,
|
|
@@ -25667,8 +25828,8 @@ var init_onboarding_attempt = __esm(() => {
|
|
|
25667
25828
|
|
|
25668
25829
|
// src/hooks/onboarding-lock.ts
|
|
25669
25830
|
import { mkdirSync as mkdirSync18, readFileSync as readFileSync24, rmSync as rmSync11, writeFileSync as writeFileSync16 } from "node:fs";
|
|
25670
|
-
import { homedir as
|
|
25671
|
-
function onboardingLockPath(home =
|
|
25831
|
+
import { homedir as homedir26 } from "node:os";
|
|
25832
|
+
function onboardingLockPath(home = homedir26()) {
|
|
25672
25833
|
return onboardingLockFile(home);
|
|
25673
25834
|
}
|
|
25674
25835
|
function processAlive(pid) {
|
|
@@ -25691,7 +25852,7 @@ function readLock(path) {
|
|
|
25691
25852
|
return null;
|
|
25692
25853
|
}
|
|
25693
25854
|
}
|
|
25694
|
-
function acquireOnboardingLock(home =
|
|
25855
|
+
function acquireOnboardingLock(home = homedir26()) {
|
|
25695
25856
|
const path = onboardingLockPath(home);
|
|
25696
25857
|
try {
|
|
25697
25858
|
const held = readLock(path);
|
|
@@ -25722,8 +25883,8 @@ var init_onboarding_lock = __esm(() => {
|
|
|
25722
25883
|
});
|
|
25723
25884
|
|
|
25724
25885
|
// lib/claude-sessions.ts
|
|
25725
|
-
import { readdirSync as
|
|
25726
|
-
import { join as
|
|
25886
|
+
import { readdirSync as readdirSync17, statSync as statSync19, existsSync as existsSync31 } from "node:fs";
|
|
25887
|
+
import { join as join34, basename as basename7 } from "node:path";
|
|
25727
25888
|
function getClaudeProjectsRoot() {
|
|
25728
25889
|
return getClaudeProjectsPath();
|
|
25729
25890
|
}
|
|
@@ -25731,21 +25892,21 @@ function listClaudeProjects() {
|
|
|
25731
25892
|
const root = getClaudeProjectsRoot();
|
|
25732
25893
|
let entries;
|
|
25733
25894
|
try {
|
|
25734
|
-
entries =
|
|
25895
|
+
entries = readdirSync17(root, { withFileTypes: true });
|
|
25735
25896
|
} catch {
|
|
25736
25897
|
return [];
|
|
25737
25898
|
}
|
|
25738
25899
|
return entries.filter((e) => e.isDirectory()).map((e) => ({
|
|
25739
25900
|
name: e.name,
|
|
25740
25901
|
cwd: decodeFolderName(e.name),
|
|
25741
|
-
path:
|
|
25902
|
+
path: join34(root, e.name)
|
|
25742
25903
|
}));
|
|
25743
25904
|
}
|
|
25744
25905
|
function listClaudeTranscripts(project) {
|
|
25745
25906
|
const out = [];
|
|
25746
25907
|
let entries;
|
|
25747
25908
|
try {
|
|
25748
|
-
entries =
|
|
25909
|
+
entries = readdirSync17(project.path, { withFileTypes: true });
|
|
25749
25910
|
} catch {
|
|
25750
25911
|
return out;
|
|
25751
25912
|
}
|
|
@@ -25754,9 +25915,9 @@ function listClaudeTranscripts(project) {
|
|
|
25754
25915
|
const sessionId = entry.name.slice(0, -".jsonl".length);
|
|
25755
25916
|
if (!UUID_RE2.test(sessionId))
|
|
25756
25917
|
continue;
|
|
25757
|
-
const transcriptPath =
|
|
25918
|
+
const transcriptPath = join34(project.path, entry.name);
|
|
25758
25919
|
try {
|
|
25759
|
-
const s =
|
|
25920
|
+
const s = statSync19(transcriptPath);
|
|
25760
25921
|
out.push({
|
|
25761
25922
|
projectName: project.name,
|
|
25762
25923
|
cwd: project.cwd,
|
|
@@ -25768,12 +25929,12 @@ function listClaudeTranscripts(project) {
|
|
|
25768
25929
|
});
|
|
25769
25930
|
} catch {}
|
|
25770
25931
|
} else if (entry.isDirectory() && UUID_RE2.test(entry.name)) {
|
|
25771
|
-
const subDir =
|
|
25772
|
-
if (!
|
|
25932
|
+
const subDir = join34(project.path, entry.name, "subagents");
|
|
25933
|
+
if (!existsSync31(subDir))
|
|
25773
25934
|
continue;
|
|
25774
25935
|
let subEntries;
|
|
25775
25936
|
try {
|
|
25776
|
-
subEntries =
|
|
25937
|
+
subEntries = readdirSync17(subDir, { withFileTypes: true });
|
|
25777
25938
|
} catch {
|
|
25778
25939
|
continue;
|
|
25779
25940
|
}
|
|
@@ -25781,9 +25942,9 @@ function listClaudeTranscripts(project) {
|
|
|
25781
25942
|
if (!sub.isFile() || !sub.name.endsWith(".jsonl"))
|
|
25782
25943
|
continue;
|
|
25783
25944
|
const agentId = sub.name.slice(0, -".jsonl".length);
|
|
25784
|
-
const transcriptPath =
|
|
25945
|
+
const transcriptPath = join34(subDir, sub.name);
|
|
25785
25946
|
try {
|
|
25786
|
-
const s =
|
|
25947
|
+
const s = statSync19(transcriptPath);
|
|
25787
25948
|
out.push({
|
|
25788
25949
|
projectName: project.name,
|
|
25789
25950
|
cwd: project.cwd,
|
|
@@ -25999,7 +26160,7 @@ var init_claude = __esm(() => {
|
|
|
25999
26160
|
});
|
|
26000
26161
|
|
|
26001
26162
|
// src/audit/cli-adapters/codex.ts
|
|
26002
|
-
import { statSync as
|
|
26163
|
+
import { statSync as statSync20 } from "node:fs";
|
|
26003
26164
|
async function listCodexTranscriptMetadata(opts = {}) {
|
|
26004
26165
|
const projectFilter = opts.projects ? new Set(opts.projects) : null;
|
|
26005
26166
|
const sinceMs = opts.sinceMs ?? 0;
|
|
@@ -26016,7 +26177,7 @@ async function listCodexTranscriptMetadata(opts = {}) {
|
|
|
26016
26177
|
continue;
|
|
26017
26178
|
let sizeBytes = 0;
|
|
26018
26179
|
try {
|
|
26019
|
-
sizeBytes =
|
|
26180
|
+
sizeBytes = statSync20(s.path).size;
|
|
26020
26181
|
} catch {}
|
|
26021
26182
|
if (!s.sessionId)
|
|
26022
26183
|
continue;
|
|
@@ -26050,7 +26211,7 @@ var init_codex = __esm(() => {
|
|
|
26050
26211
|
});
|
|
26051
26212
|
|
|
26052
26213
|
// src/audit/cli-adapters/copilot.ts
|
|
26053
|
-
import { statSync as
|
|
26214
|
+
import { statSync as statSync21 } from "node:fs";
|
|
26054
26215
|
async function listCopilotTranscriptMetadata(opts = {}) {
|
|
26055
26216
|
const projectFilter = opts.projects ? new Set(opts.projects) : null;
|
|
26056
26217
|
const sinceMs = opts.sinceMs ?? 0;
|
|
@@ -26067,7 +26228,7 @@ async function listCopilotTranscriptMetadata(opts = {}) {
|
|
|
26067
26228
|
continue;
|
|
26068
26229
|
let sizeBytes = 0;
|
|
26069
26230
|
try {
|
|
26070
|
-
sizeBytes =
|
|
26231
|
+
sizeBytes = statSync21(s.path).size;
|
|
26071
26232
|
} catch {}
|
|
26072
26233
|
if (!s.sessionId)
|
|
26073
26234
|
continue;
|
|
@@ -26101,7 +26262,7 @@ var init_copilot = __esm(() => {
|
|
|
26101
26262
|
});
|
|
26102
26263
|
|
|
26103
26264
|
// src/audit/cli-adapters/cursor.ts
|
|
26104
|
-
import { statSync as
|
|
26265
|
+
import { statSync as statSync22 } from "node:fs";
|
|
26105
26266
|
async function listCursorTranscriptMetadata(opts = {}) {
|
|
26106
26267
|
const projectFilter = opts.projects ? new Set(opts.projects) : null;
|
|
26107
26268
|
const sinceMs = opts.sinceMs ?? 0;
|
|
@@ -26118,7 +26279,7 @@ async function listCursorTranscriptMetadata(opts = {}) {
|
|
|
26118
26279
|
continue;
|
|
26119
26280
|
let sizeBytes = 0;
|
|
26120
26281
|
try {
|
|
26121
|
-
sizeBytes =
|
|
26282
|
+
sizeBytes = statSync22(s.path).size;
|
|
26122
26283
|
} catch {}
|
|
26123
26284
|
if (!s.sessionId)
|
|
26124
26285
|
continue;
|
|
@@ -26359,7 +26520,7 @@ var init_opencode = __esm(() => {
|
|
|
26359
26520
|
});
|
|
26360
26521
|
|
|
26361
26522
|
// src/audit/cli-adapters/pi.ts
|
|
26362
|
-
import { statSync as
|
|
26523
|
+
import { statSync as statSync23 } from "node:fs";
|
|
26363
26524
|
async function listPiTranscriptMetadata(opts = {}) {
|
|
26364
26525
|
const projectFilter = opts.projects ? new Set(opts.projects) : null;
|
|
26365
26526
|
const sinceMs = opts.sinceMs ?? 0;
|
|
@@ -26376,7 +26537,7 @@ async function listPiTranscriptMetadata(opts = {}) {
|
|
|
26376
26537
|
continue;
|
|
26377
26538
|
let sizeBytes = 0;
|
|
26378
26539
|
try {
|
|
26379
|
-
sizeBytes =
|
|
26540
|
+
sizeBytes = statSync23(s.path).size;
|
|
26380
26541
|
} catch {}
|
|
26381
26542
|
if (!s.sessionId)
|
|
26382
26543
|
continue;
|
|
@@ -27112,8 +27273,8 @@ var init_features = __esm(() => {
|
|
|
27112
27273
|
|
|
27113
27274
|
// src/audit/cache.ts
|
|
27114
27275
|
import { createHash as createHash8 } from "node:crypto";
|
|
27115
|
-
import { existsSync as
|
|
27116
|
-
import { join as
|
|
27276
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync19, readFileSync as readFileSync25, writeFileSync as writeFileSync17, chmodSync as chmodSync5, openSync, readSync, closeSync } from "node:fs";
|
|
27277
|
+
import { join as join35 } from "node:path";
|
|
27117
27278
|
function getEngineVersion() {
|
|
27118
27279
|
if (cachedEngineVersion)
|
|
27119
27280
|
return cachedEngineVersion;
|
|
@@ -27133,7 +27294,7 @@ function getDetectorVersion() {
|
|
|
27133
27294
|
function getCachePathFor(transcriptPath) {
|
|
27134
27295
|
const root = auditCacheDir();
|
|
27135
27296
|
const key = createHash8("sha1").update(transcriptPath).digest("hex");
|
|
27136
|
-
return
|
|
27297
|
+
return join35(root, `${key}.json`);
|
|
27137
27298
|
}
|
|
27138
27299
|
function encodeDetectorState(state) {
|
|
27139
27300
|
return JSON.stringify(state, (_k, v) => v instanceof Map ? { __map: [...v.entries()] } : v);
|
|
@@ -27173,7 +27334,7 @@ function readCachedTranscript(transcriptPath, mtimeMs, sizeBytes) {
|
|
|
27173
27334
|
if (sizeBytes === 0)
|
|
27174
27335
|
return null;
|
|
27175
27336
|
const cachePath = getCachePathFor(transcriptPath);
|
|
27176
|
-
if (!
|
|
27337
|
+
if (!existsSync32(cachePath))
|
|
27177
27338
|
return null;
|
|
27178
27339
|
try {
|
|
27179
27340
|
const raw = readFileSync25(cachePath, "utf-8");
|
|
@@ -27793,7 +27954,7 @@ var init_audit_lock = __esm(() => {
|
|
|
27793
27954
|
});
|
|
27794
27955
|
|
|
27795
27956
|
// src/audit/dashboard-cache.ts
|
|
27796
|
-
import { existsSync as
|
|
27957
|
+
import { existsSync as existsSync33, readFileSync as readFileSync27 } from "node:fs";
|
|
27797
27958
|
function getCachePath() {
|
|
27798
27959
|
return auditDashboardFile();
|
|
27799
27960
|
}
|
|
@@ -27813,7 +27974,7 @@ function writeDashboardCache(params, result) {
|
|
|
27813
27974
|
}
|
|
27814
27975
|
function readDashboardCacheMeta() {
|
|
27815
27976
|
const cachePath = getCachePath();
|
|
27816
|
-
if (!
|
|
27977
|
+
if (!existsSync33(cachePath))
|
|
27817
27978
|
return null;
|
|
27818
27979
|
try {
|
|
27819
27980
|
const raw = readFileSync27(cachePath, "utf-8");
|
|
@@ -28040,15 +28201,15 @@ var init_api_server_client = __esm(() => {
|
|
|
28040
28201
|
});
|
|
28041
28202
|
|
|
28042
28203
|
// lib/auth/auth-store.ts
|
|
28043
|
-
import { existsSync as
|
|
28044
|
-
import { join as
|
|
28204
|
+
import { existsSync as existsSync34, readFileSync as readFileSync28, readdirSync as readdirSync18, rmSync as rmSync12 } from "node:fs";
|
|
28205
|
+
import { join as join36, resolve as resolve24 } from "node:path";
|
|
28045
28206
|
function getAuthFilePath() {
|
|
28046
28207
|
const override = process.env.FAILPROOFAI_AUTH_DIR;
|
|
28047
|
-
return override ?
|
|
28208
|
+
return override ? join36(override, "session.json") : auditSessionFile();
|
|
28048
28209
|
}
|
|
28049
28210
|
function readAuth() {
|
|
28050
28211
|
const p = getAuthFilePath();
|
|
28051
|
-
if (!
|
|
28212
|
+
if (!existsSync34(p))
|
|
28052
28213
|
return null;
|
|
28053
28214
|
try {
|
|
28054
28215
|
const raw = readFileSync28(p, "utf-8");
|
|
@@ -28075,17 +28236,17 @@ function writeAuth(auth) {
|
|
|
28075
28236
|
}
|
|
28076
28237
|
function deleteAuth() {
|
|
28077
28238
|
const p = getAuthFilePath();
|
|
28078
|
-
if (
|
|
28239
|
+
if (existsSync34(p))
|
|
28079
28240
|
rmSync12(p, { force: true });
|
|
28080
28241
|
try {
|
|
28081
28242
|
const root = migrationsDir();
|
|
28082
|
-
if (!
|
|
28243
|
+
if (!existsSync34(root))
|
|
28083
28244
|
return;
|
|
28084
|
-
for (const entry of
|
|
28245
|
+
for (const entry of readdirSync18(root)) {
|
|
28085
28246
|
if (!entry.startsWith("backup-layout"))
|
|
28086
28247
|
continue;
|
|
28087
|
-
const copy =
|
|
28088
|
-
if (
|
|
28248
|
+
const copy = resolve24(root, entry, "auth.json");
|
|
28249
|
+
if (existsSync34(copy))
|
|
28089
28250
|
rmSync12(copy, { force: true });
|
|
28090
28251
|
}
|
|
28091
28252
|
} catch {}
|
|
@@ -28147,7 +28308,7 @@ var init_auth_store = __esm(() => {
|
|
|
28147
28308
|
});
|
|
28148
28309
|
|
|
28149
28310
|
// src/audit/redact-example.ts
|
|
28150
|
-
import { homedir as
|
|
28311
|
+
import { homedir as homedir27 } from "node:os";
|
|
28151
28312
|
function maskTruncatedSecret(input) {
|
|
28152
28313
|
for (const [pattern, label] of SECRET_PREFIXES) {
|
|
28153
28314
|
if (pattern.test(input)) {
|
|
@@ -28182,7 +28343,7 @@ function maskSecrets(input) {
|
|
|
28182
28343
|
}
|
|
28183
28344
|
return out;
|
|
28184
28345
|
}
|
|
28185
|
-
function shortenPaths(input, home =
|
|
28346
|
+
function shortenPaths(input, home = homedir27()) {
|
|
28186
28347
|
const homeRoot = home.replace(/\/+$/, "");
|
|
28187
28348
|
return input.replace(ABSOLUTE_PATH_RE, (match, offset, whole) => {
|
|
28188
28349
|
if (PUBLIC_PATH_ROOTS.some((root) => match.startsWith(root)))
|
|
@@ -28213,7 +28374,7 @@ function shortenPaths(input, home = homedir26()) {
|
|
|
28213
28374
|
return `${root}${middle}/${tail}${trailingSlash ? "/" : ""}`;
|
|
28214
28375
|
});
|
|
28215
28376
|
}
|
|
28216
|
-
function redactExample(input, home =
|
|
28377
|
+
function redactExample(input, home = homedir27()) {
|
|
28217
28378
|
const masked = maskAssignedSecrets(maskTruncatedSecret(maskSecrets(input)));
|
|
28218
28379
|
const shortened = shortenPaths(masked, home);
|
|
28219
28380
|
const collapsed = shortened.replace(/\s+/g, " ").trim();
|
|
@@ -28336,12 +28497,12 @@ var init_harm_report = __esm(() => {
|
|
|
28336
28497
|
});
|
|
28337
28498
|
|
|
28338
28499
|
// src/audit/machine-store.ts
|
|
28339
|
-
import { existsSync as
|
|
28500
|
+
import { existsSync as existsSync35, readFileSync as readFileSync29, rmSync as rmSync13 } from "node:fs";
|
|
28340
28501
|
import { hostname as hostname5 } from "node:os";
|
|
28341
28502
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
28342
28503
|
function readMachineIdentity(home) {
|
|
28343
28504
|
const path = auditMachineFile(home);
|
|
28344
|
-
if (!
|
|
28505
|
+
if (!existsSync35(path))
|
|
28345
28506
|
return null;
|
|
28346
28507
|
try {
|
|
28347
28508
|
const parsed = JSON.parse(readFileSync29(path, "utf8"));
|
|
@@ -28666,16 +28827,16 @@ var init_cli = __esm(() => {
|
|
|
28666
28827
|
});
|
|
28667
28828
|
|
|
28668
28829
|
// src/hooks/configure-wizard.ts
|
|
28669
|
-
import { existsSync as
|
|
28670
|
-
import { homedir as
|
|
28671
|
-
import { dirname as
|
|
28830
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync21, writeFileSync as writeFileSync19, readFileSync as readFileSync30 } from "node:fs";
|
|
28831
|
+
import { homedir as homedir28 } from "node:os";
|
|
28832
|
+
import { dirname as dirname17, resolve as resolve25, sep as sep5 } from "node:path";
|
|
28672
28833
|
async function emit(event, props) {
|
|
28673
28834
|
try {
|
|
28674
28835
|
await trackHookEvent2(getInstanceId2(), event, props);
|
|
28675
28836
|
} catch {}
|
|
28676
28837
|
}
|
|
28677
28838
|
function homeify(p) {
|
|
28678
|
-
const home =
|
|
28839
|
+
const home = homedir28();
|
|
28679
28840
|
if (p === home)
|
|
28680
28841
|
return "~";
|
|
28681
28842
|
if (p.startsWith(home + sep5))
|
|
@@ -28691,7 +28852,7 @@ function setCustomPoliciesEnabled(scope, cwd, enabled) {
|
|
|
28691
28852
|
const path = getConfigPathForScope(scope, cwd);
|
|
28692
28853
|
let config = {};
|
|
28693
28854
|
try {
|
|
28694
|
-
if (
|
|
28855
|
+
if (existsSync36(path))
|
|
28695
28856
|
config = JSON.parse(readFileSync30(path, "utf8"));
|
|
28696
28857
|
} catch {
|
|
28697
28858
|
return;
|
|
@@ -28732,7 +28893,7 @@ function describeCustomPolicies(cwd) {
|
|
|
28732
28893
|
const scopes = [];
|
|
28733
28894
|
let fileCount = 0;
|
|
28734
28895
|
const dirs = [
|
|
28735
|
-
{ dir:
|
|
28896
|
+
{ dir: resolve25(cwd, ".failproofai", "policies"), label: "project" },
|
|
28736
28897
|
{ dir: customPoliciesDir(), label: "global" }
|
|
28737
28898
|
];
|
|
28738
28899
|
for (const { dir, label } of dirs) {
|
|
@@ -28743,7 +28904,7 @@ function describeCustomPolicies(cwd) {
|
|
|
28743
28904
|
fileCount += found.length;
|
|
28744
28905
|
}
|
|
28745
28906
|
for (const name of findSkippedPolicyFiles(dir)) {
|
|
28746
|
-
warnings.push(`! ${homeify(
|
|
28907
|
+
warnings.push(`! ${homeify(resolve25(dir, name))} is NOT loaded — rename to ` + `${name.replace(/\.(js|mjs|ts)$/, "-policies.$1")}`);
|
|
28747
28908
|
}
|
|
28748
28909
|
}
|
|
28749
28910
|
return { active, warnings, fileCount, scopes };
|
|
@@ -28836,7 +28997,7 @@ function firstRunMarkerPath() {
|
|
|
28836
28997
|
}
|
|
28837
28998
|
function markLauncherSeen() {
|
|
28838
28999
|
try {
|
|
28839
|
-
mkdirSync21(
|
|
29000
|
+
mkdirSync21(dirname17(firstRunMarkerPath()), { recursive: true });
|
|
28840
29001
|
writeFileSync19(firstRunMarkerPath(), "1", "utf8");
|
|
28841
29002
|
} catch {}
|
|
28842
29003
|
}
|
|
@@ -29328,17 +29489,17 @@ var init_configure_wizard = __esm(() => {
|
|
|
29328
29489
|
});
|
|
29329
29490
|
|
|
29330
29491
|
// src/hooks/flush-cli.ts
|
|
29331
|
-
import { existsSync as
|
|
29332
|
-
import { dirname as
|
|
29492
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync22, writeFileSync as writeFileSync20, readdirSync as readdirSync19 } from "node:fs";
|
|
29493
|
+
import { dirname as dirname18, join as join37 } from "node:path";
|
|
29333
29494
|
function flushRequestPath2(home) {
|
|
29334
|
-
return
|
|
29495
|
+
return join37(failproofaiHome(home), "state", "flush-request.json");
|
|
29335
29496
|
}
|
|
29336
29497
|
function spoolDirs2(home) {
|
|
29337
29498
|
const root = spoolDir(home);
|
|
29338
|
-
if (!
|
|
29499
|
+
if (!existsSync37(root))
|
|
29339
29500
|
return [];
|
|
29340
29501
|
try {
|
|
29341
|
-
return
|
|
29502
|
+
return readdirSync19(root, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== "failed").map((e) => join37(root, e.name));
|
|
29342
29503
|
} catch {
|
|
29343
29504
|
return [];
|
|
29344
29505
|
}
|
|
@@ -29347,7 +29508,7 @@ function pendingBatches2(home) {
|
|
|
29347
29508
|
let n = 0;
|
|
29348
29509
|
for (const dir of spoolDirs2(home)) {
|
|
29349
29510
|
try {
|
|
29350
|
-
n +=
|
|
29511
|
+
n += readdirSync19(dir).filter((f) => f.endsWith(".jsonl")).length;
|
|
29351
29512
|
} catch {}
|
|
29352
29513
|
}
|
|
29353
29514
|
return n;
|
|
@@ -29404,7 +29565,7 @@ async function runFlushCommand2(opts = {}) {
|
|
|
29404
29565
|
return { exitCode: 0, pending: 0, lines: ["Nothing spooled — everything already delivered."] };
|
|
29405
29566
|
}
|
|
29406
29567
|
const path = flushRequestPath2(home);
|
|
29407
|
-
mkdirSync22(
|
|
29568
|
+
mkdirSync22(dirname18(path), { recursive: true });
|
|
29408
29569
|
writeFileSync20(path, `${JSON.stringify({ requestedAtMs: Date.now() }, null, 2)}
|
|
29409
29570
|
`, {
|
|
29410
29571
|
mode: 384
|
|
@@ -29436,16 +29597,16 @@ var init_flush_cli2 = __esm(() => {
|
|
|
29436
29597
|
});
|
|
29437
29598
|
|
|
29438
29599
|
// src/hooks/backfill-cli.ts
|
|
29439
|
-
import { existsSync as
|
|
29440
|
-
import { dirname as
|
|
29600
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync23, writeFileSync as writeFileSync21, readdirSync as readdirSync20, statSync as statSync24 } from "node:fs";
|
|
29601
|
+
import { dirname as dirname19, join as join38 } from "node:path";
|
|
29441
29602
|
function backfillRequestPath(home) {
|
|
29442
|
-
return
|
|
29603
|
+
return join38(failproofaiHome(home), "state", "backfill-request.json");
|
|
29443
29604
|
}
|
|
29444
29605
|
function surveySessions(sinceMs, homeDir) {
|
|
29445
29606
|
const out = [];
|
|
29446
29607
|
for (const { cli, dir } of SESSION_DIRS) {
|
|
29447
|
-
const root =
|
|
29448
|
-
if (!
|
|
29608
|
+
const root = join38(homeDir, dir);
|
|
29609
|
+
if (!existsSync38(root))
|
|
29449
29610
|
continue;
|
|
29450
29611
|
let files = 0;
|
|
29451
29612
|
let newest = 0;
|
|
@@ -29454,18 +29615,18 @@ function surveySessions(sinceMs, homeDir) {
|
|
|
29454
29615
|
return;
|
|
29455
29616
|
let entries;
|
|
29456
29617
|
try {
|
|
29457
|
-
entries =
|
|
29618
|
+
entries = readdirSync20(d, { withFileTypes: true });
|
|
29458
29619
|
} catch {
|
|
29459
29620
|
return;
|
|
29460
29621
|
}
|
|
29461
29622
|
for (const e of entries) {
|
|
29462
|
-
const p =
|
|
29623
|
+
const p = join38(d, e.name);
|
|
29463
29624
|
if (e.isDirectory()) {
|
|
29464
29625
|
walk(p, depth + 1);
|
|
29465
29626
|
continue;
|
|
29466
29627
|
}
|
|
29467
29628
|
try {
|
|
29468
|
-
const st =
|
|
29629
|
+
const st = statSync24(p);
|
|
29469
29630
|
if (st.mtimeMs >= sinceMs) {
|
|
29470
29631
|
files += 1;
|
|
29471
29632
|
newest = Math.max(newest, st.mtimeMs);
|
|
@@ -29483,7 +29644,7 @@ function runBackfillCommand(opts = {}) {
|
|
|
29483
29644
|
const now = opts.now ?? Date.now();
|
|
29484
29645
|
const sinceMs = opts.sinceMs ?? now - DEFAULT_BACKFILL_DAYS * 24 * 60 * 60 * 1000;
|
|
29485
29646
|
const home = failproofaiHome();
|
|
29486
|
-
if (!
|
|
29647
|
+
if (!existsSync38(home)) {
|
|
29487
29648
|
return {
|
|
29488
29649
|
exitCode: 1,
|
|
29489
29650
|
lines: [`No failproofai home at ${home}. Run \`failproofai config\` first.`]
|
|
@@ -29515,7 +29676,7 @@ function runBackfillCommand(opts = {}) {
|
|
|
29515
29676
|
]
|
|
29516
29677
|
};
|
|
29517
29678
|
}
|
|
29518
|
-
const found = surveySessions(sinceMs,
|
|
29679
|
+
const found = surveySessions(sinceMs, dirname19(home));
|
|
29519
29680
|
const totalFiles = found.reduce((n, f) => n + f.files, 0);
|
|
29520
29681
|
const sinceLabel = new Date(sinceMs).toISOString().slice(0, 10);
|
|
29521
29682
|
const lines = [
|
|
@@ -29538,7 +29699,7 @@ function runBackfillCommand(opts = {}) {
|
|
|
29538
29699
|
}
|
|
29539
29700
|
try {
|
|
29540
29701
|
const path = backfillRequestPath();
|
|
29541
|
-
mkdirSync23(
|
|
29702
|
+
mkdirSync23(dirname19(path), { recursive: true });
|
|
29542
29703
|
writeFileSync21(path, `${JSON.stringify({ sinceMs, requestedAtMs: now }, null, 2)}
|
|
29543
29704
|
`, {
|
|
29544
29705
|
mode: 384
|
|
@@ -29581,8 +29742,8 @@ var init_backfill_cli = __esm(() => {
|
|
|
29581
29742
|
});
|
|
29582
29743
|
|
|
29583
29744
|
// src/hooks/harness-cli.ts
|
|
29584
|
-
import { homedir as
|
|
29585
|
-
import { resolve as
|
|
29745
|
+
import { homedir as homedir29 } from "node:os";
|
|
29746
|
+
import { resolve as resolve26 } from "node:path";
|
|
29586
29747
|
function unknownHarness(name) {
|
|
29587
29748
|
return fail([
|
|
29588
29749
|
`Unknown harness: ${name}`,
|
|
@@ -29625,8 +29786,8 @@ function comparableLabel(raw) {
|
|
|
29625
29786
|
return raw.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
29626
29787
|
}
|
|
29627
29788
|
function comparablePath(raw) {
|
|
29628
|
-
const home =
|
|
29629
|
-
const expanded = raw === "~" ? home : raw.startsWith("~/") ?
|
|
29789
|
+
const home = homedir29();
|
|
29790
|
+
const expanded = raw === "~" ? home : raw.startsWith("~/") ? resolve26(home, raw.slice(2)) : raw;
|
|
29630
29791
|
return expanded.replace(/\/+$/, "");
|
|
29631
29792
|
}
|
|
29632
29793
|
function effectiveLabel(entry) {
|
|
@@ -29814,7 +29975,7 @@ var init_harness_cli = __esm(() => {
|
|
|
29814
29975
|
});
|
|
29815
29976
|
|
|
29816
29977
|
// src/hooks/fp-config.ts
|
|
29817
|
-
import { chmodSync as chmodSync6, existsSync as
|
|
29978
|
+
import { chmodSync as chmodSync6, existsSync as existsSync39, mkdirSync as mkdirSync24, readFileSync as readFileSync31, statSync as statSync25, writeFileSync as writeFileSync22 } from "node:fs";
|
|
29818
29979
|
function detectLayout2() {
|
|
29819
29980
|
const raw = readVersionFile2();
|
|
29820
29981
|
if (raw) {
|
|
@@ -29822,17 +29983,17 @@ function detectLayout2() {
|
|
|
29822
29983
|
return { kind: "current", version: raw };
|
|
29823
29984
|
return raw.layout > LAYOUT_VERSION ? { kind: "future", found: raw.layout } : { kind: "stale", found: raw.layout };
|
|
29824
29985
|
}
|
|
29825
|
-
if (
|
|
29986
|
+
if (existsSync39(configFile())) {
|
|
29826
29987
|
const layoutThreePositions = [
|
|
29827
29988
|
legacy.authJson(),
|
|
29828
29989
|
legacy.nextAudit(),
|
|
29829
29990
|
legacy.auditSchedule()
|
|
29830
29991
|
];
|
|
29831
|
-
if (layoutThreePositions.some((p) =>
|
|
29992
|
+
if (layoutThreePositions.some((p) => existsSync39(p)))
|
|
29832
29993
|
return { kind: "stale", found: 3 };
|
|
29833
29994
|
return { kind: "current", version: { layout: LAYOUT_VERSION, cli: "" }, inferred: true };
|
|
29834
29995
|
}
|
|
29835
|
-
if (
|
|
29996
|
+
if (existsSync39(legacy.configToml()))
|
|
29836
29997
|
return { kind: "stale", found: 2 };
|
|
29837
29998
|
const layoutOneMarkers = [
|
|
29838
29999
|
legacy.policyConfig(),
|
|
@@ -29843,7 +30004,7 @@ function detectLayout2() {
|
|
|
29843
30004
|
legacy.ingestCredentials(),
|
|
29844
30005
|
legacy.auditDashboard()
|
|
29845
30006
|
];
|
|
29846
|
-
return layoutOneMarkers.some((p) =>
|
|
30007
|
+
return layoutOneMarkers.some((p) => existsSync39(p)) ? { kind: "stale", found: 1 } : { kind: "absent" };
|
|
29847
30008
|
}
|
|
29848
30009
|
function readLegacyTomlVersion2(text) {
|
|
29849
30010
|
const layout = Number(/^\s*layout\s*=\s*(\d+)\s*$/m.exec(text)?.[1]);
|
|
@@ -29886,14 +30047,14 @@ var init_fp_home2 = () => {};
|
|
|
29886
30047
|
import {
|
|
29887
30048
|
chmodSync as chmodSync7,
|
|
29888
30049
|
copyFileSync as copyFileSync3,
|
|
29889
|
-
existsSync as
|
|
30050
|
+
existsSync as existsSync40,
|
|
29890
30051
|
mkdirSync as mkdirSync25,
|
|
29891
30052
|
readFileSync as readFileSync32,
|
|
29892
30053
|
renameSync as renameSync8,
|
|
29893
30054
|
rmSync as rmSync14,
|
|
29894
30055
|
writeFileSync as writeFileSync23
|
|
29895
30056
|
} from "node:fs";
|
|
29896
|
-
import { basename as
|
|
30057
|
+
import { basename as basename8, dirname as dirname20, join as join39, resolve as resolve27 } from "node:path";
|
|
29897
30058
|
function migrateToLayout42() {
|
|
29898
30059
|
const moves = [
|
|
29899
30060
|
{ from: legacy.authJson(), to: auditSessionFile() },
|
|
@@ -29902,20 +30063,20 @@ function migrateToLayout42() {
|
|
|
29902
30063
|
];
|
|
29903
30064
|
const authDirOverride = process.env.FAILPROOFAI_AUTH_DIR;
|
|
29904
30065
|
if (authDirOverride) {
|
|
29905
|
-
moves.push({ from:
|
|
29906
|
-
from:
|
|
29907
|
-
to:
|
|
30066
|
+
moves.push({ from: join39(authDirOverride, "auth.json"), to: join39(authDirOverride, "session.json") }, {
|
|
30067
|
+
from: join39(authDirOverride, "next-audit.json"),
|
|
30068
|
+
to: join39(authDirOverride, "reminder.json")
|
|
29908
30069
|
});
|
|
29909
30070
|
}
|
|
29910
30071
|
const migrated = [];
|
|
29911
30072
|
for (const { from, to } of moves) {
|
|
29912
|
-
if (!
|
|
30073
|
+
if (!existsSync40(from))
|
|
29913
30074
|
continue;
|
|
29914
|
-
if (
|
|
30075
|
+
if (existsSync40(to)) {
|
|
29915
30076
|
rmSync14(from, { force: true });
|
|
29916
30077
|
continue;
|
|
29917
30078
|
}
|
|
29918
|
-
mkdirSync25(
|
|
30079
|
+
mkdirSync25(dirname20(to), { recursive: true });
|
|
29919
30080
|
try {
|
|
29920
30081
|
renameSync8(from, to);
|
|
29921
30082
|
} catch {
|
|
@@ -29929,10 +30090,10 @@ function migrateToLayout42() {
|
|
|
29929
30090
|
}
|
|
29930
30091
|
rmSync14(from, { force: true });
|
|
29931
30092
|
}
|
|
29932
|
-
migrated.push(`${
|
|
30093
|
+
migrated.push(`${basename8(from)} → audit/${basename8(to)}`);
|
|
29933
30094
|
}
|
|
29934
30095
|
for (const secret of [auditSessionFile()]) {
|
|
29935
|
-
if (!
|
|
30096
|
+
if (!existsSync40(secret))
|
|
29936
30097
|
continue;
|
|
29937
30098
|
try {
|
|
29938
30099
|
chmodSync7(secret, 384);
|
|
@@ -29973,17 +30134,17 @@ function appendLedger2(entry) {
|
|
|
29973
30134
|
} catch {}
|
|
29974
30135
|
}
|
|
29975
30136
|
function backupNameOf2(f) {
|
|
29976
|
-
return f.as ??
|
|
30137
|
+
return f.as ?? basename8(f.at());
|
|
29977
30138
|
}
|
|
29978
30139
|
function pruneMigratedCredentials2(from) {
|
|
29979
30140
|
const pruned = [];
|
|
29980
30141
|
for (let layout = from;layout < LAYOUT_VERSION; layout++) {
|
|
29981
30142
|
for (const { as, landsAt } of PRUNED_AFTER_SUCCESS2) {
|
|
29982
30143
|
try {
|
|
29983
|
-
if (!
|
|
30144
|
+
if (!existsSync40(landsAt()))
|
|
29984
30145
|
continue;
|
|
29985
|
-
const copy =
|
|
29986
|
-
if (!
|
|
30146
|
+
const copy = resolve27(migrationBackupDir(layout), as);
|
|
30147
|
+
if (!existsSync40(copy))
|
|
29987
30148
|
continue;
|
|
29988
30149
|
rmSync14(copy, { force: true });
|
|
29989
30150
|
pruned.push(as);
|
|
@@ -29996,7 +30157,7 @@ function filesToBackUp2() {
|
|
|
29996
30157
|
const seen = new Map;
|
|
29997
30158
|
for (const f of [...BACKED_UP2, ...BACKED_UP_LEGACY2]) {
|
|
29998
30159
|
const path = f.at();
|
|
29999
|
-
if (
|
|
30160
|
+
if (existsSync40(path))
|
|
30000
30161
|
seen.set(path, backupNameOf2(f));
|
|
30001
30162
|
}
|
|
30002
30163
|
return [...seen].map(([path, as]) => ({ path, as }));
|
|
@@ -30012,7 +30173,7 @@ function backupBeforeMigrating2(from) {
|
|
|
30012
30173
|
}
|
|
30013
30174
|
for (const { path: source, as } of filesToBackUp2()) {
|
|
30014
30175
|
try {
|
|
30015
|
-
copyFileSync3(source,
|
|
30176
|
+
copyFileSync3(source, resolve27(dir, as));
|
|
30016
30177
|
saved.push(as);
|
|
30017
30178
|
} catch {}
|
|
30018
30179
|
}
|
|
@@ -30144,13 +30305,13 @@ var init_migrations2 = __esm(() => {
|
|
|
30144
30305
|
{ at: legacy.auditSchedule }
|
|
30145
30306
|
];
|
|
30146
30307
|
PRUNED_AFTER_SUCCESS2 = [
|
|
30147
|
-
{ as:
|
|
30308
|
+
{ as: basename8(legacy.authJson()), landsAt: auditSessionFile }
|
|
30148
30309
|
];
|
|
30149
30310
|
});
|
|
30150
30311
|
|
|
30151
30312
|
// src/hooks/daemon-service.ts
|
|
30152
30313
|
import {
|
|
30153
|
-
existsSync as
|
|
30314
|
+
existsSync as existsSync41,
|
|
30154
30315
|
mkdirSync as mkdirSync26,
|
|
30155
30316
|
mkdtempSync as mkdtempSync2,
|
|
30156
30317
|
readFileSync as readFileSync33,
|
|
@@ -30158,8 +30319,8 @@ import {
|
|
|
30158
30319
|
unlinkSync as unlinkSync5,
|
|
30159
30320
|
rmSync as rmSync15
|
|
30160
30321
|
} from "node:fs";
|
|
30161
|
-
import { homedir as
|
|
30162
|
-
import { resolve as
|
|
30322
|
+
import { homedir as homedir30, tmpdir as tmpdir3, userInfo as userInfo2 } from "node:os";
|
|
30323
|
+
import { resolve as resolve28 } from "node:path";
|
|
30163
30324
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
30164
30325
|
function isDaemonSupportedPlatform2() {
|
|
30165
30326
|
return process.platform === "linux" || process.platform === "darwin";
|
|
@@ -30175,13 +30336,13 @@ function resolveFailproofaidBinaryPath2() {
|
|
|
30175
30336
|
if (process.env.FAILPROOFAI_DAEMON_BINARY)
|
|
30176
30337
|
return process.env.FAILPROOFAI_DAEMON_BINARY;
|
|
30177
30338
|
const downloaded = installedBinaryPath();
|
|
30178
|
-
if (
|
|
30339
|
+
if (existsSync41(downloaded))
|
|
30179
30340
|
return downloaded;
|
|
30180
30341
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
30181
30342
|
if (packageRoot) {
|
|
30182
30343
|
for (const profile of ["release", "debug"]) {
|
|
30183
|
-
const candidate =
|
|
30184
|
-
if (
|
|
30344
|
+
const candidate = resolve28(packageRoot, "target", profile, "failproofaid");
|
|
30345
|
+
if (existsSync41(candidate))
|
|
30185
30346
|
return candidate;
|
|
30186
30347
|
}
|
|
30187
30348
|
}
|
|
@@ -30211,8 +30372,8 @@ function resolveWorkerCommand2() {
|
|
|
30211
30372
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
30212
30373
|
if (!packageRoot)
|
|
30213
30374
|
return null;
|
|
30214
|
-
const workerScript =
|
|
30215
|
-
if (!
|
|
30375
|
+
const workerScript = resolve28(packageRoot, "dist", "worker.mjs");
|
|
30376
|
+
if (!existsSync41(workerScript))
|
|
30216
30377
|
return null;
|
|
30217
30378
|
return `${shellQuote2(process.execPath)} ${shellQuote2(workerScript)}`;
|
|
30218
30379
|
}
|
|
@@ -30222,8 +30383,8 @@ function resolveCliCommand2() {
|
|
|
30222
30383
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
30223
30384
|
if (!packageRoot)
|
|
30224
30385
|
return null;
|
|
30225
|
-
const cliScript =
|
|
30226
|
-
if (!
|
|
30386
|
+
const cliScript = resolve28(packageRoot, "dist", "cli.mjs");
|
|
30387
|
+
if (!existsSync41(cliScript))
|
|
30227
30388
|
return null;
|
|
30228
30389
|
return `${shellQuote2(process.execPath)} ${shellQuote2(cliScript)}`;
|
|
30229
30390
|
}
|
|
@@ -30236,8 +30397,8 @@ function workerScriptPath2() {
|
|
|
30236
30397
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
30237
30398
|
if (!packageRoot)
|
|
30238
30399
|
return null;
|
|
30239
|
-
const workerScript =
|
|
30240
|
-
return
|
|
30400
|
+
const workerScript = resolve28(packageRoot, "dist", "worker.mjs");
|
|
30401
|
+
return existsSync41(workerScript) ? workerScript : null;
|
|
30241
30402
|
}
|
|
30242
30403
|
function assertUnitSafe2(value, field) {
|
|
30243
30404
|
if (UNIT_UNSAFE_RE2.test(value)) {
|
|
@@ -30263,10 +30424,10 @@ function systemdUnitDir2() {
|
|
|
30263
30424
|
return process.env.FAILPROOFAI_SYSTEMD_DIR || "/etc/systemd/system";
|
|
30264
30425
|
}
|
|
30265
30426
|
function systemdUnitPath2(user = serviceUser2()) {
|
|
30266
|
-
return
|
|
30427
|
+
return resolve28(systemdUnitDir2(), systemdUnitName2(user));
|
|
30267
30428
|
}
|
|
30268
30429
|
function legacySystemdUserUnitPath2() {
|
|
30269
|
-
return
|
|
30430
|
+
return resolve28(homedir30(), ".config", "systemd", "user", "failproofaid.service");
|
|
30270
30431
|
}
|
|
30271
30432
|
function launchdLabel2(user = serviceUser2()) {
|
|
30272
30433
|
return `ai.failproof.failproofaid.${user}`;
|
|
@@ -30275,7 +30436,7 @@ function launchdPlistPath2(user = serviceUser2()) {
|
|
|
30275
30436
|
return `/Library/LaunchDaemons/${launchdLabel2(user)}.plist`;
|
|
30276
30437
|
}
|
|
30277
30438
|
function legacyLaunchAgentPlistPath2() {
|
|
30278
|
-
return
|
|
30439
|
+
return resolve28(homedir30(), "Library", "LaunchAgents", "ai.failproof.failproofaid.plist");
|
|
30279
30440
|
}
|
|
30280
30441
|
function legacySharedLaunchDaemonPath2() {
|
|
30281
30442
|
return "/Library/LaunchDaemons/ai.failproof.failproofaid.plist";
|
|
@@ -30313,8 +30474,8 @@ function runPrivileged2(command, args) {
|
|
|
30313
30474
|
execFileSync3(cmd, argv, { stdio: "ignore", timeout: SERVICE_CMD_TIMEOUT_MS2 });
|
|
30314
30475
|
}
|
|
30315
30476
|
function writePrivilegedFile2(destination, contents, mode = "0644") {
|
|
30316
|
-
const stagingDir = mkdtempSync2(
|
|
30317
|
-
const staging =
|
|
30477
|
+
const stagingDir = mkdtempSync2(resolve28(tmpdir3(), "failproofaid-stage-"));
|
|
30478
|
+
const staging = resolve28(stagingDir, "service-definition");
|
|
30318
30479
|
try {
|
|
30319
30480
|
writeFileSync24(staging, contents, "utf8");
|
|
30320
30481
|
runPrivileged2("install", ["-m", mode, staging, destination]);
|
|
@@ -30326,7 +30487,7 @@ function removeLegacyUserService2() {
|
|
|
30326
30487
|
try {
|
|
30327
30488
|
if (process.platform === "linux") {
|
|
30328
30489
|
const legacy = legacySystemdUserUnitPath2();
|
|
30329
|
-
if (!
|
|
30490
|
+
if (!existsSync41(legacy))
|
|
30330
30491
|
return;
|
|
30331
30492
|
try {
|
|
30332
30493
|
execFileSync3("systemctl", ["--user", "disable", "--now", "failproofaid.service"], {
|
|
@@ -30343,7 +30504,7 @@ function removeLegacyUserService2() {
|
|
|
30343
30504
|
} catch {}
|
|
30344
30505
|
} else {
|
|
30345
30506
|
const legacyAgent = legacyLaunchAgentPlistPath2();
|
|
30346
|
-
if (
|
|
30507
|
+
if (existsSync41(legacyAgent)) {
|
|
30347
30508
|
try {
|
|
30348
30509
|
execFileSync3("launchctl", ["unload", "-w", legacyAgent], {
|
|
30349
30510
|
stdio: "ignore",
|
|
@@ -30353,7 +30514,7 @@ function removeLegacyUserService2() {
|
|
|
30353
30514
|
unlinkSync5(legacyAgent);
|
|
30354
30515
|
}
|
|
30355
30516
|
const legacyDaemon = legacySharedLaunchDaemonPath2();
|
|
30356
|
-
if (
|
|
30517
|
+
if (existsSync41(legacyDaemon)) {
|
|
30357
30518
|
try {
|
|
30358
30519
|
runPrivileged2("launchctl", ["unload", "-w", legacyDaemon]);
|
|
30359
30520
|
} catch {}
|
|
@@ -30369,8 +30530,8 @@ function systemdUnitContents2(binaryPath, workerCmd, cliCmd = null) {
|
|
|
30369
30530
|
`).join("");
|
|
30370
30531
|
const user = assertUnitSafe2(serviceUser2(), "User");
|
|
30371
30532
|
assertUnitSafe2(binaryPath, "ExecStart");
|
|
30372
|
-
assertUnitSafe2(
|
|
30373
|
-
const conditionPaths = [binaryPath, workerScriptPath2()].filter((p) => typeof p === "string" &&
|
|
30533
|
+
assertUnitSafe2(homedir30(), "HOME");
|
|
30534
|
+
const conditionPaths = [binaryPath, workerScriptPath2()].filter((p) => typeof p === "string" && existsSync41(p));
|
|
30374
30535
|
const conditionLines = conditionPaths.map((p) => `ConditionPathExists=${assertUnitSafe2(p, "ConditionPathExists")}
|
|
30375
30536
|
`).join("");
|
|
30376
30537
|
return `[Unit]
|
|
@@ -30383,7 +30544,7 @@ User=${user}
|
|
|
30383
30544
|
# Set explicitly rather than relying on systemd deriving it from User=:
|
|
30384
30545
|
# failproofaid stores per-user state and refuses to start without HOME, so this
|
|
30385
30546
|
# required variable is not left to a version-dependent default.
|
|
30386
|
-
Environment="HOME=${
|
|
30547
|
+
Environment="HOME=${homedir30()}"
|
|
30387
30548
|
${envLines}ExecStart=${binaryPath}
|
|
30388
30549
|
Restart=on-failure
|
|
30389
30550
|
RestartSec=2
|
|
@@ -30428,9 +30589,9 @@ ${env.map(([key, value]) => ` <key>${key}</key>
|
|
|
30428
30589
|
<key>UserName</key>
|
|
30429
30590
|
<string>${escapeXml2(serviceUser2())}</string>
|
|
30430
30591
|
${envBlock} <key>StandardOutPath</key>
|
|
30431
|
-
<string>${escapeXml2(
|
|
30592
|
+
<string>${escapeXml2(resolve28(logDir, "failproofaid.log"))}</string>
|
|
30432
30593
|
<key>StandardErrorPath</key>
|
|
30433
|
-
<string>${escapeXml2(
|
|
30594
|
+
<string>${escapeXml2(resolve28(logDir, "failproofaid.err.log"))}</string>
|
|
30434
30595
|
</dict>
|
|
30435
30596
|
</plist>
|
|
30436
30597
|
`;
|
|
@@ -30575,7 +30736,7 @@ function daemonServiceStatus2() {
|
|
|
30575
30736
|
if (!isDaemonSupportedPlatform2())
|
|
30576
30737
|
return "unsupported-platform";
|
|
30577
30738
|
if (process.platform === "linux") {
|
|
30578
|
-
if (!
|
|
30739
|
+
if (!existsSync41(systemdUnitPath2()))
|
|
30579
30740
|
return "not-installed";
|
|
30580
30741
|
try {
|
|
30581
30742
|
const out = execFileSync3("systemctl", ["is-active", systemdUnitName2()], {
|
|
@@ -30588,7 +30749,7 @@ function daemonServiceStatus2() {
|
|
|
30588
30749
|
}
|
|
30589
30750
|
}
|
|
30590
30751
|
const plistPath = launchdPlistPath2();
|
|
30591
|
-
if (!
|
|
30752
|
+
if (!existsSync41(plistPath))
|
|
30592
30753
|
return "not-installed";
|
|
30593
30754
|
try {
|
|
30594
30755
|
const root = typeof process.getuid === "function" && process.getuid() === 0;
|
|
@@ -30618,7 +30779,7 @@ var init_daemon_service2 = __esm(() => {
|
|
|
30618
30779
|
});
|
|
30619
30780
|
|
|
30620
30781
|
// src/hooks/uninstall-cli.ts
|
|
30621
|
-
import { existsSync as
|
|
30782
|
+
import { existsSync as existsSync42, rmSync as rmSync16 } from "node:fs";
|
|
30622
30783
|
function survey(cwd) {
|
|
30623
30784
|
const clis = [];
|
|
30624
30785
|
for (const id of listInstallableIds()) {
|
|
@@ -30639,9 +30800,9 @@ function survey(cwd) {
|
|
|
30639
30800
|
return {
|
|
30640
30801
|
clis,
|
|
30641
30802
|
servicePath,
|
|
30642
|
-
serviceInstalled: !!servicePath &&
|
|
30803
|
+
serviceInstalled: !!servicePath && existsSync42(servicePath),
|
|
30643
30804
|
daemonConfigured,
|
|
30644
|
-
homeExists:
|
|
30805
|
+
homeExists: existsSync42(failproofaiHome())
|
|
30645
30806
|
};
|
|
30646
30807
|
}
|
|
30647
30808
|
async function runUninstallCommand(opts = {}) {
|
|
@@ -30739,7 +30900,7 @@ async function runUninstallCommand(opts = {}) {
|
|
|
30739
30900
|
} catch {}
|
|
30740
30901
|
try {
|
|
30741
30902
|
await uninstallDaemonService();
|
|
30742
|
-
if (found.servicePath &&
|
|
30903
|
+
if (found.servicePath && existsSync42(found.servicePath)) {
|
|
30743
30904
|
failures.push(`the service at ${found.servicePath} is still there (most often: no sudo). ` + `Remove it with the commands below.`);
|
|
30744
30905
|
} else {
|
|
30745
30906
|
lines.push(`✓ stopped and removed the daemon service`);
|
|
@@ -30762,7 +30923,7 @@ async function runUninstallCommand(opts = {}) {
|
|
|
30762
30923
|
lines.push(``, `Not everything could be removed:`);
|
|
30763
30924
|
for (const f of failures)
|
|
30764
30925
|
lines.push(` ✗ ${f}`);
|
|
30765
|
-
if (found.servicePath &&
|
|
30926
|
+
if (found.servicePath && existsSync42(found.servicePath)) {
|
|
30766
30927
|
lines.push(``, `To remove the service by hand:`, ...manualServiceRemoval(found.servicePath), ``, `(\`${daemonStatusCommand()}\` shows its current state.)`);
|
|
30767
30928
|
}
|
|
30768
30929
|
return { exitCode: 1, lines, planLines, purged };
|
|
@@ -30794,10 +30955,10 @@ var init_uninstall_cli = __esm(() => {
|
|
|
30794
30955
|
|
|
30795
30956
|
// src/hooks/pack-cli.ts
|
|
30796
30957
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
30797
|
-
import { homedir as
|
|
30958
|
+
import { homedir as homedir31, tmpdir as tmpdir4 } from "node:os";
|
|
30798
30959
|
import { createHash as createHash9 } from "node:crypto";
|
|
30799
|
-
import { copyFileSync as copyFileSync4, existsSync as
|
|
30800
|
-
import { basename as
|
|
30960
|
+
import { copyFileSync as copyFileSync4, existsSync as existsSync43, mkdirSync as mkdirSync27, mkdtempSync as mkdtempSync3, readFileSync as readFileSync34, readdirSync as readdirSync21, realpathSync as realpathSync3, rmSync as rmSync17, statSync as statSync26, writeFileSync as writeFileSync25 } from "node:fs";
|
|
30961
|
+
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";
|
|
30801
30962
|
function parseList(rest, flag) {
|
|
30802
30963
|
const idx = rest.findIndex((a) => a === flag || a.startsWith(`${flag}=`));
|
|
30803
30964
|
if (idx === -1)
|
|
@@ -30897,7 +31058,7 @@ async function build(rest) {
|
|
|
30897
31058
|
const version = flag("version");
|
|
30898
31059
|
const commit = flag("commit");
|
|
30899
31060
|
const effect = flag("effect") ?? "enforce";
|
|
30900
|
-
const outDir =
|
|
31061
|
+
const outDir = resolve29(flag("out") ?? "dist-pack");
|
|
30901
31062
|
if (!entry || !id || !version) {
|
|
30902
31063
|
return fail2([
|
|
30903
31064
|
"Usage: failproofai publish <entry.mjs> --repo <owner>/<repo> --version <version>",
|
|
@@ -30910,8 +31071,8 @@ async function build(rest) {
|
|
|
30910
31071
|
} catch (err) {
|
|
30911
31072
|
return fail2([err instanceof Error ? err.message : String(err)]);
|
|
30912
31073
|
}
|
|
30913
|
-
const entryPath =
|
|
30914
|
-
if (!
|
|
31074
|
+
const entryPath = resolve29(entry);
|
|
31075
|
+
if (!existsSync43(entryPath))
|
|
30915
31076
|
return fail2([`No such file: ${entryPath}`]);
|
|
30916
31077
|
const source = readFileSync34(entryPath, "utf8");
|
|
30917
31078
|
const localImport = /(?:^|\n)\s*(?:import|export)[^;\n]*from\s+["'](\.[^"']*)["']/.exec(source);
|
|
@@ -30970,12 +31131,12 @@ async function build(rest) {
|
|
|
30970
31131
|
}, null, 2) + `
|
|
30971
31132
|
`;
|
|
30972
31133
|
mkdirSync27(outDir, { recursive: true });
|
|
30973
|
-
const manifestPath =
|
|
30974
|
-
const entryOut =
|
|
31134
|
+
const manifestPath = resolve29(outDir, PACK_MANIFEST_ASSET);
|
|
31135
|
+
const entryOut = resolve29(outDir, PACK_ENTRY_ASSET);
|
|
30975
31136
|
writeFileSync25(manifestPath, manifest, "utf8");
|
|
30976
31137
|
copyFileSync4(entryPath, entryOut);
|
|
30977
31138
|
const sha = (bytes) => createHash9("sha256").update(bytes).digest("hex");
|
|
30978
|
-
writeFileSync25(
|
|
31139
|
+
writeFileSync25(resolve29(outDir, PACK_CHECKSUMS_ASSET), `${sha(manifest)} ${PACK_MANIFEST_ASSET}
|
|
30979
31140
|
${sha(readFileSync34(entryOut))} ${PACK_ENTRY_ASSET}
|
|
30980
31141
|
`, "utf8");
|
|
30981
31142
|
const on = policies.filter((p) => p.defaultEnabled).length;
|
|
@@ -31105,11 +31266,11 @@ async function scaffold(target) {
|
|
|
31105
31266
|
return ok2(["Nothing written."]);
|
|
31106
31267
|
chosen = answer.trim();
|
|
31107
31268
|
}
|
|
31108
|
-
const path =
|
|
31109
|
-
if (
|
|
31269
|
+
const path = resolve29(withPolicyExtension(chosen ?? "my-policies"));
|
|
31270
|
+
if (existsSync43(path)) {
|
|
31110
31271
|
return fail2([`${path} already exists — name a different file, or edit that one.`]);
|
|
31111
31272
|
}
|
|
31112
|
-
mkdirSync27(
|
|
31273
|
+
mkdirSync27(resolve29(path, ".."), { recursive: true });
|
|
31113
31274
|
writeFileSync25(path, `import { customPolicies, allow, deny } from "failproofai";
|
|
31114
31275
|
|
|
31115
31276
|
// One file, no relative imports: only this entry is digest-pinned, so a pack
|
|
@@ -31147,7 +31308,7 @@ customPolicies.add({
|
|
|
31147
31308
|
function inferRepo(entryPath) {
|
|
31148
31309
|
try {
|
|
31149
31310
|
const url = execFileSync4("git", ["remote", "get-url", "origin"], {
|
|
31150
|
-
cwd:
|
|
31311
|
+
cwd: resolve29(entryPath, ".."),
|
|
31151
31312
|
encoding: "utf8",
|
|
31152
31313
|
stdio: ["ignore", "pipe", "ignore"],
|
|
31153
31314
|
timeout: 5000
|
|
@@ -31159,7 +31320,7 @@ function inferRepo(entryPath) {
|
|
|
31159
31320
|
}
|
|
31160
31321
|
}
|
|
31161
31322
|
function inferCommit(entryPath, outDir, sources) {
|
|
31162
|
-
const cwd =
|
|
31323
|
+
const cwd = resolve29(entryPath, "..");
|
|
31163
31324
|
const raw = (args) => {
|
|
31164
31325
|
try {
|
|
31165
31326
|
return execFileSync4("git", args, {
|
|
@@ -31214,9 +31375,9 @@ function realOrSelf(path) {
|
|
|
31214
31375
|
}
|
|
31215
31376
|
}
|
|
31216
31377
|
function sourcesInHead(git, raw, sources) {
|
|
31217
|
-
const paths = sources.map((f) => realOrSelf(
|
|
31378
|
+
const paths = sources.map((f) => realOrSelf(resolve29(f)));
|
|
31218
31379
|
const shown = git(["rev-parse", "--show-toplevel"]);
|
|
31219
|
-
const top = shown === null ? null : realOrSelf(
|
|
31380
|
+
const top = shown === null ? null : realOrSelf(resolve29(shown));
|
|
31220
31381
|
const missing = [];
|
|
31221
31382
|
for (const path of paths) {
|
|
31222
31383
|
const rel = top ? relative5(top, path) : null;
|
|
@@ -31240,7 +31401,7 @@ function sourcesInHead(git, raw, sources) {
|
|
|
31240
31401
|
]);
|
|
31241
31402
|
if (status === null)
|
|
31242
31403
|
return { ok: false, offending: paths, why: "modified" };
|
|
31243
|
-
const dirty = porcelainEntries(status).flatMap((entry) => [entry.path, entry.from].filter(Boolean).map((path) =>
|
|
31404
|
+
const dirty = porcelainEntries(status).flatMap((entry) => [entry.path, entry.from].filter(Boolean).map((path) => resolve29(top ?? ".", path)));
|
|
31244
31405
|
if (dirty.length > 0)
|
|
31245
31406
|
return { ok: false, offending: dirty, why: "modified" };
|
|
31246
31407
|
return { ok: true };
|
|
@@ -31248,19 +31409,19 @@ function sourcesInHead(git, raw, sources) {
|
|
|
31248
31409
|
function skipOutDir(git, entryPath, outDir) {
|
|
31249
31410
|
if (!outDir)
|
|
31250
31411
|
return [];
|
|
31251
|
-
const out =
|
|
31252
|
-
if (
|
|
31412
|
+
const out = resolve29(outDir);
|
|
31413
|
+
if (resolve29(entryPath).startsWith(out + sep6))
|
|
31253
31414
|
return [];
|
|
31254
31415
|
const top = git(["rev-parse", "--show-toplevel"]);
|
|
31255
31416
|
if (!top)
|
|
31256
31417
|
return [];
|
|
31257
|
-
const rel = relative5(
|
|
31418
|
+
const rel = relative5(resolve29(top), out);
|
|
31258
31419
|
if (!rel || rel.startsWith("..") || isAbsolute4(rel))
|
|
31259
31420
|
return [];
|
|
31260
31421
|
return ["--", ":(top)", `:(exclude,literal,top)${rel.split(sep6).join("/")}`];
|
|
31261
31422
|
}
|
|
31262
31423
|
function inferTaggedVersion(entryPath, sources) {
|
|
31263
|
-
const cwd =
|
|
31424
|
+
const cwd = resolve29(entryPath, "..");
|
|
31264
31425
|
const raw = (args) => {
|
|
31265
31426
|
try {
|
|
31266
31427
|
return execFileSync4("git", args, {
|
|
@@ -31290,7 +31451,7 @@ function inferTaggedVersion(entryPath, sources) {
|
|
|
31290
31451
|
function findEntry(dir) {
|
|
31291
31452
|
let names;
|
|
31292
31453
|
try {
|
|
31293
|
-
names =
|
|
31454
|
+
names = readdirSync21(dir);
|
|
31294
31455
|
} catch {
|
|
31295
31456
|
return [];
|
|
31296
31457
|
}
|
|
@@ -31298,9 +31459,9 @@ function findEntry(dir) {
|
|
|
31298
31459
|
for (const name of names) {
|
|
31299
31460
|
if (!/\.(mjs|js|ts)$/.test(name))
|
|
31300
31461
|
continue;
|
|
31301
|
-
const full =
|
|
31462
|
+
const full = resolve29(dir, name);
|
|
31302
31463
|
try {
|
|
31303
|
-
if (
|
|
31464
|
+
if (statSync26(full).size > 512 * 1024)
|
|
31304
31465
|
continue;
|
|
31305
31466
|
const text = readFileSync34(full, "utf8");
|
|
31306
31467
|
if (/from\s+["']failproofai["']/.test(text) && /customPolicies\s*\.\s*add\s*\(/.test(text)) {
|
|
@@ -31313,13 +31474,13 @@ function findEntry(dir) {
|
|
|
31313
31474
|
return found.sort();
|
|
31314
31475
|
}
|
|
31315
31476
|
function withLocalImports(sources) {
|
|
31316
|
-
const seen = new Set(sources.map((f) =>
|
|
31477
|
+
const seen = new Set(sources.map((f) => resolve29(f)));
|
|
31317
31478
|
const queue = [...seen];
|
|
31318
31479
|
while (queue.length > 0 && seen.size < 500) {
|
|
31319
31480
|
const file = queue.shift();
|
|
31320
31481
|
let text;
|
|
31321
31482
|
try {
|
|
31322
|
-
if (
|
|
31483
|
+
if (statSync26(file).size > 512 * 1024)
|
|
31323
31484
|
continue;
|
|
31324
31485
|
text = readFileSync34(file, "utf8");
|
|
31325
31486
|
} catch {
|
|
@@ -31327,13 +31488,13 @@ function withLocalImports(sources) {
|
|
|
31327
31488
|
}
|
|
31328
31489
|
for (const re of LOCAL_IMPORT_RES) {
|
|
31329
31490
|
for (const match of text.matchAll(re)) {
|
|
31330
|
-
const base =
|
|
31491
|
+
const base = resolve29(dirname21(file), match[1]);
|
|
31331
31492
|
for (const ext of LOCAL_IMPORT_EXTENSIONS) {
|
|
31332
31493
|
const candidate = base + ext;
|
|
31333
31494
|
if (seen.has(candidate))
|
|
31334
31495
|
break;
|
|
31335
31496
|
try {
|
|
31336
|
-
if (!
|
|
31497
|
+
if (!statSync26(candidate).isFile())
|
|
31337
31498
|
continue;
|
|
31338
31499
|
} catch {
|
|
31339
31500
|
continue;
|
|
@@ -31348,7 +31509,7 @@ function withLocalImports(sources) {
|
|
|
31348
31509
|
return [...seen];
|
|
31349
31510
|
}
|
|
31350
31511
|
function settleGitState(entryPath, provenance, packFiles, id, outDir) {
|
|
31351
|
-
const cwd =
|
|
31512
|
+
const cwd = resolve29(entryPath, "..");
|
|
31352
31513
|
const raw = (args) => {
|
|
31353
31514
|
try {
|
|
31354
31515
|
return execFileSync4("git", args, {
|
|
@@ -31423,11 +31584,11 @@ function settleGitState(entryPath, provenance, packFiles, id, outDir) {
|
|
|
31423
31584
|
if (root === null || status === null)
|
|
31424
31585
|
return null;
|
|
31425
31586
|
const entries = porcelainEntries(status);
|
|
31426
|
-
const dirty = entries.map((entry) =>
|
|
31427
|
-
const renamedFrom = entries.filter((entry) => entry.from).map((entry) =>
|
|
31587
|
+
const dirty = entries.map((entry) => resolve29(root, entry.path));
|
|
31588
|
+
const renamedFrom = entries.filter((entry) => entry.from).map((entry) => resolve29(root, entry.from));
|
|
31428
31589
|
if (dirty.length === 0)
|
|
31429
31590
|
return null;
|
|
31430
|
-
const mine = new Set(packFiles.map((f) =>
|
|
31591
|
+
const mine = new Set(packFiles.map((f) => resolve29(f)));
|
|
31431
31592
|
const foreign = dirty.filter((path) => !mine.has(path));
|
|
31432
31593
|
const toStage = [...dirty, ...renamedFrom];
|
|
31433
31594
|
if (foreign.length > 0) {
|
|
@@ -31558,7 +31719,7 @@ function pushExistingHistory(dir, owner, name, token) {
|
|
|
31558
31719
|
const branch = git(["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
31559
31720
|
if (!branch || branch === "HEAD" || !git(["rev-parse", "--verify", "HEAD"]))
|
|
31560
31721
|
return false;
|
|
31561
|
-
const askpass =
|
|
31722
|
+
const askpass = join40(mkdtempSync3(join40(tmpdir4(), "fpai-askpass-")), "askpass.sh");
|
|
31562
31723
|
try {
|
|
31563
31724
|
writeFileSync25(askpass, `#!/bin/sh
|
|
31564
31725
|
case "$1" in
|
|
@@ -31580,7 +31741,7 @@ esac
|
|
|
31580
31741
|
return true;
|
|
31581
31742
|
} finally {
|
|
31582
31743
|
try {
|
|
31583
|
-
rmSync17(
|
|
31744
|
+
rmSync17(dirname21(askpass), { recursive: true, force: true });
|
|
31584
31745
|
} catch {}
|
|
31585
31746
|
}
|
|
31586
31747
|
}
|
|
@@ -31604,8 +31765,8 @@ failproofai policies add ${owner}/${name}
|
|
|
31604
31765
|
function findBun() {
|
|
31605
31766
|
const candidates = [
|
|
31606
31767
|
"bun",
|
|
31607
|
-
process.env.BUN_INSTALL ?
|
|
31608
|
-
|
|
31768
|
+
process.env.BUN_INSTALL ? resolve29(process.env.BUN_INSTALL, "bin", "bun") : null,
|
|
31769
|
+
resolve29(homedir31(), ".bun", "bin", "bun"),
|
|
31609
31770
|
"/opt/homebrew/bin/bun",
|
|
31610
31771
|
"/usr/local/bin/bun"
|
|
31611
31772
|
].filter((c) => c !== null);
|
|
@@ -31632,11 +31793,11 @@ function bundleEntry(sources, outDir) {
|
|
|
31632
31793
|
};
|
|
31633
31794
|
}
|
|
31634
31795
|
mkdirSync27(outDir, { recursive: true });
|
|
31635
|
-
const entry =
|
|
31636
|
-
writeFileSync25(entry, sources.map((f) => `import ${JSON.stringify(f.startsWith("/") ? f :
|
|
31796
|
+
const entry = resolve29(outDir, ".entry.generated.mjs");
|
|
31797
|
+
writeFileSync25(entry, sources.map((f) => `import ${JSON.stringify(f.startsWith("/") ? f : resolve29(f))};`).join(`
|
|
31637
31798
|
`) + `
|
|
31638
31799
|
`, "utf8");
|
|
31639
|
-
const bundled =
|
|
31800
|
+
const bundled = resolve29(outDir, ".bundled.mjs");
|
|
31640
31801
|
try {
|
|
31641
31802
|
execFileSync4(bun, [
|
|
31642
31803
|
"build",
|
|
@@ -31749,12 +31910,12 @@ async function publish(rest) {
|
|
|
31749
31910
|
if (askingWhere) {
|
|
31750
31911
|
const found = discovered.length > 0 ? discovered : [entry];
|
|
31751
31912
|
process.stdout.write(`
|
|
31752
|
-
${found.length} policy ${found.length === 1 ? "file" : "files"}: ` + `${found.map((f) =>
|
|
31913
|
+
${found.length} policy ${found.length === 1 ? "file" : "files"}: ` + `${found.map((f) => basename9(f)).join(", ")}
|
|
31753
31914
|
|
|
31754
31915
|
`);
|
|
31755
31916
|
const token = githubToken();
|
|
31756
31917
|
const login = token ? await credentialLogin(token) : null;
|
|
31757
|
-
const folder =
|
|
31918
|
+
const folder = basename9(resolve29(entry, ".."));
|
|
31758
31919
|
const answered = await askWhereToPublish(`${login ?? "your-account"}/${folder}`, { stdin: process.stdin, stdout: process.stdout });
|
|
31759
31920
|
if (answered === null)
|
|
31760
31921
|
return ok2(["Nothing was published."]);
|
|
@@ -31765,7 +31926,7 @@ async function publish(rest) {
|
|
|
31765
31926
|
let versionFromSha = false;
|
|
31766
31927
|
const dryRun = rest.includes("--dry-run") || !repo;
|
|
31767
31928
|
const allowPrivate = rest.includes("--allow-private");
|
|
31768
|
-
const id = flag("id") ?? repo ?? (dryRun && entry ? `local/${
|
|
31929
|
+
const id = flag("id") ?? repo ?? (dryRun && entry ? `local/${basename9(resolve29(entry, ".."))}` : undefined);
|
|
31769
31930
|
const [owner, name] = (repo ?? "/").split("/");
|
|
31770
31931
|
if (repo && (!owner || !name || repo.split("/").length !== 2)) {
|
|
31771
31932
|
return fail2([`--repo must be <owner>/<repo>, got ${JSON.stringify(repo)}`]);
|
|
@@ -31784,7 +31945,7 @@ async function publish(rest) {
|
|
|
31784
31945
|
"With no --repo it writes the three release assets and stops."
|
|
31785
31946
|
]);
|
|
31786
31947
|
}
|
|
31787
|
-
const outDirEarly =
|
|
31948
|
+
const outDirEarly = resolve29(flag("out") ?? "dist-pack");
|
|
31788
31949
|
let provenance = entry ? inferCommit(entry, outDirEarly, bundledSources) : null;
|
|
31789
31950
|
const gitLines = [];
|
|
31790
31951
|
if (!version && entry && interactive) {
|
|
@@ -31824,7 +31985,7 @@ async function publish(rest) {
|
|
|
31824
31985
|
"It needs write access to releases on that repository, and nothing else."
|
|
31825
31986
|
]);
|
|
31826
31987
|
}
|
|
31827
|
-
const ensured = await ensureRepo(owner, name, id, token,
|
|
31988
|
+
const ensured = await ensureRepo(owner, name, id, token, resolve29(entry, ".."));
|
|
31828
31989
|
if ("error" in ensured)
|
|
31829
31990
|
return fail2(ensured.error);
|
|
31830
31991
|
created = ensured.created;
|
|
@@ -31923,7 +32084,7 @@ async function publish(rest) {
|
|
|
31923
32084
|
if (prior) {
|
|
31924
32085
|
await gh(`${GITHUB_API2}/repos/${owner}/${name}/releases/assets/${prior.id}`, auth, { method: "DELETE" });
|
|
31925
32086
|
}
|
|
31926
|
-
const bytes = readFileSync34(
|
|
32087
|
+
const bytes = readFileSync34(resolve29(outDir, asset));
|
|
31927
32088
|
const upload = await gh(`${GITHUB_UPLOADS2}/repos/${owner}/${name}/releases/${releaseId}/assets?name=${encodeURIComponent(asset)}`, auth, {
|
|
31928
32089
|
method: "POST",
|
|
31929
32090
|
contentType: asset.endsWith(".json") ? "application/json" : "application/octet-stream",
|
|
@@ -32604,8 +32765,8 @@ var init_install_prompt = __esm(() => {
|
|
|
32604
32765
|
|
|
32605
32766
|
// src/hooks/manager.ts
|
|
32606
32767
|
import { execSync as execSync7 } from "node:child_process";
|
|
32607
|
-
import { existsSync as
|
|
32608
|
-
import { resolve as
|
|
32768
|
+
import { existsSync as existsSync44 } from "node:fs";
|
|
32769
|
+
import { resolve as resolve30, basename as basename10 } from "node:path";
|
|
32609
32770
|
import { platform as platform4, arch as arch4, release as release3, hostname as hostname6 } from "node:os";
|
|
32610
32771
|
function getSettingsPath2(scope, cwd) {
|
|
32611
32772
|
return claudeCode.getSettingsPath(scope, cwd);
|
|
@@ -32824,9 +32985,9 @@ async function installHooksImpl2(policyNames, scope = "user", cwd, includeBeta =
|
|
|
32824
32985
|
delete configToWrite.customPoliciesPath;
|
|
32825
32986
|
delete configToWrite.customPoliciesPaths;
|
|
32826
32987
|
} else if (customPoliciesPath && (typeof customPoliciesPath === "string" || customPoliciesPath.length > 0)) {
|
|
32827
|
-
const incoming = (typeof customPoliciesPath === "string" ? [customPoliciesPath] : customPoliciesPath).map((path) =>
|
|
32828
|
-
const carried = (previousConfig.customPoliciesPaths ?? (previousConfig.customPoliciesPath ? [previousConfig.customPoliciesPath] : [])).map((path) =>
|
|
32829
|
-
if (
|
|
32988
|
+
const incoming = (typeof customPoliciesPath === "string" ? [customPoliciesPath] : customPoliciesPath).map((path) => resolve30(path));
|
|
32989
|
+
const carried = (previousConfig.customPoliciesPaths ?? (previousConfig.customPoliciesPath ? [previousConfig.customPoliciesPath] : [])).map((path) => resolve30(path)).filter((path) => {
|
|
32990
|
+
if (existsSync44(path))
|
|
32830
32991
|
return true;
|
|
32831
32992
|
console.log(`Dropping custom policies path (file no longer exists): ${path}`);
|
|
32832
32993
|
return false;
|
|
@@ -33049,7 +33210,7 @@ async function removeHooks2(policyNames, scope = "user", cwd, opts) {
|
|
|
33049
33210
|
const scopesToRemove = scope === "all" ? [...integration.scopes] : integration.scopes.includes(scope) ? [scope] : [];
|
|
33050
33211
|
for (const s of scopesToRemove) {
|
|
33051
33212
|
const settingsPaths = settingsPathsFor(integration, s, cwd);
|
|
33052
|
-
const existing = settingsPaths.filter((p) =>
|
|
33213
|
+
const existing = settingsPaths.filter((p) => existsSync44(p));
|
|
33053
33214
|
if (existing.length === 0) {
|
|
33054
33215
|
if (scope !== "all" && selectedClis.length === 1) {
|
|
33055
33216
|
console.log("No settings file found. Nothing to remove.");
|
|
@@ -33193,9 +33354,9 @@ async function listHooks(cwd) {
|
|
|
33193
33354
|
if (explicitPaths.length > 0) {
|
|
33194
33355
|
groups.push(rule("Custom Policies", opts));
|
|
33195
33356
|
for (const path of explicitPaths) {
|
|
33196
|
-
const absPath =
|
|
33357
|
+
const absPath = resolve30(findProjectConfigDir(cwd ?? process.cwd()), path);
|
|
33197
33358
|
groups.push(note(absPath, opts));
|
|
33198
|
-
if (!
|
|
33359
|
+
if (!existsSync44(absPath)) {
|
|
33199
33360
|
groups.push(warning([`file not found: ${absPath}`], opts));
|
|
33200
33361
|
continue;
|
|
33201
33362
|
}
|
|
@@ -33215,7 +33376,7 @@ async function listHooks(cwd) {
|
|
|
33215
33376
|
}
|
|
33216
33377
|
}
|
|
33217
33378
|
const base = findProjectConfigDir(cwd ?? process.cwd());
|
|
33218
|
-
const projectDir =
|
|
33379
|
+
const projectDir = resolve30(base, ".failproofai", "policies");
|
|
33219
33380
|
const userDir = customPoliciesDir();
|
|
33220
33381
|
const sameDir = userDir === projectDir;
|
|
33221
33382
|
const conventionDirs = [
|
|
@@ -33240,7 +33401,7 @@ async function listHooks(cwd) {
|
|
|
33240
33401
|
groups.push(note(dir, opts));
|
|
33241
33402
|
const rows = [];
|
|
33242
33403
|
for (const file of files) {
|
|
33243
|
-
const filename =
|
|
33404
|
+
const filename = basename10(file);
|
|
33244
33405
|
try {
|
|
33245
33406
|
const hooks = await loadCustomHooks(file);
|
|
33246
33407
|
record(filename, hooks.map((h) => h.name));
|
|
@@ -33694,14 +33855,14 @@ var init_schedule_cli = __esm(() => {
|
|
|
33694
33855
|
});
|
|
33695
33856
|
|
|
33696
33857
|
// scripts/parse-script-args.ts
|
|
33697
|
-
import { resolve as
|
|
33858
|
+
import { resolve as resolve31 } from "path";
|
|
33698
33859
|
function parseStringFlag(flagName, errorLabel, inlineValue, args, index, options) {
|
|
33699
33860
|
const raw = inlineValue ?? args[index + 1];
|
|
33700
33861
|
if (raw === undefined || inlineValue === null && raw.startsWith("-")) {
|
|
33701
33862
|
console.error(`Error: ${flagName} requires ${errorLabel}`);
|
|
33702
33863
|
process.exit(1);
|
|
33703
33864
|
}
|
|
33704
|
-
const value = options?.resolve ?
|
|
33865
|
+
const value = options?.resolve ? resolve31(raw) : raw;
|
|
33705
33866
|
return { value, spliceCount: inlineValue !== null ? 1 : 2 };
|
|
33706
33867
|
}
|
|
33707
33868
|
function parseScriptArgs(argv) {
|
|
@@ -33757,26 +33918,26 @@ function parseScriptArgs(argv) {
|
|
|
33757
33918
|
var init_parse_script_args = () => {};
|
|
33758
33919
|
|
|
33759
33920
|
// scripts/install-diagnosis.mjs
|
|
33760
|
-
import { existsSync as
|
|
33761
|
-
import { dirname as
|
|
33762
|
-
import { homedir as
|
|
33921
|
+
import { existsSync as existsSync45, readFileSync as readFileSync36, realpathSync as realpathSync4 } from "node:fs";
|
|
33922
|
+
import { dirname as dirname22, resolve as resolve32 } from "node:path";
|
|
33923
|
+
import { homedir as homedir32, platform as platform5 } from "node:os";
|
|
33763
33924
|
import { spawnSync } from "node:child_process";
|
|
33764
33925
|
function findPackageRoot(start) {
|
|
33765
33926
|
try {
|
|
33766
33927
|
let dir = realpathSync4(start);
|
|
33767
|
-
if (
|
|
33768
|
-
dir =
|
|
33928
|
+
if (existsSync45(dir) && !existsSync45(resolve32(dir, "package.json"))) {
|
|
33929
|
+
dir = dirname22(dir);
|
|
33769
33930
|
}
|
|
33770
33931
|
while (true) {
|
|
33771
|
-
const pkgPath =
|
|
33772
|
-
if (
|
|
33932
|
+
const pkgPath = resolve32(dir, "package.json");
|
|
33933
|
+
if (existsSync45(pkgPath)) {
|
|
33773
33934
|
try {
|
|
33774
33935
|
const pkg = JSON.parse(readFileSync36(pkgPath, "utf8"));
|
|
33775
33936
|
if (pkg.name === PKG_NAME)
|
|
33776
33937
|
return dir;
|
|
33777
33938
|
} catch {}
|
|
33778
33939
|
}
|
|
33779
|
-
const parent =
|
|
33940
|
+
const parent = dirname22(dir);
|
|
33780
33941
|
if (parent === dir)
|
|
33781
33942
|
return null;
|
|
33782
33943
|
dir = parent;
|
|
@@ -33789,7 +33950,7 @@ function readPackageVersion(packageRoot) {
|
|
|
33789
33950
|
if (!packageRoot)
|
|
33790
33951
|
return null;
|
|
33791
33952
|
try {
|
|
33792
|
-
const pkg = JSON.parse(readFileSync36(
|
|
33953
|
+
const pkg = JSON.parse(readFileSync36(resolve32(packageRoot, "package.json"), "utf8"));
|
|
33793
33954
|
return typeof pkg.version === "string" ? pkg.version : null;
|
|
33794
33955
|
} catch {
|
|
33795
33956
|
return null;
|
|
@@ -33815,16 +33976,16 @@ function locateNpmGlobal() {
|
|
|
33815
33976
|
const root = (res.stdout || "").trim();
|
|
33816
33977
|
if (!root)
|
|
33817
33978
|
return null;
|
|
33818
|
-
const candidate =
|
|
33819
|
-
return
|
|
33979
|
+
const candidate = resolve32(root, PKG_NAME);
|
|
33980
|
+
return existsSync45(resolve32(candidate, "package.json")) ? candidate : null;
|
|
33820
33981
|
} catch {
|
|
33821
33982
|
return null;
|
|
33822
33983
|
}
|
|
33823
33984
|
}
|
|
33824
33985
|
function locateBunGlobal() {
|
|
33825
33986
|
try {
|
|
33826
|
-
const candidate =
|
|
33827
|
-
return
|
|
33987
|
+
const candidate = resolve32(homedir32(), ".bun", "install", "global", "node_modules", PKG_NAME);
|
|
33988
|
+
return existsSync45(resolve32(candidate, "package.json")) ? candidate : null;
|
|
33828
33989
|
} catch {
|
|
33829
33990
|
return null;
|
|
33830
33991
|
}
|
|
@@ -33832,8 +33993,8 @@ function locateBunGlobal() {
|
|
|
33832
33993
|
function buildRecommendation(pathFirstBin) {
|
|
33833
33994
|
if (!pathFirstBin)
|
|
33834
33995
|
return null;
|
|
33835
|
-
const bunBinPrefix =
|
|
33836
|
-
const bunGlobalPrefix =
|
|
33996
|
+
const bunBinPrefix = resolve32(homedir32(), ".bun", "bin") + "/";
|
|
33997
|
+
const bunGlobalPrefix = resolve32(homedir32(), ".bun", "install", "global") + "/";
|
|
33837
33998
|
const isBun = pathFirstBin.startsWith(bunBinPrefix) || pathFirstBin.startsWith(bunGlobalPrefix);
|
|
33838
33999
|
if (isBun) {
|
|
33839
34000
|
return `rm -f ~/.bun/bin/${PKG_NAME} && rm -rf ~/.bun/install/global/node_modules/${PKG_NAME}`;
|
|
@@ -33927,8 +34088,8 @@ var init_dashboard_host = __esm(() => {
|
|
|
33927
34088
|
|
|
33928
34089
|
// scripts/launch.ts
|
|
33929
34090
|
import { spawn as spawn2 } from "child_process";
|
|
33930
|
-
import { realpathSync as realpathSync5, existsSync as
|
|
33931
|
-
import { resolve as
|
|
34091
|
+
import { realpathSync as realpathSync5, existsSync as existsSync46 } from "node:fs";
|
|
34092
|
+
import { resolve as resolve33, dirname as dirname23 } from "node:path";
|
|
33932
34093
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
33933
34094
|
import { createInterface } from "node:readline";
|
|
33934
34095
|
function launch(mode) {
|
|
@@ -33952,9 +34113,9 @@ function launch(mode) {
|
|
|
33952
34113
|
process.env.PORT = port;
|
|
33953
34114
|
process.env.HOSTNAME = bindHost;
|
|
33954
34115
|
cmd = "node";
|
|
33955
|
-
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ??
|
|
33956
|
-
const serverJsPath =
|
|
33957
|
-
if (!
|
|
34116
|
+
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ?? resolve33(dirname23(realpathSync5(fileURLToPath2(import.meta.url))), "..");
|
|
34117
|
+
const serverJsPath = resolve33(packageRoot, ".next/standalone/server.js");
|
|
34118
|
+
if (!existsSync46(serverJsPath)) {
|
|
33958
34119
|
let shadowMessage = null;
|
|
33959
34120
|
try {
|
|
33960
34121
|
const diag = diagnoseShadow({ selfPackageRoot: packageRoot, selfVersion: version2 });
|
|
@@ -34709,8 +34870,8 @@ var init_session_pause_cli = __esm(() => {
|
|
|
34709
34870
|
|
|
34710
34871
|
// scripts/launch.ts
|
|
34711
34872
|
import { spawn as spawn3 } from "child_process";
|
|
34712
|
-
import { realpathSync as realpathSync6, existsSync as
|
|
34713
|
-
import { resolve as
|
|
34873
|
+
import { realpathSync as realpathSync6, existsSync as existsSync47 } from "node:fs";
|
|
34874
|
+
import { resolve as resolve34, dirname as dirname24 } from "node:path";
|
|
34714
34875
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
34715
34876
|
import { createInterface as createInterface2 } from "node:readline";
|
|
34716
34877
|
function launch2(mode) {
|
|
@@ -34734,9 +34895,9 @@ function launch2(mode) {
|
|
|
34734
34895
|
process.env.PORT = port;
|
|
34735
34896
|
process.env.HOSTNAME = bindHost;
|
|
34736
34897
|
cmd = "node";
|
|
34737
|
-
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ??
|
|
34738
|
-
const serverJsPath =
|
|
34739
|
-
if (!
|
|
34898
|
+
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ?? resolve34(dirname24(realpathSync6(fileURLToPath3(import.meta.url))), "..");
|
|
34899
|
+
const serverJsPath = resolve34(packageRoot, ".next/standalone/server.js");
|
|
34900
|
+
if (!existsSync47(serverJsPath)) {
|
|
34740
34901
|
let shadowMessage = null;
|
|
34741
34902
|
try {
|
|
34742
34903
|
const diag = diagnoseShadow({ selfPackageRoot: packageRoot, selfVersion: version2 });
|
|
@@ -34833,17 +34994,17 @@ var init_cli_error2 = __esm(() => {
|
|
|
34833
34994
|
|
|
34834
34995
|
// bin/failproofai.mjs
|
|
34835
34996
|
import { realpathSync as realpathSync7 } from "fs";
|
|
34836
|
-
import { dirname as
|
|
34997
|
+
import { dirname as dirname25, resolve as resolve35 } from "path";
|
|
34837
34998
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
34838
34999
|
// package.json
|
|
34839
|
-
var version = "1.0.5
|
|
35000
|
+
var version = "1.0.5";
|
|
34840
35001
|
|
|
34841
35002
|
// bin/failproofai.mjs
|
|
34842
35003
|
if (!process.env.FAILPROOFAI_PACKAGE_ROOT) {
|
|
34843
|
-
process.env.FAILPROOFAI_PACKAGE_ROOT =
|
|
35004
|
+
process.env.FAILPROOFAI_PACKAGE_ROOT = resolve35(dirname25(realpathSync7(fileURLToPath4(import.meta.url))), "..");
|
|
34844
35005
|
}
|
|
34845
35006
|
if (!process.env.FAILPROOFAI_DIST_PATH) {
|
|
34846
|
-
process.env.FAILPROOFAI_DIST_PATH =
|
|
35007
|
+
process.env.FAILPROOFAI_DIST_PATH = resolve35(dirname25(realpathSync7(fileURLToPath4(import.meta.url))), "..", "dist");
|
|
34847
35008
|
}
|
|
34848
35009
|
var args = process.argv.slice(2);
|
|
34849
35010
|
if (args[0] === "p" || args[0] === "policy")
|