Add MKT opt-in on threat intercept, jittered market fetches, and Sentinel multi-scene dossier.

Operators enable Polymarket/Kalshi correlation from Global Threat Intercept with a consent dialog; polls use a jittered schedule separate from the slow tier. Right-click Sentinel imagery returns up to three signed scenes again.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
BigBodyCobain
2026-06-04 09:01:21 -06:00
parent 3ac8442e4b
commit 80a01275ff
12 changed files with 536 additions and 36 deletions
@@ -0,0 +1,54 @@
'use client';
import { useCallback, useEffect, useState } from 'react';
import { API_BASE } from '@/lib/api';
export type PredictionMarketsStatus = {
enabled: boolean;
ui_opted_in: boolean;
env_override: 'on' | 'off' | null;
jitter?: {
scheduler_interval_minutes: number;
scheduler_jitter_seconds: number;
pre_fetch_jitter_seconds: number;
};
};
export function usePredictionMarketsOptIn(enabled = true) {
const [status, setStatus] = useState<PredictionMarketsStatus | null>(null);
const refreshStatus = useCallback(async () => {
try {
const res = await fetch(`${API_BASE}/api/prediction-markets/status`);
if (!res.ok) return;
const body = (await res.json()) as PredictionMarketsStatus;
setStatus(body);
} catch {
// Backend may still be starting.
}
}, []);
useEffect(() => {
if (!enabled) return;
void refreshStatus();
}, [enabled, refreshStatus]);
const setOptIn = useCallback(
async (optedIn: boolean) => {
const res = await fetch(`${API_BASE}/api/prediction-markets/opt-in`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ opted_in: optedIn }),
});
if (!res.ok) {
throw new Error(`Prediction markets opt-in failed (${res.status})`);
}
const body = (await res.json()) as PredictionMarketsStatus;
setStatus(body);
return body;
},
[],
);
return { status, refreshStatus, setOptIn };
}