Agent builder
Agent configuration studio with inline-editable title, model selector, instructions, tool toggles, Test mode chat and Publish state.
pnpm dlx shadcn@latest add @haze/agent-builder---
import { ArrowUp, Bot, Check, FileText, Rocket, Wrench } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
interface Props {
id?: string;
agentName?: string;
class?: string;
}
const {
id = "haze-agent-builder",
agentName = "Support Triage Specialist",
class: className,
} = Astro.props;
const tools = [
{ id: "linear", label: "Linear · Create & link issues", enabled: true },
{ id: "stripe", label: "Stripe · Read invoices & charges", enabled: true },
{ id: "slack", label: "Slack · Post escalations", enabled: false },
];
---
<section aria-labelledby={`${id}-title`} data-haze-agent-builder class={cn("bg-background px-4 py-10 sm:px-6 sm:py-14", className)}>
<div class="mx-auto max-w-4xl overflow-hidden rounded-2xl border border-border bg-card">
<header class="flex flex-wrap items-center justify-between gap-3 border-b border-border px-5 py-3.5">
<div class="flex min-w-0 items-center 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">
<Bot class="size-4" />
</span>
<div class="min-w-0">
<label for={`${id}-name`} class="sr-only">Agent name</label>
<input id={`${id}-name`} data-ab-dirty type="text" value={agentName} class="-mx-px border border-frame-input h-7 min-w-0 rounded-md bg-transparent px-1 text-sm font-semibold text-foreground hover:bg-accent focus-visible:bg-background focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:outline-hidden" />
<p data-ab-saved class="px-1 text-[0.6875rem] text-muted-foreground">All changes saved</p>
</div>
</div>
<div class="flex flex-wrap items-center gap-2">
<div role="tablist" aria-label="Builder mode" class="inline-flex rounded-lg border border-frame bg-muted p-0.5">
<button type="button" role="tab" data-ab-mode="configure" aria-selected="true" class="inline-flex h-7 cursor-pointer items-center rounded-md px-2.5 text-xs font-medium text-muted-foreground aria-selected:bg-background aria-selected:text-foreground aria-selected:shadow-key focus-visible:outline-2 focus-visible:outline-ring">Configure</button>
<button type="button" role="tab" data-ab-mode="test" aria-selected="false" class="inline-flex h-7 cursor-pointer items-center rounded-md px-2.5 text-xs font-medium text-muted-foreground aria-selected:bg-background aria-selected:text-foreground aria-selected:shadow-key focus-visible:outline-2 focus-visible:outline-ring">Test</button>
</div>
<button type="button" data-ab-publish class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg bg-primary px-3.5 text-xs font-medium text-primary-foreground hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75">
<Rocket class="size-3.5" aria-hidden="true" />
Publish
</button>
</div>
</header>
<h2 id={`${id}-title`} class="sr-only">Agent configuration studio</h2>
<div data-ab-pane="configure" class="grid gap-5 p-5 md:grid-cols-[minmax(0,1.2fr)_minmax(0,0.8fr)]">
<div class="space-y-4">
<div class="grid gap-1.5">
<label for={`${id}-model`} class="text-xs font-medium text-muted-foreground">Model</label>
<select id={`${id}-model`} data-ab-dirty class="h-9 rounded-lg border border-frame-input bg-field px-2.5 text-xs text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:outline-hidden transition-[color,background-color,border-color,box-shadow] duration-150 hover:border-frame-foreground">
<option>Sonnet 4.5</option>
<option>Gemini 3.8 Pro</option>
<option>GPT-5 Mini</option>
</select>
</div>
<div class="grid gap-1.5">
<label for={`${id}-inst`} class="text-xs font-medium text-muted-foreground">System instructions</label>
<textarea id={`${id}-inst`} data-ab-dirty rows="5" class="w-full rounded-xl border border-frame-input bg-field p-3 text-xs/6 text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:outline-hidden transition-[color,background-color,border-color,box-shadow] duration-150 hover:border-frame-foreground">Triage incoming customer tickets, inspect Stripe billing status when payment errors are mentioned, and file linked Linear bugs with reproduction steps.</textarea>
</div>
</div>
<div class="space-y-4">
<div>
<p class="inline-flex items-center gap-1.5 text-xs font-medium text-foreground">
<Wrench class="size-3.5 text-muted-foreground" aria-hidden="true" />
Enabled tools
</p>
<div class="mt-2 space-y-2">
{
tools.map((t) => (
<label class="flex cursor-pointer items-center justify-between gap-2 rounded-xl border border-border bg-muted/40 px-3 py-2.5 text-xs text-foreground">
<span>{t.label}</span>
<span class="relative inline-grid size-4 shrink-0 place-items-center"><input type="checkbox" checked={t.enabled} data-ab-dirty class="peer col-start-1 row-start-1 size-4 shrink-0 cursor-pointer appearance-none rounded-sm border border-border-strong bg-field transition-[background-color,border-color,scale] duration-150 ease-snappy hover:border-foreground active:scale-90 checked:border-primary checked:bg-primary focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring forced-colors:appearance-auto" /><Check class="pointer-events-none col-start-1 row-start-1 size-3 scale-50 text-primary-foreground opacity-0 transition-[opacity,scale] duration-200 ease-spring peer-checked:scale-100 peer-checked:opacity-100 forced-colors:hidden" stroke-width={3} aria-hidden="true" /></span>
</label>
))
}
</div>
</div>
<div class="rounded-xl border border-border bg-muted/40 p-3">
<p class="inline-flex items-center gap-1.5 text-xs font-medium text-foreground">
<FileText class="size-3.5 text-muted-foreground" aria-hidden="true" />
Knowledge files
</p>
<div class="mt-2 flex items-center justify-between text-xs text-muted-foreground">
<span class="truncate font-mono">support-handbook.pdf</span>
<span class="inline-flex items-center gap-1 text-success"><Check class="size-3" aria-hidden="true" />100%</span>
</div>
</div>
</div>
</div>
<div data-ab-pane="test" hidden class="p-5">
<div data-ab-log class="space-y-3 rounded-xl border border-border bg-muted/40 p-4 text-sm/6">
<p class="text-xs text-muted-foreground">Sandbox connected to enabled tools (Linear, Stripe).</p>
<p class="rounded-lg border border-border bg-card p-3 text-xs/5 text-foreground">Send a sample customer message below to verify tool calls before publishing.</p>
</div>
<form data-ab-test-form class="mt-3 flex gap-2">
<label for={`${id}-test-q`} class="sr-only">Test message</label>
<input id={`${id}-test-q`} data-ab-test-in type="text" placeholder="e.g. We were billed twice on invoice 9012" class="h-9 min-w-0 flex-1 rounded-lg border border-frame-input bg-field px-3 text-xs text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/24 focus-visible:outline-hidden transition-[color,background-color,border-color,box-shadow] duration-150 hover:border-frame-foreground" />
<button type="submit" aria-label="Send test message" class="inline-flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-lg bg-primary text-primary-foreground hover:opacity-90 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">
<ArrowUp class="size-4" aria-hidden="true" />
</button>
</form>
</div>
<p data-ab-status role="status" class="border-t border-border bg-muted/40 px-5 py-2.5 text-xs/4 text-muted-foreground">Draft ready</p>
</div>
</section>
<script>
function initAgentBuilders() {
document.querySelectorAll<HTMLElement>("[data-haze-agent-builder]").forEach((root) => {
if (root.hasAttribute("data-enhanced")) return;
root.setAttribute("data-enhanced", "");
const saved = root.querySelector<HTMLElement>("[data-ab-saved]");
const status = root.querySelector<HTMLElement>("[data-ab-status]");
const log = root.querySelector<HTMLElement>("[data-ab-log]");
const testIn = root.querySelector<HTMLInputElement>("[data-ab-test-in]");
root.querySelectorAll<HTMLElement>("[data-ab-dirty]").forEach((el) => {
el.addEventListener("input", () => { if (saved) saved.textContent = "Unsaved changes"; });
el.addEventListener("change", () => { if (saved) saved.textContent = "Unsaved changes"; });
});
root.querySelectorAll<HTMLButtonElement>("[data-ab-mode]").forEach((tab) => {
tab.addEventListener("click", () => {
const mode = tab.dataset.abMode;
root.querySelectorAll<HTMLButtonElement>("[data-ab-mode]").forEach((t) => t.setAttribute("aria-selected", String(t === tab)));
root.querySelectorAll<HTMLElement>("[data-ab-pane]").forEach((p) => (p.hidden = p.dataset.abPane !== mode));
});
});
root.querySelector<HTMLButtonElement>("[data-ab-publish]")?.addEventListener("click", () => {
if (saved) saved.textContent = "Published · live";
if (status) status.textContent = "Agent configuration published to workspace.";
});
root.querySelector<HTMLFormElement>("[data-ab-test-form]")?.addEventListener("submit", (ev) => {
ev.preventDefault();
const q = testIn?.value.trim();
if (!q || !log) return;
const p = document.createElement("p");
p.className = "rounded-lg border border-frame bg-muted p-3 text-xs/5 text-foreground";
p.textContent = `Simulated tool call → stripe.list_invoices() for "${q}" — drafted polite refund confirmation.`;
log.append(p);
if (testIn) testIn.value = "";
if (status) status.textContent = "Test reply generated using enabled tools.";
});
});
}
initAgentBuilders();
document.addEventListener("astro:page-load", initAgentBuilders);
</script>When to use
- Letting users configure, test and publish custom workspace agents in one card
- Tracking unsaved draft edits alongside a Configure/Test sandbox switcher
When not to use
- Editing a single raw prompt template without tools or knowledge files; use prompt-studio
Installation
Add the Haze registry to components.json once, then install Agent builder with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/agent-buildernpx shadcn@latest add @haze/agent-builderyarn dlx shadcn@latest add @haze/agent-builderbunx --bun shadcn@latest add @haze/agent-builderFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | "haze-agent-builder" | Unique prefix for form control IDs. |
| agentName | string | "Support Triage Specialist" | Editable agent title. |
| class | string | – | Extra classes on the outer section. |
Keyboard interactions
- Tab
- Move across agent name, Configure/Test tabs, Publish, model/instructions and tool toggles
- EnterSpace
- Switch between Configure and Test, toggle tools, send a test message or publish
Accessibility
- Configure and Test panes switch with labelled role="tab" buttons, and every form input has an explicit label.
- Unsaved state, test messages and Publish confirmation are announced via a polite role="status" footer.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI block "Agent builder" with `npx shadcn@latest add @haze/agent-builder`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/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 AgentBuilder from "@/components/haze/blocks/agent-builder.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: http://localhost:4329/blocks/agent-builder.md
Customize with real content
Adapt the Haze agent-builder block for our product. Replace the demo values of these props with our real content: id, agentName, class. Keep the layout, the heading level rules and these accessibility details: Configure and Test panes switch with labelled role="tab" buttons, and every form input has an explicit label. Unsaved state, test messages and Publish confirmation are announced via a polite role="status" footer. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using agent-builder, check it fits: use it when letting users configure, test and publish custom workspace agents in one card; tracking unsaved draft edits alongside a configure/test sandbox switcher. Avoid it when editing a single raw prompt template without tools or knowledge files; use prompt-studio. Alternatives: @haze/prompt-studio, @haze/ai-setup-wizard.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.