'use client' import { StepHikeCompact } from '~/components/StepHikeCompact' import { AGENT_PROMPT_ANCHOR, getMonitoringAgent, getMonitoringAgentHarnesses, type MonitoringAgentHarnessSetup, } from '~/data/monitoring-agents.utils' import { SOURCE_FOOTER_CLASSES, SourceFrame } from '~/features/directives/CodeSample.client' import { CodeTabs } from '~/features/directives/CodeTabs.components' import Image from 'next/image' import { useState, type MouseEvent, type ReactNode } from 'react' import ReactMarkdown from 'react-markdown' import { cn } from 'ui' import { getMcpClientIconSrc } from 'ui-patterns/McpUrlBuilder' import { AiPrompt } from './AiPrompt' import { PromptCode } from './PromptPanel' import { TabPanel } from './Tabs' import { useTabsWithQueryParams } from './useTabsWithQueryParams' type AgentSetupProps = { id: string } type HarnessProps = { harness: MonitoringAgentHarnessSetup } const DOCS_NOTCH_WIDTH = 100 const PROMPT_FLASH_DURATION = 1600 const handleInPageLinkClick = (event: MouseEvent) => { const target = document.getElementById(event.currentTarget.hash.slice(1)) if (!target) return event.preventDefault() const { hash } = event.currentTarget if (window.location.hash !== hash) window.history.pushState(null, '', hash) const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches target.scrollIntoView({ behavior: prefersReducedMotion ? 'auto' : 'smooth', block: 'center' }) target.focus({ preventScroll: true }) const brand = getComputedStyle(target).getPropertyValue('--brand-default') target.animate([{ outlineColor: `hsl(${brand})` }, { outlineColor: `hsl(${brand} / 0)` }], { duration: PROMPT_FLASH_DURATION, easing: 'ease-out', }) } const markdownComponents = { p: ({ children }: { children?: ReactNode }) => <>{children}, a: ({ href, children }: { href?: string; children?: ReactNode }) => { if (!href) return <>{children} if (href.startsWith('#')) { return ( {children} ) } const external = /^(?:[a-z][a-z0-9+\-.]*:|\/\/)/i.test(href) return ( {children} ) }, code: PromptCode, } function AgentSetup({ id }: AgentSetupProps) { const agent = getMonitoringAgent(id) const harnesses = getMonitoringAgentHarnesses(agent) const { queryTab, onTabSelected } = useTabsWithQueryParams({ tabIds: harnesses.map((harness) => harness.key), queryGroup: 'agent-setup', }) const [selectedHarness, setSelectedHarness] = useState(harnesses[0].key) const activeHarness = queryTab ?? selectedHarness const handleHarnessChange = (key: string) => { setSelectedHarness(key) onTabSelected(key) } return (
{harnesses.map((harness) => ( } > View docs } > ))}
) } function HarnessIcon({ harness }: HarnessProps) { const getSrc = (useDarkVariant: boolean) => getMcpClientIconSrc({ icon: harness.icon, useDarkVariant, hasDistinctDarkIcon: harness.hasDistinctDarkIcon, }) if (!harness.hasDistinctDarkIcon) { return } return ( <> ) } function HarnessBody({ harness }: HarnessProps) { return (

{harness.intro}

    {harness.steps.map((step) => (
  1. {step}
  2. ))}
{harness.note && (

{harness.note}

)}
) } export { AgentSetup } export type { AgentSetupProps }