@solongate/proxy 0.81.43 → 0.81.44

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/dist/index.js CHANGED
@@ -7706,20 +7706,45 @@ function LivePanel({ active: active2 }) {
7706
7706
  }, [active2, frozen]);
7707
7707
  const startRef = useRef2(Date.now());
7708
7708
  const lastNotifyAt = useRef2(0);
7709
+ const toastQueue = useRef2(/* @__PURE__ */ new Map());
7710
+ const toastTimer = useRef2(null);
7711
+ const TOAST_RANK = { "DLP hit": 0, "Call denied": 1, "Rate-limit burst": 2 };
7712
+ const flushToasts = useCallback2(function flush() {
7713
+ toastTimer.current = null;
7714
+ const q2 = toastQueue.current;
7715
+ if (!q2.size) return;
7716
+ const wait = 3e3 - (Date.now() - lastNotifyAt.current);
7717
+ if (wait > 0) {
7718
+ toastTimer.current = setTimeout(flush, wait);
7719
+ return;
7720
+ }
7721
+ lastNotifyAt.current = Date.now();
7722
+ const items = [...q2.entries()].sort((a, b) => (TOAST_RANK[a[0]] ?? 9) - (TOAST_RANK[b[0]] ?? 9));
7723
+ q2.clear();
7724
+ try {
7725
+ process.stdout.write("\x07");
7726
+ } catch {
7727
+ }
7728
+ const total = items.reduce((n, [, v]) => n + v.count, 0);
7729
+ if (items.length === 1 && total === 1) desktopNotify(items[0][0], items[0][1].msg);
7730
+ else desktopNotify("Security alerts", items.map(([t, v]) => `${v.count}\xD7 ${t}`).join(" \xB7 "));
7731
+ }, []);
7732
+ useEffect2(
7733
+ () => () => {
7734
+ if (toastTimer.current) clearTimeout(toastTimer.current);
7735
+ },
7736
+ []
7737
+ );
7709
7738
  const fireAlert = useCallback2(
7710
7739
  (id, title, msg, level = "warn", desktop = true) => {
7711
7740
  pushLog(`${level === "bad" ? "\u26D4" : "\u23F8"} ${msg}`, level);
7712
7741
  setAlerts((a) => [...a.filter((x) => x.id !== id), { id, msg, level, until: Date.now() + 15e3 }].slice(-4));
7713
7742
  if (!desktop || !CONFIG.notifications) return;
7714
- if (Date.now() - lastNotifyAt.current < 3e3) return;
7715
- lastNotifyAt.current = Date.now();
7716
- try {
7717
- process.stdout.write("\x07");
7718
- } catch {
7719
- }
7720
- desktopNotify(title, msg);
7743
+ const cur = toastQueue.current.get(title);
7744
+ toastQueue.current.set(title, { count: (cur?.count ?? 0) + 1, msg: cur?.msg ?? msg });
7745
+ if (!toastTimer.current) toastTimer.current = setTimeout(flushToasts, 400);
7721
7746
  },
7722
- [pushLog]
7747
+ [pushLog, flushToasts]
7723
7748
  );
7724
7749
  useEffect2(() => {
7725
7750
  if (!active2) return;
package/dist/tui/index.js CHANGED
@@ -1142,20 +1142,45 @@ function LivePanel({ active: active2 }) {
1142
1142
  }, [active2, frozen]);
1143
1143
  const startRef = useRef2(Date.now());
1144
1144
  const lastNotifyAt = useRef2(0);
1145
+ const toastQueue = useRef2(/* @__PURE__ */ new Map());
1146
+ const toastTimer = useRef2(null);
1147
+ const TOAST_RANK = { "DLP hit": 0, "Call denied": 1, "Rate-limit burst": 2 };
1148
+ const flushToasts = useCallback2(function flush() {
1149
+ toastTimer.current = null;
1150
+ const q2 = toastQueue.current;
1151
+ if (!q2.size) return;
1152
+ const wait = 3e3 - (Date.now() - lastNotifyAt.current);
1153
+ if (wait > 0) {
1154
+ toastTimer.current = setTimeout(flush, wait);
1155
+ return;
1156
+ }
1157
+ lastNotifyAt.current = Date.now();
1158
+ const items = [...q2.entries()].sort((a, b) => (TOAST_RANK[a[0]] ?? 9) - (TOAST_RANK[b[0]] ?? 9));
1159
+ q2.clear();
1160
+ try {
1161
+ process.stdout.write("\x07");
1162
+ } catch {
1163
+ }
1164
+ const total = items.reduce((n, [, v]) => n + v.count, 0);
1165
+ if (items.length === 1 && total === 1) desktopNotify(items[0][0], items[0][1].msg);
1166
+ else desktopNotify("Security alerts", items.map(([t, v]) => `${v.count}\xD7 ${t}`).join(" \xB7 "));
1167
+ }, []);
1168
+ useEffect2(
1169
+ () => () => {
1170
+ if (toastTimer.current) clearTimeout(toastTimer.current);
1171
+ },
1172
+ []
1173
+ );
1145
1174
  const fireAlert = useCallback2(
1146
1175
  (id, title, msg, level = "warn", desktop = true) => {
1147
1176
  pushLog(`${level === "bad" ? "\u26D4" : "\u23F8"} ${msg}`, level);
1148
1177
  setAlerts((a) => [...a.filter((x) => x.id !== id), { id, msg, level, until: Date.now() + 15e3 }].slice(-4));
1149
1178
  if (!desktop || !CONFIG.notifications) return;
1150
- if (Date.now() - lastNotifyAt.current < 3e3) return;
1151
- lastNotifyAt.current = Date.now();
1152
- try {
1153
- process.stdout.write("\x07");
1154
- } catch {
1155
- }
1156
- desktopNotify(title, msg);
1179
+ const cur = toastQueue.current.get(title);
1180
+ toastQueue.current.set(title, { count: (cur?.count ?? 0) + 1, msg: cur?.msg ?? msg });
1181
+ if (!toastTimer.current) toastTimer.current = setTimeout(flushToasts, 400);
1157
1182
  },
1158
- [pushLog]
1183
+ [pushLog, flushToasts]
1159
1184
  );
1160
1185
  useEffect2(() => {
1161
1186
  if (!active2) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.81.43",
3
+ "version": "0.81.44",
4
4
  "description": "AI tool security proxy: protect any AI tool server with customizable policies, path/command constraints, rate limiting, and audit logging. No code changes required.",
5
5
  "type": "module",
6
6
  "bin": {