# Dead man's switch

A train cab's vigilance control for supervised agent runs: the run keeps going only while someone checks in. Miss the window and it warns, then pauses.

- Category: Coordination
- Docs: https://bevel-ui.vercel.app/components/vigilance
- Import from: `@/components/ui/vigilance`

## Install

```bash
npx shadcn@latest add @bevel/vigilance
```

npm dependencies (installed by the CLI): `@base-ui/react`, `cn`.

## Anatomy

```tsx
<Vigilance interval={30000} onTrip={pauseAgent}>
  <VigilanceLamps />
  <VigilanceTimer />
  <VigilanceButton />
</Vigilance>
```

## Parts

| Part | Renders | Description |
| --- | --- | --- |
| `Vigilance` | div (group) | interval (ms), warnAt and stopAt (share left), running, onTrip, onCheckIn, onResume. |
| `VigilanceLamps` | div | Clear, Warning, Stopping lamps (steady, never flashing) and the stage in words. Only stage changes are announced; the final warning and the pause assertively. |
| `VigilanceTimer` | Progress | Time until the next check-in, read in seconds. |
| `VigilanceButton` | Button | Check in. While paused it becomes Resume. |

## Example: A supervised agent run

Check in every 12 seconds to keep it going. Stop checking in and watch it warn, then pause.

```tsx
"use client"

import * as React from "react"
import { Vigilance, VigilanceButton, VigilanceLamps, VigilanceTimer } from "@/components/ui/vigilance"

/** A supervised agent run: it keeps going only while you check in every 12 seconds. */
export function VigilanceAgent() {
  const [log, setLog] = React.useState("Agent running with supervision.")
  return (
    <div className="flex flex-col items-center gap-4">
      <Vigilance
        aria-label="Supervision"
        interval={12000}
        onTrip={() => setLog("No check-in: the agent paused before its next action.")}
        onResume={() => setLog("Resumed. The agent carries on.")}
        onCheckIn={() => setLog("Checked in.")}
      >
        <VigilanceLamps />
        <VigilanceTimer />
        <VigilanceButton />
      </Vigilance>
      <p className="max-w-xs text-center text-sm text-muted-foreground">{log}</p>
    </div>
  )
}
```
