Spaces:
Sleeping
Sleeping
Merge upstream main, preferring our changes
Browse filesFiles changed (21)
- feature-flag-agent-env/agents/rl_agent.py+53-27
- feature-flag-agent-env/feature_flag_env/tools/connectors.py-1
- feature-flag-agent-env/pyproject.toml-1
- feature-flag-agent-env/requirements.txt-1
- frontend/app/ai-decisions/page.tsx+7
- frontend/app/integrations/page.tsxAdded+143
- frontend/app/layout.tsx+1-2
- frontend/app/page.tsx+88-38
- frontend/components/layout/sidebar.tsx+6
- frontend/components/theme-provider.tsx+63-3
- frontend/components/theme-toggle.tsx+1-1
- frontend/lib/api.ts+5-1
- node_modules/frontend/app/ai-decisions/page.tsx+7
- node_modules/frontend/app/integrations/page.tsxAdded+143
- node_modules/frontend/app/layout.tsx+1-2
- node_modules/frontend/app/page.tsx+88-38
- node_modules/frontend/components/layout/sidebar.tsx+6
- node_modules/frontend/components/theme-provider.tsx+63-3
- node_modules/frontend/components/theme-toggle.tsx+1-1
- node_modules/frontend/lib/api.ts+5-1
- pyproject.toml-1
6 unmodified lines7891011121314151617181920212223242526272829303132333435363738100 unmodified lines139140141142143144145146147148149150151152215 unmodified lines36836937037137237339 unmodified lines413414415416417418138 unmodified lines5575585595605615627 unmodified lines5705715725735745756 unmodified linesfrom feature_flag_env.models import FeatureFlagAction, FeatureFlagObservationfrom agents.replay_buffer import ReplayBuffertry:import torchimport torch.nn as nnimport torch.optim as optimfrom torch.nn.utils import clip_grad_norm_except ImportError as exc:raise ImportError("PyTorch is required for RLAgent. Install with: pip install torch") from excclass DQN(nn.Module):def __init__(self, state_dim: int, action_dim: int):super().__init__()self.net = nn.Sequential(nn.Linear(state_dim, 128),nn.ReLU(),nn.Linear(128, 64),nn.ReLU(),nn.Linear(64, 32),nn.ReLU(),nn.Linear(32, action_dim),)def forward(self, x):return self.net(x)class RLAgent:100 unmodified linesself.action_mask_events = 0self.action_safety_overrides = 0self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")self.policy_net = DQN(self.state_dim, self.action_dim).to(self.device)self.target_net = DQN(self.state_dim, self.action_dim).to(self.device)self.target_net.load_state_dict(self.policy_net.state_dict())self.target_net.eval()self.optimizer = optim.Adam(self.policy_net.parameters(), lr=lr)self.loss_fn = nn.MSELoss()self.replay_buffer = ReplayBuffer(capacity=buffer_capacity)self.external_transition_mode = False215 unmodified linesif self.training and random.random() < self.epsilon:return int(random.choice(allowed_actions))with torch.no_grad():state_tensor = torch.from_numpy(state).float().unsqueeze(0).to(self.device)q_values = self.policy_net(state_tensor)39 unmodified lines)def _optimize_model(self):if len(self.replay_buffer) < self.batch_size:return None138 unmodified linesself.last_action = Nonedef save_model(self, model_path: Optional[str] = None):path = model_path or self.model_pathos.makedirs(os.path.dirname(path), exist_ok=True)torch.save(7 unmodified lines)def load_model(self, model_path: Optional[str] = None):path = model_path or self.model_pathcheckpoint = torch.load(path, map_location=self.device)6 unmodified lines7891011121314151617181920212223242526272829303132333435363738394041424344454647100 unmodified lines148149150151152153154155156157158159160161162163164165166167168169215 unmodified lines38538638738838939039139239339 unmodified lines433434435436437438439440138 unmodified lines5795805815825835845855867 unmodified lines5945955965975985996006016 unmodified linesfrom feature_flag_env.models import FeatureFlagAction, FeatureFlagObservationfrom agents.replay_buffer import ReplayBufferTORCH_AVAILABLE = Truetry:import torchimport torch.nn as nnimport torch.optim as optimfrom torch.nn.utils import clip_grad_norm_except ImportError:TORCH_AVAILABLE = Falsetorch = Nonenn = Noneoptim = Noneclip_grad_norm_ = Noneif TORCH_AVAILABLE:class DQN(nn.Module):def __init__(self, state_dim: int, action_dim: int):super().__init__()self.net = nn.Sequential(nn.Linear(state_dim, 128),nn.ReLU(),nn.Linear(128, 64),nn.ReLU(),nn.Linear(64, 32),nn.ReLU(),nn.Linear(32, action_dim),)def forward(self, x):return self.net(x)else:class DQN:def __init__(self, state_dim: int, action_dim: int):self.state_dim = state_dimself.action_dim = action_dimclass RLAgent:100 unmodified linesself.action_mask_events = 0self.action_safety_overrides = 0self.torch_available = TORCH_AVAILABLEif self.torch_available:self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")self.policy_net = DQN(self.state_dim, self.action_dim).to(self.device)self.target_net = DQN(self.state_dim, self.action_dim).to(self.device)self.target_net.load_state_dict(self.policy_net.state_dict())self.target_net.eval()self.optimizer = optim.Adam(self.policy_net.parameters(), lr=lr)self.loss_fn = nn.MSELoss()else:self.device = "cpu"self.policy_net = Noneself.target_net = Noneself.optimizer = Noneself.loss_fn = Noneself.replay_buffer = ReplayBuffer(capacity=buffer_capacity)self.external_transition_mode = False215 unmodified linesif self.training and random.random() < self.epsilon:return int(random.choice(allowed_actions))if not self.torch_available:return int(random.choice(allowed_actions))with torch.no_grad():state_tensor = torch.from_numpy(state).float().unsqueeze(0).to(self.device)q_values = self.policy_net(state_tensor)39 unmodified lines)def _optimize_model(self):if not self.torch_available:return Noneif len(self.replay_buffer) < self.batch_size:return None138 unmodified linesself.last_action = Nonedef save_model(self, model_path: Optional[str] = None):if not self.torch_available:returnpath = model_path or self.model_pathos.makedirs(os.path.dirname(path), exist_ok=True)torch.save(7 unmodified lines)def load_model(self, model_path: Optional[str] = None):if not self.torch_available:returnpath = model_path or self.model_pathcheckpoint = torch.load(path, map_location=self.device)
7 unmodified lines8910111213147 unmodified linesfrom abc import ABC, abstractmethodfrom typing import Dict, Any, Optionalimport timeclass Connector(ABC):7 unmodified lines89101112137 unmodified linesfrom abc import ABC, abstractmethodfrom typing import Dict, Any, Optionalclass Connector(ABC):
17 unmodified lines1819202122232417 unmodified lines# 🧮 Math & Simulation"numpy>=1.24.0","torch>=2.0.0",# 🤖 LLM Integration (OpenAI-compatible client)"groq>=0.4.0",17 unmodified lines18192021222317 unmodified lines# 🧮 Math & Simulation"numpy>=1.24.0",# 🤖 LLM Integration (OpenAI-compatible client)"groq>=0.4.0",
20 unmodified lines2122232425262720 unmodified lines# Math & Simulationnumpy>=1.24.0torch>=2.0.0# LLM Integrationgroq>=0.4.020 unmodified lines21222324252620 unmodified lines# Math & Simulationnumpy>=1.24.0# LLM Integrationgroq>=0.4.0
192 unmodified lines19319419519619719841 unmodified lines240241242243244245192 unmodified lines<div className="space-y-0">{recentDecisions.length > 0 ? (recentDecisions.map((step, i) => (<div key={i} className="flex gap-4 border-b border-border/30 last:border-0 py-4 group"><div className="flex flex-col items-center"><div className="h-8 w-8 rounded-full bg-muted flex items-center justify-center text-[10px] font-bold">41 unmodified lines</div></div></div>))) : (<div className="py-20 text-center text-muted-foreground flex flex-col items-center gap-4">192 unmodified lines19319419519619719819920020120220341 unmodified lines245246247248249250251252192 unmodified lines<div className="space-y-0">{recentDecisions.length > 0 ? (recentDecisions.map((step, i) => ((() => {const actionType = step.action?.action_type ?? "MAINTAIN";const targetPercentage = step.action?.target_percentage ?? 0;const reason = step.action?.reason ?? "No reasoning provided.";return (<div key={i} className="flex gap-4 border-b border-border/30 last:border-0 py-4 group"><div className="flex flex-col items-center"><div className="h-8 w-8 rounded-full bg-muted flex items-center justify-center text-[10px] font-bold">41 unmodified lines</div></div></div>);})()))) : (<div className="py-20 text-center text-muted-foreground flex flex-col items-center gap-4">
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143"use client";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import { MessageSquare, GitGraph, ExternalLink, RefreshCw, Bell} from "lucide-react";import { useEffect, useState } from "react";import { api } from "@/lib/api";
const IntegrationsPage = () => { const [loading, setLoading] = useState(false); const [lastSync, setLastSync] = useState("Never"); const [isHealthy, setIsHealthy] = useState(false);
const syncIntegrations = async () => { setLoading(true); try { const [health] = await Promise.all([ api.getHealth(), api.getDashboard(), ]); setIsHealthy(Boolean(health?.environment_ready)); setLastSync(new Date().toLocaleTimeString()); } catch (error) { console.error("Failed to sync integration status:", error); setIsHealthy(false); setLastSync("Sync failed"); } finally { setLoading(false); } };
useEffect(() => { const initialSync = setTimeout(() => { void syncIntegrations(); }, 0); return () => clearTimeout(initialSync); }, []);
const integrations = [ { id: "slack", name: "Slack", description: "Automated rollout notifications and approval workflows.", icon: MessageSquare, status: isHealthy ? "connected" : "disconnected", details: isHealthy ? "Alerts can be routed through backend automation" : "Backend unavailable", lastSync }, { id: "github", name: "GitHub", description: "Trigger rollouts from PRs and sync deployment status.", icon: GitGraph, status: "disconnected", details: "Requires OAuth", lastSync } ];
return ( <div className="flex-1 space-y-6 p-8"> <div className="flex items-center justify-between"> <div> <h1 className="text-3xl font-bold tracking-tight">Integrations</h1> <p className="text-muted-foreground mt-1">Manage external connections and observability sync.</p> </div> <Button variant="outline" size="sm" className="rounded-full" onClick={syncIntegrations} disabled={loading}> <RefreshCw className={`mr-2 h-4 w-4 ${loading ? "animate-spin" : ""}`} /> {loading ? "Syncing..." : "Sync All"} </Button> </div>
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3"> {integrations.map((item) => ( <Card key={item.id} className="border-border/50 bg-card/50"> <CardHeader className="pb-3"> <div className="flex items-center justify-between"> <div className="flex h-10 w-10 items-center justify-center rounded-lg bg-muted/50"> <item.icon className="h-6 w-6 text-primary" /> </div> <Badge variant={item.status === "connected" ? "default" : "secondary"} className={item.status === "connected" ? "bg-green-500/10 text-green-600 hover:bg-green-500/10" : ""} > {item.status === "connected" ? "Connected" : "Disconnected"} </Badge> </div> <CardTitle className="mt-4">{item.name}</CardTitle> <CardDescription>{item.description}</CardDescription> </CardHeader> <CardContent> <div className="space-y-4"> <div className="flex items-center justify-between text-sm"> <span className="text-muted-foreground">Status</span> <span className="font-medium">{item.details}</span> </div> <div className="flex items-center justify-between text-sm"> <span className="text-muted-foreground">Last Sync</span> <span className="text-xs">{item.lastSync}</span> </div> <div className="pt-4 flex gap-2"> <Button variant="outline" className="w-full text-xs h-8 rounded-full"> Configure </Button> <Button variant="ghost" size="icon" className="h-8 w-8 rounded-full"> <ExternalLink className="h-4 w-4" /> </Button> </div> </div> </CardContent> </Card> ))} </div>
<Card className="border-primary/20 bg-primary/5"> <CardHeader> <CardTitle className="flex items-center gap-2 text-primary"> <Bell className="h-5 w-5" /> Webhook Endpoints </CardTitle> <CardDescription>Receive automated alerts from your own infrastructure.</CardDescription> </CardHeader> <CardContent> <div className="rounded-lg border bg-background/50 p-4 font-mono text-xs"> GET {(api.getApiBaseUrl() || "http://localhost:8000")}/monitoring/alerts </div> <p className="text-[10px] text-muted-foreground mt-4"> Uses live backend monitoring routes for alert ingestion and observability polling. </p> </CardContent> </Card> </div> );};
export default IntegrationsPage;29 unmodified lines303132333435363729 unmodified lines<body className="min-h-full flex flex-col font-sans"><ThemeProviderattribute="class"defaultTheme="system"enableSystemdisableTransitionOnChange><EnvProvider>29 unmodified lines3031323334353629 unmodified lines<body className="min-h-full flex flex-col font-sans"><ThemeProviderattribute="class"defaultTheme="dark"disableTransitionOnChange><EnvProvider>
15 unmodified lines161718192021224 unmodified lines2728293031325 unmodified lines38394041424335 unmodified lines798081828384858687888990919293949596979899100101102 unmodified lines2042052062072082092102112122132144 unmodified lines21922022122222322422522622722822923023123223323423523623723823956 unmodified lines29629729829930030130230330415 unmodified linesimport {Area,AreaChart,ResponsiveContainer,Tooltip,XAxis,YAxis,4 unmodified lines} from "recharts";import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";import { Badge } from "@/components/ui/badge";import { Progress } from "@/components/ui/progress";import { useMemo } from "react";import { Observation } from "@/lib/api";5 unmodified linesconst { dashboard: data, state, connectionState, connectionText } = useEnv();const loading = useMemo(() => connectionState === "checking" && !data && !state, [connectionState, data, state]);const lastObs: Observation | undefined = state?.history?.[state.history.length - 1]?.observation;const healthScore = lastObs?.system_health_score ?? data?.summary?.health_score ?? 0;35 unmodified lines<h1 className="text-3xl font-bold tracking-tight">Enterprise Overview</h1><p className="text-muted-foreground mt-1">Real-time autonomous deployment monitoring.</p></div><Badgevariant="outline"className={cn("px-4 py-1.5 rounded-full border-2",connectionState === "connected"? "border-green-500/30 text-green-600 bg-green-50": connectionState === "disconnected"? "border-destructive/30 text-destructive bg-destructive/5": "")}><div className={cn("w-2 h-2 rounded-full mr-2 animate-pulse",connectionState === "connected" ? "bg-green-500" : "bg-destructive")} />{loading ? "Syncing..." : connectionText}</Badge></div>{/* Primary Metrics */}102 unmodified lines<div className="grid gap-6 md:grid-cols-7">{/* Main Traffic Chart */}<Card className="md:col-span-4 border-border/50 bg-card/50 shadow-sm"><CardHeader><CardTitle className="flex items-center justify-between">Evaluation Traffic<Badge variant="outline" className="font-normal text-xs">Live Stream</Badge></CardTitle>4 unmodified lines<AreaChart data={state?.history?.map(h => ({time: h.observation?.time_step,rollout: h.observation?.current_rollout_percentage,error: (h.observation?.error_rate ?? 0) * 10000 // scaling for visibility})) || []}><defs><linearGradient id="colorRollout" x1="0" y1="0" x2="0" y2="1"><stop offset="5%" stopColor="var(--primary)" stopOpacity={0.2}/><stop offset="95%" stopColor="var(--primary)" stopOpacity={0}/></linearGradient></defs><CartesianGrid strokeDasharray="3 3" vertical={false} stroke="var(--border)" opacity={0.5} /><XAxis dataKey="time" stroke="var(--muted-foreground)" fontSize={10} tickLine={false} axisLine={false} /><YAxis stroke="var(--muted-foreground)" fontSize={10} tickLine={false} axisLine={false} /><Tooltip /><Area type="monotone" dataKey="rollout" stroke="var(--primary)" strokeWidth={2} fill="url(#colorRollout)" /></AreaChart></ResponsiveContainer></div></CardContent></Card>56 unmodified lines<Card className="border-border/50 bg-card/50 col-span-2"><CardHeader className="pb-2"><CardTitle className="text-sm font-medium flex items-center gap-2"><ShieldAlert className="h-4 w-4 text-red-500" />Active Alerts & Incidents</CardTitle></CardHeader><CardContent>15 unmodified lines1617181920214 unmodified lines262728293031325 unmodified lines383940414243444546474849505135 unmodified lines87888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128102 unmodified lines2312322332342352362372382392402414 unmodified lines24624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128256 unmodified lines33934034134234334434534634734834935035135235335415 unmodified linesimport {Area,AreaChart,Tooltip,XAxis,YAxis,4 unmodified lines} from "recharts";import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import { Progress } from "@/components/ui/progress";import { useMemo } from "react";import { Observation } from "@/lib/api";5 unmodified linesconst { dashboard: data, state, connectionState, connectionText } = useEnv();const loading = useMemo(() => connectionState === "checking" && !data && !state, [connectionState, data, state]);useEffect(() => {let simInterval: NodeJS.Timeout;if (isSimulating) {simInterval = setInterval(runSimulationStep, 2000);}return () => clearInterval(simInterval);}, [isSimulating, state]);const lastObs: Observation | undefined = state?.history?.[state.history.length - 1]?.observation;const healthScore = lastObs?.system_health_score ?? data?.summary?.health_score ?? 0;35 unmodified lines<h1 className="text-3xl font-bold tracking-tight">Enterprise Overview</h1><p className="text-muted-foreground mt-1">Real-time autonomous deployment monitoring.</p></div><div className="flex items-center gap-3"><Buttonvariant={isSimulating ? "destructive" : "default"}size="sm"onClick={() => setIsSimulating(!isSimulating)}className="rounded-full gap-2 px-6">{isSimulating ? <Zap className="h-4 w-4 animate-pulse" /> : <Zap className="h-4 w-4" />}{isSimulating ? "Stop Autonomous Mode" : "Start Autonomous Mode"}</Button><Buttonvariant="outline"size="sm"onClick={() => { api.reset().then(() => fetchData()); }}className="rounded-full">Reset Session</Button><Badgevariant="outline"className={cn("px-4 py-1.5 rounded-full border-2",connectionState === "connected"? "border-green-500/30 text-green-600 bg-green-50": connectionState === "disconnected"? "border-destructive/30 text-destructive bg-destructive/5": "")}><div className={cn("w-2 h-2 rounded-full mr-2 animate-pulse",connectionState === "connected" ? "bg-green-500" : "bg-destructive")} />{loading ? "Syncing..." : connectionText}</Badge></div></div>{/* Primary Metrics */}102 unmodified lines<div className="grid gap-6 md:grid-cols-7">{/* Main Traffic Chart */}<Card className="md:col-span-4 border-border/50 bg-card/50 shadow-sm overflow-hidden"><CardHeader><CardTitle className="flex items-center justify-between">Evaluation Traffic<Badge variant="outline" className="font-normal text-xs bg-background/50">Live Stream</Badge></CardTitle>4 unmodified lines<AreaChart data={state?.history?.map(h => ({time: h.observation?.time_step,rollout: h.observation?.current_rollout_percentage,error: (h.observation?.error_rate ?? 0) * 100})) : [{ time: -2, rollout: 5, error: 0.1 },{ time: -1, rollout: 5, error: 0.15 },{ time: 0, rollout: 5, error: 0.1 }]}margin={{ top: 20, right: 30, left: 0, bottom: 0 }}><defs><linearGradient id="colorRollout" x1="0" y1="0" x2="0" y2="1"><stop offset="5%" stopColor="#8b5cf6" stopOpacity={0.4}/><stop offset="95%" stopColor="#8b5cf6" stopOpacity={0}/></linearGradient></defs><CartesianGrid strokeDasharray="3 3" vertical={false} stroke="#222" /><XAxis dataKey="time" stroke="#444" fontSize={10} tickLine={false} axisLine={false} /><YAxis stroke="#444" fontSize={10} tickLine={false} axisLine={false} domain={[0, 100]} /><TooltipcontentStyle={{ backgroundColor: '#111', border: '1px solid #333', borderRadius: '8px' }}itemStyle={{ color: '#8b5cf6' }}/><Areatype="monotone"dataKey="rollout"stroke="#a78bfa"strokeWidth={3}fillOpacity={1}fill="url(#colorRollout)"animationDuration={1000}/></AreaChart></div></CardContent></Card>56 unmodified lines<Card className="border-border/50 bg-card/50 col-span-2"><CardHeader className="pb-2"><CardTitle className="text-sm font-medium flex items-center justify-between"><div className="flex items-center gap-2"><ShieldAlert className="h-4 w-4 text-red-500" />Active Alerts & Incidents</div><div className="flex items-center gap-4"><div className="flex items-center gap-1.5 text-[10px] text-muted-foreground uppercase font-bold"><div className="w-1.5 h-1.5 rounded-full bg-green-500" /> Slack</div></div></CardTitle></CardHeader><CardContent>
7 unmodified lines891011121319 unmodified lines3334353637387 unmodified linesFlag,Beaker,BrainCircuit,Settings,} from "lucide-react";import { motion } from "framer-motion";19 unmodified lineshref: "/ai-decisions",icon: BrainCircuit,},{title: "Settings",href: "/settings",7 unmodified lines89101112131419 unmodified lines34353637383940414243447 unmodified linesFlag,Beaker,BrainCircuit,Activity,Settings,} from "lucide-react";import { motion } from "framer-motion";19 unmodified lineshref: "/ai-decisions",icon: BrainCircuit,},{title: "Integrations",href: "/integrations",icon: Activity,},{title: "Settings",href: "/settings",
1234567891011"use client";import * as React from "react";import { ThemeProvider as NextThemesProvider } from "next-themes";export function ThemeProvider({children,...props}: React.ComponentProps<typeof NextThemesProvider>) {return <NextThemesProvider {...props}>{children}</NextThemesProvider>;}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071"use client";import * as React from "react";type Theme = "dark" | "light" | "system";type ThemeProviderState = {theme: Theme;setTheme: (theme: Theme) => void;};const ThemeProviderContext = React.createContext<ThemeProviderState | undefined>(undefined);export function ThemeProvider({children,defaultTheme = "dark",storageKey = "ui-theme",...props}: {children: React.ReactNode;defaultTheme?: Theme;storageKey?: string;[key: string]: unknown;}) {const [theme, setTheme] = React.useState<Theme>(() => (typeof window !== "undefined" && (localStorage.getItem(storageKey) as Theme)) || defaultTheme);React.useEffect(() => {const root = window.document.documentElement;root.classList.remove("light", "dark");if (theme === "system") {const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches? "dark": "light";root.classList.add(systemTheme);return;}root.classList.add(theme);}, [theme]);const value = {theme,setTheme: (theme: Theme) => {localStorage.setItem(storageKey, theme);setTheme(theme);},};return (<ThemeProviderContext.Provider {...props} value={value}>{children}</ThemeProviderContext.Provider>);}export const useTheme = () => {const context = React.useContext(ThemeProviderContext);if (context === undefined)throw new Error("useTheme must be used within a ThemeProvider");return context;}
1 unmodified line23456781 unmodified lineimport * as React from "react";import { Moon, Sun } from "lucide-react";import { useTheme } from "next-themes";import { cn } from "@/lib/utils";import {1 unmodified line23456781 unmodified lineimport * as React from "react";import { Moon, Sun } from "lucide-react";import { useTheme } from "@/components/theme-provider";import { cn } from "@/lib/utils";import {
121 unmodified lines122123124125126127128129130192 unmodified lines323324325326327328329121 unmodified linesepisode_id: string;step_count: number;total_reward: number;is_done: boolean;scenario_name: string;difficulty: string;history: Array<{observation?: Observation;reward?: number;192 unmodified linesasync getDashboard(): Promise<DashboardData> {try {return this.request<DashboardData>("/monitoring/dashboard", { method: "GET" });} catch (error) {// Monitoring can be disabled on backend; fall back to core state/health data.if (error instanceof Error && /(403|monitoring is not enabled)/i.test(error.message)) {121 unmodified lines122123124125126127128129130131132133192 unmodified lines326327328329330331332333121 unmodified linesepisode_id: string;step_count: number;total_reward: number;done?: boolean;is_done: boolean;scenario_name: string;difficulty: string;action_history?: ActionHistoryItem[];rollout_history?: number[];history: Array<{observation?: Observation;reward?: number;192 unmodified linesasync getDashboard(): Promise<DashboardData> {try {const dashboard = await this.request<unknown>("/monitoring/dashboard", { method: "GET" });return normalizeDashboard(dashboard);} catch (error) {// Monitoring can be disabled on backend; fall back to core state/health data.if (error instanceof Error && /(403|monitoring is not enabled)/i.test(error.message)) {
192 unmodified lines19319419519619719841 unmodified lines240241242243244245192 unmodified lines<div className="space-y-0">{recentDecisions.length > 0 ? (recentDecisions.map((step, i) => (<div key={i} className="flex gap-4 border-b border-border/30 last:border-0 py-4 group"><div className="flex flex-col items-center"><div className="h-8 w-8 rounded-full bg-muted flex items-center justify-center text-[10px] font-bold">41 unmodified lines</div></div></div>))) : (<div className="py-20 text-center text-muted-foreground flex flex-col items-center gap-4">192 unmodified lines19319419519619719819920020120220341 unmodified lines245246247248249250251252192 unmodified lines<div className="space-y-0">{recentDecisions.length > 0 ? (recentDecisions.map((step, i) => ((() => {const actionType = step.action?.action_type ?? "MAINTAIN";const targetPercentage = step.action?.target_percentage ?? 0;const reason = step.action?.reason ?? "No reasoning provided.";return (<div key={i} className="flex gap-4 border-b border-border/30 last:border-0 py-4 group"><div className="flex flex-col items-center"><div className="h-8 w-8 rounded-full bg-muted flex items-center justify-center text-[10px] font-bold">41 unmodified lines</div></div></div>);})()))) : (<div className="py-20 text-center text-muted-foreground flex flex-col items-center gap-4">
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143"use client";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import { MessageSquare, GitGraph, ExternalLink, RefreshCw, Bell} from "lucide-react";import { useEffect, useState } from "react";import { api } from "@/lib/api";
const IntegrationsPage = () => { const [loading, setLoading] = useState(false); const [lastSync, setLastSync] = useState("Never"); const [isHealthy, setIsHealthy] = useState(false);
const syncIntegrations = async () => { setLoading(true); try { const [health] = await Promise.all([ api.getHealth(), api.getDashboard(), ]); setIsHealthy(Boolean(health?.environment_ready)); setLastSync(new Date().toLocaleTimeString()); } catch (error) { console.error("Failed to sync integration status:", error); setIsHealthy(false); setLastSync("Sync failed"); } finally { setLoading(false); } };
useEffect(() => { const initialSync = setTimeout(() => { void syncIntegrations(); }, 0); return () => clearTimeout(initialSync); }, []);
const integrations = [ { id: "slack", name: "Slack", description: "Automated rollout notifications and approval workflows.", icon: MessageSquare, status: isHealthy ? "connected" : "disconnected", details: isHealthy ? "Alerts can be routed through backend automation" : "Backend unavailable", lastSync }, { id: "github", name: "GitHub", description: "Trigger rollouts from PRs and sync deployment status.", icon: GitGraph, status: "disconnected", details: "Requires OAuth", lastSync } ];
return ( <div className="flex-1 space-y-6 p-8"> <div className="flex items-center justify-between"> <div> <h1 className="text-3xl font-bold tracking-tight">Integrations</h1> <p className="text-muted-foreground mt-1">Manage external connections and observability sync.</p> </div> <Button variant="outline" size="sm" className="rounded-full" onClick={syncIntegrations} disabled={loading}> <RefreshCw className={`mr-2 h-4 w-4 ${loading ? "animate-spin" : ""}`} /> {loading ? "Syncing..." : "Sync All"} </Button> </div>
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3"> {integrations.map((item) => ( <Card key={item.id} className="border-border/50 bg-card/50"> <CardHeader className="pb-3"> <div className="flex items-center justify-between"> <div className="flex h-10 w-10 items-center justify-center rounded-lg bg-muted/50"> <item.icon className="h-6 w-6 text-primary" /> </div> <Badge variant={item.status === "connected" ? "default" : "secondary"} className={item.status === "connected" ? "bg-green-500/10 text-green-600 hover:bg-green-500/10" : ""} > {item.status === "connected" ? "Connected" : "Disconnected"} </Badge> </div> <CardTitle className="mt-4">{item.name}</CardTitle> <CardDescription>{item.description}</CardDescription> </CardHeader> <CardContent> <div className="space-y-4"> <div className="flex items-center justify-between text-sm"> <span className="text-muted-foreground">Status</span> <span className="font-medium">{item.details}</span> </div> <div className="flex items-center justify-between text-sm"> <span className="text-muted-foreground">Last Sync</span> <span className="text-xs">{item.lastSync}</span> </div> <div className="pt-4 flex gap-2"> <Button variant="outline" className="w-full text-xs h-8 rounded-full"> Configure </Button> <Button variant="ghost" size="icon" className="h-8 w-8 rounded-full"> <ExternalLink className="h-4 w-4" /> </Button> </div> </div> </CardContent> </Card> ))} </div>
<Card className="border-primary/20 bg-primary/5"> <CardHeader> <CardTitle className="flex items-center gap-2 text-primary"> <Bell className="h-5 w-5" /> Webhook Endpoints </CardTitle> <CardDescription>Receive automated alerts from your own infrastructure.</CardDescription> </CardHeader> <CardContent> <div className="rounded-lg border bg-background/50 p-4 font-mono text-xs"> GET {(api.getApiBaseUrl() || "http://localhost:8000")}/monitoring/alerts </div> <p className="text-[10px] text-muted-foreground mt-4"> Uses live backend monitoring routes for alert ingestion and observability polling. </p> </CardContent> </Card> </div> );};
export default IntegrationsPage;29 unmodified lines303132333435363729 unmodified lines<body className="min-h-full flex flex-col font-sans"><ThemeProviderattribute="class"defaultTheme="system"enableSystemdisableTransitionOnChange><EnvProvider>29 unmodified lines3031323334353629 unmodified lines<body className="min-h-full flex flex-col font-sans"><ThemeProviderattribute="class"defaultTheme="dark"disableTransitionOnChange><EnvProvider>
15 unmodified lines161718192021224 unmodified lines2728293031325 unmodified lines38394041424335 unmodified lines798081828384858687888990919293949596979899100101102 unmodified lines2042052062072082092102112122132144 unmodified lines21922022122222322422522622722822923023123223323423523623723823956 unmodified lines29629729829930030130230330415 unmodified linesimport {Area,AreaChart,ResponsiveContainer,Tooltip,XAxis,YAxis,4 unmodified lines} from "recharts";import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";import { Badge } from "@/components/ui/badge";import { Progress } from "@/components/ui/progress";import { useMemo } from "react";import { Observation } from "@/lib/api";5 unmodified linesconst { dashboard: data, state, connectionState, connectionText } = useEnv();const loading = useMemo(() => connectionState === "checking" && !data && !state, [connectionState, data, state]);const lastObs: Observation | undefined = state?.history?.[state.history.length - 1]?.observation;const healthScore = lastObs?.system_health_score ?? data?.summary?.health_score ?? 0;35 unmodified lines<h1 className="text-3xl font-bold tracking-tight">Enterprise Overview</h1><p className="text-muted-foreground mt-1">Real-time autonomous deployment monitoring.</p></div><Badgevariant="outline"className={cn("px-4 py-1.5 rounded-full border-2",connectionState === "connected"? "border-green-500/30 text-green-600 bg-green-50": connectionState === "disconnected"? "border-destructive/30 text-destructive bg-destructive/5": "")}><div className={cn("w-2 h-2 rounded-full mr-2 animate-pulse",connectionState === "connected" ? "bg-green-500" : "bg-destructive")} />{loading ? "Syncing..." : connectionText}</Badge></div>{/* Primary Metrics */}102 unmodified lines<div className="grid gap-6 md:grid-cols-7">{/* Main Traffic Chart */}<Card className="md:col-span-4 border-border/50 bg-card/50 shadow-sm"><CardHeader><CardTitle className="flex items-center justify-between">Evaluation Traffic<Badge variant="outline" className="font-normal text-xs">Live Stream</Badge></CardTitle>4 unmodified lines<AreaChart data={state?.history?.map(h => ({time: h.observation?.time_step,rollout: h.observation?.current_rollout_percentage,error: (h.observation?.error_rate ?? 0) * 10000 // scaling for visibility})) || []}><defs><linearGradient id="colorRollout" x1="0" y1="0" x2="0" y2="1"><stop offset="5%" stopColor="var(--primary)" stopOpacity={0.2}/><stop offset="95%" stopColor="var(--primary)" stopOpacity={0}/></linearGradient></defs><CartesianGrid strokeDasharray="3 3" vertical={false} stroke="var(--border)" opacity={0.5} /><XAxis dataKey="time" stroke="var(--muted-foreground)" fontSize={10} tickLine={false} axisLine={false} /><YAxis stroke="var(--muted-foreground)" fontSize={10} tickLine={false} axisLine={false} /><Tooltip /><Area type="monotone" dataKey="rollout" stroke="var(--primary)" strokeWidth={2} fill="url(#colorRollout)" /></AreaChart></ResponsiveContainer></div></CardContent></Card>56 unmodified lines<Card className="border-border/50 bg-card/50 col-span-2"><CardHeader className="pb-2"><CardTitle className="text-sm font-medium flex items-center gap-2"><ShieldAlert className="h-4 w-4 text-red-500" />Active Alerts & Incidents</CardTitle></CardHeader><CardContent>15 unmodified lines1617181920214 unmodified lines262728293031325 unmodified lines383940414243444546474849505135 unmodified lines87888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128102 unmodified lines2312322332342352362372382392402414 unmodified lines24624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128256 unmodified lines33934034134234334434534634734834935035135235335415 unmodified linesimport {Area,AreaChart,Tooltip,XAxis,YAxis,4 unmodified lines} from "recharts";import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import { Progress } from "@/components/ui/progress";import { useMemo } from "react";import { Observation } from "@/lib/api";5 unmodified linesconst { dashboard: data, state, connectionState, connectionText } = useEnv();const loading = useMemo(() => connectionState === "checking" && !data && !state, [connectionState, data, state]);useEffect(() => {let simInterval: NodeJS.Timeout;if (isSimulating) {simInterval = setInterval(runSimulationStep, 2000);}return () => clearInterval(simInterval);}, [isSimulating, state]);const lastObs: Observation | undefined = state?.history?.[state.history.length - 1]?.observation;const healthScore = lastObs?.system_health_score ?? data?.summary?.health_score ?? 0;35 unmodified lines<h1 className="text-3xl font-bold tracking-tight">Enterprise Overview</h1><p className="text-muted-foreground mt-1">Real-time autonomous deployment monitoring.</p></div><div className="flex items-center gap-3"><Buttonvariant={isSimulating ? "destructive" : "default"}size="sm"onClick={() => setIsSimulating(!isSimulating)}className="rounded-full gap-2 px-6">{isSimulating ? <Zap className="h-4 w-4 animate-pulse" /> : <Zap className="h-4 w-4" />}{isSimulating ? "Stop Autonomous Mode" : "Start Autonomous Mode"}</Button><Buttonvariant="outline"size="sm"onClick={() => { api.reset().then(() => fetchData()); }}className="rounded-full">Reset Session</Button><Badgevariant="outline"className={cn("px-4 py-1.5 rounded-full border-2",connectionState === "connected"? "border-green-500/30 text-green-600 bg-green-50": connectionState === "disconnected"? "border-destructive/30 text-destructive bg-destructive/5": "")}><div className={cn("w-2 h-2 rounded-full mr-2 animate-pulse",connectionState === "connected" ? "bg-green-500" : "bg-destructive")} />{loading ? "Syncing..." : connectionText}</Badge></div></div>{/* Primary Metrics */}102 unmodified lines<div className="grid gap-6 md:grid-cols-7">{/* Main Traffic Chart */}<Card className="md:col-span-4 border-border/50 bg-card/50 shadow-sm overflow-hidden"><CardHeader><CardTitle className="flex items-center justify-between">Evaluation Traffic<Badge variant="outline" className="font-normal text-xs bg-background/50">Live Stream</Badge></CardTitle>4 unmodified lines<AreaChart data={state?.history?.map(h => ({time: h.observation?.time_step,rollout: h.observation?.current_rollout_percentage,error: (h.observation?.error_rate ?? 0) * 100})) : [{ time: -2, rollout: 5, error: 0.1 },{ time: -1, rollout: 5, error: 0.15 },{ time: 0, rollout: 5, error: 0.1 }]}margin={{ top: 20, right: 30, left: 0, bottom: 0 }}><defs><linearGradient id="colorRollout" x1="0" y1="0" x2="0" y2="1"><stop offset="5%" stopColor="#8b5cf6" stopOpacity={0.4}/><stop offset="95%" stopColor="#8b5cf6" stopOpacity={0}/></linearGradient></defs><CartesianGrid strokeDasharray="3 3" vertical={false} stroke="#222" /><XAxis dataKey="time" stroke="#444" fontSize={10} tickLine={false} axisLine={false} /><YAxis stroke="#444" fontSize={10} tickLine={false} axisLine={false} domain={[0, 100]} /><TooltipcontentStyle={{ backgroundColor: '#111', border: '1px solid #333', borderRadius: '8px' }}itemStyle={{ color: '#8b5cf6' }}/><Areatype="monotone"dataKey="rollout"stroke="#a78bfa"strokeWidth={3}fillOpacity={1}fill="url(#colorRollout)"animationDuration={1000}/></AreaChart></div></CardContent></Card>56 unmodified lines<Card className="border-border/50 bg-card/50 col-span-2"><CardHeader className="pb-2"><CardTitle className="text-sm font-medium flex items-center justify-between"><div className="flex items-center gap-2"><ShieldAlert className="h-4 w-4 text-red-500" />Active Alerts & Incidents</div><div className="flex items-center gap-4"><div className="flex items-center gap-1.5 text-[10px] text-muted-foreground uppercase font-bold"><div className="w-1.5 h-1.5 rounded-full bg-green-500" /> Slack</div></div></CardTitle></CardHeader><CardContent>
7 unmodified lines891011121319 unmodified lines3334353637387 unmodified linesFlag,Beaker,BrainCircuit,Settings,} from "lucide-react";import { motion } from "framer-motion";19 unmodified lineshref: "/ai-decisions",icon: BrainCircuit,},{title: "Settings",href: "/settings",7 unmodified lines89101112131419 unmodified lines34353637383940414243447 unmodified linesFlag,Beaker,BrainCircuit,Activity,Settings,} from "lucide-react";import { motion } from "framer-motion";19 unmodified lineshref: "/ai-decisions",icon: BrainCircuit,},{title: "Integrations",href: "/integrations",icon: Activity,},{title: "Settings",href: "/settings",
1234567891011"use client";import * as React from "react";import { ThemeProvider as NextThemesProvider } from "next-themes";export function ThemeProvider({children,...props}: React.ComponentProps<typeof NextThemesProvider>) {return <NextThemesProvider {...props}>{children}</NextThemesProvider>;}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071"use client";import * as React from "react";type Theme = "dark" | "light" | "system";type ThemeProviderState = {theme: Theme;setTheme: (theme: Theme) => void;};const ThemeProviderContext = React.createContext<ThemeProviderState | undefined>(undefined);export function ThemeProvider({children,defaultTheme = "dark",storageKey = "ui-theme",...props}: {children: React.ReactNode;defaultTheme?: Theme;storageKey?: string;[key: string]: unknown;}) {const [theme, setTheme] = React.useState<Theme>(() => (typeof window !== "undefined" && (localStorage.getItem(storageKey) as Theme)) || defaultTheme);React.useEffect(() => {const root = window.document.documentElement;root.classList.remove("light", "dark");if (theme === "system") {const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches? "dark": "light";root.classList.add(systemTheme);return;}root.classList.add(theme);}, [theme]);const value = {theme,setTheme: (theme: Theme) => {localStorage.setItem(storageKey, theme);setTheme(theme);},};return (<ThemeProviderContext.Provider {...props} value={value}>{children}</ThemeProviderContext.Provider>);}export const useTheme = () => {const context = React.useContext(ThemeProviderContext);if (context === undefined)throw new Error("useTheme must be used within a ThemeProvider");return context;}
1 unmodified line23456781 unmodified lineimport * as React from "react";import { Moon, Sun } from "lucide-react";import { useTheme } from "next-themes";import { cn } from "@/lib/utils";import {1 unmodified line23456781 unmodified lineimport * as React from "react";import { Moon, Sun } from "lucide-react";import { useTheme } from "@/components/theme-provider";import { cn } from "@/lib/utils";import {
121 unmodified lines122123124125126127128129130192 unmodified lines323324325326327328329121 unmodified linesepisode_id: string;step_count: number;total_reward: number;is_done: boolean;scenario_name: string;difficulty: string;history: Array<{observation?: Observation;reward?: number;192 unmodified linesasync getDashboard(): Promise<DashboardData> {try {return this.request<DashboardData>("/monitoring/dashboard", { method: "GET" });} catch (error) {// Monitoring can be disabled on backend; fall back to core state/health data.if (error instanceof Error && /(403|monitoring is not enabled)/i.test(error.message)) {121 unmodified lines122123124125126127128129130131132133192 unmodified lines326327328329330331332333121 unmodified linesepisode_id: string;step_count: number;total_reward: number;done?: boolean;is_done: boolean;scenario_name: string;difficulty: string;action_history?: ActionHistoryItem[];rollout_history?: number[];history: Array<{observation?: Observation;reward?: number;192 unmodified linesasync getDashboard(): Promise<DashboardData> {try {const dashboard = await this.request<unknown>("/monitoring/dashboard", { method: "GET" });return normalizeDashboard(dashboard);} catch (error) {// Monitoring can be disabled on backend; fall back to core state/health data.if (error instanceof Error && /(403|monitoring is not enabled)/i.test(error.message)) {
17 unmodified lines1819202122232417 unmodified lines# 🧮 Math & Simulation"numpy>=1.24.0","torch>=2.0.0",# 🤖 LLM Integration (OpenAI-compatible client)"groq>=0.4.0",17 unmodified lines18192021222317 unmodified lines# 🧮 Math & Simulation"numpy>=1.24.0",# 🤖 LLM Integration (OpenAI-compatible client)"groq>=0.4.0",
feature-flag-agent-env/agents/rl_agent.py+53-27
feature-flag-agent-env/feature_flag_env/tools/connectors.py-1
feature-flag-agent-env/pyproject.toml-1
feature-flag-agent-env/requirements.txt-1
frontend/app/ai-decisions/page.tsx+7
frontend/app/integrations/page.tsxAdded+143
frontend/app/layout.tsx+1-2
frontend/app/page.tsx+88-38
frontend/components/layout/sidebar.tsx+6
frontend/components/theme-provider.tsx+63-3
frontend/components/theme-toggle.tsx+1-1
frontend/lib/api.ts+5-1
node_modules/frontend/app/ai-decisions/page.tsx+7
node_modules/frontend/app/integrations/page.tsxAdded+143
node_modules/frontend/app/layout.tsx+1-2
node_modules/frontend/app/page.tsx+88-38
node_modules/frontend/components/layout/sidebar.tsx+6
node_modules/frontend/components/theme-provider.tsx+63-3
node_modules/frontend/components/theme-toggle.tsx+1-1
node_modules/frontend/lib/api.ts+5-1
pyproject.toml-1