Each control-plane kind has one store-owned TanStack form, so edits survive navigation and the save bar submits every dirty section. Shared editors emit new values, map entries are written whole, unset resources stay null, and the container runtime page warns when max uptime is under the task limit.
202 lines
9.8 KiB
Vue
202 lines
9.8 KiB
Vue
<script setup lang="ts">
|
|
import { computed, onMounted, ref, watch } from "vue";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Textarea } from "@/components/ui/textarea";
|
|
import { Switch } from "@/components/ui/switch";
|
|
import { DurationInput } from "@/components/ui/duration-input";
|
|
import { Section } from "@/components/ui/section";
|
|
import { Field, FieldContent, FieldGroup, FieldLabel } from "@/components/ui/field";
|
|
import { useSettingsStore } from "@/stores/settings";
|
|
import ApplyStatusRows from "@/settings/ApplyStatusRows.vue";
|
|
import HistoryLink from "@/settings/HistoryLink.vue";
|
|
import PageHeader from "@/base/PageHeader.vue";
|
|
import {
|
|
Empty,
|
|
EmptyDescription,
|
|
EmptyHeader,
|
|
EmptyTitle,
|
|
} from "@/components/ui/empty";
|
|
import { api } from "@/lib/api";
|
|
import { useLiveResource } from "@/stores/session";
|
|
import CuratorCard, { type Curator } from "./CuratorCard.vue";
|
|
|
|
/**
|
|
* Backed by GET /api/curators, which reads the daemon's live curator registry:
|
|
* which curators are registered, their point-in-time health, and their recent
|
|
* activity, with the reason each action happened.
|
|
*/
|
|
|
|
interface Definition {
|
|
name: string; enabled: boolean; instructions: string; interval: string; cooldown: string;
|
|
on_input: boolean; tools: string[]; skills: boolean; memory_engine: string; conversations: boolean; model: string;
|
|
}
|
|
const KIND = "curators";
|
|
const store = useSettingsStore();
|
|
onMounted(store.load);
|
|
const form = computed(() => store.formFor(KIND));
|
|
const definitions = computed(() => store.draftValue(KIND) as Definition[] | null);
|
|
const editing = ref(false);
|
|
const newName = ref("");
|
|
// The list is the whole document, so adding or removing rebuilds it.
|
|
function add() {
|
|
const name = newName.value.trim();
|
|
if (!name || definitions.value?.some(def => def.name === name)) return;
|
|
if (!form.value) return;
|
|
const def: Definition = {name,enabled:false,instructions:"",interval:"1h",cooldown:"0s",on_input:false,tools:[],skills:false,memory_engine:"",conversations:false,model:""};
|
|
store.setDraftValue(KIND, [...(definitions.value ?? []), def]);
|
|
newName.value = "";
|
|
}
|
|
function remove(index: number) {
|
|
store.setDraftValue(KIND, (definitions.value ?? []).filter((_, i) => i !== index));
|
|
}
|
|
function toolsFromText(value: string | number): string[] {
|
|
return String(value).split(",").map(tool => tool.trim()).filter(Boolean);
|
|
}
|
|
watch(() => store.applyStatusFor(KIND).map(row => row.version).join(","), () => void load());
|
|
const curators = ref<Curator[]>([]);
|
|
const loadError = ref<string | null>(null);
|
|
|
|
async function load() {
|
|
try {
|
|
const res = await api.curators<{ curators?: Curator[] }>();
|
|
curators.value = res?.curators || [];
|
|
loadError.value = null;
|
|
} catch (err) {
|
|
loadError.value = String((err as Error).message || err);
|
|
}
|
|
}
|
|
|
|
useLiveResource("curators", () => void load());
|
|
onMounted(load);
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<PageHeader title="Curators"><HistoryLink :kinds="[KIND]" /><Button variant="outline" @click="editing = !editing">{{ editing ? "Hide definitions" : "Edit definitions" }}</Button></PageHeader>
|
|
<ApplyStatusRows :kind="KIND" class="mb-4" />
|
|
<p v-if="store.catalogError || store.pageErrorFor(KIND)" class="mb-4 text-sm text-danger" role="alert">{{ store.catalogError || store.pageErrorFor(KIND) }}</p>
|
|
<div v-if="editing" class="mb-6">
|
|
<form class="mb-4 flex gap-2" @submit.prevent="add"><Input v-model="newName" aria-label="Curator name" placeholder="Curator name" class="max-w-xs" /><Button type="submit" :disabled="!newName.trim() || definitions?.some(def => def.name === newName.trim())">Add curator</Button></form>
|
|
<Empty v-if="!definitions?.length"><EmptyHeader><EmptyTitle>No custom curator definitions</EmptyTitle></EmptyHeader></Empty>
|
|
<Section v-for="(def, index) in definitions" :key="index" :title="def.name">
|
|
<template #action><Button variant="ghost" size="sm" @click="remove(index)">Remove curator</Button></template>
|
|
<FieldGroup v-if="form" class="@container/field-group">
|
|
<form.Field v-slot="{ field }" :name="`${index}.enabled`">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel>Enabled</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Switch :model-value="field.state.value" :aria-label="`${def.name} enabled`" @update:model-value="field.handleChange" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" :name="`${index}.instructions`">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel :for="`curator-${index}-instructions`">Instructions</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Textarea :id="`curator-${index}-instructions`" :model-value="field.state.value" @blur="field.handleBlur" @update:model-value="field.handleChange" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" :name="`${index}.interval`">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel>Interval</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<DurationInput :model-value="field.state.value" :units="['s', 'm', 'h']" @update:model-value="field.handleChange" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" :name="`${index}.cooldown`">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel>Cooldown</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<DurationInput :model-value="field.state.value" :units="['s', 'm', 'h']" @update:model-value="field.handleChange" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" :name="`${index}.on_input`">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel>Wake on input</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Switch :model-value="field.state.value" :aria-label="`${def.name} wake on input`" @update:model-value="field.handleChange" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" :name="`${index}.tools`">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel :for="`curator-${index}-tools`">Tools</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input
|
|
:id="`curator-${index}-tools`"
|
|
:model-value="(field.state.value ?? []).join(', ')"
|
|
@blur="field.handleBlur"
|
|
@update:model-value="(value) => field.handleChange(toolsFromText(value))"
|
|
/>
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" :name="`${index}.skills`">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel>Skills</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Switch :model-value="field.state.value" :aria-label="`${def.name} skills`" @update:model-value="field.handleChange" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" :name="`${index}.memory_engine`">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel :for="`curator-${index}-memory`">Memory engine</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input :id="`curator-${index}-memory`" :model-value="field.state.value" @blur="field.handleBlur" @update:model-value="field.handleChange" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" :name="`${index}.conversations`">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel>Conversations</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Switch :model-value="field.state.value" :aria-label="`${def.name} conversations`" @update:model-value="field.handleChange" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
|
|
<form.Field v-slot="{ field }" :name="`${index}.model`">
|
|
<Field orientation="responsive">
|
|
<FieldContent><FieldLabel :for="`curator-${index}-model`">Model</FieldLabel></FieldContent>
|
|
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
|
|
<Input :id="`curator-${index}-model`" :model-value="field.state.value" placeholder="Default model" @blur="field.handleBlur" @update:model-value="field.handleChange" />
|
|
</div>
|
|
</Field>
|
|
</form.Field>
|
|
</FieldGroup>
|
|
</Section>
|
|
</div>
|
|
|
|
<div
|
|
class="grid grid-cols-1 gap-4 lg:grid-cols-[repeat(auto-fit,minmax(340px,1fr))]"
|
|
>
|
|
<Empty v-if="loadError">
|
|
<EmptyHeader>
|
|
<EmptyTitle>Archie is not responding</EmptyTitle>
|
|
<EmptyDescription>{{ loadError }}</EmptyDescription>
|
|
</EmptyHeader>
|
|
</Empty>
|
|
<Empty v-else-if="!curators.length">
|
|
<EmptyHeader>
|
|
<EmptyTitle>No curators registered</EmptyTitle>
|
|
</EmptyHeader>
|
|
</Empty>
|
|
<CuratorCard v-for="c in curators" v-else :key="c.name" :curator="c" />
|
|
</div>
|
|
</div>
|
|
</template>
|