feat(alerts): send each organisation's alerts to its own webhook
This commit is contained in:
20 files changed
+419
-183
No files matched your search
@@ -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>
|
||||
@@ -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">
|
||||
|
||||
Reference in new issue
Block a user