diff --git a/ui/pages/pages.json b/ui/pages/pages.json index 10391afda..d31e9ef36 100644 --- a/ui/pages/pages.json +++ b/ui/pages/pages.json @@ -1,73 +1,13 @@ [ - { - "path": "/account", - "label": "Your account", - "description": "Password, recovery code, passkeys and personal API tokens." - }, { "path": "/", "label": "Dashboard", "description": "Health, what waits on a person, and recent runs." }, { - "path": "/tasks", - "label": "Tasks", - "description": "Picked-up issues and their status." - }, - { - "path": "/runs", - "label": "Runs", - "description": "Workflow runs, their decision trails and waiting approvals." - }, - { - "path": "/proposals", - "label": "Proposals", - "description": "Changes Archie proposes, with their evidence and the actions they take." - }, - { - "path": "/controls", - "label": "Controls", - "description": "Hard rules, change-request rules, guards and action types." - }, - { - "path": "/workflows", - "label": "Workflows", - "description": "Workflows and run history." - }, - { - "path": "/settings/skills", - "label": "Skills", - "description": "Skills Archie can activate." - }, - { - "path": "/settings/curators", - "label": "Curators", - "description": "Scheduled memory and capture curation." - }, - { - "path": "/memory", - "label": "Personal memory", - "description": "What Archie remembers for you, and the notes shared with the organisation." - }, - { - "path": "/settings/memory", - "label": "Shared memory", - "description": "Notes shared with everyone, the proposals waiting for review, and their published versions." - }, - { - "path": "/events", - "label": "Events", - "description": "Received events, their sources, and the triggers that start workflows." - }, - { - "path": "/settings/status", - "label": "Status", - "description": "Module, connector and runner health, and the running version." - }, - { - "path": "/logs", - "label": "Logs", - "description": "Daemon log by level and component." + "path": "/account", + "label": "Your account", + "description": "Password, recovery code, passkeys and personal API tokens." }, { "path": "/account/appearance", @@ -75,64 +15,64 @@ "description": "Theme, density and motion." }, { - "path": "/settings/task-execution", - "label": "Task execution", - "description": "Statuses, operator actions, budgets." + "path": "/controls", + "label": "Controls", + "description": "Hard rules, change-request rules, guards and action types." }, { - "path": "/settings/models", - "label": "Models", - "description": "Model aliases, their providers and the organisation's policy." + "path": "/controls/action-types", + "label": "Action types", + "description": "Approval levels each action type has earned." }, { - "path": "/settings/organisations", - "label": "Organisations", - "description": "The organisations on this instance, and which one is active." + "path": "/controls/guards", + "label": "Guards", + "description": "Judges that inspect actions before they run." }, { - "path": "/settings/authentication", - "label": "Authentication", - "description": "Instance URL and single sign-on providers." + "path": "/events", + "label": "Events", + "description": "Received events, their sources, and the triggers that start workflows." + }, + { + "path": "/logs", + "label": "Logs", + "description": "Daemon log by level and component." + }, + { + "path": "/memory", + "label": "Personal memory", + "description": "What Archie remembers for you, and the notes shared with the organisation." }, { "path": "/org", "label": "Organisation", "description": "Members, identities, connections, models and automation." }, - { - "path": "/org/members", - "label": "Members", - "description": "People in the organisation and their roles." - }, { "path": "/org/agents", "label": "Agents", "description": "Execution identities, their permissions and commit author." }, + { + "path": "/org/alerts", + "label": "Alert webhook", + "description": "Webhook sources that receive alerts." + }, + { + "path": "/org/approvals", + "label": "Approvals", + "description": "Default owner, escalation path and approval deadline." + }, { "path": "/org/audit", "label": "Audit", "description": "Settings, access, identity and runtime events." }, { - "path": "/org/decisions", - "label": "Access decisions", - "description": "Access requests the policy chain allowed or refused, newest first." - }, - { - "path": "/org/workspaces", - "label": "Workspaces", - "description": "Groups of organisation work and resources." - }, - { - "path": "/org/policies", - "label": "Policies", - "description": "Access rules for the organisation." - }, - { - "path": "/org/repositories", - "label": "Repositories", - "description": "Repository connections, access checks and execution policies." + "path": "/org/channels", + "label": "Channels", + "description": "Chat channels." }, { "path": "/org/connections", @@ -145,70 +85,130 @@ "description": "Credentials the organisation's extensions use." }, { - "path": "/org/models", - "label": "Models", - "description": "The organisation's agent models and aliases." - }, - { - "path": "/org/approvals", - "label": "Approvals", - "description": "Default owner, escalation path and approval deadline." + "path": "/org/decisions", + "label": "Access decisions", + "description": "Access requests the policy chain allowed or refused, newest first." }, { "path": "/org/instructions", "label": "Instructions", "description": "Standing instructions given to every agent in the organisation." }, - { - "path": "/org/schedules", - "label": "Schedules", - "description": "Time triggers that start workflows." - }, - { - "path": "/org/channels", - "label": "Channels", - "description": "Chat channels." - }, - { - "path": "/org/scheduling-policy", - "label": "Scheduling policy", - "description": "Work discovery and forge labels." - }, { "path": "/org/issue-routing", "label": "Issue routing", "description": "Which workflow an issue runs by its labels." }, { - "path": "/org/alerts", - "label": "Alert webhook", - "description": "Webhook sources that receive alerts." + "path": "/org/members", + "label": "Members", + "description": "People in the organisation and their roles." + }, + { + "path": "/org/models", + "label": "Models", + "description": "The organisation's agent models and aliases." }, { "path": "/org/playbooks", "label": "Playbooks", "description": "Workflows and the events that start them." }, + { + "path": "/org/policies", + "label": "Policies", + "description": "Access rules for the organisation." + }, + { + "path": "/org/repositories", + "label": "Repositories", + "description": "Repository connections, access checks and execution policies." + }, + { + "path": "/org/schedules", + "label": "Schedules", + "description": "Time triggers that start workflows." + }, + { + "path": "/org/scheduling-policy", + "label": "Scheduling policy", + "description": "Work discovery and forge labels." + }, { "path": "/org/usage", "label": "Usage", "description": "Token spend by model, identity and period." }, { - "path": "/settings/tools", - "label": "Tools & MCP", - "description": "Agent tools and MCP servers." + "path": "/org/workspaces", + "label": "Workspaces", + "description": "Groups of organisation work and resources." + }, + { + "path": "/proposals", + "label": "Proposals", + "description": "Changes Archie proposes, with their evidence and the actions they take." + }, + { + "path": "/runs", + "label": "Runs", + "description": "Workflow runs, their decision trails and waiting approvals." + }, + { + "path": "/settings", + "label": "Instance", + "description": "Every instance-wide setting: models, prompts, connections, runtime and status." + }, + { + "path": "/settings/agent-profiles", + "label": "Agent profiles", + "description": "Execution profiles: the image and tools each agent runs with." + }, + { + "path": "/settings/authentication", + "label": "Authentication", + "description": "Instance URL and single sign-on providers." }, { "path": "/settings/channels", "label": "Channels", "description": "Chat channel connections and session defaults." }, + { + "path": "/settings/container-runtime", + "label": "Container runtime", + "description": "How task containers run: runtime, image, limits and egress hosts." + }, + { + "path": "/settings/credentials", + "label": "Credentials", + "description": "Sealed credentials extensions and models use." + }, + { + "path": "/settings/curators", + "label": "Curators", + "description": "Scheduled memory and capture curation." + }, { "path": "/settings/extensions", "label": "Extensions", "description": "Installed extensions, grants and the marketplace." }, + { + "path": "/settings/memory", + "label": "Shared memory", + "description": "Notes shared with everyone, the proposals waiting for review, and their published versions." + }, + { + "path": "/settings/models", + "label": "Models", + "description": "Model aliases, their providers and the organisation's policy." + }, + { + "path": "/settings/organisations", + "label": "Organisations", + "description": "The organisations on this instance, and which one is active." + }, { "path": "/settings/plugins", "label": "Plugins", @@ -220,23 +220,33 @@ "description": "Where secrets are read from: engines, their keys and health." }, { - "path": "/settings/credentials", - "label": "Credentials", - "description": "Sealed credentials extensions and models use." + "path": "/settings/skills", + "label": "Skills", + "description": "Skills Archie can activate." }, { - "path": "/settings/container-runtime", - "label": "Container runtime", - "description": "How task containers run: runtime, image, limits and egress hosts." + "path": "/settings/status", + "label": "Status", + "description": "Module, connector and runner health, and the running version." }, { - "path": "/settings/agent-profiles", - "label": "Agent profiles", - "description": "Execution profiles: the image and tools each agent runs with." + "path": "/settings/task-execution", + "label": "Task execution", + "description": "Statuses, operator actions, budgets." }, { - "path": "/settings", - "label": "Instance", - "description": "Every instance-wide setting: models, prompts, connections, runtime and status." + "path": "/settings/tools", + "label": "Tools & MCP", + "description": "Agent tools and MCP servers." + }, + { + "path": "/tasks", + "label": "Tasks", + "description": "Picked-up issues and their status." + }, + { + "path": "/workflows", + "label": "Workflows", + "description": "Workflows and run history." } ] diff --git a/ui/scripts/pages.ts b/ui/scripts/pages.ts index a5756db0d..431f4c88a 100644 --- a/ui/scripts/pages.ts +++ b/ui/scripts/pages.ts @@ -1,63 +1,129 @@ -// Writes pages/pages.json from the router's own route table. +// Writes pages/pages.json from the file-based pages under src/pages/ and the +// redirect table in src/router/redirects.ts. // // The dashboard's pages are the routes it serves, so deriving the catalogue // from them is what stops the assistant naming a page the dashboard lost or // missing one it gained. `task pages:check` fails when the committed file is // stale, which is what makes a new route carry a catalogue entry. -import { writeFileSync } from "node:fs"; +import { readFileSync, writeFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; -import { routes } from "../src/router/routes.ts"; +import ts from "typescript"; +import { createRoutesContext, resolveOptions } from "vue-router/unplugin"; + +import { redirects } from "../src/router/redirects.ts"; type Meta = { label?: string; description?: string; nav?: boolean }; -type Record_ = { - path: string; - meta?: Meta; - children?: Record_[]; -}; - export type Page = { path: string; label: string; description: string }; -const join_ = (parent: string, path: string): string => { - if (path.startsWith("/")) return path; - if (path === "") return parent; - return `${parent.replace(/\/$/, "")}/${path}`; -}; +const here = dirname(fileURLToPath(import.meta.url)); +const uiRoot = join(here, ".."); // dynamic is true for a route the operator reaches with an id in it; the // assistant cannot name one, so it stays out of the catalogue. const dynamic = (path: string): boolean => path.includes(":"); -const collect = (records: Record_[], parent = "", out: Page[] = []): Page[] => { - for (const route of records) { - const path = join_(parent, route.path); - if (route.meta?.label && route.meta.nav !== false && path && !dynamic(path)) { - out.push({ +function readDefinePageMeta(file: string): Meta | undefined { + const sfc = readFileSync(file, "utf8"); + const scriptMatch = sfc.match(/]*\bsetup\b[^>]*>([\s\S]*?)<\/script>/); + if (!scriptMatch) return undefined; + + const sf = ts.createSourceFile(file, scriptMatch[1], ts.ScriptTarget.Latest, true); + let meta: Meta | undefined; + + const propName = (name: ts.PropertyName): string | undefined => { + if (ts.isIdentifier(name) || ts.isStringLiteral(name)) return name.text; + return undefined; + }; + + const visit = (node: ts.Node): void => { + if ( + ts.isCallExpression(node) && + ts.isIdentifier(node.expression) && + node.expression.text === "definePage" && + node.arguments.length > 0 && + ts.isObjectLiteralExpression(node.arguments[0]) + ) { + for (const prop of node.arguments[0].properties) { + if ( + ts.isPropertyAssignment(prop) && + propName(prop.name) === "meta" && + ts.isObjectLiteralExpression(prop.initializer) + ) { + const parsed: Meta = {}; + for (const field of prop.initializer.properties) { + if (!ts.isPropertyAssignment(field)) continue; + const key = propName(field.name); + if (key === "label" && ts.isStringLiteral(field.initializer)) { + parsed.label = field.initializer.text; + } else if (key === "description" && ts.isStringLiteral(field.initializer)) { + parsed.description = field.initializer.text; + } else if (key === "nav") { + if (field.initializer.kind === ts.SyntaxKind.FalseKeyword) parsed.nav = false; + if (field.initializer.kind === ts.SyntaxKind.TrueKeyword) parsed.nav = true; + } + } + meta = parsed; + } + } + } + ts.forEachChild(node, visit); + }; + + visit(sf); + return meta; +} + +const collected: Page[] = []; + +const opts = resolveOptions({ + root: uiRoot, + routesFolder: "src/pages", + dts: false, + extendRoute(route) { + const file = route.components.get("default"); + if (!file) return; + const path = route.fullPath; + if (!path || dynamic(path)) return; + const meta = readDefinePageMeta(file); + if (meta?.label && meta.nav !== false) { + collected.push({ path, - label: route.meta.label, - description: route.meta.description ?? "", + label: meta.label, + description: meta.description ?? "", }); } - if (route.children) collect(route.children, path, out); - } - return out; -}; + }, +}); -// The org shell and its index child both answer at /org, so the first label -// for a path wins rather than the catalogue carrying the page twice. -const unique = (pages: Page[]): Page[] => { - const seen = new Set(); - return pages.filter((page) => { +const ctx = createRoutesContext(opts); +await ctx.scanPages(false); +ctx.generateRoutes(); + +for (const route of redirects) { + const meta = route.meta as Meta | undefined; + if (meta?.label && meta.nav !== false && route.path && !dynamic(route.path)) { + collected.push({ + path: route.path, + label: meta.label, + description: meta.description ?? "", + }); + } +} + +// Shell routes and their index children share a path (for example /org and +// /controls), so the first label for a path wins rather than listing it twice. +const seen = new Set(); +const pages = collected + .filter((page) => { if (seen.has(page.path)) return false; seen.add(page.path); return true; - }); -}; + }) + .sort((a, b) => a.path.localeCompare(b.path)); -const pages = unique(collect(routes as Record_[])); -const here = dirname(fileURLToPath(import.meta.url)); -const target = join(here, "..", "pages", "pages.json"); +const target = join(uiRoot, "pages", "pages.json"); writeFileSync(target, `${JSON.stringify(pages, null, 2)}\n`); console.log(`pages: ${pages.length} written to ${target}`); diff --git a/ui/src/App.vue b/ui/src/App.vue index 566bbc399..1f6e7d094 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -37,7 +37,12 @@ const route = useRoute(); const router = useRouter(); const workflowsPage = computed(() => route.name === "workflow"); const hidden = computed(() => hiddenPaths(session.sections)); -const sectionLink = computed(() => ({ workflow: "/workflows", run: "/runs" })[String(route.name)]); +const sectionLink = computed(() => ({ + workflow: "/workflows", + run: "/runs", + "controls-guard": "/controls/guards", + "controls-action-type": "/controls/action-types", +})[String(route.name)]); // The redirect below must not run during the router's first navigation: route // is still the start location then, so a deep link would be replaced by the // landing page before it resolves. @@ -130,6 +135,10 @@ watch(() => accounts.status?.user, (user) => { {{ String(route.params.id).slice(0, 8) }} +
diff --git a/ui/src/controls/ControlsPage.vue b/ui/src/controls/ControlsPage.vue deleted file mode 100644 index effbedd28..000000000 --- a/ui/src/controls/ControlsPage.vue +++ /dev/null @@ -1,146 +0,0 @@ - - - diff --git a/ui/src/logs/LogsPage.vue b/ui/src/logs/LogsPage.vue deleted file mode 100644 index 100b5e485..000000000 --- a/ui/src/logs/LogsPage.vue +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/ui/src/base/NotFoundPage.vue b/ui/src/pages/[...path].vue similarity index 80% rename from ui/src/base/NotFoundPage.vue rename to ui/src/pages/[...path].vue index 01d828199..c99769353 100644 --- a/ui/src/base/NotFoundPage.vue +++ b/ui/src/pages/[...path].vue @@ -1,5 +1,12 @@ diff --git a/ui/src/settings/SystemAppearancePage.vue b/ui/src/pages/account/appearance.vue similarity index 96% rename from ui/src/settings/SystemAppearancePage.vue rename to ui/src/pages/account/appearance.vue index 9169ce913..6334b6aa5 100644 --- a/ui/src/settings/SystemAppearancePage.vue +++ b/ui/src/pages/account/appearance.vue @@ -1,4 +1,12 @@ + + diff --git a/ui/src/pages/controls/action-types/[id].vue b/ui/src/pages/controls/action-types/[id].vue new file mode 100644 index 000000000..a9d481e62 --- /dev/null +++ b/ui/src/pages/controls/action-types/[id].vue @@ -0,0 +1,98 @@ + + + diff --git a/ui/src/pages/controls/action-types/index.vue b/ui/src/pages/controls/action-types/index.vue new file mode 100644 index 000000000..6a887b4e6 --- /dev/null +++ b/ui/src/pages/controls/action-types/index.vue @@ -0,0 +1,88 @@ + + + diff --git a/ui/src/pages/controls/guards/[id].vue b/ui/src/pages/controls/guards/[id].vue new file mode 100644 index 000000000..fcf1096eb --- /dev/null +++ b/ui/src/pages/controls/guards/[id].vue @@ -0,0 +1,136 @@ + + + diff --git a/ui/src/pages/controls/guards/index.vue b/ui/src/pages/controls/guards/index.vue new file mode 100644 index 000000000..ad5df2c55 --- /dev/null +++ b/ui/src/pages/controls/guards/index.vue @@ -0,0 +1,90 @@ + + + diff --git a/ui/src/pages/controls/index.vue b/ui/src/pages/controls/index.vue new file mode 100644 index 000000000..a8693601d --- /dev/null +++ b/ui/src/pages/controls/index.vue @@ -0,0 +1,27 @@ + + + diff --git a/ui/src/events/EventsPage.vue b/ui/src/pages/events.vue similarity index 91% rename from ui/src/events/EventsPage.vue rename to ui/src/pages/events.vue index 01e4cc82f..f3cb84285 100644 --- a/ui/src/events/EventsPage.vue +++ b/ui/src/pages/events.vue @@ -1,4 +1,13 @@ + + diff --git a/ui/src/memory/MemoryPage.vue b/ui/src/pages/memory.vue similarity index 97% rename from ui/src/memory/MemoryPage.vue rename to ui/src/pages/memory.vue index 3d67ef2bb..7b45aae98 100644 --- a/ui/src/memory/MemoryPage.vue +++ b/ui/src/pages/memory.vue @@ -1,4 +1,13 @@