docs: add evolution config controls (#2852)
* docs: add evolution config controls * docs: address evolution config review
This commit is contained in:
1 parent
255a67e2da
commit
223ebdf0c7
12 files changed
+414
-1
No files matched your search
@@ -20,6 +20,7 @@ import {
|
||||
AgentDefaultsSection,
|
||||
CronSection,
|
||||
DevicesSection,
|
||||
EvolutionSection,
|
||||
ExecSection,
|
||||
LauncherSection,
|
||||
MCPSection,
|
||||
@@ -33,6 +34,7 @@ import {
|
||||
type MCPServerForm,
|
||||
buildFormFromConfig,
|
||||
parseCIDRText,
|
||||
parseFloatField,
|
||||
parseIntField,
|
||||
parseJSONObjectField,
|
||||
parseMultilineList,
|
||||
@@ -281,6 +283,16 @@ export function ConfigPage() {
|
||||
"Cron exec timeout",
|
||||
{ min: 0 },
|
||||
)
|
||||
const evolutionMinTaskCount = parseIntField(
|
||||
form.evolutionMinTaskCount,
|
||||
"Evolution minimum task count",
|
||||
{ min: 1 },
|
||||
)
|
||||
const evolutionMinSuccessRatio = parseFloatField(
|
||||
form.evolutionMinSuccessRatio,
|
||||
"Evolution minimum success ratio",
|
||||
{ min: 0.01, max: 1 },
|
||||
)
|
||||
const mcpDiscoveryValidationEnabled =
|
||||
form.mcpEnabled && form.mcpDiscoveryEnabled
|
||||
const mcpDiscoveryPatch: Record<string, unknown> = {
|
||||
@@ -500,6 +512,20 @@ export function ConfigPage() {
|
||||
session: {
|
||||
dm_scope: dmScope,
|
||||
},
|
||||
evolution: {
|
||||
enabled: form.evolutionEnabled,
|
||||
mode: form.evolutionMode,
|
||||
state_dir:
|
||||
form.evolutionStateDir.trim() === ""
|
||||
? null
|
||||
: form.evolutionStateDir.trim(),
|
||||
min_task_count: evolutionMinTaskCount,
|
||||
min_success_ratio: evolutionMinSuccessRatio,
|
||||
cold_path_trigger: form.evolutionColdPathTrigger,
|
||||
cold_path_times: parseMultilineList(
|
||||
form.evolutionColdPathTimesText,
|
||||
),
|
||||
},
|
||||
tools: {
|
||||
cron: {
|
||||
allow_command: form.allowCommand,
|
||||
@@ -661,6 +687,8 @@ export function ConfigPage() {
|
||||
|
||||
<RuntimeSection form={form} onFieldChange={updateField} />
|
||||
|
||||
<EvolutionSection form={form} onFieldChange={updateField} />
|
||||
|
||||
<MCPSection
|
||||
form={form}
|
||||
onFieldChange={updateField}
|
||||
|
||||
@@ -236,6 +236,152 @@ interface MCPSectionProps {
|
||||
) => void
|
||||
}
|
||||
|
||||
interface EvolutionSectionProps {
|
||||
form: CoreConfigForm
|
||||
onFieldChange: UpdateCoreField
|
||||
}
|
||||
|
||||
export function EvolutionSection({
|
||||
form,
|
||||
onFieldChange,
|
||||
}: EvolutionSectionProps) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<ConfigSectionCard
|
||||
title={t("pages.config.sections.evolution")}
|
||||
description={t("pages.config.evolution_section_hint")}
|
||||
>
|
||||
<SwitchCardField
|
||||
label={t("pages.config.evolution_enabled")}
|
||||
hint={t("pages.config.evolution_enabled_hint")}
|
||||
layout="setting-row"
|
||||
checked={form.evolutionEnabled}
|
||||
onCheckedChange={(checked) =>
|
||||
onFieldChange("evolutionEnabled", checked)
|
||||
}
|
||||
/>
|
||||
|
||||
<Field
|
||||
label={t("pages.config.evolution_mode")}
|
||||
hint={t("pages.config.evolution_mode_hint")}
|
||||
layout="setting-row"
|
||||
>
|
||||
<Select
|
||||
value={form.evolutionMode}
|
||||
onValueChange={(value) => onFieldChange("evolutionMode", value)}
|
||||
>
|
||||
<SelectTrigger aria-label={t("pages.config.evolution_mode")}>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="observe">
|
||||
{t("pages.config.evolution_mode_observe")}
|
||||
</SelectItem>
|
||||
<SelectItem value="draft">
|
||||
{t("pages.config.evolution_mode_draft")}
|
||||
</SelectItem>
|
||||
<SelectItem value="apply">
|
||||
{t("pages.config.evolution_mode_apply")}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
<Field
|
||||
label={t("pages.config.evolution_state_dir")}
|
||||
hint={t("pages.config.evolution_state_dir_hint")}
|
||||
layout="setting-row"
|
||||
>
|
||||
<Input
|
||||
value={form.evolutionStateDir}
|
||||
onChange={(e) => onFieldChange("evolutionStateDir", e.target.value)}
|
||||
placeholder="e.g. /var/lib/picoclaw/evolution"
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field
|
||||
label={t("pages.config.evolution_min_task_count")}
|
||||
hint={t("pages.config.evolution_min_task_count_hint")}
|
||||
layout="setting-row"
|
||||
>
|
||||
<Input
|
||||
type="number"
|
||||
min={1}
|
||||
value={form.evolutionMinTaskCount}
|
||||
onChange={(e) =>
|
||||
onFieldChange("evolutionMinTaskCount", e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field
|
||||
label={t("pages.config.evolution_min_success_ratio")}
|
||||
hint={t("pages.config.evolution_min_success_ratio_hint")}
|
||||
layout="setting-row"
|
||||
>
|
||||
<Input
|
||||
type="number"
|
||||
min={0.01}
|
||||
max={1}
|
||||
step="0.05"
|
||||
value={form.evolutionMinSuccessRatio}
|
||||
onChange={(e) =>
|
||||
onFieldChange("evolutionMinSuccessRatio", e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field
|
||||
label={t("pages.config.evolution_cold_path_trigger")}
|
||||
hint={t("pages.config.evolution_cold_path_trigger_hint")}
|
||||
layout="setting-row"
|
||||
>
|
||||
<Select
|
||||
value={form.evolutionColdPathTrigger}
|
||||
onValueChange={(value) =>
|
||||
onFieldChange("evolutionColdPathTrigger", value)
|
||||
}
|
||||
>
|
||||
<SelectTrigger
|
||||
aria-label={t("pages.config.evolution_cold_path_trigger")}
|
||||
>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="after_turn">
|
||||
{t("pages.config.evolution_cold_path_after_turn")}
|
||||
</SelectItem>
|
||||
<SelectItem value="scheduled">
|
||||
{t("pages.config.evolution_cold_path_scheduled")}
|
||||
</SelectItem>
|
||||
<SelectItem value="manual">
|
||||
{t("pages.config.evolution_cold_path_manual")}
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</Field>
|
||||
|
||||
{form.evolutionColdPathTrigger === "scheduled" && (
|
||||
<Field
|
||||
label={t("pages.config.evolution_cold_path_times")}
|
||||
hint={t("pages.config.evolution_cold_path_times_hint")}
|
||||
layout="setting-row"
|
||||
>
|
||||
<Textarea
|
||||
value={form.evolutionColdPathTimesText}
|
||||
placeholder={"03:00\n15:30"}
|
||||
className="min-h-[88px] font-mono text-xs"
|
||||
onChange={(e) =>
|
||||
onFieldChange("evolutionColdPathTimesText", e.target.value)
|
||||
}
|
||||
/>
|
||||
</Field>
|
||||
)}
|
||||
</ConfigSectionCard>
|
||||
)
|
||||
}
|
||||
|
||||
export function MCPSection({
|
||||
form,
|
||||
onFieldChange,
|
||||
|
||||
@@ -32,6 +32,13 @@ export interface CoreConfigForm {
|
||||
mcpDiscoveryUseBM25: boolean
|
||||
mcpDiscoveryUseRegex: boolean
|
||||
mcpServers: MCPServerForm[]
|
||||
evolutionEnabled: boolean
|
||||
evolutionMode: string
|
||||
evolutionStateDir: string
|
||||
evolutionMinTaskCount: string
|
||||
evolutionMinSuccessRatio: string
|
||||
evolutionColdPathTrigger: string
|
||||
evolutionColdPathTimesText: string
|
||||
}
|
||||
|
||||
export type MCPServerType = "http" | "sse" | "stdio"
|
||||
@@ -121,6 +128,13 @@ export const EMPTY_FORM: CoreConfigForm = {
|
||||
mcpDiscoveryUseBM25: true,
|
||||
mcpDiscoveryUseRegex: false,
|
||||
mcpServers: [],
|
||||
evolutionEnabled: false,
|
||||
evolutionMode: "observe",
|
||||
evolutionStateDir: "",
|
||||
evolutionMinTaskCount: "2",
|
||||
evolutionMinSuccessRatio: "0.7",
|
||||
evolutionColdPathTrigger: "after_turn",
|
||||
evolutionColdPathTimesText: "",
|
||||
}
|
||||
|
||||
export const EMPTY_LAUNCHER_FORM: LauncherForm = {
|
||||
@@ -215,6 +229,7 @@ export function buildFormFromConfig(config: unknown): CoreConfigForm {
|
||||
const session = asRecord(root.session)
|
||||
const heartbeat = asRecord(root.heartbeat)
|
||||
const devices = asRecord(root.devices)
|
||||
const evolution = asRecord(root.evolution)
|
||||
const tools = asRecord(root.tools)
|
||||
const mcp = asRecord(tools.mcp)
|
||||
const mcpDiscovery = asRecord(mcp.discovery)
|
||||
@@ -335,6 +350,29 @@ export function buildFormFromConfig(config: unknown): CoreConfigForm {
|
||||
? EMPTY_FORM.mcpDiscoveryUseRegex
|
||||
: asBool(mcpDiscovery.use_regex),
|
||||
mcpServers: mapMCPServers(mcp.servers),
|
||||
evolutionEnabled:
|
||||
evolution.enabled === undefined
|
||||
? EMPTY_FORM.evolutionEnabled
|
||||
: asBool(evolution.enabled),
|
||||
evolutionMode: asString(evolution.mode) || EMPTY_FORM.evolutionMode,
|
||||
evolutionStateDir:
|
||||
asString(evolution.state_dir) || EMPTY_FORM.evolutionStateDir,
|
||||
evolutionMinTaskCount: asNumberString(
|
||||
evolution.min_task_count,
|
||||
EMPTY_FORM.evolutionMinTaskCount,
|
||||
),
|
||||
evolutionMinSuccessRatio: asNumberString(
|
||||
evolution.min_success_ratio,
|
||||
EMPTY_FORM.evolutionMinSuccessRatio,
|
||||
),
|
||||
evolutionColdPathTrigger:
|
||||
asString(evolution.cold_path_trigger) ||
|
||||
EMPTY_FORM.evolutionColdPathTrigger,
|
||||
evolutionColdPathTimesText: Array.isArray(evolution.cold_path_times)
|
||||
? evolution.cold_path_times
|
||||
.filter((value): value is string => typeof value === "string")
|
||||
.join("\n")
|
||||
: EMPTY_FORM.evolutionColdPathTimesText,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,6 +394,24 @@ export function parseIntField(
|
||||
return value
|
||||
}
|
||||
|
||||
export function parseFloatField(
|
||||
rawValue: string,
|
||||
label: string,
|
||||
options: { min?: number; max?: number } = {},
|
||||
): number {
|
||||
const value = Number(rawValue)
|
||||
if (!Number.isFinite(value)) {
|
||||
throw new Error(`${label} must be a number.`)
|
||||
}
|
||||
if (options.min !== undefined && value < options.min) {
|
||||
throw new Error(`${label} must be >= ${options.min}.`)
|
||||
}
|
||||
if (options.max !== undefined && value > options.max) {
|
||||
throw new Error(`${label} must be <= ${options.max}.`)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
export function parseCIDRText(raw: string): string[] {
|
||||
if (!raw.trim()) {
|
||||
return []
|
||||
|
||||
Reference in new issue
Block a user