peppa/apps/web/app/(app)/team/page.tsx
Асель 5b41e7d779 PEP-75: a team of agents — Kazakh names on the board, a character in the prompt
Also: «Открыть терминал» on live session cards.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 18:49:34 +05:00

97 lines
5.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Plus } from "lucide-react";
import { AGENT_CHARACTER_MAX, isSuperadmin, listAgents } from "@peppa/core";
import { AgentBadge } from "@/components/AgentBadge";
import { Empty, Flash, Notice, PageHeader, Section } from "@/components/common";
import { Markdown } from "@/components/Markdown";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { Input, Label, Textarea } from "@/components/ui/input";
import { Workspace } from "@/components/Workspace";
import { requireUser } from "@/lib/auth";
import { db } from "@/lib/db";
import { addAgentAction, saveAgentAction, toggleAgentAction } from "./actions";
export const metadata = { title: "Команда — Пеппа" };
/** PEP-75: the platform's team of agents — names and characters. Everyone sees it; a superadmin edits. */
export default async function Team({ searchParams }: { searchParams: Promise<{ error?: string; saved?: string }> }) {
const user = await requireUser();
const { error, saved } = await searchParams;
const [team, admin] = await Promise.all([listAgents(db), isSuperadmin(db, user)]);
return (
<Workspace>
<div className="max-w-3xl">
<Flash error={error} />
{saved && <Notice>Сохранено — агент получит новый характер при следующем запуске или перезапуске.</Notice>}
<PageHeader title="Команда">
Агенты Пеппы — постоянные персонажи, одна команда на все проекты. Раннер берёт свободного агента на стори, и тот ведёт её до конца; если все заняты — в команде
появляется новый. Характер агента добавляется к его промпту поверх правил Пеппы и AGENTS.md проекта.
</PageHeader>
{admin && (
<Card>
<form action={addAgentAction} className="flex flex-wrap items-end gap-2">
<Label className="min-w-48 flex-1">
Новый агент
<Input name="name" placeholder="Имя — или пусто: Пеппа выберет сама" maxLength={40} autoComplete="off" />
</Label>
<Button variant="default">
<Plus /> Добавить
</Button>
</form>
</Card>
)}
<Section title="Агенты" count={team.length}>
{team.length === 0 && <Empty>Пока никого: первый агент появится, когда стори уйдёт «В работу».</Empty>}
{team.map((a) => (
<Card key={a.id} id={`agent-${a.id}`} className="gap-3" data-agent={a.name}>
<div className="flex flex-wrap items-center gap-2">
<AgentBadge name={a.name} large />
{a.busy > 0 ? <Badge variant="info">работает{a.busy > 1 ? ` ×${a.busy}` : ""}</Badge> : <Badge variant="muted">свободен</Badge>}
{a.disabledAt && <Badge variant="danger">не в команде</Badge>}
<span className="ml-auto text-xs text-muted-foreground">запусков: {a.runs}</span>
</div>
{admin ? (
<>
<form action={saveAgentAction} className="flex flex-col gap-2">
<input type="hidden" name="id" value={a.id} />
<Label className="max-w-xs">
Имя
<Input name="name" defaultValue={a.name} required maxLength={40} autoComplete="off" />
</Label>
<Label>
Характер и специализация
<Textarea
name="character"
defaultValue={a.character}
rows={a.character ? 8 : 3}
maxLength={AGENT_CHARACTER_MAX}
placeholder={"Например: педант по безопасности — любой ввод проверяет, секреты ищет в каждом диффе. Пишет коротко и сухо, без извинений."}
className="text-sm"
/>
</Label>
<Button className="self-start" size="sm" variant="default">Сохранить</Button>
</form>
<form action={toggleAgentAction}>
<input type="hidden" name="id" value={a.id} />
<input type="hidden" name="disabled" value={a.disabledAt ? "0" : "1"} />
<Button size="sm" variant="ghost" className="text-muted-foreground">
{a.disabledAt ? "Вернуть в команду" : "Убрать из команды — новые стори не получит"}
</Button>
</form>
</>
) : a.character ? (
<Markdown text={a.character} />
) : (
<p className="m-0 text-sm text-muted-foreground">Характер не задан.</p>
)}
</Card>
))}
</Section>
</div>
</Workspace>
);
}