# Agent orchestrator

> Multi-agent fan-out view with planner goal, parallel worker lanes showing model and progress, and synthesized verdict card.

- Kind: block · Category: Agents · Interactivity: script
- Install: `npx shadcn@latest add @haze/agent-orchestrator`
- File: `src/components/haze/blocks/agent-orchestrator.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/blocks/agent-orchestrator

## Use when
- Visualizing a lead planner fanning subtasks out across specialized parallel worker agents
- Showing each worker's model, progress and merged output in one consolidated view

## Avoid when
- Tracking a single linear coding-agent session; use agent-run

## Alternatives
- [agent-run](https://hazeui.com/blocks/agent-run.md)
- [workflow-steps](https://hazeui.com/ui/workflow-steps.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| id | `string` | "haze-agent-orchestrator" | no | Unique prefix for section heading IDs. |
| goal | `string` | Release readiness audit goal | no | Top-level goal planned by the orchestrator. |
| workers | `WorkerLane[]` | 3 parallel worker lanes | no | Worker cards with role, model, progress and output. |
| class | `string` |  | no | Extra classes on the outer section. |

## Accessibility
- Each worker lane uses an article with a clear heading and model badge, followed by the merged synthesis card.
- Re-running the fan-out announces dispatch and completion via a polite role="status" element.
- Key Tab: Focus the Re-run fan-out button
- Key Enter / Space: Replay the parallel worker fan-out and merge

## Agent prompts

### Install and use

Install the Haze UI block "Agent orchestrator" with `npx shadcn@latest add @haze/agent-orchestrator`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "https://hazeui.com/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import AgentOrchestrator from "@/components/haze/blocks/agent-orchestrator.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: https://hazeui.com/blocks/agent-orchestrator.md

### Customize with real content

Adapt the Haze agent-orchestrator block for our product. Replace the demo values of these props with our real content: id, goal, workers, class. Keep the layout, the heading level rules and these accessibility details: Each worker lane uses an article with a clear heading and model badge, followed by the merged synthesis card. Re-running the fan-out announces dispatch and completion via a polite role="status" element. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using agent-orchestrator, check it fits: use it when visualizing a lead planner fanning subtasks out across specialized parallel worker agents; showing each worker's model, progress and merged output in one consolidated view. Avoid it when tracking a single linear coding-agent session; use agent-run. Alternatives: @haze/agent-run, @haze/workflow-steps.

## Example requests that should lead here
- Build a multi-agent orchestrator block with 3 parallel worker lanes, model badges and a merged summary card

## Source

```astro
---
import { CheckCircle2, GitMerge, Layers, Play, Sparkles } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";

interface WorkerLane {
  id: string;
  role: string;
  model: string;
  progress: number;
  output: string;
}

interface Props {
  id?: string;
  goal?: string;
  workers?: WorkerLane[];
  class?: string;
}

const {
  id = "haze-agent-orchestrator",
  goal = "Audit v2.8 release readiness across security, performance and docs",
  workers = [
    { id: "w1", role: "Security auditor", model: "Opus 4.5", progress: 100, output: "0 XSS sinks, CSP headers verified across 12 routes." },
    { id: "w2", role: "Web perf worker", model: "Sonnet 4.5", progress: 100, output: "Home LCP 0.9s, 0 CLS, client JS bundle 4.2 kB gzip." },
    { id: "w3", role: "Docs verifier", model: "Flash 3.8", progress: 100, output: "llms.txt, sitemap.xml and 239 Markdown twins in sync." },
  ],
  class: className,
} = Astro.props;
---

<section aria-labelledby={`${id}-title`} data-haze-orchestrator class={cn("bg-background px-4 py-10 sm:px-6 sm:py-14", className)}>
  <div class="mx-auto max-w-5xl rounded-2xl border border-border bg-card p-5 sm:p-6">
    <header class="flex flex-wrap items-start justify-between gap-3 border-b border-border pb-4">
      <div class="flex items-start gap-2.5">
        <span class="grid size-8 shrink-0 place-items-center rounded-lg border border-frame bg-muted text-muted-foreground" aria-hidden="true">
          <Layers class="size-4" />
        </span>
        <div>
          <p class="text-[0.6875rem]/4 font-medium tracking-wider text-muted-foreground uppercase">Lead planner · 3 parallel workers</p>
          <h2 id={`${id}-title`} class="mt-0.5 text-base/6 font-semibold tracking-tight text-foreground">{goal}</h2>
        </div>
      </div>
      <button type="button" data-orch-rerun class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-frame bg-field px-3 text-xs font-medium text-foreground hover:border-frame-strong hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
        <Play class="size-3 text-muted-foreground" aria-hidden="true" />
        Re-run fan-out
      </button>
    </header>

    <div class="mt-5 grid gap-3 md:grid-cols-3">
      {
        workers.map((w) => (
          <article class="flex flex-col justify-between rounded-xl border border-border bg-muted/40 p-4">
            <div>
              <div class="flex items-center justify-between gap-2">
                <h3 class="text-sm/5 font-semibold text-foreground">{w.role}</h3>
                <span class="rounded-md border border-border bg-card px-1.5 py-0.5 font-mono text-[0.6875rem] text-muted-foreground">{w.model}</span>
              </div>
              <div class="mt-2.5 h-1.5 w-full overflow-hidden rounded-full bg-muted">
                <div data-orch-bar class="h-full rounded-full bg-primary transition-[width] duration-300 ease-snappy" style={`width: ${w.progress}%`}></div>
              </div>
              <p class="mt-3 text-xs/5 text-pretty text-muted-foreground">{w.output}</p>
            </div>
            <p class="mt-3 inline-flex items-center gap-1 text-[0.6875rem] font-medium text-success">
              <CheckCircle2 class="size-3.5" aria-hidden="true" />
              Merged to synthesis
            </p>
          </article>
        ))
      }
    </div>

    <div class="mt-5 rounded-xl border border-frame bg-muted p-4">
      <div class="flex items-center gap-2 text-xs font-semibold text-foreground">
        <GitMerge class="size-4" aria-hidden="true" />
        <span>Synthesized release verdict</span>
        <Sparkles class="ml-auto size-3.5" aria-hidden="true" />
      </div>
      <p class="mt-2 text-sm/6 text-pretty text-foreground">
        All three worker lanes passed with zero blockers. v2.8 is cleared to tag and deploy to production.
      </p>
    </div>

    <p data-orch-status role="status" class="mt-3 min-h-4 text-xs/4 text-muted-foreground"></p>
  </div>
</section>

<script>
  function initOrchestrators() {
    document.querySelectorAll<HTMLElement>("[data-haze-orchestrator]").forEach((root) => {
      if (root.hasAttribute("data-enhanced")) return;
      root.setAttribute("data-enhanced", "");
      const status = root.querySelector<HTMLElement>("[data-orch-status]");
      const bars = Array.from(root.querySelectorAll<HTMLElement>("[data-orch-bar]"));
      root.querySelector<HTMLButtonElement>("[data-orch-rerun]")?.addEventListener("click", () => {
        bars.forEach((b) => (b.style.width = "35%"));
        if (status) status.textContent = "Dispatched 3 parallel worker lanes…";
        window.setTimeout(() => {
          bars.forEach((b) => (b.style.width = "100%"));
          if (status) status.textContent = "All 3 worker lanes completed and merged.";
        }, 420);
      });
    });
  }
  initOrchestrators();
  document.addEventListener("astro:page-load", initOrchestrators);
</script>
```
