import type { ReactNode } from "react" import { useTranslation } from "react-i18next" import { type CoreConfigForm, DM_SCOPE_OPTIONS, type LauncherForm, } from "@/components/config/form-model" import { Field, SwitchCardField } from "@/components/shared-form" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card" import { Input } from "@/components/ui/input" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { Textarea } from "@/components/ui/textarea" type UpdateCoreField = ( key: K, value: CoreConfigForm[K], ) => void type UpdateLauncherField = ( key: K, value: LauncherForm[K], ) => void interface ConfigSectionCardProps { title: string description?: string children: ReactNode } function ConfigSectionCard({ title, description, children, }: ConfigSectionCardProps) { return ( {title} {description && {description}}
{children}
) } interface AgentDefaultsSectionProps { form: CoreConfigForm onFieldChange: UpdateCoreField } export function AgentDefaultsSection({ form, onFieldChange, }: AgentDefaultsSectionProps) { const { t } = useTranslation() return ( onFieldChange("workspace", e.target.value)} placeholder="~/.picoclaw/workspace" /> onFieldChange("restrictToWorkspace", checked) } /> onFieldChange("maxTokens", e.target.value)} /> onFieldChange("contextWindow", e.target.value)} placeholder="131072" /> onFieldChange("maxToolIterations", e.target.value)} /> onFieldChange("summarizeMessageThreshold", e.target.value) } /> onFieldChange("summarizeTokenPercent", e.target.value) } /> ) } interface ExecSectionProps { form: CoreConfigForm onFieldChange: UpdateCoreField } export function ExecSection({ form, onFieldChange }: ExecSectionProps) { const { t } = useTranslation() return ( onFieldChange("execEnabled", checked)} /> {form.execEnabled && ( <> onFieldChange("allowRemote", checked)} /> onFieldChange("enableDenyPatterns", checked) } /> {form.enableDenyPatterns && (