failproofai 1.0.4-beta.4 → 1.0.4-beta.7

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.
Files changed (170) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  6. package/.next/standalone/.next/server/app/_global-error/page.js +2 -2
  7. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  8. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.rsc +7 -7
  11. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +6 -6
  12. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
  13. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page.js +2 -2
  16. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  17. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  18. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  19. package/.next/standalone/.next/server/app/_not-found.rsc +14 -14
  20. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
  21. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
  22. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  23. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +5 -5
  32. package/.next/standalone/.next/server/app/audit/page.js +3 -3
  33. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
  34. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  35. package/.next/standalone/.next/server/app/index.html +1 -1
  36. package/.next/standalone/.next/server/app/index.rsc +14 -14
  37. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +13 -13
  38. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +14 -14
  39. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  40. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  41. package/.next/standalone/.next/server/app/page.js +2 -2
  42. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  44. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
  45. package/.next/standalone/.next/server/app/policies/page.js +4 -4
  46. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  48. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  49. package/.next/standalone/.next/server/app/project/[name]/page.js +3 -3
  50. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  51. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  52. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  53. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  54. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js +4 -4
  55. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  56. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  57. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  58. package/.next/standalone/.next/server/app/projects/page.js +3 -3
  59. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  60. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  61. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +15 -4
  62. package/.next/standalone/.next/server/app/settings/page.js +4 -4
  63. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  64. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  65. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0--lkk6._.js +1 -1
  66. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0o07qi9._.js +1 -1
  67. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0q0qzx1._.js +1 -1
  68. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0rv7m0k._.js +1 -1
  69. package/.next/standalone/.next/server/chunks/[root-of-the-server]__17g9wh7._.js +1 -1
  70. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1le9jqc._.js +1 -1
  71. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1legmza._.js +1 -1
  72. package/.next/standalone/.next/server/chunks/[root-of-the-server]__1p-qi2t._.js +1 -1
  73. package/.next/standalone/.next/server/chunks/_0tovk6q._.js +1 -1
  74. package/.next/standalone/.next/server/chunks/_0trp3yc._.js +1 -1
  75. package/.next/standalone/.next/server/chunks/_1ek68ln._.js +11 -11
  76. package/.next/standalone/.next/server/chunks/lib_factory-projects_ts_1eo_bk-._.js +1 -1
  77. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4v._.js +1 -1
  78. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0p-5p8u._.js → [root-of-the-server]__0-4ja6q._.js} +3 -3
  79. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1p2otjt._.js → [root-of-the-server]__00cr3xu._.js} +3 -3
  80. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__013jr2b._.js → [root-of-the-server]__04px77e._.js} +3 -3
  81. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__190won8._.js → [root-of-the-server]__0dxf928._.js} +1 -1
  82. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0s740oi._.js → [root-of-the-server]__0egr5s1._.js} +3 -3
  83. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__01wy8d-._.js → [root-of-the-server]__0i0l1di._.js} +3 -3
  84. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0n_lxhg._.js → [root-of-the-server]__0kokc8z._.js} +1 -1
  85. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__1ctpynv._.js → [root-of-the-server]__0n2txhk._.js} +1 -1
  86. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0oa1lav._.js +1 -1
  87. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__02npjtd._.js → [root-of-the-server]__0r3c1_0._.js} +3 -3
  88. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0yl9wb5._.js → [root-of-the-server]__12hbpha._.js} +2 -2
  89. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0ftmoxc._.js → [root-of-the-server]__17xnxlx._.js} +3 -3
  90. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__0da85px._.js → [root-of-the-server]__1ckpmkk._.js} +3 -3
  91. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__00-s7h8._.js → [root-of-the-server]__1fvfw59._.js} +1 -1
  92. package/.next/standalone/.next/server/chunks/ssr/_04ng_6x._.js +3 -0
  93. package/.next/standalone/.next/server/chunks/ssr/{_1u8-lu2._.js → _07t3jol._.js} +2 -2
  94. package/.next/standalone/.next/server/chunks/ssr/_08x1r5t._.js +1 -1
  95. package/.next/standalone/.next/server/chunks/ssr/{_0guxnh-._.js → _0a0zlpr._.js} +2 -2
  96. package/.next/standalone/.next/server/chunks/ssr/{_0h_douw._.js → _0s-77v5._.js} +1 -1
  97. package/.next/standalone/.next/server/chunks/ssr/_1ddpc5g._.js +1 -1
  98. package/.next/standalone/.next/server/chunks/ssr/_1es2j7i._.js +4 -14
  99. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo.js +2 -2
  100. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47._.js +1 -1
  101. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x._.js +1 -1
  102. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpc._.js +1 -1
  103. package/.next/standalone/.next/server/chunks/ssr/app_settings_settings-client_tsx_20lq-mq._.js +1 -1
  104. package/.next/standalone/.next/server/chunks/ssr/src_hooks_builtin-policies_ts_09j2ndl._.js +1 -1
  105. package/.next/standalone/.next/server/chunks/ssr/src_hooks_fp-home_ts_0je3xkv._.js +1 -1
  106. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  107. package/.next/standalone/.next/server/pages/404.html +1 -1
  108. package/.next/standalone/.next/server/pages/500.html +1 -1
  109. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  110. package/.next/standalone/.next/server/server-reference-manifest.json +33 -22
  111. package/.next/standalone/.next/static/chunks/{17tfki9x5rd_7.js → 083fk73jtv9a0.js} +1 -1
  112. package/.next/standalone/.next/static/chunks/{1i-i0pxg9q_8y.js → 0divvxng208xo.js} +1 -1
  113. package/.next/standalone/.next/static/chunks/{38dqur43qthrl.js → 0f1pznnc7zlub.js} +1 -1
  114. package/.next/standalone/.next/static/chunks/{323cyb3a2s06y.js → 0ntdfr2552x-h.js} +1 -1
  115. package/.next/standalone/.next/static/chunks/{0po8n4tyotjf2.js → 0t6ea7d3bkmdv.js} +1 -1
  116. package/.next/standalone/.next/static/chunks/{364cqbpeg1y5i.js → 15uon66hpwbgg.js} +1 -1
  117. package/.next/standalone/.next/static/chunks/{42gwu2bsz4ske.js → 1csubx9gwhsf6.js} +2 -2
  118. package/.next/standalone/.next/static/chunks/27du9n7ssja7l.js +1 -0
  119. package/.next/standalone/.next/static/chunks/2h_pcb1y8_jde.js +1 -0
  120. package/.next/standalone/.next/static/chunks/{2bxr2_2h4kaqq.js → 2pwfrn6_mw-1u.js} +1 -1
  121. package/.next/standalone/app/actions/get-leaks.ts +0 -5
  122. package/.next/standalone/app/actions/get-scheduled-audit.ts +5 -0
  123. package/.next/standalone/app/actions/update-scheduled-audit.ts +18 -57
  124. package/.next/standalone/app/api/auth/status/route.ts +3 -2
  125. package/.next/standalone/app/audit/_components/audit-dashboard.tsx +1 -1
  126. package/.next/standalone/app/audit/_components/empty-state.tsx +1 -1
  127. package/.next/standalone/app/audit/_components/leak-section.tsx +1 -1
  128. package/.next/standalone/app/settings/page.tsx +1 -1
  129. package/.next/standalone/app/settings/settings-client.tsx +50 -45
  130. package/.next/standalone/lib/auth/api-server-client.ts +6 -6
  131. package/.next/standalone/lib/codex-sessions.ts +20 -4
  132. package/.next/standalone/lib/copilot-sessions.ts +32 -1
  133. package/.next/standalone/lib/cursor-sessions.ts +62 -5
  134. package/.next/standalone/package.json +9 -9
  135. package/.next/standalone/server.js +1 -1
  136. package/dist/cli.mjs +991 -1101
  137. package/dist/worker.mjs +175 -382
  138. package/lib/auth/api-server-client.ts +6 -6
  139. package/lib/codex-sessions.ts +20 -4
  140. package/lib/copilot-sessions.ts +32 -1
  141. package/lib/cursor-sessions.ts +62 -5
  142. package/package.json +9 -9
  143. package/pi-extension/index.ts +10 -18
  144. package/src/audit/cli.ts +72 -81
  145. package/src/audit/harm-report.ts +12 -6
  146. package/src/audit/index.ts +3 -1
  147. package/src/audit/leak-fingerprint.ts +2 -4
  148. package/src/audit/leak-record.ts +26 -10
  149. package/src/audit/leak-scan.ts +1 -1
  150. package/src/audit/leak-store.ts +1 -46
  151. package/src/audit/machine-store.ts +8 -9
  152. package/src/audit/macos-notifier.ts +56 -68
  153. package/src/audit/redact-example.ts +2 -0
  154. package/src/audit/report-harm.ts +31 -46
  155. package/src/audit/schedule-cli.ts +17 -33
  156. package/src/audit/types.ts +5 -0
  157. package/src/hooks/builtin-policies.ts +2 -2
  158. package/src/hooks/configure-wizard.ts +36 -1
  159. package/src/hooks/fp-config.ts +29 -54
  160. package/src/hooks/handler.ts +1 -79
  161. package/src/hooks/integrations.ts +4 -15
  162. package/src/hooks/notice.ts +12 -179
  163. package/src/hooks/uninstall-cli.ts +3 -3
  164. package/.next/standalone/.next/server/chunks/ssr/_0oq1dh6._.js +0 -3
  165. package/.next/standalone/.next/static/chunks/04o5zfl7p5lhx.js +0 -1
  166. package/.next/standalone/.next/static/chunks/0qx7gav1c2_vu.js +0 -1
  167. package/src/audit/leak-notice.ts +0 -259
  168. /package/.next/standalone/.next/static/{P6icI2V2PvVuePJrqjHCr → YiPsVpjrc-pEQoN7XvhZ0}/_buildManifest.js +0 -0
  169. /package/.next/standalone/.next/static/{P6icI2V2PvVuePJrqjHCr → YiPsVpjrc-pEQoN7XvhZ0}/_clientMiddlewareManifest.js +0 -0
  170. /package/.next/standalone/.next/static/{P6icI2V2PvVuePJrqjHCr → YiPsVpjrc-pEQoN7XvhZ0}/_ssgManifest.js +0 -0
@@ -8,9 +8,10 @@
8
8
  *
9
9
  * ## CLI ⟷ dashboard parity
10
10
  * - `setAutoAuditAction(enabled)` ⟷ `[audit] auto`
11
+ * - `setAuditNotifyAction(enabled)` ⟷ `[audit] notify`
11
12
  * - `setAuditIntervalAction(days)` ⟷ `[audit] interval_days`
12
13
  *
13
- * Both go through the same `updateConfig` the CLI uses — `failproofai audit
14
+ * All go through the same `updateConfig` the CLI uses — `failproofai audit
14
15
  * --schedule` / `--no-schedule` call it too — so a value set on either side is
15
16
  * byte-identical. That is the whole mechanism behind "the two
16
17
  * surfaces are always in sync": there is one file, one writer function, and no
@@ -18,7 +19,6 @@
18
19
  */
19
20
 
20
21
  import { readConfig, updateConfig } from "@/src/hooks/fp-config";
21
- import { readAuth, whoAmI } from "@/lib/auth/auth-store";
22
22
 
23
23
  /**
24
24
  * The outcome of trying to turn scheduling on.
@@ -34,73 +34,34 @@ import { readAuth, whoAmI } from "@/lib/auth/auth-store";
34
34
  * A returned discriminant survives the boundary, so the caller can open the
35
35
  * sign-in dialog for the one failure that has an obvious next step.
36
36
  */
37
- export type SetAutoAuditResult =
38
- | { ok: true; auto: boolean }
39
- | { ok: false; reason: "signed-out" }
40
- /**
41
- * The session is intact locally and the api-server could not be reached.
42
- *
43
- * Separated from `signed-out` because `whoAmI()` collapses them: it returns
44
- * null for a 401 AND for every transport failure, so an offline machine, a
45
- * proxy that blocks the host, and a genuinely expired token were one answer.
46
- * The user was told "that sign-in expired" and handed a code prompt that
47
- * cannot succeed either — the failure it names is not the failure they have,
48
- * and following its advice costs them a real, working session.
49
- */
50
- | { ok: false; reason: "unreachable" };
37
+ export type SetAutoAuditResult = { ok: true; auto: boolean };
51
38
 
52
39
  /**
53
40
  * Turn the scheduled scan on or off.
54
41
  *
55
- * Turning it ON is refused without a session. Scheduling and mailing are ONE
56
- * decision — the reason to put a scan on a timer is to be told what it found —
57
- * so a machine with the timer set and nobody to tell is a switch that reads as
58
- * on and produces nothing, discoverable only by noticing that no digest ever
59
- * arrives. The caller signs the user in first and retries.
60
- *
61
- * `whoAmI()` asks the SERVER, so this refuses in a case the page cannot see: a
62
- * session file that exists locally but whose refresh token the api-server has
63
- * rejected. The local file is what the page reads to show "reports go to …", so
64
- * the two disagree exactly when a session has expired or was minted against a
65
- * different server — and that disagreement is the common case, not an edge one.
66
- *
67
- * Turning it OFF never checks. An expired session must not be able to trap
68
- * somebody into keeping a feature they are trying to disable.
69
- *
70
- * Note this gates SETTING UP the timer, not the machine's ongoing work: a
71
- * session that later expires leaves the timer running and the local scan
72
- * working, and only the digest stops. See `report-harm.ts`.
42
+ * Scheduling is local and independent of authentication. A signed-in identity
43
+ * adds email delivery; without one the scan and desktop notification continue.
73
44
  *
74
45
  * Returns the value actually stored (re-read), so an optimistic UI can confirm
75
46
  * against the source of truth rather than assume its own guess landed.
76
47
  */
77
48
  export async function setAutoAuditAction(enabled: boolean): Promise<SetAutoAuditResult> {
78
- if (enabled) {
79
- const who = await whoAmI();
80
- if (!who) {
81
- // `whoAmI()` deletes the session on a 401 and leaves it alone on a
82
- // transport failure, so what is left ON DISK is the one thing that tells
83
- // the two apart — no extra request, and nothing new that can fail.
84
- const local = readAuth();
85
- const stillWithinWindow = local && local.refresh_expires_at * 1000 > Date.now();
86
- return { ok: false, reason: stillWithinWindow ? "unreachable" : "signed-out" };
87
- }
88
- }
89
- // Enabling stamps consent in the same write, because the `whoAmI()` above is
90
- // exactly what makes this a consent record rather than a guess: a person was
91
- // present, signed in, and looking at the panel that enumerates what gets
92
- // sent. `reportHarm` gates sending on the stamp, not on `auto`, so a machine
93
- // that inherited `auto` from a release where it meant "scan locally on a
94
- // timer" mails nothing until somebody passes through here or the CLI.
95
- //
96
- // Disabling leaves the stamp alone. It is a record of something that did
97
- // happen, and it grants nothing on its own — sending needs `auto` too.
98
- const next = updateConfig({
99
- audit: enabled ? { auto: true, reportsConsentedAt: Date.now() } : { auto: false },
100
- });
49
+ const next = updateConfig({ audit: { auto: enabled } });
101
50
  return { ok: true, auto: next.audit.auto };
102
51
  }
103
52
 
53
+ /**
54
+ * Turn OS notifications for scheduled credential findings on or off.
55
+ *
56
+ * This does not change the timer or email delivery. It writes the same setting
57
+ * as `failproofai audit --notify` / `--no-notify` and returns the value re-read
58
+ * from the shared config so the dashboard never maintains a second truth.
59
+ */
60
+ export async function setAuditNotifyAction(enabled: boolean): Promise<{ notify: boolean }> {
61
+ const next = updateConfig({ audit: { notify: enabled } });
62
+ return { notify: next.audit.notify };
63
+ }
64
+
104
65
  /**
105
66
  * Set the days between scheduled scans.
106
67
  *
@@ -7,8 +7,9 @@
7
7
  * This keeps the dashboard UI and the CLI consistent regardless of whether
8
8
  * the api-server is reachable.
9
9
  *
10
- * Reminders are gone: the machine now audits itself on a timer and mails a
11
- * digest when it finds harm, so there is nothing to nudge anyone about. The
10
+ * Reminders are gone: the machine now audits itself on a timer and can mail an
11
+ * alert when it finds a credential leak, so there is nothing to nudge anyone
12
+ * about. The
12
13
  * scheduled-scan state lives in `getScheduledAuditAction`, which reads it from
13
14
  * the config and the daemon rather than from here.
14
15
  */
@@ -366,7 +366,7 @@ function MainReport({
366
366
  <AuditReportPlaceholder
367
367
  transcripts={result.transcripts.scanned}
368
368
  events={result.eventsScanned ?? 0}
369
- projects={result.projectsScanned.length}
369
+ projects={result.projectsScanned?.length ?? 0}
370
370
  isRunning={isRunning || rerunStatus.kind === "running"}
371
371
  onRerun={() => onRerun("scan_header")}
372
372
  />
@@ -77,7 +77,7 @@ export function EmptyState({ mode, running, onStarted, onCompleted }: Props) {
77
77
  {/* Was "a tier, a score, and a punch-list" — the tier was never
78
78
  rendered and the score is switched off, so this promised two
79
79
  things the page did not show. */}
80
- or risky action. you&apos;ll get your agent&apos;s archetype and a punch-list.
80
+ or risky action. you&apos;ll get a leak report and a scan summary.
81
81
  </p>
82
82
 
83
83
  <div className="empty-actions">
@@ -155,7 +155,7 @@ export function LeakSection() {
155
155
  <span className="leak-who">{row.cli}</span>
156
156
  {" · leaked "}
157
157
  <span className="leak-when">{when(row.firstSeen)}</span>
158
- {when(row.firstSeen) !== when(row.lastSeen) ? (
158
+ {row.firstSeen !== row.lastSeen ? (
159
159
  <>
160
160
  {" · last seen "}
161
161
  <span className="leak-when">{when(row.lastSeen)}</span>
@@ -30,7 +30,7 @@ export const dynamic = "force-dynamic";
30
30
  export default async function SettingsPage() {
31
31
  // Same gate the audit, policies and projects pages carry. It was dropped in
32
32
  // the rewrite, and this is the page that least deserves to lose it: it shows
33
- // the address digests go to and can sign the machine out, on a dashboard an
33
+ // the address credential alerts go to and can sign the machine out, on a dashboard an
34
34
  // operator may deliberately be exposing beyond localhost.
35
35
  const disabled = (process.env.FAILPROOFAI_DISABLE_PAGES ?? "")
36
36
  .split(",").map((s) => s.trim()).filter(Boolean);
@@ -29,12 +29,8 @@
29
29
  * acts and for anything wrong, mint for the thing that is alive. No third hue,
30
30
  * no new webfont, one hard pixel shadow on the console. That is the budget.
31
31
  *
32
- * ## One switch, not two
33
- *
34
- * Scheduling and mailing are the same decision — the reason to put a scan on a
35
- * timer is to be told what it found. So there is one toggle, it requires a
36
- * sign-in, and "signed out with the timer on" is a real state the page names
37
- * rather than a contradiction it prevents.
32
+ * Scheduling and system notifications are separate machine settings. Turning
33
+ * notifications off must not silently stop the seven-day scan or email alerts.
38
34
  */
39
35
 
40
36
  import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
@@ -44,6 +40,7 @@ import {
44
40
  } from "@/app/actions/get-scheduled-audit";
45
41
  import {
46
42
  setAutoAuditAction,
43
+ setAuditNotifyAction,
47
44
  setAuditIntervalAction,
48
45
  } from "@/app/actions/update-scheduled-audit";
49
46
  import { triggerRun, RerunError } from "@/app/audit/_components/rerun-button";
@@ -187,12 +184,9 @@ function Toggle({
187
184
  * What the scan does, as three labelled lines. This is the old footer paragraph
188
185
  * restructured — same claims, scannable instead of a wall.
189
186
  *
190
- * "sends" ENUMERATES rather than saying "only counts and redacted examples".
191
- * That was very nearly true, and very nearly true is the worse kind: the report
192
- * carries the machine's name too — its hostname, which routinely carries its
193
- * owner's. A list a person can check beats a stronger claim they cannot, and
194
- * this panel is the one place they would come to check. The digest email states
195
- * the same three, in the same order.
187
+ * "sends" names the exact remote payload. The scheduled scan itself stays
188
+ * local, and no report is attempted unless a credential leak exists and the
189
+ * machine has a verified email identity.
196
190
  */
197
191
  const HOW_IT_WORKS: ReadonlyArray<{ label: string; body: string }> = [
198
192
  {
@@ -202,7 +196,7 @@ const HOW_IT_WORKS: ReadonlyArray<{ label: string; body: string }> = [
202
196
  { label: "runs", body: "entirely on this machine. the transcripts never leave it." },
203
197
  {
204
198
  label: "sends",
205
- body: "counts, redacted examples, and this machine's name — and only when a scan finds something harmful.",
199
+ body: "only the newest masked credential exposure, its CLI, time, location, and this machine's name — only when email is configured.",
206
200
  },
207
201
  ];
208
202
 
@@ -211,6 +205,7 @@ export default function SettingsClient({ initial }: { initial: ScheduledAuditVie
211
205
  // about whether scheduled audits are on. See the note in `page.tsx`.
212
206
  const [view, setView] = useState<ScheduledAuditView | null>(initial);
213
207
  const [auto, setAuto] = useState(initial?.auto ?? false);
208
+ const [notify, setNotify] = useState(initial?.notify ?? true);
214
209
  const [intervalDays, setIntervalDays] = useState(initial?.intervalDays ?? 7);
215
210
  const [busy, setBusy] = useState(false);
216
211
  const [running, setRunning] = useState(false);
@@ -254,6 +249,7 @@ export default function SettingsClient({ initial }: { initial: ScheduledAuditVie
254
249
  setView(next);
255
250
  hasView.current = true;
256
251
  setAuto(next.auto);
252
+ setNotify(next.notify);
257
253
  setIntervalDays(next.intervalDays);
258
254
  setNowMs(Date.now());
259
255
  setLoadError(false);
@@ -312,26 +308,6 @@ export default function SettingsClient({ initial }: { initial: ScheduledAuditVie
312
308
  setBusy(true);
313
309
  try {
314
310
  const res = await setAutoAuditAction(true);
315
- if (!res.ok) {
316
- setAuto(false);
317
- if (res.reason === "unreachable") {
318
- // The session is fine and the network is not. Offering a code prompt
319
- // here would name a failure the user does not have and hand them a
320
- // flow that cannot succeed either — and abandoning it mid-way is how
321
- // a working session gets replaced with none at all.
322
- toast("could not reach the server. check your connection and try again.");
323
- return;
324
- }
325
- // The server rejected the session this page had been showing an address
326
- // for — expired, or minted against a different api-server. The local
327
- // file is the only thing that said "signed in", and `whoAmI` has since
328
- // cleared it, so re-read before opening the dialog: otherwise the page
329
- // asks for an email while still displaying one.
330
- await reload();
331
- setAuthOpen(true);
332
- toast("that sign-in expired. one more code and it's on.");
333
- return;
334
- }
335
311
  setAuto(res.auto);
336
312
  toast("scheduled audits on.");
337
313
  await reload();
@@ -360,13 +336,23 @@ export default function SettingsClient({ initial }: { initial: ScheduledAuditVie
360
336
  }
361
337
  return;
362
338
  }
363
- // Turning it on needs somewhere to send the digest.
364
- if (!signedIn) {
365
- setAuthOpen(true);
366
- return;
367
- }
368
339
  await enable();
369
- }, [auto, enable, reload, signedIn]);
340
+ }, [auto, enable, reload]);
341
+
342
+ const onNotifyToggle = useCallback(async () => {
343
+ const requested = !notify;
344
+ setBusy(true);
345
+ try {
346
+ const res = await setAuditNotifyAction(requested);
347
+ setNotify(res.notify);
348
+ setView((v) => (v ? { ...v, notify: res.notify } : v));
349
+ toast(res.notify ? "system notifications on." : "system notifications off.");
350
+ } catch {
351
+ toast(`could not turn system notifications ${requested ? "on" : "off"}.`);
352
+ } finally {
353
+ setBusy(false);
354
+ }
355
+ }, [notify]);
370
356
 
371
357
  const commitInterval = useCallback(
372
358
  async (raw: number) => {
@@ -403,7 +389,7 @@ export default function SettingsClient({ initial }: { initial: ScheduledAuditVie
403
389
  setBusy(true);
404
390
  try {
405
391
  await fetch("/api/auth/logout", { method: "POST" });
406
- toast("signed out. scans continue; digests pause.");
392
+ toast("signed out. scans and desktop notifications continue; email alerts pause.");
407
393
  await reload();
408
394
  } catch {
409
395
  toast("could not sign out.");
@@ -534,7 +520,9 @@ export default function SettingsClient({ initial }: { initial: ScheduledAuditVie
534
520
  </span>
535
521
  <span className="set-dim">
536
522
  {auto
537
- ? "you'll get an email only when a scan finds something."
523
+ ? signedIn
524
+ ? "scheduled scans are active; the latest masked leak is emailed."
525
+ : "scheduled scans are active. add an email below for masked alerts."
538
526
  : "off. nothing runs and nothing is sent."}
539
527
  </span>
540
528
  </div>
@@ -566,6 +554,23 @@ export default function SettingsClient({ initial }: { initial: ScheduledAuditVie
566
554
  </span>
567
555
  </div>
568
556
 
557
+ <div className="set-row set-row-main">
558
+ <Toggle
559
+ enabled={notify}
560
+ disabled={busy || view === null}
561
+ onChange={() => void onNotifyToggle()}
562
+ label={notify ? "turn off system notifications" : "turn on system notifications"}
563
+ />
564
+ <div className="set-row-copy">
565
+ <span className="set-strong">system notifications.</span>
566
+ <span className="set-dim">
567
+ {notify
568
+ ? "on when a scheduled scan finds credentials."
569
+ : "off. scheduled scans and email alerts continue."}
570
+ </span>
571
+ </div>
572
+ </div>
573
+
569
574
  <div className="set-rule" />
570
575
 
571
576
  <div className="set-row set-row-identity">
@@ -593,7 +598,7 @@ export default function SettingsClient({ initial }: { initial: ScheduledAuditVie
593
598
  // from it at all.
594
599
  <>
595
600
  <span className="set-warn">
596
- signed out — scans continue, digests are paused.
601
+ signed out — scheduled scans continue; email alerts are paused.
597
602
  </span>
598
603
  <button
599
604
  type="button"
@@ -601,13 +606,13 @@ export default function SettingsClient({ initial }: { initial: ScheduledAuditVie
601
606
  disabled={busy}
602
607
  onClick={() => setAuthOpen(true)}
603
608
  >
604
- sign in to resume
609
+ add email alerts
605
610
  </button>
606
611
  </>
607
612
  ) : (
608
613
  <span className="set-dim">
609
- turning this on asks for an email, so there is somewhere to
610
- send the report.
614
+ scans and system notifications work without an account.
615
+ add email later if you want alerts in your inbox.
611
616
  </span>
612
617
  )}
613
618
  </div>
@@ -257,7 +257,7 @@ export interface AuditReportBody {
257
257
  * Credentials this machine found in its own transcripts.
258
258
  *
259
259
  * Optional on the wire, so a CLI newer than the api-server sends a field the
260
- * server ignores rather than failing the whole digest — the harmful counts
260
+ * server ignores rather than failing the whole report — the harmful counts
261
261
  * are the older half of the contract and must keep arriving either way.
262
262
  *
263
263
  * Every field here is a mask, a label, a length or a location. There is no
@@ -287,15 +287,15 @@ export interface AuditReportResult {
287
287
  report_id: string;
288
288
  /** Whether this report produced an email. */
289
289
  emailed: boolean;
290
- /** `below_threshold`, `cooldown`, `send_failed`, or null when mail went out. */
290
+ /** `no_leak`, `cooldown`, `send_failed`, or null when mail went out. */
291
291
  reason: string | null;
292
292
  /**
293
293
  * Where the next window starts, per the SERVER.
294
294
  *
295
295
  * Persisted verbatim rather than computed locally. The server anchors it on
296
- * the last DELIVERED digest, so a report held by the cooldown — or one whose
296
+ * the last DELIVERED alert, so a report held by the cooldown — or one whose
297
297
  * send failed — correctly leaves the watermark where it was, and its findings
298
- * turn up in the next digest instead of falling into a gap. A machine that
298
+ * turn up in the next alert instead of falling into a gap. A machine that
299
299
  * lost `machine.json` also resyncs here rather than re-reporting from the
300
300
  * beginning of time.
301
301
  */
@@ -303,11 +303,11 @@ export interface AuditReportResult {
303
303
  }
304
304
 
305
305
  /**
306
- * Submit one scheduled scan's harmful findings.
306
+ * Submit one scheduled scan's harmful findings and newest masked credential.
307
307
  *
308
308
  * Called only by the audit child, and only on `--scheduled`. The destination
309
309
  * address is never sent: the api-server takes it from the access-token claims,
310
- * so a report cannot name where its digest goes.
310
+ * so a report cannot name where its email alert goes.
311
311
  */
312
312
  export async function submitAuditReport(
313
313
  accessToken: string,
@@ -158,6 +158,21 @@ function joinTexts(blocks: CodexContentBlock[] | undefined, wantedType: "input_t
158
158
  .join("\n");
159
159
  }
160
160
 
161
+ /** Text carried by tool outputs. Newer Codex chronicles use an array of
162
+ * `input_text` blocks for `custom_tool_call_output`, while older releases use
163
+ * one string for `function_call_output`. */
164
+ function toolOutputText(output: unknown): string {
165
+ if (typeof output === "string") return output;
166
+ if (Array.isArray(output)) {
167
+ return output
168
+ .filter((block): block is CodexContentBlock => !!block && typeof block === "object")
169
+ .map((block) => typeof block.text === "string" ? block.text : "")
170
+ .filter(Boolean)
171
+ .join("\n");
172
+ }
173
+ return output === undefined ? "" : JSON.stringify(output);
174
+ }
175
+
161
176
  /**
162
177
  * Parse a Codex JSONL transcript into `LogEntry[]` plus the raw lines.
163
178
  * Yields to the event loop every 200 lines so big transcripts don't block.
@@ -250,10 +265,11 @@ export async function parseCodexLog(
250
265
  continue;
251
266
  }
252
267
 
253
- if (subType === "function_call") {
268
+ if (subType === "function_call" || subType === "custom_tool_call") {
254
269
  const callId = payload.call_id as string | undefined;
255
270
  const name = (payload.name as string | undefined) ?? "function_call";
256
- const input = safeJsonParse(payload.arguments as string | undefined);
271
+ const encodedInput = (payload.arguments ?? payload.input) as string | undefined;
272
+ const input = safeJsonParse(encodedInput);
257
273
  const toolUse: ToolUseBlock = {
258
274
  type: "tool_use",
259
275
  id: callId ?? `${timestamp}-${name}`,
@@ -273,7 +289,7 @@ export async function parseCodexLog(
273
289
  continue;
274
290
  }
275
291
 
276
- if (subType === "function_call_output") {
292
+ if (subType === "function_call_output" || subType === "custom_tool_call_output") {
277
293
  const callId = payload.call_id as string | undefined;
278
294
  const block = callId ? toolUseById.get(callId) : undefined;
279
295
  if (block) {
@@ -282,7 +298,7 @@ export async function parseCodexLog(
282
298
  block.result = {
283
299
  timestamp,
284
300
  timestampFormatted: formatTimestamp(date),
285
- content: typeof payload.output === "string" ? (payload.output as string) : JSON.stringify(payload.output),
301
+ content: toolOutputText(payload.output),
286
302
  durationMs: duration,
287
303
  durationFormatted: formatDuration(duration),
288
304
  };
@@ -151,6 +151,11 @@ interface CopilotToolResult {
151
151
  detailedContent?: string;
152
152
  }
153
153
 
154
+ interface CopilotHookToolResult {
155
+ textResultForLlm?: string;
156
+ sessionLog?: string;
157
+ }
158
+
154
159
  interface CopilotToolTelemetry {
155
160
  metrics?: { commandTimeMs?: number; durationMs?: number };
156
161
  properties?: Record<string, unknown>;
@@ -171,6 +176,8 @@ export async function parseCopilotLog(
171
176
  // toolCallId → tool_use block, so we can attach tool.execution_complete back.
172
177
  const toolUseById = new Map<string, ToolUseBlock>();
173
178
  const toolUseStartMs = new Map<string, number>();
179
+ let mostRecentToolUse: ToolUseBlock | undefined;
180
+ let mostRecentToolUseStartMs = 0;
174
181
  let cwd: string | undefined;
175
182
  let seenSessionStart = false;
176
183
 
@@ -273,9 +280,32 @@ export async function parseCopilotLog(
273
280
  toolUseById.set(callId, toolUse);
274
281
  toolUseStartMs.set(callId, date.getTime());
275
282
  }
283
+ mostRecentToolUse = toolUse;
284
+ mostRecentToolUseStartMs = date.getTime();
276
285
  continue;
277
286
  }
278
287
 
288
+ // Copilot CLI 1.0.39 can omit the command's real stdout from
289
+ // `tool.execution_complete` and expose it only to the PostToolUse hook as
290
+ // `input.toolResult.textResultForLlm`. That is the value the model saw and
291
+ // the value failproofai must audit. Keep it on the active tool block; the
292
+ // later completion record may still contribute timing, but must not replace
293
+ // this output with its shorter status-only summary.
294
+ if (recType === "hook.start" && data.hookType === "postToolUse" && mostRecentToolUse) {
295
+ const input = (data.input as Record<string, unknown> | undefined) ?? {};
296
+ const hookResult = (input.toolResult as CopilotHookToolResult | undefined) ?? {};
297
+ const hookContent = hookResult.textResultForLlm ?? hookResult.sessionLog;
298
+ if (typeof hookContent === "string" && hookContent.length > 0) {
299
+ mostRecentToolUse.result = {
300
+ timestamp,
301
+ timestampFormatted: formatTimestamp(date),
302
+ content: hookContent,
303
+ durationMs: Math.max(0, date.getTime() - mostRecentToolUseStartMs),
304
+ durationFormatted: formatDuration(Math.max(0, date.getTime() - mostRecentToolUseStartMs)),
305
+ };
306
+ }
307
+ }
308
+
279
309
  if (recType === "tool.execution_complete") {
280
310
  const callId = data.toolCallId as string | undefined;
281
311
  const block = callId ? toolUseById.get(callId) : undefined;
@@ -289,7 +319,8 @@ export async function parseCopilotLog(
289
319
  typeof reportedMs === "number" && reportedMs >= 0
290
320
  ? reportedMs
291
321
  : Math.max(0, date.getTime() - startMs);
292
- const content = result.detailedContent ?? result.content ?? "";
322
+ const completionContent = result.detailedContent ?? result.content ?? "";
323
+ const content = block.result?.content || completionContent;
293
324
  block.result = {
294
325
  timestamp,
295
326
  timestampFormatted: formatTimestamp(date),
@@ -127,7 +127,15 @@ interface CursorRecord {
127
127
  /** Cursor 2026-04+ transcript shape: `{role, message: {content: [...]}}`. */
128
128
  role?: "user" | "assistant" | "system" | string;
129
129
  message?: {
130
- content?: Array<{ type?: string; text?: string }>;
130
+ content?: Array<{
131
+ type?: string;
132
+ text?: string;
133
+ id?: string;
134
+ name?: string;
135
+ input?: Record<string, unknown>;
136
+ tool_use_id?: string;
137
+ content?: unknown;
138
+ }>;
131
139
  };
132
140
  }
133
141
 
@@ -183,11 +191,36 @@ export async function parseCursorLog(
183
191
  if (!raw.type && raw.role && raw.message?.content) {
184
192
  const synthDate = new Date(SYNTH_T0 + i);
185
193
  const synthTs = synthDate.toISOString();
186
- const textParts = raw.message.content
194
+ const messageContent = raw.message.content;
195
+ const textParts = messageContent
187
196
  .filter((c) => c?.type === "text" && typeof c.text === "string")
188
197
  .map((c) => c.text!)
189
198
  .join("");
190
199
  if (raw.role === "user") {
200
+ // Some Cursor builds emit Claude-style tool_result blocks in the next
201
+ // user record. Pair them before treating any remaining text as a user
202
+ // turn so command output is available to the credential scanner.
203
+ let attachedResult = false;
204
+ for (const block of messageContent) {
205
+ if (block?.type !== "tool_result") continue;
206
+ const callId = typeof block.tool_use_id === "string" ? block.tool_use_id : undefined;
207
+ const toolUse = callId ? toolUseById.get(callId) : undefined;
208
+ if (!toolUse) continue;
209
+ const durationMs = Math.max(
210
+ 0,
211
+ synthDate.getTime() - (toolUseStartMs.get(callId!) ?? synthDate.getTime()),
212
+ );
213
+ toolUse.result = {
214
+ timestamp: synthTs,
215
+ timestampFormatted: formatTimestamp(synthDate),
216
+ content: typeof block.content === "string"
217
+ ? block.content
218
+ : block.content == null ? "" : JSON.stringify(block.content),
219
+ durationMs,
220
+ durationFormatted: formatDuration(durationMs),
221
+ };
222
+ attachedResult = true;
223
+ }
191
224
  // Strip the synthesized `<timestamp>...</timestamp>\n<user_query>...\n</user_query>`
192
225
  // wrapper Cursor adds for context — keep just the user_query body.
193
226
  const queryMatch = /<user_query>\s*([\s\S]*?)\s*<\/user_query>/.exec(textParts);
@@ -198,13 +231,37 @@ export async function parseCursorLog(
198
231
  ...baseEntry(rawCopy, synthTs, synthDate, source),
199
232
  message: { role: "user", content: text },
200
233
  } satisfies UserEntry);
234
+ } else if (!attachedResult) {
235
+ entries.push({
236
+ type: "system",
237
+ ...baseEntry(rawCopy, synthTs, synthDate, source),
238
+ raw: rawCopy,
239
+ } satisfies GenericEntry);
201
240
  }
202
241
  continue;
203
242
  }
204
243
  if (raw.role === "assistant") {
205
- const blocks: ContentBlock[] = textParts
206
- ? [{ type: "text", text: textParts }]
207
- : [];
244
+ const blocks: ContentBlock[] = [];
245
+ if (textParts) blocks.push({ type: "text", text: textParts });
246
+ for (let j = 0; j < messageContent.length; j++) {
247
+ const contentBlock = messageContent[j];
248
+ if (contentBlock?.type !== "tool_use") continue;
249
+ const name = typeof contentBlock.name === "string" ? contentBlock.name : "tool";
250
+ const id = typeof contentBlock.id === "string" && contentBlock.id
251
+ ? contentBlock.id
252
+ : `cursor-${i}-${name}-${j}`;
253
+ const toolUse: ToolUseBlock = {
254
+ type: "tool_use",
255
+ id,
256
+ name,
257
+ input: contentBlock.input && typeof contentBlock.input === "object"
258
+ ? contentBlock.input
259
+ : {},
260
+ };
261
+ blocks.push(toolUse);
262
+ toolUseById.set(id, toolUse);
263
+ toolUseStartMs.set(id, synthDate.getTime());
264
+ }
208
265
  if (blocks.length === 0) {
209
266
  entries.push({
210
267
  type: "system",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "failproofai",
3
- "version": "1.0.4-beta.4",
3
+ "version": "1.0.4-beta.7",
4
4
  "description": "Observability and enforcement for AI agent harnesses. 39 built-in policies hooked into 12 of them — Claude Code, Codex, Cursor, Hermes, OpenClaw and more — blocking the tool call before it runs. Local dashboard included, no account needed.",
5
5
  "bin": {
6
6
  "failproofai": "./dist/cli.mjs",
@@ -121,15 +121,15 @@
121
121
  "browserslist": "4.28.8"
122
122
  },
123
123
  "optionalDependencies": {
124
- "@failproofai/failproofaid-linux-x64": "1.0.4-beta.4",
125
- "@failproofai/failproofaid-linux-arm64": "1.0.4-beta.4",
126
- "@failproofai/failproofaid-darwin-x64": "1.0.4-beta.4",
127
- "@failproofai/failproofaid-darwin-arm64": "1.0.4-beta.4"
124
+ "@failproofai/failproofaid-linux-x64": "1.0.4-beta.7",
125
+ "@failproofai/failproofaid-linux-arm64": "1.0.4-beta.7",
126
+ "@failproofai/failproofaid-darwin-x64": "1.0.4-beta.7",
127
+ "@failproofai/failproofaid-darwin-arm64": "1.0.4-beta.7"
128
128
  },
129
129
  "failproofaidBinaries": {
130
- "linux-x64": "4487790ed9b881da2914b5985a23b5adca1f20e226d71c635d8170064e6b2340",
131
- "linux-arm64": "c903c5e201198213ccd8295fdab741c7d08d22c8dd5c276e52aa766595bedcc2",
132
- "darwin-x64": "f0933584abbf0f9ff95cd153f8c6c704e467af1d6ffc8f42f9c426bd44b1142a",
133
- "darwin-arm64": "387a3acbf13f667a557c8ac632fe67dee350cda078e3266e71edfcfacb9ecae6"
130
+ "linux-x64": "e59735a8f94cd8ac697b2bd67aafdd8d76a8394d53db229876980cc13a18f07e",
131
+ "linux-arm64": "b9ce50dd2f79b55f4f7112add265a776a4a6d002c2a56f971e666fbb796f3906",
132
+ "darwin-x64": "b46efc8ec33945a5cc26b7bb288fb87cea65b5983bd83094b5e607d53b8eda4c",
133
+ "darwin-arm64": "a8cc6112cee5ca8a7d517900e9ce32118855135980f22979fa0ff7aa6f68d954"
134
134
  }
135
135
  }