"use client"; import { motion } from "framer-motion"; import { CheckCircle2, ClipboardList, GitBranch, Inbox, LockKeyhole, Search, Terminal, UsersRound, } from "lucide-react"; import { StepControls } from "@/components/visualizations/shared/step-controls"; import { useSteppedVisualization } from "@/hooks/useSteppedVisualization"; import { cn } from "@/lib/utils"; const STEPS = [ { title: "Confirm a Small Team", desc: "The Lead proposes focused roles and waits for the user before starting persistent teammates.", event: "lead proposes: backend + tests", }, { title: "Claim Atomically", desc: "A ready task moves to one owner while the task-store file lock protects the persisted transition.", event: "task_store_lock: task_...0042 -> backend", }, { title: "Require and Review a Plan", desc: "The gate is active before the teammate starts; the Lead reviews the typed request for this task and work version.", event: "review_plan(req_000007, approve=true)", }, { title: "Route Tools to the Task Directory", desc: "The claimed task carries its worktree binding; bash, read, and write derive their cwd from that record.", event: "cwd -> .worktrees/auth-refactor", }, { title: "Execute the Approved Work", desc: "Mutating tools run only after the current assignment's plan is approved.", event: "bash / write: allowed", }, { title: "Return the Result, Keep the Teammate", desc: "Completion keeps the task cwd through the turn; IDLE releases the assignment and keeps the teammate available.", event: "complete -> result -> IDLE", }, ] as const; const EVENTS = STEPS.map((step) => step.event); function StateBadge({ label, tone, }: { label: string; tone: "zinc" | "blue" | "amber" | "emerald"; }) { const classes = { zinc: "bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-300", blue: "bg-blue-100 text-blue-700 dark:bg-blue-950/50 dark:text-blue-200", amber: "bg-amber-100 text-amber-700 dark:bg-amber-950/50 dark:text-amber-200", emerald: "bg-emerald-100 text-emerald-700 dark:bg-emerald-950/50 dark:text-emerald-200", }[tone]; return ( {label} ); } function RuntimePanel({ step }: { step: number }) { const state = step === 0 ? "awaiting confirmation" : step === 1 ? "working" : step === 5 ? "idle" : "active"; const tone = step === 0 ? "zinc" : step === 5 ? "emerald" : "blue"; return (
Team runtime
Lead {step === 0 ? "proposes roles" : step === 5 ? "receives result" : "coordinates"} Teammate backend Protocol {step < 2 ? "-" : "request_id=req_000007"}
{step === 0 ? "No mailbox is created before confirmation." : step === 2 ? "The approval is tied to the claimed task and work version." : step === 5 ? "The result wakes the Lead; IDLE releases the cwd lease." : "The runtime owns delivery while the teammate works."}
); } function TaskPanel({ step }: { step: number }) { const status = step < 1 ? "pending" : step < 5 ? "in_progress" : "completed"; const owner = step < 1 ? "-" : "backend"; const tone = status === "pending" ? "zinc" : status === "in_progress" ? "amber" : "emerald"; return (
Task board
task_1712345678_0042
Refactor authentication
owner {owner} blockedBy []
{step < 1 ? : } {step < 1 ? "Waiting for the teammate loop." : step === 1 ? "The claim check and update share one lock." : "The claimed task remains owned through the work turn."}
); } function WorkspacePanel({ step }: { step: number }) { const routed = step >= 3 && step < 5; const retained = step >= 5; return (
Task directory
repository root
coordination state
.worktrees/auth-refactor
{routed ? "bash / read / write cwd" : retained ? "task binding remains after IDLE" : "task.worktree binding"}
{routed ? : } {routed ? "Tools follow the claimed task." : retained ? "IDLE released active tool routing." : "No implicit directory switching."}
); } export default function TeamRuntime({ title }: { title?: string }) { const vis = useSteppedVisualization({ totalSteps: STEPS.length, autoPlayInterval: 2800 }); const step = vis.currentStep; const current = STEPS[step]; return (

{title || "Agent Team Runtime"}

Runtime events
{EVENTS.map((event, index) => { const visible = index <= step; return ( {event} ); })}
); }