- PEP-30: .peppa/memory.md in the project repo (core/memory.ts), agent MCP get_memory/remember (dedupe, 12k size limit, replace to compact), runner appends memory + last finished stories to the launch rules, RULES.md rule, memory on the project «Спеки» tab. - PEP-41: agent settings platform → project → story (provider, model, effort, escalation model after N failures, fallback provider); Claude --effort / Codex model_reasoning_effort; sticky escalation relaunches a live runner on the stronger model (sendWithEscalation from CI feedback and the reviewer); fallback provider when the main one has no working subscription; web panels, MCP PM `agent`, CLI `peppa project agent`. - PEP-31: first-run checklist on the home page (core/onboarding.ts), hide button, «Агенты не запустятся» warning on the project page when its pool has no working subscription. No migrations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
116 lines
6.2 KiB
TypeScript
116 lines
6.2 KiB
TypeScript
// PEP-41: provider / model / effort of the agent and escalation (project and story).
|
||
import { AGENT_EFFORT_RU, AGENT_EFFORTS, AGENT_PROVIDERS, agentSettingsLabel, type AgentSettings, type AgentSettingsPatch, type Escalation } from "@peppa/core";
|
||
import { setAgentSettingsAction } from "@/app/(app)/actions";
|
||
import { Hidden } from "@/components/cards";
|
||
import { Badge } from "@/components/ui/badge";
|
||
import { Button } from "@/components/ui/button";
|
||
import { Input, Label, NativeSelect } from "@/components/ui/input";
|
||
|
||
const PROVIDER_RU: Record<string, string> = { claude: "Claude Code", codex: "Codex", opencode: "OpenCode" };
|
||
const inherit = (v: string | number | null | undefined, none = "по умолчанию") => (v == null ? none : `как выше: ${v}`);
|
||
|
||
function ProviderSelect({ name, own, inherited, none }: { name: string; own?: string | null; inherited?: string | null; none?: string }) {
|
||
return (
|
||
<NativeSelect name={name} defaultValue={own ?? ""} className="h-8">
|
||
<option value="">{inherit(inherited ? PROVIDER_RU[inherited] : null, none)}</option>
|
||
{AGENT_PROVIDERS.map((p) => (
|
||
<option key={p} value={p}>{PROVIDER_RU[p]}</option>
|
||
))}
|
||
</NativeSelect>
|
||
);
|
||
}
|
||
|
||
function EffortSelect({ name, own, inherited }: { name: string; own?: string | null; inherited?: string | null }) {
|
||
return (
|
||
<NativeSelect name={name} defaultValue={own ?? ""} className="h-8">
|
||
<option value="">{inherit(inherited ? AGENT_EFFORT_RU[inherited as keyof typeof AGENT_EFFORT_RU] : null)}</option>
|
||
{AGENT_EFFORTS.map((e) => (
|
||
<option key={e} value={e}>{AGENT_EFFORT_RU[e]}</option>
|
||
))}
|
||
</NativeSelect>
|
||
);
|
||
}
|
||
|
||
/** «⋯ Настройки проекта → Модель агента». */
|
||
export function AgentModelPanel({ projectId, own, inherited, back }: { projectId: number; own: AgentSettingsPatch; inherited: AgentSettings; back: string }) {
|
||
return (
|
||
<form action={setAgentSettingsAction} className="flex flex-col gap-3">
|
||
<Hidden fields={{ projectId, back }} />
|
||
<Label>
|
||
Провайдер
|
||
<ProviderSelect name="provider" own={own.provider} inherited={inherited.provider} none="решает подписка" />
|
||
</Label>
|
||
<div className="grid grid-cols-2 gap-2">
|
||
<Label>
|
||
Модель
|
||
<Input name="model" defaultValue={own.model ?? ""} placeholder={inherited.model ?? "по умолчанию CLI"} className="h-8" />
|
||
</Label>
|
||
<Label>
|
||
Усилия
|
||
<EffortSelect name="effort" own={own.effort} inherited={inherited.effort} />
|
||
</Label>
|
||
</div>
|
||
<p className="m-0 text-xs font-medium">Эскалация после неудач</p>
|
||
<div className="grid grid-cols-2 gap-2">
|
||
<Label>
|
||
Сильная модель
|
||
<Input name="escalateModel" defaultValue={own.escalateModel ?? ""} placeholder={inherited.escalateModel ?? "нет — без эскалации"} className="h-8" />
|
||
</Label>
|
||
<Label>
|
||
Усилия
|
||
<EffortSelect name="escalateEffort" own={own.escalateEffort} inherited={inherited.escalateEffort} />
|
||
</Label>
|
||
</div>
|
||
<Label>
|
||
После скольких неудач (пусто — {inherited.escalateAfter ?? "никогда"}, 0 — выключить)
|
||
<Input name="escalateAfter" type="number" min={0} max={20} defaultValue={own.escalateAfter === undefined ? "" : (own.escalateAfter ?? 0)} className="h-8" />
|
||
</Label>
|
||
<p className="m-0 text-xs font-medium">Запасной провайдер</p>
|
||
<div className="grid grid-cols-2 gap-2">
|
||
<Label>
|
||
Провайдер
|
||
<ProviderSelect name="fallbackProvider" own={own.fallbackProvider} inherited={inherited.fallbackProvider} none="нет" />
|
||
</Label>
|
||
<Label>
|
||
Модель
|
||
<Input name="fallbackModel" defaultValue={own.fallbackModel ?? ""} placeholder={inherited.fallbackModel ?? "по умолчанию CLI"} className="h-8" />
|
||
</Label>
|
||
</div>
|
||
<p className="m-0 text-xs text-muted-foreground">
|
||
Модель — для <code>--model</code> (sonnet, opus, gpt-5-codex…), действует только на своего провайдера. Неудачи — красные проверки по разным коммитам и возвраты ревьюера; после порога стори до конца идёт на сильной модели, живой раннер перезапускается в том же разговоре. Запасной провайдер — если у основного нет рабочей подписки в пуле.
|
||
</p>
|
||
<Button size="sm" className="self-start">Сохранить</Button>
|
||
</form>
|
||
);
|
||
}
|
||
|
||
/** Story page: provider / model / effort for this story only, and the escalation mark. */
|
||
export function TaskAgentModel({ taskKey, own, inherited, escalation, back }: { taskKey: string; own: AgentSettingsPatch; inherited: AgentSettings; escalation: Escalation | null; back: string }) {
|
||
return (
|
||
<form action={setAgentSettingsAction} className="flex flex-wrap items-end gap-2">
|
||
<Hidden fields={{ taskKey, back }} />
|
||
<Label className="flex-[1_1_9rem]">
|
||
Провайдер стори
|
||
<ProviderSelect name="provider" own={own.provider} inherited={inherited.provider} none="решает подписка" />
|
||
</Label>
|
||
<Label className="flex-[1_1_9rem]">
|
||
Модель
|
||
<Input name="model" defaultValue={own.model ?? ""} placeholder={inherited.model ?? "по умолчанию"} className="h-8" />
|
||
</Label>
|
||
<Label className="flex-[1_1_9rem]">
|
||
Усилия
|
||
<EffortSelect name="effort" own={own.effort} inherited={inherited.effort} />
|
||
</Label>
|
||
<Button size="sm" variant="outline">Сохранить</Button>
|
||
<p className="m-0 flex w-full flex-wrap items-center gap-2 text-xs text-muted-foreground">
|
||
Сейчас: {agentSettingsLabel({ ...inherited, ...own })}
|
||
{escalation && (
|
||
<Badge variant="warn" title={`с ${escalation.at.slice(0, 16).replace("T", " ")}`}>
|
||
эскалация на {escalation.model} после {escalation.failures} неудач
|
||
</Badge>
|
||
)}
|
||
</p>
|
||
</form>
|
||
);
|
||
}
|