Files
archie/ui/src/settings/SystemTasksPage.vue
T

113 lines
4.9 KiB
Vue

<script setup lang="ts">
import ApplyStatusRows from "./ApplyStatusRows.vue";
import { computed, onMounted } from "vue";
import { storeToRefs } from "pinia";
import {Input} from "@/components/ui/input";
import PageHeader from "@/base/PageHeader.vue";
import { DurationInput, formatGoDuration, parseGoDuration } from "@/components/ui/duration-input";
import {
NumberField,
NumberFieldContent,
NumberFieldDecrement,
NumberFieldIncrement,
NumberFieldInput,
} from "@/components/ui/number-field";
import { SettingRow } from "@/components/ui/setting-row";
import { resourcesForPage, useControlPlaneStore } from "@/stores/control-plane";
import DraftHint from "./DraftHint.vue";
import HistoryLink from "./HistoryLink.vue";
const POLICY="task-policy";
const KIND = "workflow-execution-settings";
interface ExecutionSettings {
max_model_tool_steps: number;
max_runtime_seconds: number;
max_consecutive_gate_failures: number;
max_task_runtime_seconds: number | null;
}
const store = useControlPlaneStore();
const { catalog, catalogError } = storeToRefs(store);
onMounted(store.load);
const resources = computed(() => resourcesForPage(catalog.value, "tasks"));
const policy=computed(()=>store.drafts[POLICY]?.value as {diff_cap_lines:number;notify_webhook:string}|undefined);
const limits = computed(() => store.drafts[KIND]?.value as ExecutionSettings | undefined);
const error = computed(() => store.pageErrorFor(KIND));
// The document counts seconds; the input speaks durations.
function seconds(key: "max_runtime_seconds" | "max_task_runtime_seconds") {
return computed({
get: () => formatGoDuration((limits.value?.[key] ?? 0) * 1000),
set: (text: string) => {
const ms = parseGoDuration(text);
if (limits.value && ms !== null) limits.value[key] = Math.round(ms / 1000);
},
});
}
const callRuntime = seconds("max_runtime_seconds");
const taskRuntime = seconds("max_task_runtime_seconds");
</script>
<template>
<div>
<PageHeader title="Task execution">
<HistoryLink :kinds="resources.map((r) => r.kind)" />
</PageHeader>
<ApplyStatusRows v-for="resource in resources" :key="resource.kind" :kind="resource.kind" class="mb-4" />
<p v-if="catalogError || error || store.pageErrorFor(POLICY)" class="mb-4 text-sm text-danger" role="alert">
{{ catalogError || error || store.pageErrorFor(POLICY) }}
</p>
<template v-if="policy">
<SettingRow label="Maximum changed lines" hint="Applied to new tasks. 0 disables the limit." for="task-diff-cap">
<div class="flex flex-wrap items-center gap-3"><Input id="task-diff-cap" v-model.number="policy.diff_cap_lines" type="number" min="0" class="max-w-40" /><DraftHint :kind="POLICY" path="diff_cap_lines" /></div>
</SettingRow>
<SettingRow label="Notification webhook" hint="Applied to new tasks. Empty disables notifications." for="task-notify">
<div class="flex flex-wrap items-center gap-3"><Input id="task-notify" v-model="policy.notify_webhook" type="url" class="max-w-md" /><DraftHint :kind="POLICY" path="notify_webhook" /></div>
</SettingRow>
</template>
<template v-if="limits">
<SettingRow label="Task time limit" for="te-task" hint="Parked after this. 0 disables.">
<div class="flex flex-wrap items-center gap-3">
<DurationInput id="te-task" v-model="taskRuntime" :units="['m', 'h']" />
<DraftHint :kind="KIND" path="max_task_runtime_seconds" />
</div>
</SettingRow>
<SettingRow label="Agent call time limit" for="te-call" hint="0 disables.">
<div class="flex flex-wrap items-center gap-3">
<DurationInput id="te-call" v-model="callRuntime" :units="['s', 'm', 'h']" />
<DraftHint :kind="KIND" path="max_runtime_seconds" />
</div>
</SettingRow>
<SettingRow label="Model tool steps" hint="Per agent call. 0 disables.">
<div class="flex flex-wrap items-center gap-3">
<NumberField v-model="limits.max_model_tool_steps" :min="0" class="w-32">
<NumberFieldContent>
<NumberFieldDecrement />
<NumberFieldInput class="font-mono" aria-label="Model tool steps" />
<NumberFieldIncrement />
</NumberFieldContent>
</NumberField>
<DraftHint :kind="KIND" path="max_model_tool_steps" />
</div>
</SettingRow>
<SettingRow label="Gate failures in a row" hint="In a row, then parked.">
<div class="flex flex-wrap items-center gap-3">
<NumberField v-model="limits.max_consecutive_gate_failures" :min="0" class="w-32">
<NumberFieldContent>
<NumberFieldDecrement />
<NumberFieldInput class="font-mono" aria-label="Gate failures in a row" />
<NumberFieldIncrement />
</NumberFieldContent>
</NumberField>
<DraftHint :kind="KIND" path="max_consecutive_gate_failures" />
</div>
</SettingRow>
</template>
</div>
</template>