failproofai 1.0.5-beta.0 → 1.0.5-beta.2
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 +3 -3
- 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 +4 -4
- package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js +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 +2 -2
- 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 +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/{[externals]__0-9ti7z._.js → [externals]__1_bftcl._.js} +1 -1
- package/.next/standalone/.next/server/chunks/{[externals]__0u3wrvq._.js → [externals]__1msfs-h._.js} +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__08dchfu._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0faqz9x._.js +22 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0zyc_nm._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__1p-qi2t._.js → [root-of-the-server]__112b4go._.js} +22 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1l71g3y._.js +22 -0
- 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/{_1-akg6w._.js → _1c3k-8x._.js} +2 -2
- package/.next/standalone/.next/server/chunks/_1ek68ln._.js +1 -1
- package/.next/standalone/.next/server/chunks/_1vslkoe._.js +1 -1
- package/.next/standalone/.next/server/chunks/lib_openclaw-projects_ts_0gc-p24._.js +3 -0
- 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]__1sc84bb._.js → [root-of-the-server]__00y9ww2._.js} +21 -2
- 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]__190won8._.js → [root-of-the-server]__0sz_5na._.js} +1 -1
- 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]__1kaotix._.js +22 -0
- 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]__00-s7h8._.js → [root-of-the-server]__1u6sn69._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0x1aj1_._.js → [root-of-the-server]__1xu5t8b._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_1if9ixi._.js → _14c6q09._.js} +21 -2
- package/.next/standalone/.next/server/chunks/ssr/_1_ozgif._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1es2j7i._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{_0zs_4uu._.js → _1mo4bp9._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_0u3xxgc._.js → _1olen4g._.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_openclaw-projects_ts_0qxq3bp._.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/{0oos8qpc1ugos.js → 04cawl3i7gqi5.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0hw6-c206lsma.js → 0671mdu5plc8o.js} +1 -1
- package/.next/standalone/.next/static/chunks/{33umhy-x204qj.js → 0cn62s92buqr1.js} +2 -2
- package/.next/standalone/.next/static/chunks/{2zafgs90r_leq.js → 0h95tsad4_-gr.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3nux7kkrc3eps.js → 0pdmk3xha1zih.js} +1 -1
- package/.next/standalone/.next/static/chunks/{40tpgs4fjct5p.js → 1oey07bwm1ayr.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0unrx9g_x0u7j.js → 1qwk_vp6dsat_.js} +1 -1
- package/.next/standalone/.next/static/chunks/{40uih96wnkowy.js → 2pnvnpg-kdbyt.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3i8rg2fv9nd6e.js → 315zh293r-n7v.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2xbxkaszi1xnw.js → 3aoj_ov89ym_h.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2qjn-leir0x_s.js → 3gfi5ixrc6v1z.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0m9sx3khjrl1q.js → 3k3g_4k13t9za.js} +1 -1
- package/.next/standalone/.next/static/chunks/{turbopack-3p73obe0xmrxm.js → turbopack-44avr18ueo9ob.js} +1 -1
- package/.next/standalone/fp-cloud-cli/CHANGELOG.md +7 -0
- package/.next/standalone/fp-cloud-cli/fp_cli/_version.py +1 -1
- package/.next/standalone/lib/download-session.ts +58 -13
- package/.next/standalone/lib/openclaw-db.ts +271 -0
- package/.next/standalone/lib/openclaw-profiles.ts +78 -0
- package/.next/standalone/lib/openclaw-projects.ts +57 -21
- package/.next/standalone/lib/openclaw-sessions.ts +75 -17
- package/.next/standalone/lib/sqlite-reader.ts +165 -9
- package/.next/standalone/package.json +9 -9
- package/.next/standalone/sdk/python/CHANGELOG.md +7 -0
- package/.next/standalone/sdk/python/failproofai_sdk/_version.py +1 -1
- package/.next/standalone/server.js +1 -1
- package/dist/cli.mjs +1065 -693
- package/dist/worker.mjs +425 -102
- package/lib/download-session.ts +58 -13
- package/lib/openclaw-db.ts +271 -0
- package/lib/openclaw-profiles.ts +78 -0
- package/lib/openclaw-projects.ts +57 -21
- package/lib/openclaw-sessions.ts +75 -17
- package/lib/sqlite-reader.ts +165 -9
- package/openclaw-plugin/index.js +22 -12
- package/openclaw-plugin/instruct-retry-gate.js +89 -0
- package/openclaw-plugin/workspace-context.js +93 -0
- package/package.json +9 -9
- package/src/hooks/integrations.ts +22 -14
- package/src/hooks/policy-evaluator.ts +22 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0-219ec._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__04_h-a5._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1le9jqc._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1nq7ivq._.js +0 -3
- /package/.next/standalone/.next/static/{4_QeL7mSPYsuiSVJmBOTj → GDwSJ81wNHeh1pQdxpvk_}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{4_QeL7mSPYsuiSVJmBOTj → GDwSJ81wNHeh1pQdxpvk_}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{4_QeL7mSPYsuiSVJmBOTj → GDwSJ81wNHeh1pQdxpvk_}/_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-beta.
|
|
32
|
+
var version2 = "1.0.5-beta.2", 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-beta.
|
|
158
|
-
"@failproofai/failproofaid-linux-arm64": "1.0.5-beta.
|
|
159
|
-
"@failproofai/failproofaid-darwin-x64": "1.0.5-beta.
|
|
160
|
-
"@failproofai/failproofaid-darwin-arm64": "1.0.5-beta.
|
|
157
|
+
"@failproofai/failproofaid-linux-x64": "1.0.5-beta.2",
|
|
158
|
+
"@failproofai/failproofaid-linux-arm64": "1.0.5-beta.2",
|
|
159
|
+
"@failproofai/failproofaid-darwin-x64": "1.0.5-beta.2",
|
|
160
|
+
"@failproofai/failproofaid-darwin-arm64": "1.0.5-beta.2"
|
|
161
161
|
},
|
|
162
162
|
failproofaidBinaries: {
|
|
163
|
-
"linux-x64": "
|
|
164
|
-
"linux-arm64": "
|
|
165
|
-
"darwin-x64": "
|
|
166
|
-
"darwin-arm64": "
|
|
163
|
+
"linux-x64": "cce0b612f53a28591a0eb6f3e1abe7cadfc490afedff85c8f55772e76c7be566",
|
|
164
|
+
"linux-arm64": "20ead289387082e38e456cef27271ff74df368ec90389ce4f818af73af24cfa1",
|
|
165
|
+
"darwin-x64": "9a6fc5c2aa250224aea7fa7b945230636d34e7aea454177c131d40a5f56e17a1",
|
|
166
|
+
"darwin-arm64": "fb26aa5ffbbc971b9923593dc6f5a05f1d20b7d5e9953172b81318038252a240"
|
|
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))
|
|
@@ -15856,6 +15905,22 @@ You MUST complete the above action(s) NOW. Do NOT ask the user for confirmation
|
|
|
15856
15905
|
decision: "instruct"
|
|
15857
15906
|
};
|
|
15858
15907
|
}
|
|
15908
|
+
if (eventType === "PreToolUse") {
|
|
15909
|
+
return {
|
|
15910
|
+
exitCode: 0,
|
|
15911
|
+
stdout: JSON.stringify({
|
|
15912
|
+
permission: "instruct",
|
|
15913
|
+
reason: `Instruction from failproofai: ${combined}`,
|
|
15914
|
+
policyName: policyNames[0],
|
|
15915
|
+
policyNames
|
|
15916
|
+
}),
|
|
15917
|
+
stderr: "",
|
|
15918
|
+
policyName: policyNames[0],
|
|
15919
|
+
policyNames,
|
|
15920
|
+
reason: combined,
|
|
15921
|
+
decision: "instruct"
|
|
15922
|
+
};
|
|
15923
|
+
}
|
|
15859
15924
|
const stderrMsg = instructEntries.map((e) => `[failproofai] ${e.policyName}: ${e.reason}`).join(`
|
|
15860
15925
|
`);
|
|
15861
15926
|
return {
|
|
@@ -16114,21 +16179,21 @@ import {
|
|
|
16114
16179
|
writeFileSync as writeFileSync5,
|
|
16115
16180
|
appendFileSync as appendFileSync2,
|
|
16116
16181
|
renameSync as renameSync3,
|
|
16117
|
-
readdirSync as
|
|
16182
|
+
readdirSync as readdirSync4,
|
|
16118
16183
|
mkdirSync as mkdirSync6,
|
|
16119
|
-
existsSync as
|
|
16184
|
+
existsSync as existsSync10,
|
|
16120
16185
|
statSync as statSync5,
|
|
16121
16186
|
unlinkSync as unlinkSync2
|
|
16122
16187
|
} from "node:fs";
|
|
16123
|
-
import { join as
|
|
16188
|
+
import { join as join6 } from "node:path";
|
|
16124
16189
|
function ensureDir() {
|
|
16125
|
-
if (!
|
|
16190
|
+
if (!existsSync10(storeDirValue())) {
|
|
16126
16191
|
mkdirSync6(storeDirValue(), { recursive: true });
|
|
16127
16192
|
}
|
|
16128
16193
|
}
|
|
16129
16194
|
function acquireLock() {
|
|
16130
16195
|
ensureDir();
|
|
16131
|
-
const lockPath =
|
|
16196
|
+
const lockPath = join6(storeDirValue(), LOCK_FILE);
|
|
16132
16197
|
const deadline = Date.now() + LOCK_STALE_MS;
|
|
16133
16198
|
while (Date.now() < deadline) {
|
|
16134
16199
|
try {
|
|
@@ -16149,15 +16214,15 @@ function acquireLock() {
|
|
|
16149
16214
|
}
|
|
16150
16215
|
function releaseLock() {
|
|
16151
16216
|
try {
|
|
16152
|
-
unlinkSync2(
|
|
16217
|
+
unlinkSync2(join6(storeDirValue(), LOCK_FILE));
|
|
16153
16218
|
} catch {}
|
|
16154
16219
|
}
|
|
16155
16220
|
function persistHookActivity(entry) {
|
|
16156
16221
|
ensureDir();
|
|
16157
16222
|
acquireLock();
|
|
16158
16223
|
try {
|
|
16159
|
-
const currentPath =
|
|
16160
|
-
const countPath =
|
|
16224
|
+
const currentPath = join6(storeDirValue(), CURRENT_FILE);
|
|
16225
|
+
const countPath = join6(storeDirValue(), COUNT_FILE);
|
|
16161
16226
|
const lineCount = readCount(countPath);
|
|
16162
16227
|
if (lineCount >= PAGE_SIZE) {
|
|
16163
16228
|
try {
|
|
@@ -16177,7 +16242,7 @@ function persistHookActivity(entry) {
|
|
|
16177
16242
|
}
|
|
16178
16243
|
function rotate(currentPath, countPath) {
|
|
16179
16244
|
const archiveName = `page-${Date.now()}-${rotateSeq++}.jsonl`;
|
|
16180
|
-
const archivePath =
|
|
16245
|
+
const archivePath = join6(storeDirValue(), archiveName);
|
|
16181
16246
|
renameSync3(currentPath, archivePath);
|
|
16182
16247
|
writeCount(countPath, 0);
|
|
16183
16248
|
}
|
|
@@ -16203,7 +16268,7 @@ function readFileSafe(filePath) {
|
|
|
16203
16268
|
}
|
|
16204
16269
|
function readStoredStats() {
|
|
16205
16270
|
try {
|
|
16206
|
-
return JSON.parse(readFileSync7(
|
|
16271
|
+
return JSON.parse(readFileSync7(join6(storeDirValue(), STATS_FILE), "utf-8"));
|
|
16207
16272
|
} catch {
|
|
16208
16273
|
return { totalEvents: 0, denyCount: 0, policyMap: {} };
|
|
16209
16274
|
}
|
|
@@ -16221,10 +16286,10 @@ function foldEntry(s, entry) {
|
|
|
16221
16286
|
}
|
|
16222
16287
|
}
|
|
16223
16288
|
function writeStoredStats(s) {
|
|
16224
|
-
const tmpPath =
|
|
16289
|
+
const tmpPath = join6(storeDirValue(), `stats.json.${process.pid}.tmp`);
|
|
16225
16290
|
try {
|
|
16226
16291
|
writeFileSync5(tmpPath, JSON.stringify(s), "utf-8");
|
|
16227
|
-
renameSync3(tmpPath,
|
|
16292
|
+
renameSync3(tmpPath, join6(storeDirValue(), STATS_FILE));
|
|
16228
16293
|
return true;
|
|
16229
16294
|
} catch {
|
|
16230
16295
|
try {
|
|
@@ -16244,8 +16309,8 @@ function rebuildHookActivityStats() {
|
|
|
16244
16309
|
const s = { totalEvents: 0, denyCount: 0, policyMap: {} };
|
|
16245
16310
|
let sawAny = false;
|
|
16246
16311
|
for (const file of files) {
|
|
16247
|
-
const path =
|
|
16248
|
-
if (!
|
|
16312
|
+
const path = join6(storeDirValue(), file);
|
|
16313
|
+
if (!existsSync10(path))
|
|
16249
16314
|
continue;
|
|
16250
16315
|
sawAny = true;
|
|
16251
16316
|
for (const entry of readJsonlFile(path))
|
|
@@ -16257,12 +16322,12 @@ function rebuildHookActivityStats() {
|
|
|
16257
16322
|
}
|
|
16258
16323
|
function getAllHookActivityEntries() {
|
|
16259
16324
|
ensureDir();
|
|
16260
|
-
const currentPath =
|
|
16325
|
+
const currentPath = join6(storeDirValue(), CURRENT_FILE);
|
|
16261
16326
|
const currentEntries = readJsonlFile(currentPath).reverse();
|
|
16262
16327
|
const archives = getArchiveFiles();
|
|
16263
16328
|
const archiveEntries = [];
|
|
16264
16329
|
for (const file of archives) {
|
|
16265
|
-
const entries = readJsonlFile(
|
|
16330
|
+
const entries = readJsonlFile(join6(storeDirValue(), file));
|
|
16266
16331
|
archiveEntries.push(...entries.reverse());
|
|
16267
16332
|
}
|
|
16268
16333
|
return [...currentEntries, ...archiveEntries];
|
|
@@ -16292,7 +16357,7 @@ function readJsonlFile(filePath) {
|
|
|
16292
16357
|
}
|
|
16293
16358
|
function getArchiveFiles() {
|
|
16294
16359
|
try {
|
|
16295
|
-
const files =
|
|
16360
|
+
const files = readdirSync4(storeDirValue());
|
|
16296
16361
|
return files.filter((f) => f.startsWith("page-") && f.endsWith(".jsonl")).sort((a, b) => {
|
|
16297
16362
|
const partsA = a.slice(5, -6).split("-");
|
|
16298
16363
|
const partsB = b.slice(5, -6).split("-");
|
|
@@ -16314,8 +16379,8 @@ var init_hook_activity_store = __esm(() => {
|
|
|
16314
16379
|
});
|
|
16315
16380
|
|
|
16316
16381
|
// src/hooks/delivery-health.ts
|
|
16317
|
-
import { existsSync as
|
|
16318
|
-
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";
|
|
16319
16384
|
function parseParkedName(name) {
|
|
16320
16385
|
const poison = name.endsWith(POISON_SUFFIX);
|
|
16321
16386
|
const withoutPoison = poison ? name.slice(0, -POISON_SUFFIX.length) : name;
|
|
@@ -16343,11 +16408,11 @@ function parseParkedName(name) {
|
|
|
16343
16408
|
}
|
|
16344
16409
|
function deliveryHealth(home, now = Date.now()) {
|
|
16345
16410
|
const dir = failedDir(home);
|
|
16346
|
-
if (!
|
|
16411
|
+
if (!existsSync11(dir))
|
|
16347
16412
|
return EMPTY;
|
|
16348
16413
|
let entries;
|
|
16349
16414
|
try {
|
|
16350
|
-
entries =
|
|
16415
|
+
entries = readdirSync5(dir);
|
|
16351
16416
|
} catch {
|
|
16352
16417
|
return EMPTY;
|
|
16353
16418
|
}
|
|
@@ -16368,7 +16433,7 @@ function deliveryHealth(home, now = Date.now()) {
|
|
|
16368
16433
|
credentialRejected += 1;
|
|
16369
16434
|
}
|
|
16370
16435
|
try {
|
|
16371
|
-
const mtime = statSync6(
|
|
16436
|
+
const mtime = statSync6(join7(dir, name)).mtimeMs;
|
|
16372
16437
|
if (oldestMtime === undefined || mtime < oldestMtime)
|
|
16373
16438
|
oldestMtime = mtime;
|
|
16374
16439
|
} catch {}
|
|
@@ -16462,10 +16527,10 @@ function runtimeCache(fn, revalidateSeconds, options) {
|
|
|
16462
16527
|
}
|
|
16463
16528
|
|
|
16464
16529
|
// lib/paths.ts
|
|
16465
|
-
import { homedir as
|
|
16466
|
-
import { join as
|
|
16530
|
+
import { homedir as homedir7 } from "os";
|
|
16531
|
+
import { join as join8 } from "path";
|
|
16467
16532
|
function getDefaultClaudeProjectsPath() {
|
|
16468
|
-
return
|
|
16533
|
+
return join8(homedir7(), ".claude", "projects");
|
|
16469
16534
|
}
|
|
16470
16535
|
function decodeFolderName(name) {
|
|
16471
16536
|
if (/^[A-Za-z]--/.test(name)) {
|
|
@@ -16555,8 +16620,8 @@ __export(exports_codex_projects, {
|
|
|
16555
16620
|
getCodexSessionsByEncodedName: () => getCodexSessionsByEncodedName
|
|
16556
16621
|
});
|
|
16557
16622
|
import { open, readdir } from "node:fs/promises";
|
|
16558
|
-
import { homedir as
|
|
16559
|
-
import { join as
|
|
16623
|
+
import { homedir as homedir8 } from "node:os";
|
|
16624
|
+
import { join as join9 } from "node:path";
|
|
16560
16625
|
async function safeReaddir(dir) {
|
|
16561
16626
|
try {
|
|
16562
16627
|
return await readdir(dir, { withFileTypes: true });
|
|
@@ -16604,7 +16669,7 @@ async function listJsonlFiles(dir) {
|
|
|
16604
16669
|
const entries = await safeReaddir(dir);
|
|
16605
16670
|
if (!entries)
|
|
16606
16671
|
return [];
|
|
16607
|
-
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));
|
|
16608
16673
|
}
|
|
16609
16674
|
async function scanCodexSessions() {
|
|
16610
16675
|
const yearDirs = await safeReaddir(CODEX_SESSIONS_ROOT);
|
|
@@ -16614,19 +16679,19 @@ async function scanCodexSessions() {
|
|
|
16614
16679
|
for (const y of yearDirs) {
|
|
16615
16680
|
if (!y.isDirectory())
|
|
16616
16681
|
continue;
|
|
16617
|
-
const monthDirs = await safeReaddir(
|
|
16682
|
+
const monthDirs = await safeReaddir(join9(CODEX_SESSIONS_ROOT, y.name));
|
|
16618
16683
|
if (!monthDirs)
|
|
16619
16684
|
continue;
|
|
16620
16685
|
for (const m of monthDirs) {
|
|
16621
16686
|
if (!m.isDirectory())
|
|
16622
16687
|
continue;
|
|
16623
|
-
const dayDirs = await safeReaddir(
|
|
16688
|
+
const dayDirs = await safeReaddir(join9(CODEX_SESSIONS_ROOT, y.name, m.name));
|
|
16624
16689
|
if (!dayDirs)
|
|
16625
16690
|
continue;
|
|
16626
16691
|
for (const d of dayDirs) {
|
|
16627
16692
|
if (!d.isDirectory())
|
|
16628
16693
|
continue;
|
|
16629
|
-
const dayPath =
|
|
16694
|
+
const dayPath = join9(CODEX_SESSIONS_ROOT, y.name, m.name, d.name);
|
|
16630
16695
|
filePaths.push(...await listJsonlFiles(dayPath));
|
|
16631
16696
|
}
|
|
16632
16697
|
}
|
|
@@ -16734,7 +16799,7 @@ var CODEX_SESSIONS_ROOT, SESSION_ID_RE, FIRST_LINE_CHUNK_BYTES, cachedScan, getC
|
|
|
16734
16799
|
var init_codex_projects = __esm(() => {
|
|
16735
16800
|
init_paths();
|
|
16736
16801
|
init_logger();
|
|
16737
|
-
CODEX_SESSIONS_ROOT =
|
|
16802
|
+
CODEX_SESSIONS_ROOT = join9(homedir8(), ".codex", "sessions");
|
|
16738
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;
|
|
16739
16804
|
FIRST_LINE_CHUNK_BYTES = 256 * 1024;
|
|
16740
16805
|
cachedScan = runtimeCache(scanCodexSessions, 30);
|
|
@@ -16750,10 +16815,10 @@ __export(exports_copilot_projects, {
|
|
|
16750
16815
|
getCopilotSessionsByEncodedName: () => getCopilotSessionsByEncodedName
|
|
16751
16816
|
});
|
|
16752
16817
|
import { readdir as readdir2, readFile as readFile4, stat } from "node:fs/promises";
|
|
16753
|
-
import { homedir as
|
|
16754
|
-
import { join as
|
|
16818
|
+
import { homedir as homedir9 } from "node:os";
|
|
16819
|
+
import { join as join10 } from "node:path";
|
|
16755
16820
|
function getCopilotSessionStateRoot() {
|
|
16756
|
-
return
|
|
16821
|
+
return join10(process.env.COPILOT_HOME || join10(homedir9(), ".copilot"), "session-state");
|
|
16757
16822
|
}
|
|
16758
16823
|
async function safeReaddir2(dir) {
|
|
16759
16824
|
try {
|
|
@@ -16782,8 +16847,8 @@ async function scanCopilotSessions() {
|
|
|
16782
16847
|
return [];
|
|
16783
16848
|
const candidates = entries.filter((e) => e.isDirectory()).map((e) => ({
|
|
16784
16849
|
sessionId: e.name,
|
|
16785
|
-
workspacePath:
|
|
16786
|
-
eventsPath:
|
|
16850
|
+
workspacePath: join10(root, e.name, "workspace.yaml"),
|
|
16851
|
+
eventsPath: join10(root, e.name, "events.jsonl")
|
|
16787
16852
|
}));
|
|
16788
16853
|
const settled = await batchAll(candidates.map((c) => async () => {
|
|
16789
16854
|
let workspaceText;
|
|
@@ -16894,10 +16959,10 @@ __export(exports_cursor_projects, {
|
|
|
16894
16959
|
getCursorSessionsByEncodedName: () => getCursorSessionsByEncodedName
|
|
16895
16960
|
});
|
|
16896
16961
|
import { readdir as readdir3, readFile as readFile5, stat as stat2 } from "node:fs/promises";
|
|
16897
|
-
import { homedir as
|
|
16898
|
-
import { join as
|
|
16962
|
+
import { homedir as homedir10 } from "node:os";
|
|
16963
|
+
import { join as join11 } from "node:path";
|
|
16899
16964
|
function getCursorHome() {
|
|
16900
|
-
return process.env.CURSOR_HOME ||
|
|
16965
|
+
return process.env.CURSOR_HOME || join11(homedir10(), ".cursor");
|
|
16901
16966
|
}
|
|
16902
16967
|
async function safeReaddir3(dir) {
|
|
16903
16968
|
try {
|
|
@@ -16929,7 +16994,7 @@ function parseCwdFromMetaText(text) {
|
|
|
16929
16994
|
}
|
|
16930
16995
|
async function findFirstUsableMeta(dir, candidates) {
|
|
16931
16996
|
for (const name of candidates) {
|
|
16932
|
-
const path =
|
|
16997
|
+
const path = join11(dir, name);
|
|
16933
16998
|
if (await statMtime2(path) === null)
|
|
16934
16999
|
continue;
|
|
16935
17000
|
let text;
|
|
@@ -16946,7 +17011,7 @@ async function findFirstUsableMeta(dir, candidates) {
|
|
|
16946
17011
|
}
|
|
16947
17012
|
async function findFirstExistingPath(dir, candidates) {
|
|
16948
17013
|
for (const name of candidates) {
|
|
16949
|
-
const path =
|
|
17014
|
+
const path = join11(dir, name);
|
|
16950
17015
|
if (await statMtime2(path) !== null)
|
|
16951
17016
|
return path;
|
|
16952
17017
|
}
|
|
@@ -16956,7 +17021,7 @@ async function scanCursorSessions() {
|
|
|
16956
17021
|
const home = getCursorHome();
|
|
16957
17022
|
const newCandidates = [];
|
|
16958
17023
|
const legacyCandidates = [];
|
|
16959
|
-
const projectsRoot =
|
|
17024
|
+
const projectsRoot = join11(home, NEW_PROJECTS_DIR);
|
|
16960
17025
|
const projectEntries = await safeReaddir3(projectsRoot);
|
|
16961
17026
|
if (projectEntries) {
|
|
16962
17027
|
for (const proj of projectEntries) {
|
|
@@ -16964,7 +17029,7 @@ async function scanCursorSessions() {
|
|
|
16964
17029
|
continue;
|
|
16965
17030
|
const decoded = decodeFolderName(proj.name);
|
|
16966
17031
|
const cwd = decoded.startsWith("/") || /^[A-Za-z]:\//.test(decoded) ? decoded : `/${decoded}`;
|
|
16967
|
-
const transcriptsRoot =
|
|
17032
|
+
const transcriptsRoot = join11(projectsRoot, proj.name, NEW_AGENT_TRANSCRIPTS_DIR);
|
|
16968
17033
|
const sessionDirs = await safeReaddir3(transcriptsRoot);
|
|
16969
17034
|
if (!sessionDirs)
|
|
16970
17035
|
continue;
|
|
@@ -16973,28 +17038,28 @@ async function scanCursorSessions() {
|
|
|
16973
17038
|
continue;
|
|
16974
17039
|
newCandidates.push({
|
|
16975
17040
|
sessionId: sd.name,
|
|
16976
|
-
dir:
|
|
17041
|
+
dir: join11(transcriptsRoot, sd.name),
|
|
16977
17042
|
cwd
|
|
16978
17043
|
});
|
|
16979
17044
|
}
|
|
16980
17045
|
}
|
|
16981
17046
|
}
|
|
16982
17047
|
for (const sub of LEGACY_SESSION_ROOT_CANDIDATES) {
|
|
16983
|
-
const root =
|
|
17048
|
+
const root = join11(home, sub);
|
|
16984
17049
|
const entries = await safeReaddir3(root);
|
|
16985
17050
|
if (!entries)
|
|
16986
17051
|
continue;
|
|
16987
17052
|
for (const e of entries) {
|
|
16988
17053
|
if (!e.isDirectory())
|
|
16989
17054
|
continue;
|
|
16990
|
-
legacyCandidates.push({ sessionId: e.name, dir:
|
|
17055
|
+
legacyCandidates.push({ sessionId: e.name, dir: join11(root, e.name) });
|
|
16991
17056
|
}
|
|
16992
17057
|
}
|
|
16993
17058
|
if (newCandidates.length === 0 && legacyCandidates.length === 0)
|
|
16994
17059
|
return [];
|
|
16995
17060
|
const settled = await batchAll([
|
|
16996
17061
|
...newCandidates.map((c) => async () => {
|
|
16997
|
-
const transcriptPath =
|
|
17062
|
+
const transcriptPath = join11(c.dir, `${c.sessionId}.jsonl`);
|
|
16998
17063
|
const transcriptMtime = await statMtime2(transcriptPath);
|
|
16999
17064
|
if (!transcriptMtime)
|
|
17000
17065
|
return null;
|
|
@@ -17108,7 +17173,7 @@ var init_cursor_projects = __esm(() => {
|
|
|
17108
17173
|
});
|
|
17109
17174
|
|
|
17110
17175
|
// lib/sqlite-reader.ts
|
|
17111
|
-
import { existsSync as
|
|
17176
|
+
import { existsSync as existsSync12, readFileSync as readFileSync8, statSync as statSync7 } from "node:fs";
|
|
17112
17177
|
import initSqlJs from "sql.js/dist/sql-asm.js";
|
|
17113
17178
|
async function tryNodeSqlite(dbPath) {
|
|
17114
17179
|
try {
|
|
@@ -17132,10 +17197,117 @@ function loadSqlJs() {
|
|
|
17132
17197
|
sqlPromise = initSqlJs();
|
|
17133
17198
|
return sqlPromise;
|
|
17134
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
|
+
}
|
|
17135
17307
|
async function trySqlJs(dbPath) {
|
|
17136
17308
|
try {
|
|
17137
17309
|
const SQL = await loadSqlJs();
|
|
17138
|
-
const db = new SQL.Database(
|
|
17310
|
+
const db = new SQL.Database(readPortableSnapshot(dbPath));
|
|
17139
17311
|
return {
|
|
17140
17312
|
query(sql, params) {
|
|
17141
17313
|
const stmt = db.prepare(sql);
|
|
@@ -17158,22 +17330,27 @@ async function trySqlJs(dbPath) {
|
|
|
17158
17330
|
return null;
|
|
17159
17331
|
}
|
|
17160
17332
|
}
|
|
17161
|
-
async function openSqliteReadonly(dbPath) {
|
|
17162
|
-
if (!
|
|
17333
|
+
async function openSqliteReadonly(dbPath, options = {}) {
|
|
17334
|
+
if (!existsSync12(dbPath))
|
|
17163
17335
|
return null;
|
|
17164
|
-
|
|
17336
|
+
if (!options.forcePortable) {
|
|
17337
|
+
const native = await tryNodeSqlite(dbPath);
|
|
17338
|
+
if (native)
|
|
17339
|
+
return native;
|
|
17340
|
+
}
|
|
17341
|
+
return trySqlJs(dbPath);
|
|
17165
17342
|
}
|
|
17166
17343
|
var sqlPromise = null;
|
|
17167
17344
|
var init_sqlite_reader = () => {};
|
|
17168
17345
|
|
|
17169
17346
|
// lib/opencode-db.ts
|
|
17170
|
-
import { homedir as
|
|
17171
|
-
import { join as
|
|
17347
|
+
import { homedir as homedir11 } from "node:os";
|
|
17348
|
+
import { join as join12 } from "node:path";
|
|
17172
17349
|
function opencodeDbPath() {
|
|
17173
17350
|
if (process.env.OPENCODE_DB_PATH)
|
|
17174
17351
|
return process.env.OPENCODE_DB_PATH;
|
|
17175
|
-
const home = process.env.OPENCODE_HOME ??
|
|
17176
|
-
return
|
|
17352
|
+
const home = process.env.OPENCODE_HOME ?? join12(homedir11(), ".local", "share", "opencode");
|
|
17353
|
+
return join12(home, "opencode.db");
|
|
17177
17354
|
}
|
|
17178
17355
|
async function withOpenCodeDb(fn) {
|
|
17179
17356
|
const db = await openSqliteReadonly(opencodeDbPath());
|
|
@@ -17333,10 +17510,10 @@ __export(exports_pi_projects, {
|
|
|
17333
17510
|
getPiSessionsByEncodedName: () => getPiSessionsByEncodedName
|
|
17334
17511
|
});
|
|
17335
17512
|
import { readdir as readdir4, readFile as readFile6, stat as stat3 } from "node:fs/promises";
|
|
17336
|
-
import { homedir as
|
|
17337
|
-
import { join as
|
|
17513
|
+
import { homedir as homedir12 } from "node:os";
|
|
17514
|
+
import { join as join13 } from "node:path";
|
|
17338
17515
|
function getPiSessionsRoot() {
|
|
17339
|
-
return process.env.PI_SESSIONS_DIR ||
|
|
17516
|
+
return process.env.PI_SESSIONS_DIR || join13(homedir12(), ".pi", "agent", "sessions");
|
|
17340
17517
|
}
|
|
17341
17518
|
async function safeReaddir4(dir) {
|
|
17342
17519
|
try {
|
|
@@ -17384,7 +17561,7 @@ async function scanPiSessions() {
|
|
|
17384
17561
|
for (const cwdDir of cwdDirs) {
|
|
17385
17562
|
if (!cwdDir.isDirectory())
|
|
17386
17563
|
continue;
|
|
17387
|
-
const cwdPath =
|
|
17564
|
+
const cwdPath = join13(root, cwdDir.name);
|
|
17388
17565
|
const sessionFiles = await safeReaddir4(cwdPath);
|
|
17389
17566
|
if (!sessionFiles)
|
|
17390
17567
|
continue;
|
|
@@ -17394,7 +17571,7 @@ async function scanPiSessions() {
|
|
|
17394
17571
|
const m = SESSION_FILE_RE.exec(f.name);
|
|
17395
17572
|
if (!m)
|
|
17396
17573
|
continue;
|
|
17397
|
-
candidates.push({ sessionId: m[1], filePath:
|
|
17574
|
+
candidates.push({ sessionId: m[1], filePath: join13(cwdPath, f.name) });
|
|
17398
17575
|
}
|
|
17399
17576
|
}
|
|
17400
17577
|
if (candidates.length === 0)
|
|
@@ -17516,14 +17693,14 @@ function formatDuration(ms) {
|
|
|
17516
17693
|
}
|
|
17517
17694
|
|
|
17518
17695
|
// lib/hermes-sessions.ts
|
|
17519
|
-
import { join as
|
|
17696
|
+
import { join as join14 } from "node:path";
|
|
17520
17697
|
function hermesDbPaths() {
|
|
17521
17698
|
const override = process.env.HERMES_DB_PATH;
|
|
17522
17699
|
if (override)
|
|
17523
17700
|
return [{ profile: HERMES_DEFAULT_PROFILE, dbPath: override }];
|
|
17524
17701
|
return listHermesProfiles().map((p) => ({
|
|
17525
17702
|
profile: p.name,
|
|
17526
|
-
dbPath:
|
|
17703
|
+
dbPath: join14(p.home, "state.db")
|
|
17527
17704
|
}));
|
|
17528
17705
|
}
|
|
17529
17706
|
function epochToMs(value) {
|
|
@@ -17814,13 +17991,169 @@ var init_hermes_projects = __esm(() => {
|
|
|
17814
17991
|
getCachedHermesSessionsByEncodedName = runtimeCache((name) => getHermesSessionsByEncodedName(name), 2, { maxSize: 50 });
|
|
17815
17992
|
});
|
|
17816
17993
|
|
|
17994
|
+
// lib/openclaw-db.ts
|
|
17995
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
17996
|
+
import { join as join15 } from "node:path";
|
|
17997
|
+
function str(value) {
|
|
17998
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
17999
|
+
}
|
|
18000
|
+
function parseObject(value) {
|
|
18001
|
+
try {
|
|
18002
|
+
const parsed = JSON.parse(value);
|
|
18003
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
|
|
18004
|
+
} catch {
|
|
18005
|
+
return;
|
|
18006
|
+
}
|
|
18007
|
+
}
|
|
18008
|
+
function syntheticPath(agentId, sessionId) {
|
|
18009
|
+
return `openclaw-sqlite://${encodeURIComponent(agentId)}/${sessionId}`;
|
|
18010
|
+
}
|
|
18011
|
+
function listOpenClawDatabases(home, agentIds) {
|
|
18012
|
+
const out = [];
|
|
18013
|
+
for (const agentId of agentIds) {
|
|
18014
|
+
const dbPath = join15(home, "agents", agentId, "agent", DB_NAME);
|
|
18015
|
+
if (existsSync13(dbPath))
|
|
18016
|
+
out.push({ agentId, dbPath });
|
|
18017
|
+
}
|
|
18018
|
+
return out;
|
|
18019
|
+
}
|
|
18020
|
+
function readNodeMetadata(db) {
|
|
18021
|
+
const out = new Map;
|
|
18022
|
+
let rows;
|
|
18023
|
+
try {
|
|
18024
|
+
rows = db.query(`SELECT current_session_id, entry_json, label, display_name
|
|
18025
|
+
FROM session_nodes`);
|
|
18026
|
+
} catch {
|
|
18027
|
+
return out;
|
|
18028
|
+
}
|
|
18029
|
+
for (const row of rows) {
|
|
18030
|
+
const entry = parseObject(row.entry_json) ?? {};
|
|
18031
|
+
const origin = entry.origin && typeof entry.origin === "object" && !Array.isArray(entry.origin) ? entry.origin : {};
|
|
18032
|
+
out.set(row.current_session_id, {
|
|
18033
|
+
channel: str(entry.lastChannel) ?? str(origin.provider) ?? str(origin.surface),
|
|
18034
|
+
label: str(row.label) ?? str(row.display_name) ?? str(entry.displayName) ?? str(origin.label),
|
|
18035
|
+
chatId: str(entry.lastTo) ?? str(origin.from),
|
|
18036
|
+
chatType: str(entry.chatType) ?? str(origin.chatType)
|
|
18037
|
+
});
|
|
18038
|
+
}
|
|
18039
|
+
return out;
|
|
18040
|
+
}
|
|
18041
|
+
function readConversationMetadata(db) {
|
|
18042
|
+
const out = new Map;
|
|
18043
|
+
let rows;
|
|
18044
|
+
try {
|
|
18045
|
+
rows = db.query(`SELECT sc.session_id, c.channel, c.kind, c.peer_id,
|
|
18046
|
+
c.delivery_target, c.label
|
|
18047
|
+
FROM session_conversations sc
|
|
18048
|
+
JOIN conversations c ON c.conversation_id = sc.conversation_id
|
|
18049
|
+
ORDER BY CASE sc.role WHEN 'primary' THEN 0 ELSE 1 END, sc.last_seen_at DESC`);
|
|
18050
|
+
} catch {
|
|
18051
|
+
return out;
|
|
18052
|
+
}
|
|
18053
|
+
for (const row of rows) {
|
|
18054
|
+
if (out.has(row.session_id))
|
|
18055
|
+
continue;
|
|
18056
|
+
out.set(row.session_id, {
|
|
18057
|
+
channel: str(row.channel),
|
|
18058
|
+
label: str(row.label),
|
|
18059
|
+
chatId: str(row.delivery_target) ?? str(row.peer_id),
|
|
18060
|
+
chatType: str(row.kind)
|
|
18061
|
+
});
|
|
18062
|
+
}
|
|
18063
|
+
return out;
|
|
18064
|
+
}
|
|
18065
|
+
async function listOpenClawSqliteSessions(home, agentIds) {
|
|
18066
|
+
const sessions = [];
|
|
18067
|
+
for (const { agentId, dbPath } of listOpenClawDatabases(home, agentIds)) {
|
|
18068
|
+
const db = await openSqliteReadonly(dbPath);
|
|
18069
|
+
if (!db)
|
|
18070
|
+
continue;
|
|
18071
|
+
try {
|
|
18072
|
+
let rows;
|
|
18073
|
+
try {
|
|
18074
|
+
rows = db.query(`SELECT w.session_id, w.session_key, w.updated_at,
|
|
18075
|
+
w.transcript_updated_at, w.ended_at, w.channel,
|
|
18076
|
+
w.chat_type, w.display_name,
|
|
18077
|
+
COALESCE((SELECT MAX(e.created_at)
|
|
18078
|
+
FROM transcript_events e
|
|
18079
|
+
WHERE e.session_id = w.session_id), 0) AS event_updated_at,
|
|
18080
|
+
COALESCE((SELECT SUM(length(e.event_json) + 1)
|
|
18081
|
+
FROM transcript_events e
|
|
18082
|
+
WHERE e.session_id = w.session_id), 0) AS size_bytes
|
|
18083
|
+
FROM session_windows w
|
|
18084
|
+
WHERE EXISTS (SELECT 1 FROM transcript_events e
|
|
18085
|
+
WHERE e.session_id = w.session_id)`);
|
|
18086
|
+
} catch {
|
|
18087
|
+
continue;
|
|
18088
|
+
}
|
|
18089
|
+
const nodes = readNodeMetadata(db);
|
|
18090
|
+
const conversations = readConversationMetadata(db);
|
|
18091
|
+
for (const row of rows) {
|
|
18092
|
+
const node = nodes.get(row.session_id);
|
|
18093
|
+
const conversation = conversations.get(row.session_id);
|
|
18094
|
+
sessions.push({
|
|
18095
|
+
sessionId: row.session_id,
|
|
18096
|
+
agentId,
|
|
18097
|
+
dbPath,
|
|
18098
|
+
transcriptPath: syntheticPath(agentId, row.session_id),
|
|
18099
|
+
mtimeMs: Math.max(Number(row.updated_at) || 0, Number(row.transcript_updated_at) || 0, Number(row.ended_at) || 0, Number(row.event_updated_at) || 0),
|
|
18100
|
+
sizeBytes: Number(row.size_bytes) || 0,
|
|
18101
|
+
channel: str(row.channel) ?? conversation?.channel ?? node?.channel ?? "local",
|
|
18102
|
+
label: str(row.display_name) ?? conversation?.label ?? node?.label,
|
|
18103
|
+
chatId: conversation?.chatId ?? node?.chatId,
|
|
18104
|
+
chatType: str(row.chat_type) ?? conversation?.chatType ?? node?.chatType
|
|
18105
|
+
});
|
|
18106
|
+
}
|
|
18107
|
+
} finally {
|
|
18108
|
+
db.close();
|
|
18109
|
+
}
|
|
18110
|
+
}
|
|
18111
|
+
return sessions;
|
|
18112
|
+
}
|
|
18113
|
+
async function readOpenClawSqliteTranscript(home, agentIds, sessionId) {
|
|
18114
|
+
for (const { agentId, dbPath } of listOpenClawDatabases(home, agentIds)) {
|
|
18115
|
+
const db = await openSqliteReadonly(dbPath);
|
|
18116
|
+
if (!db)
|
|
18117
|
+
continue;
|
|
18118
|
+
try {
|
|
18119
|
+
let rows;
|
|
18120
|
+
try {
|
|
18121
|
+
rows = db.query(`SELECT event_json
|
|
18122
|
+
FROM transcript_events
|
|
18123
|
+
WHERE session_id = ?
|
|
18124
|
+
ORDER BY seq ASC`, [sessionId]);
|
|
18125
|
+
} catch {
|
|
18126
|
+
continue;
|
|
18127
|
+
}
|
|
18128
|
+
if (rows.length === 0)
|
|
18129
|
+
continue;
|
|
18130
|
+
const eventJsonLines = rows.map((row) => row.event_json);
|
|
18131
|
+
const rawLines = eventJsonLines.map(parseObject).filter((line) => line !== undefined);
|
|
18132
|
+
return {
|
|
18133
|
+
agentId,
|
|
18134
|
+
dbPath,
|
|
18135
|
+
filePath: syntheticPath(agentId, sessionId),
|
|
18136
|
+
rawLines,
|
|
18137
|
+
eventJsonLines
|
|
18138
|
+
};
|
|
18139
|
+
} finally {
|
|
18140
|
+
db.close();
|
|
18141
|
+
}
|
|
18142
|
+
}
|
|
18143
|
+
return null;
|
|
18144
|
+
}
|
|
18145
|
+
var DB_NAME = "openclaw-agent.sqlite";
|
|
18146
|
+
var init_openclaw_db = __esm(() => {
|
|
18147
|
+
init_sqlite_reader();
|
|
18148
|
+
});
|
|
18149
|
+
|
|
17817
18150
|
// lib/openclaw-sessions.ts
|
|
17818
18151
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
17819
|
-
import { readdirSync as
|
|
17820
|
-
import { homedir as
|
|
17821
|
-
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";
|
|
17822
18155
|
function openclawHome() {
|
|
17823
|
-
return process.env.OPENCLAW_HOME ||
|
|
18156
|
+
return process.env.OPENCLAW_STATE_DIR || process.env.OPENCLAW_HOME || join16(homedir13(), ".openclaw");
|
|
17824
18157
|
}
|
|
17825
18158
|
function isPlainObject3(v) {
|
|
17826
18159
|
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
@@ -17907,7 +18240,11 @@ function openclawLinesToLogEntries(lines, source = "session") {
|
|
|
17907
18240
|
entries.push({
|
|
17908
18241
|
type: "assistant",
|
|
17909
18242
|
...base,
|
|
17910
|
-
message: {
|
|
18243
|
+
message: {
|
|
18244
|
+
role: "assistant",
|
|
18245
|
+
content: blocks,
|
|
18246
|
+
model: typeof m.model === "string" ? m.model : undefined
|
|
18247
|
+
}
|
|
17911
18248
|
});
|
|
17912
18249
|
continue;
|
|
17913
18250
|
}
|
|
@@ -17935,25 +18272,25 @@ function openclawLinesToLogEntries(lines, source = "session") {
|
|
|
17935
18272
|
}
|
|
17936
18273
|
function listOpenClawAgents() {
|
|
17937
18274
|
try {
|
|
17938
|
-
return
|
|
18275
|
+
return readdirSync6(join16(openclawHome(), "agents"), { withFileTypes: true }).filter((d) => d.isDirectory() && !d.name.startsWith(".")).map((d) => d.name).sort();
|
|
17939
18276
|
} catch {
|
|
17940
18277
|
return [];
|
|
17941
18278
|
}
|
|
17942
18279
|
}
|
|
17943
18280
|
function listOpenClawTranscripts() {
|
|
17944
|
-
const agentsDir =
|
|
18281
|
+
const agentsDir = join16(openclawHome(), "agents");
|
|
17945
18282
|
const out = [];
|
|
17946
18283
|
let agentIds;
|
|
17947
18284
|
try {
|
|
17948
|
-
agentIds =
|
|
18285
|
+
agentIds = readdirSync6(agentsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
17949
18286
|
} catch {
|
|
17950
18287
|
return out;
|
|
17951
18288
|
}
|
|
17952
18289
|
for (const agentId of agentIds) {
|
|
17953
|
-
const sessionsDir =
|
|
18290
|
+
const sessionsDir = join16(agentsDir, agentId, "sessions");
|
|
17954
18291
|
let files;
|
|
17955
18292
|
try {
|
|
17956
|
-
files =
|
|
18293
|
+
files = readdirSync6(sessionsDir);
|
|
17957
18294
|
} catch {
|
|
17958
18295
|
continue;
|
|
17959
18296
|
}
|
|
@@ -17963,10 +18300,16 @@ function listOpenClawTranscripts() {
|
|
|
17963
18300
|
const sessionId = file.slice(0, -".jsonl".length);
|
|
17964
18301
|
if (!OPENCLAW_SESSION_ID_RE.test(sessionId))
|
|
17965
18302
|
continue;
|
|
17966
|
-
const transcriptPath =
|
|
18303
|
+
const transcriptPath = join16(sessionsDir, file);
|
|
17967
18304
|
try {
|
|
17968
|
-
const st =
|
|
17969
|
-
out.push({
|
|
18305
|
+
const st = statSync8(transcriptPath);
|
|
18306
|
+
out.push({
|
|
18307
|
+
agentId,
|
|
18308
|
+
sessionId,
|
|
18309
|
+
transcriptPath,
|
|
18310
|
+
mtimeMs: st.mtimeMs,
|
|
18311
|
+
sizeBytes: st.size
|
|
18312
|
+
});
|
|
17970
18313
|
} catch {}
|
|
17971
18314
|
}
|
|
17972
18315
|
}
|
|
@@ -17982,6 +18325,25 @@ function findOpenClawTranscript(sessionId) {
|
|
|
17982
18325
|
return null;
|
|
17983
18326
|
}
|
|
17984
18327
|
async function getOpenClawSessionLog(sessionId) {
|
|
18328
|
+
if (!OPENCLAW_SESSION_ID_RE.test(sessionId))
|
|
18329
|
+
return null;
|
|
18330
|
+
const sqlite = await readOpenClawSqliteTranscript(openclawHome(), listOpenClawAgents(), sessionId);
|
|
18331
|
+
if (sqlite) {
|
|
18332
|
+
const entries = openclawLinesToLogEntries(sqlite.rawLines, "session");
|
|
18333
|
+
let cwd;
|
|
18334
|
+
for (const line of sqlite.rawLines) {
|
|
18335
|
+
if (line.type === "session" && typeof line.cwd === "string" && line.cwd.length > 0) {
|
|
18336
|
+
cwd = line.cwd;
|
|
18337
|
+
break;
|
|
18338
|
+
}
|
|
18339
|
+
}
|
|
18340
|
+
return {
|
|
18341
|
+
entries,
|
|
18342
|
+
rawLines: sqlite.rawLines,
|
|
18343
|
+
cwd,
|
|
18344
|
+
filePath: sqlite.filePath
|
|
18345
|
+
};
|
|
18346
|
+
}
|
|
17985
18347
|
const filePath = findOpenClawTranscript(sessionId);
|
|
17986
18348
|
if (!filePath)
|
|
17987
18349
|
return null;
|
|
@@ -18005,6 +18367,7 @@ async function getOpenClawSessionLog(sessionId) {
|
|
|
18005
18367
|
var OPENCLAW_SESSION_ID_RE, getCachedOpenClawSessionLog;
|
|
18006
18368
|
var init_openclaw_sessions = __esm(() => {
|
|
18007
18369
|
init_log_entries();
|
|
18370
|
+
init_openclaw_db();
|
|
18008
18371
|
OPENCLAW_SESSION_ID_RE = /^[0-9a-fA-F-]{36}$/;
|
|
18009
18372
|
getCachedOpenClawSessionLog = runtimeCache((sessionId) => getOpenClawSessionLog(sessionId), 2, { maxSize: 50 });
|
|
18010
18373
|
});
|
|
@@ -18017,13 +18380,13 @@ __export(exports_openclaw_projects, {
|
|
|
18017
18380
|
openClawProjectPath: () => openClawProjectPath
|
|
18018
18381
|
});
|
|
18019
18382
|
import { readFileSync as readFileSync9 } from "node:fs";
|
|
18020
|
-
import { join as
|
|
18021
|
-
function
|
|
18383
|
+
import { join as join17 } from "node:path";
|
|
18384
|
+
function str2(v) {
|
|
18022
18385
|
return typeof v === "string" && v.length > 0 ? v : undefined;
|
|
18023
18386
|
}
|
|
18024
18387
|
function readSessionsIndex(agentId) {
|
|
18025
18388
|
const out = new Map;
|
|
18026
|
-
const indexPath =
|
|
18389
|
+
const indexPath = join17(openclawHome(), "agents", agentId, "sessions", "sessions.json");
|
|
18027
18390
|
let raw;
|
|
18028
18391
|
try {
|
|
18029
18392
|
raw = JSON.parse(readFileSync9(indexPath, "utf-8"));
|
|
@@ -18036,17 +18399,17 @@ function readSessionsIndex(agentId) {
|
|
|
18036
18399
|
if (!v || typeof v !== "object")
|
|
18037
18400
|
continue;
|
|
18038
18401
|
const e = v;
|
|
18039
|
-
const sessionId =
|
|
18402
|
+
const sessionId = str2(e.sessionId);
|
|
18040
18403
|
if (!sessionId)
|
|
18041
18404
|
continue;
|
|
18042
18405
|
const origin = e.origin && typeof e.origin === "object" ? e.origin : {};
|
|
18043
18406
|
const lastMs = typeof e.lastInteractionAt === "number" ? e.lastInteractionAt : typeof e.updatedAt === "number" ? e.updatedAt : undefined;
|
|
18044
18407
|
out.set(sessionId, {
|
|
18045
18408
|
lastMs,
|
|
18046
|
-
channel:
|
|
18047
|
-
chatType:
|
|
18048
|
-
label:
|
|
18049
|
-
chatId:
|
|
18409
|
+
channel: str2(e.lastChannel) ?? str2(origin.provider) ?? str2(origin.surface),
|
|
18410
|
+
chatType: str2(e.chatType) ?? str2(origin.chatType),
|
|
18411
|
+
label: str2(origin.label),
|
|
18412
|
+
chatId: str2(e.lastTo) ?? str2(origin.from)
|
|
18050
18413
|
});
|
|
18051
18414
|
}
|
|
18052
18415
|
return out;
|
|
@@ -18054,7 +18417,7 @@ function readSessionsIndex(agentId) {
|
|
|
18054
18417
|
async function getOpenClawSessions() {
|
|
18055
18418
|
const transcripts = listOpenClawTranscripts();
|
|
18056
18419
|
const indexByAgent = new Map;
|
|
18057
|
-
const refs =
|
|
18420
|
+
const refs = new Map;
|
|
18058
18421
|
for (const t of transcripts) {
|
|
18059
18422
|
let idx = indexByAgent.get(t.agentId);
|
|
18060
18423
|
if (!idx) {
|
|
@@ -18062,7 +18425,7 @@ async function getOpenClawSessions() {
|
|
|
18062
18425
|
indexByAgent.set(t.agentId, idx);
|
|
18063
18426
|
}
|
|
18064
18427
|
const meta = idx.get(t.sessionId);
|
|
18065
|
-
refs.
|
|
18428
|
+
refs.set(`${t.agentId}\x00${t.sessionId}`, {
|
|
18066
18429
|
sessionId: t.sessionId,
|
|
18067
18430
|
agentId: t.agentId,
|
|
18068
18431
|
channel: meta?.channel ?? "local",
|
|
@@ -18074,8 +18437,11 @@ async function getOpenClawSessions() {
|
|
|
18074
18437
|
sizeBytes: t.sizeBytes
|
|
18075
18438
|
});
|
|
18076
18439
|
}
|
|
18077
|
-
|
|
18078
|
-
|
|
18440
|
+
const sqliteSessions = await listOpenClawSqliteSessions(openclawHome(), listOpenClawAgents());
|
|
18441
|
+
for (const s of sqliteSessions) {
|
|
18442
|
+
refs.set(`${s.agentId}\x00${s.sessionId}`, s);
|
|
18443
|
+
}
|
|
18444
|
+
return [...refs.values()].sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
18079
18445
|
}
|
|
18080
18446
|
function openClawProjectName(agentId, channel) {
|
|
18081
18447
|
return `openclaw-${agentId}-${channel}`;
|
|
@@ -18110,7 +18476,12 @@ async function getOpenClawProjects() {
|
|
|
18110
18476
|
prev.latest = Math.max(prev.latest, s.mtimeMs);
|
|
18111
18477
|
prev.count += 1;
|
|
18112
18478
|
} else {
|
|
18113
|
-
groups.set(key, {
|
|
18479
|
+
groups.set(key, {
|
|
18480
|
+
agentId: s.agentId,
|
|
18481
|
+
channel: s.channel,
|
|
18482
|
+
latest: s.mtimeMs,
|
|
18483
|
+
count: 1
|
|
18484
|
+
});
|
|
18114
18485
|
}
|
|
18115
18486
|
}
|
|
18116
18487
|
const out = [];
|
|
@@ -18168,6 +18539,7 @@ async function getOpenClawSessionsByEncodedName(name) {
|
|
|
18168
18539
|
var getCachedOpenClawSessions, getCachedOpenClawProjects, getCachedOpenClawSessionsByEncodedName;
|
|
18169
18540
|
var init_openclaw_projects = __esm(() => {
|
|
18170
18541
|
init_openclaw_sessions();
|
|
18542
|
+
init_openclaw_db();
|
|
18171
18543
|
getCachedOpenClawSessions = runtimeCache(getOpenClawSessions, 2);
|
|
18172
18544
|
getCachedOpenClawProjects = runtimeCache(getOpenClawProjects, 2);
|
|
18173
18545
|
getCachedOpenClawSessionsByEncodedName = runtimeCache((name) => getOpenClawSessionsByEncodedName(name), 2, { maxSize: 50 });
|
|
@@ -18175,14 +18547,14 @@ var init_openclaw_projects = __esm(() => {
|
|
|
18175
18547
|
|
|
18176
18548
|
// lib/factory-sessions.ts
|
|
18177
18549
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
18178
|
-
import { readdirSync as
|
|
18179
|
-
import { homedir as
|
|
18180
|
-
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";
|
|
18181
18553
|
function factoryHome() {
|
|
18182
|
-
return process.env.FACTORY_HOME ||
|
|
18554
|
+
return process.env.FACTORY_HOME || join18(homedir14(), ".factory");
|
|
18183
18555
|
}
|
|
18184
18556
|
function factorySessionsRoot() {
|
|
18185
|
-
return
|
|
18557
|
+
return join18(factoryHome(), "sessions");
|
|
18186
18558
|
}
|
|
18187
18559
|
function isPlainObject4(v) {
|
|
18188
18560
|
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
@@ -18321,17 +18693,17 @@ function listFactoryTranscripts() {
|
|
|
18321
18693
|
const out = [];
|
|
18322
18694
|
let projectDirs;
|
|
18323
18695
|
try {
|
|
18324
|
-
projectDirs =
|
|
18696
|
+
projectDirs = readdirSync7(root, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
18325
18697
|
} catch {
|
|
18326
18698
|
return out;
|
|
18327
18699
|
}
|
|
18328
18700
|
for (const dir of projectDirs) {
|
|
18329
18701
|
const projectName = dir.name;
|
|
18330
18702
|
const cwd = decodeFolderName(projectName);
|
|
18331
|
-
const projectPath =
|
|
18703
|
+
const projectPath = join18(root, projectName);
|
|
18332
18704
|
let files;
|
|
18333
18705
|
try {
|
|
18334
|
-
files =
|
|
18706
|
+
files = readdirSync7(projectPath);
|
|
18335
18707
|
} catch {
|
|
18336
18708
|
continue;
|
|
18337
18709
|
}
|
|
@@ -18341,9 +18713,9 @@ function listFactoryTranscripts() {
|
|
|
18341
18713
|
const sessionId = file.slice(0, -".jsonl".length);
|
|
18342
18714
|
if (!FACTORY_SESSION_ID_RE.test(sessionId))
|
|
18343
18715
|
continue;
|
|
18344
|
-
const transcriptPath =
|
|
18716
|
+
const transcriptPath = join18(projectPath, file);
|
|
18345
18717
|
try {
|
|
18346
|
-
const st =
|
|
18718
|
+
const st = statSync9(transcriptPath);
|
|
18347
18719
|
out.push({ projectName, cwd, sessionId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
|
|
18348
18720
|
} catch {}
|
|
18349
18721
|
}
|
|
@@ -18464,13 +18836,13 @@ var init_factory_projects = __esm(() => {
|
|
|
18464
18836
|
});
|
|
18465
18837
|
|
|
18466
18838
|
// lib/devin-sessions.ts
|
|
18467
|
-
import { homedir as
|
|
18468
|
-
import { join as
|
|
18839
|
+
import { homedir as homedir15 } from "node:os";
|
|
18840
|
+
import { join as join19 } from "node:path";
|
|
18469
18841
|
function devinHome() {
|
|
18470
|
-
return process.env.DEVIN_HOME ||
|
|
18842
|
+
return process.env.DEVIN_HOME || join19(homedir15(), ".local", "share", "devin");
|
|
18471
18843
|
}
|
|
18472
18844
|
function devinDbPath() {
|
|
18473
|
-
return process.env.DEVIN_DB_PATH ||
|
|
18845
|
+
return process.env.DEVIN_DB_PATH || join19(devinHome(), "cli", "sessions.db");
|
|
18474
18846
|
}
|
|
18475
18847
|
function devinEpochToMs(value) {
|
|
18476
18848
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
@@ -18763,17 +19135,17 @@ var init_devin_projects = __esm(() => {
|
|
|
18763
19135
|
|
|
18764
19136
|
// lib/antigravity-sessions.ts
|
|
18765
19137
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
18766
|
-
import { readdirSync as
|
|
18767
|
-
import { homedir as
|
|
18768
|
-
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";
|
|
18769
19141
|
function antigravityHome() {
|
|
18770
|
-
return process.env.ANTIGRAVITY_HOME ||
|
|
19142
|
+
return process.env.ANTIGRAVITY_HOME || join20(homedir16(), ".gemini", "antigravity-cli");
|
|
18771
19143
|
}
|
|
18772
19144
|
function antigravityBrainRoot() {
|
|
18773
|
-
return
|
|
19145
|
+
return join20(antigravityHome(), "brain");
|
|
18774
19146
|
}
|
|
18775
19147
|
function antigravityTranscriptRelPath() {
|
|
18776
|
-
return
|
|
19148
|
+
return join20(".system_generated", "logs", "transcript_full.jsonl");
|
|
18777
19149
|
}
|
|
18778
19150
|
function isPlainObject6(v) {
|
|
18779
19151
|
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
@@ -18888,7 +19260,7 @@ function listAntigravityTranscripts() {
|
|
|
18888
19260
|
const out = [];
|
|
18889
19261
|
let convoDirs;
|
|
18890
19262
|
try {
|
|
18891
|
-
convoDirs =
|
|
19263
|
+
convoDirs = readdirSync8(root, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
18892
19264
|
} catch {
|
|
18893
19265
|
return out;
|
|
18894
19266
|
}
|
|
@@ -18896,9 +19268,9 @@ function listAntigravityTranscripts() {
|
|
|
18896
19268
|
const conversationId = dir.name;
|
|
18897
19269
|
if (!ANTIGRAVITY_CONVERSATION_ID_RE.test(conversationId))
|
|
18898
19270
|
continue;
|
|
18899
|
-
const transcriptPath =
|
|
19271
|
+
const transcriptPath = join20(root, conversationId, rel);
|
|
18900
19272
|
try {
|
|
18901
|
-
const st =
|
|
19273
|
+
const st = statSync10(transcriptPath);
|
|
18902
19274
|
if (!st.isFile())
|
|
18903
19275
|
continue;
|
|
18904
19276
|
out.push({ conversationId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
|
|
@@ -18909,9 +19281,9 @@ function listAntigravityTranscripts() {
|
|
|
18909
19281
|
function findAntigravityTranscript(conversationId) {
|
|
18910
19282
|
if (!ANTIGRAVITY_CONVERSATION_ID_RE.test(conversationId))
|
|
18911
19283
|
return null;
|
|
18912
|
-
const transcriptPath =
|
|
19284
|
+
const transcriptPath = join20(antigravityBrainRoot(), conversationId, antigravityTranscriptRelPath());
|
|
18913
19285
|
try {
|
|
18914
|
-
if (
|
|
19286
|
+
if (statSync10(transcriptPath).isFile())
|
|
18915
19287
|
return transcriptPath;
|
|
18916
19288
|
} catch {}
|
|
18917
19289
|
return null;
|
|
@@ -18945,9 +19317,9 @@ __export(exports_antigravity_projects, {
|
|
|
18945
19317
|
getAntigravityIndex: () => getAntigravityIndex,
|
|
18946
19318
|
getAntigravityProjects: () => getAntigravityProjects
|
|
18947
19319
|
});
|
|
18948
|
-
import { join as
|
|
19320
|
+
import { join as join21 } from "node:path";
|
|
18949
19321
|
function antigravitySummariesDbPath() {
|
|
18950
|
-
return
|
|
19322
|
+
return join21(antigravityHome(), "conversation_summaries.db");
|
|
18951
19323
|
}
|
|
18952
19324
|
function parseWorkspaceCwd(raw) {
|
|
18953
19325
|
if (!raw)
|
|
@@ -19090,16 +19462,16 @@ var init_antigravity_projects = __esm(() => {
|
|
|
19090
19462
|
});
|
|
19091
19463
|
|
|
19092
19464
|
// lib/goose-sessions.ts
|
|
19093
|
-
import { homedir as
|
|
19094
|
-
import { join as
|
|
19465
|
+
import { homedir as homedir17 } from "node:os";
|
|
19466
|
+
import { join as join22 } from "node:path";
|
|
19095
19467
|
function gooseHome() {
|
|
19096
19468
|
if (process.env.GOOSE_HOME)
|
|
19097
19469
|
return process.env.GOOSE_HOME;
|
|
19098
19470
|
const xdg = process.env.XDG_DATA_HOME;
|
|
19099
|
-
return
|
|
19471
|
+
return join22(xdg && xdg.length > 0 ? xdg : join22(homedir17(), ".local", "share"), "goose");
|
|
19100
19472
|
}
|
|
19101
19473
|
function gooseDbPath() {
|
|
19102
|
-
return process.env.GOOSE_DB_PATH ||
|
|
19474
|
+
return process.env.GOOSE_DB_PATH || join22(gooseHome(), "sessions", "sessions.db");
|
|
19103
19475
|
}
|
|
19104
19476
|
function gooseTimestampToMs(value) {
|
|
19105
19477
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
@@ -19363,7 +19735,7 @@ var init_goose_projects = __esm(() => {
|
|
|
19363
19735
|
|
|
19364
19736
|
// lib/projects.ts
|
|
19365
19737
|
import { readdir as readdir5, stat as stat4 } from "node:fs/promises";
|
|
19366
|
-
import { join as
|
|
19738
|
+
import { join as join23, resolve as resolve12, sep } from "node:path";
|
|
19367
19739
|
async function getMtime(path, label) {
|
|
19368
19740
|
try {
|
|
19369
19741
|
return (await stat4(path)).mtime;
|
|
@@ -19389,7 +19761,7 @@ async function getClaudeProjectFolders() {
|
|
|
19389
19761
|
if (!entries)
|
|
19390
19762
|
return [];
|
|
19391
19763
|
const settled = await batchAll(entries.filter((entry) => entry.isDirectory()).map((entry) => async () => {
|
|
19392
|
-
const folderPath =
|
|
19764
|
+
const folderPath = join23(projectsPath, entry.name);
|
|
19393
19765
|
const mtime = await getMtime(folderPath, entry.name);
|
|
19394
19766
|
return {
|
|
19395
19767
|
name: entry.name,
|
|
@@ -19515,8 +19887,8 @@ function resolveProjectPath(projectName) {
|
|
|
19515
19887
|
throw new RangeError("Empty project name");
|
|
19516
19888
|
if (/^[/\\]/.test(projectName))
|
|
19517
19889
|
throw new RangeError("Absolute project name");
|
|
19518
|
-
const projectsPath =
|
|
19519
|
-
const candidate =
|
|
19890
|
+
const projectsPath = resolve12(getClaudeProjectsPath());
|
|
19891
|
+
const candidate = resolve12(join23(projectsPath, projectName));
|
|
19520
19892
|
if (!candidate.startsWith(projectsPath + sep)) {
|
|
19521
19893
|
throw new RangeError("Project path escapes root");
|
|
19522
19894
|
}
|
|
@@ -19534,7 +19906,7 @@ async function getSessionFiles(projectPath) {
|
|
|
19534
19906
|
return [];
|
|
19535
19907
|
const jsonlEntries = entries.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl") && extractSessionId2(entry.name));
|
|
19536
19908
|
const settled = await batchAll(jsonlEntries.map((entry) => async () => {
|
|
19537
|
-
const filePath =
|
|
19909
|
+
const filePath = join23(projectPath, entry.name);
|
|
19538
19910
|
const mtime = await getMtime(filePath, entry.name);
|
|
19539
19911
|
return {
|
|
19540
19912
|
name: entry.name,
|
|
@@ -19563,13 +19935,13 @@ var init_projects = __esm(() => {
|
|
|
19563
19935
|
|
|
19564
19936
|
// lib/resolve-subagent-path.ts
|
|
19565
19937
|
import { access as access2 } from "fs/promises";
|
|
19566
|
-
import { join as
|
|
19938
|
+
import { join as join24, relative as relative3 } from "path";
|
|
19567
19939
|
async function resolveSubagentPath(projectsPath, projectName, sessionId, agentId) {
|
|
19568
19940
|
const fileName = `agent-${agentId}.jsonl`;
|
|
19569
19941
|
const candidatePaths = [
|
|
19570
|
-
|
|
19571
|
-
|
|
19572
|
-
|
|
19942
|
+
join24(projectsPath, projectName, fileName),
|
|
19943
|
+
join24(projectsPath, projectName, sessionId, fileName),
|
|
19944
|
+
join24(projectsPath, projectName, sessionId, "subagents", fileName)
|
|
19573
19945
|
];
|
|
19574
19946
|
for (const candidatePath of candidatePaths) {
|
|
19575
19947
|
if (relative3(projectsPath, candidatePath).startsWith("..")) {
|
|
@@ -19591,7 +19963,7 @@ var init_resolve_subagent_path = () => {};
|
|
|
19591
19963
|
|
|
19592
19964
|
// lib/log-entries.ts
|
|
19593
19965
|
import { readFile as readFile10 } from "fs/promises";
|
|
19594
|
-
import { join as
|
|
19966
|
+
import { join as join25 } from "path";
|
|
19595
19967
|
function formatTimestamp(date) {
|
|
19596
19968
|
const base = formatDate(date);
|
|
19597
19969
|
const ms = date.getMilliseconds().toString().padStart(3, "0");
|
|
@@ -19789,7 +20161,7 @@ async function parseLogContent(fileContent, source = "session") {
|
|
|
19789
20161
|
async function parseSessionLog(projectName, sessionId) {
|
|
19790
20162
|
const projectDir = resolveProjectPath(projectName);
|
|
19791
20163
|
const projectsPath = getClaudeProjectsPath();
|
|
19792
|
-
const filePath =
|
|
20164
|
+
const filePath = join25(projectDir, `${sessionId}.jsonl`);
|
|
19793
20165
|
const fileContent = await readFile10(filePath, "utf-8");
|
|
19794
20166
|
const { entries: sessionEntries, rawLines: sessionRawLines, subagentIds } = await parseFileContent(fileContent, "session");
|
|
19795
20167
|
if (subagentIds.length === 0) {
|
|
@@ -19826,13 +20198,13 @@ var init_log_entries = __esm(() => {
|
|
|
19826
20198
|
});
|
|
19827
20199
|
|
|
19828
20200
|
// lib/codex-sessions.ts
|
|
19829
|
-
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";
|
|
19830
20202
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
19831
|
-
import { dirname as
|
|
19832
|
-
import { homedir as
|
|
20203
|
+
import { dirname as dirname8, join as join26 } from "node:path";
|
|
20204
|
+
import { homedir as homedir18 } from "node:os";
|
|
19833
20205
|
function readCache() {
|
|
19834
20206
|
try {
|
|
19835
|
-
if (!
|
|
20207
|
+
if (!existsSync14(CACHE_PATH))
|
|
19836
20208
|
return {};
|
|
19837
20209
|
return JSON.parse(readFileSync10(CACHE_PATH, "utf-8"));
|
|
19838
20210
|
} catch {
|
|
@@ -19841,7 +20213,7 @@ function readCache() {
|
|
|
19841
20213
|
}
|
|
19842
20214
|
function writeCacheEntry(sessionId, path) {
|
|
19843
20215
|
try {
|
|
19844
|
-
mkdirSync7(
|
|
20216
|
+
mkdirSync7(dirname8(CACHE_PATH), { recursive: true });
|
|
19845
20217
|
const cache = readCache();
|
|
19846
20218
|
cache[sessionId] = path;
|
|
19847
20219
|
writeFileSync6(CACHE_PATH, JSON.stringify(cache), "utf-8");
|
|
@@ -19849,9 +20221,9 @@ function writeCacheEntry(sessionId, path) {
|
|
|
19849
20221
|
}
|
|
19850
20222
|
function dirSearch(dir, sessionId) {
|
|
19851
20223
|
try {
|
|
19852
|
-
for (const f of
|
|
20224
|
+
for (const f of readdirSync9(dir, { withFileTypes: true })) {
|
|
19853
20225
|
if (f.isFile() && f.name.includes(sessionId) && f.name.endsWith(".jsonl")) {
|
|
19854
|
-
return
|
|
20226
|
+
return join26(dir, f.name);
|
|
19855
20227
|
}
|
|
19856
20228
|
}
|
|
19857
20229
|
} catch {}
|
|
@@ -19860,16 +20232,16 @@ function dirSearch(dir, sessionId) {
|
|
|
19860
20232
|
function findCodexTranscript(sessionId) {
|
|
19861
20233
|
const cache = readCache();
|
|
19862
20234
|
const cached = cache[sessionId];
|
|
19863
|
-
if (cached &&
|
|
20235
|
+
if (cached && existsSync14(cached))
|
|
19864
20236
|
return cached;
|
|
19865
|
-
const root =
|
|
20237
|
+
const root = join26(homedir18(), ".codex", "sessions");
|
|
19866
20238
|
const today = new Date;
|
|
19867
20239
|
const yesterday = new Date(today.getTime() - 24 * 60 * 60 * 1000);
|
|
19868
20240
|
const datedDirs = [today, yesterday].map((d) => {
|
|
19869
20241
|
const y = String(d.getUTCFullYear());
|
|
19870
20242
|
const m = String(d.getUTCMonth() + 1).padStart(2, "0");
|
|
19871
20243
|
const day = String(d.getUTCDate()).padStart(2, "0");
|
|
19872
|
-
return
|
|
20244
|
+
return join26(root, y, m, day);
|
|
19873
20245
|
});
|
|
19874
20246
|
for (const dir of datedDirs) {
|
|
19875
20247
|
const hit = dirSearch(dir, sessionId);
|
|
@@ -19879,16 +20251,16 @@ function findCodexTranscript(sessionId) {
|
|
|
19879
20251
|
}
|
|
19880
20252
|
}
|
|
19881
20253
|
try {
|
|
19882
|
-
for (const y of
|
|
20254
|
+
for (const y of readdirSync9(root, { withFileTypes: true })) {
|
|
19883
20255
|
if (!y.isDirectory())
|
|
19884
20256
|
continue;
|
|
19885
|
-
for (const m of
|
|
20257
|
+
for (const m of readdirSync9(join26(root, y.name), { withFileTypes: true })) {
|
|
19886
20258
|
if (!m.isDirectory())
|
|
19887
20259
|
continue;
|
|
19888
|
-
for (const d of
|
|
20260
|
+
for (const d of readdirSync9(join26(root, y.name, m.name), { withFileTypes: true })) {
|
|
19889
20261
|
if (!d.isDirectory())
|
|
19890
20262
|
continue;
|
|
19891
|
-
const hit = dirSearch(
|
|
20263
|
+
const hit = dirSearch(join26(root, y.name, m.name, d.name), sessionId);
|
|
19892
20264
|
if (hit) {
|
|
19893
20265
|
writeCacheEntry(sessionId, hit);
|
|
19894
20266
|
return hit;
|
|
@@ -20154,21 +20526,21 @@ var init_resolve_permission_mode = __esm(() => {
|
|
|
20154
20526
|
});
|
|
20155
20527
|
|
|
20156
20528
|
// lib/copilot-sessions.ts
|
|
20157
|
-
import { readFileSync as readFileSync12, readdirSync as
|
|
20529
|
+
import { readFileSync as readFileSync12, readdirSync as readdirSync10, existsSync as existsSync15, statSync as statSync12 } from "node:fs";
|
|
20158
20530
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
20159
|
-
import { join as
|
|
20160
|
-
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";
|
|
20161
20533
|
function getCopilotHome() {
|
|
20162
|
-
return process.env.COPILOT_HOME ||
|
|
20534
|
+
return process.env.COPILOT_HOME || join27(homedir19(), ".copilot");
|
|
20163
20535
|
}
|
|
20164
20536
|
function getCopilotSessionStateRoot2() {
|
|
20165
|
-
return
|
|
20537
|
+
return join27(getCopilotHome(), "session-state");
|
|
20166
20538
|
}
|
|
20167
20539
|
function getCopilotSessionDir(sessionId) {
|
|
20168
20540
|
if (!sessionId)
|
|
20169
20541
|
return null;
|
|
20170
|
-
const root =
|
|
20171
|
-
const candidate =
|
|
20542
|
+
const root = resolve13(getCopilotSessionStateRoot2());
|
|
20543
|
+
const candidate = resolve13(root, sessionId);
|
|
20172
20544
|
if (candidate === root || !candidate.startsWith(`${root}${sep2}`))
|
|
20173
20545
|
return null;
|
|
20174
20546
|
return candidate;
|
|
@@ -20177,19 +20549,19 @@ function resolveSessionFile(sessionId, filename) {
|
|
|
20177
20549
|
const dir = getCopilotSessionDir(sessionId);
|
|
20178
20550
|
if (!dir)
|
|
20179
20551
|
return null;
|
|
20180
|
-
return
|
|
20552
|
+
return join27(dir, filename);
|
|
20181
20553
|
}
|
|
20182
20554
|
function findCopilotTranscript(sessionId) {
|
|
20183
20555
|
const candidate = resolveSessionFile(sessionId, "events.jsonl");
|
|
20184
20556
|
if (!candidate)
|
|
20185
20557
|
return null;
|
|
20186
|
-
return
|
|
20558
|
+
return existsSync15(candidate) ? candidate : null;
|
|
20187
20559
|
}
|
|
20188
20560
|
function findCopilotWorkspace(sessionId) {
|
|
20189
20561
|
const candidate = resolveSessionFile(sessionId, "workspace.yaml");
|
|
20190
20562
|
if (!candidate)
|
|
20191
20563
|
return null;
|
|
20192
|
-
return
|
|
20564
|
+
return existsSync15(candidate) ? candidate : null;
|
|
20193
20565
|
}
|
|
20194
20566
|
function readYamlScalar(path, key) {
|
|
20195
20567
|
try {
|
|
@@ -20371,38 +20743,38 @@ var init_copilot_sessions = __esm(() => {
|
|
|
20371
20743
|
});
|
|
20372
20744
|
|
|
20373
20745
|
// lib/cursor-sessions.ts
|
|
20374
|
-
import { readFileSync as readFileSync13, readdirSync as
|
|
20746
|
+
import { readFileSync as readFileSync13, readdirSync as readdirSync11, existsSync as existsSync16, statSync as statSync13 } from "node:fs";
|
|
20375
20747
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
20376
|
-
import { basename as
|
|
20377
|
-
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";
|
|
20378
20750
|
function getCursorHome2() {
|
|
20379
|
-
return process.env.CURSOR_HOME ||
|
|
20751
|
+
return process.env.CURSOR_HOME || join28(homedir20(), ".cursor");
|
|
20380
20752
|
}
|
|
20381
20753
|
function getCursorSessionDir(sessionId) {
|
|
20382
20754
|
if (!sessionId)
|
|
20383
20755
|
return null;
|
|
20384
|
-
const home =
|
|
20385
|
-
const projectsRoot =
|
|
20756
|
+
const home = resolve14(getCursorHome2());
|
|
20757
|
+
const projectsRoot = resolve14(home, NEW_PROJECTS_DIR2);
|
|
20386
20758
|
let projectEntries = [];
|
|
20387
20759
|
try {
|
|
20388
|
-
projectEntries =
|
|
20760
|
+
projectEntries = readdirSync11(projectsRoot, { withFileTypes: true });
|
|
20389
20761
|
} catch {}
|
|
20390
20762
|
for (const entry of projectEntries) {
|
|
20391
20763
|
if (!entry.isDirectory())
|
|
20392
20764
|
continue;
|
|
20393
|
-
const candidate =
|
|
20394
|
-
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);
|
|
20395
20767
|
if (candidate === transcriptRoot || !candidate.startsWith(`${transcriptRoot}${sep3}`))
|
|
20396
20768
|
continue;
|
|
20397
|
-
if (
|
|
20769
|
+
if (existsSync16(candidate))
|
|
20398
20770
|
return candidate;
|
|
20399
20771
|
}
|
|
20400
20772
|
for (const sub of LEGACY_SESSION_ROOT_CANDIDATES2) {
|
|
20401
|
-
const root =
|
|
20402
|
-
const candidate =
|
|
20773
|
+
const root = resolve14(home, sub);
|
|
20774
|
+
const candidate = resolve14(root, sessionId);
|
|
20403
20775
|
if (candidate === root || !candidate.startsWith(`${root}${sep3}`))
|
|
20404
20776
|
continue;
|
|
20405
|
-
if (
|
|
20777
|
+
if (existsSync16(candidate))
|
|
20406
20778
|
return candidate;
|
|
20407
20779
|
}
|
|
20408
20780
|
return null;
|
|
@@ -20411,12 +20783,12 @@ function findCursorTranscript(sessionId) {
|
|
|
20411
20783
|
const dir = getCursorSessionDir(sessionId);
|
|
20412
20784
|
if (!dir)
|
|
20413
20785
|
return null;
|
|
20414
|
-
const newCandidate =
|
|
20415
|
-
if (
|
|
20786
|
+
const newCandidate = join28(dir, `${basename4(dir)}.jsonl`);
|
|
20787
|
+
if (existsSync16(newCandidate))
|
|
20416
20788
|
return newCandidate;
|
|
20417
20789
|
for (const name of LEGACY_TRANSCRIPT_FILE_CANDIDATES2) {
|
|
20418
|
-
const candidate =
|
|
20419
|
-
if (
|
|
20790
|
+
const candidate = join28(dir, name);
|
|
20791
|
+
if (existsSync16(candidate))
|
|
20420
20792
|
return candidate;
|
|
20421
20793
|
}
|
|
20422
20794
|
return null;
|
|
@@ -20627,12 +20999,12 @@ var init_cursor_sessions = __esm(() => {
|
|
|
20627
20999
|
});
|
|
20628
21000
|
|
|
20629
21001
|
// lib/pi-sessions.ts
|
|
20630
|
-
import { readFileSync as readFileSync14, readdirSync as
|
|
21002
|
+
import { readFileSync as readFileSync14, readdirSync as readdirSync12, existsSync as existsSync17, statSync as statSync14 } from "node:fs";
|
|
20631
21003
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
20632
|
-
import { join as
|
|
20633
|
-
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";
|
|
20634
21006
|
function getPiSessionStateRoot() {
|
|
20635
|
-
return process.env.PI_SESSIONS_DIR ||
|
|
21007
|
+
return process.env.PI_SESSIONS_DIR || join29(homedir21(), ".pi", "agent", "sessions");
|
|
20636
21008
|
}
|
|
20637
21009
|
function isSafeSessionId(sessionId) {
|
|
20638
21010
|
return UUID_RE.test(sessionId);
|
|
@@ -20640,20 +21012,20 @@ function isSafeSessionId(sessionId) {
|
|
|
20640
21012
|
function findPiTranscript(sessionId) {
|
|
20641
21013
|
if (!isSafeSessionId(sessionId))
|
|
20642
21014
|
return null;
|
|
20643
|
-
const root =
|
|
21015
|
+
const root = resolve15(getPiSessionStateRoot());
|
|
20644
21016
|
let cwdDirs;
|
|
20645
21017
|
try {
|
|
20646
|
-
cwdDirs =
|
|
21018
|
+
cwdDirs = readdirSync12(root);
|
|
20647
21019
|
} catch {
|
|
20648
21020
|
return null;
|
|
20649
21021
|
}
|
|
20650
21022
|
for (const cwdDir of cwdDirs) {
|
|
20651
|
-
const cwdPath =
|
|
21023
|
+
const cwdPath = resolve15(root, cwdDir);
|
|
20652
21024
|
if (!cwdPath.startsWith(`${root}${sep4}`))
|
|
20653
21025
|
continue;
|
|
20654
21026
|
let files;
|
|
20655
21027
|
try {
|
|
20656
|
-
files =
|
|
21028
|
+
files = readdirSync12(cwdPath);
|
|
20657
21029
|
} catch {
|
|
20658
21030
|
continue;
|
|
20659
21031
|
}
|
|
@@ -20661,10 +21033,10 @@ function findPiTranscript(sessionId) {
|
|
|
20661
21033
|
const m = SESSION_FILE_RE2.exec(f);
|
|
20662
21034
|
if (!m || m[1].toLowerCase() !== sessionId.toLowerCase())
|
|
20663
21035
|
continue;
|
|
20664
|
-
const candidate =
|
|
21036
|
+
const candidate = resolve15(cwdPath, f);
|
|
20665
21037
|
if (!candidate.startsWith(`${cwdPath}${sep4}`))
|
|
20666
21038
|
continue;
|
|
20667
|
-
if (
|
|
21039
|
+
if (existsSync17(candidate))
|
|
20668
21040
|
return candidate;
|
|
20669
21041
|
}
|
|
20670
21042
|
}
|
|
@@ -21070,31 +21442,31 @@ var init_pack_failclosed = __esm(() => {
|
|
|
21070
21442
|
// lib/atomic-write.ts
|
|
21071
21443
|
import {
|
|
21072
21444
|
chmodSync as chmodSync2,
|
|
21073
|
-
existsSync as
|
|
21445
|
+
existsSync as existsSync18,
|
|
21074
21446
|
mkdirSync as mkdirSync8,
|
|
21075
21447
|
renameSync as renameSync4,
|
|
21076
21448
|
rmSync as rmSync3,
|
|
21077
|
-
statSync as
|
|
21449
|
+
statSync as statSync15,
|
|
21078
21450
|
writeFileSync as writeFileSync7
|
|
21079
21451
|
} from "node:fs";
|
|
21080
|
-
import { dirname as
|
|
21452
|
+
import { dirname as dirname9 } from "node:path";
|
|
21081
21453
|
import { randomBytes } from "node:crypto";
|
|
21082
21454
|
function writeJsonAtomically(filePath, value, opts = {}) {
|
|
21083
21455
|
const mode = opts.mode ?? 384;
|
|
21084
21456
|
const dirMode = opts.dirMode ?? 448;
|
|
21085
|
-
const dir =
|
|
21086
|
-
if (!
|
|
21457
|
+
const dir = dirname9(filePath);
|
|
21458
|
+
if (!existsSync18(dir))
|
|
21087
21459
|
mkdirSync8(dir, { recursive: true, mode: dirMode });
|
|
21088
21460
|
const tmp = `${filePath}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
21089
21461
|
try {
|
|
21090
21462
|
writeFileSync7(tmp, JSON.stringify(value, null, 2), { mode });
|
|
21091
21463
|
try {
|
|
21092
|
-
if ((
|
|
21464
|
+
if ((statSync15(tmp).mode & 63) !== 0)
|
|
21093
21465
|
chmodSync2(tmp, mode);
|
|
21094
21466
|
} catch {}
|
|
21095
21467
|
renameSync4(tmp, filePath);
|
|
21096
21468
|
try {
|
|
21097
|
-
if ((
|
|
21469
|
+
if ((statSync15(filePath).mode & 63) !== 0)
|
|
21098
21470
|
chmodSync2(filePath, mode);
|
|
21099
21471
|
} catch {}
|
|
21100
21472
|
} catch (err) {
|
|
@@ -21107,18 +21479,18 @@ function writeJsonAtomically(filePath, value, opts = {}) {
|
|
|
21107
21479
|
var init_atomic_write = () => {};
|
|
21108
21480
|
|
|
21109
21481
|
// src/hooks/session-pause.ts
|
|
21110
|
-
import { existsSync as
|
|
21482
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync9, readdirSync as readdirSync13, readFileSync as readFileSync15, rmSync as rmSync4 } from "node:fs";
|
|
21111
21483
|
import { createHash as createHash6 } from "node:crypto";
|
|
21112
|
-
import { join as
|
|
21484
|
+
import { join as join30, resolve as resolve16 } from "node:path";
|
|
21113
21485
|
function pauseStateDir() {
|
|
21114
21486
|
const override = process.env.FAILPROOFAI_STATE_DIR;
|
|
21115
21487
|
if (override)
|
|
21116
|
-
return
|
|
21488
|
+
return resolve16(override, "sessions");
|
|
21117
21489
|
return sessionPauseDir();
|
|
21118
21490
|
}
|
|
21119
21491
|
function pauseFilePath(sessionId) {
|
|
21120
21492
|
const digest = createHash6("sha256").update(sessionId).digest("hex").slice(0, 32);
|
|
21121
|
-
return
|
|
21493
|
+
return join30(pauseStateDir(), `${digest}.json`);
|
|
21122
21494
|
}
|
|
21123
21495
|
function parsePauseDuration(input, ceilingMs = PAUSE_CEILING_MS) {
|
|
21124
21496
|
if (input === undefined || input === "")
|
|
@@ -21174,7 +21546,7 @@ function readActivePause(sessionId, now = Date.now()) {
|
|
|
21174
21546
|
return null;
|
|
21175
21547
|
try {
|
|
21176
21548
|
const path = pauseFilePath(sessionId);
|
|
21177
|
-
if (!
|
|
21549
|
+
if (!existsSync19(path))
|
|
21178
21550
|
return null;
|
|
21179
21551
|
const stored = parseStored(JSON.parse(readFileSync15(path, "utf8")));
|
|
21180
21552
|
if (!stored)
|
|
@@ -21205,7 +21577,7 @@ function writePause(opts) {
|
|
|
21205
21577
|
}
|
|
21206
21578
|
function clearPause(sessionId) {
|
|
21207
21579
|
const path = pauseFilePath(sessionId);
|
|
21208
|
-
if (!
|
|
21580
|
+
if (!existsSync19(path))
|
|
21209
21581
|
return false;
|
|
21210
21582
|
try {
|
|
21211
21583
|
rmSync4(path);
|
|
@@ -21216,12 +21588,12 @@ function clearPause(sessionId) {
|
|
|
21216
21588
|
}
|
|
21217
21589
|
function listActivePauses(now = Date.now()) {
|
|
21218
21590
|
const dir = pauseStateDir();
|
|
21219
|
-
if (!
|
|
21591
|
+
if (!existsSync19(dir))
|
|
21220
21592
|
return [];
|
|
21221
21593
|
const out = [];
|
|
21222
21594
|
let names;
|
|
21223
21595
|
try {
|
|
21224
|
-
names =
|
|
21596
|
+
names = readdirSync13(dir);
|
|
21225
21597
|
} catch {
|
|
21226
21598
|
return [];
|
|
21227
21599
|
}
|
|
@@ -21229,7 +21601,7 @@ function listActivePauses(now = Date.now()) {
|
|
|
21229
21601
|
if (!name.endsWith(".json"))
|
|
21230
21602
|
continue;
|
|
21231
21603
|
try {
|
|
21232
|
-
const stored = parseStored(JSON.parse(readFileSync15(
|
|
21604
|
+
const stored = parseStored(JSON.parse(readFileSync15(join30(dir, name), "utf8")));
|
|
21233
21605
|
if (!stored || stored.expiresAt <= now)
|
|
21234
21606
|
continue;
|
|
21235
21607
|
const { schemaVersion: _ignored, ...pause } = stored;
|
|
@@ -21270,17 +21642,17 @@ var init_session_pause = __esm(() => {
|
|
|
21270
21642
|
import { createHash as createHash7 } from "node:crypto";
|
|
21271
21643
|
import {
|
|
21272
21644
|
chmodSync as chmodSync3,
|
|
21273
|
-
existsSync as
|
|
21645
|
+
existsSync as existsSync20,
|
|
21274
21646
|
mkdirSync as mkdirSync10,
|
|
21275
|
-
readdirSync as
|
|
21647
|
+
readdirSync as readdirSync14,
|
|
21276
21648
|
readFileSync as readFileSync16,
|
|
21277
21649
|
renameSync as renameSync5,
|
|
21278
21650
|
rmSync as rmSync5,
|
|
21279
|
-
statSync as
|
|
21651
|
+
statSync as statSync16,
|
|
21280
21652
|
writeFileSync as writeFileSync8
|
|
21281
21653
|
} from "node:fs";
|
|
21282
21654
|
import { createRequire as createRequire2 } from "node:module";
|
|
21283
|
-
import { dirname as
|
|
21655
|
+
import { dirname as dirname10, resolve as resolve17 } from "node:path";
|
|
21284
21656
|
import { gunzipSync } from "node:zlib";
|
|
21285
21657
|
function baseUrl2() {
|
|
21286
21658
|
return (process.env.FAILPROOFAI_DAEMON_BASE_URL || DEFAULT_BASE_URL2).replace(/\/+$/, "");
|
|
@@ -21289,7 +21661,7 @@ function daemonBinaryDir() {
|
|
|
21289
21661
|
return binDir();
|
|
21290
21662
|
}
|
|
21291
21663
|
function installedBinaryPath(ver = version2) {
|
|
21292
|
-
return
|
|
21664
|
+
return resolve17(daemonBinaryDir(), `failproofaid-${ver}`);
|
|
21293
21665
|
}
|
|
21294
21666
|
function daemonAssetUrl(key, ver = version2) {
|
|
21295
21667
|
return `${baseUrl2()}/v${ver}/failproofaid-${key}.gz`;
|
|
@@ -21306,31 +21678,31 @@ function npmPlatformBinaryPath(key) {
|
|
|
21306
21678
|
return null;
|
|
21307
21679
|
const name = platformPackageName(key);
|
|
21308
21680
|
try {
|
|
21309
|
-
const requireFromRoot = createRequire2(
|
|
21310
|
-
const found = platformPackageBinary(
|
|
21681
|
+
const requireFromRoot = createRequire2(resolve17(packageRoot, "package.json"));
|
|
21682
|
+
const found = platformPackageBinary(dirname10(requireFromRoot.resolve(`${name}/package.json`)));
|
|
21311
21683
|
if (found)
|
|
21312
21684
|
return found;
|
|
21313
21685
|
} catch {}
|
|
21314
|
-
return platformPackageBinary(
|
|
21686
|
+
return platformPackageBinary(resolve17(packageRoot, "node_modules", name));
|
|
21315
21687
|
}
|
|
21316
21688
|
function platformPackageBinary(dir) {
|
|
21317
21689
|
try {
|
|
21318
|
-
const manifest = JSON.parse(readFileSync16(
|
|
21690
|
+
const manifest = JSON.parse(readFileSync16(resolve17(dir, "package.json"), "utf8"));
|
|
21319
21691
|
if (manifest.version !== version2)
|
|
21320
21692
|
return null;
|
|
21321
21693
|
} catch {
|
|
21322
21694
|
return null;
|
|
21323
21695
|
}
|
|
21324
|
-
const candidate =
|
|
21325
|
-
return
|
|
21696
|
+
const candidate = resolve17(dir, "bin", "failproofaid");
|
|
21697
|
+
return existsSync20(candidate) ? candidate : null;
|
|
21326
21698
|
}
|
|
21327
21699
|
function pruneOldDaemonBinaries(keep = 2) {
|
|
21328
21700
|
const removed = [];
|
|
21329
21701
|
try {
|
|
21330
21702
|
const dir = daemonBinaryDir();
|
|
21331
|
-
const entries =
|
|
21332
|
-
const full =
|
|
21333
|
-
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 };
|
|
21334
21706
|
}).sort((a, b) => b.mtime - a.mtime);
|
|
21335
21707
|
for (const stale of entries.slice(keep)) {
|
|
21336
21708
|
try {
|
|
@@ -21400,7 +21772,7 @@ function digestFor2(manifest, assetName) {
|
|
|
21400
21772
|
}
|
|
21401
21773
|
async function downloadFailproofaidBinary(key) {
|
|
21402
21774
|
const target = installedBinaryPath();
|
|
21403
|
-
if (
|
|
21775
|
+
if (existsSync20(target))
|
|
21404
21776
|
return { path: target };
|
|
21405
21777
|
if (process.env.FAILPROOFAI_NO_DOWNLOAD) {
|
|
21406
21778
|
return { error: "daemon downloads are disabled (FAILPROOFAI_NO_DOWNLOAD)" };
|
|
@@ -21434,10 +21806,10 @@ var init_daemon_download = __esm(() => {
|
|
|
21434
21806
|
|
|
21435
21807
|
// src/hooks/daemon-client.ts
|
|
21436
21808
|
import { createConnection as createConnection2 } from "node:net";
|
|
21437
|
-
import { existsSync as
|
|
21809
|
+
import { existsSync as existsSync21 } from "node:fs";
|
|
21438
21810
|
function daemonSocketPresent() {
|
|
21439
21811
|
try {
|
|
21440
|
-
return
|
|
21812
|
+
return existsSync21(socketPath2());
|
|
21441
21813
|
} catch {
|
|
21442
21814
|
return false;
|
|
21443
21815
|
}
|
|
@@ -21563,7 +21935,7 @@ var init_daemon_client2 = __esm(() => {
|
|
|
21563
21935
|
|
|
21564
21936
|
// src/hooks/daemon-service.ts
|
|
21565
21937
|
import {
|
|
21566
|
-
existsSync as
|
|
21938
|
+
existsSync as existsSync22,
|
|
21567
21939
|
mkdirSync as mkdirSync11,
|
|
21568
21940
|
mkdtempSync,
|
|
21569
21941
|
readFileSync as readFileSync17,
|
|
@@ -21571,8 +21943,8 @@ import {
|
|
|
21571
21943
|
unlinkSync as unlinkSync3,
|
|
21572
21944
|
rmSync as rmSync6
|
|
21573
21945
|
} from "node:fs";
|
|
21574
|
-
import { homedir as
|
|
21575
|
-
import { resolve as
|
|
21946
|
+
import { homedir as homedir22, tmpdir as tmpdir2, userInfo } from "node:os";
|
|
21947
|
+
import { resolve as resolve18 } from "node:path";
|
|
21576
21948
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
21577
21949
|
function setDaemonConfigured(value, installedVersion) {
|
|
21578
21950
|
try {
|
|
@@ -21594,13 +21966,13 @@ function resolveFailproofaidBinaryPath() {
|
|
|
21594
21966
|
if (process.env.FAILPROOFAI_DAEMON_BINARY)
|
|
21595
21967
|
return process.env.FAILPROOFAI_DAEMON_BINARY;
|
|
21596
21968
|
const downloaded = installedBinaryPath();
|
|
21597
|
-
if (
|
|
21969
|
+
if (existsSync22(downloaded))
|
|
21598
21970
|
return downloaded;
|
|
21599
21971
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
21600
21972
|
if (packageRoot) {
|
|
21601
21973
|
for (const profile of ["release", "debug"]) {
|
|
21602
|
-
const candidate =
|
|
21603
|
-
if (
|
|
21974
|
+
const candidate = resolve18(packageRoot, "target", profile, "failproofaid");
|
|
21975
|
+
if (existsSync22(candidate))
|
|
21604
21976
|
return candidate;
|
|
21605
21977
|
}
|
|
21606
21978
|
}
|
|
@@ -21630,8 +22002,8 @@ function resolveWorkerCommand() {
|
|
|
21630
22002
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
21631
22003
|
if (!packageRoot)
|
|
21632
22004
|
return null;
|
|
21633
|
-
const workerScript =
|
|
21634
|
-
if (!
|
|
22005
|
+
const workerScript = resolve18(packageRoot, "dist", "worker.mjs");
|
|
22006
|
+
if (!existsSync22(workerScript))
|
|
21635
22007
|
return null;
|
|
21636
22008
|
return `${shellQuote(process.execPath)} ${shellQuote(workerScript)}`;
|
|
21637
22009
|
}
|
|
@@ -21641,8 +22013,8 @@ function resolveCliCommand() {
|
|
|
21641
22013
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
21642
22014
|
if (!packageRoot)
|
|
21643
22015
|
return null;
|
|
21644
|
-
const cliScript =
|
|
21645
|
-
if (!
|
|
22016
|
+
const cliScript = resolve18(packageRoot, "dist", "cli.mjs");
|
|
22017
|
+
if (!existsSync22(cliScript))
|
|
21646
22018
|
return null;
|
|
21647
22019
|
return `${shellQuote(process.execPath)} ${shellQuote(cliScript)}`;
|
|
21648
22020
|
}
|
|
@@ -21655,8 +22027,8 @@ function workerScriptPath() {
|
|
|
21655
22027
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
21656
22028
|
if (!packageRoot)
|
|
21657
22029
|
return null;
|
|
21658
|
-
const workerScript =
|
|
21659
|
-
return
|
|
22030
|
+
const workerScript = resolve18(packageRoot, "dist", "worker.mjs");
|
|
22031
|
+
return existsSync22(workerScript) ? workerScript : null;
|
|
21660
22032
|
}
|
|
21661
22033
|
function assertUnitSafe(value, field) {
|
|
21662
22034
|
if (UNIT_UNSAFE_RE.test(value)) {
|
|
@@ -21682,10 +22054,10 @@ function systemdUnitDir() {
|
|
|
21682
22054
|
return process.env.FAILPROOFAI_SYSTEMD_DIR || "/etc/systemd/system";
|
|
21683
22055
|
}
|
|
21684
22056
|
function systemdUnitPath(user = serviceUser()) {
|
|
21685
|
-
return
|
|
22057
|
+
return resolve18(systemdUnitDir(), systemdUnitName(user));
|
|
21686
22058
|
}
|
|
21687
22059
|
function legacySystemdUserUnitPath() {
|
|
21688
|
-
return
|
|
22060
|
+
return resolve18(homedir22(), ".config", "systemd", "user", "failproofaid.service");
|
|
21689
22061
|
}
|
|
21690
22062
|
function launchdLabel(user = serviceUser()) {
|
|
21691
22063
|
return `ai.failproof.failproofaid.${user}`;
|
|
@@ -21694,7 +22066,7 @@ function launchdPlistPath(user = serviceUser()) {
|
|
|
21694
22066
|
return `/Library/LaunchDaemons/${launchdLabel(user)}.plist`;
|
|
21695
22067
|
}
|
|
21696
22068
|
function legacyLaunchAgentPlistPath() {
|
|
21697
|
-
return
|
|
22069
|
+
return resolve18(homedir22(), "Library", "LaunchAgents", "ai.failproof.failproofaid.plist");
|
|
21698
22070
|
}
|
|
21699
22071
|
function legacySharedLaunchDaemonPath() {
|
|
21700
22072
|
return "/Library/LaunchDaemons/ai.failproof.failproofaid.plist";
|
|
@@ -21742,8 +22114,8 @@ function runPrivileged(command, args) {
|
|
|
21742
22114
|
execFileSync2(cmd, argv, { stdio: "ignore", timeout: SERVICE_CMD_TIMEOUT_MS });
|
|
21743
22115
|
}
|
|
21744
22116
|
function writePrivilegedFile(destination, contents, mode = "0644") {
|
|
21745
|
-
const stagingDir = mkdtempSync(
|
|
21746
|
-
const staging =
|
|
22117
|
+
const stagingDir = mkdtempSync(resolve18(tmpdir2(), "failproofaid-stage-"));
|
|
22118
|
+
const staging = resolve18(stagingDir, "service-definition");
|
|
21747
22119
|
try {
|
|
21748
22120
|
writeFileSync9(staging, contents, "utf8");
|
|
21749
22121
|
runPrivileged("install", ["-m", mode, staging, destination]);
|
|
@@ -21755,7 +22127,7 @@ function removeLegacyUserService() {
|
|
|
21755
22127
|
try {
|
|
21756
22128
|
if (process.platform === "linux") {
|
|
21757
22129
|
const legacy = legacySystemdUserUnitPath();
|
|
21758
|
-
if (!
|
|
22130
|
+
if (!existsSync22(legacy))
|
|
21759
22131
|
return;
|
|
21760
22132
|
try {
|
|
21761
22133
|
execFileSync2("systemctl", ["--user", "disable", "--now", "failproofaid.service"], {
|
|
@@ -21772,7 +22144,7 @@ function removeLegacyUserService() {
|
|
|
21772
22144
|
} catch {}
|
|
21773
22145
|
} else {
|
|
21774
22146
|
const legacyAgent = legacyLaunchAgentPlistPath();
|
|
21775
|
-
if (
|
|
22147
|
+
if (existsSync22(legacyAgent)) {
|
|
21776
22148
|
try {
|
|
21777
22149
|
execFileSync2("launchctl", ["unload", "-w", legacyAgent], {
|
|
21778
22150
|
stdio: "ignore",
|
|
@@ -21782,7 +22154,7 @@ function removeLegacyUserService() {
|
|
|
21782
22154
|
unlinkSync3(legacyAgent);
|
|
21783
22155
|
}
|
|
21784
22156
|
const legacyDaemon = legacySharedLaunchDaemonPath();
|
|
21785
|
-
if (
|
|
22157
|
+
if (existsSync22(legacyDaemon)) {
|
|
21786
22158
|
try {
|
|
21787
22159
|
runPrivileged("launchctl", ["unload", "-w", legacyDaemon]);
|
|
21788
22160
|
} catch {}
|
|
@@ -21798,8 +22170,8 @@ function systemdUnitContents(binaryPath, workerCmd, cliCmd = null) {
|
|
|
21798
22170
|
`).join("");
|
|
21799
22171
|
const user = assertUnitSafe(serviceUser(), "User");
|
|
21800
22172
|
assertUnitSafe(binaryPath, "ExecStart");
|
|
21801
|
-
assertUnitSafe(
|
|
21802
|
-
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));
|
|
21803
22175
|
const conditionLines = conditionPaths.map((p) => `ConditionPathExists=${assertUnitSafe(p, "ConditionPathExists")}
|
|
21804
22176
|
`).join("");
|
|
21805
22177
|
return `[Unit]
|
|
@@ -21812,7 +22184,7 @@ User=${user}
|
|
|
21812
22184
|
# Set explicitly rather than relying on systemd deriving it from User=:
|
|
21813
22185
|
# failproofaid stores per-user state and refuses to start without HOME, so this
|
|
21814
22186
|
# required variable is not left to a version-dependent default.
|
|
21815
|
-
Environment="HOME=${
|
|
22187
|
+
Environment="HOME=${homedir22()}"
|
|
21816
22188
|
${envLines}ExecStart=${binaryPath}
|
|
21817
22189
|
Restart=on-failure
|
|
21818
22190
|
RestartSec=2
|
|
@@ -21860,9 +22232,9 @@ ${env.map(([key, value]) => ` <key>${key}</key>
|
|
|
21860
22232
|
<key>UserName</key>
|
|
21861
22233
|
<string>${escapeXml(serviceUser())}</string>
|
|
21862
22234
|
${envBlock} <key>StandardOutPath</key>
|
|
21863
|
-
<string>${escapeXml(
|
|
22235
|
+
<string>${escapeXml(resolve18(logDir, "failproofaid.log"))}</string>
|
|
21864
22236
|
<key>StandardErrorPath</key>
|
|
21865
|
-
<string>${escapeXml(
|
|
22237
|
+
<string>${escapeXml(resolve18(logDir, "failproofaid.err.log"))}</string>
|
|
21866
22238
|
</dict>
|
|
21867
22239
|
</plist>
|
|
21868
22240
|
`;
|
|
@@ -21994,7 +22366,7 @@ function readInstalledServiceDefinition() {
|
|
|
21994
22366
|
if (!isDaemonSupportedPlatform())
|
|
21995
22367
|
return null;
|
|
21996
22368
|
const path = daemonServiceFilePath();
|
|
21997
|
-
if (!path || !
|
|
22369
|
+
if (!path || !existsSync22(path))
|
|
21998
22370
|
return null;
|
|
21999
22371
|
try {
|
|
22000
22372
|
return readFileSync17(path, "utf8");
|
|
@@ -22130,7 +22502,7 @@ async function uninstallDaemonService() {
|
|
|
22130
22502
|
try {
|
|
22131
22503
|
if (process.platform === "linux") {
|
|
22132
22504
|
const unitPath = systemdUnitPath();
|
|
22133
|
-
if (!
|
|
22505
|
+
if (!existsSync22(unitPath))
|
|
22134
22506
|
return;
|
|
22135
22507
|
try {
|
|
22136
22508
|
runPrivileged("systemctl", ["disable", "--now", systemdUnitName()]);
|
|
@@ -22141,7 +22513,7 @@ async function uninstallDaemonService() {
|
|
|
22141
22513
|
} catch {}
|
|
22142
22514
|
} else {
|
|
22143
22515
|
const plistPath = launchdPlistPath();
|
|
22144
|
-
if (!
|
|
22516
|
+
if (!existsSync22(plistPath))
|
|
22145
22517
|
return;
|
|
22146
22518
|
try {
|
|
22147
22519
|
runPrivileged("launchctl", ["unload", "-w", plistPath]);
|
|
@@ -22158,7 +22530,7 @@ function daemonVersionSkew() {
|
|
|
22158
22530
|
const recorded = readVersionFile()?.daemon;
|
|
22159
22531
|
if (!recorded)
|
|
22160
22532
|
return null;
|
|
22161
|
-
if (!
|
|
22533
|
+
if (!existsSync22(installedBinaryPath(recorded)))
|
|
22162
22534
|
return null;
|
|
22163
22535
|
return recorded === version2 ? null : { installed: recorded, expected: version2 };
|
|
22164
22536
|
}
|
|
@@ -22176,7 +22548,7 @@ function daemonServiceStatus() {
|
|
|
22176
22548
|
if (!isDaemonSupportedPlatform())
|
|
22177
22549
|
return "unsupported-platform";
|
|
22178
22550
|
if (process.platform === "linux") {
|
|
22179
|
-
if (!
|
|
22551
|
+
if (!existsSync22(systemdUnitPath()))
|
|
22180
22552
|
return "not-installed";
|
|
22181
22553
|
try {
|
|
22182
22554
|
const out = execFileSync2("systemctl", ["is-active", systemdUnitName()], {
|
|
@@ -22189,7 +22561,7 @@ function daemonServiceStatus() {
|
|
|
22189
22561
|
}
|
|
22190
22562
|
}
|
|
22191
22563
|
const plistPath = launchdPlistPath();
|
|
22192
|
-
if (!
|
|
22564
|
+
if (!existsSync22(plistPath))
|
|
22193
22565
|
return "not-installed";
|
|
22194
22566
|
try {
|
|
22195
22567
|
const root = typeof process.getuid === "function" && process.getuid() === 0;
|
|
@@ -22221,26 +22593,26 @@ var init_daemon_service = __esm(() => {
|
|
|
22221
22593
|
// src/hooks/fp-reset.ts
|
|
22222
22594
|
import {
|
|
22223
22595
|
copyFileSync,
|
|
22224
|
-
existsSync as
|
|
22596
|
+
existsSync as existsSync23,
|
|
22225
22597
|
mkdirSync as mkdirSync12,
|
|
22226
22598
|
readFileSync as readFileSync18,
|
|
22227
|
-
readdirSync as
|
|
22599
|
+
readdirSync as readdirSync15,
|
|
22228
22600
|
renameSync as renameSync6,
|
|
22229
22601
|
rmSync as rmSync7,
|
|
22230
22602
|
rmdirSync,
|
|
22231
|
-
statSync as
|
|
22603
|
+
statSync as statSync17,
|
|
22232
22604
|
writeFileSync as writeFileSync10
|
|
22233
22605
|
} from "node:fs";
|
|
22234
|
-
import { dirname as
|
|
22606
|
+
import { dirname as dirname11, isAbsolute as isAbsolute3, relative as relative4, resolve as resolve19 } from "node:path";
|
|
22235
22607
|
function migrateConventionPolicies() {
|
|
22236
22608
|
const from = legacy.customPoliciesDir();
|
|
22237
|
-
if (!
|
|
22609
|
+
if (!existsSync23(from))
|
|
22238
22610
|
return [];
|
|
22239
22611
|
const moved = [];
|
|
22240
22612
|
const mergeInto = (dir, dest, prefix) => {
|
|
22241
22613
|
let entries;
|
|
22242
22614
|
try {
|
|
22243
|
-
entries =
|
|
22615
|
+
entries = readdirSync15(dir, { withFileTypes: true });
|
|
22244
22616
|
} catch {
|
|
22245
22617
|
return;
|
|
22246
22618
|
}
|
|
@@ -22252,17 +22624,17 @@ function migrateConventionPolicies() {
|
|
|
22252
22624
|
return;
|
|
22253
22625
|
}
|
|
22254
22626
|
for (const entry of entries) {
|
|
22255
|
-
const source =
|
|
22256
|
-
const target =
|
|
22627
|
+
const source = resolve19(dir, entry.name);
|
|
22628
|
+
const target = resolve19(dest, entry.name);
|
|
22257
22629
|
const name = `${prefix}${entry.name}`;
|
|
22258
|
-
if (!
|
|
22630
|
+
if (!existsSync23(target)) {
|
|
22259
22631
|
try {
|
|
22260
22632
|
renameSync6(source, target);
|
|
22261
22633
|
moved.push(name);
|
|
22262
22634
|
} catch {}
|
|
22263
22635
|
continue;
|
|
22264
22636
|
}
|
|
22265
|
-
if (entry.isDirectory() &&
|
|
22637
|
+
if (entry.isDirectory() && statSync17(target).isDirectory()) {
|
|
22266
22638
|
mergeInto(source, target, `${name}/`);
|
|
22267
22639
|
try {
|
|
22268
22640
|
rmdirSync(source);
|
|
@@ -22282,23 +22654,23 @@ function migrateLegacySpool() {
|
|
|
22282
22654
|
[legacy.spoolDir(), spoolDir()],
|
|
22283
22655
|
[legacy.failedDir(), failedDir()]
|
|
22284
22656
|
]) {
|
|
22285
|
-
if (!
|
|
22657
|
+
if (!existsSync23(from))
|
|
22286
22658
|
continue;
|
|
22287
22659
|
try {
|
|
22288
22660
|
mkdirSync12(to, { recursive: true });
|
|
22289
|
-
for (const entry of
|
|
22661
|
+
for (const entry of readdirSync15(from, { withFileTypes: true })) {
|
|
22290
22662
|
if (!entry.isFile())
|
|
22291
22663
|
continue;
|
|
22292
22664
|
let name = entry.name;
|
|
22293
22665
|
let n = 0;
|
|
22294
|
-
while (
|
|
22666
|
+
while (existsSync23(resolve19(to, name)))
|
|
22295
22667
|
name = `legacy-${n++}-${entry.name}`;
|
|
22296
22668
|
try {
|
|
22297
|
-
renameSync6(
|
|
22669
|
+
renameSync6(resolve19(from, entry.name), resolve19(to, name));
|
|
22298
22670
|
moved.push(name);
|
|
22299
22671
|
} catch {
|
|
22300
22672
|
try {
|
|
22301
|
-
copyFileSync(
|
|
22673
|
+
copyFileSync(resolve19(from, entry.name), resolve19(to, name));
|
|
22302
22674
|
moved.push(name);
|
|
22303
22675
|
} catch {}
|
|
22304
22676
|
}
|
|
@@ -22309,11 +22681,11 @@ function migrateLegacySpool() {
|
|
|
22309
22681
|
}
|
|
22310
22682
|
function migrateHookActivity() {
|
|
22311
22683
|
const from = legacy.hookActivityDir();
|
|
22312
|
-
if (!
|
|
22684
|
+
if (!existsSync23(from))
|
|
22313
22685
|
return [];
|
|
22314
22686
|
const moved = [];
|
|
22315
22687
|
try {
|
|
22316
|
-
const entries =
|
|
22688
|
+
const entries = readdirSync15(from, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl"));
|
|
22317
22689
|
if (entries.length === 0)
|
|
22318
22690
|
return [];
|
|
22319
22691
|
const to = hookActivityDir();
|
|
@@ -22321,12 +22693,12 @@ function migrateHookActivity() {
|
|
|
22321
22693
|
const stamp = Date.now();
|
|
22322
22694
|
let seq = 0;
|
|
22323
22695
|
for (const entry of entries) {
|
|
22324
|
-
const source =
|
|
22696
|
+
const source = resolve19(from, entry.name);
|
|
22325
22697
|
let name = entry.name === "current.jsonl" ? `page-${stamp}-${seq++}.jsonl` : entry.name;
|
|
22326
|
-
let target =
|
|
22327
|
-
while (
|
|
22698
|
+
let target = resolve19(to, name);
|
|
22699
|
+
while (existsSync23(target)) {
|
|
22328
22700
|
name = `page-${stamp}-${seq++}.jsonl`;
|
|
22329
|
-
target =
|
|
22701
|
+
target = resolve19(to, name);
|
|
22330
22702
|
}
|
|
22331
22703
|
try {
|
|
22332
22704
|
renameSync6(source, target);
|
|
@@ -22374,8 +22746,8 @@ function retirePolicyConfigKeys() {
|
|
|
22374
22746
|
return [...removed];
|
|
22375
22747
|
}
|
|
22376
22748
|
function readCarriedPolicyConfig() {
|
|
22377
|
-
const from =
|
|
22378
|
-
if (!
|
|
22749
|
+
const from = resolve19(legacy.localPoliciesDir(), "policies-config.json");
|
|
22750
|
+
if (!existsSync23(from))
|
|
22379
22751
|
return null;
|
|
22380
22752
|
let parsed;
|
|
22381
22753
|
try {
|
|
@@ -22404,11 +22776,11 @@ function rewriteCarriedCustomPaths(carried) {
|
|
|
22404
22776
|
const repoint = (value) => {
|
|
22405
22777
|
if (typeof value !== "string" || value === "")
|
|
22406
22778
|
return value;
|
|
22407
|
-
const abs =
|
|
22779
|
+
const abs = resolve19(value);
|
|
22408
22780
|
const rel = relative4(fromDir, abs);
|
|
22409
22781
|
if (rel === "" || rel.startsWith("..") || isAbsolute3(rel))
|
|
22410
22782
|
return value;
|
|
22411
|
-
return
|
|
22783
|
+
return resolve19(toDir, rel);
|
|
22412
22784
|
};
|
|
22413
22785
|
if (Array.isArray(carried.customPoliciesPaths)) {
|
|
22414
22786
|
carried.customPoliciesPaths = carried.customPoliciesPaths.map(repoint);
|
|
@@ -22429,7 +22801,7 @@ function writeCarriedPolicyConfig(carried) {
|
|
|
22429
22801
|
}
|
|
22430
22802
|
} catch {}
|
|
22431
22803
|
try {
|
|
22432
|
-
mkdirSync12(
|
|
22804
|
+
mkdirSync12(dirname11(to), { recursive: true });
|
|
22433
22805
|
writeFileSync10(to, JSON.stringify({ ...existing, ...carried }, null, 2) + `
|
|
22434
22806
|
`, "utf8");
|
|
22435
22807
|
} catch {
|
|
@@ -22439,7 +22811,7 @@ function writeCarriedPolicyConfig(carried) {
|
|
|
22439
22811
|
}
|
|
22440
22812
|
function readCarriedTelemetryOptOut() {
|
|
22441
22813
|
const from = legacy.configToml();
|
|
22442
|
-
if (!
|
|
22814
|
+
if (!existsSync23(from))
|
|
22443
22815
|
return false;
|
|
22444
22816
|
try {
|
|
22445
22817
|
const text = readFileSync18(from, "utf8");
|
|
@@ -22494,7 +22866,7 @@ function parseLegacyToml(text) {
|
|
|
22494
22866
|
}
|
|
22495
22867
|
function readCarriedLegacyConfig() {
|
|
22496
22868
|
const from = legacy.configToml();
|
|
22497
|
-
if (!
|
|
22869
|
+
if (!existsSync23(from))
|
|
22498
22870
|
return null;
|
|
22499
22871
|
try {
|
|
22500
22872
|
return projectConfig(parseLegacyToml(readFileSync18(from, "utf8")));
|
|
@@ -22504,7 +22876,7 @@ function readCarriedLegacyConfig() {
|
|
|
22504
22876
|
}
|
|
22505
22877
|
function readCarriedLegacyCredentials() {
|
|
22506
22878
|
const toml = legacy.credentialsToml();
|
|
22507
|
-
if (
|
|
22879
|
+
if (existsSync23(toml)) {
|
|
22508
22880
|
try {
|
|
22509
22881
|
const creds = projectCredentials(parseLegacyToml(readFileSync18(toml, "utf8")));
|
|
22510
22882
|
if (Object.keys(creds).length > 0)
|
|
@@ -22547,7 +22919,7 @@ function resetHome(from, to = LAYOUT_VERSION) {
|
|
|
22547
22919
|
const spooled = migrateLegacySpool();
|
|
22548
22920
|
const removed = [];
|
|
22549
22921
|
for (const path of resettablePaths()) {
|
|
22550
|
-
if (!
|
|
22922
|
+
if (!existsSync23(path))
|
|
22551
22923
|
continue;
|
|
22552
22924
|
try {
|
|
22553
22925
|
rmSync7(path, { recursive: true, force: true });
|
|
@@ -22572,7 +22944,7 @@ function layoutWarningForHook() {
|
|
|
22572
22944
|
if (state.kind === "future") {
|
|
22573
22945
|
return `[failproofai] this directory was written by a newer version (layout ${state.found} vs ${LAYOUT_VERSION}) — policies are NOT being enforced. ` + `Upgrade failproofai.`;
|
|
22574
22946
|
}
|
|
22575
|
-
if (
|
|
22947
|
+
if (existsSync23(globalPolicyConfigFile()))
|
|
22576
22948
|
return null;
|
|
22577
22949
|
return `[failproofai] setup predates this version — global policies are NOT being enforced. ` + `Run \`failproofai config\` to re-create it.`;
|
|
22578
22950
|
}
|
|
@@ -23620,17 +23992,17 @@ var init_collector_config = __esm(() => {
|
|
|
23620
23992
|
});
|
|
23621
23993
|
|
|
23622
23994
|
// src/hooks/flush-cli.ts
|
|
23623
|
-
import { existsSync as
|
|
23624
|
-
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";
|
|
23625
23997
|
function flushRequestPath(home) {
|
|
23626
|
-
return
|
|
23998
|
+
return join31(failproofaiHome(home), "state", "flush-request.json");
|
|
23627
23999
|
}
|
|
23628
24000
|
function spoolDirs(home) {
|
|
23629
24001
|
const root = spoolDir(home);
|
|
23630
|
-
if (!
|
|
24002
|
+
if (!existsSync24(root))
|
|
23631
24003
|
return [];
|
|
23632
24004
|
try {
|
|
23633
|
-
return
|
|
24005
|
+
return readdirSync16(root, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== "failed").map((e) => join31(root, e.name));
|
|
23634
24006
|
} catch {
|
|
23635
24007
|
return [];
|
|
23636
24008
|
}
|
|
@@ -23639,7 +24011,7 @@ function pendingBatches(home) {
|
|
|
23639
24011
|
let n = 0;
|
|
23640
24012
|
for (const dir of spoolDirs(home)) {
|
|
23641
24013
|
try {
|
|
23642
|
-
n +=
|
|
24014
|
+
n += readdirSync16(dir).filter((f) => f.endsWith(".jsonl")).length;
|
|
23643
24015
|
} catch {}
|
|
23644
24016
|
}
|
|
23645
24017
|
return n;
|
|
@@ -23696,7 +24068,7 @@ async function runFlushCommand(opts = {}) {
|
|
|
23696
24068
|
return { exitCode: 0, pending: 0, lines: ["Nothing spooled — everything already delivered."] };
|
|
23697
24069
|
}
|
|
23698
24070
|
const path = flushRequestPath(home);
|
|
23699
|
-
mkdirSync13(
|
|
24071
|
+
mkdirSync13(dirname12(path), { recursive: true });
|
|
23700
24072
|
writeFileSync11(path, `${JSON.stringify({ requestedAtMs: Date.now() }, null, 2)}
|
|
23701
24073
|
`, {
|
|
23702
24074
|
mode: 384
|
|
@@ -23731,14 +24103,14 @@ var init_flush_cli = __esm(() => {
|
|
|
23731
24103
|
import {
|
|
23732
24104
|
chmodSync as chmodSync4,
|
|
23733
24105
|
copyFileSync as copyFileSync2,
|
|
23734
|
-
existsSync as
|
|
24106
|
+
existsSync as existsSync25,
|
|
23735
24107
|
mkdirSync as mkdirSync14,
|
|
23736
24108
|
readFileSync as readFileSync19,
|
|
23737
24109
|
renameSync as renameSync7,
|
|
23738
24110
|
rmSync as rmSync8,
|
|
23739
24111
|
writeFileSync as writeFileSync12
|
|
23740
24112
|
} from "node:fs";
|
|
23741
|
-
import { basename as
|
|
24113
|
+
import { basename as basename5, dirname as dirname13, join as join32, resolve as resolve20 } from "node:path";
|
|
23742
24114
|
function migrateToLayout4() {
|
|
23743
24115
|
const moves = [
|
|
23744
24116
|
{ from: legacy.authJson(), to: auditSessionFile() },
|
|
@@ -23747,20 +24119,20 @@ function migrateToLayout4() {
|
|
|
23747
24119
|
];
|
|
23748
24120
|
const authDirOverride = process.env.FAILPROOFAI_AUTH_DIR;
|
|
23749
24121
|
if (authDirOverride) {
|
|
23750
|
-
moves.push({ from:
|
|
23751
|
-
from:
|
|
23752
|
-
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")
|
|
23753
24125
|
});
|
|
23754
24126
|
}
|
|
23755
24127
|
const migrated = [];
|
|
23756
24128
|
for (const { from, to } of moves) {
|
|
23757
|
-
if (!
|
|
24129
|
+
if (!existsSync25(from))
|
|
23758
24130
|
continue;
|
|
23759
|
-
if (
|
|
24131
|
+
if (existsSync25(to)) {
|
|
23760
24132
|
rmSync8(from, { force: true });
|
|
23761
24133
|
continue;
|
|
23762
24134
|
}
|
|
23763
|
-
mkdirSync14(
|
|
24135
|
+
mkdirSync14(dirname13(to), { recursive: true });
|
|
23764
24136
|
try {
|
|
23765
24137
|
renameSync7(from, to);
|
|
23766
24138
|
} catch {
|
|
@@ -23774,10 +24146,10 @@ function migrateToLayout4() {
|
|
|
23774
24146
|
}
|
|
23775
24147
|
rmSync8(from, { force: true });
|
|
23776
24148
|
}
|
|
23777
|
-
migrated.push(`${
|
|
24149
|
+
migrated.push(`${basename5(from)} → audit/${basename5(to)}`);
|
|
23778
24150
|
}
|
|
23779
24151
|
for (const secret of [auditSessionFile()]) {
|
|
23780
|
-
if (!
|
|
24152
|
+
if (!existsSync25(secret))
|
|
23781
24153
|
continue;
|
|
23782
24154
|
try {
|
|
23783
24155
|
chmodSync4(secret, 384);
|
|
@@ -23818,17 +24190,17 @@ function appendLedger(entry) {
|
|
|
23818
24190
|
} catch {}
|
|
23819
24191
|
}
|
|
23820
24192
|
function backupNameOf(f) {
|
|
23821
|
-
return f.as ??
|
|
24193
|
+
return f.as ?? basename5(f.at());
|
|
23822
24194
|
}
|
|
23823
24195
|
function pruneMigratedCredentials(from) {
|
|
23824
24196
|
const pruned = [];
|
|
23825
24197
|
for (let layout = from;layout < LAYOUT_VERSION; layout++) {
|
|
23826
24198
|
for (const { as, landsAt } of PRUNED_AFTER_SUCCESS) {
|
|
23827
24199
|
try {
|
|
23828
|
-
if (!
|
|
24200
|
+
if (!existsSync25(landsAt()))
|
|
23829
24201
|
continue;
|
|
23830
|
-
const copy =
|
|
23831
|
-
if (!
|
|
24202
|
+
const copy = resolve20(migrationBackupDir(layout), as);
|
|
24203
|
+
if (!existsSync25(copy))
|
|
23832
24204
|
continue;
|
|
23833
24205
|
rmSync8(copy, { force: true });
|
|
23834
24206
|
pruned.push(as);
|
|
@@ -23841,7 +24213,7 @@ function filesToBackUp() {
|
|
|
23841
24213
|
const seen = new Map;
|
|
23842
24214
|
for (const f of [...BACKED_UP, ...BACKED_UP_LEGACY]) {
|
|
23843
24215
|
const path = f.at();
|
|
23844
|
-
if (
|
|
24216
|
+
if (existsSync25(path))
|
|
23845
24217
|
seen.set(path, backupNameOf(f));
|
|
23846
24218
|
}
|
|
23847
24219
|
return [...seen].map(([path, as]) => ({ path, as }));
|
|
@@ -23857,7 +24229,7 @@ function backupBeforeMigrating(from) {
|
|
|
23857
24229
|
}
|
|
23858
24230
|
for (const { path: source, as } of filesToBackUp()) {
|
|
23859
24231
|
try {
|
|
23860
|
-
copyFileSync2(source,
|
|
24232
|
+
copyFileSync2(source, resolve20(dir, as));
|
|
23861
24233
|
saved.push(as);
|
|
23862
24234
|
} catch {}
|
|
23863
24235
|
}
|
|
@@ -23967,7 +24339,7 @@ var init_migrations = __esm(() => {
|
|
|
23967
24339
|
{ at: legacy.auditSchedule }
|
|
23968
24340
|
];
|
|
23969
24341
|
PRUNED_AFTER_SUCCESS = [
|
|
23970
|
-
{ as:
|
|
24342
|
+
{ as: basename5(legacy.authJson()), landsAt: auditSessionFile }
|
|
23971
24343
|
];
|
|
23972
24344
|
});
|
|
23973
24345
|
|
|
@@ -24148,14 +24520,14 @@ var init_fp_reset2 = __esm(() => {
|
|
|
24148
24520
|
import { createHmac, randomUUID as randomUUID2 } from "node:crypto";
|
|
24149
24521
|
import { execSync as execSync5 } from "node:child_process";
|
|
24150
24522
|
import { readFileSync as readFileSync20, writeFileSync as writeFileSync13, mkdirSync as mkdirSync15 } from "node:fs";
|
|
24151
|
-
import { homedir as
|
|
24152
|
-
import { join as
|
|
24523
|
+
import { homedir as homedir23, platform, arch, hostname, cpus } from "node:os";
|
|
24524
|
+
import { join as join33 } from "node:path";
|
|
24153
24525
|
function hashToId3(raw) {
|
|
24154
24526
|
return createHmac("sha256", NAMESPACE3).update(raw).digest("hex");
|
|
24155
24527
|
}
|
|
24156
24528
|
function getInstanceId3() {
|
|
24157
|
-
const idDir =
|
|
24158
|
-
const idFile =
|
|
24529
|
+
const idDir = join33(homedir23(), ".failproofai");
|
|
24530
|
+
const idFile = join33(idDir, "instance-id");
|
|
24159
24531
|
try {
|
|
24160
24532
|
const existing = readFileSync20(idFile, "utf-8").trim();
|
|
24161
24533
|
if (existing)
|
|
@@ -24189,7 +24561,7 @@ function getInstanceId3() {
|
|
|
24189
24561
|
try {
|
|
24190
24562
|
const sysProps = [
|
|
24191
24563
|
hostname(),
|
|
24192
|
-
|
|
24564
|
+
homedir23(),
|
|
24193
24565
|
platform(),
|
|
24194
24566
|
arch(),
|
|
24195
24567
|
cpus()[0]?.model ?? ""
|
|
@@ -24231,9 +24603,9 @@ var NAMESPACE3 = "failproofai-telemetry-v1", API_KEY3 = "phc_Ac1Ww1GqKc0z1SyrRWb
|
|
|
24231
24603
|
var init_install_telemetry = () => {};
|
|
24232
24604
|
|
|
24233
24605
|
// lib/install-check.ts
|
|
24234
|
-
import { existsSync as
|
|
24235
|
-
import { dirname as
|
|
24236
|
-
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";
|
|
24237
24609
|
import { createHmac as createHmac2 } from "node:crypto";
|
|
24238
24610
|
function hashToId4(raw) {
|
|
24239
24611
|
return createHmac2("sha256", NAMESPACE4).update(raw).digest("hex");
|
|
@@ -24287,7 +24659,7 @@ function compareSemver(a, b) {
|
|
|
24287
24659
|
}
|
|
24288
24660
|
function checkHooks() {
|
|
24289
24661
|
const hooksConfigPath = globalPolicyConfigFile();
|
|
24290
|
-
if (!
|
|
24662
|
+
if (!existsSync26(hooksConfigPath)) {
|
|
24291
24663
|
return { configured: false, registered: false, policyCount: 0 };
|
|
24292
24664
|
}
|
|
24293
24665
|
let config;
|
|
@@ -24300,8 +24672,8 @@ function checkHooks() {
|
|
|
24300
24672
|
return { configured: false, registered: false, policyCount: 0 };
|
|
24301
24673
|
}
|
|
24302
24674
|
const policyCount = config.enabledPolicies.length;
|
|
24303
|
-
const settingsPath =
|
|
24304
|
-
if (!
|
|
24675
|
+
const settingsPath = resolve21(homedir24(), ".claude", "settings.json");
|
|
24676
|
+
if (!existsSync26(settingsPath))
|
|
24305
24677
|
return { configured: true, registered: false, policyCount };
|
|
24306
24678
|
let settings;
|
|
24307
24679
|
try {
|
|
@@ -24329,7 +24701,7 @@ async function maybeReportInstall(version) {
|
|
|
24329
24701
|
const versionFile = lastVersionPath();
|
|
24330
24702
|
let previousVersion = null;
|
|
24331
24703
|
try {
|
|
24332
|
-
if (
|
|
24704
|
+
if (existsSync26(versionFile)) {
|
|
24333
24705
|
previousVersion = readFileSync21(versionFile, "utf8").trim() || null;
|
|
24334
24706
|
}
|
|
24335
24707
|
} catch {}
|
|
@@ -24366,7 +24738,7 @@ async function maybeReportInstall(version) {
|
|
|
24366
24738
|
enabled_policy_count: hooks.policyCount
|
|
24367
24739
|
}, { version, timeoutMs: REPORT_TIMEOUT_MS, enabled: telemetryEnabled }));
|
|
24368
24740
|
try {
|
|
24369
|
-
mkdirSync16(
|
|
24741
|
+
mkdirSync16(dirname14(versionFile), { recursive: true });
|
|
24370
24742
|
writeFileSync14(versionFile, version, "utf8");
|
|
24371
24743
|
} catch {}
|
|
24372
24744
|
await Promise.all(events.map((p) => p.catch(() => {})));
|
|
@@ -24417,8 +24789,8 @@ var init_cli_error = __esm(() => {
|
|
|
24417
24789
|
|
|
24418
24790
|
// src/hooks/manager.ts
|
|
24419
24791
|
import { execSync as execSync6 } from "node:child_process";
|
|
24420
|
-
import { existsSync as
|
|
24421
|
-
import { resolve as
|
|
24792
|
+
import { existsSync as existsSync27 } from "node:fs";
|
|
24793
|
+
import { resolve as resolve22, basename as basename6 } from "node:path";
|
|
24422
24794
|
import { platform as platform3, arch as arch3, release as release2, hostname as hostname3 } from "node:os";
|
|
24423
24795
|
function getSettingsPath(scope, cwd) {
|
|
24424
24796
|
return claudeCode.getSettingsPath(scope, cwd);
|
|
@@ -24637,9 +25009,9 @@ async function installHooksImpl(policyNames, scope = "user", cwd, includeBeta =
|
|
|
24637
25009
|
delete configToWrite.customPoliciesPath;
|
|
24638
25010
|
delete configToWrite.customPoliciesPaths;
|
|
24639
25011
|
} else if (customPoliciesPath && (typeof customPoliciesPath === "string" || customPoliciesPath.length > 0)) {
|
|
24640
|
-
const incoming = (typeof customPoliciesPath === "string" ? [customPoliciesPath] : customPoliciesPath).map((path) =>
|
|
24641
|
-
const carried = (previousConfig.customPoliciesPaths ?? (previousConfig.customPoliciesPath ? [previousConfig.customPoliciesPath] : [])).map((path) =>
|
|
24642
|
-
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))
|
|
24643
25015
|
return true;
|
|
24644
25016
|
console.log(`Dropping custom policies path (file no longer exists): ${path}`);
|
|
24645
25017
|
return false;
|
|
@@ -24862,7 +25234,7 @@ async function removeHooks(policyNames, scope = "user", cwd, opts) {
|
|
|
24862
25234
|
const scopesToRemove = scope === "all" ? [...integration.scopes] : integration.scopes.includes(scope) ? [scope] : [];
|
|
24863
25235
|
for (const s of scopesToRemove) {
|
|
24864
25236
|
const settingsPaths = settingsPathsFor(integration, s, cwd);
|
|
24865
|
-
const existing = settingsPaths.filter((p) =>
|
|
25237
|
+
const existing = settingsPaths.filter((p) => existsSync27(p));
|
|
24866
25238
|
if (existing.length === 0) {
|
|
24867
25239
|
if (scope !== "all" && selectedClis.length === 1) {
|
|
24868
25240
|
console.log("No settings file found. Nothing to remove.");
|
|
@@ -24965,7 +25337,7 @@ var DEFAULT_FETCH_TIMEOUT_MS = 15000;
|
|
|
24965
25337
|
|
|
24966
25338
|
// src/hooks/cloud-enrollment.ts
|
|
24967
25339
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
24968
|
-
import { existsSync as
|
|
25340
|
+
import { existsSync as existsSync28, readFileSync as readFileSync22, rmSync as rmSync9 } from "node:fs";
|
|
24969
25341
|
import { hostname as hostname4 } from "node:os";
|
|
24970
25342
|
function cloudCredentialPath() {
|
|
24971
25343
|
return process.env.FAILPROOFAI_CLOUD_CREDENTIALS ?? credentialsFile();
|
|
@@ -25004,7 +25376,7 @@ function readCloudCredentials() {
|
|
|
25004
25376
|
if (!usingJsonOverride())
|
|
25005
25377
|
return readCredentials().cloud ?? null;
|
|
25006
25378
|
const path = cloudCredentialPath();
|
|
25007
|
-
if (!
|
|
25379
|
+
if (!existsSync28(path))
|
|
25008
25380
|
return null;
|
|
25009
25381
|
try {
|
|
25010
25382
|
const raw = JSON.parse(readFileSync22(path, "utf8"));
|
|
@@ -25046,7 +25418,7 @@ function resolveMachineLabel(explicit) {
|
|
|
25046
25418
|
function clearCloudCredentials() {
|
|
25047
25419
|
if (usingJsonOverride()) {
|
|
25048
25420
|
const path = cloudCredentialPath();
|
|
25049
|
-
if (!
|
|
25421
|
+
if (!existsSync28(path))
|
|
25050
25422
|
return false;
|
|
25051
25423
|
try {
|
|
25052
25424
|
rmSync9(path);
|
|
@@ -25297,37 +25669,37 @@ var init_cloud_connection = __esm(() => {
|
|
|
25297
25669
|
});
|
|
25298
25670
|
|
|
25299
25671
|
// src/hooks/setup-state.ts
|
|
25300
|
-
import { existsSync as
|
|
25301
|
-
import { dirname as
|
|
25302
|
-
import { homedir as
|
|
25303
|
-
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()) {
|
|
25304
25676
|
return globalPolicyConfigFile(home);
|
|
25305
25677
|
}
|
|
25306
25678
|
function projectConfigPath(projectRoot) {
|
|
25307
|
-
return
|
|
25679
|
+
return resolve23(projectRoot, ".failproofai", "policies-config.json");
|
|
25308
25680
|
}
|
|
25309
25681
|
function legacyMarkerPath(home) {
|
|
25310
25682
|
return launcherMarker(home);
|
|
25311
25683
|
}
|
|
25312
25684
|
function isDir(path) {
|
|
25313
25685
|
try {
|
|
25314
|
-
return
|
|
25686
|
+
return statSync18(path).isDirectory();
|
|
25315
25687
|
} catch {
|
|
25316
25688
|
return false;
|
|
25317
25689
|
}
|
|
25318
25690
|
}
|
|
25319
|
-
function findProjectRoot(start, home =
|
|
25691
|
+
function findProjectRoot(start, home = homedir25()) {
|
|
25320
25692
|
const resolvedHome = realResolve(home);
|
|
25321
25693
|
let dir = realResolve(start);
|
|
25322
25694
|
while (dir !== resolvedHome) {
|
|
25323
|
-
if (isDir(
|
|
25695
|
+
if (isDir(resolve23(dir, ".failproofai")))
|
|
25324
25696
|
return dir;
|
|
25325
|
-
const parent =
|
|
25697
|
+
const parent = dirname15(dir);
|
|
25326
25698
|
if (parent === dir)
|
|
25327
25699
|
break;
|
|
25328
25700
|
dir = parent;
|
|
25329
25701
|
}
|
|
25330
|
-
return
|
|
25702
|
+
return resolve23(start);
|
|
25331
25703
|
}
|
|
25332
25704
|
function hasGlobalHooksInstalled() {
|
|
25333
25705
|
for (const id of INTEGRATION_TYPES) {
|
|
@@ -25339,14 +25711,14 @@ function hasGlobalHooksInstalled() {
|
|
|
25339
25711
|
return false;
|
|
25340
25712
|
}
|
|
25341
25713
|
function realResolve(path) {
|
|
25342
|
-
const lexical =
|
|
25714
|
+
const lexical = resolve23(path);
|
|
25343
25715
|
try {
|
|
25344
25716
|
return realpathSync2(lexical);
|
|
25345
25717
|
} catch {
|
|
25346
25718
|
return lexical;
|
|
25347
25719
|
}
|
|
25348
25720
|
}
|
|
25349
|
-
function detectSetupState(cwd = process.cwd(), home =
|
|
25721
|
+
function detectSetupState(cwd = process.cwd(), home = homedir25()) {
|
|
25350
25722
|
const resolvedCwd = realResolve(cwd);
|
|
25351
25723
|
const resolvedHome = realResolve(home);
|
|
25352
25724
|
const projectRoot = findProjectRoot(resolvedCwd, resolvedHome);
|
|
@@ -25354,10 +25726,10 @@ function detectSetupState(cwd = process.cwd(), home = homedir24()) {
|
|
|
25354
25726
|
cwd: resolvedCwd,
|
|
25355
25727
|
home: resolvedHome,
|
|
25356
25728
|
projectRoot,
|
|
25357
|
-
hasGlobalConfig:
|
|
25358
|
-
hasProjectConfig: projectRoot !== resolvedHome &&
|
|
25729
|
+
hasGlobalConfig: existsSync29(globalConfigPath(resolvedHome)),
|
|
25730
|
+
hasProjectConfig: projectRoot !== resolvedHome && existsSync29(projectConfigPath(projectRoot)),
|
|
25359
25731
|
hasGlobalHooks: hasGlobalHooksInstalled(),
|
|
25360
|
-
hasLegacyMarker:
|
|
25732
|
+
hasLegacyMarker: existsSync29(legacyMarkerPath(resolvedHome)),
|
|
25361
25733
|
inHomeDir: resolvedCwd === resolvedHome
|
|
25362
25734
|
};
|
|
25363
25735
|
}
|
|
@@ -25374,11 +25746,11 @@ var init_setup_state = __esm(() => {
|
|
|
25374
25746
|
});
|
|
25375
25747
|
|
|
25376
25748
|
// src/hooks/onboarding-attempt.ts
|
|
25377
|
-
import { existsSync as
|
|
25378
|
-
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";
|
|
25379
25751
|
function readOnboardingAttempt() {
|
|
25380
25752
|
const path = onboardingAttemptFile();
|
|
25381
|
-
if (!
|
|
25753
|
+
if (!existsSync30(path))
|
|
25382
25754
|
return null;
|
|
25383
25755
|
try {
|
|
25384
25756
|
const raw = JSON.parse(readFileSync23(path, "utf8"));
|
|
@@ -25400,7 +25772,7 @@ function readOnboardingAttempt() {
|
|
|
25400
25772
|
function recordOnboardingAttempt(reason, cliVersion, daemonStatus, now = Date.now()) {
|
|
25401
25773
|
try {
|
|
25402
25774
|
const path = onboardingAttemptFile();
|
|
25403
|
-
mkdirSync17(
|
|
25775
|
+
mkdirSync17(dirname16(path), { recursive: true });
|
|
25404
25776
|
const record = {
|
|
25405
25777
|
schemaVersion: SCHEMA_VERSION3,
|
|
25406
25778
|
reason,
|
|
@@ -25456,8 +25828,8 @@ var init_onboarding_attempt = __esm(() => {
|
|
|
25456
25828
|
|
|
25457
25829
|
// src/hooks/onboarding-lock.ts
|
|
25458
25830
|
import { mkdirSync as mkdirSync18, readFileSync as readFileSync24, rmSync as rmSync11, writeFileSync as writeFileSync16 } from "node:fs";
|
|
25459
|
-
import { homedir as
|
|
25460
|
-
function onboardingLockPath(home =
|
|
25831
|
+
import { homedir as homedir26 } from "node:os";
|
|
25832
|
+
function onboardingLockPath(home = homedir26()) {
|
|
25461
25833
|
return onboardingLockFile(home);
|
|
25462
25834
|
}
|
|
25463
25835
|
function processAlive(pid) {
|
|
@@ -25480,7 +25852,7 @@ function readLock(path) {
|
|
|
25480
25852
|
return null;
|
|
25481
25853
|
}
|
|
25482
25854
|
}
|
|
25483
|
-
function acquireOnboardingLock(home =
|
|
25855
|
+
function acquireOnboardingLock(home = homedir26()) {
|
|
25484
25856
|
const path = onboardingLockPath(home);
|
|
25485
25857
|
try {
|
|
25486
25858
|
const held = readLock(path);
|
|
@@ -25511,8 +25883,8 @@ var init_onboarding_lock = __esm(() => {
|
|
|
25511
25883
|
});
|
|
25512
25884
|
|
|
25513
25885
|
// lib/claude-sessions.ts
|
|
25514
|
-
import { readdirSync as
|
|
25515
|
-
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";
|
|
25516
25888
|
function getClaudeProjectsRoot() {
|
|
25517
25889
|
return getClaudeProjectsPath();
|
|
25518
25890
|
}
|
|
@@ -25520,21 +25892,21 @@ function listClaudeProjects() {
|
|
|
25520
25892
|
const root = getClaudeProjectsRoot();
|
|
25521
25893
|
let entries;
|
|
25522
25894
|
try {
|
|
25523
|
-
entries =
|
|
25895
|
+
entries = readdirSync17(root, { withFileTypes: true });
|
|
25524
25896
|
} catch {
|
|
25525
25897
|
return [];
|
|
25526
25898
|
}
|
|
25527
25899
|
return entries.filter((e) => e.isDirectory()).map((e) => ({
|
|
25528
25900
|
name: e.name,
|
|
25529
25901
|
cwd: decodeFolderName(e.name),
|
|
25530
|
-
path:
|
|
25902
|
+
path: join34(root, e.name)
|
|
25531
25903
|
}));
|
|
25532
25904
|
}
|
|
25533
25905
|
function listClaudeTranscripts(project) {
|
|
25534
25906
|
const out = [];
|
|
25535
25907
|
let entries;
|
|
25536
25908
|
try {
|
|
25537
|
-
entries =
|
|
25909
|
+
entries = readdirSync17(project.path, { withFileTypes: true });
|
|
25538
25910
|
} catch {
|
|
25539
25911
|
return out;
|
|
25540
25912
|
}
|
|
@@ -25543,9 +25915,9 @@ function listClaudeTranscripts(project) {
|
|
|
25543
25915
|
const sessionId = entry.name.slice(0, -".jsonl".length);
|
|
25544
25916
|
if (!UUID_RE2.test(sessionId))
|
|
25545
25917
|
continue;
|
|
25546
|
-
const transcriptPath =
|
|
25918
|
+
const transcriptPath = join34(project.path, entry.name);
|
|
25547
25919
|
try {
|
|
25548
|
-
const s =
|
|
25920
|
+
const s = statSync19(transcriptPath);
|
|
25549
25921
|
out.push({
|
|
25550
25922
|
projectName: project.name,
|
|
25551
25923
|
cwd: project.cwd,
|
|
@@ -25557,12 +25929,12 @@ function listClaudeTranscripts(project) {
|
|
|
25557
25929
|
});
|
|
25558
25930
|
} catch {}
|
|
25559
25931
|
} else if (entry.isDirectory() && UUID_RE2.test(entry.name)) {
|
|
25560
|
-
const subDir =
|
|
25561
|
-
if (!
|
|
25932
|
+
const subDir = join34(project.path, entry.name, "subagents");
|
|
25933
|
+
if (!existsSync31(subDir))
|
|
25562
25934
|
continue;
|
|
25563
25935
|
let subEntries;
|
|
25564
25936
|
try {
|
|
25565
|
-
subEntries =
|
|
25937
|
+
subEntries = readdirSync17(subDir, { withFileTypes: true });
|
|
25566
25938
|
} catch {
|
|
25567
25939
|
continue;
|
|
25568
25940
|
}
|
|
@@ -25570,9 +25942,9 @@ function listClaudeTranscripts(project) {
|
|
|
25570
25942
|
if (!sub.isFile() || !sub.name.endsWith(".jsonl"))
|
|
25571
25943
|
continue;
|
|
25572
25944
|
const agentId = sub.name.slice(0, -".jsonl".length);
|
|
25573
|
-
const transcriptPath =
|
|
25945
|
+
const transcriptPath = join34(subDir, sub.name);
|
|
25574
25946
|
try {
|
|
25575
|
-
const s =
|
|
25947
|
+
const s = statSync19(transcriptPath);
|
|
25576
25948
|
out.push({
|
|
25577
25949
|
projectName: project.name,
|
|
25578
25950
|
cwd: project.cwd,
|
|
@@ -25788,7 +26160,7 @@ var init_claude = __esm(() => {
|
|
|
25788
26160
|
});
|
|
25789
26161
|
|
|
25790
26162
|
// src/audit/cli-adapters/codex.ts
|
|
25791
|
-
import { statSync as
|
|
26163
|
+
import { statSync as statSync20 } from "node:fs";
|
|
25792
26164
|
async function listCodexTranscriptMetadata(opts = {}) {
|
|
25793
26165
|
const projectFilter = opts.projects ? new Set(opts.projects) : null;
|
|
25794
26166
|
const sinceMs = opts.sinceMs ?? 0;
|
|
@@ -25805,7 +26177,7 @@ async function listCodexTranscriptMetadata(opts = {}) {
|
|
|
25805
26177
|
continue;
|
|
25806
26178
|
let sizeBytes = 0;
|
|
25807
26179
|
try {
|
|
25808
|
-
sizeBytes =
|
|
26180
|
+
sizeBytes = statSync20(s.path).size;
|
|
25809
26181
|
} catch {}
|
|
25810
26182
|
if (!s.sessionId)
|
|
25811
26183
|
continue;
|
|
@@ -25839,7 +26211,7 @@ var init_codex = __esm(() => {
|
|
|
25839
26211
|
});
|
|
25840
26212
|
|
|
25841
26213
|
// src/audit/cli-adapters/copilot.ts
|
|
25842
|
-
import { statSync as
|
|
26214
|
+
import { statSync as statSync21 } from "node:fs";
|
|
25843
26215
|
async function listCopilotTranscriptMetadata(opts = {}) {
|
|
25844
26216
|
const projectFilter = opts.projects ? new Set(opts.projects) : null;
|
|
25845
26217
|
const sinceMs = opts.sinceMs ?? 0;
|
|
@@ -25856,7 +26228,7 @@ async function listCopilotTranscriptMetadata(opts = {}) {
|
|
|
25856
26228
|
continue;
|
|
25857
26229
|
let sizeBytes = 0;
|
|
25858
26230
|
try {
|
|
25859
|
-
sizeBytes =
|
|
26231
|
+
sizeBytes = statSync21(s.path).size;
|
|
25860
26232
|
} catch {}
|
|
25861
26233
|
if (!s.sessionId)
|
|
25862
26234
|
continue;
|
|
@@ -25890,7 +26262,7 @@ var init_copilot = __esm(() => {
|
|
|
25890
26262
|
});
|
|
25891
26263
|
|
|
25892
26264
|
// src/audit/cli-adapters/cursor.ts
|
|
25893
|
-
import { statSync as
|
|
26265
|
+
import { statSync as statSync22 } from "node:fs";
|
|
25894
26266
|
async function listCursorTranscriptMetadata(opts = {}) {
|
|
25895
26267
|
const projectFilter = opts.projects ? new Set(opts.projects) : null;
|
|
25896
26268
|
const sinceMs = opts.sinceMs ?? 0;
|
|
@@ -25907,7 +26279,7 @@ async function listCursorTranscriptMetadata(opts = {}) {
|
|
|
25907
26279
|
continue;
|
|
25908
26280
|
let sizeBytes = 0;
|
|
25909
26281
|
try {
|
|
25910
|
-
sizeBytes =
|
|
26282
|
+
sizeBytes = statSync22(s.path).size;
|
|
25911
26283
|
} catch {}
|
|
25912
26284
|
if (!s.sessionId)
|
|
25913
26285
|
continue;
|
|
@@ -26148,7 +26520,7 @@ var init_opencode = __esm(() => {
|
|
|
26148
26520
|
});
|
|
26149
26521
|
|
|
26150
26522
|
// src/audit/cli-adapters/pi.ts
|
|
26151
|
-
import { statSync as
|
|
26523
|
+
import { statSync as statSync23 } from "node:fs";
|
|
26152
26524
|
async function listPiTranscriptMetadata(opts = {}) {
|
|
26153
26525
|
const projectFilter = opts.projects ? new Set(opts.projects) : null;
|
|
26154
26526
|
const sinceMs = opts.sinceMs ?? 0;
|
|
@@ -26165,7 +26537,7 @@ async function listPiTranscriptMetadata(opts = {}) {
|
|
|
26165
26537
|
continue;
|
|
26166
26538
|
let sizeBytes = 0;
|
|
26167
26539
|
try {
|
|
26168
|
-
sizeBytes =
|
|
26540
|
+
sizeBytes = statSync23(s.path).size;
|
|
26169
26541
|
} catch {}
|
|
26170
26542
|
if (!s.sessionId)
|
|
26171
26543
|
continue;
|
|
@@ -26901,8 +27273,8 @@ var init_features = __esm(() => {
|
|
|
26901
27273
|
|
|
26902
27274
|
// src/audit/cache.ts
|
|
26903
27275
|
import { createHash as createHash8 } from "node:crypto";
|
|
26904
|
-
import { existsSync as
|
|
26905
|
-
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";
|
|
26906
27278
|
function getEngineVersion() {
|
|
26907
27279
|
if (cachedEngineVersion)
|
|
26908
27280
|
return cachedEngineVersion;
|
|
@@ -26922,7 +27294,7 @@ function getDetectorVersion() {
|
|
|
26922
27294
|
function getCachePathFor(transcriptPath) {
|
|
26923
27295
|
const root = auditCacheDir();
|
|
26924
27296
|
const key = createHash8("sha1").update(transcriptPath).digest("hex");
|
|
26925
|
-
return
|
|
27297
|
+
return join35(root, `${key}.json`);
|
|
26926
27298
|
}
|
|
26927
27299
|
function encodeDetectorState(state) {
|
|
26928
27300
|
return JSON.stringify(state, (_k, v) => v instanceof Map ? { __map: [...v.entries()] } : v);
|
|
@@ -26962,7 +27334,7 @@ function readCachedTranscript(transcriptPath, mtimeMs, sizeBytes) {
|
|
|
26962
27334
|
if (sizeBytes === 0)
|
|
26963
27335
|
return null;
|
|
26964
27336
|
const cachePath = getCachePathFor(transcriptPath);
|
|
26965
|
-
if (!
|
|
27337
|
+
if (!existsSync32(cachePath))
|
|
26966
27338
|
return null;
|
|
26967
27339
|
try {
|
|
26968
27340
|
const raw = readFileSync25(cachePath, "utf-8");
|
|
@@ -27582,7 +27954,7 @@ var init_audit_lock = __esm(() => {
|
|
|
27582
27954
|
});
|
|
27583
27955
|
|
|
27584
27956
|
// src/audit/dashboard-cache.ts
|
|
27585
|
-
import { existsSync as
|
|
27957
|
+
import { existsSync as existsSync33, readFileSync as readFileSync27 } from "node:fs";
|
|
27586
27958
|
function getCachePath() {
|
|
27587
27959
|
return auditDashboardFile();
|
|
27588
27960
|
}
|
|
@@ -27602,7 +27974,7 @@ function writeDashboardCache(params, result) {
|
|
|
27602
27974
|
}
|
|
27603
27975
|
function readDashboardCacheMeta() {
|
|
27604
27976
|
const cachePath = getCachePath();
|
|
27605
|
-
if (!
|
|
27977
|
+
if (!existsSync33(cachePath))
|
|
27606
27978
|
return null;
|
|
27607
27979
|
try {
|
|
27608
27980
|
const raw = readFileSync27(cachePath, "utf-8");
|
|
@@ -27829,15 +28201,15 @@ var init_api_server_client = __esm(() => {
|
|
|
27829
28201
|
});
|
|
27830
28202
|
|
|
27831
28203
|
// lib/auth/auth-store.ts
|
|
27832
|
-
import { existsSync as
|
|
27833
|
-
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";
|
|
27834
28206
|
function getAuthFilePath() {
|
|
27835
28207
|
const override = process.env.FAILPROOFAI_AUTH_DIR;
|
|
27836
|
-
return override ?
|
|
28208
|
+
return override ? join36(override, "session.json") : auditSessionFile();
|
|
27837
28209
|
}
|
|
27838
28210
|
function readAuth() {
|
|
27839
28211
|
const p = getAuthFilePath();
|
|
27840
|
-
if (!
|
|
28212
|
+
if (!existsSync34(p))
|
|
27841
28213
|
return null;
|
|
27842
28214
|
try {
|
|
27843
28215
|
const raw = readFileSync28(p, "utf-8");
|
|
@@ -27864,17 +28236,17 @@ function writeAuth(auth) {
|
|
|
27864
28236
|
}
|
|
27865
28237
|
function deleteAuth() {
|
|
27866
28238
|
const p = getAuthFilePath();
|
|
27867
|
-
if (
|
|
28239
|
+
if (existsSync34(p))
|
|
27868
28240
|
rmSync12(p, { force: true });
|
|
27869
28241
|
try {
|
|
27870
28242
|
const root = migrationsDir();
|
|
27871
|
-
if (!
|
|
28243
|
+
if (!existsSync34(root))
|
|
27872
28244
|
return;
|
|
27873
|
-
for (const entry of
|
|
28245
|
+
for (const entry of readdirSync18(root)) {
|
|
27874
28246
|
if (!entry.startsWith("backup-layout"))
|
|
27875
28247
|
continue;
|
|
27876
|
-
const copy =
|
|
27877
|
-
if (
|
|
28248
|
+
const copy = resolve24(root, entry, "auth.json");
|
|
28249
|
+
if (existsSync34(copy))
|
|
27878
28250
|
rmSync12(copy, { force: true });
|
|
27879
28251
|
}
|
|
27880
28252
|
} catch {}
|
|
@@ -27936,7 +28308,7 @@ var init_auth_store = __esm(() => {
|
|
|
27936
28308
|
});
|
|
27937
28309
|
|
|
27938
28310
|
// src/audit/redact-example.ts
|
|
27939
|
-
import { homedir as
|
|
28311
|
+
import { homedir as homedir27 } from "node:os";
|
|
27940
28312
|
function maskTruncatedSecret(input) {
|
|
27941
28313
|
for (const [pattern, label] of SECRET_PREFIXES) {
|
|
27942
28314
|
if (pattern.test(input)) {
|
|
@@ -27971,7 +28343,7 @@ function maskSecrets(input) {
|
|
|
27971
28343
|
}
|
|
27972
28344
|
return out;
|
|
27973
28345
|
}
|
|
27974
|
-
function shortenPaths(input, home =
|
|
28346
|
+
function shortenPaths(input, home = homedir27()) {
|
|
27975
28347
|
const homeRoot = home.replace(/\/+$/, "");
|
|
27976
28348
|
return input.replace(ABSOLUTE_PATH_RE, (match, offset, whole) => {
|
|
27977
28349
|
if (PUBLIC_PATH_ROOTS.some((root) => match.startsWith(root)))
|
|
@@ -28002,7 +28374,7 @@ function shortenPaths(input, home = homedir26()) {
|
|
|
28002
28374
|
return `${root}${middle}/${tail}${trailingSlash ? "/" : ""}`;
|
|
28003
28375
|
});
|
|
28004
28376
|
}
|
|
28005
|
-
function redactExample(input, home =
|
|
28377
|
+
function redactExample(input, home = homedir27()) {
|
|
28006
28378
|
const masked = maskAssignedSecrets(maskTruncatedSecret(maskSecrets(input)));
|
|
28007
28379
|
const shortened = shortenPaths(masked, home);
|
|
28008
28380
|
const collapsed = shortened.replace(/\s+/g, " ").trim();
|
|
@@ -28125,12 +28497,12 @@ var init_harm_report = __esm(() => {
|
|
|
28125
28497
|
});
|
|
28126
28498
|
|
|
28127
28499
|
// src/audit/machine-store.ts
|
|
28128
|
-
import { existsSync as
|
|
28500
|
+
import { existsSync as existsSync35, readFileSync as readFileSync29, rmSync as rmSync13 } from "node:fs";
|
|
28129
28501
|
import { hostname as hostname5 } from "node:os";
|
|
28130
28502
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
28131
28503
|
function readMachineIdentity(home) {
|
|
28132
28504
|
const path = auditMachineFile(home);
|
|
28133
|
-
if (!
|
|
28505
|
+
if (!existsSync35(path))
|
|
28134
28506
|
return null;
|
|
28135
28507
|
try {
|
|
28136
28508
|
const parsed = JSON.parse(readFileSync29(path, "utf8"));
|
|
@@ -28455,16 +28827,16 @@ var init_cli = __esm(() => {
|
|
|
28455
28827
|
});
|
|
28456
28828
|
|
|
28457
28829
|
// src/hooks/configure-wizard.ts
|
|
28458
|
-
import { existsSync as
|
|
28459
|
-
import { homedir as
|
|
28460
|
-
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";
|
|
28461
28833
|
async function emit(event, props) {
|
|
28462
28834
|
try {
|
|
28463
28835
|
await trackHookEvent2(getInstanceId2(), event, props);
|
|
28464
28836
|
} catch {}
|
|
28465
28837
|
}
|
|
28466
28838
|
function homeify(p) {
|
|
28467
|
-
const home =
|
|
28839
|
+
const home = homedir28();
|
|
28468
28840
|
if (p === home)
|
|
28469
28841
|
return "~";
|
|
28470
28842
|
if (p.startsWith(home + sep5))
|
|
@@ -28480,7 +28852,7 @@ function setCustomPoliciesEnabled(scope, cwd, enabled) {
|
|
|
28480
28852
|
const path = getConfigPathForScope(scope, cwd);
|
|
28481
28853
|
let config = {};
|
|
28482
28854
|
try {
|
|
28483
|
-
if (
|
|
28855
|
+
if (existsSync36(path))
|
|
28484
28856
|
config = JSON.parse(readFileSync30(path, "utf8"));
|
|
28485
28857
|
} catch {
|
|
28486
28858
|
return;
|
|
@@ -28521,7 +28893,7 @@ function describeCustomPolicies(cwd) {
|
|
|
28521
28893
|
const scopes = [];
|
|
28522
28894
|
let fileCount = 0;
|
|
28523
28895
|
const dirs = [
|
|
28524
|
-
{ dir:
|
|
28896
|
+
{ dir: resolve25(cwd, ".failproofai", "policies"), label: "project" },
|
|
28525
28897
|
{ dir: customPoliciesDir(), label: "global" }
|
|
28526
28898
|
];
|
|
28527
28899
|
for (const { dir, label } of dirs) {
|
|
@@ -28532,7 +28904,7 @@ function describeCustomPolicies(cwd) {
|
|
|
28532
28904
|
fileCount += found.length;
|
|
28533
28905
|
}
|
|
28534
28906
|
for (const name of findSkippedPolicyFiles(dir)) {
|
|
28535
|
-
warnings.push(`! ${homeify(
|
|
28907
|
+
warnings.push(`! ${homeify(resolve25(dir, name))} is NOT loaded — rename to ` + `${name.replace(/\.(js|mjs|ts)$/, "-policies.$1")}`);
|
|
28536
28908
|
}
|
|
28537
28909
|
}
|
|
28538
28910
|
return { active, warnings, fileCount, scopes };
|
|
@@ -28625,7 +28997,7 @@ function firstRunMarkerPath() {
|
|
|
28625
28997
|
}
|
|
28626
28998
|
function markLauncherSeen() {
|
|
28627
28999
|
try {
|
|
28628
|
-
mkdirSync21(
|
|
29000
|
+
mkdirSync21(dirname17(firstRunMarkerPath()), { recursive: true });
|
|
28629
29001
|
writeFileSync19(firstRunMarkerPath(), "1", "utf8");
|
|
28630
29002
|
} catch {}
|
|
28631
29003
|
}
|
|
@@ -29117,17 +29489,17 @@ var init_configure_wizard = __esm(() => {
|
|
|
29117
29489
|
});
|
|
29118
29490
|
|
|
29119
29491
|
// src/hooks/flush-cli.ts
|
|
29120
|
-
import { existsSync as
|
|
29121
|
-
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";
|
|
29122
29494
|
function flushRequestPath2(home) {
|
|
29123
|
-
return
|
|
29495
|
+
return join37(failproofaiHome(home), "state", "flush-request.json");
|
|
29124
29496
|
}
|
|
29125
29497
|
function spoolDirs2(home) {
|
|
29126
29498
|
const root = spoolDir(home);
|
|
29127
|
-
if (!
|
|
29499
|
+
if (!existsSync37(root))
|
|
29128
29500
|
return [];
|
|
29129
29501
|
try {
|
|
29130
|
-
return
|
|
29502
|
+
return readdirSync19(root, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== "failed").map((e) => join37(root, e.name));
|
|
29131
29503
|
} catch {
|
|
29132
29504
|
return [];
|
|
29133
29505
|
}
|
|
@@ -29136,7 +29508,7 @@ function pendingBatches2(home) {
|
|
|
29136
29508
|
let n = 0;
|
|
29137
29509
|
for (const dir of spoolDirs2(home)) {
|
|
29138
29510
|
try {
|
|
29139
|
-
n +=
|
|
29511
|
+
n += readdirSync19(dir).filter((f) => f.endsWith(".jsonl")).length;
|
|
29140
29512
|
} catch {}
|
|
29141
29513
|
}
|
|
29142
29514
|
return n;
|
|
@@ -29193,7 +29565,7 @@ async function runFlushCommand2(opts = {}) {
|
|
|
29193
29565
|
return { exitCode: 0, pending: 0, lines: ["Nothing spooled — everything already delivered."] };
|
|
29194
29566
|
}
|
|
29195
29567
|
const path = flushRequestPath2(home);
|
|
29196
|
-
mkdirSync22(
|
|
29568
|
+
mkdirSync22(dirname18(path), { recursive: true });
|
|
29197
29569
|
writeFileSync20(path, `${JSON.stringify({ requestedAtMs: Date.now() }, null, 2)}
|
|
29198
29570
|
`, {
|
|
29199
29571
|
mode: 384
|
|
@@ -29225,16 +29597,16 @@ var init_flush_cli2 = __esm(() => {
|
|
|
29225
29597
|
});
|
|
29226
29598
|
|
|
29227
29599
|
// src/hooks/backfill-cli.ts
|
|
29228
|
-
import { existsSync as
|
|
29229
|
-
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";
|
|
29230
29602
|
function backfillRequestPath(home) {
|
|
29231
|
-
return
|
|
29603
|
+
return join38(failproofaiHome(home), "state", "backfill-request.json");
|
|
29232
29604
|
}
|
|
29233
29605
|
function surveySessions(sinceMs, homeDir) {
|
|
29234
29606
|
const out = [];
|
|
29235
29607
|
for (const { cli, dir } of SESSION_DIRS) {
|
|
29236
|
-
const root =
|
|
29237
|
-
if (!
|
|
29608
|
+
const root = join38(homeDir, dir);
|
|
29609
|
+
if (!existsSync38(root))
|
|
29238
29610
|
continue;
|
|
29239
29611
|
let files = 0;
|
|
29240
29612
|
let newest = 0;
|
|
@@ -29243,18 +29615,18 @@ function surveySessions(sinceMs, homeDir) {
|
|
|
29243
29615
|
return;
|
|
29244
29616
|
let entries;
|
|
29245
29617
|
try {
|
|
29246
|
-
entries =
|
|
29618
|
+
entries = readdirSync20(d, { withFileTypes: true });
|
|
29247
29619
|
} catch {
|
|
29248
29620
|
return;
|
|
29249
29621
|
}
|
|
29250
29622
|
for (const e of entries) {
|
|
29251
|
-
const p =
|
|
29623
|
+
const p = join38(d, e.name);
|
|
29252
29624
|
if (e.isDirectory()) {
|
|
29253
29625
|
walk(p, depth + 1);
|
|
29254
29626
|
continue;
|
|
29255
29627
|
}
|
|
29256
29628
|
try {
|
|
29257
|
-
const st =
|
|
29629
|
+
const st = statSync24(p);
|
|
29258
29630
|
if (st.mtimeMs >= sinceMs) {
|
|
29259
29631
|
files += 1;
|
|
29260
29632
|
newest = Math.max(newest, st.mtimeMs);
|
|
@@ -29272,7 +29644,7 @@ function runBackfillCommand(opts = {}) {
|
|
|
29272
29644
|
const now = opts.now ?? Date.now();
|
|
29273
29645
|
const sinceMs = opts.sinceMs ?? now - DEFAULT_BACKFILL_DAYS * 24 * 60 * 60 * 1000;
|
|
29274
29646
|
const home = failproofaiHome();
|
|
29275
|
-
if (!
|
|
29647
|
+
if (!existsSync38(home)) {
|
|
29276
29648
|
return {
|
|
29277
29649
|
exitCode: 1,
|
|
29278
29650
|
lines: [`No failproofai home at ${home}. Run \`failproofai config\` first.`]
|
|
@@ -29304,7 +29676,7 @@ function runBackfillCommand(opts = {}) {
|
|
|
29304
29676
|
]
|
|
29305
29677
|
};
|
|
29306
29678
|
}
|
|
29307
|
-
const found = surveySessions(sinceMs,
|
|
29679
|
+
const found = surveySessions(sinceMs, dirname19(home));
|
|
29308
29680
|
const totalFiles = found.reduce((n, f) => n + f.files, 0);
|
|
29309
29681
|
const sinceLabel = new Date(sinceMs).toISOString().slice(0, 10);
|
|
29310
29682
|
const lines = [
|
|
@@ -29327,7 +29699,7 @@ function runBackfillCommand(opts = {}) {
|
|
|
29327
29699
|
}
|
|
29328
29700
|
try {
|
|
29329
29701
|
const path = backfillRequestPath();
|
|
29330
|
-
mkdirSync23(
|
|
29702
|
+
mkdirSync23(dirname19(path), { recursive: true });
|
|
29331
29703
|
writeFileSync21(path, `${JSON.stringify({ sinceMs, requestedAtMs: now }, null, 2)}
|
|
29332
29704
|
`, {
|
|
29333
29705
|
mode: 384
|
|
@@ -29370,8 +29742,8 @@ var init_backfill_cli = __esm(() => {
|
|
|
29370
29742
|
});
|
|
29371
29743
|
|
|
29372
29744
|
// src/hooks/harness-cli.ts
|
|
29373
|
-
import { homedir as
|
|
29374
|
-
import { resolve as
|
|
29745
|
+
import { homedir as homedir29 } from "node:os";
|
|
29746
|
+
import { resolve as resolve26 } from "node:path";
|
|
29375
29747
|
function unknownHarness(name) {
|
|
29376
29748
|
return fail([
|
|
29377
29749
|
`Unknown harness: ${name}`,
|
|
@@ -29414,8 +29786,8 @@ function comparableLabel(raw) {
|
|
|
29414
29786
|
return raw.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
29415
29787
|
}
|
|
29416
29788
|
function comparablePath(raw) {
|
|
29417
|
-
const home =
|
|
29418
|
-
const expanded = raw === "~" ? home : raw.startsWith("~/") ?
|
|
29789
|
+
const home = homedir29();
|
|
29790
|
+
const expanded = raw === "~" ? home : raw.startsWith("~/") ? resolve26(home, raw.slice(2)) : raw;
|
|
29419
29791
|
return expanded.replace(/\/+$/, "");
|
|
29420
29792
|
}
|
|
29421
29793
|
function effectiveLabel(entry) {
|
|
@@ -29603,7 +29975,7 @@ var init_harness_cli = __esm(() => {
|
|
|
29603
29975
|
});
|
|
29604
29976
|
|
|
29605
29977
|
// src/hooks/fp-config.ts
|
|
29606
|
-
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";
|
|
29607
29979
|
function detectLayout2() {
|
|
29608
29980
|
const raw = readVersionFile2();
|
|
29609
29981
|
if (raw) {
|
|
@@ -29611,17 +29983,17 @@ function detectLayout2() {
|
|
|
29611
29983
|
return { kind: "current", version: raw };
|
|
29612
29984
|
return raw.layout > LAYOUT_VERSION ? { kind: "future", found: raw.layout } : { kind: "stale", found: raw.layout };
|
|
29613
29985
|
}
|
|
29614
|
-
if (
|
|
29986
|
+
if (existsSync39(configFile())) {
|
|
29615
29987
|
const layoutThreePositions = [
|
|
29616
29988
|
legacy.authJson(),
|
|
29617
29989
|
legacy.nextAudit(),
|
|
29618
29990
|
legacy.auditSchedule()
|
|
29619
29991
|
];
|
|
29620
|
-
if (layoutThreePositions.some((p) =>
|
|
29992
|
+
if (layoutThreePositions.some((p) => existsSync39(p)))
|
|
29621
29993
|
return { kind: "stale", found: 3 };
|
|
29622
29994
|
return { kind: "current", version: { layout: LAYOUT_VERSION, cli: "" }, inferred: true };
|
|
29623
29995
|
}
|
|
29624
|
-
if (
|
|
29996
|
+
if (existsSync39(legacy.configToml()))
|
|
29625
29997
|
return { kind: "stale", found: 2 };
|
|
29626
29998
|
const layoutOneMarkers = [
|
|
29627
29999
|
legacy.policyConfig(),
|
|
@@ -29632,7 +30004,7 @@ function detectLayout2() {
|
|
|
29632
30004
|
legacy.ingestCredentials(),
|
|
29633
30005
|
legacy.auditDashboard()
|
|
29634
30006
|
];
|
|
29635
|
-
return layoutOneMarkers.some((p) =>
|
|
30007
|
+
return layoutOneMarkers.some((p) => existsSync39(p)) ? { kind: "stale", found: 1 } : { kind: "absent" };
|
|
29636
30008
|
}
|
|
29637
30009
|
function readLegacyTomlVersion2(text) {
|
|
29638
30010
|
const layout = Number(/^\s*layout\s*=\s*(\d+)\s*$/m.exec(text)?.[1]);
|
|
@@ -29675,14 +30047,14 @@ var init_fp_home2 = () => {};
|
|
|
29675
30047
|
import {
|
|
29676
30048
|
chmodSync as chmodSync7,
|
|
29677
30049
|
copyFileSync as copyFileSync3,
|
|
29678
|
-
existsSync as
|
|
30050
|
+
existsSync as existsSync40,
|
|
29679
30051
|
mkdirSync as mkdirSync25,
|
|
29680
30052
|
readFileSync as readFileSync32,
|
|
29681
30053
|
renameSync as renameSync8,
|
|
29682
30054
|
rmSync as rmSync14,
|
|
29683
30055
|
writeFileSync as writeFileSync23
|
|
29684
30056
|
} from "node:fs";
|
|
29685
|
-
import { basename as
|
|
30057
|
+
import { basename as basename8, dirname as dirname20, join as join39, resolve as resolve27 } from "node:path";
|
|
29686
30058
|
function migrateToLayout42() {
|
|
29687
30059
|
const moves = [
|
|
29688
30060
|
{ from: legacy.authJson(), to: auditSessionFile() },
|
|
@@ -29691,20 +30063,20 @@ function migrateToLayout42() {
|
|
|
29691
30063
|
];
|
|
29692
30064
|
const authDirOverride = process.env.FAILPROOFAI_AUTH_DIR;
|
|
29693
30065
|
if (authDirOverride) {
|
|
29694
|
-
moves.push({ from:
|
|
29695
|
-
from:
|
|
29696
|
-
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")
|
|
29697
30069
|
});
|
|
29698
30070
|
}
|
|
29699
30071
|
const migrated = [];
|
|
29700
30072
|
for (const { from, to } of moves) {
|
|
29701
|
-
if (!
|
|
30073
|
+
if (!existsSync40(from))
|
|
29702
30074
|
continue;
|
|
29703
|
-
if (
|
|
30075
|
+
if (existsSync40(to)) {
|
|
29704
30076
|
rmSync14(from, { force: true });
|
|
29705
30077
|
continue;
|
|
29706
30078
|
}
|
|
29707
|
-
mkdirSync25(
|
|
30079
|
+
mkdirSync25(dirname20(to), { recursive: true });
|
|
29708
30080
|
try {
|
|
29709
30081
|
renameSync8(from, to);
|
|
29710
30082
|
} catch {
|
|
@@ -29718,10 +30090,10 @@ function migrateToLayout42() {
|
|
|
29718
30090
|
}
|
|
29719
30091
|
rmSync14(from, { force: true });
|
|
29720
30092
|
}
|
|
29721
|
-
migrated.push(`${
|
|
30093
|
+
migrated.push(`${basename8(from)} → audit/${basename8(to)}`);
|
|
29722
30094
|
}
|
|
29723
30095
|
for (const secret of [auditSessionFile()]) {
|
|
29724
|
-
if (!
|
|
30096
|
+
if (!existsSync40(secret))
|
|
29725
30097
|
continue;
|
|
29726
30098
|
try {
|
|
29727
30099
|
chmodSync7(secret, 384);
|
|
@@ -29762,17 +30134,17 @@ function appendLedger2(entry) {
|
|
|
29762
30134
|
} catch {}
|
|
29763
30135
|
}
|
|
29764
30136
|
function backupNameOf2(f) {
|
|
29765
|
-
return f.as ??
|
|
30137
|
+
return f.as ?? basename8(f.at());
|
|
29766
30138
|
}
|
|
29767
30139
|
function pruneMigratedCredentials2(from) {
|
|
29768
30140
|
const pruned = [];
|
|
29769
30141
|
for (let layout = from;layout < LAYOUT_VERSION; layout++) {
|
|
29770
30142
|
for (const { as, landsAt } of PRUNED_AFTER_SUCCESS2) {
|
|
29771
30143
|
try {
|
|
29772
|
-
if (!
|
|
30144
|
+
if (!existsSync40(landsAt()))
|
|
29773
30145
|
continue;
|
|
29774
|
-
const copy =
|
|
29775
|
-
if (!
|
|
30146
|
+
const copy = resolve27(migrationBackupDir(layout), as);
|
|
30147
|
+
if (!existsSync40(copy))
|
|
29776
30148
|
continue;
|
|
29777
30149
|
rmSync14(copy, { force: true });
|
|
29778
30150
|
pruned.push(as);
|
|
@@ -29785,7 +30157,7 @@ function filesToBackUp2() {
|
|
|
29785
30157
|
const seen = new Map;
|
|
29786
30158
|
for (const f of [...BACKED_UP2, ...BACKED_UP_LEGACY2]) {
|
|
29787
30159
|
const path = f.at();
|
|
29788
|
-
if (
|
|
30160
|
+
if (existsSync40(path))
|
|
29789
30161
|
seen.set(path, backupNameOf2(f));
|
|
29790
30162
|
}
|
|
29791
30163
|
return [...seen].map(([path, as]) => ({ path, as }));
|
|
@@ -29801,7 +30173,7 @@ function backupBeforeMigrating2(from) {
|
|
|
29801
30173
|
}
|
|
29802
30174
|
for (const { path: source, as } of filesToBackUp2()) {
|
|
29803
30175
|
try {
|
|
29804
|
-
copyFileSync3(source,
|
|
30176
|
+
copyFileSync3(source, resolve27(dir, as));
|
|
29805
30177
|
saved.push(as);
|
|
29806
30178
|
} catch {}
|
|
29807
30179
|
}
|
|
@@ -29933,13 +30305,13 @@ var init_migrations2 = __esm(() => {
|
|
|
29933
30305
|
{ at: legacy.auditSchedule }
|
|
29934
30306
|
];
|
|
29935
30307
|
PRUNED_AFTER_SUCCESS2 = [
|
|
29936
|
-
{ as:
|
|
30308
|
+
{ as: basename8(legacy.authJson()), landsAt: auditSessionFile }
|
|
29937
30309
|
];
|
|
29938
30310
|
});
|
|
29939
30311
|
|
|
29940
30312
|
// src/hooks/daemon-service.ts
|
|
29941
30313
|
import {
|
|
29942
|
-
existsSync as
|
|
30314
|
+
existsSync as existsSync41,
|
|
29943
30315
|
mkdirSync as mkdirSync26,
|
|
29944
30316
|
mkdtempSync as mkdtempSync2,
|
|
29945
30317
|
readFileSync as readFileSync33,
|
|
@@ -29947,8 +30319,8 @@ import {
|
|
|
29947
30319
|
unlinkSync as unlinkSync5,
|
|
29948
30320
|
rmSync as rmSync15
|
|
29949
30321
|
} from "node:fs";
|
|
29950
|
-
import { homedir as
|
|
29951
|
-
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";
|
|
29952
30324
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
29953
30325
|
function isDaemonSupportedPlatform2() {
|
|
29954
30326
|
return process.platform === "linux" || process.platform === "darwin";
|
|
@@ -29964,13 +30336,13 @@ function resolveFailproofaidBinaryPath2() {
|
|
|
29964
30336
|
if (process.env.FAILPROOFAI_DAEMON_BINARY)
|
|
29965
30337
|
return process.env.FAILPROOFAI_DAEMON_BINARY;
|
|
29966
30338
|
const downloaded = installedBinaryPath();
|
|
29967
|
-
if (
|
|
30339
|
+
if (existsSync41(downloaded))
|
|
29968
30340
|
return downloaded;
|
|
29969
30341
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
29970
30342
|
if (packageRoot) {
|
|
29971
30343
|
for (const profile of ["release", "debug"]) {
|
|
29972
|
-
const candidate =
|
|
29973
|
-
if (
|
|
30344
|
+
const candidate = resolve28(packageRoot, "target", profile, "failproofaid");
|
|
30345
|
+
if (existsSync41(candidate))
|
|
29974
30346
|
return candidate;
|
|
29975
30347
|
}
|
|
29976
30348
|
}
|
|
@@ -30000,8 +30372,8 @@ function resolveWorkerCommand2() {
|
|
|
30000
30372
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
30001
30373
|
if (!packageRoot)
|
|
30002
30374
|
return null;
|
|
30003
|
-
const workerScript =
|
|
30004
|
-
if (!
|
|
30375
|
+
const workerScript = resolve28(packageRoot, "dist", "worker.mjs");
|
|
30376
|
+
if (!existsSync41(workerScript))
|
|
30005
30377
|
return null;
|
|
30006
30378
|
return `${shellQuote2(process.execPath)} ${shellQuote2(workerScript)}`;
|
|
30007
30379
|
}
|
|
@@ -30011,8 +30383,8 @@ function resolveCliCommand2() {
|
|
|
30011
30383
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
30012
30384
|
if (!packageRoot)
|
|
30013
30385
|
return null;
|
|
30014
|
-
const cliScript =
|
|
30015
|
-
if (!
|
|
30386
|
+
const cliScript = resolve28(packageRoot, "dist", "cli.mjs");
|
|
30387
|
+
if (!existsSync41(cliScript))
|
|
30016
30388
|
return null;
|
|
30017
30389
|
return `${shellQuote2(process.execPath)} ${shellQuote2(cliScript)}`;
|
|
30018
30390
|
}
|
|
@@ -30025,8 +30397,8 @@ function workerScriptPath2() {
|
|
|
30025
30397
|
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT;
|
|
30026
30398
|
if (!packageRoot)
|
|
30027
30399
|
return null;
|
|
30028
|
-
const workerScript =
|
|
30029
|
-
return
|
|
30400
|
+
const workerScript = resolve28(packageRoot, "dist", "worker.mjs");
|
|
30401
|
+
return existsSync41(workerScript) ? workerScript : null;
|
|
30030
30402
|
}
|
|
30031
30403
|
function assertUnitSafe2(value, field) {
|
|
30032
30404
|
if (UNIT_UNSAFE_RE2.test(value)) {
|
|
@@ -30052,10 +30424,10 @@ function systemdUnitDir2() {
|
|
|
30052
30424
|
return process.env.FAILPROOFAI_SYSTEMD_DIR || "/etc/systemd/system";
|
|
30053
30425
|
}
|
|
30054
30426
|
function systemdUnitPath2(user = serviceUser2()) {
|
|
30055
|
-
return
|
|
30427
|
+
return resolve28(systemdUnitDir2(), systemdUnitName2(user));
|
|
30056
30428
|
}
|
|
30057
30429
|
function legacySystemdUserUnitPath2() {
|
|
30058
|
-
return
|
|
30430
|
+
return resolve28(homedir30(), ".config", "systemd", "user", "failproofaid.service");
|
|
30059
30431
|
}
|
|
30060
30432
|
function launchdLabel2(user = serviceUser2()) {
|
|
30061
30433
|
return `ai.failproof.failproofaid.${user}`;
|
|
@@ -30064,7 +30436,7 @@ function launchdPlistPath2(user = serviceUser2()) {
|
|
|
30064
30436
|
return `/Library/LaunchDaemons/${launchdLabel2(user)}.plist`;
|
|
30065
30437
|
}
|
|
30066
30438
|
function legacyLaunchAgentPlistPath2() {
|
|
30067
|
-
return
|
|
30439
|
+
return resolve28(homedir30(), "Library", "LaunchAgents", "ai.failproof.failproofaid.plist");
|
|
30068
30440
|
}
|
|
30069
30441
|
function legacySharedLaunchDaemonPath2() {
|
|
30070
30442
|
return "/Library/LaunchDaemons/ai.failproof.failproofaid.plist";
|
|
@@ -30102,8 +30474,8 @@ function runPrivileged2(command, args) {
|
|
|
30102
30474
|
execFileSync3(cmd, argv, { stdio: "ignore", timeout: SERVICE_CMD_TIMEOUT_MS2 });
|
|
30103
30475
|
}
|
|
30104
30476
|
function writePrivilegedFile2(destination, contents, mode = "0644") {
|
|
30105
|
-
const stagingDir = mkdtempSync2(
|
|
30106
|
-
const staging =
|
|
30477
|
+
const stagingDir = mkdtempSync2(resolve28(tmpdir3(), "failproofaid-stage-"));
|
|
30478
|
+
const staging = resolve28(stagingDir, "service-definition");
|
|
30107
30479
|
try {
|
|
30108
30480
|
writeFileSync24(staging, contents, "utf8");
|
|
30109
30481
|
runPrivileged2("install", ["-m", mode, staging, destination]);
|
|
@@ -30115,7 +30487,7 @@ function removeLegacyUserService2() {
|
|
|
30115
30487
|
try {
|
|
30116
30488
|
if (process.platform === "linux") {
|
|
30117
30489
|
const legacy = legacySystemdUserUnitPath2();
|
|
30118
|
-
if (!
|
|
30490
|
+
if (!existsSync41(legacy))
|
|
30119
30491
|
return;
|
|
30120
30492
|
try {
|
|
30121
30493
|
execFileSync3("systemctl", ["--user", "disable", "--now", "failproofaid.service"], {
|
|
@@ -30132,7 +30504,7 @@ function removeLegacyUserService2() {
|
|
|
30132
30504
|
} catch {}
|
|
30133
30505
|
} else {
|
|
30134
30506
|
const legacyAgent = legacyLaunchAgentPlistPath2();
|
|
30135
|
-
if (
|
|
30507
|
+
if (existsSync41(legacyAgent)) {
|
|
30136
30508
|
try {
|
|
30137
30509
|
execFileSync3("launchctl", ["unload", "-w", legacyAgent], {
|
|
30138
30510
|
stdio: "ignore",
|
|
@@ -30142,7 +30514,7 @@ function removeLegacyUserService2() {
|
|
|
30142
30514
|
unlinkSync5(legacyAgent);
|
|
30143
30515
|
}
|
|
30144
30516
|
const legacyDaemon = legacySharedLaunchDaemonPath2();
|
|
30145
|
-
if (
|
|
30517
|
+
if (existsSync41(legacyDaemon)) {
|
|
30146
30518
|
try {
|
|
30147
30519
|
runPrivileged2("launchctl", ["unload", "-w", legacyDaemon]);
|
|
30148
30520
|
} catch {}
|
|
@@ -30158,8 +30530,8 @@ function systemdUnitContents2(binaryPath, workerCmd, cliCmd = null) {
|
|
|
30158
30530
|
`).join("");
|
|
30159
30531
|
const user = assertUnitSafe2(serviceUser2(), "User");
|
|
30160
30532
|
assertUnitSafe2(binaryPath, "ExecStart");
|
|
30161
|
-
assertUnitSafe2(
|
|
30162
|
-
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));
|
|
30163
30535
|
const conditionLines = conditionPaths.map((p) => `ConditionPathExists=${assertUnitSafe2(p, "ConditionPathExists")}
|
|
30164
30536
|
`).join("");
|
|
30165
30537
|
return `[Unit]
|
|
@@ -30172,7 +30544,7 @@ User=${user}
|
|
|
30172
30544
|
# Set explicitly rather than relying on systemd deriving it from User=:
|
|
30173
30545
|
# failproofaid stores per-user state and refuses to start without HOME, so this
|
|
30174
30546
|
# required variable is not left to a version-dependent default.
|
|
30175
|
-
Environment="HOME=${
|
|
30547
|
+
Environment="HOME=${homedir30()}"
|
|
30176
30548
|
${envLines}ExecStart=${binaryPath}
|
|
30177
30549
|
Restart=on-failure
|
|
30178
30550
|
RestartSec=2
|
|
@@ -30217,9 +30589,9 @@ ${env.map(([key, value]) => ` <key>${key}</key>
|
|
|
30217
30589
|
<key>UserName</key>
|
|
30218
30590
|
<string>${escapeXml2(serviceUser2())}</string>
|
|
30219
30591
|
${envBlock} <key>StandardOutPath</key>
|
|
30220
|
-
<string>${escapeXml2(
|
|
30592
|
+
<string>${escapeXml2(resolve28(logDir, "failproofaid.log"))}</string>
|
|
30221
30593
|
<key>StandardErrorPath</key>
|
|
30222
|
-
<string>${escapeXml2(
|
|
30594
|
+
<string>${escapeXml2(resolve28(logDir, "failproofaid.err.log"))}</string>
|
|
30223
30595
|
</dict>
|
|
30224
30596
|
</plist>
|
|
30225
30597
|
`;
|
|
@@ -30364,7 +30736,7 @@ function daemonServiceStatus2() {
|
|
|
30364
30736
|
if (!isDaemonSupportedPlatform2())
|
|
30365
30737
|
return "unsupported-platform";
|
|
30366
30738
|
if (process.platform === "linux") {
|
|
30367
|
-
if (!
|
|
30739
|
+
if (!existsSync41(systemdUnitPath2()))
|
|
30368
30740
|
return "not-installed";
|
|
30369
30741
|
try {
|
|
30370
30742
|
const out = execFileSync3("systemctl", ["is-active", systemdUnitName2()], {
|
|
@@ -30377,7 +30749,7 @@ function daemonServiceStatus2() {
|
|
|
30377
30749
|
}
|
|
30378
30750
|
}
|
|
30379
30751
|
const plistPath = launchdPlistPath2();
|
|
30380
|
-
if (!
|
|
30752
|
+
if (!existsSync41(plistPath))
|
|
30381
30753
|
return "not-installed";
|
|
30382
30754
|
try {
|
|
30383
30755
|
const root = typeof process.getuid === "function" && process.getuid() === 0;
|
|
@@ -30407,7 +30779,7 @@ var init_daemon_service2 = __esm(() => {
|
|
|
30407
30779
|
});
|
|
30408
30780
|
|
|
30409
30781
|
// src/hooks/uninstall-cli.ts
|
|
30410
|
-
import { existsSync as
|
|
30782
|
+
import { existsSync as existsSync42, rmSync as rmSync16 } from "node:fs";
|
|
30411
30783
|
function survey(cwd) {
|
|
30412
30784
|
const clis = [];
|
|
30413
30785
|
for (const id of listInstallableIds()) {
|
|
@@ -30428,9 +30800,9 @@ function survey(cwd) {
|
|
|
30428
30800
|
return {
|
|
30429
30801
|
clis,
|
|
30430
30802
|
servicePath,
|
|
30431
|
-
serviceInstalled: !!servicePath &&
|
|
30803
|
+
serviceInstalled: !!servicePath && existsSync42(servicePath),
|
|
30432
30804
|
daemonConfigured,
|
|
30433
|
-
homeExists:
|
|
30805
|
+
homeExists: existsSync42(failproofaiHome())
|
|
30434
30806
|
};
|
|
30435
30807
|
}
|
|
30436
30808
|
async function runUninstallCommand(opts = {}) {
|
|
@@ -30528,7 +30900,7 @@ async function runUninstallCommand(opts = {}) {
|
|
|
30528
30900
|
} catch {}
|
|
30529
30901
|
try {
|
|
30530
30902
|
await uninstallDaemonService();
|
|
30531
|
-
if (found.servicePath &&
|
|
30903
|
+
if (found.servicePath && existsSync42(found.servicePath)) {
|
|
30532
30904
|
failures.push(`the service at ${found.servicePath} is still there (most often: no sudo). ` + `Remove it with the commands below.`);
|
|
30533
30905
|
} else {
|
|
30534
30906
|
lines.push(`✓ stopped and removed the daemon service`);
|
|
@@ -30551,7 +30923,7 @@ async function runUninstallCommand(opts = {}) {
|
|
|
30551
30923
|
lines.push(``, `Not everything could be removed:`);
|
|
30552
30924
|
for (const f of failures)
|
|
30553
30925
|
lines.push(` ✗ ${f}`);
|
|
30554
|
-
if (found.servicePath &&
|
|
30926
|
+
if (found.servicePath && existsSync42(found.servicePath)) {
|
|
30555
30927
|
lines.push(``, `To remove the service by hand:`, ...manualServiceRemoval(found.servicePath), ``, `(\`${daemonStatusCommand()}\` shows its current state.)`);
|
|
30556
30928
|
}
|
|
30557
30929
|
return { exitCode: 1, lines, planLines, purged };
|
|
@@ -30583,10 +30955,10 @@ var init_uninstall_cli = __esm(() => {
|
|
|
30583
30955
|
|
|
30584
30956
|
// src/hooks/pack-cli.ts
|
|
30585
30957
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
30586
|
-
import { homedir as
|
|
30958
|
+
import { homedir as homedir31, tmpdir as tmpdir4 } from "node:os";
|
|
30587
30959
|
import { createHash as createHash9 } from "node:crypto";
|
|
30588
|
-
import { copyFileSync as copyFileSync4, existsSync as
|
|
30589
|
-
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";
|
|
30590
30962
|
function parseList(rest, flag) {
|
|
30591
30963
|
const idx = rest.findIndex((a) => a === flag || a.startsWith(`${flag}=`));
|
|
30592
30964
|
if (idx === -1)
|
|
@@ -30686,7 +31058,7 @@ async function build(rest) {
|
|
|
30686
31058
|
const version = flag("version");
|
|
30687
31059
|
const commit = flag("commit");
|
|
30688
31060
|
const effect = flag("effect") ?? "enforce";
|
|
30689
|
-
const outDir =
|
|
31061
|
+
const outDir = resolve29(flag("out") ?? "dist-pack");
|
|
30690
31062
|
if (!entry || !id || !version) {
|
|
30691
31063
|
return fail2([
|
|
30692
31064
|
"Usage: failproofai publish <entry.mjs> --repo <owner>/<repo> --version <version>",
|
|
@@ -30699,8 +31071,8 @@ async function build(rest) {
|
|
|
30699
31071
|
} catch (err) {
|
|
30700
31072
|
return fail2([err instanceof Error ? err.message : String(err)]);
|
|
30701
31073
|
}
|
|
30702
|
-
const entryPath =
|
|
30703
|
-
if (!
|
|
31074
|
+
const entryPath = resolve29(entry);
|
|
31075
|
+
if (!existsSync43(entryPath))
|
|
30704
31076
|
return fail2([`No such file: ${entryPath}`]);
|
|
30705
31077
|
const source = readFileSync34(entryPath, "utf8");
|
|
30706
31078
|
const localImport = /(?:^|\n)\s*(?:import|export)[^;\n]*from\s+["'](\.[^"']*)["']/.exec(source);
|
|
@@ -30759,12 +31131,12 @@ async function build(rest) {
|
|
|
30759
31131
|
}, null, 2) + `
|
|
30760
31132
|
`;
|
|
30761
31133
|
mkdirSync27(outDir, { recursive: true });
|
|
30762
|
-
const manifestPath =
|
|
30763
|
-
const entryOut =
|
|
31134
|
+
const manifestPath = resolve29(outDir, PACK_MANIFEST_ASSET);
|
|
31135
|
+
const entryOut = resolve29(outDir, PACK_ENTRY_ASSET);
|
|
30764
31136
|
writeFileSync25(manifestPath, manifest, "utf8");
|
|
30765
31137
|
copyFileSync4(entryPath, entryOut);
|
|
30766
31138
|
const sha = (bytes) => createHash9("sha256").update(bytes).digest("hex");
|
|
30767
|
-
writeFileSync25(
|
|
31139
|
+
writeFileSync25(resolve29(outDir, PACK_CHECKSUMS_ASSET), `${sha(manifest)} ${PACK_MANIFEST_ASSET}
|
|
30768
31140
|
${sha(readFileSync34(entryOut))} ${PACK_ENTRY_ASSET}
|
|
30769
31141
|
`, "utf8");
|
|
30770
31142
|
const on = policies.filter((p) => p.defaultEnabled).length;
|
|
@@ -30894,11 +31266,11 @@ async function scaffold(target) {
|
|
|
30894
31266
|
return ok2(["Nothing written."]);
|
|
30895
31267
|
chosen = answer.trim();
|
|
30896
31268
|
}
|
|
30897
|
-
const path =
|
|
30898
|
-
if (
|
|
31269
|
+
const path = resolve29(withPolicyExtension(chosen ?? "my-policies"));
|
|
31270
|
+
if (existsSync43(path)) {
|
|
30899
31271
|
return fail2([`${path} already exists — name a different file, or edit that one.`]);
|
|
30900
31272
|
}
|
|
30901
|
-
mkdirSync27(
|
|
31273
|
+
mkdirSync27(resolve29(path, ".."), { recursive: true });
|
|
30902
31274
|
writeFileSync25(path, `import { customPolicies, allow, deny } from "failproofai";
|
|
30903
31275
|
|
|
30904
31276
|
// One file, no relative imports: only this entry is digest-pinned, so a pack
|
|
@@ -30936,7 +31308,7 @@ customPolicies.add({
|
|
|
30936
31308
|
function inferRepo(entryPath) {
|
|
30937
31309
|
try {
|
|
30938
31310
|
const url = execFileSync4("git", ["remote", "get-url", "origin"], {
|
|
30939
|
-
cwd:
|
|
31311
|
+
cwd: resolve29(entryPath, ".."),
|
|
30940
31312
|
encoding: "utf8",
|
|
30941
31313
|
stdio: ["ignore", "pipe", "ignore"],
|
|
30942
31314
|
timeout: 5000
|
|
@@ -30948,7 +31320,7 @@ function inferRepo(entryPath) {
|
|
|
30948
31320
|
}
|
|
30949
31321
|
}
|
|
30950
31322
|
function inferCommit(entryPath, outDir, sources) {
|
|
30951
|
-
const cwd =
|
|
31323
|
+
const cwd = resolve29(entryPath, "..");
|
|
30952
31324
|
const raw = (args) => {
|
|
30953
31325
|
try {
|
|
30954
31326
|
return execFileSync4("git", args, {
|
|
@@ -31003,9 +31375,9 @@ function realOrSelf(path) {
|
|
|
31003
31375
|
}
|
|
31004
31376
|
}
|
|
31005
31377
|
function sourcesInHead(git, raw, sources) {
|
|
31006
|
-
const paths = sources.map((f) => realOrSelf(
|
|
31378
|
+
const paths = sources.map((f) => realOrSelf(resolve29(f)));
|
|
31007
31379
|
const shown = git(["rev-parse", "--show-toplevel"]);
|
|
31008
|
-
const top = shown === null ? null : realOrSelf(
|
|
31380
|
+
const top = shown === null ? null : realOrSelf(resolve29(shown));
|
|
31009
31381
|
const missing = [];
|
|
31010
31382
|
for (const path of paths) {
|
|
31011
31383
|
const rel = top ? relative5(top, path) : null;
|
|
@@ -31029,7 +31401,7 @@ function sourcesInHead(git, raw, sources) {
|
|
|
31029
31401
|
]);
|
|
31030
31402
|
if (status === null)
|
|
31031
31403
|
return { ok: false, offending: paths, why: "modified" };
|
|
31032
|
-
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)));
|
|
31033
31405
|
if (dirty.length > 0)
|
|
31034
31406
|
return { ok: false, offending: dirty, why: "modified" };
|
|
31035
31407
|
return { ok: true };
|
|
@@ -31037,19 +31409,19 @@ function sourcesInHead(git, raw, sources) {
|
|
|
31037
31409
|
function skipOutDir(git, entryPath, outDir) {
|
|
31038
31410
|
if (!outDir)
|
|
31039
31411
|
return [];
|
|
31040
|
-
const out =
|
|
31041
|
-
if (
|
|
31412
|
+
const out = resolve29(outDir);
|
|
31413
|
+
if (resolve29(entryPath).startsWith(out + sep6))
|
|
31042
31414
|
return [];
|
|
31043
31415
|
const top = git(["rev-parse", "--show-toplevel"]);
|
|
31044
31416
|
if (!top)
|
|
31045
31417
|
return [];
|
|
31046
|
-
const rel = relative5(
|
|
31418
|
+
const rel = relative5(resolve29(top), out);
|
|
31047
31419
|
if (!rel || rel.startsWith("..") || isAbsolute4(rel))
|
|
31048
31420
|
return [];
|
|
31049
31421
|
return ["--", ":(top)", `:(exclude,literal,top)${rel.split(sep6).join("/")}`];
|
|
31050
31422
|
}
|
|
31051
31423
|
function inferTaggedVersion(entryPath, sources) {
|
|
31052
|
-
const cwd =
|
|
31424
|
+
const cwd = resolve29(entryPath, "..");
|
|
31053
31425
|
const raw = (args) => {
|
|
31054
31426
|
try {
|
|
31055
31427
|
return execFileSync4("git", args, {
|
|
@@ -31079,7 +31451,7 @@ function inferTaggedVersion(entryPath, sources) {
|
|
|
31079
31451
|
function findEntry(dir) {
|
|
31080
31452
|
let names;
|
|
31081
31453
|
try {
|
|
31082
|
-
names =
|
|
31454
|
+
names = readdirSync21(dir);
|
|
31083
31455
|
} catch {
|
|
31084
31456
|
return [];
|
|
31085
31457
|
}
|
|
@@ -31087,9 +31459,9 @@ function findEntry(dir) {
|
|
|
31087
31459
|
for (const name of names) {
|
|
31088
31460
|
if (!/\.(mjs|js|ts)$/.test(name))
|
|
31089
31461
|
continue;
|
|
31090
|
-
const full =
|
|
31462
|
+
const full = resolve29(dir, name);
|
|
31091
31463
|
try {
|
|
31092
|
-
if (
|
|
31464
|
+
if (statSync26(full).size > 512 * 1024)
|
|
31093
31465
|
continue;
|
|
31094
31466
|
const text = readFileSync34(full, "utf8");
|
|
31095
31467
|
if (/from\s+["']failproofai["']/.test(text) && /customPolicies\s*\.\s*add\s*\(/.test(text)) {
|
|
@@ -31102,13 +31474,13 @@ function findEntry(dir) {
|
|
|
31102
31474
|
return found.sort();
|
|
31103
31475
|
}
|
|
31104
31476
|
function withLocalImports(sources) {
|
|
31105
|
-
const seen = new Set(sources.map((f) =>
|
|
31477
|
+
const seen = new Set(sources.map((f) => resolve29(f)));
|
|
31106
31478
|
const queue = [...seen];
|
|
31107
31479
|
while (queue.length > 0 && seen.size < 500) {
|
|
31108
31480
|
const file = queue.shift();
|
|
31109
31481
|
let text;
|
|
31110
31482
|
try {
|
|
31111
|
-
if (
|
|
31483
|
+
if (statSync26(file).size > 512 * 1024)
|
|
31112
31484
|
continue;
|
|
31113
31485
|
text = readFileSync34(file, "utf8");
|
|
31114
31486
|
} catch {
|
|
@@ -31116,13 +31488,13 @@ function withLocalImports(sources) {
|
|
|
31116
31488
|
}
|
|
31117
31489
|
for (const re of LOCAL_IMPORT_RES) {
|
|
31118
31490
|
for (const match of text.matchAll(re)) {
|
|
31119
|
-
const base =
|
|
31491
|
+
const base = resolve29(dirname21(file), match[1]);
|
|
31120
31492
|
for (const ext of LOCAL_IMPORT_EXTENSIONS) {
|
|
31121
31493
|
const candidate = base + ext;
|
|
31122
31494
|
if (seen.has(candidate))
|
|
31123
31495
|
break;
|
|
31124
31496
|
try {
|
|
31125
|
-
if (!
|
|
31497
|
+
if (!statSync26(candidate).isFile())
|
|
31126
31498
|
continue;
|
|
31127
31499
|
} catch {
|
|
31128
31500
|
continue;
|
|
@@ -31137,7 +31509,7 @@ function withLocalImports(sources) {
|
|
|
31137
31509
|
return [...seen];
|
|
31138
31510
|
}
|
|
31139
31511
|
function settleGitState(entryPath, provenance, packFiles, id, outDir) {
|
|
31140
|
-
const cwd =
|
|
31512
|
+
const cwd = resolve29(entryPath, "..");
|
|
31141
31513
|
const raw = (args) => {
|
|
31142
31514
|
try {
|
|
31143
31515
|
return execFileSync4("git", args, {
|
|
@@ -31212,11 +31584,11 @@ function settleGitState(entryPath, provenance, packFiles, id, outDir) {
|
|
|
31212
31584
|
if (root === null || status === null)
|
|
31213
31585
|
return null;
|
|
31214
31586
|
const entries = porcelainEntries(status);
|
|
31215
|
-
const dirty = entries.map((entry) =>
|
|
31216
|
-
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));
|
|
31217
31589
|
if (dirty.length === 0)
|
|
31218
31590
|
return null;
|
|
31219
|
-
const mine = new Set(packFiles.map((f) =>
|
|
31591
|
+
const mine = new Set(packFiles.map((f) => resolve29(f)));
|
|
31220
31592
|
const foreign = dirty.filter((path) => !mine.has(path));
|
|
31221
31593
|
const toStage = [...dirty, ...renamedFrom];
|
|
31222
31594
|
if (foreign.length > 0) {
|
|
@@ -31347,7 +31719,7 @@ function pushExistingHistory(dir, owner, name, token) {
|
|
|
31347
31719
|
const branch = git(["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
31348
31720
|
if (!branch || branch === "HEAD" || !git(["rev-parse", "--verify", "HEAD"]))
|
|
31349
31721
|
return false;
|
|
31350
|
-
const askpass =
|
|
31722
|
+
const askpass = join40(mkdtempSync3(join40(tmpdir4(), "fpai-askpass-")), "askpass.sh");
|
|
31351
31723
|
try {
|
|
31352
31724
|
writeFileSync25(askpass, `#!/bin/sh
|
|
31353
31725
|
case "$1" in
|
|
@@ -31369,7 +31741,7 @@ esac
|
|
|
31369
31741
|
return true;
|
|
31370
31742
|
} finally {
|
|
31371
31743
|
try {
|
|
31372
|
-
rmSync17(
|
|
31744
|
+
rmSync17(dirname21(askpass), { recursive: true, force: true });
|
|
31373
31745
|
} catch {}
|
|
31374
31746
|
}
|
|
31375
31747
|
}
|
|
@@ -31393,8 +31765,8 @@ failproofai policies add ${owner}/${name}
|
|
|
31393
31765
|
function findBun() {
|
|
31394
31766
|
const candidates = [
|
|
31395
31767
|
"bun",
|
|
31396
|
-
process.env.BUN_INSTALL ?
|
|
31397
|
-
|
|
31768
|
+
process.env.BUN_INSTALL ? resolve29(process.env.BUN_INSTALL, "bin", "bun") : null,
|
|
31769
|
+
resolve29(homedir31(), ".bun", "bin", "bun"),
|
|
31398
31770
|
"/opt/homebrew/bin/bun",
|
|
31399
31771
|
"/usr/local/bin/bun"
|
|
31400
31772
|
].filter((c) => c !== null);
|
|
@@ -31421,11 +31793,11 @@ function bundleEntry(sources, outDir) {
|
|
|
31421
31793
|
};
|
|
31422
31794
|
}
|
|
31423
31795
|
mkdirSync27(outDir, { recursive: true });
|
|
31424
|
-
const entry =
|
|
31425
|
-
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(`
|
|
31426
31798
|
`) + `
|
|
31427
31799
|
`, "utf8");
|
|
31428
|
-
const bundled =
|
|
31800
|
+
const bundled = resolve29(outDir, ".bundled.mjs");
|
|
31429
31801
|
try {
|
|
31430
31802
|
execFileSync4(bun, [
|
|
31431
31803
|
"build",
|
|
@@ -31538,12 +31910,12 @@ async function publish(rest) {
|
|
|
31538
31910
|
if (askingWhere) {
|
|
31539
31911
|
const found = discovered.length > 0 ? discovered : [entry];
|
|
31540
31912
|
process.stdout.write(`
|
|
31541
|
-
${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(", ")}
|
|
31542
31914
|
|
|
31543
31915
|
`);
|
|
31544
31916
|
const token = githubToken();
|
|
31545
31917
|
const login = token ? await credentialLogin(token) : null;
|
|
31546
|
-
const folder =
|
|
31918
|
+
const folder = basename9(resolve29(entry, ".."));
|
|
31547
31919
|
const answered = await askWhereToPublish(`${login ?? "your-account"}/${folder}`, { stdin: process.stdin, stdout: process.stdout });
|
|
31548
31920
|
if (answered === null)
|
|
31549
31921
|
return ok2(["Nothing was published."]);
|
|
@@ -31554,7 +31926,7 @@ async function publish(rest) {
|
|
|
31554
31926
|
let versionFromSha = false;
|
|
31555
31927
|
const dryRun = rest.includes("--dry-run") || !repo;
|
|
31556
31928
|
const allowPrivate = rest.includes("--allow-private");
|
|
31557
|
-
const id = flag("id") ?? repo ?? (dryRun && entry ? `local/${
|
|
31929
|
+
const id = flag("id") ?? repo ?? (dryRun && entry ? `local/${basename9(resolve29(entry, ".."))}` : undefined);
|
|
31558
31930
|
const [owner, name] = (repo ?? "/").split("/");
|
|
31559
31931
|
if (repo && (!owner || !name || repo.split("/").length !== 2)) {
|
|
31560
31932
|
return fail2([`--repo must be <owner>/<repo>, got ${JSON.stringify(repo)}`]);
|
|
@@ -31573,7 +31945,7 @@ async function publish(rest) {
|
|
|
31573
31945
|
"With no --repo it writes the three release assets and stops."
|
|
31574
31946
|
]);
|
|
31575
31947
|
}
|
|
31576
|
-
const outDirEarly =
|
|
31948
|
+
const outDirEarly = resolve29(flag("out") ?? "dist-pack");
|
|
31577
31949
|
let provenance = entry ? inferCommit(entry, outDirEarly, bundledSources) : null;
|
|
31578
31950
|
const gitLines = [];
|
|
31579
31951
|
if (!version && entry && interactive) {
|
|
@@ -31613,7 +31985,7 @@ async function publish(rest) {
|
|
|
31613
31985
|
"It needs write access to releases on that repository, and nothing else."
|
|
31614
31986
|
]);
|
|
31615
31987
|
}
|
|
31616
|
-
const ensured = await ensureRepo(owner, name, id, token,
|
|
31988
|
+
const ensured = await ensureRepo(owner, name, id, token, resolve29(entry, ".."));
|
|
31617
31989
|
if ("error" in ensured)
|
|
31618
31990
|
return fail2(ensured.error);
|
|
31619
31991
|
created = ensured.created;
|
|
@@ -31712,7 +32084,7 @@ async function publish(rest) {
|
|
|
31712
32084
|
if (prior) {
|
|
31713
32085
|
await gh(`${GITHUB_API2}/repos/${owner}/${name}/releases/assets/${prior.id}`, auth, { method: "DELETE" });
|
|
31714
32086
|
}
|
|
31715
|
-
const bytes = readFileSync34(
|
|
32087
|
+
const bytes = readFileSync34(resolve29(outDir, asset));
|
|
31716
32088
|
const upload = await gh(`${GITHUB_UPLOADS2}/repos/${owner}/${name}/releases/${releaseId}/assets?name=${encodeURIComponent(asset)}`, auth, {
|
|
31717
32089
|
method: "POST",
|
|
31718
32090
|
contentType: asset.endsWith(".json") ? "application/json" : "application/octet-stream",
|
|
@@ -32393,8 +32765,8 @@ var init_install_prompt = __esm(() => {
|
|
|
32393
32765
|
|
|
32394
32766
|
// src/hooks/manager.ts
|
|
32395
32767
|
import { execSync as execSync7 } from "node:child_process";
|
|
32396
|
-
import { existsSync as
|
|
32397
|
-
import { resolve as
|
|
32768
|
+
import { existsSync as existsSync44 } from "node:fs";
|
|
32769
|
+
import { resolve as resolve30, basename as basename10 } from "node:path";
|
|
32398
32770
|
import { platform as platform4, arch as arch4, release as release3, hostname as hostname6 } from "node:os";
|
|
32399
32771
|
function getSettingsPath2(scope, cwd) {
|
|
32400
32772
|
return claudeCode.getSettingsPath(scope, cwd);
|
|
@@ -32613,9 +32985,9 @@ async function installHooksImpl2(policyNames, scope = "user", cwd, includeBeta =
|
|
|
32613
32985
|
delete configToWrite.customPoliciesPath;
|
|
32614
32986
|
delete configToWrite.customPoliciesPaths;
|
|
32615
32987
|
} else if (customPoliciesPath && (typeof customPoliciesPath === "string" || customPoliciesPath.length > 0)) {
|
|
32616
|
-
const incoming = (typeof customPoliciesPath === "string" ? [customPoliciesPath] : customPoliciesPath).map((path) =>
|
|
32617
|
-
const carried = (previousConfig.customPoliciesPaths ?? (previousConfig.customPoliciesPath ? [previousConfig.customPoliciesPath] : [])).map((path) =>
|
|
32618
|
-
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))
|
|
32619
32991
|
return true;
|
|
32620
32992
|
console.log(`Dropping custom policies path (file no longer exists): ${path}`);
|
|
32621
32993
|
return false;
|
|
@@ -32838,7 +33210,7 @@ async function removeHooks2(policyNames, scope = "user", cwd, opts) {
|
|
|
32838
33210
|
const scopesToRemove = scope === "all" ? [...integration.scopes] : integration.scopes.includes(scope) ? [scope] : [];
|
|
32839
33211
|
for (const s of scopesToRemove) {
|
|
32840
33212
|
const settingsPaths = settingsPathsFor(integration, s, cwd);
|
|
32841
|
-
const existing = settingsPaths.filter((p) =>
|
|
33213
|
+
const existing = settingsPaths.filter((p) => existsSync44(p));
|
|
32842
33214
|
if (existing.length === 0) {
|
|
32843
33215
|
if (scope !== "all" && selectedClis.length === 1) {
|
|
32844
33216
|
console.log("No settings file found. Nothing to remove.");
|
|
@@ -32982,9 +33354,9 @@ async function listHooks(cwd) {
|
|
|
32982
33354
|
if (explicitPaths.length > 0) {
|
|
32983
33355
|
groups.push(rule("Custom Policies", opts));
|
|
32984
33356
|
for (const path of explicitPaths) {
|
|
32985
|
-
const absPath =
|
|
33357
|
+
const absPath = resolve30(findProjectConfigDir(cwd ?? process.cwd()), path);
|
|
32986
33358
|
groups.push(note(absPath, opts));
|
|
32987
|
-
if (!
|
|
33359
|
+
if (!existsSync44(absPath)) {
|
|
32988
33360
|
groups.push(warning([`file not found: ${absPath}`], opts));
|
|
32989
33361
|
continue;
|
|
32990
33362
|
}
|
|
@@ -33004,7 +33376,7 @@ async function listHooks(cwd) {
|
|
|
33004
33376
|
}
|
|
33005
33377
|
}
|
|
33006
33378
|
const base = findProjectConfigDir(cwd ?? process.cwd());
|
|
33007
|
-
const projectDir =
|
|
33379
|
+
const projectDir = resolve30(base, ".failproofai", "policies");
|
|
33008
33380
|
const userDir = customPoliciesDir();
|
|
33009
33381
|
const sameDir = userDir === projectDir;
|
|
33010
33382
|
const conventionDirs = [
|
|
@@ -33029,7 +33401,7 @@ async function listHooks(cwd) {
|
|
|
33029
33401
|
groups.push(note(dir, opts));
|
|
33030
33402
|
const rows = [];
|
|
33031
33403
|
for (const file of files) {
|
|
33032
|
-
const filename =
|
|
33404
|
+
const filename = basename10(file);
|
|
33033
33405
|
try {
|
|
33034
33406
|
const hooks = await loadCustomHooks(file);
|
|
33035
33407
|
record(filename, hooks.map((h) => h.name));
|
|
@@ -33483,14 +33855,14 @@ var init_schedule_cli = __esm(() => {
|
|
|
33483
33855
|
});
|
|
33484
33856
|
|
|
33485
33857
|
// scripts/parse-script-args.ts
|
|
33486
|
-
import { resolve as
|
|
33858
|
+
import { resolve as resolve31 } from "path";
|
|
33487
33859
|
function parseStringFlag(flagName, errorLabel, inlineValue, args, index, options) {
|
|
33488
33860
|
const raw = inlineValue ?? args[index + 1];
|
|
33489
33861
|
if (raw === undefined || inlineValue === null && raw.startsWith("-")) {
|
|
33490
33862
|
console.error(`Error: ${flagName} requires ${errorLabel}`);
|
|
33491
33863
|
process.exit(1);
|
|
33492
33864
|
}
|
|
33493
|
-
const value = options?.resolve ?
|
|
33865
|
+
const value = options?.resolve ? resolve31(raw) : raw;
|
|
33494
33866
|
return { value, spliceCount: inlineValue !== null ? 1 : 2 };
|
|
33495
33867
|
}
|
|
33496
33868
|
function parseScriptArgs(argv) {
|
|
@@ -33546,26 +33918,26 @@ function parseScriptArgs(argv) {
|
|
|
33546
33918
|
var init_parse_script_args = () => {};
|
|
33547
33919
|
|
|
33548
33920
|
// scripts/install-diagnosis.mjs
|
|
33549
|
-
import { existsSync as
|
|
33550
|
-
import { dirname as
|
|
33551
|
-
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";
|
|
33552
33924
|
import { spawnSync } from "node:child_process";
|
|
33553
33925
|
function findPackageRoot(start) {
|
|
33554
33926
|
try {
|
|
33555
33927
|
let dir = realpathSync4(start);
|
|
33556
|
-
if (
|
|
33557
|
-
dir =
|
|
33928
|
+
if (existsSync45(dir) && !existsSync45(resolve32(dir, "package.json"))) {
|
|
33929
|
+
dir = dirname22(dir);
|
|
33558
33930
|
}
|
|
33559
33931
|
while (true) {
|
|
33560
|
-
const pkgPath =
|
|
33561
|
-
if (
|
|
33932
|
+
const pkgPath = resolve32(dir, "package.json");
|
|
33933
|
+
if (existsSync45(pkgPath)) {
|
|
33562
33934
|
try {
|
|
33563
33935
|
const pkg = JSON.parse(readFileSync36(pkgPath, "utf8"));
|
|
33564
33936
|
if (pkg.name === PKG_NAME)
|
|
33565
33937
|
return dir;
|
|
33566
33938
|
} catch {}
|
|
33567
33939
|
}
|
|
33568
|
-
const parent =
|
|
33940
|
+
const parent = dirname22(dir);
|
|
33569
33941
|
if (parent === dir)
|
|
33570
33942
|
return null;
|
|
33571
33943
|
dir = parent;
|
|
@@ -33578,7 +33950,7 @@ function readPackageVersion(packageRoot) {
|
|
|
33578
33950
|
if (!packageRoot)
|
|
33579
33951
|
return null;
|
|
33580
33952
|
try {
|
|
33581
|
-
const pkg = JSON.parse(readFileSync36(
|
|
33953
|
+
const pkg = JSON.parse(readFileSync36(resolve32(packageRoot, "package.json"), "utf8"));
|
|
33582
33954
|
return typeof pkg.version === "string" ? pkg.version : null;
|
|
33583
33955
|
} catch {
|
|
33584
33956
|
return null;
|
|
@@ -33604,16 +33976,16 @@ function locateNpmGlobal() {
|
|
|
33604
33976
|
const root = (res.stdout || "").trim();
|
|
33605
33977
|
if (!root)
|
|
33606
33978
|
return null;
|
|
33607
|
-
const candidate =
|
|
33608
|
-
return
|
|
33979
|
+
const candidate = resolve32(root, PKG_NAME);
|
|
33980
|
+
return existsSync45(resolve32(candidate, "package.json")) ? candidate : null;
|
|
33609
33981
|
} catch {
|
|
33610
33982
|
return null;
|
|
33611
33983
|
}
|
|
33612
33984
|
}
|
|
33613
33985
|
function locateBunGlobal() {
|
|
33614
33986
|
try {
|
|
33615
|
-
const candidate =
|
|
33616
|
-
return
|
|
33987
|
+
const candidate = resolve32(homedir32(), ".bun", "install", "global", "node_modules", PKG_NAME);
|
|
33988
|
+
return existsSync45(resolve32(candidate, "package.json")) ? candidate : null;
|
|
33617
33989
|
} catch {
|
|
33618
33990
|
return null;
|
|
33619
33991
|
}
|
|
@@ -33621,8 +33993,8 @@ function locateBunGlobal() {
|
|
|
33621
33993
|
function buildRecommendation(pathFirstBin) {
|
|
33622
33994
|
if (!pathFirstBin)
|
|
33623
33995
|
return null;
|
|
33624
|
-
const bunBinPrefix =
|
|
33625
|
-
const bunGlobalPrefix =
|
|
33996
|
+
const bunBinPrefix = resolve32(homedir32(), ".bun", "bin") + "/";
|
|
33997
|
+
const bunGlobalPrefix = resolve32(homedir32(), ".bun", "install", "global") + "/";
|
|
33626
33998
|
const isBun = pathFirstBin.startsWith(bunBinPrefix) || pathFirstBin.startsWith(bunGlobalPrefix);
|
|
33627
33999
|
if (isBun) {
|
|
33628
34000
|
return `rm -f ~/.bun/bin/${PKG_NAME} && rm -rf ~/.bun/install/global/node_modules/${PKG_NAME}`;
|
|
@@ -33716,8 +34088,8 @@ var init_dashboard_host = __esm(() => {
|
|
|
33716
34088
|
|
|
33717
34089
|
// scripts/launch.ts
|
|
33718
34090
|
import { spawn as spawn2 } from "child_process";
|
|
33719
|
-
import { realpathSync as realpathSync5, existsSync as
|
|
33720
|
-
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";
|
|
33721
34093
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
33722
34094
|
import { createInterface } from "node:readline";
|
|
33723
34095
|
function launch(mode) {
|
|
@@ -33741,9 +34113,9 @@ function launch(mode) {
|
|
|
33741
34113
|
process.env.PORT = port;
|
|
33742
34114
|
process.env.HOSTNAME = bindHost;
|
|
33743
34115
|
cmd = "node";
|
|
33744
|
-
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ??
|
|
33745
|
-
const serverJsPath =
|
|
33746
|
-
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)) {
|
|
33747
34119
|
let shadowMessage = null;
|
|
33748
34120
|
try {
|
|
33749
34121
|
const diag = diagnoseShadow({ selfPackageRoot: packageRoot, selfVersion: version2 });
|
|
@@ -34498,8 +34870,8 @@ var init_session_pause_cli = __esm(() => {
|
|
|
34498
34870
|
|
|
34499
34871
|
// scripts/launch.ts
|
|
34500
34872
|
import { spawn as spawn3 } from "child_process";
|
|
34501
|
-
import { realpathSync as realpathSync6, existsSync as
|
|
34502
|
-
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";
|
|
34503
34875
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
34504
34876
|
import { createInterface as createInterface2 } from "node:readline";
|
|
34505
34877
|
function launch2(mode) {
|
|
@@ -34523,9 +34895,9 @@ function launch2(mode) {
|
|
|
34523
34895
|
process.env.PORT = port;
|
|
34524
34896
|
process.env.HOSTNAME = bindHost;
|
|
34525
34897
|
cmd = "node";
|
|
34526
|
-
const packageRoot = process.env.FAILPROOFAI_PACKAGE_ROOT ??
|
|
34527
|
-
const serverJsPath =
|
|
34528
|
-
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)) {
|
|
34529
34901
|
let shadowMessage = null;
|
|
34530
34902
|
try {
|
|
34531
34903
|
const diag = diagnoseShadow({ selfPackageRoot: packageRoot, selfVersion: version2 });
|
|
@@ -34622,17 +34994,17 @@ var init_cli_error2 = __esm(() => {
|
|
|
34622
34994
|
|
|
34623
34995
|
// bin/failproofai.mjs
|
|
34624
34996
|
import { realpathSync as realpathSync7 } from "fs";
|
|
34625
|
-
import { dirname as
|
|
34997
|
+
import { dirname as dirname25, resolve as resolve35 } from "path";
|
|
34626
34998
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
34627
34999
|
// package.json
|
|
34628
|
-
var version = "1.0.5-beta.
|
|
35000
|
+
var version = "1.0.5-beta.2";
|
|
34629
35001
|
|
|
34630
35002
|
// bin/failproofai.mjs
|
|
34631
35003
|
if (!process.env.FAILPROOFAI_PACKAGE_ROOT) {
|
|
34632
|
-
process.env.FAILPROOFAI_PACKAGE_ROOT =
|
|
35004
|
+
process.env.FAILPROOFAI_PACKAGE_ROOT = resolve35(dirname25(realpathSync7(fileURLToPath4(import.meta.url))), "..");
|
|
34633
35005
|
}
|
|
34634
35006
|
if (!process.env.FAILPROOFAI_DIST_PATH) {
|
|
34635
|
-
process.env.FAILPROOFAI_DIST_PATH =
|
|
35007
|
+
process.env.FAILPROOFAI_DIST_PATH = resolve35(dirname25(realpathSync7(fileURLToPath4(import.meta.url))), "..", "dist");
|
|
34636
35008
|
}
|
|
34637
35009
|
var args = process.argv.slice(2);
|
|
34638
35010
|
if (args[0] === "p" || args[0] === "policy")
|