feat(webui): install, accept and enable extensions from the dashboard

This commit is contained in:
sam committed 2026-10-04 01:56:10 +10:00
1 parent 357762c52f
commit 33e86f79fa
12 files changed
+637 -59

No files matched your search

+1
View File
@@ -44,6 +44,7 @@ const settings: NavSpec = {
"/settings/repositories",
"/settings/identities",
"/settings/tools",
"/settings/extensions",
"/settings/plugins",
],
},
+13
View File
@@ -11,6 +11,7 @@ import ToolsPage from "@/settings/ToolsPage.vue";
import HistoryPage from "@/settings/HistoryPage.vue";
import PersonasPage from "@/settings/PersonasPage.vue";
import SchedulesPage from "@/settings/SchedulesPage.vue";
import ExtensionsPage from "@/settings/ExtensionsPage.vue";
import PluginsPage from "@/settings/PluginsPage.vue";
import ContainerRuntimePage from "@/settings/ContainerRuntimePage.vue";
import SystemAdvancedPage from "@/settings/SystemAdvancedPage.vue";
@@ -259,6 +260,18 @@ const routes = [
section: "settings",
},
},
{
path: "/settings/extensions",
name: "settings-extensions",
component: ExtensionsPage,
meta: {
navPath: "/settings",
settings: true,
label: "Extensions",
description: "Installable extensions: install, accept what they may use, enable.",
section: "settings",
},
},
{
path: "/settings/plugins",
name: "settings-plugins",
+142
View File
@@ -0,0 +1,142 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { Plus } from "@lucide/vue";
import PageHeader from "@/base/PageHeader.vue";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
import { Input } from "@/components/ui/input";
import { StatusPill } from "@/components/ui/status-pill";
import { Switch } from "@/components/ui/switch";
import { grants, stage, useExtensionsStore, type Extension } from "@/stores/extensions";
import ApplyStatusRows from "./ApplyStatusRows.vue";
const KIND = "extension-settings";
const store = useExtensionsStore();
onMounted(store.load);
const name = ref("");
const reference = ref("");
const digest = ref("");
async function install(): Promise<void> {
if (await store.install(name.value, reference.value, digest.value)) {
name.value = reference.value = digest.value = "";
}
}
const accepting = ref<Extension | null>(null);
async function accept(): Promise<void> {
if (accepting.value) await store.accept(accepting.value.name);
accepting.value = null;
}
const removing = ref<Extension | null>(null);
async function remove(): Promise<void> {
if (removing.value) await store.remove(removing.value.name);
removing.value = null;
}
const tones = {
accept: { tone: "warn", dot: "warn", label: "Authority not accepted" },
disabled: { tone: "neutral", dot: "idle", label: "Disabled" },
enabled: { tone: "neutral", dot: "live", label: "Enabled" },
inert: { tone: "neutral", dot: "idle", label: "No extensions" },
} as const;
</script>
<template>
<div>
<PageHeader title="Extensions" />
<p v-if="store.error" role="alert" class="mb-4 text-sm text-danger">{{ store.error }}</p>
<form class="mb-6 flex flex-wrap gap-2" @submit.prevent="install">
<Input v-model="name" class="max-w-40" placeholder="Name" aria-label="Name" required />
<Input v-model="reference" class="max-w-80 font-mono" placeholder="registry/repo:tag" aria-label="Reference" required />
<Input v-model="digest" class="max-w-96 font-mono" placeholder="sha256:…" aria-label="Digest" required />
<Button type="submit" size="sm" :disabled="!!store.busy"><Plus data-icon="inline-start" /> Install</Button>
</form>
<ul class="divide-y divide-border rounded-lg border border-border bg-card" aria-label="Extensions">
<li v-for="extension in store.extensions" :key="extension.name" class="flex flex-wrap items-center gap-3 px-4 py-3">
<div class="min-w-0 flex-1">
<p class="truncate text-sm font-medium">
{{ extension.display_name || extension.name }}
<span class="font-mono text-xs text-fg-subtle">{{ extension.name }} {{ extension.version }}</span>
</p>
<p class="text-xs text-fg-subtle">{{ extension.description }}</p>
<p class="truncate font-mono text-xs text-fg-subtle">{{ extension.digest }}</p>
</div>
<StatusPill :tone="tones[stage(extension)].tone" :dot="tones[stage(extension)].dot">
{{ tones[stage(extension)].label }}
</StatusPill>
<Button
v-if="stage(extension) === 'accept'"
variant="ghost"
size="sm"
:disabled="!!store.busy"
@click="accepting = extension"
>Review authority</Button
>
<Switch
v-else-if="stage(extension) !== 'inert'"
:model-value="extension.enabled"
:disabled="!!store.busy"
:aria-label="`Enable ${extension.name}`"
@update:model-value="(value: boolean) => store.setEnabled(extension.name, value)"
/>
<Button variant="ghost" size="sm" class="text-danger" :disabled="!!store.busy" @click="removing = extension">Remove</Button>
</li>
<li v-if="!store.extensions.length">
<Empty class="py-6">
<EmptyHeader>
<EmptyTitle>Nothing installed</EmptyTitle>
</EmptyHeader>
</Empty>
</li>
</ul>
<ApplyStatusRows :kind="KIND" class="mt-6 border-t border-border py-4" />
<AlertDialog :open="!!accepting" @update:open="(open) => !open && (accepting = null)">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Accept what {{ accepting?.name }} may use?</AlertDialogTitle>
<AlertDialogDescription>
It runs as a process on this host and sees only these.
</AlertDialogDescription>
</AlertDialogHeader>
<ul class="font-mono text-xs">
<li v-for="line in accepting ? grants(accepting.declared) : []" :key="line">{{ line }}</li>
<li v-if="accepting && !grants(accepting.declared).length">Nothing beyond its own process.</li>
</ul>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="accept">Accept</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<AlertDialog :open="!!removing" @update:open="(open) => !open && (removing = null)">
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Remove {{ removing?.name }}?</AlertDialogTitle>
<AlertDialogDescription>Its process stops on the next sync.</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction @click="remove">Remove</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
</template>
+3 -1
View File
@@ -174,6 +174,7 @@ export type ControlPlanePage =
| "personas"
| "schedules"
| "plugins"
| "extensions"
| "containers"
| "review"
| "workflows";
@@ -187,7 +188,8 @@ const PAGE_RESOURCES: Record<ControlPlanePage, string[]> = {
tools: ["tool-settings"],
personas: ["personas"],
schedules: ["schedules"],
plugins: ["plugin-settings", "extension-settings"],
plugins: ["plugin-settings"],
extensions: ["extension-settings"],
containers: ["container-runtime-policies"],
review: ["review-settings"],
workflows: ["workflow-definitions"],
+99
View File
@@ -0,0 +1,99 @@
import { defineStore } from "pinia";
import { ref } from "vue";
export interface Authority {
credential_services: string[];
egress_hosts: string[];
forge_permissions: string[];
triggers: string[];
tools: string[];
env: string[];
}
export interface Extension {
name: string;
display_name: string;
description: string;
version: string;
reference: string;
digest: string;
surfaces: string[];
declared: Authority;
accepted: Authority | null;
enabled: boolean;
}
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>;
}
/** The grants an authority record names, as "kind: value" lines. */
export function grants(authority: Authority): string[] {
const labelled: [string, string[]][] = [
["credential", authority.credential_services],
["egress", authority.egress_hosts],
["forge", authority.forge_permissions],
["trigger", authority.triggers],
["tool", authority.tools],
["env", authority.env],
];
return labelled.flatMap(([label, values]) => values.map((value) => `${label}: ${value}`));
}
/** What an extension needs from the operator next, in the order it happens. */
export function stage(extension: Extension): "accept" | "disabled" | "enabled" | "inert" {
if (!extension.surfaces.length) return "inert";
if (!extension.accepted) return "accept";
return extension.enabled ? "enabled" : "disabled";
}
export const useExtensionsStore = defineStore("extensions", () => {
const extensions = ref<Extension[]>([]);
const error = ref("");
const busy = ref("");
async function load(): Promise<void> {
try {
extensions.value = (await call<{ extensions: Extension[] }>("/api/extensions")).extensions;
error.value = "";
} catch (cause) {
error.value = String((cause as Error).message || cause);
}
}
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 = "";
}
}
const path = (name: string) => `/api/extensions/${encodeURIComponent(name)}`;
return {
extensions,
error,
busy,
load,
install: (name: string, reference: string, digest: string) =>
mutate("install", () => call("/api/extensions", { method: "POST", body: JSON.stringify({ name, reference, digest }) })),
accept: (name: string) => mutate(name, () => call(`${path(name)}/accept`, { method: "POST" })),
setEnabled: (name: string, enabled: boolean) =>
mutate(name, () => call(`${path(name)}/enabled`, { method: "PUT", body: JSON.stringify({ enabled }) })),
remove: (name: string) => mutate(name, () => call(path(name), { method: "DELETE" })),
};
});