feat(ui): run events, workflows, runs, controls and settings pages on the archie binary (#2023)
Events (sources, triggers), workflows (list, document, YAML publish, read-only canvas), runs with approvals and the decision trail, controls (policies, guards, action classes), agent models, accepted extensions, secret engines and credentials now read the binary's API. Capabilities name every section, so pages the binary can't back yet (the visual workflow editor, captures, mappings, bindings, the extension catalogue, model aliases and the rest) stay in the tree, hidden. Adds GET /api/credential-kinds for the credentials form. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
35 files changed
+2274
-51
No files matched your search
@@ -331,6 +331,27 @@ components:
|
||||
- method
|
||||
- request
|
||||
type: object
|
||||
ConnectorsCredentialKind:
|
||||
additionalProperties: false
|
||||
properties:
|
||||
kind:
|
||||
type: string
|
||||
optional:
|
||||
items:
|
||||
type: string
|
||||
type:
|
||||
- array
|
||||
- "null"
|
||||
required:
|
||||
items:
|
||||
type: string
|
||||
type:
|
||||
- array
|
||||
- "null"
|
||||
required:
|
||||
- kind
|
||||
- required
|
||||
type: object
|
||||
ConnectorsCredentialRequest:
|
||||
additionalProperties: false
|
||||
properties:
|
||||
@@ -3444,6 +3465,29 @@ paths:
|
||||
summary: List each guard's judge, its standing and its eval date
|
||||
tags:
|
||||
- Controls
|
||||
/api/credential-kinds:
|
||||
get:
|
||||
operationId: list-credential-kinds
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: "#/components/schemas/ConnectorsCredentialKind"
|
||||
type:
|
||||
- array
|
||||
- "null"
|
||||
description: OK
|
||||
default:
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ErrorModel"
|
||||
description: Error
|
||||
summary: List credential kinds and the fields each takes
|
||||
tags:
|
||||
- Credentials
|
||||
/api/credentials:
|
||||
get:
|
||||
operationId: list-credentials
|
||||
|
||||
@@ -39,6 +39,27 @@ func kindFields(kind string) (required, optional []string, ok bool) {
|
||||
return nil, nil, false
|
||||
}
|
||||
|
||||
// credentialKinds is every kind kindFields accepts, in the order a form
|
||||
// offers them.
|
||||
var credentialKinds = []string{"bearer", "basic", "machine", "age"}
|
||||
|
||||
type credentialKind struct {
|
||||
Kind string `json:"kind"`
|
||||
Required []string `json:"required"`
|
||||
Optional []string `json:"optional,omitzero"`
|
||||
}
|
||||
|
||||
// listCredentialKinds serves kindFields, so a form asks for exactly the fields
|
||||
// a put accepts.
|
||||
func listCredentialKinds(context.Context, *struct{}) (*httpapi.Reply[[]credentialKind], error) {
|
||||
kinds := make([]credentialKind, 0, len(credentialKinds))
|
||||
for _, kind := range credentialKinds {
|
||||
required, optional, _ := kindFields(kind)
|
||||
kinds = append(kinds, credentialKind{Kind: kind, Required: required, Optional: optional})
|
||||
}
|
||||
return httpapi.OK(kinds), nil
|
||||
}
|
||||
|
||||
type credentialRequest struct {
|
||||
Kind string `json:"kind"`
|
||||
Fields map[string]Field `json:"fields"`
|
||||
|
||||
@@ -294,6 +294,10 @@ func (m *Module) Register(api huma.API) {
|
||||
OperationID: "put-credential", Method: http.MethodPut, Path: "/api/credentials/{name}",
|
||||
Summary: "Store a credential sealed and restart what uses it", Tags: tags,
|
||||
}, m.putCredential)
|
||||
huma.Register(api, huma.Operation{
|
||||
OperationID: "list-credential-kinds", Method: http.MethodGet, Path: "/api/credential-kinds",
|
||||
Summary: "List credential kinds and the fields each takes", Tags: tags,
|
||||
}, listCredentialKinds)
|
||||
}
|
||||
|
||||
type acceptRequest struct {
|
||||
|
||||
@@ -602,16 +602,23 @@ type capabilitiesBody struct {
|
||||
Sections map[string]bool `json:"sections"`
|
||||
}
|
||||
|
||||
// capabilities reports the dashboard sections this binary serves. The
|
||||
// sections below have no backend here yet, so the dashboard hides them;
|
||||
// settings is the instance area, which only an instance administrator
|
||||
// operates.
|
||||
// capabilities reports the dashboard sections this binary serves. Every
|
||||
// served section's operations need an instance administrator, so each is
|
||||
// reported as the caller's administrator standing; the dashboard hides the
|
||||
// rest, whose pages call operations this binary does not have.
|
||||
func (m *Module) capabilities(ctx context.Context, _ *struct{}) (*httpapi.Reply[capabilitiesBody], error) {
|
||||
p, _ := PrincipalFromContext(ctx)
|
||||
sections := map[string]bool{"settings": p.InstanceAdmin()}
|
||||
sections := map[string]bool{}
|
||||
for _, name := range []string{
|
||||
"chat", "logs", "skills", "curators", "channels", "captures", "mappings", "bindings", "workflows",
|
||||
"org_members", "org_agents", "org_policies", "org_denials", "org_audit", "org_usage", "org_config",
|
||||
"settings", "events", "workflows", "runs", "credentials", "extensions", "secret_engines", "models", "controls",
|
||||
} {
|
||||
sections[name] = p.InstanceAdmin()
|
||||
}
|
||||
for _, name := range []string{
|
||||
"home", "tasks", "work_requests", "chat", "logs", "skills", "curators", "channels",
|
||||
"captures", "mappings", "bindings", "workflow_editor", "extension_catalogue", "model_aliases",
|
||||
"system_status", "task_execution", "organisations", "tools", "plugins", "container_runtime", "agent_profiles",
|
||||
"org", "org_members", "org_agents", "org_workspaces", "org_policies", "org_denials", "org_audit", "org_usage", "org_config",
|
||||
} {
|
||||
sections[name] = false
|
||||
}
|
||||
|
||||
+6
-3
@@ -23,7 +23,7 @@ import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
|
||||
import NewTaskDialog from "@/tasks/NewTaskDialog.vue";
|
||||
import SettingsShell from "@/settings/SettingsShell.vue";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
import { hiddenPaths } from "@/lib/nav";
|
||||
import { hiddenPaths, navTree } from "@/lib/nav";
|
||||
import { loadTaskMeta } from "@/lib/task-meta";
|
||||
import { useSessionStore } from "@/stores/session";
|
||||
import { Toaster } from "vue-sonner";
|
||||
@@ -42,7 +42,10 @@ const newTaskOpen = ref(false);
|
||||
// it, so a bookmark or a chat link must not land on a form whose saves the
|
||||
// control plane refuses.
|
||||
watch([() => route.path, hidden], () => {
|
||||
if (hidden.value.includes(typeof route.meta.navPath === "string" ? route.meta.navPath : route.path)) void router.replace("/");
|
||||
if (!hidden.value.includes(typeof route.meta.navPath === "string" ? route.meta.navPath : route.path)) return;
|
||||
// Home may be hidden too, so land on the first destination that is served.
|
||||
const first = navTree(hidden.value).find((node) => node.kind === "link");
|
||||
void router.replace(first?.kind === "link" ? first.entry.path : "/account");
|
||||
});
|
||||
watch(() => [route.path, accounts.instance], () => {
|
||||
const scope = route.meta.org ? "Organisation" : route.meta.settings ? "Instance" : "";
|
||||
@@ -117,7 +120,7 @@ watch(() => accounts.status?.user, (user) => {
|
||||
<div class="ml-auto flex shrink-0 items-center gap-4 max-sm:gap-1">
|
||||
<ConnectionPill />
|
||||
<CommandPalette :hidden="hidden" @new-task="newTaskOpen = true" />
|
||||
<NewTaskDialog v-if="!hidden.includes('/workflows')" v-model:open="newTaskOpen" />
|
||||
<NewTaskDialog v-if="session.sections?.work_requests !== false" v-model:open="newTaskOpen" />
|
||||
<ChatTopbarButton />
|
||||
<AlertsBell />
|
||||
<span><AccountMenu /></span>
|
||||
|
||||
@@ -46,6 +46,7 @@ const tasks = ref<TaskEntry[]>([]);
|
||||
const workflows = ref<string[]>([]);
|
||||
const shortcut = navigator.platform.startsWith("Mac") ? "⌘K" : "Ctrl K";
|
||||
const showWorkflows = computed(() => !props.hidden.includes("/workflows"));
|
||||
const showTasks = computed(() => !props.hidden.includes("/tasks"));
|
||||
|
||||
// A failed read shows as an error item with Retry in that group, not as a
|
||||
// missing group: the pages still work either way.
|
||||
@@ -55,16 +56,14 @@ let entriesGeneration = 0;
|
||||
async function loadEntries(): Promise<void> {
|
||||
const current = ++entriesGeneration;
|
||||
const [taskPage, workflowList] = await Promise.all([
|
||||
api.taskPage<TaskEntry>({ limit: 100 }).catch(() => null),
|
||||
showWorkflows.value
|
||||
? api.workflows<{ definitions?: { id: string }[] }>().catch(() => null)
|
||||
: null,
|
||||
showTasks.value ? api.taskPage<TaskEntry>({ limit: 100 }).catch(() => null) : { tasks: [] },
|
||||
showWorkflows.value ? api.workflowList().catch(() => null) : [],
|
||||
]);
|
||||
if (current !== entriesGeneration) return;
|
||||
tasksError.value = taskPage === null;
|
||||
tasks.value = taskPage?.tasks ?? [];
|
||||
workflowsError.value = showWorkflows.value && workflowList === null;
|
||||
workflows.value = (workflowList?.definitions ?? []).map(({ id }) => id);
|
||||
workflowsError.value = workflowList === null;
|
||||
workflows.value = (workflowList ?? []).map(({ name }) => name);
|
||||
}
|
||||
|
||||
watch(open, (value) => {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { api } from "@/lib/api";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
|
||||
/** A class's recent decisions, level raises and resets. */
|
||||
const props = defineProps<{ id: string }>();
|
||||
const { data, error, reload } = useRead(() => api.actionClass(props.id));
|
||||
onMounted(reload);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||
<Skeleton v-else-if="!data" class="h-12 w-full" />
|
||||
<div v-else class="space-y-2 text-caption" @click.stop>
|
||||
<p v-if="data.tightened_because">Tightened <Timestamp :at="data.tightened_at" />: {{ data.tightened_because }}</p>
|
||||
<ul v-if="data.raises?.length" class="space-y-0.5">
|
||||
<li v-for="r in data.raises" :key="r.id">Raise {{ r.from }} → {{ r.to }}, {{ r.state }}, proposed <Timestamp :at="r.proposed_at" /></li>
|
||||
</ul>
|
||||
<ul v-if="data.resets?.length" class="space-y-0.5">
|
||||
<li v-for="r in data.resets" :key="r.at">Reset {{ r.from }} → {{ r.to }} by {{ r.by }} <Timestamp :at="r.at" /></li>
|
||||
</ul>
|
||||
<ul v-if="data.history?.length" class="space-y-0.5">
|
||||
<li v-for="h in data.history" :key="h.at + (h.run_id ?? '')">
|
||||
<Timestamp :at="h.at" /> · {{ h.level }}<template v-if="h.target"> · {{ h.target }}</template><template v-if="h.answered_by"> · answered by {{ h.answered_by }}</template><template v-if="h.refused_by"> · refused by {{ h.refused_by }}</template>
|
||||
<template v-if="h.run_id"> · <RouterLink class="underline" :to="`/runs/${h.run_id}`">run</RouterLink></template>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-if="!data.raises?.length && !data.resets?.length && !data.history?.length" class="text-fg-muted">No decisions yet.</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,103 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { MoreMenu } from "@/components/ui/more-menu";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError, type ActionClass, type Judge } from "@/lib/api";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
import ActionClassDetail from "./ActionClassDetail.vue";
|
||||
import PolicyText from "./PolicyText.vue";
|
||||
|
||||
/** What bounds every action: hard rules, change-request rules, the guards'
|
||||
* judges, and the approval level each class of action has earned. */
|
||||
const judges = useRead(() => api.judges());
|
||||
const classes = useRead(() => api.actionClasses());
|
||||
onMounted(() => {
|
||||
void judges.reload();
|
||||
void classes.reload();
|
||||
});
|
||||
|
||||
const judgeColumns: DataTableColumn<Judge>[] = [
|
||||
{ id: "name", label: "Guard", fixed: true, sort: (j) => j.name },
|
||||
{ id: "mode", label: "Mode", fixed: true },
|
||||
{ id: "latest", label: "Last evaluation" },
|
||||
];
|
||||
const classColumns: DataTableColumn<ActionClass>[] = [
|
||||
{ id: "action", label: "Action", fixed: true, sort: (c) => `${c.connector}.${c.action}` },
|
||||
{ id: "target", label: "Target", sort: (c) => c.target_kind ?? "" },
|
||||
{ id: "level", label: "Level", fixed: true, sort: (c) => c.level },
|
||||
{ id: "count", label: "Approved in a row", sort: (c) => c.count },
|
||||
{ id: "decisions", label: "Decisions", hidden: true, sort: (c) => c.decisions },
|
||||
{ id: "last", label: "Last decided", sort: (c) => (c.last_decided_at ? Date.parse(c.last_decided_at) : 0) },
|
||||
];
|
||||
|
||||
const resetError = ref("");
|
||||
async function reset(c: ActionClass): Promise<void> {
|
||||
resetError.value = "";
|
||||
try {
|
||||
await api.resetActionClass(c.id);
|
||||
} catch (cause) {
|
||||
resetError.value = describeError(cause, errors.common.unknown);
|
||||
}
|
||||
await classes.reload();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Controls" />
|
||||
<PolicyText kind="hard-rules" title="Hard rules" />
|
||||
<PolicyText kind="change-request" title="Change-request rules" />
|
||||
<Section title="Guards">
|
||||
<ReadError v-if="judges.error.value" :message="judges.error.value" retry-label="Retry" @retry="judges.reload" />
|
||||
<Skeleton v-else-if="!judges.data.value" class="h-16 w-full" />
|
||||
<DataTable v-else :columns="judgeColumns" :rows="judges.data.value" :row-key="(j) => j.name" storage-key="judges">
|
||||
<template #cell-name="{ row }"><span class="font-medium">{{ row.name }}</span> <span class="text-caption text-fg-subtle">{{ row.version }}</span></template>
|
||||
<template #cell-mode="{ row }">
|
||||
<Badge :variant="row.advisory ? 'idle' : 'ok'" :title="row.latest?.advisory_reason || undefined">{{ row.advisory ? "Advisory" : "Enforcing" }}</Badge>
|
||||
</template>
|
||||
<template #cell-latest="{ row }">
|
||||
<span v-if="row.latest" class="text-caption">
|
||||
<Timestamp :at="row.latest.at" /><template v-if="row.latest.model"> · {{ row.latest.model }}</template><template v-if="row.latest.answer"> · {{ row.latest.answer }}</template>
|
||||
<Badge v-if="row.latest.trusted === false" variant="warn" class="ml-1">Not trusted</Badge>
|
||||
</span>
|
||||
</template>
|
||||
<template #empty><Empty><EmptyHeader><EmptyTitle>No guards</EmptyTitle></EmptyHeader></Empty></template>
|
||||
</DataTable>
|
||||
<p class="mt-2 text-caption text-fg-muted"><RouterLink class="underline" :to="{ path: '/settings/extensions', query: { kind: 'guards' } }">Manage guards</RouterLink></p>
|
||||
</Section>
|
||||
<Section title="Action classes">
|
||||
<p v-if="resetError" role="alert" class="mb-2 text-caption text-danger">{{ resetError }}</p>
|
||||
<ReadError v-if="classes.error.value" :message="classes.error.value" retry-label="Retry" @retry="classes.reload" />
|
||||
<Skeleton v-else-if="!classes.data.value" class="h-16 w-full" />
|
||||
<DataTable v-else :columns="classColumns" :rows="classes.data.value" :row-key="(c) => c.id" storage-key="action-classes">
|
||||
<template #cell-action="{ row }"><span class="font-mono text-caption">{{ row.connector }}.{{ row.action }}</span></template>
|
||||
<template #cell-target="{ row }">{{ row.target_kind }}<span v-if="row.environment" class="text-caption text-fg-muted"> · {{ row.environment }}</span></template>
|
||||
<template #cell-level="{ row }">
|
||||
<Badge variant="outline" :title="row.tightened_because || undefined">{{ row.level }}</Badge>
|
||||
<span v-if="row.level !== row.default" class="text-caption text-fg-muted"> from {{ row.default }}</span>
|
||||
</template>
|
||||
<template #cell-count="{ row }">{{ row.count }}</template>
|
||||
<template #cell-decisions="{ row }">{{ row.decisions }}</template>
|
||||
<template #cell-last="{ row }"><Timestamp :at="row.last_decided_at" /></template>
|
||||
<template #detail="{ row }"><ActionClassDetail :id="row.id" /></template>
|
||||
<template #actions="{ row }">
|
||||
<MoreMenu :label="`${row.connector}.${row.action} actions`">
|
||||
<DropdownMenuItem :disabled="row.level === row.default" @select="reset(row)">Reset to {{ row.default }}</DropdownMenuItem>
|
||||
</MoreMenu>
|
||||
</template>
|
||||
<template #empty><Empty><EmptyHeader><EmptyTitle>No action classes</EmptyTitle></EmptyHeader></Empty></template>
|
||||
</DataTable>
|
||||
</Section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,97 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError, type PolicyKind } from "@/lib/api";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
|
||||
/** One Cedar rule set: the current text, edited in place and published as a
|
||||
* new version, and the versions before it, read-only. */
|
||||
const props = defineProps<{ kind: PolicyKind; title: string }>();
|
||||
|
||||
const latest = useRead(() => api.policyText(props.kind));
|
||||
onMounted(latest.reload);
|
||||
const picked = ref(0);
|
||||
const old = useRead(() => api.policyText(props.kind, picked.value));
|
||||
watch(picked, (v) => v && void old.reload());
|
||||
|
||||
const text = ref("");
|
||||
const base = ref(0);
|
||||
watch(() => latest.data.value, (p) => {
|
||||
if (p && !base.value) {
|
||||
text.value = p.body;
|
||||
base.value = p.version;
|
||||
}
|
||||
});
|
||||
const viewingOld = computed(() => !!picked.value && picked.value !== latest.data.value?.version);
|
||||
const edited = computed(() => !!latest.data.value && text.value !== latest.data.value.body);
|
||||
|
||||
const busy = ref(false);
|
||||
const publishError = ref("");
|
||||
async function publish(): Promise<void> {
|
||||
busy.value = true;
|
||||
publishError.value = "";
|
||||
try {
|
||||
const current = await api.policyText(props.kind);
|
||||
if (current.version !== base.value) {
|
||||
publishError.value = `Version ${current.version} was published after you opened version ${base.value}. Copy your changes, then discard them to load it.`;
|
||||
return;
|
||||
}
|
||||
const saved = await api.putPolicyText(props.kind, text.value);
|
||||
base.value = saved.version;
|
||||
text.value = saved.body;
|
||||
await latest.reload();
|
||||
} catch (cause) {
|
||||
publishError.value = describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
function discard(): void {
|
||||
base.value = 0;
|
||||
publishError.value = "";
|
||||
void latest.reload();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Section :title="title" :edited="edited">
|
||||
<template v-if="latest.data.value" #action>
|
||||
<Select v-if="(latest.data.value.versions?.length ?? 0) > 1" :model-value="String(picked || latest.data.value.version)" @update:model-value="(v) => (picked = Number(v) === latest.data.value?.version ? 0 : Number(v))">
|
||||
<SelectTrigger size="sm" :aria-label="`${title} version`"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="v in latest.data.value.versions" :key="v.version" :value="String(v.version)">Version {{ v.version }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Badge v-else variant="outline">Version {{ latest.data.value.version }}</Badge>
|
||||
</template>
|
||||
<ReadError v-if="latest.error.value" :message="latest.error.value" retry-label="Retry" @retry="latest.reload" />
|
||||
<Skeleton v-else-if="!latest.data.value" class="h-40 w-full" />
|
||||
<template v-else-if="viewingOld">
|
||||
<ReadError v-if="old.error.value" :message="old.error.value" retry-label="Retry" @retry="old.reload" />
|
||||
<p v-if="old.data.value" class="mb-2 text-caption text-fg-muted">
|
||||
<Timestamp :at="old.data.value.created_at" /><template v-if="old.data.value.created_by"> by {{ old.data.value.created_by }}</template>
|
||||
</p>
|
||||
<Textarea :model-value="old.data.value?.body ?? ''" readonly class="min-h-60 font-mono" :aria-label="`${title}, version ${picked}`" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<p class="mb-2 text-caption text-fg-muted">
|
||||
<Timestamp :at="latest.data.value.created_at" /><template v-if="latest.data.value.created_by"> by {{ latest.data.value.created_by }}</template>
|
||||
</p>
|
||||
<Textarea v-model="text" class="min-h-60 font-mono" spellcheck="false" :aria-label="title" />
|
||||
<div class="mt-2 flex flex-wrap items-center justify-end gap-2">
|
||||
<p v-if="publishError" role="alert" class="mr-auto text-caption text-danger">{{ publishError }}</p>
|
||||
<Button size="sm" variant="outline" :disabled="!edited || busy" @click="discard">Discard</Button>
|
||||
<Button size="sm" :disabled="!edited || busy" @click="publish">Publish</Button>
|
||||
</div>
|
||||
</template>
|
||||
</Section>
|
||||
</template>
|
||||
@@ -0,0 +1,28 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
|
||||
import CodeView from "@/base/CodeView.vue";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { api } from "@/lib/api";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
|
||||
/** One event's payload and the runs it started. */
|
||||
const props = defineProps<{ id: string }>();
|
||||
const { data, error, reload } = useRead(() => api.event(props.id));
|
||||
onMounted(reload);
|
||||
const body = computed(() => JSON.stringify(data.value?.body ?? null, null, 2));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||
<Skeleton v-else-if="!data" class="h-24 w-full" />
|
||||
<div v-else class="space-y-2" @click.stop>
|
||||
<p v-if="data.runs?.length" class="text-caption text-fg-muted">
|
||||
Started
|
||||
<template v-for="(run, i) in data.runs" :key="run.run_id"><template v-if="i">, </template><RouterLink class="underline" :to="`/runs/${run.run_id}`">a run</RouterLink> through {{ run.trigger }}</template>
|
||||
</p>
|
||||
<CodeView :code="body" lang="json" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,103 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { api, type EventRecord } from "@/lib/api";
|
||||
import { usePoll, useRead } from "@/lib/use-read";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
import EventDetail from "./EventDetail.vue";
|
||||
|
||||
const route = useRoute();
|
||||
const ALL = "__all__";
|
||||
const source = ref(ALL);
|
||||
const type = ref("");
|
||||
const matched = ref(ALL);
|
||||
|
||||
const sources = useRead(() => api.eventSources());
|
||||
const { data, error, reload } = useRead(() =>
|
||||
api.events({
|
||||
limit: 200,
|
||||
source: source.value === ALL ? undefined : source.value,
|
||||
type: type.value.trim() || undefined,
|
||||
matched: matched.value === ALL ? undefined : matched.value,
|
||||
}),
|
||||
);
|
||||
onMounted(() => {
|
||||
void reload();
|
||||
void sources.reload();
|
||||
});
|
||||
watch([source, matched], () => void reload());
|
||||
useLiveResource(null, () => void reload());
|
||||
usePoll(reload);
|
||||
|
||||
// ?event= opens one event above the list: a run links to the event it started from.
|
||||
const linked = computed(() => String(route.query.event ?? ""));
|
||||
|
||||
const time = (at?: string) => (at ? Date.parse(at) : 0);
|
||||
const columns: DataTableColumn<EventRecord>[] = [
|
||||
{ id: "received", label: "Received", fixed: true, sort: (e) => time(e.received_at) },
|
||||
{ id: "source", label: "Source", fixed: true, sort: (e) => e.source },
|
||||
{ id: "type", label: "Type", fixed: true, sort: (e) => e.type },
|
||||
{ id: "matched", label: "Matched", sort: (e) => (e.matched ? 1 : 0) },
|
||||
{ id: "occurred", label: "Occurred", hidden: true, sort: (e) => time(e.occurred_at) },
|
||||
{ id: "linked", label: "Same as", hidden: true },
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Section v-if="linked" title="Event"><EventDetail :id="linked" /></Section>
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2">
|
||||
<Select v-model="source">
|
||||
<SelectTrigger size="sm" aria-label="Source"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem :value="ALL">All sources</SelectItem>
|
||||
<SelectItem v-for="s in sources.data.value ?? []" :key="s.name" :value="s.name">{{ s.name }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Select v-model="matched">
|
||||
<SelectTrigger size="sm" aria-label="Trigger outcome"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem :value="ALL">Matched or not</SelectItem>
|
||||
<SelectItem value="true">Matched a trigger</SelectItem>
|
||||
<SelectItem value="false">Unmatched</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<form class="contents" @submit.prevent="reload">
|
||||
<Input v-model="type" class="h-8 w-48" placeholder="Event type" aria-label="Event type" @change="reload" />
|
||||
</form>
|
||||
</div>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||
<div v-else-if="!data" role="status" aria-label="Loading events" class="space-y-2"><Skeleton class="h-8 w-full" /><Skeleton class="h-8 w-full" /></div>
|
||||
<DataTable
|
||||
v-else
|
||||
:columns="columns"
|
||||
:rows="data"
|
||||
:row-key="(e) => e.id"
|
||||
storage-key="events"
|
||||
:initial-sort="{ id: 'received', desc: true }"
|
||||
>
|
||||
<template #cell-received="{ row }"><Timestamp :at="row.received_at" /></template>
|
||||
<template #cell-source="{ row }">{{ row.source }}</template>
|
||||
<template #cell-type="{ row }"><span class="font-mono text-caption">{{ row.type }}</span></template>
|
||||
<template #cell-matched="{ row }">
|
||||
<Badge :variant="row.matched ? 'ok' : 'idle'">{{ row.matched ? "Matched" : "Unmatched" }}</Badge>
|
||||
</template>
|
||||
<template #cell-occurred="{ row }"><Timestamp :at="row.occurred_at" /></template>
|
||||
<template #cell-linked="{ row }"><span class="font-mono text-caption">{{ row.linked_to }}</span></template>
|
||||
<template #detail="{ row }"><EventDetail :id="row.id" /></template>
|
||||
<template #empty>
|
||||
<Empty><EmptyHeader><EmptyTitle>No events</EmptyTitle></EmptyHeader></Empty>
|
||||
</template>
|
||||
</DataTable>
|
||||
</div>
|
||||
</template>
|
||||
@@ -23,6 +23,9 @@ import CapturesPage from "@/captures/CapturesPage.vue";
|
||||
import { api } from "@/lib/api";
|
||||
import { useLiveResource, useSessionStore } from "@/stores/session";
|
||||
import MappingsPage from "@/mappings/MappingsPage.vue";
|
||||
import EventList from "./EventList.vue";
|
||||
import SourceList from "./SourceList.vue";
|
||||
import TriggerList from "./TriggerList.vue";
|
||||
import { activeTab, availableTabs, stepsFor } from "./tab-selection";
|
||||
import { loadEventCounts, type EventsCounts } from "./counts";
|
||||
|
||||
@@ -41,6 +44,9 @@ import { loadEventCounts, type EventsCounts } from "./counts";
|
||||
* Which steps exist, and which one is showing, is decided in tab-selection.ts.
|
||||
*/
|
||||
const PANELS: Record<string, Component> = {
|
||||
events: EventList,
|
||||
sources: SourceList,
|
||||
triggers: TriggerList,
|
||||
inspector: CapturesPage,
|
||||
bindings: BindingsPage,
|
||||
mappings: MappingsPage,
|
||||
@@ -77,7 +83,10 @@ const counts = ref<EventsCounts>({});
|
||||
// started is dropped, so the previous workspace's counts never overwrite the
|
||||
// current one.
|
||||
let countsGeneration = 0;
|
||||
// The capture chain's counts read routes only a capture backend serves.
|
||||
const captureChain = computed(() => session.sections?.captures !== false);
|
||||
async function loadCounts() {
|
||||
if (!captureChain.value) return;
|
||||
const gen = ++countsGeneration;
|
||||
const workspace = events.workspace;
|
||||
const loaded = await loadEventCounts({
|
||||
@@ -108,6 +117,7 @@ function pickWorkspace(value: unknown): void {
|
||||
void router.replace({ query: { ...route.query, workspace } });
|
||||
}
|
||||
onMounted(async () => {
|
||||
if (session.sections?.org === false) return;
|
||||
try {
|
||||
await orgStore.loadOrg();
|
||||
workspaces.value = (
|
||||
@@ -146,7 +156,7 @@ const panel = computed(() => PANELS[active.value]);
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<template v-if="!captureLoading">
|
||||
<template v-if="captureChain && !captureLoading">
|
||||
<Badge v-if="!captureEnabled" variant="warn">Capture off</Badge>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
<script setup lang="ts">
|
||||
import { Plus } from "@lucide/vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
|
||||
import CodeView from "@/base/CodeView.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { MoreMenu } from "@/components/ui/more-menu";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { SettingRow } from "@/components/ui/setting-row";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError, type EventSource_ } from "@/lib/api";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
|
||||
const { data, error, reload } = useRead(() => api.eventSources());
|
||||
const connectors = useRead(() => api.extensions("connectors"));
|
||||
onMounted(() => {
|
||||
void reload();
|
||||
void connectors.reload();
|
||||
});
|
||||
|
||||
const columns: DataTableColumn<EventSource_>[] = [
|
||||
{ id: "name", label: "Source", fixed: true, sort: (s) => s.name },
|
||||
{ id: "connector", label: "Connector", sort: (s) => s.connector },
|
||||
{ id: "key", label: "Grouped by" },
|
||||
];
|
||||
|
||||
// A put creates a source or rotates its token; either way the token is shown
|
||||
// once, since only its hash is kept.
|
||||
const issued = ref<{ url: string; token: string } | null>(null);
|
||||
const busy = ref(false);
|
||||
const actionError = ref("");
|
||||
async function put(name: string, connector: string): Promise<boolean> {
|
||||
busy.value = true;
|
||||
actionError.value = "";
|
||||
try {
|
||||
const created = await api.putEventSource(name, connector);
|
||||
issued.value = { url: new URL(created.url, window.location.origin).toString(), token: created.token };
|
||||
await reload();
|
||||
return true;
|
||||
} catch (cause) {
|
||||
actionError.value = describeError(cause, errors.common.unknown);
|
||||
return false;
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const adding = ref(false);
|
||||
const draft = ref({ name: "", connector: "" });
|
||||
async function add(): Promise<void> {
|
||||
if (await put(draft.value.name.trim(), draft.value.connector)) {
|
||||
adding.value = false;
|
||||
draft.value = { name: "", connector: "" };
|
||||
}
|
||||
}
|
||||
|
||||
const keyFieldsOf = ref<EventSource_ | null>(null);
|
||||
const keyFields = ref("");
|
||||
function editKeyFields(source: EventSource_): void {
|
||||
keyFieldsOf.value = source;
|
||||
keyFields.value = (source.key_fields ?? []).join(", ");
|
||||
actionError.value = "";
|
||||
}
|
||||
async function saveKeyFields(): Promise<void> {
|
||||
if (!keyFieldsOf.value) return;
|
||||
busy.value = true;
|
||||
actionError.value = "";
|
||||
try {
|
||||
const paths = keyFields.value.split(",").map((p) => p.trim()).filter(Boolean);
|
||||
await api.putSourceKeyFields(keyFieldsOf.value.name, paths);
|
||||
keyFieldsOf.value = null;
|
||||
await reload();
|
||||
} catch (cause) {
|
||||
actionError.value = describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
const connectorNames = computed(() => (connectors.data.value ?? []).map((c) => c.name));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Section v-if="issued" title="Webhook" description="Copy the token now: it is not shown again.">
|
||||
<SettingRow label="URL"><CodeView :code="issued.url" /></SettingRow>
|
||||
<SettingRow label="Bearer token"><CodeView :code="issued.token" /></SettingRow>
|
||||
<div class="flex justify-end"><Button size="sm" variant="outline" @click="issued = null">Done</Button></div>
|
||||
</Section>
|
||||
<p v-if="actionError && !adding && !keyFieldsOf" role="alert" class="mb-2 text-caption text-danger">{{ actionError }}</p>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||
<div v-else-if="!data" role="status" aria-label="Loading sources" class="space-y-2"><Skeleton class="h-8 w-full" /></div>
|
||||
<template v-else>
|
||||
<div class="mb-2 flex justify-end">
|
||||
<Button size="sm" aria-label="Add source" title="Add source" @click="adding = true; actionError = ''"><Plus /></Button>
|
||||
</div>
|
||||
<DataTable :columns="columns" :rows="data" :row-key="(s) => s.name" storage-key="sources">
|
||||
<template #cell-name="{ row }"><span class="font-medium">{{ row.name }}</span></template>
|
||||
<template #cell-connector="{ row }">{{ row.connector }}</template>
|
||||
<template #cell-key="{ row }"><span class="font-mono text-caption">{{ (row.key_fields ?? []).join(", ") || "Connector default" }}</span></template>
|
||||
<template #actions="{ row }">
|
||||
<MoreMenu :label="`${row.name} actions`">
|
||||
<DropdownMenuItem @select="editKeyFields(row)">Group by…</DropdownMenuItem>
|
||||
<DropdownMenuItem :disabled="busy" @select="put(row.name, row.connector)">Rotate token</DropdownMenuItem>
|
||||
</MoreMenu>
|
||||
</template>
|
||||
<template #empty><Empty><EmptyHeader><EmptyTitle>No sources</EmptyTitle></EmptyHeader></Empty></template>
|
||||
</DataTable>
|
||||
</template>
|
||||
|
||||
<Dialog v-model:open="adding">
|
||||
<DialogContent>
|
||||
<DialogHeader><DialogTitle>Add source</DialogTitle></DialogHeader>
|
||||
<form id="add-source" class="space-y-3" @submit.prevent="add">
|
||||
<Input v-model="draft.name" aria-label="Name" placeholder="alertmanager" pattern="[a-z0-9][a-z0-9-]*" required />
|
||||
<Select v-model="draft.connector" required>
|
||||
<SelectTrigger class="w-full" aria-label="Connector"><SelectValue placeholder="Connector that parses its events" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="name in connectorNames" :key="name" :value="name">{{ name }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<p v-if="connectors.error.value" class="text-caption text-danger">{{ connectors.error.value }}</p>
|
||||
<p v-if="actionError" role="alert" class="text-caption text-danger">{{ actionError }}</p>
|
||||
</form>
|
||||
<DialogFooter><Button type="submit" form="add-source" :disabled="busy || !draft.name || !draft.connector">Add</Button></DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<Dialog :open="!!keyFieldsOf" @update:open="(open) => { if (!open) keyFieldsOf = null; }">
|
||||
<DialogContent>
|
||||
<DialogHeader><DialogTitle>Group {{ keyFieldsOf?.name }} events by</DialogTitle></DialogHeader>
|
||||
<form id="key-fields" class="space-y-3" @submit.prevent="saveKeyFields">
|
||||
<Input v-model="keyFields" aria-label="Field paths" placeholder="labels.alertname, labels.instance" />
|
||||
<p class="text-caption text-fg-muted">Comma-separated field paths. Leave empty for the connector's default. Applies to events that arrive after you save.</p>
|
||||
<p v-if="actionError" role="alert" class="text-caption text-danger">{{ actionError }}</p>
|
||||
</form>
|
||||
<DialogFooter><Button type="submit" form="key-fields" :disabled="busy">Save</Button></DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,153 @@
|
||||
<script setup lang="ts">
|
||||
import { Plus } from "@lucide/vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { MoreMenu } from "@/components/ui/more-menu";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError, type Trigger, type TriggerInput } from "@/lib/api";
|
||||
import { fromLines, toLines } from "@/lib/lines";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
import { triggerInput } from "./trigger";
|
||||
|
||||
/** With `workflow`, only the triggers that run it, and new ones run it. */
|
||||
const props = defineProps<{ workflow?: string }>();
|
||||
|
||||
const { data, error, reload } = useRead(() => api.triggers());
|
||||
const sources = useRead(() => api.eventSources());
|
||||
const workflows = useRead(() => api.workflowList());
|
||||
onMounted(() => {
|
||||
void reload();
|
||||
void sources.reload();
|
||||
if (!props.workflow) void workflows.reload();
|
||||
});
|
||||
const rows = computed(() => (data.value ?? []).filter((t) => !props.workflow || t.workflow === props.workflow));
|
||||
|
||||
const columns = computed<DataTableColumn<Trigger>[]>(() => [
|
||||
{ id: "name", label: "Trigger", fixed: true, sort: (t) => t.name },
|
||||
{ id: "fires", label: "Fires on", fixed: true },
|
||||
...(props.workflow ? [] : [{ id: "workflow", label: "Workflow", sort: (t: Trigger) => t.workflow }]),
|
||||
{ id: "filter", label: "Filter", hidden: true },
|
||||
{ id: "enabled", label: "On", fixed: true, class: "w-0" },
|
||||
]);
|
||||
|
||||
const busy = ref(false);
|
||||
const actionError = ref("");
|
||||
async function save(name: string, input: TriggerInput): Promise<boolean> {
|
||||
busy.value = true;
|
||||
actionError.value = "";
|
||||
try {
|
||||
await api.putTrigger(name, input);
|
||||
await reload();
|
||||
return true;
|
||||
} catch (cause) {
|
||||
actionError.value = describeError(cause, errors.common.unknown);
|
||||
return false;
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const editing = ref(false);
|
||||
const isNew = ref(true);
|
||||
const form = ref({ name: "", mode: "event", source: "", event_type: "", every: "", workflow: "", filter: "", disabled: false });
|
||||
function open(trigger?: Trigger): void {
|
||||
isNew.value = !trigger;
|
||||
actionError.value = "";
|
||||
form.value = {
|
||||
name: trigger?.name ?? "",
|
||||
mode: trigger?.every ? "schedule" : "event",
|
||||
source: trigger?.every ? "" : (trigger?.source ?? ""),
|
||||
event_type: trigger?.every ? "" : (trigger?.event_type ?? ""),
|
||||
every: trigger?.every ?? "",
|
||||
workflow: trigger?.workflow ?? props.workflow ?? "",
|
||||
filter: trigger?.every ? "" : toLines(trigger?.filter ?? {}),
|
||||
disabled: trigger ? !trigger.enabled : false,
|
||||
};
|
||||
editing.value = true;
|
||||
}
|
||||
async function submit(): Promise<void> {
|
||||
const f = form.value;
|
||||
const filter = fromLines(f.filter);
|
||||
const input: TriggerInput =
|
||||
f.mode === "schedule"
|
||||
? { every: f.every.trim(), workflow: f.workflow, disabled: f.disabled }
|
||||
: { source: f.source, event_type: f.event_type.trim(), filter, workflow: f.workflow, disabled: f.disabled };
|
||||
if (await save(f.name.trim(), input)) editing.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<p v-if="actionError && !editing" role="alert" class="mb-2 text-caption text-danger">{{ actionError }}</p>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||
<div v-else-if="!data" role="status" aria-label="Loading triggers" class="space-y-2"><Skeleton class="h-8 w-full" /></div>
|
||||
<template v-else>
|
||||
<div class="mb-2 flex justify-end">
|
||||
<Button size="sm" aria-label="Add trigger" title="Add trigger" @click="open()"><Plus /></Button>
|
||||
</div>
|
||||
<DataTable :columns="columns" :rows="rows" :row-key="(t) => t.name" :storage-key="workflow ? 'workflow-triggers' : 'triggers'">
|
||||
<template #cell-name="{ row }"><span class="font-medium">{{ row.name }}</span></template>
|
||||
<template #cell-fires="{ row }">
|
||||
<template v-if="row.every">Every {{ row.every }}</template>
|
||||
<template v-else>{{ row.source }} <span class="font-mono text-caption">{{ row.event_type }}</span></template>
|
||||
</template>
|
||||
<template #cell-workflow="{ row }"><RouterLink class="underline" :to="`/workflows/${row.workflow}`">{{ row.workflow }}</RouterLink></template>
|
||||
<template #cell-filter="{ row }">
|
||||
<span v-if="!row.every" class="font-mono text-caption">{{ Object.entries(row.filter ?? {}).map(([k, v]) => `${k}=${v}`).join(", ") }}</span>
|
||||
</template>
|
||||
<template #cell-enabled="{ row }">
|
||||
<Switch size="sm" :model-value="row.enabled" :disabled="busy" :aria-label="`${row.name} on`" @click.stop @update:model-value="save(row.name, { ...triggerInput(row), disabled: !$event })" />
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<MoreMenu :label="`${row.name} actions`"><DropdownMenuItem @select="open(row)">Edit</DropdownMenuItem></MoreMenu>
|
||||
</template>
|
||||
<template #empty><Empty><EmptyHeader><EmptyTitle>No triggers</EmptyTitle></EmptyHeader></Empty></template>
|
||||
</DataTable>
|
||||
</template>
|
||||
|
||||
<Dialog v-model:open="editing">
|
||||
<DialogContent>
|
||||
<DialogHeader><DialogTitle>{{ isNew ? "Add trigger" : `Edit ${form.name}` }}</DialogTitle></DialogHeader>
|
||||
<form id="trigger-form" class="space-y-3" @submit.prevent="submit">
|
||||
<Input v-if="isNew" v-model="form.name" aria-label="Name" placeholder="Name" pattern="[a-z0-9][a-z0-9-]*" required />
|
||||
<ToggleGroup v-model="form.mode" type="single" variant="outline" size="sm" aria-label="Fires on">
|
||||
<ToggleGroupItem value="event">Events</ToggleGroupItem>
|
||||
<ToggleGroupItem value="schedule">Schedule</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
<template v-if="form.mode === 'event'">
|
||||
<Select v-model="form.source" required>
|
||||
<SelectTrigger class="w-full" aria-label="Source"><SelectValue placeholder="Source" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="s in sources.data.value ?? []" :key="s.name" :value="s.name">{{ s.name }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Input v-model="form.event_type" aria-label="Event type" placeholder="Event type" required />
|
||||
<Textarea v-model="form.filter" aria-label="Filter" placeholder="field=value, one per line" class="font-mono" rows="3" />
|
||||
</template>
|
||||
<Input v-else v-model="form.every" aria-label="Every" placeholder="Every, such as 1h" required />
|
||||
<Select v-if="!workflow" v-model="form.workflow" required>
|
||||
<SelectTrigger class="w-full" aria-label="Workflow"><SelectValue placeholder="Workflow it runs" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="w in workflows.data.value ?? []" :key="w.name" :value="w.name">{{ w.name }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<p v-if="actionError" role="alert" class="text-caption text-danger">{{ actionError }}</p>
|
||||
</form>
|
||||
<DialogFooter><Button type="submit" form="trigger-form" :disabled="busy">Save</Button></DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -17,6 +17,9 @@ export interface EventsTabSpec {
|
||||
/** The tabs, in reading order: what arrived, where its fields go wrong, what
|
||||
* runs. */
|
||||
const EVENTS_TABS: EventsTabSpec[] = [
|
||||
{ id: "events", label: "Events", section: "events" },
|
||||
{ id: "sources", label: "Sources", section: "events" },
|
||||
{ id: "triggers", label: "Triggers", section: "events" },
|
||||
{ id: "inspector", label: "Inspector", section: "captures" },
|
||||
{ id: "mappings", label: "Mappings", section: "mappings" },
|
||||
{ id: "bindings", label: "Bindings", section: "bindings" },
|
||||
@@ -68,6 +71,9 @@ const STEP_COPY: Record<string, { label: string; hint: string }> = {
|
||||
inspector: { label: "Capture", hint: "webhooks received" },
|
||||
mappings: { label: "Map", hint: "field mappings" },
|
||||
bindings: { label: "Bind", hint: "bindings to workflows" },
|
||||
events: { label: "Events", hint: "events received" },
|
||||
sources: { label: "Sources", hint: "sources" },
|
||||
triggers: { label: "Triggers", hint: "triggers" },
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { Trigger, TriggerInput } from "@/lib/api";
|
||||
|
||||
/** triggerInput is the put that keeps a listed trigger as it is. A schedule
|
||||
* sends only its interval: the server fixes its source, type and filter. */
|
||||
export function triggerInput(trigger: Trigger): TriggerInput {
|
||||
if (trigger.every) return { every: trigger.every, workflow: trigger.workflow, disabled: !trigger.enabled };
|
||||
return {
|
||||
source: trigger.source,
|
||||
event_type: trigger.event_type,
|
||||
filter: trigger.filter,
|
||||
workflow: trigger.workflow,
|
||||
disabled: !trigger.enabled,
|
||||
};
|
||||
}
|
||||
+275
-1
@@ -184,6 +184,52 @@ async function request<T = unknown>(
|
||||
}
|
||||
|
||||
export const api = {
|
||||
// The archie binary's module API; the wire types are below the object.
|
||||
runs: (limit = 200) => request<Run[]>("/api/runs" + qs({ limit })),
|
||||
run: (id: string) => request<RunTrail>(`/api/runs/${encodeURIComponent(id)}`),
|
||||
approvals: () => request<Approval[]>("/api/approvals"),
|
||||
answerApproval: (id: string, approved: boolean) =>
|
||||
request<Approval>(`/api/approvals/${encodeURIComponent(id)}/answer`, { method: "POST", body: { approved } }),
|
||||
events: (params: { limit?: number; source?: string; type?: string; matched?: string } = {}) =>
|
||||
request<EventRecord[]>("/api/events" + qs(params)),
|
||||
event: (id: string) => request<EventDetail>(`/api/events/${encodeURIComponent(id)}`),
|
||||
eventSources: () => request<EventSource_[]>("/api/sources"),
|
||||
putEventSource: (name: string, connector: string) =>
|
||||
request<{ source: string; token: string; url: string }>(`/api/sources/${encodeURIComponent(name)}`, { method: "PUT", body: { connector } }),
|
||||
putSourceKeyFields: (name: string, paths: string[]) =>
|
||||
request<{ key_fields: string[] }>(`/api/sources/${encodeURIComponent(name)}/key-fields`, { method: "PUT", body: { paths } }),
|
||||
triggers: () => request<Trigger[]>("/api/triggers"),
|
||||
putTrigger: (name: string, trigger: TriggerInput) =>
|
||||
request<{ trigger: string }>(`/api/triggers/${encodeURIComponent(name)}`, { method: "PUT", body: trigger }),
|
||||
workflowList: () => request<WorkflowVersion[]>("/api/workflows"),
|
||||
workflow: (name: string, version?: number) =>
|
||||
request<WorkflowVersion>(`/api/workflows/${encodeURIComponent(name)}` + qs({ version })),
|
||||
putWorkflow: (name: string, body: string) =>
|
||||
request<WorkflowVersion>(`/api/workflows/${encodeURIComponent(name)}`, { method: "PUT", body: { body } }),
|
||||
workflowStepTypes: () => request<{ name: string; needs_repository: boolean; settings?: unknown }[]>("/api/workflow-step-types"),
|
||||
extensions: (kind: ExtensionKind) => request<Extension[]>(`/api/${kind}`),
|
||||
acceptExtension: (kind: ExtensionKind, name: string, body: ExtensionInput) =>
|
||||
request<{ name: string; state: string }>(`/api/${kind}/${encodeURIComponent(name)}`, { method: "PUT", body, timeoutMs: 60_000 }),
|
||||
removeExtension: (kind: ExtensionKind, name: string) =>
|
||||
request<{ name: string; state: string }>(`/api/${kind}/${encodeURIComponent(name)}`, { method: "DELETE" }),
|
||||
credentials: () => request<Credential[]>("/api/credentials"),
|
||||
credentialKinds: () => request<CredentialKind[]>("/api/credential-kinds"),
|
||||
putCredential: (name: string, kind: string, fields: Record<string, CredentialField>) =>
|
||||
request<{ name: string; kind: string; restarted: string[] }>(`/api/credentials/${encodeURIComponent(name)}`, { method: "PUT", body: { kind, fields }, timeoutMs: 60_000 }),
|
||||
agentModels: () => request<Record<string, AgentModel>>("/api/settings/agent-models"),
|
||||
putAgentModel: (alias: string, model: AgentModel) =>
|
||||
request<AgentModel>("/api/settings/agent-model" + qs({ alias }), { method: "PUT", body: model }),
|
||||
testAgentModel: (model: AgentModel) =>
|
||||
request<{ answer: string; model: string }>("/api/settings/agent-model/test", { method: "POST", body: model, timeoutMs: 60_000 }),
|
||||
policyText: (kind: PolicyKind, version?: number) =>
|
||||
request<PolicyText>(`/api/policies/${kind}` + qs({ version })),
|
||||
putPolicyText: (kind: PolicyKind, body: string) =>
|
||||
request<PolicyText>(`/api/policies/${kind}`, { method: "PUT", body: { body } }),
|
||||
judges: () => request<Judge[]>("/api/controls/judges"),
|
||||
actionClasses: () => request<ActionClass[]>("/api/classes"),
|
||||
actionClass: (id: string) => request<ActionClassDetail>(`/api/classes/${encodeURIComponent(id)}`),
|
||||
resetActionClass: (id: string) =>
|
||||
request<ActionClass>(`/api/classes/${encodeURIComponent(id)}/reset`, { method: "POST" }),
|
||||
recoveryCode: () => request<{code:string}>("/api/account/recovery",{method:"POST",body:{}}),
|
||||
recoverAccount: (email:string,code:string,password:string) => request<void>("/api/auth/recover",{method:"POST",body:{email,code,password},parse:false}),
|
||||
authStatus: <T = unknown>() => request<T>("/api/auth/status"),
|
||||
@@ -201,7 +247,6 @@ export const api = {
|
||||
deletePasskey: (id:string) => request<void>(`/api/account/passkeys/${encodeURIComponent(id)}`,{method:"DELETE",body:{},parse:false}),
|
||||
beginPasskey: <T = unknown>(registration:boolean) => request<T>(registration?"/api/account/passkeys/begin":"/api/auth/passkey/begin",{method:"POST",body:{}}),
|
||||
finishPasskey: (registration:boolean,credential:unknown,name:string) => request(registration?"/api/account/passkeys/finish":"/api/auth/passkey/finish",{method:"POST",body:{credential,name}}),
|
||||
secretEngines: <T = unknown>() => request<T>("/api/secret-engines"),
|
||||
checkSecret: (ref: { engine: string; key: string }) => request<{ resolved: boolean; process: string }>("/api/secret-references/check", { method: "POST", body: ref }),
|
||||
health: <T = unknown>() => request<T>("/health/detailed"),
|
||||
services: <T = unknown>() => request<T>("/api/services"),
|
||||
@@ -498,6 +543,235 @@ export const api = {
|
||||
}),
|
||||
};
|
||||
|
||||
export interface Run {
|
||||
id: string;
|
||||
workflow: string;
|
||||
workflow_version: number;
|
||||
state: string;
|
||||
attempts: number;
|
||||
error?: string;
|
||||
created_at: string;
|
||||
finished_at?: string;
|
||||
result?: unknown;
|
||||
}
|
||||
|
||||
export interface Approval {
|
||||
id: string;
|
||||
run_id: string;
|
||||
step: number;
|
||||
kind: string;
|
||||
action: string;
|
||||
target: string;
|
||||
level: string;
|
||||
summary: string;
|
||||
state: string;
|
||||
requested_at: string;
|
||||
deadline?: string;
|
||||
answered_at?: string;
|
||||
answered_by?: string;
|
||||
answered_via?: string;
|
||||
}
|
||||
|
||||
interface Decision {
|
||||
id: string;
|
||||
level: string;
|
||||
reason?: string;
|
||||
refused_by?: string;
|
||||
dry?: boolean;
|
||||
change_request?: boolean;
|
||||
change_request_rule?: string;
|
||||
at: string;
|
||||
action: { connector: string; name: string; target?: { Kind?: string; ID?: string; Environment?: string } };
|
||||
verdicts?: { guard: string; advisory: boolean; ceiling?: string; failed?: string }[];
|
||||
}
|
||||
|
||||
export interface RunAction {
|
||||
decision: Decision;
|
||||
rejudged?: Decision;
|
||||
approval?: Approval;
|
||||
effect?: { state: string; output?: string; error?: string; at?: string };
|
||||
}
|
||||
|
||||
export interface RunEntry {
|
||||
seq: number;
|
||||
kind: string;
|
||||
name?: string;
|
||||
at?: string;
|
||||
text?: string;
|
||||
output?: string;
|
||||
error?: string;
|
||||
unknown?: boolean;
|
||||
tool_calls?: { name: string; input: string }[];
|
||||
}
|
||||
|
||||
export interface RunTrail {
|
||||
run: Run;
|
||||
origin?: { event_id?: string; source?: string; type?: string; trigger?: string; received_at?: string };
|
||||
actions?: RunAction[];
|
||||
entries?: RunEntry[];
|
||||
}
|
||||
|
||||
export interface EventRecord {
|
||||
id: string;
|
||||
source: string;
|
||||
type: string;
|
||||
matched: boolean;
|
||||
received_at: string;
|
||||
occurred_at?: string;
|
||||
dispatched_at?: string;
|
||||
linked_to?: string;
|
||||
fields?: unknown;
|
||||
}
|
||||
|
||||
export interface EventDetail {
|
||||
body: unknown;
|
||||
runs?: { run_id: string; trigger: string }[];
|
||||
}
|
||||
|
||||
// Named with a trailing underscore: EventSource is the browser's SSE class.
|
||||
export interface EventSource_ {
|
||||
name: string;
|
||||
connector: string;
|
||||
key_fields?: string[];
|
||||
token_set: boolean;
|
||||
}
|
||||
|
||||
export interface Trigger {
|
||||
name: string;
|
||||
source?: string;
|
||||
event_type?: string;
|
||||
every?: string;
|
||||
workflow: string;
|
||||
filter?: Record<string, string>;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface TriggerInput {
|
||||
source?: string;
|
||||
event_type?: string;
|
||||
every?: string;
|
||||
workflow: string;
|
||||
filter?: Record<string, string>;
|
||||
disabled: boolean;
|
||||
}
|
||||
|
||||
export interface WorkflowVersion {
|
||||
name: string;
|
||||
version: number;
|
||||
body: string;
|
||||
steps?: string[];
|
||||
created_at: string;
|
||||
created_by?: string;
|
||||
}
|
||||
|
||||
export type ExtensionKind = "connectors" | "guards" | "mcp-servers" | "secret-engines";
|
||||
|
||||
export interface SettingField {
|
||||
key: string;
|
||||
label?: string;
|
||||
description?: string;
|
||||
type?: string;
|
||||
options?: string[];
|
||||
required?: boolean;
|
||||
secret?: boolean;
|
||||
}
|
||||
|
||||
export interface Extension {
|
||||
name: string;
|
||||
state: string;
|
||||
error?: string;
|
||||
path?: string;
|
||||
url?: string;
|
||||
args?: string[];
|
||||
digest?: string;
|
||||
version?: string;
|
||||
contract?: string;
|
||||
egress?: string[];
|
||||
env?: string[];
|
||||
settings?: Record<string, string>;
|
||||
settings_schema?: SettingField[];
|
||||
credentials?: Record<string, string>;
|
||||
/** An MCP server's declared tools, as it was accepted with them. */
|
||||
tools?: unknown;
|
||||
}
|
||||
|
||||
export interface ExtensionInput {
|
||||
path?: string;
|
||||
sha256?: string;
|
||||
url?: string;
|
||||
args?: string[];
|
||||
egress?: string[];
|
||||
env?: string[];
|
||||
settings?: Record<string, string>;
|
||||
credentials?: Record<string, string>;
|
||||
tools?: unknown;
|
||||
}
|
||||
|
||||
export interface Credential {
|
||||
name: string;
|
||||
kind: string;
|
||||
/** Per field: "stored", or "engine:key" for one a secret engine resolves. */
|
||||
fields: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface CredentialKind {
|
||||
kind: string;
|
||||
required: string[];
|
||||
optional?: string[];
|
||||
}
|
||||
|
||||
export interface CredentialField {
|
||||
value?: string;
|
||||
engine?: string;
|
||||
key?: string;
|
||||
}
|
||||
|
||||
export interface AgentModel {
|
||||
class: string;
|
||||
model: string;
|
||||
base_url?: string;
|
||||
api_key_credential?: string;
|
||||
}
|
||||
|
||||
export type PolicyKind = "hard-rules" | "change-request";
|
||||
|
||||
export interface PolicyText {
|
||||
body: string;
|
||||
version: number;
|
||||
created_at?: string;
|
||||
created_by?: string;
|
||||
versions?: { version: number; created_at: string; created_by?: string }[];
|
||||
}
|
||||
|
||||
export interface Judge {
|
||||
name: string;
|
||||
version?: string;
|
||||
advisory: boolean;
|
||||
latest?: { answer?: string; at?: string; model?: string; trusted?: boolean; advisory_reason?: string };
|
||||
}
|
||||
|
||||
export interface ActionClass {
|
||||
id: string;
|
||||
connector: string;
|
||||
action: string;
|
||||
target_kind?: string;
|
||||
environment?: string;
|
||||
level: string;
|
||||
default: string;
|
||||
count: number;
|
||||
decisions: number;
|
||||
last_decided_at?: string;
|
||||
tightened_at?: string;
|
||||
tightened_because?: string;
|
||||
reset_at?: string;
|
||||
}
|
||||
|
||||
export interface ActionClassDetail extends ActionClass {
|
||||
history?: { at: string; level: string; run_id?: string; target?: string; approval?: string; answered_by?: string; refused_by?: string }[];
|
||||
raises?: { id: string; from: string; to: string; state: string; proposed_at: string }[];
|
||||
resets?: { at: string; by: string; from: string; to: string }[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe to archied's event stream. Returns an unsubscribe function.
|
||||
* Reconnection is the browser's job via EventSource, but a closed stream is
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/** toLines writes a string map as `key=value` lines for a textarea. */
|
||||
export function toLines(map: Record<string, string>): string {
|
||||
return Object.entries(map).map(([k, v]) => `${k}=${v}`).join("\n");
|
||||
}
|
||||
|
||||
/** fromLines reads `key=value` lines back; a line without `=` is a key with no value. */
|
||||
export function fromLines(text: string): Record<string, string> {
|
||||
return Object.fromEntries(
|
||||
text.split("\n").map((l) => l.trim()).filter(Boolean).map((line) => {
|
||||
const at = line.indexOf("=");
|
||||
return at < 0 ? [line, ""] : [line.slice(0, at).trim(), line.slice(at + 1).trim()];
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -17,8 +17,10 @@ const table = flattenRoutes(routes as NavRouteNode[]);
|
||||
const specs: NavSpec[] = [
|
||||
{ kind: "link", path: "/" },
|
||||
{ kind: "link", path: "/tasks" },
|
||||
{ kind: "link", path: "/runs" },
|
||||
{ kind: "link", path: "/workflows" },
|
||||
{ kind: "link", path: "/events" },
|
||||
{ kind: "link", path: "/controls" },
|
||||
{ kind: "link", path: "/org" },
|
||||
{ kind: "link", path: "/settings" },
|
||||
];
|
||||
@@ -61,6 +63,7 @@ const settings: NavSpec = {
|
||||
label: "Models & prompts",
|
||||
paths: [
|
||||
"/settings/models",
|
||||
"/settings/model-aliases",
|
||||
"/settings/skills",
|
||||
"/settings/curators",
|
||||
],
|
||||
@@ -71,8 +74,10 @@ const settings: NavSpec = {
|
||||
"/settings/channels",
|
||||
"/settings/tools",
|
||||
"/settings/extensions",
|
||||
"/settings/extension-catalogue",
|
||||
"/settings/plugins",
|
||||
"/settings/secret-engines",
|
||||
"/settings/credentials",
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { onScopeDispose, ref, shallowRef, type Ref, type ShallowRef } from "vue";
|
||||
|
||||
import { errors } from "@/copy/errors";
|
||||
import { describeError } from "./api";
|
||||
|
||||
export interface Read<T> {
|
||||
/** Undefined until the first read succeeds. */
|
||||
data: ShallowRef<T | undefined>;
|
||||
error: Ref<string>;
|
||||
loading: Ref<boolean>;
|
||||
reload: () => Promise<void>;
|
||||
}
|
||||
|
||||
/** useRead keeps one server read's loading, failed and loaded states apart,
|
||||
* and drops a response that settles after a newer read started. */
|
||||
export function useRead<T>(read: () => Promise<T>): Read<T> {
|
||||
const data = shallowRef<T>();
|
||||
const error = ref("");
|
||||
const loading = ref(false);
|
||||
let generation = 0;
|
||||
async function reload(): Promise<void> {
|
||||
const current = ++generation;
|
||||
loading.value = true;
|
||||
try {
|
||||
const value = await read();
|
||||
if (current !== generation) return;
|
||||
data.value = value;
|
||||
error.value = "";
|
||||
} catch (cause) {
|
||||
if (current !== generation) return;
|
||||
error.value = describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
if (current === generation) loading.value = false;
|
||||
}
|
||||
}
|
||||
return { data, error, loading, reload };
|
||||
}
|
||||
|
||||
/** usePoll re-reads every intervalMs while the tab is visible, for views
|
||||
* whose data the live stream does not carry. */
|
||||
export function usePoll(reload: () => unknown, intervalMs = 5000): void {
|
||||
const timer = setInterval(() => {
|
||||
if (!document.hidden) void reload();
|
||||
}, intervalMs);
|
||||
onScopeDispose(() => clearInterval(timer));
|
||||
}
|
||||
+74
-22
@@ -24,7 +24,6 @@ const SecretEnginesPage = () => import("@/settings/SecretEnginesPage.vue");
|
||||
const ContainerRuntimePage = () => import("@/settings/ContainerRuntimePage.vue");
|
||||
const ConnectionsPage = () => import("@/settings/ConnectionsPage.vue");
|
||||
const SystemAppearancePage = () => import("@/settings/SystemAppearancePage.vue");
|
||||
const SystemModelsPage = () => import("@/settings/SystemModelsPage.vue");
|
||||
const SystemReposPage = () => import("@/settings/SystemReposPage.vue");
|
||||
const SystemStatusPage = () => import("@/settings/SystemStatusPage.vue");
|
||||
const SystemTasksPage = () => import("@/settings/SystemTasksPage.vue");
|
||||
@@ -53,6 +52,7 @@ const routes = [
|
||||
label: "Dashboard",
|
||||
description:
|
||||
"Running work, work needing attention, token spend.",
|
||||
section: "home",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -62,18 +62,37 @@ const routes = [
|
||||
meta: {
|
||||
label: "Tasks",
|
||||
description: "Picked-up issues and their status.",
|
||||
section: "tasks",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/tasks/:id",
|
||||
name: "task-detail",
|
||||
component: TaskDetailPage,
|
||||
meta: { label: "Task run", nav: false, navPath: "/tasks" },
|
||||
meta: { label: "Task run", nav: false, navPath: "/tasks", section: "tasks" },
|
||||
},
|
||||
{
|
||||
path: "/runs",
|
||||
name: "runs",
|
||||
component: () => import("@/runs/RunsPage.vue"),
|
||||
meta: { label: "Runs", description: "Workflow runs, their decision trails and waiting approvals.", section: "runs" },
|
||||
},
|
||||
{
|
||||
path: "/runs/:id",
|
||||
name: "run",
|
||||
component: () => import("@/runs/RunPage.vue"),
|
||||
meta: { label: "Run", nav: false, navPath: "/runs", section: "runs" },
|
||||
},
|
||||
{
|
||||
path: "/controls",
|
||||
name: "controls",
|
||||
component: () => import("@/controls/ControlsPage.vue"),
|
||||
meta: { label: "Controls", description: "Hard rules, change-request rules, guards and action classes.", section: "controls" },
|
||||
},
|
||||
{
|
||||
path: "/workflows",
|
||||
name: "workflows",
|
||||
component: WorkflowsPage,
|
||||
component: () => import("@/workflows/WorkflowListPage.vue"),
|
||||
// Links written as /workflows?workflow=<id> open that workflow's page.
|
||||
beforeEnter: (to: RouteLocationGeneric) => {
|
||||
const { workflow, ...query } = to.query;
|
||||
@@ -89,8 +108,22 @@ const routes = [
|
||||
{
|
||||
path: "/workflows/:id",
|
||||
name: "workflow",
|
||||
component: () => import("@/workflows/WorkflowDocumentPage.vue"),
|
||||
meta: { label: "Workflow", nav: false, navPath: "/workflows", section: "workflows" },
|
||||
},
|
||||
// The visual editor, with drafts, test runs and per-step statistics; it
|
||||
// needs workflow drafts and run stages the binary does not serve yet.
|
||||
{
|
||||
path: "/workflow-editor",
|
||||
name: "workflow-editor-list",
|
||||
component: WorkflowsPage,
|
||||
meta: { label: "Workflow editor", nav: false, navPath: "/workflows", section: "workflow_editor" },
|
||||
},
|
||||
{
|
||||
path: "/workflow-editor/:id",
|
||||
name: "workflow-editor",
|
||||
component: WorkflowPage,
|
||||
meta: { label: "Workflow", nav: false, navPath: "/workflows" },
|
||||
meta: { label: "Workflow", nav: false, navPath: "/workflows", section: "workflow_editor" },
|
||||
},
|
||||
{
|
||||
path: "/settings/skills",
|
||||
@@ -122,8 +155,8 @@ const routes = [
|
||||
component: EventsPage,
|
||||
meta: {
|
||||
label: "Events",
|
||||
description:
|
||||
"Captured events, field mappings, workflow bindings.",
|
||||
description: "Received events, their sources, and the triggers that start workflows.",
|
||||
section: "events",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -136,7 +169,7 @@ const routes = [
|
||||
label: "Status",
|
||||
description:
|
||||
"Service presence, dependency health, and build versions.",
|
||||
section: "settings",
|
||||
section: "system_status",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -164,26 +197,26 @@ const routes = [
|
||||
settings: true,
|
||||
label: "Task execution",
|
||||
description: "Statuses, operator actions, budgets.",
|
||||
section: "settings",
|
||||
section: "task_execution",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/models",
|
||||
name: "system-models",
|
||||
component: SystemModelsPage,
|
||||
component: () => import("@/settings/AgentModelsPage.vue"),
|
||||
meta: {
|
||||
navPath: "/settings",
|
||||
settings: true,
|
||||
label: "Models",
|
||||
description: "Model aliases and providers.",
|
||||
section: "settings",
|
||||
description: "The models agent loops use, by alias.",
|
||||
section: "models",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/organisations",
|
||||
name: "settings-organisations",
|
||||
component: () => import("@/settings/OrganisationsPage.vue"),
|
||||
meta: { navPath: "/settings", settings: true, label: "Organisations", section: "settings" },
|
||||
meta: { navPath: "/settings", settings: true, label: "Organisations", section: "organisations" },
|
||||
},
|
||||
{
|
||||
path: "/settings/authentication",
|
||||
@@ -205,6 +238,7 @@ const routes = [
|
||||
label: "Organisation",
|
||||
description: "Members, identities, connections, models and automation.",
|
||||
navPath: "/org",
|
||||
section: "org",
|
||||
org: true,
|
||||
},
|
||||
children: [
|
||||
@@ -252,7 +286,7 @@ const routes = [
|
||||
path: "workspaces",
|
||||
name: "org-workspaces",
|
||||
component: OrgWorkspacesPage,
|
||||
meta: { label: "Workspaces", navPath: "/org" },
|
||||
meta: { section: "org_workspaces", label: "Workspaces", navPath: "/org" },
|
||||
},
|
||||
{
|
||||
path: "policies",
|
||||
@@ -371,7 +405,7 @@ const routes = [
|
||||
settings: true,
|
||||
label: "Tools & MCP",
|
||||
description: "Agent tools and MCP servers.",
|
||||
section: "settings",
|
||||
section: "tools",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -383,15 +417,27 @@ const routes = [
|
||||
{
|
||||
path: "/settings/extensions",
|
||||
name: "settings-extensions",
|
||||
component: ExtensionsPage,
|
||||
component: () => import("@/settings/AcceptedExtensionsPage.vue"),
|
||||
meta: {
|
||||
navPath: "/settings",
|
||||
settings: true,
|
||||
label: "Extensions",
|
||||
description: "Installed extensions and grants.",
|
||||
section: "settings",
|
||||
description: "Connectors, guards and MCP servers.",
|
||||
section: "extensions",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/extension-catalogue",
|
||||
name: "settings-extension-catalogue",
|
||||
component: ExtensionsPage,
|
||||
meta: { navPath: "/settings", settings: true, label: "Extension catalogue", description: "Installed extensions, grants and the marketplace.", section: "extension_catalogue" },
|
||||
},
|
||||
{
|
||||
path: "/settings/model-aliases",
|
||||
name: "settings-model-aliases",
|
||||
component: () => import("@/settings/SystemModelsPage.vue"),
|
||||
meta: { navPath: "/settings", settings: true, label: "Model aliases", description: "Model aliases and providers.", section: "model_aliases" },
|
||||
},
|
||||
{
|
||||
path: "/settings/plugins",
|
||||
name: "settings-plugins",
|
||||
@@ -401,14 +447,20 @@ const routes = [
|
||||
settings: true,
|
||||
label: "Plugins",
|
||||
description: "Extension directories loaded at startup.",
|
||||
section: "settings",
|
||||
section: "plugins",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/secret-engines",
|
||||
name: "settings-secret-engines",
|
||||
component: SecretEnginesPage,
|
||||
meta: { navPath: "/settings", settings: true, label: "Secret engines", section: "settings" },
|
||||
meta: { navPath: "/settings", settings: true, label: "Secret engines", section: "secret_engines" },
|
||||
},
|
||||
{
|
||||
path: "/settings/credentials",
|
||||
name: "settings-credentials",
|
||||
component: () => import("@/settings/CredentialsPage.vue"),
|
||||
meta: { navPath: "/settings", settings: true, label: "Credentials", description: "Sealed credentials extensions and models use.", section: "credentials" },
|
||||
},
|
||||
{
|
||||
path: "/settings/container-runtime",
|
||||
@@ -418,20 +470,20 @@ const routes = [
|
||||
navPath: "/settings",
|
||||
settings: true,
|
||||
label: "Container runtime",
|
||||
section: "settings",
|
||||
section: "container_runtime",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/settings/agent-profiles",
|
||||
name: "settings-agent-profiles",
|
||||
component: () => import("@/settings/AgentProfilesPage.vue"),
|
||||
meta: { navPath: "/settings", settings: true, label: "Agent profiles", section: "settings" },
|
||||
meta: { navPath: "/settings", settings: true, label: "Agent profiles", section: "agent_profiles" },
|
||||
},
|
||||
{ path: "/settings/history", redirect: (to: RouteLocationGeneric) => ({ path: "/org/audit", query: to.query, hash: to.hash }), meta: { nav: false } },
|
||||
{ path: "/settings/audit", redirect: (to: RouteLocationGeneric) => ({ path: "/org/audit", query: to.query, hash: to.hash }), meta: { nav: false } },
|
||||
{
|
||||
path: "/settings",
|
||||
redirect: "/settings/status",
|
||||
redirect: "/settings/models",
|
||||
meta: {
|
||||
label: "Instance",
|
||||
},
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError } from "@/lib/api";
|
||||
import { usePoll, useRead } from "@/lib/use-read";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
|
||||
/** Waiting approvals are a filter on runs: each asks a person to allow one
|
||||
* action a run wants to take. With `run`, only that run's. */
|
||||
const props = defineProps<{ run?: string }>();
|
||||
const emit = defineEmits<{ answered: [] }>();
|
||||
|
||||
const { data, error, reload } = useRead(() => api.approvals());
|
||||
onMounted(reload);
|
||||
useLiveResource(null, () => void reload());
|
||||
usePoll(reload);
|
||||
|
||||
const waiting = computed(() =>
|
||||
(data.value ?? []).filter((a) => a.state === "pending" && (!props.run || a.run_id === props.run)),
|
||||
);
|
||||
const busy = ref("");
|
||||
const answerError = ref("");
|
||||
async function answer(id: string, approved: boolean): Promise<void> {
|
||||
busy.value = id;
|
||||
answerError.value = "";
|
||||
try {
|
||||
await api.answerApproval(id, approved);
|
||||
emit("answered");
|
||||
} catch (cause) {
|
||||
answerError.value = describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
busy.value = "";
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" class="mb-4" @retry="reload" />
|
||||
<Section v-else-if="waiting.length" title="Waiting for approval">
|
||||
<p v-if="answerError" role="alert" class="mb-2 text-caption text-danger">{{ answerError }}</p>
|
||||
<ul class="divide-y divide-border">
|
||||
<li v-for="approval in waiting" :key="approval.id" class="flex flex-wrap items-center gap-x-3 gap-y-1 py-2">
|
||||
<div class="min-w-0 flex-1">
|
||||
<p class="text-label">{{ approval.summary || approval.action }}</p>
|
||||
<p class="text-caption text-fg-muted">
|
||||
<span class="font-mono">{{ approval.action }}</span>
|
||||
<template v-if="approval.target"> on <span class="font-mono">{{ approval.target }}</span></template>
|
||||
<template v-if="!run"> · <RouterLink class="underline" :to="`/runs/${approval.run_id}`">run</RouterLink></template>
|
||||
<template v-if="approval.deadline"> · due <Timestamp :at="approval.deadline" /></template>
|
||||
</p>
|
||||
</div>
|
||||
<Badge variant="outline">{{ approval.level }}</Badge>
|
||||
<Button size="sm" variant="outline" :disabled="busy === approval.id" @click="answer(approval.id, false)">Deny</Button>
|
||||
<Button size="sm" :disabled="busy === approval.id" @click="answer(approval.id, true)">Approve</Button>
|
||||
</li>
|
||||
</ul>
|
||||
</Section>
|
||||
</template>
|
||||
@@ -0,0 +1,127 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted } from "vue";
|
||||
import { RouterLink, useRoute } from "vue-router";
|
||||
|
||||
import CodeView from "@/base/CodeView.vue";
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { MetadataList } from "@/components/ui/metadata-list";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Section } from "@/components/ui/section";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { api, type RunAction } from "@/lib/api";
|
||||
import { usePoll, useRead } from "@/lib/use-read";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
import ApprovalsSection from "./ApprovalsSection.vue";
|
||||
import { stateTone } from "./state";
|
||||
|
||||
/** A run's decision trail: where it came from, each action it asked to take
|
||||
* and how that was judged, and the steps it recorded. */
|
||||
const route = useRoute();
|
||||
const id = String(route.params.id);
|
||||
const { data, error, reload } = useRead(() => api.run(id));
|
||||
onMounted(reload);
|
||||
useLiveResource(null, () => void reload());
|
||||
const finished = computed(() => !!data.value?.run.finished_at);
|
||||
usePoll(() => {
|
||||
if (!finished.value) void reload();
|
||||
});
|
||||
|
||||
const details = computed(() => {
|
||||
const run = data.value?.run;
|
||||
if (!run) return [];
|
||||
return [
|
||||
{ label: "Workflow", value: `${run.workflow} v${run.workflow_version}` },
|
||||
{ label: "Attempts", value: String(run.attempts) },
|
||||
{ label: "Run", value: run.id, mono: true },
|
||||
...(run.error ? [{ label: "Error", value: run.error }] : []),
|
||||
];
|
||||
});
|
||||
const origin = computed(() => {
|
||||
const o = data.value?.origin;
|
||||
if (!o) return [];
|
||||
return [
|
||||
...(o.source ? [{ label: "Source", value: o.source }] : []),
|
||||
...(o.type ? [{ label: "Event type", value: o.type }] : []),
|
||||
...(o.trigger ? [{ label: "Trigger", value: o.trigger }] : []),
|
||||
...(o.event_id ? [{ label: "Event", value: o.event_id, mono: true }] : []),
|
||||
];
|
||||
});
|
||||
|
||||
function target(action: RunAction): string {
|
||||
const t = action.decision.action.target;
|
||||
return t?.ID ? `${t.Kind ? `${t.Kind} ` : ""}${t.ID}` : "";
|
||||
}
|
||||
const result = computed(() =>
|
||||
data.value?.run.result == null ? "" : JSON.stringify(data.value.run.result, null, 2),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader :title="data ? data.run.workflow : 'Run'">
|
||||
<Badge v-if="data" :variant="stateTone(data.run.state)">{{ data.run.state }}</Badge>
|
||||
<span v-if="data" class="text-caption text-fg-muted">Started <Timestamp :at="data.run.created_at" /></span>
|
||||
</PageHeader>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||
<div v-else-if="!data" role="status" aria-label="Loading run" class="space-y-2"><Skeleton class="h-24 w-full" /><Skeleton class="h-48 w-full" /></div>
|
||||
<template v-else>
|
||||
<ApprovalsSection :run="id" @answered="reload" />
|
||||
<div class="grid gap-x-4 lg:grid-cols-2">
|
||||
<Section title="Run"><MetadataList :rows="details" /></Section>
|
||||
<Section v-if="origin.length" title="Started by">
|
||||
<MetadataList :rows="origin">
|
||||
<template #value="{ row }">
|
||||
<RouterLink v-if="row.label === 'Event'" class="underline" :to="{ path: '/events', query: { event: row.value } }">{{ row.value }}</RouterLink>
|
||||
<template v-else>{{ row.value }}</template>
|
||||
</template>
|
||||
</MetadataList>
|
||||
</Section>
|
||||
</div>
|
||||
<Section title="Actions">
|
||||
<Empty v-if="!data.actions?.length"><EmptyHeader><EmptyTitle>No actions</EmptyTitle></EmptyHeader></Empty>
|
||||
<ul v-else class="divide-y divide-border">
|
||||
<li v-for="action in data.actions" :key="action.decision.id" class="space-y-1 py-3">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="font-mono text-label">{{ action.decision.action.connector }}.{{ action.decision.action.name }}</span>
|
||||
<span v-if="target(action)" class="text-caption text-fg-muted">{{ target(action) }}</span>
|
||||
<Badge variant="outline">{{ action.decision.level }}</Badge>
|
||||
<Badge v-if="action.decision.dry" variant="secondary">Dry run</Badge>
|
||||
<Badge v-if="action.decision.refused_by" variant="danger">Refused by {{ action.decision.refused_by }}</Badge>
|
||||
<Badge v-if="action.approval" :variant="stateTone(action.approval.state)">Approval {{ action.approval.state }}</Badge>
|
||||
<Badge v-if="action.effect" :variant="stateTone(action.effect.state)">{{ action.effect.state }}</Badge>
|
||||
<Timestamp class="ml-auto text-caption text-fg-subtle" :at="action.decision.at" />
|
||||
</div>
|
||||
<p v-if="action.decision.reason" class="text-caption text-fg-muted">{{ action.decision.reason }}</p>
|
||||
<p v-if="action.approval?.answered_by" class="text-caption text-fg-muted">
|
||||
Answered by {{ action.approval.answered_by }}<template v-if="action.approval.answered_via"> via {{ action.approval.answered_via }}</template>
|
||||
</p>
|
||||
<p v-if="action.rejudged" class="text-caption text-fg-muted">Judged again before it ran: {{ action.rejudged.level }}<template v-if="action.rejudged.refused_by">, refused by {{ action.rejudged.refused_by }}</template></p>
|
||||
<p v-if="action.effect?.error" class="text-caption text-danger">{{ action.effect.error }}</p>
|
||||
<CodeView v-if="action.effect?.output" :code="action.effect.output" />
|
||||
</li>
|
||||
</ul>
|
||||
</Section>
|
||||
<Section title="Steps">
|
||||
<Empty v-if="!data.entries?.length"><EmptyHeader><EmptyTitle>No steps recorded</EmptyTitle></EmptyHeader></Empty>
|
||||
<ol v-else class="divide-y divide-border">
|
||||
<li v-for="entry in data.entries" :key="entry.seq" class="space-y-1 py-2">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<Badge variant="secondary">{{ entry.kind }}</Badge>
|
||||
<span v-if="entry.name" class="font-mono text-label">{{ entry.name }}</span>
|
||||
<Badge v-if="entry.unknown" variant="warn">Outcome unknown</Badge>
|
||||
<Timestamp class="ml-auto text-caption text-fg-subtle" :at="entry.at" />
|
||||
</div>
|
||||
<p v-if="entry.text" class="text-label whitespace-pre-wrap">{{ entry.text }}</p>
|
||||
<p v-for="call in entry.tool_calls ?? []" :key="call.name + call.input" class="font-mono text-caption text-fg-muted [overflow-wrap:anywhere]">{{ call.name }} {{ call.input }}</p>
|
||||
<p v-if="entry.error" class="text-caption text-danger">{{ entry.error }}</p>
|
||||
<CodeView v-if="entry.output" :code="entry.output" />
|
||||
</li>
|
||||
</ol>
|
||||
</Section>
|
||||
<Section v-if="result" title="Result"><CodeView :code="result" /></Section>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,75 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { X } from "@lucide/vue";
|
||||
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import type { Run } from "@/lib/api";
|
||||
import { api } from "@/lib/api";
|
||||
import { usePoll, useRead } from "@/lib/use-read";
|
||||
import { useLiveResource } from "@/stores/session";
|
||||
import ApprovalsSection from "./ApprovalsSection.vue";
|
||||
import { stateTone } from "./state";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { data, error, reload } = useRead(() => api.runs());
|
||||
onMounted(reload);
|
||||
useLiveResource(null, () => void reload());
|
||||
usePoll(reload);
|
||||
|
||||
// ?workflow= narrows the list to one workflow's runs, so a workflow links here.
|
||||
const workflow = computed(() => String(route.query.workflow ?? ""));
|
||||
const rows = computed(() => (data.value ?? []).filter((r) => !workflow.value || r.workflow === workflow.value));
|
||||
|
||||
const time = (at?: string) => (at ? Date.parse(at) : 0);
|
||||
const columns: DataTableColumn<Run>[] = [
|
||||
{ id: "workflow", label: "Workflow", fixed: true, sort: (r) => r.workflow },
|
||||
{ id: "state", label: "State", fixed: true, sort: (r) => r.state },
|
||||
{ id: "created", label: "Started", sort: (r) => time(r.created_at) },
|
||||
{ id: "finished", label: "Finished", sort: (r) => time(r.finished_at) },
|
||||
{ id: "attempts", label: "Attempts", hidden: true, sort: (r) => r.attempts },
|
||||
{ id: "id", label: "Run", hidden: true },
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Runs">
|
||||
<Button v-if="workflow" variant="outline" size="sm" title="Show every workflow's runs" @click="router.replace({ query: {} })">{{ workflow }}<X data-icon="inline-end" /></Button>
|
||||
</PageHeader>
|
||||
<ApprovalsSection @answered="reload" />
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||
<div v-else-if="!data" role="status" aria-label="Loading runs" class="space-y-2"><Skeleton class="h-8 w-full" /><Skeleton class="h-8 w-full" /></div>
|
||||
<DataTable
|
||||
v-else
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
:row-key="(r) => r.id"
|
||||
:row-link="(r) => `/runs/${r.id}`"
|
||||
:row-label="(r) => `${r.workflow} run`"
|
||||
storage-key="runs"
|
||||
:initial-sort="{ id: 'created', desc: true }"
|
||||
>
|
||||
<template #cell-workflow="{ row }"><span class="font-medium">{{ row.workflow }}</span> <span class="text-caption text-fg-subtle">v{{ row.workflow_version }}</span></template>
|
||||
<template #cell-state="{ row }">
|
||||
<Badge :variant="stateTone(row.state)" :title="row.error || undefined">{{ row.state }}</Badge>
|
||||
</template>
|
||||
<template #cell-created="{ row }"><Timestamp :at="row.created_at" /></template>
|
||||
<template #cell-finished="{ row }"><Timestamp :at="row.finished_at" /></template>
|
||||
<template #cell-attempts="{ row }">{{ row.attempts }}</template>
|
||||
<template #cell-id="{ row }"><span class="font-mono text-caption">{{ row.id }}</span></template>
|
||||
<template #empty>
|
||||
<Empty><EmptyHeader><EmptyTitle>No runs yet</EmptyTitle></EmptyHeader></Empty>
|
||||
</template>
|
||||
</DataTable>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,24 @@
|
||||
/** The Badge and StatusDot tone for a run, approval or effect state the server
|
||||
* reports. A state this build does not know reads as idle. */
|
||||
export function stateTone(state: string): "ok" | "warn" | "danger" | "info" | "idle" {
|
||||
switch (state) {
|
||||
case "succeeded":
|
||||
case "approved":
|
||||
case "done":
|
||||
return "ok";
|
||||
case "waiting":
|
||||
case "pending":
|
||||
case "unknown":
|
||||
return "warn";
|
||||
case "failed":
|
||||
case "denied":
|
||||
case "expired":
|
||||
case "refused":
|
||||
return "danger";
|
||||
case "running":
|
||||
case "queued":
|
||||
return "info";
|
||||
default:
|
||||
return "idle";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import type { ExtensionKind } from "@/lib/api";
|
||||
import ExtensionList from "./ExtensionList.vue";
|
||||
|
||||
/** Connectors, guards and MCP servers: the packages Archie acts and judges
|
||||
* through. The open tab is `?kind=`. */
|
||||
const KINDS: { kind: ExtensionKind; label: string; noun: string }[] = [
|
||||
{ kind: "connectors", label: "Connectors", noun: "connector" },
|
||||
{ kind: "guards", label: "Guards", noun: "guard" },
|
||||
{ kind: "mcp-servers", label: "MCP servers", noun: "MCP server" },
|
||||
{ kind: "secret-engines", label: "Secret engines", noun: "secret engine" },
|
||||
];
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const active = computed(() => KINDS.find((k) => k.kind === route.query.kind) ?? KINDS[0]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Extensions" />
|
||||
<Tabs :model-value="active.kind" class="mb-4" @update:model-value="(k) => router.replace({ query: { kind: String(k) } })">
|
||||
<TabsList variant="line" class="w-full justify-start">
|
||||
<TabsTrigger v-for="k in KINDS" :key="k.kind" :value="k.kind" class="flex-none px-3">{{ k.label }}</TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
<ExtensionList :key="active.kind" :kind="active.kind" :noun="active.noun" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,142 @@
|
||||
<script setup lang="ts">
|
||||
import { Plus } from "@lucide/vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { MoreMenu } from "@/components/ui/more-menu";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { SettingRow } from "@/components/ui/setting-row";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError, type AgentModel } from "@/lib/api";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
|
||||
/** The models agent loops use, by alias. "default" is the one a workflow gets
|
||||
* when it names none. */
|
||||
const { data, error, reload } = useRead(() => api.agentModels());
|
||||
const credentials = useRead(() => api.credentials());
|
||||
onMounted(() => {
|
||||
void reload();
|
||||
void credentials.reload();
|
||||
});
|
||||
|
||||
interface Row extends AgentModel { alias: string }
|
||||
const rows = computed<Row[]>(() => Object.entries(data.value ?? {}).map(([alias, m]) => ({ alias, ...m })));
|
||||
const columns: DataTableColumn<Row>[] = [
|
||||
{ id: "alias", label: "Alias", fixed: true, sort: (r) => r.alias },
|
||||
{ id: "model", label: "Model", fixed: true, sort: (r) => r.model },
|
||||
{ id: "class", label: "Provider", sort: (r) => r.class },
|
||||
{ id: "base", label: "Base URL", hidden: true },
|
||||
{ id: "key", label: "API key" },
|
||||
];
|
||||
|
||||
const NONE = "__none__";
|
||||
const editing = ref(false);
|
||||
const isNew = ref(true);
|
||||
const form = ref({ alias: "", class: "", model: "", base_url: "", api_key_credential: NONE });
|
||||
function open(row?: Row): void {
|
||||
isNew.value = !row;
|
||||
actionError.value = "";
|
||||
tested.value = "";
|
||||
form.value = {
|
||||
alias: row?.alias ?? "",
|
||||
class: row?.class ?? "",
|
||||
model: row?.model ?? "",
|
||||
base_url: row?.base_url ?? "",
|
||||
api_key_credential: row?.api_key_credential || NONE,
|
||||
};
|
||||
editing.value = true;
|
||||
}
|
||||
const model = (): AgentModel => ({
|
||||
class: form.value.class.trim(),
|
||||
model: form.value.model.trim(),
|
||||
base_url: form.value.base_url.trim() || undefined,
|
||||
api_key_credential: form.value.api_key_credential === NONE ? undefined : form.value.api_key_credential,
|
||||
});
|
||||
|
||||
const busy = ref(false);
|
||||
const actionError = ref("");
|
||||
const tested = ref("");
|
||||
async function test(): Promise<void> {
|
||||
busy.value = true;
|
||||
actionError.value = "";
|
||||
tested.value = "";
|
||||
try {
|
||||
const answer = await api.testAgentModel(model());
|
||||
tested.value = `${answer.model} answered “${answer.answer.trim()}”`;
|
||||
} catch (cause) {
|
||||
actionError.value = describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
async function save(): Promise<void> {
|
||||
busy.value = true;
|
||||
actionError.value = "";
|
||||
try {
|
||||
const alias = form.value.alias.trim();
|
||||
await api.putAgentModel(alias === "default" ? "" : alias, model());
|
||||
editing.value = false;
|
||||
await reload();
|
||||
} catch (cause) {
|
||||
actionError.value = describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Models">
|
||||
<Button size="sm" aria-label="Add model" title="Add model" @click="open()"><Plus /></Button>
|
||||
</PageHeader>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||
<div v-else-if="!data" role="status" aria-label="Loading models" class="space-y-2"><Skeleton class="h-8 w-full" /></div>
|
||||
<DataTable v-else :columns="columns" :rows="rows" :row-key="(r) => r.alias" storage-key="agent-models">
|
||||
<template #cell-alias="{ row }"><span class="font-medium">{{ row.alias }}</span></template>
|
||||
<template #cell-model="{ row }"><span class="font-mono text-caption">{{ row.model }}</span></template>
|
||||
<template #cell-class="{ row }">{{ row.class }}</template>
|
||||
<template #cell-base="{ row }"><span class="font-mono text-caption">{{ row.base_url }}</span></template>
|
||||
<template #cell-key="{ row }">{{ row.api_key_credential }}</template>
|
||||
<template #actions="{ row }">
|
||||
<MoreMenu :label="`${row.alias} actions`"><DropdownMenuItem @select="open(row)">Edit</DropdownMenuItem></MoreMenu>
|
||||
</template>
|
||||
<template #empty><Empty><EmptyHeader><EmptyTitle>No models</EmptyTitle></EmptyHeader></Empty></template>
|
||||
</DataTable>
|
||||
|
||||
<Dialog v-model:open="editing">
|
||||
<DialogContent class="sm:max-w-2xl">
|
||||
<DialogHeader><DialogTitle>{{ isNew ? "Add model" : `Edit ${form.alias}` }}</DialogTitle></DialogHeader>
|
||||
<form id="model-form" @submit.prevent="save">
|
||||
<SettingRow v-if="isNew" label="Alias" for="model-alias" hint="Workflows name it; default is used when they name none."><Input id="model-alias" v-model="form.alias" required /></SettingRow>
|
||||
<SettingRow label="Provider" for="model-class"><Input id="model-class" v-model="form.class" placeholder="openai" required /></SettingRow>
|
||||
<SettingRow label="Model" for="model-name"><Input id="model-name" v-model="form.model" required /></SettingRow>
|
||||
<SettingRow label="Base URL" for="model-base" hint="Empty uses the provider's own."><Input id="model-base" v-model="form.base_url" type="url" /></SettingRow>
|
||||
<SettingRow label="API key" for="model-key" hint="A bearer credential.">
|
||||
<Select v-model="form.api_key_credential">
|
||||
<SelectTrigger id="model-key" class="w-full"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem :value="NONE">None</SelectItem>
|
||||
<SelectItem v-for="c in (credentials.data.value ?? []).filter((c) => c.kind === 'bearer')" :key="c.name" :value="c.name">{{ c.name }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</SettingRow>
|
||||
<p v-if="tested" role="status" class="pt-2 text-caption text-ok">{{ tested }}</p>
|
||||
<p v-if="actionError" role="alert" class="pt-2 text-caption text-danger">{{ actionError }}</p>
|
||||
</form>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" :disabled="busy || !form.class || !form.model" @click="test">Test</Button>
|
||||
<Button type="submit" form="model-form" :disabled="busy">Save</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,148 @@
|
||||
<script setup lang="ts">
|
||||
import { Plus } from "@lucide/vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { MoreMenu } from "@/components/ui/more-menu";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { SettingRow } from "@/components/ui/setting-row";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError, type Credential, type CredentialField } from "@/lib/api";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
|
||||
/** Credentials are sealed and never read back: the list says only where each
|
||||
* field comes from, and a save replaces every field. */
|
||||
const { data, error, reload } = useRead(() => api.credentials());
|
||||
const kinds = useRead(() => api.credentialKinds());
|
||||
const engines = useRead(() => api.extensions("secret-engines"));
|
||||
onMounted(() => {
|
||||
void reload();
|
||||
void kinds.reload();
|
||||
void engines.reload();
|
||||
});
|
||||
|
||||
const columns: DataTableColumn<Credential>[] = [
|
||||
{ id: "name", label: "Credential", fixed: true, sort: (c) => c.name },
|
||||
{ id: "kind", label: "Kind", sort: (c) => c.kind },
|
||||
{ id: "fields", label: "Fields" },
|
||||
];
|
||||
|
||||
interface FieldForm { from: "value" | "engine"; value: string; engine: string; key: string }
|
||||
const editing = ref(false);
|
||||
const isNew = ref(true);
|
||||
const name = ref("");
|
||||
const kind = ref("");
|
||||
const fields = ref<Record<string, FieldForm>>({});
|
||||
const kindSpec = computed(() => kinds.data.value?.find((k) => k.kind === kind.value));
|
||||
const fieldNames = computed(() => [...(kindSpec.value?.required ?? []), ...(kindSpec.value?.optional ?? [])]);
|
||||
function pickKind(next: unknown): void {
|
||||
kind.value = String(next);
|
||||
fields.value = Object.fromEntries(fieldNames.value.map((f) => [f, fields.value[f] ?? { from: "value", value: "", engine: "", key: "" }]));
|
||||
}
|
||||
function open(cred?: Credential): void {
|
||||
isNew.value = !cred;
|
||||
actionError.value = "";
|
||||
name.value = cred?.name ?? "";
|
||||
fields.value = {};
|
||||
for (const [field, from] of Object.entries(cred?.fields ?? {})) {
|
||||
const at = from.indexOf(":");
|
||||
fields.value[field] = from === "stored" || at < 0
|
||||
? { from: "value", value: "", engine: "", key: "" }
|
||||
: { from: "engine", value: "", engine: from.slice(0, at), key: from.slice(at + 1) };
|
||||
}
|
||||
pickKind(cred?.kind ?? kinds.data.value?.[0]?.kind ?? "");
|
||||
editing.value = true;
|
||||
}
|
||||
const optional = (field: string) => kindSpec.value?.optional?.includes(field) ?? false;
|
||||
const multiline = (field: string) => field.includes("key") || field === "identity";
|
||||
|
||||
const busy = ref(false);
|
||||
const actionError = ref("");
|
||||
const restarted = ref<string[]>([]);
|
||||
async function submit(): Promise<void> {
|
||||
busy.value = true;
|
||||
actionError.value = "";
|
||||
const body: Record<string, CredentialField> = {};
|
||||
for (const field of fieldNames.value) {
|
||||
const f = fields.value[field];
|
||||
if (f.from === "engine" && f.engine && f.key) body[field] = { engine: f.engine, key: f.key.trim() };
|
||||
else if (f.from === "value" && f.value) body[field] = { value: f.value };
|
||||
}
|
||||
try {
|
||||
restarted.value = (await api.putCredential(name.value.trim(), kind.value, body)).restarted ?? [];
|
||||
editing.value = false;
|
||||
} catch (cause) {
|
||||
actionError.value = describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Credentials">
|
||||
<Button size="sm" aria-label="Add credential" title="Add credential" :disabled="!kinds.data.value" @click="open()"><Plus /></Button>
|
||||
</PageHeader>
|
||||
<p v-if="restarted.length" role="status" class="mb-2 text-caption text-fg-muted">Restarted {{ restarted.join(", ") }}.</p>
|
||||
<ReadError v-if="error || kinds.error.value" :message="error || kinds.error.value" retry-label="Retry" @retry="reload(); kinds.reload()" />
|
||||
<div v-else-if="!data" role="status" aria-label="Loading credentials" class="space-y-2"><Skeleton class="h-8 w-full" /></div>
|
||||
<DataTable v-else :columns="columns" :rows="data" :row-key="(c) => c.name" storage-key="credentials">
|
||||
<template #cell-name="{ row }"><span class="font-medium">{{ row.name }}</span></template>
|
||||
<template #cell-kind="{ row }"><Badge variant="outline">{{ row.kind }}</Badge></template>
|
||||
<template #cell-fields="{ row }">
|
||||
<span class="font-mono text-caption">{{ Object.entries(row.fields).map(([f, from]) => from === "stored" ? f : `${f} ← ${from}`).join(", ") }}</span>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<MoreMenu :label="`${row.name} actions`"><DropdownMenuItem @select="open(row)">Replace…</DropdownMenuItem></MoreMenu>
|
||||
</template>
|
||||
<template #empty><Empty><EmptyHeader><EmptyTitle>No credentials</EmptyTitle></EmptyHeader></Empty></template>
|
||||
</DataTable>
|
||||
|
||||
<Dialog v-model:open="editing">
|
||||
<DialogContent class="max-h-[90dvh] overflow-y-auto sm:max-w-2xl">
|
||||
<DialogHeader><DialogTitle>{{ isNew ? "Add credential" : `Replace ${name}` }}</DialogTitle></DialogHeader>
|
||||
<form id="credential-form" @submit.prevent="submit">
|
||||
<SettingRow v-if="isNew" label="Name" for="cred-name"><Input id="cred-name" v-model="name" pattern="[a-z0-9][a-z0-9-]*" required /></SettingRow>
|
||||
<SettingRow label="Kind" for="cred-kind">
|
||||
<Select :model-value="kind" @update:model-value="pickKind">
|
||||
<SelectTrigger id="cred-kind" class="w-full"><SelectValue /></SelectTrigger>
|
||||
<SelectContent><SelectItem v-for="k in kinds.data.value ?? []" :key="k.kind" :value="k.kind">{{ k.kind }}</SelectItem></SelectContent>
|
||||
</Select>
|
||||
</SettingRow>
|
||||
<SettingRow v-for="field in fieldNames" :key="field" :label="field" :for="`cred-${field}`" :hint="optional(field) ? 'Optional' : undefined">
|
||||
<div class="space-y-2">
|
||||
<ToggleGroup v-if="engines.data.value?.length" v-model="fields[field].from" type="single" variant="outline" size="sm" :aria-label="`${field} from`">
|
||||
<ToggleGroupItem value="value">Value</ToggleGroupItem>
|
||||
<ToggleGroupItem value="engine">Secret engine</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
<template v-if="fields[field].from === 'engine'">
|
||||
<Select v-model="fields[field].engine">
|
||||
<SelectTrigger class="w-full" :aria-label="`${field} engine`"><SelectValue placeholder="Engine" /></SelectTrigger>
|
||||
<SelectContent><SelectItem v-for="e in engines.data.value ?? []" :key="e.name" :value="e.name">{{ e.name }}</SelectItem></SelectContent>
|
||||
</Select>
|
||||
<Input v-model="fields[field].key" :aria-label="`${field} key`" placeholder="Key" class="font-mono" :required="!optional(field)" />
|
||||
</template>
|
||||
<Textarea v-else-if="multiline(field)" :id="`cred-${field}`" v-model="fields[field].value" class="font-mono" rows="4" :required="!optional(field)" autocomplete="off" />
|
||||
<Input v-else :id="`cred-${field}`" v-model="fields[field].value" :type="field === 'username' ? 'text' : 'password'" autocomplete="off" :required="!optional(field)" />
|
||||
</div>
|
||||
</SettingRow>
|
||||
<p v-if="actionError" role="alert" class="pt-2 text-caption text-danger">{{ actionError }}</p>
|
||||
</form>
|
||||
<DialogFooter><Button type="submit" form="credential-form" :disabled="busy || !kind">Save</Button></DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,183 @@
|
||||
<script setup lang="ts">
|
||||
import { Plus } from "@lucide/vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@/components/ui/alert-dialog";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { MoreMenu } from "@/components/ui/more-menu";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { SettingRow } from "@/components/ui/setting-row";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError, type Extension, type ExtensionInput, type ExtensionKind } from "@/lib/api";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
import { stateTone } from "@/runs/state";
|
||||
import { fromLines, toLines } from "@/lib/lines";
|
||||
|
||||
/** The packages of one kind the binary runs: each is accepted by path and
|
||||
* digest, and runs only while its digest matches. */
|
||||
const props = defineProps<{ kind: ExtensionKind; noun: string }>();
|
||||
|
||||
const { data, error, reload } = useRead(() => api.extensions(props.kind));
|
||||
onMounted(reload);
|
||||
|
||||
const columns: DataTableColumn<Extension>[] = [
|
||||
{ id: "name", label: "Name", fixed: true, sort: (e) => e.name },
|
||||
{ id: "state", label: "State", fixed: true, sort: (e) => e.state },
|
||||
{ id: "version", label: "Version", sort: (e) => e.version ?? "" },
|
||||
{ id: "path", label: "Path", hidden: true },
|
||||
{ id: "egress", label: "Egress", hidden: true },
|
||||
];
|
||||
|
||||
const mcp = computed(() => props.kind === "mcp-servers");
|
||||
const editing = ref(false);
|
||||
const isNew = ref(true);
|
||||
const schema = ref<Extension["settings_schema"]>([]);
|
||||
const form = ref({ name: "", path: "", sha256: "", url: "", args: "", egress: "", env: "", credentials: "", tools: "", settings: {} as Record<string, string>, other: "" });
|
||||
function open(ext?: Extension): void {
|
||||
isNew.value = !ext;
|
||||
actionError.value = "";
|
||||
schema.value = ext?.settings_schema ?? [];
|
||||
const known = new Set(schema.value.map((f) => f.key));
|
||||
const settings = ext?.settings ?? {};
|
||||
form.value = {
|
||||
name: ext?.name ?? "",
|
||||
path: ext?.path ?? "",
|
||||
sha256: ext?.digest ?? "",
|
||||
url: ext?.url ?? "",
|
||||
args: (ext?.args ?? []).join("\n"),
|
||||
egress: (ext?.egress ?? []).join("\n"),
|
||||
env: (ext?.env ?? []).join("\n"),
|
||||
credentials: toLines(ext?.credentials ?? {}),
|
||||
tools: ext?.tools ? JSON.stringify(ext.tools, null, 2) : "[]",
|
||||
settings: Object.fromEntries(Object.entries(settings).filter(([k]) => known.has(k))),
|
||||
other: toLines(Object.fromEntries(Object.entries(settings).filter(([k]) => !known.has(k)))),
|
||||
};
|
||||
editing.value = true;
|
||||
}
|
||||
const list = (text: string) => text.split("\n").map((l) => l.trim()).filter(Boolean);
|
||||
|
||||
const busy = ref(false);
|
||||
const actionError = ref("");
|
||||
async function submit(): Promise<void> {
|
||||
const f = form.value;
|
||||
busy.value = true;
|
||||
actionError.value = "";
|
||||
try {
|
||||
const settings = { ...fromLines(f.other), ...Object.fromEntries(Object.entries(f.settings).filter(([, v]) => v !== "")) };
|
||||
const body: ExtensionInput = {
|
||||
path: f.path.trim() || undefined,
|
||||
sha256: f.sha256.trim() || undefined,
|
||||
egress: list(f.egress),
|
||||
env: list(f.env),
|
||||
settings,
|
||||
credentials: fromLines(f.credentials),
|
||||
};
|
||||
if (mcp.value) {
|
||||
body.url = f.url.trim() || undefined;
|
||||
body.args = list(f.args);
|
||||
body.tools = JSON.parse(f.tools || "[]");
|
||||
}
|
||||
await api.acceptExtension(props.kind, f.name.trim(), body);
|
||||
editing.value = false;
|
||||
} catch (cause) {
|
||||
actionError.value = cause instanceof SyntaxError ? `Tools: ${cause.message}` : describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
|
||||
const removing = ref<Extension | null>(null);
|
||||
async function remove(): Promise<void> {
|
||||
if (!removing.value) return;
|
||||
busy.value = true;
|
||||
actionError.value = "";
|
||||
try {
|
||||
await api.removeExtension(props.kind, removing.value.name);
|
||||
} catch (cause) {
|
||||
actionError.value = describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
removing.value = null;
|
||||
busy.value = false;
|
||||
await reload();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<p v-if="actionError && !editing" role="alert" class="mb-2 text-caption text-danger">{{ actionError }}</p>
|
||||
<ReadError v-if="error" :message="error" retry-label="Retry" @retry="reload" />
|
||||
<div v-else-if="!data" role="status" :aria-label="`Loading ${noun}s`" class="space-y-2"><Skeleton class="h-8 w-full" /></div>
|
||||
<template v-else>
|
||||
<div class="mb-2 flex justify-end">
|
||||
<Button size="sm" :aria-label="`Add ${noun}`" :title="`Add ${noun}`" @click="open()"><Plus /></Button>
|
||||
</div>
|
||||
<DataTable :columns="columns" :rows="data" :row-key="(e) => e.name" :storage-key="`extensions-${kind}`">
|
||||
<template #cell-name="{ row }"><span class="font-medium">{{ row.name }}</span></template>
|
||||
<template #cell-state="{ row }">
|
||||
<Badge :variant="stateTone(row.state === 'running' ? 'succeeded' : row.state)" :title="row.error || undefined">{{ row.state }}</Badge>
|
||||
<p v-if="row.error" class="mt-1 text-caption text-danger">{{ row.error }}</p>
|
||||
</template>
|
||||
<template #cell-version="{ row }">{{ row.version }}</template>
|
||||
<template #cell-path="{ row }"><span class="font-mono text-caption [overflow-wrap:anywhere]">{{ row.path || row.url }}</span></template>
|
||||
<template #cell-egress="{ row }"><span class="font-mono text-caption">{{ (row.egress ?? []).join(", ") }}</span></template>
|
||||
<template #actions="{ row }">
|
||||
<MoreMenu :label="`${row.name} actions`">
|
||||
<DropdownMenuItem @select="open(row)">Edit</DropdownMenuItem>
|
||||
<DropdownMenuItem class="text-danger" @select="removing = row">Remove</DropdownMenuItem>
|
||||
</MoreMenu>
|
||||
</template>
|
||||
<template #empty><Empty><EmptyHeader><EmptyTitle>No {{ noun }}s</EmptyTitle></EmptyHeader></Empty></template>
|
||||
</DataTable>
|
||||
</template>
|
||||
|
||||
<Dialog v-model:open="editing">
|
||||
<DialogContent class="max-h-[90dvh] overflow-y-auto sm:max-w-2xl">
|
||||
<DialogHeader><DialogTitle>{{ isNew ? `Add ${noun}` : `Edit ${form.name}` }}</DialogTitle></DialogHeader>
|
||||
<form :id="`extension-${kind}`" @submit.prevent="submit">
|
||||
<SettingRow v-if="isNew" label="Name" for="ext-name"><Input id="ext-name" v-model="form.name" pattern="[a-z0-9][a-z0-9-]*" required /></SettingRow>
|
||||
<SettingRow label="Path" for="ext-path" hint="The binary on this host."><Input id="ext-path" v-model="form.path" class="font-mono" :required="!mcp" /></SettingRow>
|
||||
<SettingRow label="SHA-256" for="ext-sha" hint="It runs only while the binary has this digest."><Input id="ext-sha" v-model="form.sha256" class="font-mono" :required="!mcp" /></SettingRow>
|
||||
<template v-if="mcp">
|
||||
<SettingRow label="URL" for="ext-url" hint="For a server reached over HTTP instead of run from a path."><Input id="ext-url" v-model="form.url" type="url" /></SettingRow>
|
||||
<SettingRow label="Arguments" for="ext-args" hint="One per line."><Textarea id="ext-args" v-model="form.args" class="font-mono" rows="2" /></SettingRow>
|
||||
<SettingRow label="Tools" for="ext-tools" hint="The tools it may offer, as JSON: name, kind, read_only, reversibility, summary."><Textarea id="ext-tools" v-model="form.tools" class="font-mono" rows="5" /></SettingRow>
|
||||
</template>
|
||||
<SettingRow v-for="field in schema" :key="field.key" :label="field.label || field.key" :for="`ext-set-${field.key}`" :hint="field.description">
|
||||
<Select v-if="field.options?.length" v-model="form.settings[field.key]">
|
||||
<SelectTrigger :id="`ext-set-${field.key}`" class="w-full"><SelectValue /></SelectTrigger>
|
||||
<SelectContent><SelectItem v-for="o in field.options" :key="o" :value="o">{{ o }}</SelectItem></SelectContent>
|
||||
</Select>
|
||||
<Input v-else :id="`ext-set-${field.key}`" v-model="form.settings[field.key]" :required="field.required" :placeholder="field.secret ? 'engine:key' : undefined" />
|
||||
</SettingRow>
|
||||
<SettingRow :label="schema?.length ? 'Other settings' : 'Settings'" for="ext-settings" hint="key=value, one per line. A key ending in _ref takes engine:key."><Textarea id="ext-settings" v-model="form.other" class="font-mono" rows="3" /></SettingRow>
|
||||
<SettingRow label="Credentials" for="ext-creds" hint="slot=credential, one per line."><Textarea id="ext-creds" v-model="form.credentials" class="font-mono" rows="2" /></SettingRow>
|
||||
<SettingRow label="Egress" for="ext-egress" hint="Hosts it may reach, one per line."><Textarea id="ext-egress" v-model="form.egress" class="font-mono" rows="2" /></SettingRow>
|
||||
<SettingRow label="Environment" for="ext-env" hint="Host variables it may see, one per line."><Textarea id="ext-env" v-model="form.env" class="font-mono" rows="2" /></SettingRow>
|
||||
<p v-if="actionError" role="alert" class="pt-2 text-caption text-danger">{{ actionError }}</p>
|
||||
</form>
|
||||
<DialogFooter><Button type="submit" :form="`extension-${kind}`" :disabled="busy">{{ isNew ? "Accept and start" : "Save and restart" }}</Button></DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<AlertDialog :open="!!removing" @update:open="(o) => { if (!o) removing = null; }">
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader><AlertDialogTitle>Stop and remove {{ removing?.name }}?</AlertDialogTitle></AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction :disabled="busy" @click="remove">Remove</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -12,7 +12,8 @@ export const useSecretEnginesStore = defineStore("secret-engines", () => {
|
||||
async function load() {
|
||||
const current = ++generation;
|
||||
try {
|
||||
engines.value = (await api.secretEngines<{ engines: SecretEngine[] }>()).engines;
|
||||
const accepted = await api.extensions("secret-engines");
|
||||
engines.value = accepted.map((e) => ({ name: e.name, version: e.version, source: e.path || e.url || "" }));
|
||||
if (current !== generation) return;
|
||||
error.value = "";
|
||||
} catch (cause) {
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { RouterLink, useRoute, useRouter } from "vue-router";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError } from "@/lib/api";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
import TriggerList from "@/events/TriggerList.vue";
|
||||
import WorkflowCanvas from "./WorkflowCanvas.vue";
|
||||
import WorkflowYaml from "./WorkflowYaml.vue";
|
||||
|
||||
/** One workflow: its graph, its document, the versions it has been published
|
||||
* as, and the triggers that start it. */
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const name = String(route.params.id);
|
||||
|
||||
const latest = useRead(() => api.workflow(name));
|
||||
onMounted(latest.reload);
|
||||
|
||||
// ?version= shows a published version read-only, marked against the latest.
|
||||
const versionParam = computed(() => Number(route.query.version) || 0);
|
||||
const shown = useRead(() => api.workflow(name, versionParam.value));
|
||||
watch(versionParam, (v) => v && void shown.reload(), { immediate: true });
|
||||
const viewingOld = computed(() => !!versionParam.value && versionParam.value !== latest.data.value?.version);
|
||||
const versions = computed(() => Array.from({ length: latest.data.value?.version ?? 0 }, (_, i) => String((latest.data.value?.version ?? 0) - i)));
|
||||
function pickVersion(v: unknown): void {
|
||||
const n = Number(v);
|
||||
void router.replace({ query: { ...route.query, version: n === latest.data.value?.version ? undefined : String(n) } });
|
||||
}
|
||||
|
||||
// The document being edited: unpublished until Publish, and lost on leaving.
|
||||
const yaml = ref("");
|
||||
const base = ref(0);
|
||||
watch(
|
||||
() => latest.data.value,
|
||||
(w) => {
|
||||
if (w && (!base.value || yaml.value === "")) {
|
||||
yaml.value = w.body;
|
||||
base.value = w.version;
|
||||
}
|
||||
},
|
||||
);
|
||||
const edited = computed(() => !!latest.data.value && yaml.value !== latest.data.value.body);
|
||||
const busy = ref(false);
|
||||
const publishError = ref("");
|
||||
async function publish(): Promise<void> {
|
||||
busy.value = true;
|
||||
publishError.value = "";
|
||||
try {
|
||||
// Another writer (a person, or Archie publishing a draft) may have
|
||||
// published since this copy was opened; never overwrite their version.
|
||||
const current = await api.workflow(name);
|
||||
if (current.version !== base.value) {
|
||||
publishError.value = `Version ${current.version} was published after you opened version ${base.value}. Copy your changes, then discard them to load it.`;
|
||||
return;
|
||||
}
|
||||
const saved = await api.putWorkflow(name, yaml.value);
|
||||
base.value = saved.version;
|
||||
yaml.value = saved.body;
|
||||
await latest.reload();
|
||||
} catch (cause) {
|
||||
publishError.value = describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
function discard(): void {
|
||||
base.value = 0;
|
||||
yaml.value = "";
|
||||
publishError.value = "";
|
||||
void latest.reload();
|
||||
}
|
||||
|
||||
const view = computed(() => (["yaml", "triggers"].includes(String(route.query.view)) ? String(route.query.view) : "canvas"));
|
||||
function showView(v: unknown): void {
|
||||
void router.replace({ query: { ...route.query, view: v === "canvas" ? undefined : String(v) } });
|
||||
}
|
||||
const open = ref<string | null>(null);
|
||||
const displayed = computed(() => (viewingOld.value ? (shown.data.value?.body ?? "") : yaml.value));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader :title="name">
|
||||
<Badge v-if="edited" variant="outline">Unpublished changes</Badge>
|
||||
<Select v-if="versions.length > 1" :model-value="String(versionParam || latest.data.value?.version)" @update:model-value="pickVersion">
|
||||
<SelectTrigger size="sm" aria-label="Version"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="v in versions" :key="v" :value="v">Version {{ v }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Badge v-else-if="latest.data.value" variant="outline">Version {{ latest.data.value.version }}</Badge>
|
||||
<Button size="sm" variant="outline" as-child><RouterLink :to="{ path: '/runs', query: { workflow: name } }">Runs</RouterLink></Button>
|
||||
</PageHeader>
|
||||
<ReadError v-if="latest.error.value" :message="latest.error.value" retry-label="Retry" @retry="latest.reload" />
|
||||
<div v-else-if="!latest.data.value" role="status" aria-label="Loading workflow"><Skeleton class="h-96 w-full" /></div>
|
||||
<template v-else>
|
||||
<Tabs :model-value="view" class="mb-3" @update:model-value="showView">
|
||||
<TabsList variant="line" class="w-full justify-start">
|
||||
<TabsTrigger value="canvas" class="flex-none px-3">Canvas</TabsTrigger>
|
||||
<TabsTrigger value="yaml" class="flex-none px-3">YAML</TabsTrigger>
|
||||
<TabsTrigger value="triggers" class="flex-none px-3">Triggers</TabsTrigger>
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
<ReadError v-if="viewingOld && shown.error.value" :message="shown.error.value" retry-label="Retry" @retry="shown.reload" />
|
||||
<div v-if="view === 'canvas'" class="h-[70dvh] min-h-96">
|
||||
<WorkflowCanvas :yaml="displayed" readonly :open="open" @toggle="open = open === $event ? null : $event" />
|
||||
</div>
|
||||
<div v-else-if="view === 'yaml'" class="flex flex-col gap-2">
|
||||
<div v-if="!viewingOld" class="flex flex-wrap items-center justify-end gap-2">
|
||||
<p v-if="publishError" role="alert" class="mr-auto text-caption text-danger">{{ publishError }}</p>
|
||||
<Button size="sm" variant="outline" :disabled="!edited || busy" @click="discard">Discard</Button>
|
||||
<Button size="sm" :disabled="!edited || busy" @click="publish">Publish</Button>
|
||||
</div>
|
||||
<WorkflowYaml v-if="viewingOld" :model-value="displayed" readonly />
|
||||
<WorkflowYaml v-else v-model="yaml" />
|
||||
</div>
|
||||
<TriggerList v-else :workflow="name" />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,126 @@
|
||||
<script setup lang="ts">
|
||||
import { Plus } from "@lucide/vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DataTable, type DataTableColumn } from "@/components/ui/data-table";
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { ReadError } from "@/components/ui/read-error";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { errors } from "@/copy/errors";
|
||||
import { api, describeError, type Run, type Trigger } from "@/lib/api";
|
||||
import { useRead } from "@/lib/use-read";
|
||||
import { stateTone } from "@/runs/state";
|
||||
import WorkflowYaml from "./WorkflowYaml.vue";
|
||||
|
||||
const router = useRouter();
|
||||
const workflows = useRead(() => api.workflowList());
|
||||
const triggers = useRead(() => api.triggers());
|
||||
const runs = useRead(() => api.runs());
|
||||
onMounted(() => {
|
||||
void workflows.reload();
|
||||
void triggers.reload();
|
||||
void runs.reload();
|
||||
});
|
||||
|
||||
interface Row {
|
||||
name: string;
|
||||
version: number;
|
||||
steps: number;
|
||||
updated: string;
|
||||
by?: string;
|
||||
triggers: Trigger[];
|
||||
last?: Run;
|
||||
}
|
||||
const rows = computed<Row[]>(() =>
|
||||
(workflows.data.value ?? []).map((w) => ({
|
||||
name: w.name,
|
||||
version: w.version,
|
||||
steps: w.steps?.length ?? 0,
|
||||
updated: w.created_at,
|
||||
by: w.created_by,
|
||||
triggers: (triggers.data.value ?? []).filter((t) => t.workflow === w.name),
|
||||
last: (runs.data.value ?? []).filter((r) => r.workflow === w.name).sort((a, b) => Date.parse(b.created_at) - Date.parse(a.created_at))[0],
|
||||
})),
|
||||
);
|
||||
const time = (at?: string) => (at ? Date.parse(at) : 0);
|
||||
const columns: DataTableColumn<Row>[] = [
|
||||
{ id: "name", label: "Workflow", fixed: true, sort: (r) => r.name },
|
||||
{ id: "triggers", label: "Started by" },
|
||||
{ id: "last", label: "Last run", sort: (r) => time(r.last?.created_at) },
|
||||
{ id: "steps", label: "Steps", hidden: true, sort: (r) => r.steps },
|
||||
{ id: "updated", label: "Published", sort: (r) => time(r.updated) },
|
||||
];
|
||||
function startedBy(row: Row): string {
|
||||
if (!row.triggers.length) return triggers.error.value ? "" : "Manual";
|
||||
return row.triggers.map((t) => (t.every ? `Every ${t.every}` : `${t.source} ${t.event_type}`)).join(", ");
|
||||
}
|
||||
|
||||
const creating = ref(false);
|
||||
const draft = ref({ name: "", body: "steps:\n - id: first\n type: agent.run\n settings:\n mission: |\n \n" });
|
||||
const busy = ref(false);
|
||||
const createError = ref("");
|
||||
async function create(): Promise<void> {
|
||||
busy.value = true;
|
||||
createError.value = "";
|
||||
const name = draft.value.name.trim();
|
||||
try {
|
||||
await api.putWorkflow(name, draft.value.body);
|
||||
creating.value = false;
|
||||
void router.push(`/workflows/${name}`);
|
||||
} catch (cause) {
|
||||
createError.value = describeError(cause, errors.common.unknown);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Workflows">
|
||||
<Button size="sm" aria-label="New workflow" title="New workflow" @click="creating = true"><Plus /></Button>
|
||||
</PageHeader>
|
||||
<ReadError v-if="workflows.error.value" :message="workflows.error.value" retry-label="Retry" @retry="workflows.reload" />
|
||||
<div v-else-if="!workflows.data.value" role="status" aria-label="Loading workflows" class="space-y-2"><Skeleton class="h-8 w-full" /><Skeleton class="h-8 w-full" /></div>
|
||||
<template v-else>
|
||||
<p v-if="triggers.error.value || runs.error.value" role="alert" class="mb-2 text-caption text-danger">{{ triggers.error.value || runs.error.value }}</p>
|
||||
<DataTable
|
||||
:columns="columns"
|
||||
:rows="rows"
|
||||
:row-key="(r) => r.name"
|
||||
:row-link="(r) => `/workflows/${r.name}`"
|
||||
:row-label="(r) => r.name"
|
||||
storage-key="workflows"
|
||||
:initial-sort="{ id: 'name', desc: false }"
|
||||
>
|
||||
<template #cell-name="{ row }"><span class="font-medium">{{ row.name }}</span> <span class="text-caption text-fg-subtle">v{{ row.version }}</span></template>
|
||||
<template #cell-triggers="{ row }"><span class="text-caption text-fg-muted">{{ startedBy(row) }}</span></template>
|
||||
<template #cell-last="{ row }">
|
||||
<span v-if="row.last" class="flex items-center gap-2"><Badge :variant="stateTone(row.last.state)">{{ row.last.state }}</Badge><Timestamp class="text-caption text-fg-muted" :at="row.last.created_at" /></span>
|
||||
</template>
|
||||
<template #cell-steps="{ row }">{{ row.steps }}</template>
|
||||
<template #cell-updated="{ row }"><Timestamp :at="row.updated" /><span v-if="row.by" class="text-caption text-fg-muted"> by {{ row.by }}</span></template>
|
||||
<template #empty><Empty><EmptyHeader><EmptyTitle>No workflows</EmptyTitle></EmptyHeader></Empty></template>
|
||||
</DataTable>
|
||||
</template>
|
||||
|
||||
<Dialog v-model:open="creating">
|
||||
<DialogContent class="sm:max-w-2xl">
|
||||
<DialogHeader><DialogTitle>New workflow</DialogTitle></DialogHeader>
|
||||
<form id="new-workflow" class="flex min-h-0 flex-col gap-3" @submit.prevent="create">
|
||||
<Input v-model="draft.name" aria-label="Name" placeholder="Name" pattern="[a-z0-9]+([.\-][a-z0-9]+)*" required />
|
||||
<WorkflowYaml v-model="draft.body" class="max-h-[60dvh]" />
|
||||
<p v-if="createError" role="alert" class="text-caption text-danger">{{ createError }}</p>
|
||||
</form>
|
||||
<DialogFooter><Button type="submit" form="new-workflow" :disabled="busy || !draft.name">Publish</Button></DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -20,7 +20,7 @@ const { store, data, error, loading, statsKnown, load, enabledOf, setEnabled, du
|
||||
// under another id or deleting, and the URL follows.
|
||||
const selected = computed({
|
||||
get: () => String(route.params.id ?? ""),
|
||||
set: (id: string) => void (id ? router.replace({ name: "workflow", params: { id }, query: route.query }) : router.replace({ name: "workflows" })),
|
||||
set: (id: string) => void (id ? router.replace({ name: "workflow-editor", params: { id }, query: route.query }) : router.replace({ name: "workflow-editor-list" })),
|
||||
});
|
||||
|
||||
// ?view= opens a tab and ?run= opens the run dialog; a link carries them once.
|
||||
|
||||
@@ -69,7 +69,7 @@ const shown = computed(() => {
|
||||
return needle ? rows.value.filter((row) => row.id.toLowerCase().includes(needle) || row.trigger.text.toLowerCase().includes(needle)) : rows.value;
|
||||
});
|
||||
|
||||
const open = (id: string, query?: Record<string, string>) => void router.push({ name: "workflow", params: { id }, query });
|
||||
const open = (id: string, query?: Record<string, string>) => void router.push({ name: "workflow-editor", params: { id }, query });
|
||||
const run = (id: string) => open(id, { run: "1" });
|
||||
const openRuns = (id: string) => open(id, { view: "runs" });
|
||||
const copy = (id: string) => void duplicate(id).then((next) => next && open(next));
|
||||
|
||||
@@ -4,11 +4,12 @@ import { activeTab, availableTabs } from "../src/events/tab-selection.ts";
|
||||
|
||||
test("Events hides only capabilities explicitly disabled by the server", () => {
|
||||
const cases: Array<[Record<string, boolean> | null | undefined, string[]]> = [
|
||||
[null, ["inspector", "mappings", "bindings"]],
|
||||
[undefined, ["inspector", "mappings", "bindings"]],
|
||||
[{ captures: true }, ["inspector", "mappings", "bindings"]],
|
||||
[{ captures: true, mappings: true, bindings: false }, ["inspector", "mappings"]],
|
||||
[{ captures: false, mappings: false, bindings: false }, []],
|
||||
[null, ["events", "sources", "triggers", "inspector", "mappings", "bindings"]],
|
||||
[undefined, ["events", "sources", "triggers", "inspector", "mappings", "bindings"]],
|
||||
[{ captures: true, events: false }, ["inspector", "mappings", "bindings"]],
|
||||
[{ events: false, captures: true, mappings: true, bindings: false }, ["inspector", "mappings"]],
|
||||
[{ events: true, captures: false, mappings: false, bindings: false }, ["events", "sources", "triggers"]],
|
||||
[{ events: false, captures: false, mappings: false, bindings: false }, []],
|
||||
];
|
||||
for (const [sections, expected] of cases) {
|
||||
assert.deepEqual(availableTabs(sections).map((tab) => tab.id), expected, JSON.stringify(sections));
|
||||
@@ -18,9 +19,10 @@ test("Events hides only capabilities explicitly disabled by the server", () => {
|
||||
test("Events bookmarks select an available tab or fall back to the first", () => {
|
||||
const cases: Array<[Record<string, boolean> | null, string, string]> = [
|
||||
[null, "mappings", "mappings"],
|
||||
[{ captures: false, mappings: false, bindings: true }, "inspector", "bindings"],
|
||||
[{ captures: false, mappings: false, bindings: true }, "", "bindings"],
|
||||
[{ captures: false, mappings: false, bindings: false }, "bindings", ""],
|
||||
[{ events: false, captures: false, mappings: false, bindings: true }, "inspector", "bindings"],
|
||||
[{ events: false, captures: false, mappings: false, bindings: true }, "", "bindings"],
|
||||
[{ events: true, captures: false, mappings: false, bindings: false }, "bindings", "events"],
|
||||
[{ events: false, captures: false, mappings: false, bindings: false }, "bindings", ""],
|
||||
];
|
||||
for (const [sections, requested, expected] of cases) {
|
||||
assert.equal(activeTab(requested, availableTabs(sections)), expected, `${JSON.stringify(sections)}: ${requested}`);
|
||||
|
||||
Reference in new issue
Block a user