Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
docs: bring in the LLM providers overview and clean up stale provider docs
Diego Zacarias83e95210a8b3
diff --git a/README.md b/README.mdindex 705e657b3..f5c9347dc 100644--- a/README.md+++ b/README.md@@ -168,7 +168,9 @@ environment variable; setup infers the matching provider).Most providers are OpenAI-compatible and plug in as config with no custom code;only a few (`claude`, `vertex`, `bedrock`, `azure`) need a dedicated integration.-Adding one: [docs/llm-providers/adding-a-provider.md](docs/llm-providers/adding-a-provider.md).+Overview: [docs/llm-providers/README.md](docs/llm-providers/README.md) ·+Configure: [docs/deploy/llm-providers.md](docs/deploy/llm-providers.md) ·+Add one: [docs/llm-providers/adding-a-provider.md](docs/llm-providers/adding-a-provider.md) ·Details: [mcp-host/README.md](mcp-host/README.md).---diff --git a/docs/README.md b/docs/README.mdindex 282b65bef..52b8258c9 100644--- a/docs/README.md+++ b/docs/README.md@@ -22,42 +22,45 @@ Use this index for long-form docs.## Concepts-| Doc | Description |-| -------------------------------------------------------- | -------------------------------------------------------------------- |-| [Why evenfire](concepts/why-evenfire.md) | Problem, audience, design intent |-| [When to use evenfire](concepts/when-to-use-evenfire.md) | Fit vs personal assistants / in-process frameworks (categories only) |-| [Open core: self-host vs hosted](concepts/open-core-and-hosted.md) | What's in this repo vs the managed evenfire hosted service |-| [Code names](concepts/code-names.md) | evenfire vs clerum |-| [Architecture overview](architecture/overview.md) | Services, CRDs, message lifecycle, NetworkPolicy model |-| [Platform topology](architecture/platform-topology.md) | Namespaces, controller split, deny-all baseline |-| [Non-MCP services](architecture/non-mcp-services.md) | Namespace splitting and L0–L3 policy layers |-| [Diagrams](architecture/diagrams/) | Excalidraw sources |+| Doc | Description |+| ------------------------------------------------------------------ | -------------------------------------------------------------------- |+| [Why evenfire](concepts/why-evenfire.md) | Problem, audience, design intent |+| [When to use evenfire](concepts/when-to-use-evenfire.md) | Fit vs personal assistants / in-process frameworks (categories only) |+| [Open core: self-host vs hosted](concepts/open-core-and-hosted.md) | What's in this repo vs the managed evenfire hosted service |+| [Code names](concepts/code-names.md) | evenfire vs clerum |+| [Architecture overview](architecture/overview.md) | Services, CRDs, message lifecycle, NetworkPolicy model |+| [Platform topology](architecture/platform-topology.md) | Namespaces, controller split, deny-all baseline |+| [Non-MCP services](architecture/non-mcp-services.md) | Namespace splitting and L0–L3 policy layers |+| [Diagrams](architecture/diagrams/) | Excalidraw sources |## Surfaces (the UIs)-| Doc | Description |-| ---------------------------------------- | ---------------------------------------------------------------------------- |-| [Surfaces index](surfaces/README.md) | Which UI is for whom, and what each may reach |-| [Control UI](surfaces/control-ui.md) | Admin console: usage, budgets, approvals, egress, registry |+| Doc | Description |+| -------------------------------------- | -------------------------------------------------------------------------- |+| [Surfaces index](surfaces/README.md) | Which UI is for whom, and what each may reach |+| [Control UI](surfaces/control-ui.md) | Admin console: usage, budgets, approvals, egress, registry || [Desktop App](surfaces/desktop-app.md) | End-user client: chat, live activity, approvals, artifacts; how to ship it |-| [Profile UI](surfaces/profile-ui.md) | Member front door: invitation, password, desktop handoff |+| [Profile UI](surfaces/profile-ui.md) | Member front door: invitation, password, desktop handoff |## How-to guides-| Doc | Description |-| -------------------------------------------------------------- | ----------------------------------- |-| [Connect Telegram](how-to/connect-telegram.md) | Minikube env or CRD channel path |-| [Configure approvals](how-to/configure-approvals.md) | Human-in-the-loop tool gates |-| [Add an MCP server](how-to/add-mcp-server.md) | Dev-mode JSON or CRD allowlist path |-| [Desktop setup & updates](how-to/desktop-setup-and-updates.md) | Environments, invitation setup, updates |+| Doc | Description |+| ----------------------------------------------------------------------------- | ---------------------------------------------------------- |+| [Connect Telegram](how-to/connect-telegram.md) | Minikube env or CRD channel path |+| [Configure approvals](how-to/configure-approvals.md) | Human-in-the-loop tool gates |+| [Add an MCP server](how-to/add-mcp-server.md) | Dev-mode JSON or CRD allowlist path |+| [LLM providers overview](llm-providers/README.md) | Which providers are supported and how they fit together |+| [Configure LLM providers](deploy/llm-providers.md) | Credentials, model allowlist, per-session selector |+| [Add an LLM provider](llm-providers/adding-a-provider.md) | Data-only vs driver-based integration paths |+| [Desktop setup & updates](how-to/desktop-setup-and-updates.md) | Environments, invitation setup, updates || [Member invitations on self-hosted](how-to/member-invitations-self-hosted.md) | Hosted mode zero-config emails vs running your own service |-| [Track usage & set budgets](how-to/token-budgets-and-usage.md) | Enable budgets, scope, block vs warn |-| [Connect to the registry](how-to/connect-to-registry.md) | Self-hosted registry connect flow |-| [Publish a plugin](how-to/publish-plugin-to-registry.md) | Publish under your org with an `efrk_` key |-| [Shared & global files](how-to/shared-and-global-files.md) | Team workspaces (SFS) and the brokered drive (GFS) |-| [Minikube full stack](deploy/minikube.md) | Local Kubernetes platform |-| [Production notes](deploy/production.md) | Checklist and in-repo deploy assets |-| [WorkflowRecipes operations](deploy/workflow-recipes-guide.md) | Recipe ops, RBAC, debugging |+| [Track usage & set budgets](how-to/token-budgets-and-usage.md) | Enable budgets, scope, block vs warn |+| [Connect to the registry](how-to/connect-to-registry.md) | Self-hosted registry connect flow |+| [Publish a plugin](how-to/publish-plugin-to-registry.md) | Publish under your org with an `efrk_` key |+| [Shared & global files](how-to/shared-and-global-files.md) | Team workspaces (SFS) and the brokered drive (GFS) |+| [Minikube full stack](deploy/minikube.md) | Local Kubernetes platform |+| [Production notes](deploy/production.md) | Checklist and in-repo deploy assets |+| [WorkflowRecipes operations](deploy/workflow-recipes-guide.md) | Recipe ops, RBAC, debugging |## Reference@@ -78,11 +81,11 @@ Use this index for long-form docs.## For coding agents-| Doc | Description |-| --------------------------------------------------------------- | ----------------------------- |-| [WorkflowRecipe guide](agents/CLERUM_WORKFLOW_RECIPE_GUIDE.md) | Authoring recipes, for agents |+| Doc | Description |+| --------------------------------------------------------------- | ---------------------------------------------------------- |+| [WorkflowRecipe guide](agents/CLERUM_WORKFLOW_RECIPE_GUIDE.md) | Authoring recipes, for agents || [Frontend style rules](agents/frontend-style-rules.md) | CSS tokens, page shells, component rules for the three UIs |-| [WorkflowRecipe naming](architecture/workflow-recipe-naming.md) | Generated resource-name rules |+| [WorkflowRecipe naming](architecture/workflow-recipe-naming.md) | Generated resource-name rules |## Community & trust@@ -103,12 +106,13 @@ Use this index for long-form docs.| Understand why this exists | [Why evenfire](concepts/why-evenfire.md) || Decide if evenfire fits my use case | [When to use evenfire](concepts/when-to-use-evenfire.md) || Configure Host / Context / McpServer | [CRD index](crds/README.md) |+| Pick or configure an LLM provider | [LLM providers overview](llm-providers/README.md) || Run the full stack locally | [Minikube](deploy/minikube.md) || Ship to a real cluster | [Production notes](deploy/production.md) || Debug E2E | [E2E guide](testing/e2e-guide.md) || Feed docs to an LLM | [llms.txt](llms.txt) |-| Use the admin console | [Control UI](surfaces/control-ui.md) |-| Chat with an agent from the desktop | [Desktop App](surfaces/desktop-app.md) |+| Use the admin console | [Control UI](surfaces/control-ui.md) |+| Chat with an agent from the desktop | [Desktop App](surfaces/desktop-app.md) |> **Note:** Contributor-local working artifacts live under `docs/superpowers/`> on each checkout. They are git-ignored and intentionally not part of the repo.diff --git a/docs/control-ui/llm-management-analysis.md b/docs/control-ui/llm-management-analysis.mddeleted file mode 100644index efabacf1f..000000000--- a/docs/control-ui/llm-management-analysis.md+++ /dev/null@@ -1,86 +0,0 @@-# Control UI LLM Management Analysis--## Scope and constraints--- Target workspace: `control-ui`.-- Backend must remain unchanged.-- New UI behavior must work against existing `control-api` routes.--## Current frontend architecture (before changes)--## Main state owner--- `control-ui/app/page.tsx` is the main dashboard container.-- It loads core resources in `loadAll()`:- - `/api/v1/admin/hosts`- - `/api/v1/admin/contexts`- - `/api/v1/admin/mcp-servers`- - `/api/v1/admin/communication-channels`- - `/api/v1/admin/secrets`-- Tab rendering is centralized in this file and driven by `tab` query params.--## Host creation flow--- `control-ui/components/HostWizard.tsx` handles Create Agent.-- It already supports:- - creating/reusing contexts- - creating/reusing channels- - creating/reusing host secrets via `/api/v1/admin/secrets`- - creating host CRD via `/api/v1/admin/hosts`-- Before implementation, provider options were limited to `openai` and `claude`, and model was free-text.--## Host edit flow--- `control-ui/app/hosts/[name]/page.tsx` handles host details + edits.-- It supports editing:- - host name/display- - contextRef- - `spec.model.provider` and `spec.model.name`- - `secretRef`-- Before implementation, provider options were `openai`/`claude` only.--## Backend API contract relevant to LLM secrets--From `control-api/src/routes/admin/secrets.ts`:--- `GET /api/v1/admin/secrets`- - forced namespace: `CONTROL_API_SECRETS_NAMESPACE` (default `mcp-host`)- - returns filtered names only (host-secret label match)- - rejects `namespace` query override-- `POST /api/v1/admin/secrets`- - creates secret using provided payload, namespace forced by backend config-- `PUT /api/v1/admin/secrets`- - updates (replace) secret via `updateSecret`-- `DELETE /api/v1/admin/secrets/:name`- - deletes secret in fixed secrets namespace--From `control-api/src/services/secretService.ts`:--- `updateSecret` uses `replaceNamespacedSecret` with provided `data/stringData`.-- If fields are omitted in update payload, they are not preserved automatically in request body.--## Critical caveats from backend behavior--- Secret values are write-only from Control UI:- - list endpoint returns names only, not secret payloads.-- Update is effectively a replace operation:- - UI cannot fetch existing keys/values to prefill.- - operators must re-enter all key entries they want retained.-- Namespace for these secrets is backend-controlled and cannot be changed from UI.--## LLM provider/model ecosystem signals in repo--- Host runtime supports provider strings including at least `openai`, `claude`, `zai` (and backend services also include `bailian` in broader system types).-- Current control-ui model menu is intentionally curated to:- - OpenAI: `gpt-5.4-mini`, `gpt-5.1-codex`, `gpt-5.1-codex-mini`- - Anthropic (`claude` provider value): `claude-opus-4-6`, `claude-sonnet-4-6`, `claude-haiku-4-5`- - Z.AI: `glm-4.7`, `glm-5.1`, `glm-5`, `glm-5-turbo`--## Design implications for frontend-only implementation--- Add Z.AI provider support in both create and edit flows.-- Keep model input flexible (backend accepts arbitrary values), but provide curated dropdown presets for operator guidance.-- Add dedicated sidebar section for LLM secrets using existing secrets endpoints.-- In UI copy, explicitly communicate:- - names-only visibility- - update replace semanticsdiff --git a/docs/control-ui/llm-management-source-of-truth.md b/docs/control-ui/llm-management-source-of-truth.mddeleted file mode 100644index 3003804f0..000000000--- a/docs/control-ui/llm-management-source-of-truth.md+++ /dev/null@@ -1,207 +0,0 @@-# Control UI LLM Management Source of Truth--## Source of truth for models (spec §3-R3, allowlist)--**The list of usable models is the operator-declared allowlist, not a static-catalog.** It lives in the control-api Postgres table `llm_allowed_models` and is-served by the admin API `GET/POST/PUT/DELETE /admin/llm-models`. A mutation also-materializes the `clerum-llm-allowed-models` ConfigMap that mcp-host and the WRC-read at runtime.--Fail-closed semantics: a model is usable only if a row exists for-`(provider, model)` and `enabled = true`. Disabled/absent rows are not-selectable in new host creation, host editing, or the runtime picker.--The former static `LLM_MODELS_BY_PROVIDER` map in `control-ui/lib/llm.ts` has-been **removed**. `lib/llm.ts` now keeps only provider-level metadata; every-model picker loads the allowlist and passes the rows to the catalog helpers.--### Data flow in control-ui--- `lib/api.ts` — typed wrappers `getLlmModels`, `getLlmModel`, `createLlmModel`,- `updateLlmModel`, `deleteLlmModel` (+ types `LlmAllowedModel`,- `CreateLlmModelInput`, `UpdateLlmModelInput`) and `isLlmModelConfigMapDeferred`- (detects the 503 `configmap_write_failed` — the row was saved, only the- ConfigMap propagation is delayed; surfaced as an info toast, not a failure).-- `lib/hooks/useLlmAllowedModels.ts` — loads the allowlist once and exposes- `{ models, loading, error, reload }`. On error the caller shows an- error/empty picker; there is **no** hardcoded fallback list (spec R4.5.1).-- `lib/llm.ts` catalog helpers (all take the allowlist rows as an argument):- - `getModelOptions(catalog, provider, { includeDisabled? })` — model names for- a provider (enabled only by default).- - `getAllModelOptions(catalog, { includeDisabled? })` — de-duplicated model- names across all providers (budget-scope suggestions).- - `resolveDefaultModel(provider, enabledModels)` — the static- `LLM_DEFAULT_MODEL_BY_PROVIDER` default when enabled, else the first enabled- model, else `''`.- - `inferProviderFromModels(models, catalog)` — recovers the provider for a- legacy grant that stored model names but no explicit provider.--### Admin page--- `control-ui/app/llm-models/` (`page.tsx` + `new/page.tsx` +- `[id]/edit/page.tsx`) — App Router list / create / edit, mirroring- `app/cost/llm-prices/`. Columns: provider, model, vendor, display name,- context window, enabled; provider filter + search; disabled badge. Rows for- enabled models that have no enabled price render a "No price" chip linking to- `/cost/llm-prices` (cross-check against `getUnpricedModels`, spec R3.3).- A 503 `configmap_write_failed` is treated as "saved, propagation delayed".-- `components/LlmModelTable.tsx` / `components/LlmModelForm/` — table and form.-- Sidebar entry `llm-models` ("LLM Models", `IconModels`) registered in- `components/Sidebar/constants.tsx` + `types.ts`, with the route→tab mapping in- `components/DashboardLayout.tsx`.--## Provider metadata source: the shared `@clerum/llm-providers` package (spec §3-R4)--The canonical provider set, their display labels, credential slots, and-non-secret env vars now live in the shared **`@clerum/llm-providers`** package-(`packages/llm-providers/`), consumed by control-ui, control-api, mcp-host, and-the WRC. `lib/llm.ts` derives its provider-level UI metadata from that package-instead of re-declaring the enum — this is the single source of truth referenced-by spec R4.5.1 ("the slot list always comes from the package; never a hardcoded-field list in the UI").--Exports the package provides:--- `PROVIDER_IDS` / `LlmProviderId` — the canonical 6 provider ids- (`openai`, `claude`, `zai`, `bailian`, `vertex`, `bedrock`).-- `PROVIDER_CREDENTIAL_SLOTS` — the credential slots each provider loads from the- LLM Secret (single key for the 4 originals; the `aws-access-key-id` /- `aws-secret-access-key` pair for Bedrock; the `vertex-service-account-json`- slot for Vertex), each mapped to its shell env name.-- `PROVIDER_DISPLAY_LABELS` — the brand label per provider.-- `PROVIDER_NON_SECRET_ENV` — the non-secret per-Host env vars a provider needs- (`VERTEX_PROJECT_ID`/`VERTEX_LOCATION`, `AWS_REGION`), which flow via- `host-<ref>-env`, **not** the Secret.-- `isLlmProviderId` — a prototype-safe own-property guard.--### Provider metadata that stays local to `lib/llm.ts`--- `LlmProvider` union + `LLM_PROVIDER_OPTIONS` (labels) — derived from the package.-- `LLM_CREDENTIAL_GROUPS` — the grouped structure the multi-slot secrets form- renders (one group per provider, derived from `PROVIDER_CREDENTIAL_SLOTS` +- UI-only label/placeholder hints; the Vertex slot is flagged `multiline`). This- **replaces** the former flat `LLM_SECRET_FIELDS` (removed in B3).-- `getLlmGroupCompleteness(group, isPresent)` — powers the "provider usable" chip- (all `required` slots present, spec R4.5.5).-- `validateLlmSecretData(draft)` — slot-aware validation shared with the- server-side gate in control-api's secrets route (spec R4.5.3): the Bedrock pair- must be written together; the Vertex JSON must parse with `client_email` +- `private_key`. The `BEDROCK_CREDENTIAL_KEYS` set it uses is derived from the- package, not hardcoded.-- `LLM_DEFAULT_MODEL_BY_PROVIDER` — wizard pre-select default per provider (a- provider-level mirror of each provider's `defaultModel` in- `mcp-host/src/llm/registryCore.ts`; includes `vertex: gemini-2.5-pro` and- `bedrock: anthropic.claude-sonnet-4-6-v1:0`, aligned with the registry and the- control-api migration `0052` seed rows). Consumed only via `resolveDefaultModel`,- which falls back to the first enabled allowlist model when this default is not- enabled.-- Helpers `normalizeProvider`, `isKnownProvider`, `getProviderLabel`,- `getProviderDisplayLabel`.--### Multi-slot secrets form (spec R4.5)--`components/LlmCredentialFields/` renders the grouped credential form from-`LLM_CREDENTIAL_GROUPS`, reused by the create-secret page-(`app/secrets/new/page.tsx`), the update-secret modal (`components/SecretsTable.tsx`),-and the HostWizard credential step. Each provider is a group with a completeness-chip; single-key providers show one password field; Bedrock shows its pair;-Vertex shows a JSON textarea. Non-secret env vars appear only as a hint linking-to **Host → Environment** (`HostEnvTable`) — the form never duplicates that-editor. An "Add credential slot" action creates an extra key in the same Secret-(suggested `<provider>-api-key-fb1`, validated as a data key) for the R5 fallback-credentials. The write-only pattern is intact: existing values are never-re-rendered (the listing returns names only).--## Consumers migrated off the static catalog--`HostWizard`, host edit page (`app/hosts/[name]/page.tsx`), `LlmPriceForm`-(suggestions, includes disabled), `TokenBudgetForm` (`getAllModelOptions`),-the SDK grant picker (`app/plugin-workload-sdk/page.tsx` +-`lib/pluginWorkloadSdkModels.ts`) all load the allowlist via-`useLlmAllowedModels`. The host edit page keeps a host's saved model selectable-even if it fell out of the allowlist (preexisting resources are not-interrupted — spec R3.7), marking it "(out of allowlist)".-------## Historical notes (pre-allowlist)--The sections below record the earlier frontend-only work (Z.AI provider support-and the `LLM Secrets` section) and predate the allowlist. `LLM_MODELS_BY_PROVIDER`-and `getDefaultModel`/`getModelOptions` as described there no longer exist in-their original static form.--## Host creation (wizard)--- `control-ui/components/HostWizard.tsx`- - Added Z.AI API key input in new-secret step.- - Secret validation now accepts any of:- - OpenAI key- - Claude key- - Z.AI key- - Secret creation payload now includes `zai-api-key` when provided.- - Provider selector now includes Z.AI.- - Model selection is now provider-aware:- - dropdown of presets per provider- - model input is restricted to curated dropdown values--## Host details editing--- `control-ui/app/hosts/[name]/page.tsx`- - Provider state normalized with shared helper.- - Provider selector includes Z.AI.- - Model selection now offers provider-specific presets.- - Model input is restricted to curated dropdown values.- - `secretRef` now supports dropdown selection from `/api/v1/admin/secrets`.- - Manual custom `secretRef` override remains available.- - Provider is displayed as `Anthropic` in UI while preserving `claude` provider value in payloads.- - Save payload still sends `spec.model.provider` + `spec.model.name` to backend unchanged.--## New LLM Secrets section--- `control-ui/components/LlmSecretsTable.tsx` (new)- - Displays current LLM secret names from `/api/v1/admin/secrets`.- - Supports:- - create (`POST /api/v1/admin/secrets`)- - update (`PUT /api/v1/admin/secrets`)- - delete (`DELETE /api/v1/admin/secrets/:name`)- - Create flow enforces host-secret label:- - `clerum.io/host-secret: "true"`- - UI warnings explain backend constraints:- - names only are visible- - update replaces secret data with submitted keys--## Navigation wiring--- `control-ui/components/Sidebar.tsx`- - Added `llm-secrets` tab and icon.-- `control-ui/components/DashboardLayout.tsx`- - Added `llm-secrets` query-tab support.-- `control-ui/app/page.tsx`- - Added `llm-secrets` tab handling and rendering with `LlmSecretsTable`.--## Documentation update--- `control-ui/README.md`- - Added `LLM Secrets` tab and updated host wizard/provider description.--## Operational behavior and caveats--- Secret values are intentionally not readable from Control UI (backend returns names only).-- Updating a secret requires re-entering all keys that must remain in the final secret payload.-- Namespace for these secret operations is backend-controlled (`CONTROL_API_SECRETS_NAMESPACE`).-- Model dropdowns are convenience presets only; custom model values are still allowed and forwarded.--## Suggested manual verification--1. Open Control UI and switch to `LLM Secrets`.-2. Create a secret with only `zai-api-key`.-3. Use Create Agent wizard:- - choose provider `Z.AI`- - select model `glm-5-turbo` (or custom override)- - reference the created secret-4. Open created agent details:- - verify provider/model persist- - switch provider/model and save-5. Update the secret from `LLM Secrets` and confirm backend accepts update.diff --git a/docs/deploy/llm-providers.md b/docs/deploy/llm-providers.mdindex 18079e04e..21a31bf25 100644--- a/docs/deploy/llm-providers.md+++ b/docs/deploy/llm-providers.md@@ -5,11 +5,15 @@ credentials (including the multi-slot providers **Google Vertex AI** and**Amazon Bedrock**), how to manage the operator-declared model allowlist, and howthe per-session model selector behaves in the desktop app.-The canonical provider set — `openai`, `claude` (Anthropic), `zai`, `bailian`,-`vertex`, `bedrock` — and their credential slots live in the shared-`@clerum/llm-providers` package, which the Control UI, control-api, mcp-host, and-the workflow runtime all consume. A Host is bound to **one** provider-(`spec.model.provider`); the allowlist and selector operate within that provider.+The canonical provider set — **21 providers**, from `openai`, `claude`+(Anthropic), `zai` and `bailian` through the own-SDK `vertex` / `bedrock` to the+OpenAI-compatible additions and `azure` — and their credential slots live in the+shared `@clerum/llm-providers` package, which the Control UI, control-api,+mcp-host, and the workflow runtime all consume. See the+[providers overview](../llm-providers/README.md) for the full list and the+per-surface support matrix (`bedrock` and `azure` are host-only). A Host is bound+to **one** provider (`spec.model.provider`); the allowlist and selector operate+within that provider.## 1. Where credentials and non-secret config live@@ -31,6 +35,12 @@ secrets form only shows a hint linking there; it does not duplicate the editor.| Bailian | `bailian-api-key` | — || Google Vertex AI (`vertex`) | `vertex-service-account-json` | `VERTEX_PROJECT_ID` (required), `VERTEX_LOCATION` || Amazon Bedrock (`bedrock`) | `aws-access-key-id` + `aws-secret-access-key` | `AWS_REGION` (required) |+| Azure OpenAI (`azure`) | `azure-openai-api-key` | `AZURE_OPENAI_ENDPOINT` (required), `AZURE_OPENAI_API_VERSION` |++Every other provider (the OpenAI-compatible additions — `openrouter`, `gemini`,+`deepseek`, `groq`, `together`, `fireworks`, `mistral`, `xai`, `cerebras`,+`deepinfra`, `perplexity`, `moonshot`, `nebius`, `novita`) uses a single+`<id>-api-key` slot and needs no non-secret env.The secrets form is **write-only**: existing values are never displayed (the APIreturns key names only). To rotate a key, re-enter it.@@ -69,18 +79,21 @@ returns key names only). To rotate a key, re-enter it.allowlist. Bedrock model ids are runtime-qualified, e.g.`anthropic.claude-sonnet-4-6-v1:0`.-### Bedrock limitation in workflows+### Bedrock and Azure in workflows-The per-provider fallback engine and the runtime model selector target the-interactive agent first. Multi-credential providers such as Bedrock are fully-supported for interactive Hosts; **workflow steps** that pin a Bedrock model-follow the workflow's own model-configuration path and do not yet participate in-the runtime selector. Configure workflow-step models explicitly in the recipe.+`bedrock` and `azure` are **not admissible in WorkflowRecipe steps**: they are+deliberately absent from the recipe CRD's provider enum, so a recipe pinning+either is rejected at admission. The workflow `configure` transport carries a+single credential string, which can deliver neither Bedrock's key pair nor+Azure's required endpoint. Both remain fully supported for interactive Hosts;+the other 19 providers are admissible in recipes — see the+[providers overview](../llm-providers/README.md) for the per-surface matrix and+the `clerum-model-secret-mapping` caveat.> **Dev-mode note.** When mcp-host runs in dev mode with no explicit> `spec.model`, it auto-detects the provider from whichever credential env vars-> are present, in priority order (`openai` → `claude` → `zai` → `bailian` →-> `vertex` → `bedrock`). Because Bedrock's slots are the standard AWS variables+> are present, in canonical id order (`openai` → `claude` → `zai` → `bailian` →+> `vertex` → `bedrock` → the rest). Because Bedrock's slots are the standard AWS variables> (`aws-access-key-id` / `aws-secret-access-key`), a shell that already exports> generic AWS credentials — with `AWS_REGION` also set — can auto-select> `bedrock` when no higher-priority provider key is exported. Set `spec.model`@@ -91,8 +104,9 @@ the runtime selector. Configure workflow-step models explicitly in the recipe.Each provider group in the secrets form has an **Add credential slot** action.It creates an additional key in the **same** LLM Secret with a suggested namelike `openai-api-key-fb1` (editable, validated as a Kubernetes data key). These-extra keys are how a future fallback policy references a second credential of the-same provider (e.g. a backup Anthropic key). Because the listing enumerates the+extra keys are how a Host's fallback policy (`spec.llmPolicy.fallbacks[]` with a+pinned `credentialSlot`) references a second credential of the same provider+(e.g. a backup Anthropic key). Because the listing enumerates theSecret's real key names, extra slots simply appear with their own present/absentstatus — there is no parallel registry to maintain.diff --git a/docs/llm-providers/README.md b/docs/llm-providers/README.mdnew file mode 100644index 000000000..89670b812--- /dev/null+++ b/docs/llm-providers/README.md@@ -0,0 +1,350 @@+# LLM providers — how they work, which are supported, how to configure them++This is the orientation guide. Read it first, then branch:++| You want to… | Go to |+| ------------------------------------------ | ----------------------------------------------------------------- |+| Set up credentials and the model allowlist | [Operator guide](../deploy/llm-providers.md) |+| Add a provider that isn't in the list | [Adding a provider](adding-a-provider.md) |+| Understand the Control UI surface | [Control UI](../surfaces/control-ui.md) |++> Code and API group still use the historical name **clerum** (`clerum.io`,+> `CLERUM_*`, `@clerum/*`). Same project — [code names](../concepts/code-names.md).++---++## 1. The mental model: three independent things++The single most common confusion is treating "provider", "model" and "credential"+as one setting. They are three separate axes, configured in three different places+by (potentially) three different people.++```mermaid+flowchart LR+ subgraph P["1. PROVIDER — who serves the model"]+ P1["Host CRD spec.model.provider<br/>one of 21 ids<br/>chosen by the operator"]+ end+ subgraph M["2. MODEL — which model of that provider"]+ M1["allowlist llm_allowed_models<br/>operator-declared in Control UI<br/>user picks within it, per chat"]+ end+ subgraph C["3. CREDENTIALS — how we authenticate"]+ C1["credential slots in the LLM Secret<br/>+ non-secret env per Host"]+ end+ P1 --> M1 --> C1+```++A few rules that follow from this split, and that surprise people:++- **A Host is bound to exactly one provider.** There is no per-message provider+ switching. Changing provider means editing the Host.+- **The credential belongs to the provider, not to the model.** Every model of a+ provider resolves to the same credential. (This was not always true — the old+ `provider__model` mapping is retired.)+- **A model is usable only if the operator allowlisted it.** Fail-closed: a row+ must exist in `llm_allowed_models` for `(provider, model)` with `enabled = true`.+ Installing a provider does _not_ make its models available.+- **A credential can have more than one part.** `bedrock` needs two keys; `vertex`+ needs a whole service-account JSON. The code models this as _slots_, not as "the+ API key".++---++## 2. Which providers are supported++**21 providers**, defined once in+[`packages/llm-providers/index.cjs`](../../packages/llm-providers/index.cjs) —+the single source of truth consumed by mcp-host, control-api, the workflow+runtime, the host controller and the Control UI.++They differ only in _how much code_ the integration needs. That is the axis that+determines everything else (which config they need, where they work, what can go+wrong):++### Group A — OpenAI-compatible, pure data (16)++These speak an OpenAI-compatible `/chat/completions` API. Integrating them is a+`baseURL` + one API key, **no driver code**. They are all handled by one shared+class, `OpenAICompatibleProvider`.++| Provider | id | Credential slot | Default model |+| ------------- | ------------ | -------------------- | --------------------------------------------------- |+| Z.AI | `zai` | `zai-api-key` | `glm-5.1` |+| Bailian | `bailian` | `bailian-api-key` | `qwen3-coder-plus` |+| OpenRouter | `openrouter` | `openrouter-api-key` | `anthropic/claude-sonnet-latest` |+| Google Gemini | `gemini` | `gemini-api-key` | `gemini-2.5-flash` |+| DeepSeek | `deepseek` | `deepseek-api-key` | `deepseek-v4-flash` |+| Groq | `groq` | `groq-api-key` | `llama-3.3-70b-versatile` |+| Together AI | `together` | `together-api-key` | `meta-llama/Llama-3.3-70B-Instruct-Turbo` |+| Fireworks AI | `fireworks` | `fireworks-api-key` | `accounts/fireworks/models/llama-v3p3-70b-instruct` |+| Mistral AI | `mistral` | `mistral-api-key` | `mistral-medium-latest` |+| xAI (Grok) | `xai` | `xai-api-key` | `grok-4.3` |+| Cerebras | `cerebras` | `cerebras-api-key` | `gpt-oss-120b` |+| DeepInfra | `deepinfra` | `deepinfra-api-key` | `deepseek-ai/DeepSeek-V3.2` |+| Perplexity | `perplexity` | `perplexity-api-key` | `sonar-pro` |+| Moonshot | `moonshot` | `moonshot-api-key` | `kimi-k2.6` |+| Nebius | `nebius` | `nebius-api-key` | `Qwen/Qwen3-235B-A22B-Instruct-2507` |+| Novita AI | `novita` | `novita-api-key` | `deepseek/deepseek-v3.2` |++`openai` itself also speaks this protocol but uses the official SDK (Group B).++### Group B — own SDK / bespoke wire protocol (4)++| Provider | id | Credential slots | Non-secret env (per Host) |+| ---------------- | --------- | ------------------------------------------------- | -------------------------------------------- |+| OpenAI | `openai` | `openai-api-key` | — |+| Anthropic | `claude` | `claude-api-key` | — |+| Google Vertex AI | `vertex` | `vertex-service-account-json` _(multi-line JSON)_ | `VERTEX_PROJECT_ID` (req), `VERTEX_LOCATION` |+| Amazon Bedrock | `bedrock` | `aws-access-key-id` **+** `aws-secret-access-key` | `AWS_REGION` (required) |++`claude` is the only provider that ships its own token counter; everything except+`openai`/`azure` uses a fallback counter, so **token counts for Group A and for+Vertex/Bedrock are approximations**, not provider-exact.++### Group C — light driver (1)++| Provider | id | Credential slot | Non-secret env (per Host) |+| ------------ | ------- | ---------------------- | --------------------------------------------------------- |+| Azure OpenAI | `azure` | `azure-openai-api-key` | `AZURE_OPENAI_ENDPOINT` (req), `AZURE_OPENAI_API_VERSION` |++Azure is OpenAI-shaped but has no fixed base URL (per-resource endpoint), it+authenticates with an `api-key` header instead of `Authorization: Bearer`, and+**its "model" is your Azure deployment name**, not a catalog id.++### Important: not every provider works everywhere++| Surface | Providers supported |+| ----------------------------- | --------------------------------------- |+| Interactive Host (chat agent) | all **21** |+| WorkflowRecipe LLM steps | **19** — `bedrock` and `azure` excluded |++`bedrock` and `azure` are deliberately absent from the WorkflowRecipe CRD enum:+the workflow `configure` transport carries a **single** credential string, so it+cannot deliver Bedrock's key pair nor Azure's required endpoint. Excluding them+makes the recipe fail at admission rather than mid-run.++---++## 3. How a request actually flows++```mermaid+sequenceDiagram+ participant Op as Operator (Control UI)+ participant CA as control-api+ participant K8s as Kubernetes+ participant MH as mcp-host (the agent)+ participant LLM as Provider API++ Op->>CA: define allowlist + credentials+ CA->>K8s: LLM Secret (slots)+ CA->>K8s: ConfigMap clerum-llm-allowed-models+ Note over K8s,MH: mcp-host WATCHES both — no restart needed+ K8s-->>MH: credential slots + allowlist+ MH->>MH: resolve model (session choice → Host default)+ MH->>MH: createLLMProvider() — fail-closed+ MH->>LLM: chat completion+```++Two properties worth internalising:++1. **Everything is watch-based.** mcp-host holds four watches (`host-secret`,+ `host-cm`, `llm-secret`, `allowlist-cm`) with precedence+ `host-secret > host-cm > llm-secret > process.env`. Rotating a key or editing+ the allowlist propagates in about a second — **no pod restart, no redeploy**.+2. **mcp-host never calls control-api for this.** The allowlist reaches the+ runtime as a ConfigMap watch, never an API call, so a control-api outage+ cannot break a running agent. Direct mcp-host → control-api traffic is denied+ by the NetworkPolicy; the only allowed control-plane lane is the+ workflow-approval gateway.++### Fail-closed at every step++`createLLMProvider()` returns `null` (degraded, never a crash) if the provider id+is unknown, **or if any _required_ credential slot is missing**. This is why+Bedrock with only one of its two AWS keys is rejected up front instead of+surfacing as an opaque `401` on the first message.++---++## 4. Configuring a provider++### 4.1 The general shape++1. **Credentials** → Control UI **Secrets → LLM**. The form renders one group per+ provider, derived from the shared package. It is **write-only**: values are+ never read back, only key names. To rotate, re-enter.+2. **Non-secret config** (region, project, endpoint) → Control UI+ **Host → Environment**. These are _not_ credentials and never belong in the+ Secret.+3. **Allowlist the models** → Control UI **LLM Models** (`/llm-models`). Nothing+ is usable until this exists.+4. **Point the Host at it** → `spec.model.provider` + `spec.model.name`, via the+ Host wizard or the CRD.++### 4.2 A plain API-key provider (Groq, Mistral, DeepSeek, …)++Paste the key into its field under **Secrets → LLM**, allowlist at least one+model, set the Host's provider and model. That's all — no env vars, no code.++### 4.3 Amazon Bedrock++Enter **both** `aws-access-key-id` and `aws-secret-access-key` **in a single+save** — a half-written pair is rejected client-side and by control-api, so a+Host is never left half-configured. Then set `AWS_REGION` under+**Host → Environment**. Bedrock model ids are runtime-qualified, e.g.+`anthropic.claude-sonnet-4-6-v1:0`.++### 4.4 Google Vertex AI++Paste the **entire service-account JSON** into `vertex-service-account-json`.+Its shape is validated (must parse, must contain `client_email` and+`private_key`). Set `VERTEX_PROJECT_ID` (and optionally `VERTEX_LOCATION`) under+**Host → Environment**. The driver builds credentials from the JSON **in memory**+— it never writes a key file and never uses `GOOGLE_APPLICATION_CREDENTIALS`.++### 4.5 Azure OpenAI++Enter the key, then set `AZURE_OPENAI_ENDPOINT` under **Host → Environment**+(this is required — construction fails closed without it). Remember the model+field is your **deployment name**.++### 4.6 Local development (no Kubernetes)++Dev mode bypasses all of the above. Set `CLERUM_DEV_MODE=true` and export the+provider's env var(s) — `OPENAI_API_KEY`, `GROQ_API_KEY`, `AWS_ACCESS_KEY_ID` ++`AWS_SECRET_ACCESS_KEY`, etc. If `CLERUM_MODEL_PROVIDER` is unset, mcp-host+**auto-detects** the first provider (in the canonical id order) whose required+slots are all present and uses that provider's default model;+`CLERUM_MODEL_NAME` applies only when `CLERUM_MODEL_PROVIDER` is also set.++> One gotcha: because Bedrock's slots are the standard AWS variable names, a+> shell that already exports generic AWS credentials (plus `AWS_REGION`) can+> auto-select `bedrock`. Set `CLERUM_MODEL_PROVIDER` explicitly if that's not+> what you want.++---++## 5. The model allowlist++The set of usable models is **operator-declared, not a shipped catalog**. It+lives in the control-api Postgres table `llm_allowed_models`, is managed at+`/llm-models`, is fully audited (`llm_allowed_models_audit`), and is materialized+to the `clerum-llm-allowed-models` ConfigMap for the runtime.++- **Fail-closed**: a row must exist and be `enabled`. A provider with no enabled+ rows is unusable and flagged in the wizard.+- **Discovery**: `/llm-models/discovery` can sync a catalog from models.dev,+ which lands rows as **disabled** for the operator to curate — it never+ auto-enables anything.+- **Deployed resources are never interrupted.** If a model falls out of the+ allowlist, running Hosts keep working (a `WARN` plus a metric, marked "out of+ allowlist" in the UI). Hard enforcement applies only to _new_ selections: host+ create/edit, the runtime set-model call, and workflow `configure`.+- **If the ConfigMap is missing** (rollout in progress, migration not yet run),+ the runtime degrades explicitly: only the model already configured on the+ Host/step is permitted. Neither open nor bricked.++Beyond the global allowlist there are two narrower scopes:++| Scope | Where | Purpose |+| ------------- | ------------------------------------------- | --------------------------------------- |+| Global | `llm_allowed_models` | what the cluster may use at all |+| Per Host | `spec.allowedModels` | narrow one Host to a subset |+| Per SDK grant | `plugin_workload_sdk_grants.allowed_models` | what one recipe's promptBridge may call |++---++## 6. Choosing a model as a user++The desktop app has a per-chat model selector, Claude-Code style, restricted to+the allowlist:++- The choice is **session state, not process state** — one Host serves many users+ and chats, so your switch never touches anyone else's.+- It applies **from your next message**; in-flight tasks finish on the model they+ started with.+- It survives restarts. If the saved model later leaves the allowlist, the agent+ falls back to the Host default and says so.+- You can change the _model_, not the _provider_ — the provider is the operator's+ decision.++---++## 7. Provider fallback++A Host may declare `spec.llmPolicy` with an ordered `fallbacks[]` list, so that a+primary failure (outage, exhausted credit, banned key) fails over instead of+failing the chat. It is **opt-in** — no policy means no behaviour change.++Failover is sticky with a cooldown (default 300s) and recovers lazily. Each entry+is a fixed `(provider, model)` pair and may pin a `credentialSlot` — an extra key+in the _same_ Secret (e.g. `claude-api-key-fb1`), which is how "same provider,+different key" works. Triggers are a closed catalogue mapped onto the error+classifier: `insufficient_quota` (402), `auth` (401/403), `rate_limited` (429),+`provider_unavailable` (5xx/529 and retryable transport errors). Deliberately+**not** eligible: non-retryable `400`s, validation and content-policy errors —+failing over on those would just mask bugs.++---++## 8. Troubleshooting++| Symptom | Cause |+| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |+| Agent degraded, log `credential '<slot>' not found` | A required slot is missing. Bedrock needs **both** keys. |+| Agent degraded, `failed to construct <provider>` | Missing non-secret env (`AWS_REGION`, `VERTEX_PROJECT_ID`, `AZURE_OPENAI_ENDPOINT`) or malformed Vertex JSON. |+| `403 model_not_allowed` | Model isn't allowlisted/enabled for that provider. |+| `404 No secret mapping found` (workflow step) | Provider has no entry in `clerum-model-secret-mapping` — see below. |+| `500 ConfigMap not found` (workflow step) | `clerum-model-secret-mapping` missing from the `mcp-host` namespace. |+| `502 mcp_host configure failed/unreachable` | WRC resolved the credential but couldn't configure mcp-host. |+| Model dropdown empty in the wizard | No enabled allowlist rows for that provider. |+| Context-window indicator looks wrong | `context_window_tokens` unset on the allowlist row → falls back to `CLERUM_CONTEXT_MAX_TOKENS`. |+| Cost report shows a model as unpriced | No row in `llm_model_prices`; only 8 models are seeded. Add one under **Cost → LLM prices**. |++### Known sharp edge: workflow steps and the secret mapping++The WorkflowRecipe CRD admits **19** providers, but the shipped+`clerum-model-secret-mapping` ConfigMap+([`deploy/base/mcp-host/model-secret-mapping.yaml`](../../deploy/base/mcp-host/model-secret-mapping.yaml))+maps only **five**: `openai`, `claude`, `zai`, `bailian`, `vertex`.++A recipe pinning any of the other 14 (`groq`, `mistral`, `xai`, …) passes+admission and then fails at runtime with `404 No secret mapping found`. This+ConfigMap is declarative — nothing generates it — so to use those providers in+workflows an operator must add the entry themselves:++```yaml+data:+ groq: 'chatllm-api-keys/groq-api-key'+```++Interactive Hosts are unaffected: they resolve credentials through the+ConfigStore, not this mapping.++---++## 9. Where things live in the code++| Concern | Location |+| -------------------------------------------------- | ----------------------------------------------------- |+| Canonical provider ids, slots, labels, env | `packages/llm-providers/index.cjs` |+| Runtime fields (baseURL, default model, tokenizer) | `mcp-host/src/llm/registryCore.ts` |+| Provider construction (`makeProvider`) | `mcp-host/src/llm/registry.ts` |+| Fail-closed entry point | `mcp-host/src/llm/index.ts` |+| Own-SDK drivers | `mcp-host/src/llm/drivers/` |+| Credential watches / exclusion boundary | `mcp-host/src/config/configStore.ts` |+| Allowlist CRUD + ConfigMap materialization | `control-api/src/routes/admin/llmModels.ts` |+| Host spec validation (model, policy, subset) | `control-api/src/routes/admin/hostSpecValidation.ts` |+| Workflow secret broker | `workflow-recipes/src/workflow/modelConfigHandler.ts` |+| UI provider/model metadata | `control-ui/lib/llm.ts` |+| CRD enums | `charts/clerum-crds/crds/{host,workflowrecipe}.yaml` |++A note on secrets hygiene: no provider credential — for **any** provider, whether+configured or not — reaches a tool subprocess through the ConfigStore boundary.+The exclusion set is derived from the full slot list of every provider _plus_+whatever the LLM Secret actually delivers, so dynamically-named fallback slots+are covered too. The shell tool additionally strips every non-active provider's+slots from the child env; keep provider key names out of `CLERUM_ENV_ALLOWLIST`+so the active provider's key stays out of subprocesses as well.++Adding a provider is usually a data change, not a code change — see+[Adding a provider](adding-a-provider.md).diff --git a/docs/llms.txt b/docs/llms.txtindex ffd5a84cb..eab3201e1 100644--- a/docs/llms.txt+++ b/docs/llms.txt@@ -32,6 +32,9 @@- Connect Telegram: how-to/connect-telegram.md- Configure approvals: how-to/configure-approvals.md- Add MCP server: how-to/add-mcp-server.md+- LLM providers overview (the 21 providers, mental model, support matrix): llm-providers/README.md+- Configure LLM providers (credentials, model allowlist, session selector): deploy/llm-providers.md+- Add an LLM provider (data-only vs driver-based integration): llm-providers/adding-a-provider.md- Desktop setup & updates (environments, invitation, updates): how-to/desktop-setup-and-updates.md- Member invitations on self-hosted (hosted mode vs your own service): how-to/member-invitations-self-hosted.md- Track usage & set token budgets: how-to/token-budgets-and-usage.mddiff --git a/docs/meta/claims-guardrails.md b/docs/meta/claims-guardrails.mdindex 8db72d49a..53d5429c6 100644--- a/docs/meta/claims-guardrails.md+++ b/docs/meta/claims-guardrails.md@@ -11,8 +11,8 @@ caveats over absolute language.| Do not write | Prefer || ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- || Per-domain egress allowlisting for SaaS connectors | Port/CIDR egress with documented FQDN limits |-| “Any model” / every provider under the sun | Four providers; OpenAI-compatible entries are config |-| Gemini (or other non-shipped) as a first-class provider | Only `openai` / `claude` / `zai` / `bailian` |+| “Any model” / every provider under the sun | The 21 canonical providers (README table); OpenAI-compatible entries are config |+| A provider outside the shared package as shipped | Only the 21 ids in `packages/llm-providers/index.cjs` ([overview](../llm-providers/README.md)) || MiniMax as a direct provider | Via Bailian catalog (Qwen/GLM/Kimi/MiniMax models) || Context memory always-on | Built-in pre-pruning + tiered compaction; **configurable** || Usage/cost in Grafana / `monitoring/` | control-api + control-ui (token dashboards, prices, budgets) |diff --git a/docs/surfaces/control-ui.md b/docs/surfaces/control-ui.mdindex 70246b207..3ae0a911f 100644--- a/docs/surfaces/control-ui.md+++ b/docs/surfaces/control-ui.md@@ -120,6 +120,7 @@ resources and grants inside it — it never writes that CR.| Cost & Usage | `/cost-and-usage/usage`, `/cost-and-usage/llm-prices`, `/cost-and-usage/token-budgets` | cost (non-CRD) || External Channels | `/external-channels` | `CommunicationChannel` || Global File System | `/global-file-system` | gfs resources & grants (non-CRD) |+| LLM Models | `/llm-models`, `/llm-models/discovery` | model allowlist (non-CRD) || Marketplace | `/marketplace/connectors` | registry (non-CRD) || Plugins | `/plugins` | `WorkflowRecipe` || Publisher | `/publisher` | publisher (non-CRD) |