failproofai 1.0.4-beta.4 → 1.0.4-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js +2 -2
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js +2 -2
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +14 -14
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +5 -5
- package/.next/standalone/.next/server/app/audit/page.js +3 -3
- package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +14 -14
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +13 -13
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +14 -14
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js +2 -2
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
- package/.next/standalone/.next/server/app/policies/page.js +4 -4
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js +3 -3
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +4 -4
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js +3 -3
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +4 -4
- package/.next/standalone/.next/server/app/settings/page.js +2 -2
- package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0--lkk6._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0q0qzx1._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__0rv7m0k._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__17g9wh7._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1le9jqc._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1legmza._.js +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1p-qi2t._.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/_1ek68ln._.js +4 -4
- package/.next/standalone/.next/server/chunks/lib_factory-projects_ts_1eo_bk-._.js +1 -1
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0p-5p8u._.js → [root-of-the-server]__0-4ja6q._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1p2otjt._.js → [root-of-the-server]__00cr3xu._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__013jr2b._.js → [root-of-the-server]__04px77e._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__190won8._.js → [root-of-the-server]__0dxf928._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0s740oi._.js → [root-of-the-server]__0egr5s1._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__01wy8d-._.js → [root-of-the-server]__0i0l1di._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0n_lxhg._.js → [root-of-the-server]__0kokc8z._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1ctpynv._.js → [root-of-the-server]__0n2txhk._.js} +1 -1
- 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]__02npjtd._.js → [root-of-the-server]__0r3c1_0._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0ftmoxc._.js → [root-of-the-server]__17xnxlx._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0da85px._.js → [root-of-the-server]__1ckpmkk._.js} +3 -3
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__00-s7h8._.js → [root-of-the-server]__1fvfw59._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0yl9wb5._.js → [root-of-the-server]__1ui5ur8._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/{_0guxnh-._.js → _02b3i98._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_04ng_6x._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/{_1u8-lu2._.js → _07t3jol._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_0h_douw._.js → _0s-77v5._.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1ddpc5g._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_1es2j7i._.js +4 -14
- 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/src_hooks_fp-home_ts_0je3xkv._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +22 -22
- package/.next/standalone/.next/static/chunks/{364cqbpeg1y5i.js → 07c6l1lq5_69b.js} +1 -1
- package/.next/standalone/.next/static/chunks/{2bxr2_2h4kaqq.js → 12bsgz8czvcnn.js} +1 -1
- package/.next/standalone/.next/static/chunks/{38dqur43qthrl.js → 1gn08w2pgqh09.js} +1 -1
- package/.next/standalone/.next/static/chunks/{1i-i0pxg9q_8y.js → 1xgq22tri86an.js} +1 -1
- package/.next/standalone/.next/static/chunks/{17tfki9x5rd_7.js → 20xkiqzvfkuvm.js} +1 -1
- package/.next/standalone/.next/static/chunks/{42gwu2bsz4ske.js → 2a84ug32tzik2.js} +2 -2
- package/.next/standalone/.next/static/chunks/{0po8n4tyotjf2.js → 32m2ryfankf_2.js} +1 -1
- package/.next/standalone/.next/static/chunks/3ioub_lpen-sq.js +1 -0
- package/.next/standalone/.next/static/chunks/{323cyb3a2s06y.js → 3jxd133cw2vm3.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0qx7gav1c2_vu.js → 44ncu88eq6z71.js} +1 -1
- package/.next/standalone/app/actions/get-leaks.ts +0 -5
- package/.next/standalone/app/actions/update-scheduled-audit.ts +4 -56
- package/.next/standalone/app/api/auth/status/route.ts +3 -2
- package/.next/standalone/app/settings/page.tsx +1 -1
- package/.next/standalone/app/settings/settings-client.tsx +13 -39
- package/.next/standalone/lib/auth/api-server-client.ts +6 -6
- package/.next/standalone/lib/codex-sessions.ts +20 -4
- package/.next/standalone/lib/copilot-sessions.ts +32 -1
- package/.next/standalone/lib/cursor-sessions.ts +62 -5
- package/.next/standalone/package.json +9 -9
- package/.next/standalone/server.js +1 -1
- package/dist/cli.mjs +952 -1063
- package/dist/worker.mjs +173 -380
- package/lib/auth/api-server-client.ts +6 -6
- package/lib/codex-sessions.ts +20 -4
- package/lib/copilot-sessions.ts +32 -1
- package/lib/cursor-sessions.ts +62 -5
- package/package.json +9 -9
- package/pi-extension/index.ts +10 -18
- package/src/audit/cli.ts +72 -81
- package/src/audit/harm-report.ts +12 -6
- package/src/audit/index.ts +2 -0
- package/src/audit/leak-fingerprint.ts +2 -4
- package/src/audit/leak-record.ts +13 -9
- package/src/audit/leak-scan.ts +1 -1
- package/src/audit/leak-store.ts +1 -46
- package/src/audit/machine-store.ts +8 -9
- package/src/audit/macos-notifier.ts +2 -2
- package/src/audit/redact-example.ts +2 -0
- package/src/audit/report-harm.ts +31 -46
- package/src/audit/schedule-cli.ts +17 -33
- package/src/audit/types.ts +5 -0
- package/src/hooks/configure-wizard.ts +28 -0
- package/src/hooks/fp-config.ts +29 -54
- package/src/hooks/handler.ts +1 -79
- package/src/hooks/integrations.ts +4 -15
- package/src/hooks/notice.ts +12 -179
- package/.next/standalone/.next/server/chunks/ssr/_0oq1dh6._.js +0 -3
- package/.next/standalone/.next/static/chunks/04o5zfl7p5lhx.js +0 -1
- package/src/audit/leak-notice.ts +0 -259
- /package/.next/standalone/.next/static/{P6icI2V2PvVuePJrqjHCr → aeM365dNTtUZOZvNkX8ba}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{P6icI2V2PvVuePJrqjHCr → aeM365dNTtUZOZvNkX8ba}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{P6icI2V2PvVuePJrqjHCr → aeM365dNTtUZOZvNkX8ba}/_ssgManifest.js +0 -0
package/dist/worker.mjs
CHANGED
|
@@ -378,7 +378,7 @@ function failproofaiHome(home) {
|
|
|
378
378
|
return resolve(home, ".failproofai");
|
|
379
379
|
return process.env.FAILPROOFAI_HOME || resolve(homedir(), ".failproofai");
|
|
380
380
|
}
|
|
381
|
-
var LAYOUT_VERSION = 4, at = (...parts) => resolve(failproofaiHome(), ...parts), atHome = (home, ...parts) => home ? resolve(failproofaiHome(home), ...parts) : at(...parts), versionFile = (home) => atHome(home, "VERSION"), configFile = (home) => atHome(home, "config.json"), policiesDir = (home) => atHome(home, "policies"), customPoliciesDir, globalPolicyConfigFile = (home) => atHome(home, "policies-config.json"), cloudPoliciesDir = (home) => resolve(policiesDir(home), "cloud-policies"), packsDir = (home) => resolve(policiesDir(home), "packs"), packsInstalledFile = (home) => resolve(packsDir(home), "installed.json"),
|
|
381
|
+
var LAYOUT_VERSION = 4, at = (...parts) => resolve(failproofaiHome(), ...parts), atHome = (home, ...parts) => home ? resolve(failproofaiHome(home), ...parts) : at(...parts), versionFile = (home) => atHome(home, "VERSION"), configFile = (home) => atHome(home, "config.json"), policiesDir = (home) => atHome(home, "policies"), customPoliciesDir, globalPolicyConfigFile = (home) => atHome(home, "policies-config.json"), cloudPoliciesDir = (home) => resolve(policiesDir(home), "cloud-policies"), packsDir = (home) => resolve(policiesDir(home), "packs"), packsInstalledFile = (home) => resolve(packsDir(home), "installed.json"), hookActivityDir = (home) => atHome(home, "hook-activity"), stateDir = (home) => atHome(home, "state"), shimsDir = (home) => resolve(stateDir(home), "shims"), sessionPauseDir = () => resolve(stateDir(), "sessions"), telemetryIdFile = (home) => resolve(stateDir(home), "telemetry-id"), codexSessionPathsFile = (home) => resolve(stateDir(home), "codex-session-paths.json"), logsDir = (home) => atHome(home, "logs"), legacy;
|
|
382
382
|
var init_fp_home = __esm(() => {
|
|
383
383
|
customPoliciesDir = policiesDir;
|
|
384
384
|
legacy = {
|
|
@@ -3507,7 +3507,7 @@ function parsePackPolicyName(canonicalName) {
|
|
|
3507
3507
|
}
|
|
3508
3508
|
|
|
3509
3509
|
// package.json
|
|
3510
|
-
var version = "1.0.4-beta.
|
|
3510
|
+
var version = "1.0.4-beta.6";
|
|
3511
3511
|
var init_package = () => {};
|
|
3512
3512
|
|
|
3513
3513
|
// src/posthog-key.ts
|
|
@@ -5211,260 +5211,6 @@ var init_delivery_health = __esm(() => {
|
|
|
5211
5211
|
CREDENTIAL_STATUSES = new Set([401, 403]);
|
|
5212
5212
|
});
|
|
5213
5213
|
|
|
5214
|
-
// src/hooks/notice.ts
|
|
5215
|
-
function shapeNotice(cli, notice, existingStdout = "") {
|
|
5216
|
-
const empty = { stdout: existingStdout, stderr: "" };
|
|
5217
|
-
if (!notice.trim() || !cli)
|
|
5218
|
-
return empty;
|
|
5219
|
-
const channel = NOTICE_CHANNEL[cli] ?? "none";
|
|
5220
|
-
const text = notice.length > MAX_NOTICE_CHARS ? notice.slice(0, MAX_NOTICE_CHARS - 1) + "…" : notice;
|
|
5221
|
-
switch (channel) {
|
|
5222
|
-
case "systemMessage": {
|
|
5223
|
-
if (existingStdout.trim().startsWith("{")) {
|
|
5224
|
-
try {
|
|
5225
|
-
const parsed = JSON.parse(existingStdout);
|
|
5226
|
-
parsed.systemMessage = text;
|
|
5227
|
-
return { stdout: JSON.stringify(parsed), stderr: "" };
|
|
5228
|
-
} catch {
|
|
5229
|
-
return empty;
|
|
5230
|
-
}
|
|
5231
|
-
}
|
|
5232
|
-
if (existingStdout.trim())
|
|
5233
|
-
return empty;
|
|
5234
|
-
return { stdout: JSON.stringify({ systemMessage: text }), stderr: "" };
|
|
5235
|
-
}
|
|
5236
|
-
case "stderr":
|
|
5237
|
-
return { stdout: existingStdout, stderr: text + `
|
|
5238
|
-
` };
|
|
5239
|
-
case "stdout":
|
|
5240
|
-
if (existingStdout.trim())
|
|
5241
|
-
return empty;
|
|
5242
|
-
return { stdout: text + `
|
|
5243
|
-
`, stderr: "" };
|
|
5244
|
-
case "shim": {
|
|
5245
|
-
if (existingStdout.trim().startsWith("{")) {
|
|
5246
|
-
try {
|
|
5247
|
-
const parsed = JSON.parse(existingStdout);
|
|
5248
|
-
parsed.failproofaiNotice = text;
|
|
5249
|
-
return { stdout: JSON.stringify(parsed), stderr: "" };
|
|
5250
|
-
} catch {
|
|
5251
|
-
return empty;
|
|
5252
|
-
}
|
|
5253
|
-
}
|
|
5254
|
-
if (existingStdout.trim())
|
|
5255
|
-
return empty;
|
|
5256
|
-
return { stdout: JSON.stringify({ failproofaiNotice: text }), stderr: "" };
|
|
5257
|
-
}
|
|
5258
|
-
default:
|
|
5259
|
-
return empty;
|
|
5260
|
-
}
|
|
5261
|
-
}
|
|
5262
|
-
function canDeliverNotice(cli) {
|
|
5263
|
-
return !!cli && (NOTICE_CHANNEL[cli] ?? "none") !== "none";
|
|
5264
|
-
}
|
|
5265
|
-
function leakNoticeText(newFindings) {
|
|
5266
|
-
const n = newFindings === 1 ? "a possible credential exposure" : `${newFindings} possible credential exposures`;
|
|
5267
|
-
return `failproofai found ${n} in this project's agent transcripts.
|
|
5268
|
-
` + "Run `failproofai audit` to review the matches and rotate anything real.";
|
|
5269
|
-
}
|
|
5270
|
-
var NOTICE_CHANNEL, MAX_NOTICE_CHARS = 900;
|
|
5271
|
-
var init_notice = __esm(() => {
|
|
5272
|
-
NOTICE_CHANNEL = {
|
|
5273
|
-
claude: "systemMessage",
|
|
5274
|
-
codex: "systemMessage",
|
|
5275
|
-
copilot: "stderr",
|
|
5276
|
-
factory: "stdout",
|
|
5277
|
-
opencode: "shim",
|
|
5278
|
-
pi: "shim"
|
|
5279
|
-
};
|
|
5280
|
-
});
|
|
5281
|
-
|
|
5282
|
-
// lib/atomic-write.ts
|
|
5283
|
-
import {
|
|
5284
|
-
chmodSync as chmodSync2,
|
|
5285
|
-
existsSync as existsSync8,
|
|
5286
|
-
mkdirSync as mkdirSync5,
|
|
5287
|
-
renameSync as renameSync3,
|
|
5288
|
-
rmSync as rmSync2,
|
|
5289
|
-
statSync as statSync6,
|
|
5290
|
-
writeFileSync as writeFileSync4
|
|
5291
|
-
} from "node:fs";
|
|
5292
|
-
import { dirname as dirname3 } from "node:path";
|
|
5293
|
-
import { randomBytes } from "node:crypto";
|
|
5294
|
-
function writeJsonAtomically(filePath, value, opts = {}) {
|
|
5295
|
-
const mode = opts.mode ?? 384;
|
|
5296
|
-
const dirMode = opts.dirMode ?? 448;
|
|
5297
|
-
const dir = dirname3(filePath);
|
|
5298
|
-
if (!existsSync8(dir))
|
|
5299
|
-
mkdirSync5(dir, { recursive: true, mode: dirMode });
|
|
5300
|
-
const tmp = `${filePath}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`;
|
|
5301
|
-
try {
|
|
5302
|
-
writeFileSync4(tmp, JSON.stringify(value, null, 2), { mode });
|
|
5303
|
-
try {
|
|
5304
|
-
if ((statSync6(tmp).mode & 63) !== 0)
|
|
5305
|
-
chmodSync2(tmp, mode);
|
|
5306
|
-
} catch {}
|
|
5307
|
-
renameSync3(tmp, filePath);
|
|
5308
|
-
try {
|
|
5309
|
-
if ((statSync6(filePath).mode & 63) !== 0)
|
|
5310
|
-
chmodSync2(filePath, mode);
|
|
5311
|
-
} catch {}
|
|
5312
|
-
} catch (err) {
|
|
5313
|
-
try {
|
|
5314
|
-
rmSync2(tmp, { force: true });
|
|
5315
|
-
} catch {}
|
|
5316
|
-
throw err;
|
|
5317
|
-
}
|
|
5318
|
-
}
|
|
5319
|
-
var init_atomic_write = () => {};
|
|
5320
|
-
|
|
5321
|
-
// src/audit/leak-record.ts
|
|
5322
|
-
function emptyRecord(salt, nowIso) {
|
|
5323
|
-
return {
|
|
5324
|
-
schemaVersion: LEAK_RECORD_SCHEMA_VERSION,
|
|
5325
|
-
salt,
|
|
5326
|
-
updatedAt: nowIso,
|
|
5327
|
-
findings: []
|
|
5328
|
-
};
|
|
5329
|
-
}
|
|
5330
|
-
var LEAK_RECORD_SCHEMA_VERSION = 1;
|
|
5331
|
-
|
|
5332
|
-
// src/audit/leak-fingerprint.ts
|
|
5333
|
-
function isFindingId(id) {
|
|
5334
|
-
return /^[0-9a-f]{16}$/.test(id);
|
|
5335
|
-
}
|
|
5336
|
-
var init_leak_fingerprint = () => {};
|
|
5337
|
-
|
|
5338
|
-
// src/audit/leak-store.ts
|
|
5339
|
-
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
5340
|
-
import { existsSync as existsSync9, mkdirSync as mkdirSync6, readFileSync as readFileSync6 } from "node:fs";
|
|
5341
|
-
import { dirname as dirname4 } from "node:path";
|
|
5342
|
-
function readJson(path) {
|
|
5343
|
-
try {
|
|
5344
|
-
if (!existsSync9(path))
|
|
5345
|
-
return null;
|
|
5346
|
-
return JSON.parse(readFileSync6(path, "utf8"));
|
|
5347
|
-
} catch {
|
|
5348
|
-
return null;
|
|
5349
|
-
}
|
|
5350
|
-
}
|
|
5351
|
-
function readLeakIdentity(home) {
|
|
5352
|
-
const existing = readJson(auditLeakIdentityFile(home));
|
|
5353
|
-
if (existing && typeof existing.salt === "string" && existing.salt.length >= 32) {
|
|
5354
|
-
return {
|
|
5355
|
-
salt: existing.salt,
|
|
5356
|
-
dismissed: existing.dismissed ?? [],
|
|
5357
|
-
reportViewedAt: typeof existing.reportViewedAt === "number" && Number.isFinite(existing.reportViewedAt) ? existing.reportViewedAt : undefined
|
|
5358
|
-
};
|
|
5359
|
-
}
|
|
5360
|
-
const minted = { salt: randomBytes2(32).toString("hex"), dismissed: [] };
|
|
5361
|
-
writeLeakIdentity(minted, home);
|
|
5362
|
-
return minted;
|
|
5363
|
-
}
|
|
5364
|
-
function writeLeakIdentity(identity, home) {
|
|
5365
|
-
const path = auditLeakIdentityFile(home);
|
|
5366
|
-
try {
|
|
5367
|
-
mkdirSync6(dirname4(path), { recursive: true });
|
|
5368
|
-
writeJsonAtomically(path, identity, { mode: FILE_MODE });
|
|
5369
|
-
return true;
|
|
5370
|
-
} catch {
|
|
5371
|
-
return false;
|
|
5372
|
-
}
|
|
5373
|
-
}
|
|
5374
|
-
function sanitizeFinding(raw) {
|
|
5375
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
5376
|
-
return null;
|
|
5377
|
-
const f = raw;
|
|
5378
|
-
if (typeof f.id !== "string" || !isFindingId(f.id))
|
|
5379
|
-
return null;
|
|
5380
|
-
const fp = f.fingerprint;
|
|
5381
|
-
if (!fp || typeof fp !== "object" || typeof fp.display !== "string" || typeof fp.label !== "string") {
|
|
5382
|
-
return null;
|
|
5383
|
-
}
|
|
5384
|
-
const sightings = Array.isArray(f.sightings) ? f.sightings.filter((s) => {
|
|
5385
|
-
if (!s || typeof s !== "object")
|
|
5386
|
-
return false;
|
|
5387
|
-
const m = s.mechanism;
|
|
5388
|
-
return !!m && typeof m === "object" && typeof m.summary === "string";
|
|
5389
|
-
}) : [];
|
|
5390
|
-
return {
|
|
5391
|
-
...f,
|
|
5392
|
-
fingerprint: {
|
|
5393
|
-
display: fp.display,
|
|
5394
|
-
label: fp.label,
|
|
5395
|
-
length: typeof fp.length === "number" && Number.isFinite(fp.length) ? fp.length : 0,
|
|
5396
|
-
attributed: fp.attributed === true
|
|
5397
|
-
},
|
|
5398
|
-
name: typeof f.name === "string" ? f.name : null,
|
|
5399
|
-
firstSeen: typeof f.firstSeen === "string" ? f.firstSeen : "",
|
|
5400
|
-
lastSeen: typeof f.lastSeen === "string" ? f.lastSeen : "",
|
|
5401
|
-
occurrences: typeof f.occurrences === "number" && Number.isFinite(f.occurrences) ? f.occurrences : sightings.length,
|
|
5402
|
-
sightings
|
|
5403
|
-
};
|
|
5404
|
-
}
|
|
5405
|
-
function readLeakRecord(home) {
|
|
5406
|
-
const identity = readLeakIdentity(home);
|
|
5407
|
-
const raw = readJson(auditLeaksFile(home));
|
|
5408
|
-
if (!raw || raw.schemaVersion !== LEAK_RECORD_SCHEMA_VERSION || !Array.isArray(raw.findings)) {
|
|
5409
|
-
return emptyRecord(identity.salt, new Date().toISOString());
|
|
5410
|
-
}
|
|
5411
|
-
const findings = raw.findings.map(sanitizeFinding).filter((f) => f !== null);
|
|
5412
|
-
return { ...raw, findings, salt: identity.salt };
|
|
5413
|
-
}
|
|
5414
|
-
function activeFindings(record, home) {
|
|
5415
|
-
const dismissed = new Set(readLeakIdentity(home).dismissed);
|
|
5416
|
-
return record.findings.filter((f) => !dismissed.has(f.id)).sort((a, b) => a.lastSeen < b.lastSeen ? 1 : a.lastSeen > b.lastSeen ? -1 : 0);
|
|
5417
|
-
}
|
|
5418
|
-
var FILE_MODE = 384;
|
|
5419
|
-
var init_leak_store = __esm(() => {
|
|
5420
|
-
init_fp_home();
|
|
5421
|
-
init_atomic_write();
|
|
5422
|
-
init_leak_fingerprint();
|
|
5423
|
-
});
|
|
5424
|
-
|
|
5425
|
-
// src/audit/leak-notice.ts
|
|
5426
|
-
import { existsSync as existsSync10, mkdirSync as mkdirSync7, readdirSync as readdirSync3, statSync as statSync7, writeFileSync as writeFileSync5, rmSync as rmSync3 } from "node:fs";
|
|
5427
|
-
import { resolve as resolve8 } from "node:path";
|
|
5428
|
-
function sessionNoticePending(sessionId, home) {
|
|
5429
|
-
try {
|
|
5430
|
-
if (!sessionId || !/^[\w.:-]{1,200}$/.test(sessionId))
|
|
5431
|
-
return { ids: [], count: 0 };
|
|
5432
|
-
const dir = resolve8(auditDir(home), "notified-sessions");
|
|
5433
|
-
if (existsSync10(resolve8(dir, sessionId)))
|
|
5434
|
-
return { ids: [], count: 0 };
|
|
5435
|
-
const findings = activeFindings(readLeakRecord(home), home);
|
|
5436
|
-
if (findings.length === 0)
|
|
5437
|
-
return { ids: [], count: 0 };
|
|
5438
|
-
const viewedAt = readLeakIdentity(home).reportViewedAt ?? 0;
|
|
5439
|
-
const unviewed = findings.filter((f) => {
|
|
5440
|
-
const seen = Date.parse(f.firstSeen);
|
|
5441
|
-
return !Number.isFinite(seen) || seen > viewedAt;
|
|
5442
|
-
});
|
|
5443
|
-
return { ids: unviewed.map((f) => f.id), count: unviewed.length };
|
|
5444
|
-
} catch {
|
|
5445
|
-
return { ids: [], count: 0 };
|
|
5446
|
-
}
|
|
5447
|
-
}
|
|
5448
|
-
function markSessionNoticed(sessionId, home) {
|
|
5449
|
-
try {
|
|
5450
|
-
if (!sessionId || !/^[\w.:-]{1,200}$/.test(sessionId))
|
|
5451
|
-
return false;
|
|
5452
|
-
const dir = resolve8(auditDir(home), "notified-sessions");
|
|
5453
|
-
mkdirSync7(dir, { recursive: true });
|
|
5454
|
-
writeFileSync5(resolve8(dir, sessionId), "", { flag: "wx", mode: 384 });
|
|
5455
|
-
return true;
|
|
5456
|
-
} catch {
|
|
5457
|
-
return false;
|
|
5458
|
-
}
|
|
5459
|
-
}
|
|
5460
|
-
var MARKER_TTL_MS;
|
|
5461
|
-
var init_leak_notice = __esm(() => {
|
|
5462
|
-
init_fp_home();
|
|
5463
|
-
init_leak_store();
|
|
5464
|
-
init_leak_fingerprint();
|
|
5465
|
-
MARKER_TTL_MS = 120 * 86400000;
|
|
5466
|
-
});
|
|
5467
|
-
|
|
5468
5214
|
// src/hooks/resolve-cwd.ts
|
|
5469
5215
|
function resolveCwd(integration, parsed) {
|
|
5470
5216
|
const direct = typeof parsed.cwd === "string" && parsed.cwd.length > 0 ? parsed.cwd : undefined;
|
|
@@ -6154,7 +5900,7 @@ var init_cursor_projects = __esm(() => {
|
|
|
6154
5900
|
});
|
|
6155
5901
|
|
|
6156
5902
|
// lib/sqlite-reader.ts
|
|
6157
|
-
import { existsSync as
|
|
5903
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6 } from "node:fs";
|
|
6158
5904
|
import initSqlJs from "sql.js/dist/sql-asm.js";
|
|
6159
5905
|
function silenceSqliteExperimentalWarning() {
|
|
6160
5906
|
if (warningPatched)
|
|
@@ -6205,7 +5951,7 @@ function clearWalFlag(bytes) {
|
|
|
6205
5951
|
async function trySqlJs(dbPath) {
|
|
6206
5952
|
try {
|
|
6207
5953
|
const SQL = await loadSqlJs();
|
|
6208
|
-
const db = new SQL.Database(clearWalFlag(
|
|
5954
|
+
const db = new SQL.Database(clearWalFlag(readFileSync6(dbPath)));
|
|
6209
5955
|
return {
|
|
6210
5956
|
query(sql, params) {
|
|
6211
5957
|
const stmt = db.prepare(sql);
|
|
@@ -6229,7 +5975,7 @@ async function trySqlJs(dbPath) {
|
|
|
6229
5975
|
}
|
|
6230
5976
|
}
|
|
6231
5977
|
async function openSqliteReadonly(dbPath) {
|
|
6232
|
-
if (!
|
|
5978
|
+
if (!existsSync8(dbPath))
|
|
6233
5979
|
return null;
|
|
6234
5980
|
return await tryNodeSqlite(dbPath) ?? await trySqlJs(dbPath);
|
|
6235
5981
|
}
|
|
@@ -6564,16 +6310,16 @@ var init_pi_projects = __esm(() => {
|
|
|
6564
6310
|
});
|
|
6565
6311
|
|
|
6566
6312
|
// lib/hermes-profiles.ts
|
|
6567
|
-
import { readdirSync as
|
|
6313
|
+
import { readdirSync as readdirSync3 } from "node:fs";
|
|
6568
6314
|
import { homedir as homedir10 } from "node:os";
|
|
6569
|
-
import { basename as basename2, dirname as
|
|
6315
|
+
import { basename as basename2, dirname as dirname3, join as join11, resolve as resolve8 } from "node:path";
|
|
6570
6316
|
function hermesRoot() {
|
|
6571
6317
|
const env = (process.env.HERMES_HOME || "").trim();
|
|
6572
6318
|
if (env) {
|
|
6573
|
-
const home =
|
|
6574
|
-
const parent =
|
|
6319
|
+
const home = resolve8(env);
|
|
6320
|
+
const parent = dirname3(home);
|
|
6575
6321
|
if (basename2(parent) === PROFILES_DIR)
|
|
6576
|
-
return
|
|
6322
|
+
return dirname3(parent);
|
|
6577
6323
|
return home;
|
|
6578
6324
|
}
|
|
6579
6325
|
return join11(homedir10(), ".hermes");
|
|
@@ -6584,7 +6330,7 @@ function listHermesProfiles() {
|
|
|
6584
6330
|
const seen = new Set([HERMES_DEFAULT_PROFILE]);
|
|
6585
6331
|
let names;
|
|
6586
6332
|
try {
|
|
6587
|
-
names =
|
|
6333
|
+
names = readdirSync3(join11(root, PROFILES_DIR), { withFileTypes: true }).filter((e) => (e.isDirectory() || e.isSymbolicLink()) && !e.name.startsWith(".")).map((e) => e.name).sort();
|
|
6588
6334
|
} catch {
|
|
6589
6335
|
return out;
|
|
6590
6336
|
}
|
|
@@ -6942,7 +6688,7 @@ var init_hermes_projects = __esm(() => {
|
|
|
6942
6688
|
|
|
6943
6689
|
// lib/openclaw-sessions.ts
|
|
6944
6690
|
import { readFile as readFile7 } from "node:fs/promises";
|
|
6945
|
-
import { readdirSync as
|
|
6691
|
+
import { readdirSync as readdirSync4, statSync as statSync6 } from "node:fs";
|
|
6946
6692
|
import { homedir as homedir11 } from "node:os";
|
|
6947
6693
|
import { join as join13 } from "node:path";
|
|
6948
6694
|
function openclawHome() {
|
|
@@ -7061,7 +6807,7 @@ function openclawLinesToLogEntries(lines, source = "session") {
|
|
|
7061
6807
|
}
|
|
7062
6808
|
function listOpenClawAgents() {
|
|
7063
6809
|
try {
|
|
7064
|
-
return
|
|
6810
|
+
return readdirSync4(join13(openclawHome(), "agents"), { withFileTypes: true }).filter((d) => d.isDirectory() && !d.name.startsWith(".")).map((d) => d.name).sort();
|
|
7065
6811
|
} catch {
|
|
7066
6812
|
return [];
|
|
7067
6813
|
}
|
|
@@ -7071,7 +6817,7 @@ function listOpenClawTranscripts() {
|
|
|
7071
6817
|
const out = [];
|
|
7072
6818
|
let agentIds;
|
|
7073
6819
|
try {
|
|
7074
|
-
agentIds =
|
|
6820
|
+
agentIds = readdirSync4(agentsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
7075
6821
|
} catch {
|
|
7076
6822
|
return out;
|
|
7077
6823
|
}
|
|
@@ -7079,7 +6825,7 @@ function listOpenClawTranscripts() {
|
|
|
7079
6825
|
const sessionsDir = join13(agentsDir, agentId, "sessions");
|
|
7080
6826
|
let files;
|
|
7081
6827
|
try {
|
|
7082
|
-
files =
|
|
6828
|
+
files = readdirSync4(sessionsDir);
|
|
7083
6829
|
} catch {
|
|
7084
6830
|
continue;
|
|
7085
6831
|
}
|
|
@@ -7091,7 +6837,7 @@ function listOpenClawTranscripts() {
|
|
|
7091
6837
|
continue;
|
|
7092
6838
|
const transcriptPath = join13(sessionsDir, file);
|
|
7093
6839
|
try {
|
|
7094
|
-
const st =
|
|
6840
|
+
const st = statSync6(transcriptPath);
|
|
7095
6841
|
out.push({ agentId, sessionId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
|
|
7096
6842
|
} catch {}
|
|
7097
6843
|
}
|
|
@@ -7140,7 +6886,7 @@ var exports_openclaw_projects = {};
|
|
|
7140
6886
|
__export(exports_openclaw_projects, {
|
|
7141
6887
|
getOpenClawProjects: () => getOpenClawProjects
|
|
7142
6888
|
});
|
|
7143
|
-
import { readFileSync as
|
|
6889
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
7144
6890
|
import { join as join14 } from "node:path";
|
|
7145
6891
|
function str(v) {
|
|
7146
6892
|
return typeof v === "string" && v.length > 0 ? v : undefined;
|
|
@@ -7150,7 +6896,7 @@ function readSessionsIndex(agentId) {
|
|
|
7150
6896
|
const indexPath = join14(openclawHome(), "agents", agentId, "sessions", "sessions.json");
|
|
7151
6897
|
let raw;
|
|
7152
6898
|
try {
|
|
7153
|
-
raw = JSON.parse(
|
|
6899
|
+
raw = JSON.parse(readFileSync7(indexPath, "utf-8"));
|
|
7154
6900
|
} catch {
|
|
7155
6901
|
return out;
|
|
7156
6902
|
}
|
|
@@ -7299,7 +7045,7 @@ var init_openclaw_projects = __esm(() => {
|
|
|
7299
7045
|
|
|
7300
7046
|
// lib/factory-sessions.ts
|
|
7301
7047
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
7302
|
-
import { readdirSync as
|
|
7048
|
+
import { readdirSync as readdirSync5, statSync as statSync7 } from "node:fs";
|
|
7303
7049
|
import { homedir as homedir12 } from "node:os";
|
|
7304
7050
|
import { join as join15 } from "node:path";
|
|
7305
7051
|
function factoryHome() {
|
|
@@ -7445,7 +7191,7 @@ function listFactoryTranscripts() {
|
|
|
7445
7191
|
const out = [];
|
|
7446
7192
|
let projectDirs;
|
|
7447
7193
|
try {
|
|
7448
|
-
projectDirs =
|
|
7194
|
+
projectDirs = readdirSync5(root, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
7449
7195
|
} catch {
|
|
7450
7196
|
return out;
|
|
7451
7197
|
}
|
|
@@ -7455,7 +7201,7 @@ function listFactoryTranscripts() {
|
|
|
7455
7201
|
const projectPath = join15(root, projectName);
|
|
7456
7202
|
let files;
|
|
7457
7203
|
try {
|
|
7458
|
-
files =
|
|
7204
|
+
files = readdirSync5(projectPath);
|
|
7459
7205
|
} catch {
|
|
7460
7206
|
continue;
|
|
7461
7207
|
}
|
|
@@ -7467,7 +7213,7 @@ function listFactoryTranscripts() {
|
|
|
7467
7213
|
continue;
|
|
7468
7214
|
const transcriptPath = join15(projectPath, file);
|
|
7469
7215
|
try {
|
|
7470
|
-
const st =
|
|
7216
|
+
const st = statSync7(transcriptPath);
|
|
7471
7217
|
out.push({ projectName, cwd, sessionId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
|
|
7472
7218
|
} catch {}
|
|
7473
7219
|
}
|
|
@@ -7886,7 +7632,7 @@ var init_devin_projects = __esm(() => {
|
|
|
7886
7632
|
|
|
7887
7633
|
// lib/antigravity-sessions.ts
|
|
7888
7634
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
7889
|
-
import { readdirSync as
|
|
7635
|
+
import { readdirSync as readdirSync6, statSync as statSync8 } from "node:fs";
|
|
7890
7636
|
import { homedir as homedir14 } from "node:os";
|
|
7891
7637
|
import { join as join17 } from "node:path";
|
|
7892
7638
|
function antigravityHome() {
|
|
@@ -8011,7 +7757,7 @@ function listAntigravityTranscripts() {
|
|
|
8011
7757
|
const out = [];
|
|
8012
7758
|
let convoDirs;
|
|
8013
7759
|
try {
|
|
8014
|
-
convoDirs =
|
|
7760
|
+
convoDirs = readdirSync6(root, { withFileTypes: true }).filter((d) => d.isDirectory());
|
|
8015
7761
|
} catch {
|
|
8016
7762
|
return out;
|
|
8017
7763
|
}
|
|
@@ -8021,7 +7767,7 @@ function listAntigravityTranscripts() {
|
|
|
8021
7767
|
continue;
|
|
8022
7768
|
const transcriptPath = join17(root, conversationId, rel);
|
|
8023
7769
|
try {
|
|
8024
|
-
const st =
|
|
7770
|
+
const st = statSync8(transcriptPath);
|
|
8025
7771
|
if (!st.isFile())
|
|
8026
7772
|
continue;
|
|
8027
7773
|
out.push({ conversationId, transcriptPath, mtimeMs: st.mtimeMs, sizeBytes: st.size });
|
|
@@ -8034,7 +7780,7 @@ function findAntigravityTranscript(conversationId) {
|
|
|
8034
7780
|
return null;
|
|
8035
7781
|
const transcriptPath = join17(antigravityBrainRoot(), conversationId, antigravityTranscriptRelPath());
|
|
8036
7782
|
try {
|
|
8037
|
-
if (
|
|
7783
|
+
if (statSync8(transcriptPath).isFile())
|
|
8038
7784
|
return transcriptPath;
|
|
8039
7785
|
} catch {}
|
|
8040
7786
|
return null;
|
|
@@ -8484,7 +8230,7 @@ var init_goose_projects = __esm(() => {
|
|
|
8484
8230
|
|
|
8485
8231
|
// lib/projects.ts
|
|
8486
8232
|
import { readdir as readdir5, stat as stat4 } from "node:fs/promises";
|
|
8487
|
-
import { join as join20, resolve as
|
|
8233
|
+
import { join as join20, resolve as resolve9, sep } from "node:path";
|
|
8488
8234
|
async function getMtime(path, label) {
|
|
8489
8235
|
try {
|
|
8490
8236
|
return (await stat4(path)).mtime;
|
|
@@ -8636,8 +8382,8 @@ function resolveProjectPath(projectName) {
|
|
|
8636
8382
|
throw new RangeError("Empty project name");
|
|
8637
8383
|
if (/^[/\\]/.test(projectName))
|
|
8638
8384
|
throw new RangeError("Absolute project name");
|
|
8639
|
-
const projectsPath =
|
|
8640
|
-
const candidate =
|
|
8385
|
+
const projectsPath = resolve9(getClaudeProjectsPath());
|
|
8386
|
+
const candidate = resolve9(join20(projectsPath, projectName));
|
|
8641
8387
|
if (!candidate.startsWith(projectsPath + sep)) {
|
|
8642
8388
|
throw new RangeError("Project path escapes root");
|
|
8643
8389
|
}
|
|
@@ -8943,30 +8689,30 @@ var init_log_entries = __esm(() => {
|
|
|
8943
8689
|
});
|
|
8944
8690
|
|
|
8945
8691
|
// lib/codex-sessions.ts
|
|
8946
|
-
import { readFileSync as
|
|
8692
|
+
import { readFileSync as readFileSync8, readdirSync as readdirSync7, existsSync as existsSync9, writeFileSync as writeFileSync4, mkdirSync as mkdirSync5, statSync as statSync9 } from "node:fs";
|
|
8947
8693
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
8948
|
-
import { dirname as
|
|
8694
|
+
import { dirname as dirname4, join as join23 } from "node:path";
|
|
8949
8695
|
import { homedir as homedir16 } from "node:os";
|
|
8950
8696
|
function readCache() {
|
|
8951
8697
|
try {
|
|
8952
|
-
if (!
|
|
8698
|
+
if (!existsSync9(CACHE_PATH))
|
|
8953
8699
|
return {};
|
|
8954
|
-
return JSON.parse(
|
|
8700
|
+
return JSON.parse(readFileSync8(CACHE_PATH, "utf-8"));
|
|
8955
8701
|
} catch {
|
|
8956
8702
|
return {};
|
|
8957
8703
|
}
|
|
8958
8704
|
}
|
|
8959
8705
|
function writeCacheEntry(sessionId, path) {
|
|
8960
8706
|
try {
|
|
8961
|
-
|
|
8707
|
+
mkdirSync5(dirname4(CACHE_PATH), { recursive: true });
|
|
8962
8708
|
const cache = readCache();
|
|
8963
8709
|
cache[sessionId] = path;
|
|
8964
|
-
|
|
8710
|
+
writeFileSync4(CACHE_PATH, JSON.stringify(cache), "utf-8");
|
|
8965
8711
|
} catch {}
|
|
8966
8712
|
}
|
|
8967
8713
|
function dirSearch(dir, sessionId) {
|
|
8968
8714
|
try {
|
|
8969
|
-
for (const f of
|
|
8715
|
+
for (const f of readdirSync7(dir, { withFileTypes: true })) {
|
|
8970
8716
|
if (f.isFile() && f.name.includes(sessionId) && f.name.endsWith(".jsonl")) {
|
|
8971
8717
|
return join23(dir, f.name);
|
|
8972
8718
|
}
|
|
@@ -8977,7 +8723,7 @@ function dirSearch(dir, sessionId) {
|
|
|
8977
8723
|
function findCodexTranscript(sessionId) {
|
|
8978
8724
|
const cache = readCache();
|
|
8979
8725
|
const cached = cache[sessionId];
|
|
8980
|
-
if (cached &&
|
|
8726
|
+
if (cached && existsSync9(cached))
|
|
8981
8727
|
return cached;
|
|
8982
8728
|
const root = join23(homedir16(), ".codex", "sessions");
|
|
8983
8729
|
const today = new Date;
|
|
@@ -8996,13 +8742,13 @@ function findCodexTranscript(sessionId) {
|
|
|
8996
8742
|
}
|
|
8997
8743
|
}
|
|
8998
8744
|
try {
|
|
8999
|
-
for (const y of
|
|
8745
|
+
for (const y of readdirSync7(root, { withFileTypes: true })) {
|
|
9000
8746
|
if (!y.isDirectory())
|
|
9001
8747
|
continue;
|
|
9002
|
-
for (const m of
|
|
8748
|
+
for (const m of readdirSync7(join23(root, y.name), { withFileTypes: true })) {
|
|
9003
8749
|
if (!m.isDirectory())
|
|
9004
8750
|
continue;
|
|
9005
|
-
for (const d of
|
|
8751
|
+
for (const d of readdirSync7(join23(root, y.name, m.name), { withFileTypes: true })) {
|
|
9006
8752
|
if (!d.isDirectory())
|
|
9007
8753
|
continue;
|
|
9008
8754
|
const hit = dirSearch(join23(root, y.name, m.name, d.name), sessionId);
|
|
@@ -9031,6 +8777,15 @@ function joinTexts(blocks, wantedType) {
|
|
|
9031
8777
|
return blocks.filter((b) => b?.type === wantedType && typeof b.text === "string").map((b) => b.text).join(`
|
|
9032
8778
|
`);
|
|
9033
8779
|
}
|
|
8780
|
+
function toolOutputText(output) {
|
|
8781
|
+
if (typeof output === "string")
|
|
8782
|
+
return output;
|
|
8783
|
+
if (Array.isArray(output)) {
|
|
8784
|
+
return output.filter((block) => !!block && typeof block === "object").map((block) => typeof block.text === "string" ? block.text : "").filter(Boolean).join(`
|
|
8785
|
+
`);
|
|
8786
|
+
}
|
|
8787
|
+
return output === undefined ? "" : JSON.stringify(output);
|
|
8788
|
+
}
|
|
9034
8789
|
async function parseCodexLog(fileContent, source = "session") {
|
|
9035
8790
|
const lines = fileContent.split(`
|
|
9036
8791
|
`).filter((line) => line.trim() !== "");
|
|
@@ -9107,10 +8862,11 @@ async function parseCodexLog(fileContent, source = "session") {
|
|
|
9107
8862
|
});
|
|
9108
8863
|
continue;
|
|
9109
8864
|
}
|
|
9110
|
-
if (subType === "function_call") {
|
|
8865
|
+
if (subType === "function_call" || subType === "custom_tool_call") {
|
|
9111
8866
|
const callId = payload.call_id;
|
|
9112
8867
|
const name = payload.name ?? "function_call";
|
|
9113
|
-
const
|
|
8868
|
+
const encodedInput = payload.arguments ?? payload.input;
|
|
8869
|
+
const input = safeJsonParse4(encodedInput);
|
|
9114
8870
|
const toolUse = {
|
|
9115
8871
|
type: "tool_use",
|
|
9116
8872
|
id: callId ?? `${timestamp}-${name}`,
|
|
@@ -9129,7 +8885,7 @@ async function parseCodexLog(fileContent, source = "session") {
|
|
|
9129
8885
|
}
|
|
9130
8886
|
continue;
|
|
9131
8887
|
}
|
|
9132
|
-
if (subType === "function_call_output") {
|
|
8888
|
+
if (subType === "function_call_output" || subType === "custom_tool_call_output") {
|
|
9133
8889
|
const callId = payload.call_id;
|
|
9134
8890
|
const block = callId ? toolUseById.get(callId) : undefined;
|
|
9135
8891
|
if (block) {
|
|
@@ -9138,7 +8894,7 @@ async function parseCodexLog(fileContent, source = "session") {
|
|
|
9138
8894
|
block.result = {
|
|
9139
8895
|
timestamp,
|
|
9140
8896
|
timestampFormatted: formatTimestamp(date),
|
|
9141
|
-
content:
|
|
8897
|
+
content: toolOutputText(payload.output),
|
|
9142
8898
|
durationMs: duration,
|
|
9143
8899
|
durationFormatted: formatDuration(duration)
|
|
9144
8900
|
};
|
|
@@ -9231,7 +8987,7 @@ var init_codex_sessions = __esm(() => {
|
|
|
9231
8987
|
});
|
|
9232
8988
|
|
|
9233
8989
|
// src/hooks/resolve-permission-mode.ts
|
|
9234
|
-
import { readFileSync as
|
|
8990
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
9235
8991
|
function resolvePermissionMode(integration, parsed, sessionId) {
|
|
9236
8992
|
if (integration === "claude") {
|
|
9237
8993
|
return parsed.permission_mode ?? "default";
|
|
@@ -9246,7 +9002,7 @@ function resolveCodexMode(sessionId) {
|
|
|
9246
9002
|
const path = findCodexTranscript(sessionId);
|
|
9247
9003
|
if (!path)
|
|
9248
9004
|
return;
|
|
9249
|
-
for (const line of
|
|
9005
|
+
for (const line of readFileSync9(path, "utf-8").split(`
|
|
9250
9006
|
`)) {
|
|
9251
9007
|
if (!line.includes("turn_context"))
|
|
9252
9008
|
continue;
|
|
@@ -9271,9 +9027,9 @@ var init_resolve_permission_mode = __esm(() => {
|
|
|
9271
9027
|
});
|
|
9272
9028
|
|
|
9273
9029
|
// lib/copilot-sessions.ts
|
|
9274
|
-
import { readFileSync as
|
|
9030
|
+
import { readFileSync as readFileSync10, readdirSync as readdirSync8, existsSync as existsSync10, statSync as statSync10 } from "node:fs";
|
|
9275
9031
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
9276
|
-
import { join as join24, resolve as
|
|
9032
|
+
import { join as join24, resolve as resolve10, sep as sep2 } from "node:path";
|
|
9277
9033
|
import { homedir as homedir17 } from "node:os";
|
|
9278
9034
|
function getCopilotHome() {
|
|
9279
9035
|
return process.env.COPILOT_HOME || join24(homedir17(), ".copilot");
|
|
@@ -9284,8 +9040,8 @@ function getCopilotSessionStateRoot2() {
|
|
|
9284
9040
|
function getCopilotSessionDir(sessionId) {
|
|
9285
9041
|
if (!sessionId)
|
|
9286
9042
|
return null;
|
|
9287
|
-
const root =
|
|
9288
|
-
const candidate =
|
|
9043
|
+
const root = resolve10(getCopilotSessionStateRoot2());
|
|
9044
|
+
const candidate = resolve10(root, sessionId);
|
|
9289
9045
|
if (candidate === root || !candidate.startsWith(`${root}${sep2}`))
|
|
9290
9046
|
return null;
|
|
9291
9047
|
return candidate;
|
|
@@ -9300,17 +9056,17 @@ function findCopilotTranscript(sessionId) {
|
|
|
9300
9056
|
const candidate = resolveSessionFile(sessionId, "events.jsonl");
|
|
9301
9057
|
if (!candidate)
|
|
9302
9058
|
return null;
|
|
9303
|
-
return
|
|
9059
|
+
return existsSync10(candidate) ? candidate : null;
|
|
9304
9060
|
}
|
|
9305
9061
|
function findCopilotWorkspace(sessionId) {
|
|
9306
9062
|
const candidate = resolveSessionFile(sessionId, "workspace.yaml");
|
|
9307
9063
|
if (!candidate)
|
|
9308
9064
|
return null;
|
|
9309
|
-
return
|
|
9065
|
+
return existsSync10(candidate) ? candidate : null;
|
|
9310
9066
|
}
|
|
9311
9067
|
function readYamlScalar(path, key) {
|
|
9312
9068
|
try {
|
|
9313
|
-
const text =
|
|
9069
|
+
const text = readFileSync10(path, "utf-8");
|
|
9314
9070
|
const re = new RegExp(`^${key}\\s*:\\s*(.+?)\\s*$`, "m");
|
|
9315
9071
|
const m = text.match(re);
|
|
9316
9072
|
if (!m)
|
|
@@ -9333,6 +9089,8 @@ async function parseCopilotLog(fileContent, source = "session") {
|
|
|
9333
9089
|
const rawLines = [];
|
|
9334
9090
|
const toolUseById = new Map;
|
|
9335
9091
|
const toolUseStartMs = new Map;
|
|
9092
|
+
let mostRecentToolUse;
|
|
9093
|
+
let mostRecentToolUseStartMs = 0;
|
|
9336
9094
|
let cwd;
|
|
9337
9095
|
let seenSessionStart = false;
|
|
9338
9096
|
for (let i = 0;i < lines.length; i++) {
|
|
@@ -9428,8 +9186,24 @@ async function parseCopilotLog(fileContent, source = "session") {
|
|
|
9428
9186
|
toolUseById.set(callId, toolUse);
|
|
9429
9187
|
toolUseStartMs.set(callId, date.getTime());
|
|
9430
9188
|
}
|
|
9189
|
+
mostRecentToolUse = toolUse;
|
|
9190
|
+
mostRecentToolUseStartMs = date.getTime();
|
|
9431
9191
|
continue;
|
|
9432
9192
|
}
|
|
9193
|
+
if (recType === "hook.start" && data.hookType === "postToolUse" && mostRecentToolUse) {
|
|
9194
|
+
const input = data.input ?? {};
|
|
9195
|
+
const hookResult = input.toolResult ?? {};
|
|
9196
|
+
const hookContent = hookResult.textResultForLlm ?? hookResult.sessionLog;
|
|
9197
|
+
if (typeof hookContent === "string" && hookContent.length > 0) {
|
|
9198
|
+
mostRecentToolUse.result = {
|
|
9199
|
+
timestamp,
|
|
9200
|
+
timestampFormatted: formatTimestamp(date),
|
|
9201
|
+
content: hookContent,
|
|
9202
|
+
durationMs: Math.max(0, date.getTime() - mostRecentToolUseStartMs),
|
|
9203
|
+
durationFormatted: formatDuration(Math.max(0, date.getTime() - mostRecentToolUseStartMs))
|
|
9204
|
+
};
|
|
9205
|
+
}
|
|
9206
|
+
}
|
|
9433
9207
|
if (recType === "tool.execution_complete") {
|
|
9434
9208
|
const callId = data.toolCallId;
|
|
9435
9209
|
const block = callId ? toolUseById.get(callId) : undefined;
|
|
@@ -9439,7 +9213,8 @@ async function parseCopilotLog(fileContent, source = "session") {
|
|
|
9439
9213
|
const telemetry = data.toolTelemetry ?? {};
|
|
9440
9214
|
const reportedMs = telemetry.metrics?.commandTimeMs ?? telemetry.metrics?.durationMs ?? null;
|
|
9441
9215
|
const durationMs = typeof reportedMs === "number" && reportedMs >= 0 ? reportedMs : Math.max(0, date.getTime() - startMs);
|
|
9442
|
-
const
|
|
9216
|
+
const completionContent = result.detailedContent ?? result.content ?? "";
|
|
9217
|
+
const content = block.result?.content || completionContent;
|
|
9443
9218
|
block.result = {
|
|
9444
9219
|
timestamp,
|
|
9445
9220
|
timestampFormatted: formatTimestamp(date),
|
|
@@ -9488,9 +9263,9 @@ var init_copilot_sessions = __esm(() => {
|
|
|
9488
9263
|
});
|
|
9489
9264
|
|
|
9490
9265
|
// lib/cursor-sessions.ts
|
|
9491
|
-
import { readFileSync as
|
|
9266
|
+
import { readFileSync as readFileSync11, readdirSync as readdirSync9, existsSync as existsSync11, statSync as statSync11 } from "node:fs";
|
|
9492
9267
|
import { readFile as readFile13 } from "node:fs/promises";
|
|
9493
|
-
import { basename as basename3, join as join25, resolve as
|
|
9268
|
+
import { basename as basename3, join as join25, resolve as resolve11, sep as sep3 } from "node:path";
|
|
9494
9269
|
import { homedir as homedir18 } from "node:os";
|
|
9495
9270
|
function getCursorHome2() {
|
|
9496
9271
|
return process.env.CURSOR_HOME || join25(homedir18(), ".cursor");
|
|
@@ -9498,28 +9273,28 @@ function getCursorHome2() {
|
|
|
9498
9273
|
function getCursorSessionDir(sessionId) {
|
|
9499
9274
|
if (!sessionId)
|
|
9500
9275
|
return null;
|
|
9501
|
-
const home =
|
|
9502
|
-
const projectsRoot =
|
|
9276
|
+
const home = resolve11(getCursorHome2());
|
|
9277
|
+
const projectsRoot = resolve11(home, NEW_PROJECTS_DIR2);
|
|
9503
9278
|
let projectEntries = [];
|
|
9504
9279
|
try {
|
|
9505
|
-
projectEntries =
|
|
9280
|
+
projectEntries = readdirSync9(projectsRoot, { withFileTypes: true });
|
|
9506
9281
|
} catch {}
|
|
9507
9282
|
for (const entry of projectEntries) {
|
|
9508
9283
|
if (!entry.isDirectory())
|
|
9509
9284
|
continue;
|
|
9510
|
-
const candidate =
|
|
9511
|
-
const transcriptRoot =
|
|
9285
|
+
const candidate = resolve11(projectsRoot, entry.name, NEW_AGENT_TRANSCRIPTS_DIR2, sessionId);
|
|
9286
|
+
const transcriptRoot = resolve11(projectsRoot, entry.name, NEW_AGENT_TRANSCRIPTS_DIR2);
|
|
9512
9287
|
if (candidate === transcriptRoot || !candidate.startsWith(`${transcriptRoot}${sep3}`))
|
|
9513
9288
|
continue;
|
|
9514
|
-
if (
|
|
9289
|
+
if (existsSync11(candidate))
|
|
9515
9290
|
return candidate;
|
|
9516
9291
|
}
|
|
9517
9292
|
for (const sub of LEGACY_SESSION_ROOT_CANDIDATES2) {
|
|
9518
|
-
const root =
|
|
9519
|
-
const candidate =
|
|
9293
|
+
const root = resolve11(home, sub);
|
|
9294
|
+
const candidate = resolve11(root, sessionId);
|
|
9520
9295
|
if (candidate === root || !candidate.startsWith(`${root}${sep3}`))
|
|
9521
9296
|
continue;
|
|
9522
|
-
if (
|
|
9297
|
+
if (existsSync11(candidate))
|
|
9523
9298
|
return candidate;
|
|
9524
9299
|
}
|
|
9525
9300
|
return null;
|
|
@@ -9529,11 +9304,11 @@ function findCursorTranscript(sessionId) {
|
|
|
9529
9304
|
if (!dir)
|
|
9530
9305
|
return null;
|
|
9531
9306
|
const newCandidate = join25(dir, `${basename3(dir)}.jsonl`);
|
|
9532
|
-
if (
|
|
9307
|
+
if (existsSync11(newCandidate))
|
|
9533
9308
|
return newCandidate;
|
|
9534
9309
|
for (const name of LEGACY_TRANSCRIPT_FILE_CANDIDATES2) {
|
|
9535
9310
|
const candidate = join25(dir, name);
|
|
9536
|
-
if (
|
|
9311
|
+
if (existsSync11(candidate))
|
|
9537
9312
|
return candidate;
|
|
9538
9313
|
}
|
|
9539
9314
|
return null;
|
|
@@ -9563,8 +9338,27 @@ async function parseCursorLog(fileContent, source = "session") {
|
|
|
9563
9338
|
if (!raw.type && raw.role && raw.message?.content) {
|
|
9564
9339
|
const synthDate = new Date(SYNTH_T0 + i);
|
|
9565
9340
|
const synthTs = synthDate.toISOString();
|
|
9566
|
-
const
|
|
9341
|
+
const messageContent = raw.message.content;
|
|
9342
|
+
const textParts = messageContent.filter((c) => c?.type === "text" && typeof c.text === "string").map((c) => c.text).join("");
|
|
9567
9343
|
if (raw.role === "user") {
|
|
9344
|
+
let attachedResult = false;
|
|
9345
|
+
for (const block of messageContent) {
|
|
9346
|
+
if (block?.type !== "tool_result")
|
|
9347
|
+
continue;
|
|
9348
|
+
const callId = typeof block.tool_use_id === "string" ? block.tool_use_id : undefined;
|
|
9349
|
+
const toolUse = callId ? toolUseById.get(callId) : undefined;
|
|
9350
|
+
if (!toolUse)
|
|
9351
|
+
continue;
|
|
9352
|
+
const durationMs = Math.max(0, synthDate.getTime() - (toolUseStartMs.get(callId) ?? synthDate.getTime()));
|
|
9353
|
+
toolUse.result = {
|
|
9354
|
+
timestamp: synthTs,
|
|
9355
|
+
timestampFormatted: formatTimestamp(synthDate),
|
|
9356
|
+
content: typeof block.content === "string" ? block.content : block.content == null ? "" : JSON.stringify(block.content),
|
|
9357
|
+
durationMs,
|
|
9358
|
+
durationFormatted: formatDuration(durationMs)
|
|
9359
|
+
};
|
|
9360
|
+
attachedResult = true;
|
|
9361
|
+
}
|
|
9568
9362
|
const queryMatch = /<user_query>\s*([\s\S]*?)\s*<\/user_query>/.exec(textParts);
|
|
9569
9363
|
const text = queryMatch ? queryMatch[1] : textParts;
|
|
9570
9364
|
if (text) {
|
|
@@ -9573,11 +9367,35 @@ async function parseCursorLog(fileContent, source = "session") {
|
|
|
9573
9367
|
...baseEntry(rawCopy, synthTs, synthDate, source),
|
|
9574
9368
|
message: { role: "user", content: text }
|
|
9575
9369
|
});
|
|
9370
|
+
} else if (!attachedResult) {
|
|
9371
|
+
entries.push({
|
|
9372
|
+
type: "system",
|
|
9373
|
+
...baseEntry(rawCopy, synthTs, synthDate, source),
|
|
9374
|
+
raw: rawCopy
|
|
9375
|
+
});
|
|
9576
9376
|
}
|
|
9577
9377
|
continue;
|
|
9578
9378
|
}
|
|
9579
9379
|
if (raw.role === "assistant") {
|
|
9580
|
-
const blocks =
|
|
9380
|
+
const blocks = [];
|
|
9381
|
+
if (textParts)
|
|
9382
|
+
blocks.push({ type: "text", text: textParts });
|
|
9383
|
+
for (let j = 0;j < messageContent.length; j++) {
|
|
9384
|
+
const contentBlock = messageContent[j];
|
|
9385
|
+
if (contentBlock?.type !== "tool_use")
|
|
9386
|
+
continue;
|
|
9387
|
+
const name = typeof contentBlock.name === "string" ? contentBlock.name : "tool";
|
|
9388
|
+
const id = typeof contentBlock.id === "string" && contentBlock.id ? contentBlock.id : `cursor-${i}-${name}-${j}`;
|
|
9389
|
+
const toolUse = {
|
|
9390
|
+
type: "tool_use",
|
|
9391
|
+
id,
|
|
9392
|
+
name,
|
|
9393
|
+
input: contentBlock.input && typeof contentBlock.input === "object" ? contentBlock.input : {}
|
|
9394
|
+
};
|
|
9395
|
+
blocks.push(toolUse);
|
|
9396
|
+
toolUseById.set(id, toolUse);
|
|
9397
|
+
toolUseStartMs.set(id, synthDate.getTime());
|
|
9398
|
+
}
|
|
9581
9399
|
if (blocks.length === 0) {
|
|
9582
9400
|
entries.push({
|
|
9583
9401
|
type: "system",
|
|
@@ -9744,9 +9562,9 @@ var init_cursor_sessions = __esm(() => {
|
|
|
9744
9562
|
});
|
|
9745
9563
|
|
|
9746
9564
|
// lib/pi-sessions.ts
|
|
9747
|
-
import { readFileSync as
|
|
9565
|
+
import { readFileSync as readFileSync12, readdirSync as readdirSync10, existsSync as existsSync12, statSync as statSync12 } from "node:fs";
|
|
9748
9566
|
import { readFile as readFile14 } from "node:fs/promises";
|
|
9749
|
-
import { join as join26, resolve as
|
|
9567
|
+
import { join as join26, resolve as resolve12, sep as sep4 } from "node:path";
|
|
9750
9568
|
import { homedir as homedir19 } from "node:os";
|
|
9751
9569
|
function getPiSessionStateRoot() {
|
|
9752
9570
|
return process.env.PI_SESSIONS_DIR || join26(homedir19(), ".pi", "agent", "sessions");
|
|
@@ -9757,20 +9575,20 @@ function isSafeSessionId(sessionId) {
|
|
|
9757
9575
|
function findPiTranscript(sessionId) {
|
|
9758
9576
|
if (!isSafeSessionId(sessionId))
|
|
9759
9577
|
return null;
|
|
9760
|
-
const root =
|
|
9578
|
+
const root = resolve12(getPiSessionStateRoot());
|
|
9761
9579
|
let cwdDirs;
|
|
9762
9580
|
try {
|
|
9763
|
-
cwdDirs =
|
|
9581
|
+
cwdDirs = readdirSync10(root);
|
|
9764
9582
|
} catch {
|
|
9765
9583
|
return null;
|
|
9766
9584
|
}
|
|
9767
9585
|
for (const cwdDir of cwdDirs) {
|
|
9768
|
-
const cwdPath =
|
|
9586
|
+
const cwdPath = resolve12(root, cwdDir);
|
|
9769
9587
|
if (!cwdPath.startsWith(`${root}${sep4}`))
|
|
9770
9588
|
continue;
|
|
9771
9589
|
let files;
|
|
9772
9590
|
try {
|
|
9773
|
-
files =
|
|
9591
|
+
files = readdirSync10(cwdPath);
|
|
9774
9592
|
} catch {
|
|
9775
9593
|
continue;
|
|
9776
9594
|
}
|
|
@@ -9778,10 +9596,10 @@ function findPiTranscript(sessionId) {
|
|
|
9778
9596
|
const m = SESSION_FILE_RE2.exec(f);
|
|
9779
9597
|
if (!m || m[1].toLowerCase() !== sessionId.toLowerCase())
|
|
9780
9598
|
continue;
|
|
9781
|
-
const candidate =
|
|
9599
|
+
const candidate = resolve12(cwdPath, f);
|
|
9782
9600
|
if (!candidate.startsWith(`${cwdPath}${sep4}`))
|
|
9783
9601
|
continue;
|
|
9784
|
-
if (
|
|
9602
|
+
if (existsSync12(candidate))
|
|
9785
9603
|
return candidate;
|
|
9786
9604
|
}
|
|
9787
9605
|
}
|
|
@@ -10137,14 +9955,17 @@ var init_pack_failclosed = __esm(() => {
|
|
|
10137
9955
|
]);
|
|
10138
9956
|
});
|
|
10139
9957
|
|
|
9958
|
+
// lib/atomic-write.ts
|
|
9959
|
+
var init_atomic_write = () => {};
|
|
9960
|
+
|
|
10140
9961
|
// src/hooks/session-pause.ts
|
|
10141
|
-
import { existsSync as
|
|
9962
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync6, readdirSync as readdirSync11, readFileSync as readFileSync13, rmSync as rmSync2 } from "node:fs";
|
|
10142
9963
|
import { createHash as createHash5 } from "node:crypto";
|
|
10143
|
-
import { join as join27, resolve as
|
|
9964
|
+
import { join as join27, resolve as resolve13 } from "node:path";
|
|
10144
9965
|
function pauseStateDir() {
|
|
10145
9966
|
const override = process.env.FAILPROOFAI_STATE_DIR;
|
|
10146
9967
|
if (override)
|
|
10147
|
-
return
|
|
9968
|
+
return resolve13(override, "sessions");
|
|
10148
9969
|
return sessionPauseDir();
|
|
10149
9970
|
}
|
|
10150
9971
|
function pauseFilePath(sessionId) {
|
|
@@ -10178,9 +9999,9 @@ function readActivePause(sessionId, now = Date.now()) {
|
|
|
10178
9999
|
return null;
|
|
10179
10000
|
try {
|
|
10180
10001
|
const path = pauseFilePath(sessionId);
|
|
10181
|
-
if (!
|
|
10002
|
+
if (!existsSync13(path))
|
|
10182
10003
|
return null;
|
|
10183
|
-
const stored = parseStored(JSON.parse(
|
|
10004
|
+
const stored = parseStored(JSON.parse(readFileSync13(path, "utf8")));
|
|
10184
10005
|
if (!stored)
|
|
10185
10006
|
return null;
|
|
10186
10007
|
if (stored.expiresAt <= now)
|
|
@@ -10219,15 +10040,15 @@ var init_daemon_service = __esm(() => {
|
|
|
10219
10040
|
// src/hooks/fp-reset.ts
|
|
10220
10041
|
import {
|
|
10221
10042
|
copyFileSync,
|
|
10222
|
-
existsSync as
|
|
10223
|
-
mkdirSync as
|
|
10224
|
-
readFileSync as
|
|
10225
|
-
readdirSync as
|
|
10226
|
-
renameSync as
|
|
10227
|
-
rmSync as
|
|
10043
|
+
existsSync as existsSync14,
|
|
10044
|
+
mkdirSync as mkdirSync7,
|
|
10045
|
+
readFileSync as readFileSync14,
|
|
10046
|
+
readdirSync as readdirSync12,
|
|
10047
|
+
renameSync as renameSync3,
|
|
10048
|
+
rmSync as rmSync3,
|
|
10228
10049
|
rmdirSync,
|
|
10229
|
-
statSync as
|
|
10230
|
-
writeFileSync as
|
|
10050
|
+
statSync as statSync13,
|
|
10051
|
+
writeFileSync as writeFileSync5
|
|
10231
10052
|
} from "node:fs";
|
|
10232
10053
|
function layoutWarningForHook() {
|
|
10233
10054
|
const state = detectLayout();
|
|
@@ -10236,7 +10057,7 @@ function layoutWarningForHook() {
|
|
|
10236
10057
|
if (state.kind === "future") {
|
|
10237
10058
|
return `[failproofai] this directory was written by a newer version (layout ${state.found} vs ${LAYOUT_VERSION}) — policies are NOT being enforced. ` + `Upgrade failproofai.`;
|
|
10238
10059
|
}
|
|
10239
|
-
if (
|
|
10060
|
+
if (existsSync14(globalPolicyConfigFile()))
|
|
10240
10061
|
return null;
|
|
10241
10062
|
return `[failproofai] setup predates this version — global policies are NOT being enforced. ` + `Run \`failproofai config\` to re-create it.`;
|
|
10242
10063
|
}
|
|
@@ -10281,31 +10102,6 @@ function canonicalizeEventType(raw, cli) {
|
|
|
10281
10102
|
}
|
|
10282
10103
|
return raw;
|
|
10283
10104
|
}
|
|
10284
|
-
function attachLeakNotice(eventType, cli, outcome, sessionId) {
|
|
10285
|
-
try {
|
|
10286
|
-
if (!canDeliverNotice(cli))
|
|
10287
|
-
return outcome;
|
|
10288
|
-
if (!cli)
|
|
10289
|
-
return outcome;
|
|
10290
|
-
const canonical = canonicalizeEventType(eventType, cli);
|
|
10291
|
-
if (canonical !== "Stop")
|
|
10292
|
-
return outcome;
|
|
10293
|
-
const pending = sessionNoticePending(sessionId ?? "");
|
|
10294
|
-
if (pending.count === 0)
|
|
10295
|
-
return outcome;
|
|
10296
|
-
const shaped = shapeNotice(cli, leakNoticeText(pending.count), outcome.stdout);
|
|
10297
|
-
if (shaped.stdout === outcome.stdout && !shaped.stderr)
|
|
10298
|
-
return outcome;
|
|
10299
|
-
markSessionNoticed(sessionId ?? "");
|
|
10300
|
-
return {
|
|
10301
|
-
exitCode: outcome.exitCode,
|
|
10302
|
-
stdout: shaped.stdout,
|
|
10303
|
-
stderr: outcome.stderr + shaped.stderr
|
|
10304
|
-
};
|
|
10305
|
-
} catch {
|
|
10306
|
-
return outcome;
|
|
10307
|
-
}
|
|
10308
|
-
}
|
|
10309
10105
|
async function runObserved(hook, ctx, hookName, eventType, cli) {
|
|
10310
10106
|
try {
|
|
10311
10107
|
return await Promise.race([
|
|
@@ -10608,8 +10404,7 @@ async function evaluateHookEvent(eventType, cli = "claude", stdinPayload, opts)
|
|
|
10608
10404
|
}
|
|
10609
10405
|
} catch {}
|
|
10610
10406
|
}
|
|
10611
|
-
|
|
10612
|
-
return withNotice;
|
|
10407
|
+
return { exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr };
|
|
10613
10408
|
} finally {
|
|
10614
10409
|
if (opts?.awaitTelemetryFlush ?? true) {
|
|
10615
10410
|
await flushHookTelemetry();
|
|
@@ -10625,8 +10420,6 @@ var init_handler = __esm(() => {
|
|
|
10625
10420
|
init_custom_hooks_loader();
|
|
10626
10421
|
init_hook_activity_store();
|
|
10627
10422
|
init_delivery_health();
|
|
10628
|
-
init_notice();
|
|
10629
|
-
init_leak_notice();
|
|
10630
10423
|
init_hook_telemetry();
|
|
10631
10424
|
init_resolve_permission_mode();
|
|
10632
10425
|
init_resolve_transcript_path();
|
|
@@ -10641,7 +10434,7 @@ var init_handler = __esm(() => {
|
|
|
10641
10434
|
|
|
10642
10435
|
// src/hooks/worker-server.ts
|
|
10643
10436
|
import { createConnection, createServer } from "node:net";
|
|
10644
|
-
import { existsSync as
|
|
10437
|
+
import { existsSync as existsSync15, unlinkSync as unlinkSync2 } from "node:fs";
|
|
10645
10438
|
function isWorkerHookRequest(msg) {
|
|
10646
10439
|
if (!msg || typeof msg !== "object")
|
|
10647
10440
|
return false;
|
|
@@ -10774,14 +10567,14 @@ function requestExistingWorkerShutdown(socketPath) {
|
|
|
10774
10567
|
function startWorkerServer(socketPath, shutdown) {
|
|
10775
10568
|
const server = createServer((socket) => handleConnection(socket, shutdown ?? (() => server.close())));
|
|
10776
10569
|
const listen = () => {
|
|
10777
|
-
if (
|
|
10570
|
+
if (existsSync15(socketPath)) {
|
|
10778
10571
|
try {
|
|
10779
10572
|
unlinkSync2(socketPath);
|
|
10780
10573
|
} catch {}
|
|
10781
10574
|
}
|
|
10782
10575
|
server.listen(socketPath);
|
|
10783
10576
|
};
|
|
10784
|
-
if (!
|
|
10577
|
+
if (!existsSync15(socketPath))
|
|
10785
10578
|
listen();
|
|
10786
10579
|
else
|
|
10787
10580
|
requestExistingWorkerShutdown(socketPath).then(listen, (err) => server.emit("error", err));
|
|
@@ -10797,13 +10590,13 @@ var init_worker_server = __esm(() => {
|
|
|
10797
10590
|
|
|
10798
10591
|
// bin/failproofai-worker.mjs
|
|
10799
10592
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
10800
|
-
import { dirname as
|
|
10593
|
+
import { dirname as dirname5, resolve as resolve14 } from "node:path";
|
|
10801
10594
|
import { fileURLToPath } from "node:url";
|
|
10802
10595
|
if (!process.env.FAILPROOFAI_PACKAGE_ROOT) {
|
|
10803
|
-
process.env.FAILPROOFAI_PACKAGE_ROOT =
|
|
10596
|
+
process.env.FAILPROOFAI_PACKAGE_ROOT = resolve14(dirname5(realpathSync2(fileURLToPath(import.meta.url))), "..");
|
|
10804
10597
|
}
|
|
10805
10598
|
if (!process.env.FAILPROOFAI_DIST_PATH) {
|
|
10806
|
-
process.env.FAILPROOFAI_DIST_PATH =
|
|
10599
|
+
process.env.FAILPROOFAI_DIST_PATH = resolve14(dirname5(realpathSync2(fileURLToPath(import.meta.url))), "..", "dist");
|
|
10807
10600
|
}
|
|
10808
10601
|
var socketPath = process.env.FAILPROOFAI_WORKER_SOCKET;
|
|
10809
10602
|
if (!socketPath) {
|