import { t } from "@lingui/core/macro"; import { Trans, useLingui } from "@lingui/react/macro"; import type { AgentSkillCatalogEntry, Bot, ComputerMode, Me, ModelCatalogEntry, ModelCredential, ModelTier, ModelTierMapping, ThinkingLevel, VoiceInfo, } from "@rakazo/contracts"; import { BOT_DESCRIPTION_MAX_LENGTH, BOT_NAME_MAX_LENGTH, BOT_TITLE_MAX_LENGTH, MODEL_TIERS, ModelTierSchema, normalizeBotTags, } from "@rakazo/contracts"; import { Button, Input, NativeSelect, NativeSelectOptGroup, NativeSelectOption, Switch, Textarea, Toggle, } from "@rakazo/ui-web"; import { X } from "lucide-react"; import { Suspense, useEffect, useId, useRef, useState } from "react"; import { connectedModelOptions } from "../../lib/connected-models"; import { lazyWithRecovery } from "../../lib/lazy-recovery"; import { modelTierLabel } from "../../lib/model-tier-label"; import { rpc } from "../../lib/rpc"; import { AvatarStudioPopover } from "./avatar-studio-popover"; import { BotCapabilitiesFields } from "./bot-capabilities"; const ScratchpadSection = lazyWithRecovery("ScratchpadSection", () => import("../ScratchpadSection").then((module) => ({ default: module.ScratchpadSection })), ); const KnowledgeSection = lazyWithRecovery("KnowledgeSection", () => import("../KnowledgeSection").then((module) => ({ default: module.KnowledgeSection })), ); const fieldLabelClass = "mt-4 block text-ui-body text-muted-foreground"; function ComputerModePicker({ value, onChange, teamTestId, privateTestId, }: { value: ComputerMode; onChange: (value: ComputerMode) => void; teamTestId?: string; privateTestId?: string; }) { return (
Computer
{(["team", "dedicated"] as const).map((mode) => ( { if (pressed) onChange(mode); }} className="capitalize aria-pressed:border-foreground/40 aria-pressed:text-foreground" > {mode === "team" ? Team : Private} ))}
); } export function CreateBotForm({ onCreate, onCancel, }: { onCreate: (input: { name: string; title: string; description: string; computerMode: ComputerMode; }) => Promise; onCancel: () => void; }) { const { t } = useLingui(); const ids = useId(); const [name, setName] = useState(""); const [title, setTitle] = useState(""); const [description, setDescription] = useState(""); const [computerMode, setComputerMode] = useState("team"); const [submitting, setSubmitting] = useState(false); const [error, setError] = useState(null); async function handleSubmit() { if (!name.trim() || submitting) return; setError(null); setSubmitting(true); try { await onCreate({ name: name.trim(), title: title.trim(), description: description.trim(), computerMode, }); } catch (err) { setError(err instanceof Error ? err.message : t`Could not create bot`); } finally { setSubmitting(false); } } return (
New bot
{error ? (

{error}

) : null}