Skip to content

Server & APIs Admin UI (FEAT 468)

Jesus Lara edited this page Nov 5, 2026 · 1 revision

title: "Admin UI (FEAT 468)"

Admin UI (FEAT-468)

Feature: FEAT-468 — UI Server Backend — Embedded Admin UI Foundation Status: shipped Affects: anyone running ai-parrot-server, and anyone developing the Admin UI itself.

What it is

ai-parrot-server embeds a small single-page web UI, served by the same aiohttp application that serves the API. End users get a login page, the agent list and a chat page per agent at the site root; operators get the administration pages under /admin — without standing up a separate frontend deployment.

URL Page Who
/ redirects to /agents (signed in) or /login everyone
/login navigator-auth sign-in everyone
/agents agent list, Chat action only any signed-in user
/agents/<name>/chat full-page Agent Chat any signed-in user (PBAC agent:chat decides)
/admin/home, /admin/dashboard, /admin/agents[...] administration (below) any signed-in user today; role gating is future work

Hashed assets are served from /ui/assets/. The SPA never registers a root catch-all: only the paths above return index.html, so /api/*, /static/*, /a2a, etc. are untouched. Set PARROT_UI_AT_ROOT=false to keep / for something else (the SPA then answers only /login, /agents and /admin).

  • Home (/admin/home) — server identity + navigation.
  • Dashboard (/admin/dashboard) — GET /api/v1/admin/status: version, uptime, agent counts (database/registry/loaded), crews, and per-dependency health (Postgres, Redis, the configured vector store), auto-refreshed.
  • Agents (/admin/agents) — table over GET /api/v1/bots (merged database + registry agents), plus full CRUD for database agents (FEAT-475 — see Agent management below). Registry (YAML/code) agents stay read-only.

Auth model

Authentication is exclusively navigator-auth — there is no parallel auth system for the Admin UI.

  • Login: POST /api/v1/login with a BasicAuth username/password form. Any other configured auth backend (GET /api/v1/auth/methods discovers them) shows up as an extra sign-in option on the login page.
  • Passkeys (FEAT-772): with navigator-auth's PasskeyAuth enabled, the login page offers "Sign in with a passkey" plus passkey autofill, and Account (/account/security) lets each user add, rename and delete passkeys. The passkey ceremony calls skip the 401 interceptor, so a failed passkey attempt never clears your session or ?next=.
  • Any authenticated user may enter — the Admin UI does not layer its own authorization on top of navigator-auth.
  • The SPA authenticates its own API calls with a Bearer token (stored under the ai_parrot_token localStorage key — the same key parrot/autonomous/admin.py's inline admin page and parrot-formdesigner use, so a redirect between them round-trips correctly), not the session cookie navigator-auth also sets. A 401 response clears the stored session and redirects to /login, preserving the page you were on via ?next=.
  • Logout: GET /api/v1/logout.

Agent management

Feature: FEAT-475 — UI Agent Management — Admin UI Agent CRUD

The Agents page (/admin/agents) gets a Create Agent button, per-row Edit/Delete actions, and a Show disabled toggle. Every mutating affordance is database-agent-only (source: "database") — registry (YAML/code) rows never get an Edit or Delete action, matching FEAT-468's original read-only design for that source.

Tools Tab (FEAT-593)

Feature: FEAT-593 — Tool Configuration for Agent Studio

The agent edit form includes a new Tools tab that provides advanced toolkit configuration capabilities:

  • Toolkit Catalog: Lists all available toolkits with on/off switches
  • Toolkit Configuration Drawer: Schema-driven forms for configuring toolkit parameters with proper typing, validation, and secret handling
  • Per-Parameter Override Controls: Toggle to mark parameters as user-overridable
  • Dynamic Options: Multi-select widgets for parameters that support dynamic options (e.g., Jira projects, Querysource programs)
  • Datasets Panel: Specialized interface for configuring the dataset_manager toolkit with support for multiple datasource kinds (query slug, SQL, table, file, Airtable, Smartsheet, Iceberg, Mongo, Delta)
  • MCP Servers Panel: Interface for configuring agent-level MCP server connections with proper secret handling for authentication and headers
  • Reload Action: Button to reload the agent after configuration changes
  • Test Action: Button to test toolkit assignments on a live agent instance

For registry agents with YAML under AGENTS_DIR, the tab provides full configuration capabilities. For .py agents and YAML outside AGENTS_DIR, the tab is displayed in read-only mode with an explanation.

Chat "My tool settings" (FEAT-593)

The chat interface includes a new My tool settings tab in the DataManagementModal that allows end users to configure their own overrides for toolkit parameters marked as user-overridable by the operator. User secrets are stored securely in their own vault entries.

Registry agents stay read-only

Agents loaded from the repository's YAML/code registry (source: "registry") cannot be created, edited, or deleted from the Admin UI — there is no affordance for it in the list, the detail dialog, or the form. Attempting to DELETE a repo-committed registry agent via the API directly returns 403 ("...is a repo YAML/code agent and cannot be deleted via this endpoint."); only database agents are managed here.

Creating and editing: the form

/admin/agents/new (create) and /admin/agents/<name> (edit) open a six-tab form covering every user-editable BotModel field:

Tab Fields
General chatbot_id (edit only, read-only), name (read-only in edit — see below), description, avatar, enabled, timezone, language, disclaimer
Behavior role, goal, backstory, rationale, capabilities, pre_instructions, system_prompt_template, human_prompt_template, prompt_config
AI llm (from the catalog), plus model/temperature/max_tokens/top_p/top_k (stored inside model_config), and the raw model_config JSON
Capabilities tools_enabled, auto_tool_detection, tool_threshold, tools (checkbox list from /api/v1/agent_tools + a fallback text list for names not in the catalog), operation_mode (from the catalog), use_kb, kb, custom_kbs (suggestions from the catalog's knowledge-base classes)
Tools Agent-level toolkit configurations, per-user overrides, dataset manager, MCP servers
Data & Memory use_vector, vector_store_config, reranker_config, parent_searcher_config, context_search_limit, context_score_threshold, memory_type (from the catalog), memory_config, max_context_turns, use_conversation_history
Advanced bot_class (plain text, default BasicBot), permissions (JSON — a dict or a list of rule objects)

Every JSONB field (model_config, prompt_config, vector_store_config, reranker_config, parent_searcher_config, memory_config, permissions) is edited through a validated JSON text editor — malformed JSON blocks Save with an inline error; there is no external JSON-editor dependency. Save is sticky across every tab, and a tab with an invalid field shows a red badge with its error count.

Name slugification — read this before scripting against the API

name is the agent's identity (it appears in the URL and in BotManager's internal registration key). On create, the server slugifies and deduplicates whatever you type:

  • PUT /api/v1/bots with name: "My Bot" creates an agent named my-bot, not My Bot. If my-bot is already taken, the server tries my-bot-2, my-bot-3, etc.
  • The Admin UI always navigates to the name the server actually returned (response.name), never the name you typed, and shows a brief notice when the two differ.
  • Renaming an existing agent is not supported by the UI (v1) — name is rendered read-only in the edit form and is never included in the update request. The backend itself would technically apply a name key sent via POST /api/v1/bots/{name}, but the UI deliberately never sends one.

Disabled agents and "Show disabled"

By default, GET /api/v1/bots — and therefore the Agents list — only returns enabled database agents (enabled: true), exactly as before FEAT-475. Toggling Show disabled on the list page adds ?include_disabled=true to the request, which returns every database agent regardless of its enabled flag; disabled rows are shown with a muted style and a "disabled" badge. This lets you find and re-enable (or delete) an agent you previously toggled off from the form's General tab.

The catalog endpoint (GET /api/v1/admin/catalog)

The form never hardcodes its option lists. GET /api/v1/admin/catalog (authenticated, like every other Admin UI JSON endpoint) returns:

{
  "llm_providers": ["anthropic", "google", "groq", "..."],
  "operation_modes": ["conversational", "agentic", "adaptive"],
  "memory_types": ["memory", "file", "redis"],
  "knowledge_bases": [
    {"class_path": "parrot.stores.kb.redis.RedisKnowledgeBase", "name": "RedisKnowledgeBase"}
  ],
  "bot_class_default": "BasicBot"
}
  • llm_providers is deduplicated by resolved client class (SUPPORTED_CLIENTS has many alias keys — claude/anthropic, claude-agent/claude-code, etc. — for the same underlying client; only the first alias per client is listed). An agent's stored llm value is still shown/kept even when it holds an alias absent from this list.
  • knowledge_bases lists the importable AbstractKnowledgeBase subclasses (RedisKnowledgeBase always; LocalKB only when ai-parrot-embeddings is installed — its absence degrades the catalog gracefully rather than raising).
  • Like /api/v1/admin/status, this endpoint registers unconditionally (even when the compiled dist/ is absent) — it is UI-agnostic JSON, not part of the SPA shell.

Tools list is now library-owned

GET /api/v1/agent_tools (the tools picker's data source) is registered by BotManager.setup() itself — a plain pip install ai-parrot-server deployment has this route without needing repo-root app.py to register it separately (as it did before FEAT-475). The registration is idempotent: a host app that still registers the route itself does not crash on startup.

Quick start: python run.py, gunicorn or supervisord

From a checkout of this repository (venv active):

make build-server-ui      # once per UI change: Node 24 + pnpm 9 (corepack)
make run-server           # = python run.py  (builds the UI first if missing)
# or, multi-process:
AUTH_SECRET_KEY=... make serve-gunicorn   # gunicorn --config deploy/gunicorn.conf.py "run:create_app()"

Open http://localhost:5000/ → sign in → Agents → Chat.

  • Minimal install: ai-parrot + ai-parrot-server + ai-parrot-integrations is enough. app.py registers QuerySource, the agent scheduler/GitHub reviewer, the vector-store API, parrot-formdesigner and the planogram pipeline only when their packages are installed, logging one INFO line per skipped component. Add ai-parrot-server[scheduler], ai-parrot[db], ai-parrot-loaders, parrot-formdesigner, ai-parrot-pipelines to get them.
  • Infrastructure: PostgreSQL (navigator pool + navigator-auth's auth.users table) and Redis are required at startup.
  • Login: set AUTHENTICATION_BACKENDS=navigator_auth.backends.BasicAuth (plus any SSO backend) and create users in auth.users.
  • Passkeys: enable WebAuthn sign-in by installing the passkey extra and configuring relying parties:
    pip install "ai-parrot-server[passkey]"  # pulls navigator-auth[passkey]>=0.28.9 → webauthn
    Then add navigator_auth.backends.PasskeyAuth to AUTHENTICATION_BACKENDS and set PASSKEY_RELYING_PARTIES to a JSON list with one entry per exact browser origin (scheme://host:port). Each entry's rp_id must be that host or a parent domain. Example for production and local development:
    # docs/examples/passkey.settings.example
    PASSKEY_RELYING_PARTIES='[{"origin": "https://parrot.example.com", "rp_id": "parrot.example.com", "rp_name": "AI-Parrot"}, {"origin": "http://localhost:5000", "rp_id": "localhost", "rp_name": "AI-Parrot (dev)"}, {"origin": "http://localhost:5173", "rp_id": "localhost", "rp_name": "AI-Parrot (vite dev)"}]'
    Notes:
    • The Vite dev server (pnpm dev, :5173) is a different origin from the backend (:5000). The proxy rewrites Host, not Origin, so a passkey enrolled on :5173 is not offered on :5000.
    • Redis >= 6.2 is required (for GETDEL).
    • AUTH_SECRET_KEY is still mandatory for multi-worker token signing.
    • Startup fails with ConfigError if PASSKEY_RELYING_PARTIES is empty/invalid or webauthn is missing.
    • Set PASSKEY_LOGIN_OPTIONS_RATE=0 behind a reverse proxy (it keys on the socket address); rate-limit login/options at the proxy instead.
  • AUTH_SECRET_KEY: always set it in production. Without it navigator-auth generates a random signing key per process, so tokens die on restart and, under gunicorn with several workers, a token minted by one worker is rejected by the others (users bounce back to /login). deploy/gunicorn.conf.py refuses to start more than one worker without it.
  • Chat permission (PBAC): chatting is agent:chat on agent:<name>, deny-by-default. The policies shipped in policies/ only grant it to specific groups/users; add a policy for your users or a 403 No policies matched shows up as an error bubble in the chat.
  • LLM provider: each agent needs its client package (e.g. ai-parrot-client-google) and API key; otherwise the chat reports Agent '<name>' not found because it failed to instantiate at startup.
  • supervisord: deploy/supervisord/ai-parrot.conf runs the gunicorn command (or, alternatively, python run.py) with graceful stop settings.

Adopter view: running it

pip install ai-parrot-server
# ... start your aiohttp app that calls BotManager.setup(), which wires
# setup_admin_ui() automatically ...

Visit / — you get the login page, then the agent list and chat, with no Node.js required on the host. The UI ships pre-built inside the wheel (parrot/server/ui/dist/); the server only serves static files.

The git-install caveat

If you install ai-parrot-server from a git checkout (editable install, pip install -e ., or building your own wheel locally) without running the UI build first, parrot/server/ui/dist/ will not exist. setup_admin_ui() degrades gracefully in that case:

  • the server starts normally,
  • a single WARNING is logged,
  • zero UI routes (/, /login, /agents, /admin) are registered,
  • the rest of the API is completely unaffected.

This is expected, not a bug — dist/ is intentionally gitignored (it is build output, not source). If you need the Admin UI from a git checkout, build it yourself first:

cd packages/ai-parrot-server/ui
pnpm install --frozen-lockfile
pnpm generate   # regenerate TS types from the backend's JSON Schema
pnpm build      # writes packages/ai-parrot-server/src/parrot/server/ui/dist/

Then start the server as usual. Note: parrot-formdesigner's own /admin redirect will 404 if you skip this step — that is an accepted consequence of the git-install caveat, not a separate failure mode.

The official release pipeline (.github/workflows/release.yml's build-server job, and the make build-server-ui / make release path) always runs this build before publishing a wheel — see Wheel-content guarantee below.

Developer view: working on the Admin UI

The UI is a standalone Vite + Svelte 5 SPA (not SvelteKit) that lives at packages/ai-parrot-server/ui/. It is not part of the uv Python workspace — manage it with pnpm.

cd packages/ai-parrot-server/ui
pnpm install

# Point the dev server at a running backend (defaults to
# http://localhost:5000 — override via a .env's PUBLIC_API_URL, read
# through `lib/config.ts`):
pnpm dev

pnpm dev starts Vite's dev server with /api proxied to the backend (see vite.config.ts's server.proxy), so you can iterate on the UI against a real running server without rebuilding anything Python-side.

Codegen (pnpm generate)

TypeScript types under ui/src/lib/types/generated/ are generated from backend Pydantic models' JSON Schema — never hand-edit files carrying the // GENERATED … DO NOT EDIT banner. Regenerate them with:

pnpm generate

This runs json2ts (json-schema-to-typescript) against ui/schemas/ and writes .d.ts files. pnpm build always runs pnpm generate first (see package.json's build script), so a production build never ships stale types.

Where the build output lands

pnpm build

writes the production bundle to packages/ai-parrot-server/src/parrot/server/ui/dist/ (see vite.config.ts's build.outDir; hashed assets go to dist/ui/assets/ and are referenced as /ui/assets/*) — directly into the Python package's source tree, one level below the aiohttp handlers that serve it (parrot/server/ui/serving.py). That directory is gitignored; it exists only as local build output or as release-pipeline output.

Tests

pnpm test    # vitest — component + unit tests, jsdom environment
pnpm build   # also type-checks/generates and verifies the production build

Wheel-content guarantee and release pipeline

A wheel built without the Node/pnpm stage silently ships no Admin UI — setuptools's package-data glob ("parrot.server.ui" = ["dist/*", "dist/assets/*"] in packages/ai-parrot-server/pyproject.toml) only picks up files that already exist in dist/ at build time, and there is no build hook that runs the frontend build automatically. This is caught by a dual check:

  1. @pytest.mark.wheel_build test — packages/ai-parrot-server/tests/test_wheel_layout.py::TestWheelContainsAdminUI builds the wheel (via the existing satellite_wheel_path fixture, which shells out to uv build) and asserts it contains parrot/server/ui/dist/index.html and at least one file under parrot/server/ui/dist/assets/. Run it locally:

    pytest packages/ai-parrot-server/tests/test_wheel_layout.py -v -m wheel_build

    It fails if pnpm build was never run (no dist/, or a stale packages/ai-parrot-server/build/ cache from a previous build — clean that directory locally if you see stale results) and passes once the UI has actually been built.

  2. Release-workflow step — both real release paths build the UI before invoking uv build, and fail loudly (test -f .../dist/index.html, non-zero exit) rather than silently publishing a UI-less wheel:

    • .github/workflows/release.yml's build-server job (the path that feeds the deploy job publishing to PyPI): sets up Node 24 LTS + pnpm 9 via corepack, pnpm install --frozen-lockfile, pnpm generate, pnpm build, then asserts dist/index.html exists.
    • Makefile's release target now depends on a new build-server-ui target (make build-server-ui) that does the same, before any uv build --package ai-parrot-server / uv publish step.

Agent Chat

Feature: FEAT-476 — AgentChat Migration

/agents/:name/chat (alias: /admin/agents/:name/chat) mounts a full-page chat with a single agent (vendored from the navigator-frontend-next reference frontend, spec sdd/specs/agentchat-migration.spec.md). It's also reachable without leaving the agents list: a Chat button on every enabled row (database and registry agents — registry agents just chat without a prompt library, since they carry no chatbot_id), and a Chat tab on the existing read-only agent detail dialog (mounting the same component's compact variant, canvas disabled).

Feature flags

Eight build-time flags gate the heaviest surfaces (canvas/charts/maps, voice notes, the LiveKit avatar, datasets, and the rich HTML editor) so an adopter who doesn't need them isn't forced to ship the dependency. Every flag defaults to on; set any PUBLIC_AGENTCHAT_* env var to false or 0 (case-insensitive) before pnpm build to turn it off:

Env var Default Gates
PUBLIC_AGENTCHAT_VOICE true Voice notes (mic button, VoiceNotePlayer)
PUBLIC_AGENTCHAT_AVATAR true LiveKit avatar viewers (AvatarViewer, VoiceNativeAvatarViewer)
PUBLIC_AGENTCHAT_MAPS true DataMap/StructuredMap (Leaflet), AppChartGeo's geo renderer
PUBLIC_AGENTCHAT_CHARTS true AppChart (layerchart), ECharts, DataChart/ChartConfigPanel
PUBLIC_AGENTCHAT_CANVAS true The whole canvas side panel (CanvasPanel and everything under it)
PUBLIC_AGENTCHAT_INFOGRAPHIC true Infographic canvas + editor
PUBLIC_AGENTCHAT_DATASETS true Dataset management modals
PUBLIC_AGENTCHAT_RICH_EDITOR true The @tiptap-backed rich HTML editor (InfographicEditor, AppTextEditor's rich mode)
PUBLIC_AGENTCHAT_A2UI true FEAT-527: the bundled A2UI Infographic renderer (canvas/a2ui/*, opens the infographic canvas in mode: "a2ui" for a chat turn carrying an Infographic/Report-rooted a2ui_envelope); off falls back to today's HTML iframe view

These map 1:1 to ui/vite.config.ts's agentchatDefines() (compiled into __AGENTCHAT_<NAME>__ constants) and ui/src/lib/features.ts's features object, which every gated component checks at the render/ lazy-import site ({#if features.x}{#await import(...)}).

Lean-build recipe — e.g. to drop maps support:

cd packages/ai-parrot-server/ui
PUBLIC_AGENTCHAT_MAPS=false pnpm build

Neither Makefile's build-server-ui target nor .github/workflows/release.yml's build-server job needs a change for this — both just run a plain pnpm build, and since every flag defaults to true, that produces the same full build as before FEAT-476. Either would honour a PUBLIC_AGENTCHAT_* override if one were exported into their environment (Vite's loadEnv reads process.env), but neither sets one — see the size caveat below before relying on this for a smaller release artifact.

Known limitation — flags don't currently shrink dist/. Verified while building this feature (vite@5.4.21 / rollup@4.63.0): each gated surface still lazy-loads as its own chunk file (confirmed — AppChart-*.js, ECharts-*.js, DataMap-*.js, leaflet-src-*.js, livekit-client.esm-*.js, exceljs.min-*.js, etc. are all separate from the main bundle either way), and that chunk is genuinely never fetched by the browser unless the corresponding features.x branch actually executes at runtime — the practically important property for a page's initial load cost. But Rollup still emits the chunk file into dist/assets/ regardless of the flag, because features.x is an object property read (Object.freeze({charts: __AGENTCHAT_CHARTS__, ...})), and esbuild/Rollup's dead-code elimination only removes a compile-time-constant-guarded dynamic import() when the guard is a bare const binding, not a property read through an object — confirmed with an isolated repro during TASK-2595. Measured on this build (all eight flags on vs. all eight off): dist/assets is 15,306,233 bytes / 77 JS files in both cases — byte-for-byte identical. Turning a flag off today only prevents the runtime fetch, not the on-disk/wheel footprint; shrinking the actual dist//wheel size for a given flag combination would need $lib/features.ts reshaped to flat const exports (a cross-cutting change touching every features.x call site across the vendored tree) — tracked as a follow-up, not done in FEAT-476.

Offline icons

Every icon the vendored tree renders (<Icon icon="prefix:name" /> via @iconify/svelte) must resolve from a locally bundled collection — by default @iconify/svelte falls back to the public api.iconify.design API for unregistered icons, which breaks in an air-gapped deployment. ui/src/lib/icons.ts registers every prefix the tree actually uses (mdi, ph, svg-spinners, tabler, lucide) via addCollection() before the app mounts; icons.test.ts fails the build if a future vendored file introduces an unregistered prefix.

The wsService stub

The vendored tree's realtime notifications (answer_ready events, etc.) go through $lib/services/websocket-service.ts's wsService — in ai-parrot's Admin UI this is a stub: connect()/subscribe()/ onMessage() exist (so every vendored call site compiles and runs verbatim) but no socket is ever opened (there is nothing on the ai-parrot backend for it to connect to yet). Chat still works end-to-end over the regular HTTP/streaming APIs; only the "push a notification without the tab being focused" enhancement is a no-op today.

Navigator-divergence policy

The vendored tree under ui/src/lib/components/agents/, ui/src/lib/components/charts/, ui/src/lib/components/visualizations/, and ui/src/lib/components/grid/ mirrors navigator-frontend-next's relative paths file-for-file. Every file that needed a real edit (gating, an import re-pointed at the Admin UI's own http.ts/ auth-headers.ts/stores, an added features.x check) carries a // ai-parrot (FEAT-476 TASK-...): ... header/inline comment explaining the change — logic is otherwise untouched ("no logic changes beyond gating/shims" per the migration spec). To back-port a navigator fix or check what diverged:

diff -r \
  /path/to/navigator-frontend-next/src/lib/components/agents \
  packages/ai-parrot-server/ui/src/lib/components/agents

A few files were intentionally vendored ahead of the task that spec originally assigned them to (e.g. canvas-block-types.ts, config/regeneration-models.ts) because an earlier task's component needed them unconditionally — see the FEAT-476 task history (sdd/tasks/completed/TASK-2594-*.md through TASK-2597-*.md) for the full list and rationale if a diff shows an unexpected file already present.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally