Files
Shadowbroker/frontend/src/hooks/useRuntimeProfile.ts
T
Shadowbroker cfbeabda1e Feat/gt analytics openclaw (#392)
* feat(telegram): auto-translate OSINT channel posts to English

Cherry-picked from @Bobpick PR #391 (telegram-only slice): server-side translation during fetch, SHOW ORIGINAL toggle in TelegramOsintPopup, and on-demand /api/telegram-feed?lang=.

Co-authored-by: Robert Pickett <bobpickettsr@yahoo.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

* feat(gt): experimental Derived OSINT analytics with lean-node safeguards

Cherry-picked from @Bobpick PR #391 (GT + OpenClaw slice): Bayesian strategic-risk engine, map overlay, OpenClaw commands, and telegram_rhetoric watchdog. Off by default (GT_ANALYTICS_ENABLED=false, gt_risk layer false). 1 vCPU nodes get cgroup detection, UI warning on layer toggle, and lean profile that skips scheduled ingest/Louvain unless GT_ANALYTICS_ACK_LOW_CPU=true. Backtest HUD removed from dashboard (OpenClaw/API regression only).

Co-authored-by: Robert Pickett <bobpickettsr@yahoo.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Robert Pickett <bobpickettsr@yahoo.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 17:05:46 -06:00

61 lines
1.5 KiB
TypeScript

'use client';
import { useEffect, useState } from 'react';
import { API_BASE } from '@/lib/api';
export interface RuntimeGtAnalytics {
enabled?: boolean;
operational?: boolean;
profile?: string;
lean_node?: boolean;
recommended?: boolean;
warning?: string | null;
experimental?: boolean;
}
export interface RuntimeProfile {
profile?: string;
cpu_limit?: number | null;
memory_limit_mb?: number | null;
gt_analytics?: RuntimeGtAnalytics;
}
export function useRuntimeProfile(): RuntimeProfile | null {
const [runtime, setRuntime] = useState<RuntimeProfile | null>(null);
useEffect(() => {
let cancelled = false;
const load = async () => {
try {
const res = await fetch(`${API_BASE}/api/health`, { cache: 'no-store' });
if (!res.ok || cancelled) return;
const body = await res.json();
if (!cancelled && body?.runtime) {
setRuntime(body.runtime as RuntimeProfile);
}
} catch {
/* health unavailable during boot */
}
};
void load();
const timer = window.setInterval(load, 60_000);
return () => {
cancelled = true;
window.clearInterval(timer);
};
}, []);
return runtime;
}
export function gtLeanLayerWarning(runtime: RuntimeProfile | null): string | null {
const gt = runtime?.gt_analytics;
if (!gt?.lean_node) return null;
return (
gt.warning ||
'This node is capped at 1 vCPU. Enabling Strategic Risk (Derived OSINT) may slow OSINT fetches.'
);
}