"use client" import type React from "react" import { Book, Code2, Terminal, Copy, Check } from "lucide-react" import { Button } from "@/components/ui/button" import { useState } from "react" const CodeBlock = ({ children }: { children: React.ReactNode }) => { const [copied, setCopied] = useState(false) const copyToClipboard = async (text: string) => { try { await navigator.clipboard.writeText(text) setCopied(true) setTimeout(() => setCopied(false), 2000) } catch (err) { console.error("Failed to copy:", err) } } const codeText = typeof children === "string" ? children : children?.toString() || "" return (
        {children}
      
) } export function DocsSection() { return (

Docs

A quick guide to get started with the @lerobot/web API.

{/* Getting Started */}

Getting Started

First, import the API from the library. Then you can call its methods to find and control your robot.

{`import { lerobot } from '@lerobot/web'; async function connectToRobot() { const { result } = await lerobot.findPort({ onMessage: (message) => console.log('Status:', message), }); const robots = await result; console.log('Found robots:', robots); }`}
{/* API Reference */}

API Reference

{/* findPort */}

lerobot.findPort(options)

Scans for available robot connections via WebSerial.

{`// Options { robotConfigs?: RobotConfig[], // Optional: Saved configs to try reconnecting onMessage?: (msg: string) => void // Callback for status updates } // Returns { result: Promise // A promise that resolves with found robots }`}
{/* calibrate */}

lerobot.calibrate(robot, options)

Starts the calibration process for a specific robot.

{`// Parameters robot: RobotConnection // The robot instance to calibrate // Options { onLiveUpdate: (data: LiveCalibrationData) => void, // Callback for real-time joint data onProgress: (msg: string) => void // Callback for status messages } // Returns { result: Promise, // A promise that resolves with final calibration stop: () => void // Function to stop the calibration recording }`}
{/* teleoperate */}

lerobot.teleoperate(robot, options)

Initializes the teleoperation interface for a robot.

{`// Parameters robot: RobotConnection, calibrationData: WebCalibrationResults // Options { onStateUpdate: (state: TeleoperationState) => void // Callback for real-time state updates } // Returns { start: () => void, stop: () => void, updateKeyState: (key: string, pressed: boolean) => void, moveMotor: (motorName: string, position: number) => void }`}
) }