feat(controlplane): runtime administration over the State Store's gRPC server

The Web UI and messaging channels now read and write Archie's runtime
settings through one versioned, audited control-plane API hosted on the
State Store's existing gRPC server: catalog, query, command, watch. Each
feature owns its resource, validation and commands; storage only writes
versions and audit records.

Workflows move with it. Definitions become portable YAML compiled through
a closed, typed step registry and stored as a control-plane resource, so
the yaegi interpretation paths (internal/gate, wfeval, wfextract,
gateeval, gateextract, skillbuild) are deleted rather than carried.

The UI process reads definitions as data: the JSON projection lives in
internal/domain/workflow/task so a dashboard decodes the stored
collection without linking the workflow engine, which cmd/archie-ui's
deletion gate forbids. Shipped definitions ride the catalog descriptor
rather than a bespoke REST route, keeping the API to its four operations.

archie-messaging gains -state-store-target/-state-store-token and reads
channel settings from the database, failing closed when the State Store
is unreachable: the database is authoritative for those settings.
This commit is contained in:
sam committed 2026-09-21 08:17:42 +10:00
1 parent 2e172c679c
commit 924b02a1b0
131 files changed
+8510 -3371

No files matched your search

+2 -23
View File
@@ -12,20 +12,13 @@ export interface Channel {
</script>
<script setup lang="ts">
import { RefreshCw } from "@lucide/vue";
import { computed, ref } from "vue";
import { computed } from "vue";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import type { StatusKind } from "@/lib/status";
const props = defineProps<{ channel: Channel }>();
const emit = defineEmits<{ reload: [id: string] }>();
// In-flight state rather than mutating the button's disabled attribute: the
// element is re-rendered by Vue, so a DOM write would be discarded.
const reloading = ref(false);
function tone(state: string | undefined, configured: boolean | undefined): StatusKind {
if (state === "running") return "ok";
@@ -34,15 +27,6 @@ function tone(state: string | undefined, configured: boolean | undefined): Statu
}
const label = computed(() => props.channel.state || (props.channel.configured ? "configured" : "stopped"));
async function reload() {
reloading.value = true;
try {
emit("reload", props.channel.id || props.channel.name.toLowerCase());
} finally {
reloading.value = false;
}
}
</script>
<template>
@@ -53,12 +37,7 @@ async function reload() {
<Badge :variant="tone(props.channel.state, props.channel.configured)">{{ label }}</Badge>
</CardHeader>
<CardContent>
<p v-if="props.channel.detail" class="mb-3 text-sm text-fg-muted">{{ props.channel.detail }}</p>
<Button v-if="props.channel.reload_supported" variant="outline" :disabled="reloading" @click="reload">
<RefreshCw data-icon="inline-start" />
Reload
</Button>
<p v-else class="text-sm text-fg-subtle">Reload requires a daemon restart for this adapter.</p>
<p v-if="props.channel.detail" class="text-sm text-fg-muted">{{ props.channel.detail }}</p>
</CardContent>
</Card>
</template>
+11 -17
View File
@@ -1,9 +1,12 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { computed, onMounted, ref } from "vue";
import { storeToRefs } from "pinia";
import PageHeader from "@/base/PageHeader.vue";
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { api } from "@/lib/api";
import StructuredResourceCard from "@/settings/StructuredResourceCard.vue";
import { resourcesForPage, useControlPlaneStore } from "@/stores/control-plane";
import { useLiveResource } from "@/stores/live-updates";
import ChannelCard, { type Channel } from "./ChannelCard.vue";
@@ -11,6 +14,9 @@ import ChannelCard, { type Channel } from "./ChannelCard.vue";
const channels = ref<Channel[]>([]);
const error = ref<string | null>(null);
const controlPlane = useControlPlaneStore();
const { catalog } = storeToRefs(controlPlane);
const settings = computed(() => resourcesForPage(catalog.value, "channels"));
async function load() {
try {
@@ -22,19 +28,8 @@ async function load() {
}
}
/** Reload, then re-read: the adapter's new state is what the card shows, so a
* failed reload surfaces as the state it failed to leave. */
async function reload(id: string) {
try {
await api.channelReload(id);
} catch {
// Reported by the refreshed state below.
}
await load();
}
useLiveResource(null, () => void load());
onMounted(load);
onMounted(() => Promise.all([load(), controlPlane.load()]));
</script>
<template>
@@ -51,12 +46,11 @@ onMounted(load);
<Empty v-else-if="!channels.length">
<EmptyHeader>
<EmptyTitle>No channels configured</EmptyTitle>
<EmptyDescription>
Configure [chat.telegram] or [chat.webhook_addr] in config.toml to talk to Archie outside the dashboard.
</EmptyDescription>
<EmptyDescription>Add one below.</EmptyDescription>
</EmptyHeader>
</Empty>
<ChannelCard v-for="channel in channels" v-else :key="channel.id || channel.name" :channel="channel" @reload="reload" />
<ChannelCard v-for="channel in channels" v-else :key="channel.id || channel.name" :channel="channel" />
</div>
<StructuredResourceCard v-for="descriptor in settings" :key="descriptor.kind" :descriptor="descriptor" />
</div>
</template>
+2 -3
View File
@@ -42,19 +42,18 @@ interface GroupSpec {
}
const groups: GroupSpec[] = [
{ label: "Work", paths: ["/tasks", "/workflows"] },
{ label: "Work", paths: ["/tasks", "/workflows", "/channels", "/logs"] },
{ label: "Agent", paths: ["/skills", "/curators"] },
{ label: "Events", paths: ["/captures", "/mappings", "/bindings"] },
{
label: "System",
paths: [
"/system/status",
"/logs",
"/system/appearance",
"/system/tasks",
"/system/models",
"/system/repos",
"/channels",
"/system/identities",
"/system/advanced",
],
dividerBefore: { path: "/system/tasks", label: "Settings" },
+1 -1
View File
@@ -20,7 +20,7 @@ export function logsEmptyTitle(durableUnavailable: boolean, streamState: string)
*/
export function logsEmptyDetail(durableUnavailable: boolean, streamState: string): string {
if (streamState === "unavailable") {
return "The daemon is not serving the log stream. Reload once it is reachable.";
return "The log stream will reconnect automatically.";
}
if (durableUnavailable) {
return "This deployment keeps no durable history. Live daemon logs appear here while the page is open.";
+2
View File
@@ -8,6 +8,7 @@ import DashboardPage from "@/dashboard/DashboardPage.vue";
import LogsPage from "@/logs/LogsPage.vue";
import MappingsPage from "@/mappings/MappingsPage.vue";
import SystemAdvancedPage from "@/settings/SystemAdvancedPage.vue";
import SystemIdentitiesPage from "@/settings/SystemIdentitiesPage.vue";
import SystemAppearancePage from "@/settings/SystemAppearancePage.vue";
import SystemModelsPage from "@/settings/SystemModelsPage.vue";
import SystemReposPage from "@/settings/SystemReposPage.vue";
@@ -45,6 +46,7 @@ const routes = [
{ path: "/system/tasks", name: "system-tasks", component: SystemTasksPage, meta: { label: "Task settings", description: "Work lifecycle: statuses, operator actions, and budgets.", section: "settings" } },
{ path: "/system/models", name: "system-models", component: SystemModelsPage, meta: { label: "Models", description: "Model roles and the providers backing them.", section: "settings" } },
{ path: "/system/repos", name: "system-repos", component: SystemReposPage, meta: { label: "Repositories", description: "Repositories Archie watches, and their per-repo gate overrides.", section: "settings" } },
{ path: "/system/identities", name: "system-identities", component: SystemIdentitiesPage, meta: { label: "Identities", description: "Persistent actors and lifecycle.", section: "settings" } },
{ path: "/channels", name: "channels", component: ChannelsPage, meta: { label: "Channels", description: "Inbound chat and notification channels, and their state.", section: "channels" } },
{ path: "/system/advanced", name: "system-advanced", component: SystemAdvancedPage, meta: { label: "Advanced", description: "Identity, storage, sandboxing, and dangerous actions.", section: "settings" } },
{ path: "/settings", redirect: "/system/status", meta: { nav: false } },
@@ -0,0 +1,117 @@
<script setup lang="ts">
import { computed, reactive, watch } from "vue";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Field, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Spinner } from "@/components/ui/spinner";
import { useControlPlaneStore, type ResourceDescriptor } from "@/stores/control-plane";
import ConfigCard from "./ConfigCard.vue";
interface JSONSchemaProperty {
type?: "integer" | "number" | "string" | "boolean";
title?: string;
description?: string;
minimum?: number;
maximum?: number;
enum?: Array<string | number>;
}
const props = defineProps<{ descriptor: ResourceDescriptor }>();
const store = useControlPlaneStore();
const state = computed(() => store.stateFor(props.descriptor.kind));
const draft = reactive<Record<string, unknown>>({});
const touched = reactive<Record<string, boolean>>({});
const schema = computed(() => {
try { return JSON.parse(props.descriptor.schema_json) as { properties?: Record<string, JSONSchemaProperty> }; }
catch { return {}; }
});
const fields = computed(() => Object.entries(schema.value.properties ?? {}));
watch(() => state.value.resource, (resource) => {
if (!resource) return;
for (const key of Object.keys(draft)) delete draft[key];
Object.assign(draft, resource.value as Record<string, unknown>);
}, { immediate: true });
function label(key: string, property: JSONSchemaProperty): string {
if (property.title) return property.title;
const taskLabels: Record<string, string> = {
max_model_tool_steps: "Max model steps",
max_runtime_seconds: "Max runtime (seconds)",
max_consecutive_gate_failures: "Max gate failures",
};
return taskLabels[key] ?? key.replaceAll("_", " ").replace(/^./, (value) => value.toUpperCase());
}
function update(key: string, property: JSONSchemaProperty, value: unknown): void {
touched[key] = true;
if (property.type === "integer" || property.type === "number") draft[key] = Number(value);
else if (property.type === "boolean") draft[key] = value === true || value === "true";
else draft[key] = value;
}
function invalid(key: string, property: JSONSchemaProperty): boolean {
if (!touched[key]) return false;
const value = draft[key];
if ((property.type === "integer" || property.type === "number") && !Number.isFinite(value)) return true;
if (typeof value === "number" && property.minimum !== undefined && value < property.minimum) return true;
if (typeof value === "number" && property.maximum !== undefined && value > property.maximum) return true;
return false;
}
async function save(): Promise<void> {
for (const [key] of fields.value) touched[key] = true;
if (fields.value.some(([key, property]) => invalid(key, property))) return;
if (await store.replace(props.descriptor.kind, { ...draft })) {
for (const key of Object.keys(touched)) touched[key] = false;
}
}
</script>
<template>
<ConfigCard :title="descriptor.title">
<form class="flex flex-col gap-5" @submit.prevent="save">
<FieldGroup>
<Field v-for="[key, property] in fields" :key="key" :data-invalid="invalid(key, property)">
<FieldLabel :for="`${descriptor.kind}-${key}`">{{ label(key, property) }}</FieldLabel>
<Select v-if="property.type === 'boolean' || property.enum" :model-value="String(draft[key])" @update:model-value="update(key, property, $event)">
<SelectTrigger :id="`${descriptor.kind}-${key}`" :aria-invalid="invalid(key, property)"><SelectValue /></SelectTrigger>
<SelectContent><SelectGroup>
<SelectItem v-for="option in property.enum ?? ['true', 'false']" :key="String(option)" :value="String(option)">{{ option }}</SelectItem>
</SelectGroup></SelectContent>
</Select>
<Input
v-else
:id="`${descriptor.kind}-${key}`"
:model-value="draft[key] as string | number"
:type="property.type === 'integer' || property.type === 'number' ? 'number' : 'text'"
:min="property.minimum"
:max="property.maximum"
:step="property.type === 'integer' ? 1 : undefined"
:aria-invalid="invalid(key, property)"
autocomplete="off"
@update:model-value="update(key, property, $event)"
/>
<FieldDescription v-if="property.description">{{ property.description }}</FieldDescription>
<FieldDescription v-if="invalid(key, property)" class="text-destructive">Enter a valid value.</FieldDescription>
</Field>
</FieldGroup>
<p v-if="state.error" class="text-sm text-destructive" role="alert">{{ state.error }}</p>
<div class="flex items-center justify-between gap-3">
<div class="flex items-center gap-2">
<Badge :variant="state.stream === 'live' ? 'ok' : 'warn'">{{ state.stream === 'live' ? 'Live' : 'Connecting' }}</Badge>
<Badge v-if="descriptor.apply_mode === 'restart-required'" variant="warn">Restart required</Badge>
<span v-if="state.resource" class="text-xs text-muted-foreground">Version {{ state.resource.version }}</span>
</div>
<Button type="submit" :disabled="state.saving || state.loading">
<Spinner v-if="state.saving" data-icon="inline-start" />
Save changes
</Button>
</div>
</form>
</ConfigCard>
</template>
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Spinner } from "@/components/ui/spinner";
import { cloneControlPlaneValue, useControlPlaneStore, type ResourceDescriptor } from "@/stores/control-plane";
import ConfigCard from "./ConfigCard.vue";
import StructuredValueEditor from "./StructuredValueEditor.vue";
const props = defineProps<{ descriptor: ResourceDescriptor; rootPath?: string }>();
const store = useControlPlaneStore();
const state = computed(() => store.stateFor(props.descriptor.kind));
const draft = ref<unknown>({});
watch(() => state.value.resource, (resource) => {
if (resource) draft.value = cloneControlPlaneValue(resource.value);
}, { immediate: true });
async function save(): Promise<void> {
await store.replace(props.descriptor.kind, cloneControlPlaneValue(draft.value));
}
</script>
<template>
<ConfigCard :title="descriptor.title">
<form class="space-y-5" @submit.prevent="save">
<StructuredValueEditor v-model="draft" :path="rootPath ?? descriptor.kind" />
<p v-if="state.error" class="text-sm text-destructive" role="alert">{{ state.error }}</p>
<div class="flex flex-wrap items-center justify-between gap-3">
<div class="flex items-center gap-2">
<Badge :variant="state.stream === 'live' ? 'ok' : 'warn'">{{ state.stream === 'live' ? 'Live' : 'Connecting' }}</Badge>
<Badge v-if="descriptor.apply_mode === 'restart-required'" variant="warn">Restart required</Badge>
<span v-if="state.resource" class="text-xs text-muted-foreground">Version {{ state.resource.version }}</span>
</div>
<Button type="submit" :disabled="state.saving || state.loading">
<Spinner v-if="state.saving" data-icon="inline-start" /> Save changes
</Button>
</div>
</form>
</ConfigCard>
</template>
+124
View File
@@ -0,0 +1,124 @@
<script setup lang="ts">
import { computed } from "vue";
import { Plus, Trash2 } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
const props = withDefaults(defineProps<{
modelValue: unknown;
path?: string;
locked?: boolean;
}>(), { path: "value", locked: false });
const emit = defineEmits<{ "update:modelValue": [value: unknown] }>();
const isArray = computed(() => Array.isArray(props.modelValue));
const isObject = computed(() => props.modelValue !== null && typeof props.modelValue === "object" && !isArray.value);
const entries = computed(() => Object.entries((props.modelValue ?? {}) as Record<string, unknown>));
const readOnly = computed(() => props.locked || /(^|\.)(has_credential|credential_configured|headers_configured)$/.test(props.path));
function label(value: string): string {
return value.replaceAll("_", " ").replace(/^./, (character) => character.toUpperCase());
}
function setObject(key: string, value: unknown): void {
emit("update:modelValue", { ...(props.modelValue as Record<string, unknown>), [key]: value });
}
function renameObject(oldKey: string, newKey: string): void {
const current = { ...(props.modelValue as Record<string, unknown>) };
const value = current[oldKey];
delete current[oldKey];
current[newKey] = value;
emit("update:modelValue", current);
}
function removeObject(key: string): void {
const current = { ...(props.modelValue as Record<string, unknown>) };
delete current[key];
emit("update:modelValue", current);
}
function addObject(): void {
const current = props.modelValue as Record<string, unknown>;
let index = 1;
while (`new_${index}` in current) index++;
emit("update:modelValue", { ...current, [`new_${index}`]: "" });
}
function setArray(index: number, value: unknown): void {
const current = [...(props.modelValue as unknown[])];
current[index] = value;
emit("update:modelValue", current);
}
function addArray(): void {
const current = props.modelValue as unknown[];
const sample = current[0];
let value: unknown = Array.isArray(sample) ? [] : sample && typeof sample === "object" ? {} : "";
if (props.path === "repositories") value = {
owner: "", name: "", base: "main", gate: [], protect: [], ecosystem: "go", preflight: [], test_glob: "",
persistent_storage: false, max_retries: 0, allow_concurrent: false, review_enabled: false,
};
else if (props.path.endsWith("mcp_servers")) value = {
name: "", transport: "stdio", command: "", args: [], work_dir: "", url: "",
sse_endpoint: "", message_endpoint: "", headers_configured: false,
};
else if (props.path.endsWith("gate") || props.path.endsWith("preflight")) value = [];
else if (props.path.endsWith("allowed_user_ids")) value = 0;
else if (props.path.endsWith("personas")) value = { name: "", prompt: "" };
else if (props.path === "schedules") value = {
id: "", pool: "sequential", detail: "", kind: "workflow",
schedule: { kind: "interval", interval: 3600000000000, start: "0001-01-01T00:00:00Z" },
target: {}, payload: { text: "" }, next_run: "0001-01-01T00:00:00Z",
created: "0001-01-01T00:00:00Z", updated: "0001-01-01T00:00:00Z",
};
emit("update:modelValue", [...current, value]);
}
function removeArray(index: number): void {
emit("update:modelValue", (props.modelValue as unknown[]).filter((_, itemIndex) => itemIndex !== index));
}
function scalar(value: string | number): void {
emit("update:modelValue", typeof props.modelValue === "number" ? Number(value) : value);
}
</script>
<template>
<div v-if="isArray" class="space-y-2 rounded-lg border border-border/70 p-3">
<div v-for="(item, index) in modelValue as unknown[]" :key="index" class="flex items-start gap-2">
<div class="min-w-0 flex-1">
<StructuredValueEditor :model-value="item" :path="`${path}.${index}`" @update:model-value="setArray(index, $event)" />
</div>
<Button type="button" variant="ghost" size="icon-sm" :aria-label="`Remove ${label(path)} row ${index + 1}`" @click="removeArray(index)">
<Trash2 />
</Button>
</div>
<Button type="button" variant="outline" size="sm" @click="addArray"><Plus /> Add row</Button>
</div>
<fieldset v-else-if="isObject" class="space-y-4 rounded-lg border border-border/70 p-3">
<div v-for="[key, value] in entries" :key="key" class="space-y-1.5">
<div class="flex items-center gap-2">
<Label :for="`${path}.${key}`" class="flex-1">{{ label(key) }}</Label>
<template v-if="path.endsWith('_map') || path.endsWith('labels') || path === 'providers' || path === 'roles'">
<Input class="h-7 max-w-48" :model-value="key" aria-label="Entry key" @change="renameObject(key, ($event.target as HTMLInputElement).value)" />
<Button type="button" variant="ghost" size="icon-sm" :aria-label="`Remove ${key}`" @click="removeObject(key)"><Trash2 /></Button>
</template>
</div>
<StructuredValueEditor :id="`${path}.${key}`" :model-value="value" :path="`${path}.${key}`" @update:model-value="setObject(key, $event)" />
</div>
<Button v-if="path.endsWith('_map') || path.endsWith('labels') || path === 'providers' || path === 'roles'" type="button" variant="outline" size="sm" @click="addObject"><Plus /> Add entry</Button>
</fieldset>
<div v-else-if="typeof modelValue === 'boolean'" class="flex min-h-9 items-center gap-2">
<Checkbox :id="path" :model-value="modelValue" :disabled="readOnly" @update:model-value="emit('update:modelValue', $event === true)" />
<span v-if="readOnly" class="text-xs text-muted-foreground">Reported by Archie</span>
</div>
<Textarea v-else-if="path.endsWith('.prompt')" :id="path" :model-value="modelValue as string" :readonly="readOnly" autocomplete="off" @update:model-value="scalar" />
<Input v-else :id="path" :model-value="modelValue as string | number" :type="typeof modelValue === 'number' ? 'number' : 'text'" :readonly="readOnly" autocomplete="off" @update:model-value="scalar" />
</template>
+20 -20
View File
@@ -1,27 +1,22 @@
<script setup lang="ts">
import { onMounted } from "vue";
import { computed, onMounted } from "vue";
import { storeToRefs } from "pinia";
import PageHeader from "@/base/PageHeader.vue";
import { useLiveResource } from "@/stores/live-updates";
import ConfigSections from "./ConfigSections.vue";
import ConfigUnavailable from "./ConfigUnavailable.vue";
import { Button } from "@/components/ui/button";
import { resourcesForPage, useControlPlaneStore } from "@/stores/control-plane";
import ConfigCard from "./ConfigCard.vue";
import DangerousActionsCard from "./DangerousActionsCard.vue";
import { ADVANCED_SECTIONS } from "./sections";
import { configUnavailable, loadConfig, loadDangerous } from "./state";
import StructuredResourceCard from "./StructuredResourceCard.vue";
import { loadDangerous } from "./state";
/**
* The settings that change where archied keeps its state and how it isolates
* task execution, who it is on the forge, and the actions that need explicit
* approval before they run.
*
* These are the fields with the longest reach: identity is what commits are
* attributed to, and the container fields decide what the agent runs in.
*/
const controlPlane = useControlPlaneStore();
const { catalog, catalogError } = storeToRefs(controlPlane);
const resources = computed(() => resourcesForPage(catalog.value, "advanced"));
async function load(): Promise<void> {
await Promise.all([loadConfig(), loadDangerous()]);
await Promise.all([controlPlane.load(), loadDangerous()]);
}
useLiveResource(null, () => void load());
onMounted(load);
</script>
@@ -29,10 +24,15 @@ onMounted(load);
<div>
<PageHeader title="Advanced" />
<ConfigUnavailable v-if="configUnavailable" />
<ConfigSections v-else :ids="ADVANCED_SECTIONS" />
<!-- Dangerous actions come from the daemon's own endpoint, not the config
projection, so a config that failed to load does not hide them. -->
<p v-if="catalogError" class="text-sm text-destructive" role="alert">{{ catalogError }}</p>
<StructuredResourceCard v-for="descriptor in resources" :key="descriptor.kind" :descriptor="descriptor" />
<ConfigCard title="Managed elsewhere">
<div class="flex flex-wrap gap-2">
<Button as-child variant="outline"><RouterLink to="/captures">Captured events</RouterLink></Button>
<Button as-child variant="outline"><RouterLink to="/mappings">Capture mappings</RouterLink></Button>
<Button as-child variant="outline"><RouterLink to="/bindings">Capture bindings</RouterLink></Button>
</div>
</ConfigCard>
<DangerousActionsCard />
</div>
</template>
+41
View File
@@ -0,0 +1,41 @@
<script setup lang="ts">
import { ref } from "vue";
import PageHeader from "@/base/PageHeader.vue";
import { useIdentitiesStore, type Identity } from "@/stores/identities";
const store = useIdentitiesStore();
const name = ref("");
const kind = ref<Identity["kind"]>("bot");
store.watch();
async function create(): Promise<void> { if (await store.create(name.value, kind.value)) name.value = ""; }
async function rename(value: Identity): Promise<void> { const next = window.prompt("Display name", value.display_name); if (next && next !== value.display_name) await store.command(value, "rename", next); }
async function retire(value: Identity): Promise<void> { if (window.confirm(`Retire ${value.display_name}? This cannot be undone.`)) await store.command(value, "retire"); }
</script>
<template>
<main class="page identities-page">
<PageHeader title="Identities" />
<p v-if="store.error" role="alert" class="error">{{ store.error }}</p>
<form class="identity-create" @submit.prevent="create">
<input v-model.trim="name" required aria-label="Display name" placeholder="Display name">
<select v-model="kind" aria-label="Kind"><option value="bot">Bot</option><option value="service_account">Service account</option><option value="user">User</option></select>
<button type="submit" :disabled="!name || !!store.busy">Create</button>
</form>
<section aria-label="Identity list" class="identity-list">
<article v-for="value in store.identities" :key="value.id" class="identity-row">
<div><strong>{{ value.display_name }}</strong><span>{{ value.kind.replace('_', ' ') }} · {{ value.lifecycle }}</span></div>
<div v-if="value.kind !== 'system'" class="actions">
<button :disabled="!!store.busy || value.lifecycle === 'retired'" @click="rename(value)">Rename</button>
<button v-if="value.lifecycle === 'active'" :disabled="!!store.busy" @click="store.command(value, 'suspend')">Suspend</button>
<button v-if="value.lifecycle === 'suspended'" :disabled="!!store.busy" @click="store.command(value, 'reactivate')">Reactivate</button>
<button class="danger" :disabled="!!store.busy || value.lifecycle === 'retired'" @click="retire(value)">Retire</button>
</div>
</article>
</section>
</main>
</template>
<style scoped>
.identities-page{max-width:960px}.identity-create{display:flex;gap:.75rem;margin:1.5rem 0}.identity-create input{flex:1}.identity-create input,.identity-create select,.identity-create button,.actions button{border:1px solid var(--border);border-radius:.5rem;background:var(--surface);color:inherit;padding:.6rem .8rem}.identity-list{border-top:1px solid var(--border)}.identity-row{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:1rem 0;border-bottom:1px solid var(--border)}.identity-row span{display:block;color:var(--muted-foreground);font-size:.85rem;margin-top:.2rem;text-transform:capitalize}.actions{display:flex;gap:.5rem}.actions .danger{color:var(--destructive)}.error{color:var(--destructive)}
</style>
+15 -14
View File
@@ -1,26 +1,27 @@
<script setup lang="ts">
import { onMounted } from "vue";
import { computed, onMounted } from "vue";
import { storeToRefs } from "pinia";
import PageHeader from "@/base/PageHeader.vue";
import { useLiveResource } from "@/stores/live-updates";
import ConfigUnavailable from "./ConfigUnavailable.vue";
import ModelsCard from "./ModelsCard.vue";
import { configUnavailable, loadConfig } from "./state";
import { resourcesForPage, useControlPlaneStore } from "@/stores/control-plane";
import StructuredResourceCard from "./StructuredResourceCard.vue";
/**
* Which model handles each stage of work, and which providers are wired up.
* Nothing on this page is editable from the dashboard: a model role is a
* structured field, and the server keeps those behind its own config path.
*/
useLiveResource(null, () => void loadConfig());
onMounted(loadConfig);
const controlPlane = useControlPlaneStore();
const { catalog, catalogError } = storeToRefs(controlPlane);
const resources = computed(() => resourcesForPage(catalog.value, "models"));
onMounted(controlPlane.load);
</script>
<template>
<div>
<PageHeader title="Models" />
<ConfigUnavailable v-if="configUnavailable" />
<ModelsCard v-else />
<p v-if="catalogError" class="text-sm text-destructive" role="alert">{{ catalogError }}</p>
<StructuredResourceCard
v-for="descriptor in resources"
:key="descriptor.kind"
:descriptor="descriptor"
:root-path="descriptor.kind === 'provider-settings' ? 'providers' : 'roles'"
/>
</div>
</template>
+10 -12
View File
@@ -1,24 +1,22 @@
<script setup lang="ts">
import { onMounted } from "vue";
import { computed, onMounted } from "vue";
import { storeToRefs } from "pinia";
import PageHeader from "@/base/PageHeader.vue";
import { useLiveResource } from "@/stores/live-updates";
import ConfigUnavailable from "./ConfigUnavailable.vue";
import RepositoriesCard from "./RepositoriesCard.vue";
import { configUnavailable, loadConfig } from "./state";
import { resourcesForPage, useControlPlaneStore } from "@/stores/control-plane";
import StructuredResourceCard from "./StructuredResourceCard.vue";
/**
* The repositories Archie watches, and the gate overrides each one carries.
*/
useLiveResource(null, () => void loadConfig());
onMounted(loadConfig);
const controlPlane = useControlPlaneStore();
const { catalog, catalogError } = storeToRefs(controlPlane);
const resources = computed(() => resourcesForPage(catalog.value, "repositories"));
onMounted(controlPlane.load);
</script>
<template>
<div>
<PageHeader title="Repositories" />
<ConfigUnavailable v-if="configUnavailable" />
<RepositoriesCard v-else />
<p v-if="catalogError" class="text-sm text-destructive" role="alert">{{ catalogError }}</p>
<StructuredResourceCard v-for="descriptor in resources" :key="descriptor.kind" :descriptor="descriptor" root-path="repositories" />
</div>
</template>
+15 -10
View File
@@ -1,22 +1,27 @@
<script setup lang="ts">
import { onMounted } from "vue";
import { computed, onMounted } from "vue";
import { storeToRefs } from "pinia";
import PageHeader from "@/base/PageHeader.vue";
import { useLiveResource } from "@/stores/live-updates";
import ConfigSections from "./ConfigSections.vue";
import ConfigUnavailable from "./ConfigUnavailable.vue";
import { TASKS_SECTIONS } from "./sections";
import { configUnavailable, loadConfig } from "./state";
import { useControlPlaneStore } from "@/stores/control-plane";
import { resourcesForPage } from "@/stores/control-plane";
import StructuredResourceCard from "./StructuredResourceCard.vue";
useLiveResource(null, () => void loadConfig());
onMounted(loadConfig);
const controlPlane = useControlPlaneStore();
const { catalog, catalogError } = storeToRefs(controlPlane);
const resources = computed(() => resourcesForPage(catalog.value, "tasks"));
onMounted(controlPlane.load);
</script>
<template>
<div>
<PageHeader title="Task settings" />
<ConfigUnavailable v-if="configUnavailable" />
<ConfigSections v-else :ids="TASKS_SECTIONS" />
<p v-if="catalogError" class="text-sm text-destructive" role="alert">{{ catalogError }}</p>
<StructuredResourceCard
v-for="descriptor in resources"
:key="descriptor.kind"
:descriptor="descriptor"
/>
</div>
</template>
+193
View File
@@ -0,0 +1,193 @@
import { defineStore } from "pinia";
import { computed, reactive, ref } from "vue";
export interface ResourceDescriptor {
kind: string;
title: string;
schema_json: string;
commands: string[];
apply_mode?: "live" | "restart-required" | "domain-managed";
query_service?: string;
command_service?: string;
/** Factory value this resource can be restored to, as JSON. */
defaults_json?: string;
}
export interface ControlPlaneResource {
kind: string;
version: number;
value: unknown;
updated_at?: string;
}
interface ResourceResponse { resource: ControlPlaneResource }
export interface ResourceState {
resource?: ControlPlaneResource;
loading: boolean;
saving: boolean;
error?: string;
conflict: boolean;
stream: "connecting" | "live" | "reconnecting";
}
class ControlPlaneError extends Error {
readonly status: number;
constructor(message: string, status: number) {
super(message);
this.status = status;
}
}
async function request<T>(path: string, init: RequestInit = {}): Promise<T> {
const headers = new Headers(init.headers);
headers.set("Accept", "application/json");
if (init.method && init.method !== "GET") {
headers.set("Content-Type", "application/json");
headers.set("X-Archie-CSRF", "1");
}
const response = await fetch(path, { ...init, headers, signal: AbortSignal.timeout(15_000) });
if (!response.ok) throw new ControlPlaneError((await response.text()).trim() || response.statusText, response.status);
return response.json() as Promise<T>;
}
export type ControlPlanePage = "tasks" | "models" | "repositories" | "channels" | "advanced" | "workflows";
const PAGE_RESOURCES: Record<ControlPlanePage, string[]> = {
tasks: ["workflow-execution-settings"],
models: ["provider-settings", "model-role-assignments"],
repositories: ["repository-policies"],
channels: ["channel-settings"],
advanced: ["personas", "schedules", "scheduling-policy", "tool-settings", "plugin-settings", "container-runtime-policies"],
workflows: ["workflow-definitions"],
};
export interface WorkflowDefinitionEntry { id: string; yaml: string }
export interface WorkflowDefinitionCollection { definitions: WorkflowDefinitionEntry[] }
export function cloneControlPlaneValue<T>(value: T): T {
return JSON.parse(JSON.stringify(value)) as T;
}
export function resourcesForPage(catalog: ResourceDescriptor[], page: ControlPlanePage): ResourceDescriptor[] {
const ownership = PAGE_RESOURCES[page];
return ownership.flatMap((kind) => catalog.filter((descriptor) => descriptor.kind === kind));
}
export function upsertWorkflowDefinition(collection: WorkflowDefinitionCollection, entry: WorkflowDefinitionEntry): WorkflowDefinitionCollection {
const found = collection.definitions.some(({ id }) => id === entry.id);
return { definitions: found
? collection.definitions.map((definition) => definition.id === entry.id ? entry : definition)
: [...collection.definitions, entry] };
}
export function removeWorkflowDefinition(collection: WorkflowDefinitionCollection, id: string): WorkflowDefinitionCollection {
return { definitions: collection.definitions.filter((definition) => definition.id !== id) };
}
export function commandBody(value: unknown, expectedVersion: number): string {
return JSON.stringify({ value, expected_version: expectedVersion });
}
export const useControlPlaneStore = defineStore("control-plane", () => {
const catalog = ref<ResourceDescriptor[]>([]);
const catalogError = ref("");
const states = reactive<Record<string, ResourceState>>({});
const streams = new Map<string, EventSource>();
const genericResources = computed(() => catalog.value.filter((item) =>
item.apply_mode !== "domain-managed" && !item.query_service && item.commands.includes("replace"),
));
function stateFor(kind: string): ResourceState {
if (!states[kind]) states[kind] = { loading: false, saving: false, conflict: false, stream: "connecting" };
return states[kind];
}
function apply(resource: ControlPlaneResource): void {
const state = stateFor(resource.kind);
if (!state.resource || resource.version >= state.resource.version) state.resource = resource;
state.error = undefined;
state.conflict = false;
}
async function loadResource(kind: string): Promise<void> {
const state = stateFor(kind);
state.loading = true;
try {
apply((await request<ResourceResponse>(`/api/control-plane/resources/${encodeURIComponent(kind)}`)).resource);
} catch (error) {
state.error = String((error as Error).message || error);
} finally {
state.loading = false;
}
}
function watchResource(kind: string): void {
if (streams.has(kind)) return;
const state = stateFor(kind);
const after = state.resource?.version ?? 0;
const stream = new EventSource(`/api/control-plane/watch/${encodeURIComponent(kind)}?after=${after}`);
stream.onopen = () => { state.stream = "live"; };
stream.onerror = () => { state.stream = "reconnecting"; };
stream.onmessage = (event) => {
try { apply((JSON.parse(event.data) as ResourceResponse).resource); } catch { state.error = "Invalid live update"; }
};
streams.set(kind, stream);
}
async function load(): Promise<void> {
try {
const response = await request<{ resources?: ResourceDescriptor[] }>("/api/control-plane/catalog");
catalog.value = response.resources ?? [];
catalogError.value = "";
await Promise.all(genericResources.value.map(async ({ kind }) => {
await loadResource(kind);
watchResource(kind);
}));
} catch (error) {
catalogError.value = String((error as Error).message || error);
}
}
async function replace(kind: string, value: unknown): Promise<boolean> {
const state = stateFor(kind);
if (!state.resource || state.saving) return false;
state.saving = true;
state.error = undefined;
state.conflict = false;
try {
const response = await request<ResourceResponse>(
`/api/control-plane/resources/${encodeURIComponent(kind)}/commands/replace`,
{ method: "POST", body: commandBody(value, state.resource.version) },
);
apply(response.resource);
return true;
} catch (error) {
if (error instanceof ControlPlaneError && error.status === 409) {
state.conflict = true;
state.error = "Changed elsewhere. Latest values loaded.";
await loadResource(kind);
} else {
state.error = String((error as Error).message || error);
}
return false;
} finally {
state.saving = false;
}
}
/** The shipped definitions the catalog offers as "restore shipped". */
function shippedWorkflows(): WorkflowDefinitionCollection {
const defaults = catalog.value.find((resource) => resource.kind === "workflow-definitions")?.defaults_json;
if (!defaults) return { definitions: [] };
try {
return JSON.parse(defaults) as WorkflowDefinitionCollection;
} catch {
return { definitions: [] };
}
}
return { catalog, catalogError, states, genericResources, load, replace, shippedWorkflows, stateFor };
});
+34
View File
@@ -0,0 +1,34 @@
import { defineStore } from "pinia";
import { onScopeDispose, ref } from "vue";
export interface Identity { id: string; kind: "system" | "bot" | "service_account" | "user"; display_name: string; lifecycle: "active" | "suspended" | "retired"; version: number }
async function call<T>(path: string, init: RequestInit = {}): Promise<T> {
const response = await fetch(path, { ...init, headers: { Accept: "application/json", "Content-Type": "application/json", "X-Archie-CSRF": "1", ...init.headers } });
if (!response.ok) throw new Error((await response.text()).trim());
return response.json() as Promise<T>;
}
export const useIdentitiesStore = defineStore("identities", () => {
const identities = ref<Identity[]>([]);
const error = ref("");
const busy = ref("");
let stream: EventSource | undefined;
async function load(): Promise<void> { try { identities.value = (await call<{ identities: Identity[] }>("/api/identities")).identities; error.value = ""; } catch (cause) { error.value = String((cause as Error).message || cause); } }
function watch(): void {
if (stream) return;
void load();
stream = new EventSource("/api/identities/watch");
stream.onmessage = (event) => {
try { identities.value = (JSON.parse(event.data) as { identities: Identity[] }).identities; error.value = ""; }
catch { error.value = "Invalid live update"; }
};
stream.onerror = () => { error.value = "Identity updates disconnected"; };
onScopeDispose(() => { stream?.close(); stream = undefined; });
}
async function create(display_name: string, kind: Identity["kind"]): Promise<boolean> { return mutate("create", () => call("/api/identities", { method: "POST", body: JSON.stringify({ display_name, kind }) })); }
async function command(value: Identity, commandName: string, display_name = ""): Promise<boolean> { return mutate(value.id, () => call(`/api/identities/${encodeURIComponent(value.id)}/${commandName}`, { method: "POST", body: JSON.stringify({ expected_version: value.version, display_name }) })); }
async function mutate(key: string, action: () => Promise<unknown>): Promise<boolean> { busy.value = key; try { await action(); await load(); return true; } catch (cause) { error.value = String((cause as Error).message || cause); return false; } finally { busy.value = ""; } }
return { identities, error, busy, watch, create, command };
});
@@ -0,0 +1,119 @@
<script setup lang="ts">
import { computed, ref, watchEffect } from "vue";
import { Plus, RotateCcw, Trash2 } from "@lucide/vue";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { Spinner } from "@/components/ui/spinner";
import { Textarea } from "@/components/ui/textarea";
import {
cloneControlPlaneValue,
removeWorkflowDefinition,
upsertWorkflowDefinition,
useControlPlaneStore,
type WorkflowDefinitionCollection,
} from "@/stores/control-plane";
import ConfigCard from "@/settings/ConfigCard.vue";
const store = useControlPlaneStore();
const state = computed(() => store.stateFor("workflow-definitions"));
const collection = computed(() => (state.value.resource?.value as WorkflowDefinitionCollection | undefined) ?? { definitions: [] });
const shipped = computed<WorkflowDefinitionCollection>(() => store.shippedWorkflows());
const selected = ref("");
const id = ref("");
const yaml = ref("");
const localError = ref("");
const shippedEntry = computed(() => shipped.value.definitions.find((entry) => entry.id === id.value));
watchEffect(() => {
const entries = collection.value.definitions;
if (entries.length && (!selected.value || !entries.some((entry) => entry.id === selected.value))) {
select(entries[0].id);
}
});
function select(value: string): void {
selected.value = value;
const entry = collection.value.definitions.find((candidate) => candidate.id === value);
id.value = entry?.id ?? value;
yaml.value = entry?.yaml ?? `id: ${value}\nsteps:\n - type: `;
localError.value = "";
}
function create(): void {
let index = 1;
while (collection.value.definitions.some((entry) => entry.id === `workflow-${index}`)) index++;
select(`workflow-${index}`);
}
async function save(next: WorkflowDefinitionCollection): Promise<boolean> {
localError.value = "";
return store.replace("workflow-definitions", next);
}
async function saveDraft(): Promise<void> {
const nextID = id.value.trim();
if (!nextID) { localError.value = "Workflow ID is required."; return; }
const previous = selected.value;
let next = collection.value;
if (previous && previous !== nextID) next = removeWorkflowDefinition(next, previous);
if (await save(upsertWorkflowDefinition(next, { id: nextID, yaml: yaml.value }))) selected.value = nextID;
}
async function remove(): Promise<void> {
if (!selected.value || !await save(removeWorkflowDefinition(collection.value, selected.value))) return;
selected.value = "";
id.value = "";
yaml.value = "";
}
async function restoreOne(): Promise<void> {
if (!shippedEntry.value) return;
await save(upsertWorkflowDefinition(collection.value, cloneControlPlaneValue(shippedEntry.value)));
}
async function restoreAll(): Promise<void> {
if (await save(cloneControlPlaneValue(shipped.value))) select(shipped.value.definitions[0]?.id ?? "");
}
</script>
<template>
<ConfigCard title="Definitions">
<div class="mb-4 flex flex-wrap items-center gap-2">
<Select :model-value="selected" @update:model-value="select(String($event))">
<SelectTrigger class="min-w-56"><SelectValue placeholder="Select workflow" /></SelectTrigger>
<SelectContent><SelectItem v-for="entry in collection.definitions" :key="entry.id" :value="entry.id">{{ entry.id }}</SelectItem></SelectContent>
</Select>
<Button type="button" variant="outline" @click="create"><Plus /> New</Button>
<Button type="button" variant="outline" :disabled="!shipped.definitions.length" @click="restoreAll"><RotateCcw /> Restore shipped</Button>
</div>
<form class="space-y-4" @submit.prevent="saveDraft">
<div class="space-y-1.5">
<Label for="workflow-id">ID</Label>
<Input id="workflow-id" v-model="id" name="workflow-id" required autocomplete="off" />
</div>
<div class="space-y-1.5">
<Label for="workflow-yaml">YAML</Label>
<Textarea id="workflow-yaml" v-model="yaml" name="workflow-yaml" required class="min-h-80 resize-y font-mono" spellcheck="false" />
</div>
<p v-if="localError || state.error" class="text-sm text-destructive" role="alert">{{ localError || state.error }}</p>
<div class="flex flex-wrap items-center justify-between gap-3">
<div class="flex items-center gap-2">
<Badge :variant="state.stream === 'live' ? 'ok' : 'warn'">{{ state.stream === 'live' ? 'Live' : 'Connecting' }}</Badge>
<span v-if="state.resource" class="text-xs text-muted-foreground">Version {{ state.resource.version }}</span>
</div>
<div class="flex gap-2">
<Button v-if="shippedEntry" type="button" variant="outline" @click="restoreOne"><RotateCcw /> Restore this workflow</Button>
<Button v-if="selected" type="button" variant="destructive" @click="remove"><Trash2 /> Remove</Button>
<Button type="submit" :disabled="state.saving"><Spinner v-if="state.saving" data-icon="inline-start" /> Validate & save</Button>
</div>
</div>
</form>
</ConfigCard>
</template>
+6 -1
View File
@@ -6,10 +6,12 @@ import { Card, CardContent } from "@/components/ui/card";
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { api } from "@/lib/api";
import { useLiveResource } from "@/stores/live-updates";
import { useControlPlaneStore } from "@/stores/control-plane";
import StartWorkForm from "./StartWorkForm.vue";
import type { StageStats } from "./stages";
import StagesSection from "./StagesSection.vue";
import WorkflowTable from "./WorkflowTable.vue";
import WorkflowDefinitionsCard from "./WorkflowDefinitionsCard.vue";
import type { WorkflowDefinition, WorkflowStats } from "./workflow-rows";
interface WorkflowsResponse {
@@ -22,6 +24,7 @@ const definitions = ref<WorkflowDefinition[]>([]);
const workflows = ref<WorkflowStats[]>([]);
const stages = ref<StageStats[]>([]);
const error = ref<string | null>(null);
const controlPlane = useControlPlaneStore();
async function load() {
try {
@@ -36,13 +39,15 @@ async function load() {
}
useLiveResource("tasks", () => void load(), 500);
onMounted(load);
onMounted(async () => { await Promise.all([load(), controlPlane.load()]); });
</script>
<template>
<div>
<PageHeader title="Workflows" />
<WorkflowDefinitionsCard />
<!-- Starting work needs a definition to start: with none served, the form
could only be submitted to fail. -->
<StartWorkForm v-if="definitions.length" :definitions="definitions" />