feat(alerts): send each organisation's alerts to its own webhook

This commit is contained in:
sam committed 2026-10-27 10:38:00 +11:00
1 parent e363512c7c
commit 3ea929cbdc
20 files changed
+419 -183

No files matched your search

+1 -1
View File
@@ -41,7 +41,7 @@ const orgSpecs: NavSpec[] = [
},
{
label: "Automation",
paths: ["/org/schedules", "/org/scheduling-policy", "/org/playbooks"],
paths: ["/org/schedules", "/org/scheduling-policy", "/org/playbooks", "/org/alerts"],
},
],
},
+6
View File
@@ -272,6 +272,12 @@ const routes = [
component: SchedulingPolicyPage,
meta: { label: "Scheduling policy", navPath: "/org", description: "Work discovery and forge labels." },
},
{
path: "alerts",
name: "org-alerts",
component: () => import("@/settings/OrgAlertsPage.vue"),
meta: { label: "Alert webhook", navPath: "/org", description: "Where this organisation's alerts are sent." },
},
{
path: "playbooks",
name: "org-playbooks",
+107
View File
@@ -0,0 +1,107 @@
<script setup lang="ts">
import { Alert, AlertDescription } from "@/components/ui/alert";
import ApplyStatusRows from "./ApplyStatusRows.vue";
import { computed, onMounted } from "vue";
import { storeToRefs } from "pinia";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import PageHeader from "@/base/PageHeader.vue";
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
import { useSessionStore } from "@/stores/session";
import { resourcesForPage, useSettingsStore } from "@/stores/settings";
import DraftHint from "./DraftHint.vue";
import HistoryLink from "./HistoryLink.vue";
import SecretRefField from "./SecretRefField.vue";
const POLICY = "task-policy";
const store = useSettingsStore();
const { catalog, catalogError } = storeToRefs(store);
onMounted(store.load);
// A secret reference resolves against the instance's engines, so only the
// system org names one; another org signs with its credential binding.
const instance = computed(() => useSessionStore().sections?.settings !== false);
const resources = computed(() => resourcesForPage(catalog.value, "alerts"));
const form = computed(() => store.formFor(POLICY));
const policy = computed(() => store.draftValue(POLICY));
</script>
<template>
<div>
<PageHeader title="Alert webhook">
<HistoryLink :kinds="resources.map((r) => r.kind)" />
</PageHeader>
<ApplyStatusRows v-for="resource in resources" :key="resource.kind" :kind="resource.kind" class="mb-4" />
<Alert v-if="catalogError || store.pageErrorFor(POLICY)" variant="destructive" class="mb-4"><AlertDescription>
{{ catalogError || store.pageErrorFor(POLICY) }}
</AlertDescription></Alert>
<FieldGroup v-if="form && policy" class="@container/field-group">
<form.Field v-slot="{ field }" name="notify_webhook">
<Field orientation="responsive">
<FieldContent>
<FieldLabel for="task-notify">Alert webhook</FieldLabel>
<FieldDescription>Receives each raised and resolved alert. Empty disables.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<Input
id="task-notify"
:model-value="field.state.value"
type="url"
class="max-w-md"
@blur="field.handleBlur"
@update:model-value="field.handleChange"
/>
<DraftHint :kind="POLICY" path="notify_webhook" />
</div>
</Field>
</form.Field>
<form.Field v-slot="{ field }" name="notify_min_severity">
<Field orientation="responsive">
<FieldContent>
<FieldLabel>Webhook severity</FieldLabel>
<FieldDescription>Minimum severity.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<Select
:model-value="field.state.value || 'warning'"
@update:model-value="field.handleChange(String($event))"
>
<SelectTrigger class="w-40" aria-label="Webhook severity"><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value="info">Info</SelectItem>
<SelectItem value="warning">Warning</SelectItem>
<SelectItem value="action">Needs attention</SelectItem>
</SelectContent>
</Select>
<DraftHint :kind="POLICY" path="notify_min_severity" />
</div>
</Field>
</form.Field>
<form.Field v-if="instance" v-slot="{ field }" name="notify_secret">
<Field orientation="responsive">
<FieldContent>
<FieldLabel>Webhook signing secret</FieldLabel>
<FieldDescription>Signs each payload in X-Archie-Signature. Not set sends unsigned.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<SecretRefField
v-if="field.state.value"
:model-value="field.state.value"
id-prefix="task-notify-secret"
@update:model-value="field.handleChange"
/>
<Button v-else variant="outline" size="sm" @click="field.handleChange({ engine: '', key: '' })">Set reference</Button>
<DraftHint :kind="POLICY" path="notify_secret" />
</div>
</Field>
</form.Field>
</FieldGroup>
</div>
</template>
+2 -78
View File
@@ -6,8 +6,6 @@ import { RotateCcw } from "@lucide/vue";
import { storeToRefs } from "pinia";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import PageHeader from "@/base/PageHeader.vue";
import { DurationInput, formatGoDuration, parseGoDuration } from "@/components/ui/duration-input";
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field";
@@ -32,17 +30,9 @@ import { cloneControlPlaneValue, resourcesForPage, useSettingsStore } from "@/st
import { restoreShippedDefinitions, useWorkflowsStore } from "@/stores/workflows";
import DraftHint from "./DraftHint.vue";
import HistoryLink from "./HistoryLink.vue";
import SecretRefField from "./SecretRefField.vue";
const POLICY = "task-policy";
const KIND = "workflow-execution-settings";
interface TaskPolicy {
notify_webhook: string;
notify_min_severity: string;
notify_secret: { engine: string; key: string };
}
interface ExecutionSettings {
max_model_tool_steps: number;
max_runtime_seconds: number;
@@ -55,8 +45,6 @@ const { catalog, catalogError } = storeToRefs(store);
onMounted(store.load);
const resources = computed(() => resourcesForPage(catalog.value, "tasks"));
const policyForm = computed(() => store.formFor(POLICY));
const policy = computed(() => store.draftValue(POLICY) as TaskPolicy | undefined);
const limitsForm = computed(() => store.formFor(KIND));
const limits = computed(() => store.draftValue(KIND) as ExecutionSettings | undefined);
const error = computed(() => store.pageErrorFor(KIND));
@@ -85,74 +73,10 @@ async function restoreWorkflows(): Promise<void> {
</PageHeader>
<ApplyStatusRows v-for="resource in resources" :key="resource.kind" :kind="resource.kind" class="mb-4" />
<Alert v-if="catalogError || error || store.pageErrorFor(POLICY)" variant="destructive" class="mb-4"><AlertDescription>
{{ catalogError || error || store.pageErrorFor(POLICY) }}
<Alert v-if="catalogError || error" variant="destructive" class="mb-4"><AlertDescription>
{{ catalogError || error }}
</AlertDescription></Alert>
<FieldGroup v-if="policyForm && policy" class="@container/field-group">
<policyForm.Field v-slot="{ field }" name="notify_webhook">
<Field orientation="responsive">
<FieldContent>
<FieldLabel for="task-notify">Alert webhook</FieldLabel>
<FieldDescription>Receives each raised and resolved alert. Empty disables.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<Input
id="task-notify"
:model-value="field.state.value"
type="url"
class="max-w-md"
@blur="field.handleBlur"
@update:model-value="field.handleChange"
/>
<DraftHint :kind="POLICY" path="notify_webhook" />
</div>
</Field>
</policyForm.Field>
<policyForm.Field v-slot="{ field }" name="notify_min_severity">
<Field orientation="responsive">
<FieldContent>
<FieldLabel>Webhook severity</FieldLabel>
<FieldDescription>Minimum severity.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<Select
:model-value="field.state.value || 'warning'"
@update:model-value="field.handleChange(String($event))"
>
<SelectTrigger class="w-40" aria-label="Webhook severity"><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value="info">Info</SelectItem>
<SelectItem value="warning">Warning</SelectItem>
<SelectItem value="action">Needs attention</SelectItem>
</SelectContent>
</Select>
<DraftHint :kind="POLICY" path="notify_min_severity" />
</div>
</Field>
</policyForm.Field>
<policyForm.Field v-slot="{ field }" name="notify_secret">
<Field orientation="responsive">
<FieldContent>
<FieldLabel>Webhook signing secret</FieldLabel>
<FieldDescription>Signs each payload in X-Archie-Signature. Not set sends unsigned.</FieldDescription>
</FieldContent>
<div class="flex min-w-0 flex-wrap items-center gap-3 @md/field-group:flex-1">
<SecretRefField
v-if="field.state.value"
:model-value="field.state.value"
id-prefix="task-notify-secret"
@update:model-value="field.handleChange"
/>
<Button v-else variant="outline" size="sm" @click="field.handleChange({ engine: '', key: '' })">Set reference</Button>
<DraftHint :kind="POLICY" path="notify_secret" />
</div>
</Field>
</policyForm.Field>
</FieldGroup>
<FieldGroup v-if="limitsForm && limits" class="@container/field-group">
<limitsForm.Field v-slot="{ field }" name="max_task_runtime_seconds">
<Field orientation="responsive">
+3 -1
View File
@@ -165,6 +165,7 @@ async function request<T>(path: string, init: RequestInit = {}): Promise<T> {
export type ControlPlanePage =
| "tasks"
| "alerts"
| "models"
| "repositories"
| "connections"
@@ -178,7 +179,8 @@ export type ControlPlanePage =
| "review";
const PAGE_RESOURCES: Record<ControlPlanePage, string[]> = {
tasks: ["workflow-execution-settings","task-policy"],
tasks: ["workflow-execution-settings"],
alerts: ["task-policy"],
models: ["provider-settings", "model-aliases", "org-model-policy"],
repositories: ["repository-policies"],
connections: ["forge-connections"],