Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript
28.8 KB
Raw Blame
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: hosts.clerum.io
  annotations:
    clerum.io/secret-reference-contract: |-
      {
        "version": 1,
        "plural": "hosts",
        "fields": [
          {
            "path": "spec.secretRef",
            "namespaceBinding": "host-secret"
          }
        ]
      }
  labels:
    app.kubernetes.io/name: host
    app.kubernetes.io/part-of: clerum
spec:
  group: clerum.io
  names:
    kind: Host
    listKind: HostList
    plural: hosts
    singular: host
  scope: Namespaced
  versions:
    - name: v1alpha1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          description: Host is the central entity that uses a context and connects to channels and MPC servers.
          properties:
            spec:
              type: object
              required:
                - host
                - contextRef
              x-kubernetes-validations:
                - rule: "(has(self.model) && has(self.model.provider) && self.model.provider == 'codex-subscription' && (!has(self.llmPolicy) || !has(self.llmPolicy.fallbacks) || !self.llmPolicy.fallbacks.exists(f, f.provider != 'codex-subscription'))) || (has(self.model) && has(self.model.provider) && self.model.provider == 'grok-subscription' && (!has(self.llmPolicy) || !has(self.llmPolicy.fallbacks) || !self.llmPolicy.fallbacks.exists(f, f.provider != 'grok-subscription'))) || (has(self.secretRef) && size(self.secretRef) > 0)"
                  message: spec.secretRef is required unless every LLM target is the same oauth-broker provider
                - rule: "!has(self.llmPolicy) || !has(self.llmPolicy.fallbacks) || !self.llmPolicy.fallbacks.exists(f, (f.provider == 'codex-subscription' || f.provider == 'grok-subscription') && has(f.credentialSlot))"
                  message: credentialSlot is not supported for oauth-broker providers
                - rule: "!(((has(self.model) && has(self.model.provider) && self.model.provider == 'codex-subscription') || (has(self.llmPolicy) && has(self.llmPolicy.fallbacks) && self.llmPolicy.fallbacks.exists(f, f.provider == 'codex-subscription')) || (has(self.allowedModels) && self.allowedModels.exists(m, m.provider == 'codex-subscription'))) && ((has(self.model) && has(self.model.provider) && self.model.provider == 'grok-subscription') || (has(self.llmPolicy) && has(self.llmPolicy.fallbacks) && self.llmPolicy.fallbacks.exists(f, f.provider == 'grok-subscription')) || (has(self.allowedModels) && self.allowedModels.exists(m, m.provider == 'grok-subscription'))))"
                  message: a Host may declare at most one oauth-broker provider
              properties:
                host:
                  type: string
                  description: >-
                    Display name for this agent, freely editable (spaces and
                    capitals allowed). It is the human-facing visible name, not an
                    identifier — the immutable RFC1123 identifier is metadata.name.
                    Length is validated by control-api (free text; no pattern here).
                contextRef:
                  type: string
                  description: Reference to the context (e.g. context1) used for MPC servers and secrets.
                secretRef:
                  type: string
                  description: >-
                    Name of the Kubernetes Secret containing static LLM API keys.
                    Required when any primary or fallback target uses
                    static-credentials. Optional for a Codex-subscription-only Host.
                channels:
                  type: array
                  description: List of CommunicationChannel names this host interacts with.
                  items:
                    type: string
                model:
                  type: object
                  description: LLM model configuration.
                  properties:
                    provider:
                      type: string
                      enum:
                        - openai
                        - claude
                        - zai
                        - bailian
                        - vertex
                        - bedrock
                        - openrouter
                        - gemini
                        - deepseek
                        - groq
                        - together
                        - fireworks
                        - mistral
                        - xai
                        - cerebras
                        - deepinfra
                        - perplexity
                        - moonshot
                        - nebius
                        - novita
                        - minimax
                        - azure
                        - codex-subscription
                        - grok-subscription
                      description: LLM provider to use.
                    name:
                      type: string
                      description: Model name (e.g. gpt-5.4-mini, claude-opus-4-7, glm-5.1).
                    connectionRef:
                      type: string
                      maxLength: 63
                      pattern: '^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$'
                      description: >-
                        Named oauth-broker subscription connection key (Codex or
                        Grok) this Host is assigned to. Absent or empty broker
                        Hosts persist unassigned and must
                        not spend a grant. Do not invent deployment-default.
                        ROLLOUT ORDER — CRD FIRST: apiextensions/v1 prunes unknown
                        fields, so this property must be applied before control-api
                        or Control UI persist spec.model.connectionRef.
                allowedModels:
                  maxItems: 32
                  # Per-host model allowlist subset (spec v2 Topic 3a). OPTIONAL,
                  # ADDITIVE: when absent or empty, the host offers the FULL global
                  # operator allowlist for its provider(s) — existing hosts are
                  # unaffected (back-compat). When set, it is the subset of the
                  # global allowlist this host offers: the per-session model
                  # selector (desktop-app, GET /v1/runtime/model[s]) and the
                  # write-time validation both restrict to this subset ∩ the live
                  # global allowlist. control-api validates every entry against the
                  # global allowlist on write — each (provider, model) pair must
                  # exist there. `provider` is a plain string (not enum'd here) so
                  # the global allowlist stays the single source of truth for valid
                  # pairs and adding a provider needn't touch a third enum.
                  type: array
                  items:
                    type: object
                    required:
                      - provider
                      - model
                    properties:
                      provider:
                        type: string
                        description: >-
                          LLM provider id; validated against the global allowlist
                          by control-api.
                      model:
                        type: string
                        description: >-
                          Model name; must exist in the global allowlist under
                          `provider`.
                llmPolicy:
                  # Provider fallback (spec v2 R5). ADDITIVE, OPT-IN: a Host with
                  # no llmPolicy behaves exactly as before (zero failover). When
                  # the primary model fails with an eligible error, mcp-host
                  # switches to the first available entry in `fallbacks`.
                  #
                  # ROLLOUT ORDER — CRD FIRST. apiextensions/v1 silently PRUNES
                  # unknown fields: if the runtime writes a Host with `llmPolicy`
                  # while the OLD CRD (without this schema) is still applied, the
                  # apiserver drops `llmPolicy` on admission with no error. Always
                  # apply this CRD before rolling out any component that reads or
                  # writes `spec.llmPolicy` (mcp-host, control-api).
                  type: object
                  description: >-
                    LLM provider fallback policy (opt-in). When the primary model
                    (spec.model) fails with an eligible error, mcp-host switches to
                    the first available entry in `fallbacks`, applies a cooldown to
                    the primary, and lazily retries it once the cooldown expires.
                    Every fallback model must be enabled in the operator allowlist
                    (validated on write by control-api).
                  required:
                    - fallbacks
                  properties:
                    cooldownSeconds:
                      type: integer
                      minimum: 0
                      default: 300
                      description: >-
                        Seconds the primary stays in cooldown after an eligible
                        failure before mcp-host lazily retries it. Default 300.
                    triggerOn:
                      type: array
                      description: >-
                        Error classes that trigger a fallback. Omit for the default
                        (all four classes). Restrict this list to avoid failing over
                        on unrecognized/transport errors (folded into
                        provider_unavailable).
                      x-kubernetes-list-type: set
                      items:
                        type: string
                        enum:
                          - insufficient_quota
                          - auth
                          - provider_unavailable
                          - rate_limited
                    fallbacks:
                      type: array
                      minItems: 1
                      maxItems: 8
                      description: >-
                        Ordered fallback list, tried in order. The engine advances
                        to the next entry when the current one also fails.
                      items:
                        type: object
                        required:
                          - provider
                          - model
                        properties:
                          provider:
                            type: string
                            enum:
                              - openai
                              - claude
                              - zai
                              - bailian
                              - vertex
                              - bedrock
                              - openrouter
                              - gemini
                              - deepseek
                              - groq
                              - together
                              - fireworks
                              - mistral
                              - xai
                              - cerebras
                              - deepinfra
                              - perplexity
                              - moonshot
                              - nebius
                              - novita
                              - minimax
                              - azure
                              - codex-subscription
                              - grok-subscription
                            description: >-
                              Fallback LLM provider. Same enum as spec.model.provider.
                          model:
                            type: string
                            description: >-
                              Fallback model name. Must be enabled in the operator
                              allowlist under `provider` (enforced on write).
                          credentialSlot:
                            type: string
                            # Defense-in-depth: mirror control-api's write-side
                            # format gate onto the CRD so a direct cluster apply
                            # (bypassing control-api) still gets a valid K8s Secret
                            # data key. Same pattern/length as SECRET_KEY_RE.
                            maxLength: 253
                            pattern: '^[-._a-zA-Z0-9]+$'
                            description: >-
                              Optional key of the Host's OWN `spec.secretRef` Secret
                              that feeds this fallback's credential (e.g. claude-api-key-fb1
                              for a same-provider-other-key fallback). mcp-host resolves
                              fallback slots from the Host secret. Absent = the provider's
                              normal slots. Existence of the key in the Secret is resolved
                              by mcp-host at runtime; control-api validates only its format
                              on write.
                approval:
                  type: object
                  description: Tool approval configuration. Controls who can approve tool executions.
                  properties:
                    defaultPolicy:
                      type: string
                      enum:
                        - cli_only
                        - channel_users
                        - designated_approvers
                      description: >-
                        Who can approve tool calls.
                        cli_only: Only HTTP /approve /deny endpoints.
                        channel_users: Any authorized channel user.
                        designated_approvers: Only users in approvers list.
                    channels:
                      type: object
                      description: Per-channel-type approval settings.
                      properties:
                        telegram:
                          type: object
                          properties:
                            enabled:
                              type: boolean
                              description: Whether Telegram users can approve.
                            approvers:
                              type: array
                              description: List of Telegram user IDs allowed to approve.
                              items:
                                type: string
                        email:
                          type: object
                          properties:
                            enabled:
                              type: boolean
                              description: Whether email users can approve.
                            approvers:
                              type: array
                              description: List of email addresses allowed to approve.
                              items:
                                type: string
                        slack:
                          type: object
                          properties:
                            enabled:
                              type: boolean
                              description: Whether Slack users can approve.
                            approvers:
                              type: array
                              description: List of Slack user IDs allowed to approve.
                              items:
                                type: string
                    tools:
                      type: object
                      description: >-
                        Per-tool approval overrides for native mcp-host tools.
                        Map of native tool name (e.g. http_request, shell_exec)
                        to boolean: true forces approval, false skips approval.
                        Absent entries fall through to each tool's built-in default.
                        Out of scope: MCP tools (gated separately).
                      additionalProperties:
                        type: boolean
                desktop:
                  type: object
                  description: Desktop environment configuration. Enables a Linux desktop (XFCE + KasmVNC) with agent-accessible X11 and browser tools.
                  properties:
                    browser:
                      type: boolean
                      description: Enable Playwright browser tools (browser_open, browser_screenshot, etc.).
                    x11:
                      type: boolean
                      description: Enable X11 desktop tools (desktop_screenshot, desktop_click, desktop_type, etc.).
                lifecycle:
                  type: object
                  description: >-
                    Runtime lifecycle configuration. Cross-field constraints
                    (no CommunicationChannels, no desktop, satisfiable
                    SharedFileSystem co-location) are enforced at reconcile
                    time via the StatelessEnableRejected status condition, not
                    by this schema.
                  properties:
                    stateless:
                      type: boolean
                      default: false
                      description: >-
                        Enable the stateless agent lifecycle. mcp-host
                        persists session state to SQLite on the workspace PVC
                        and the operator may scale the Deployment to 0 while
                        status.lifecycle.state is suspended.
                workflowControl:
                  type: object
                  description: >-
                    Workflow broker scopes this first-party Host is allowed to
                    request in its mcp-host-control JWT. control-api remains the
                    authority for every workflow request; these scopes only
                    bound the broker tool surface available to the Host runtime.
                  properties:
                    scopes:
                      type: array
                      items:
                        type: string
                        enum:
                          - workflow:list
                          - workflow:read
                          - workflow:trigger
                          - workflow:approval:resolve
                          - workflow:approval:decide
                      description: >-
                        Allowed workflow tool scopes. workflow_status and
                        workflow_health are covered by workflow:read; there is
                        no separate workflow_read native tool.
                personalization:
                  type: object
                  description: Identity files (admin-managed, read-only to the agent).
                  properties:
                    enabled:
                      type: boolean
                      description: Whether mcp-host should reconcile identity files from this block.
                    identity:
                      type: string
                      description: Content of IDENTITY.md (system-prompt section "## Identity").
                    soul:
                      type: string
                      description: Content of SOUL.md (system-prompt section "## Core Values").
                    agents:
                      type: string
                      description: Content of AGENTS.md (system-prompt section "## Agent Instructions").
                    user:
                      type: string
                      description: Content of USER.md (system-prompt section "## User Context").
                guardrails:
                  # Guardrail policy (guardrails spec §5). ADDITIVE, OPT-IN: a Host
                  # with no guardrails block behaves exactly as before — no rules, no
                  # installed hooks, no built-ins (byte-identical to prior behavior).
                  #
                  # ROLLOUT ORDER — CRD FIRST. apiextensions/v1 silently PRUNES
                  # unknown fields: if the runtime writes a Host with `guardrails`
                  # while the OLD CRD (without this schema) is applied, the apiserver
                  # drops it on admission with no error. Apply this CRD before any
                  # component reads or writes spec.guardrails (mcp-host, control-api).
                  # The loosely-typed `rules` and `builtins` entries carry
                  # x-kubernetes-preserve-unknown-fields so their nested shape (which
                  # mcp-host/control-api validate) survives admission rather than
                  # being pruned.
                  type: object
                  description: >-
                    Guardrail policy for this Host: tool-lane rules,
                    installed LlmHook references grouped by lifecycle phase,
                    first-party built-ins, and the capability/trust ceilings that
                    bound the installed hooks.
                  properties:
                    rules:
                      type: array
                      description: >-
                        Tool-lane allow/ask/deny rules. Every matching rule
                        contributes and the engine aggregates them (strictest
                        wins); array order is not precedence.
                        Each entry: { id, action: allow|ask|deny, reasonCode,
                        match{ tool, arguments[] } } — shape validated by
                        mcp-host/control-api (§6.1).
                      items:
                        type: object
                        x-kubernetes-preserve-unknown-fields: true
                    hooks:
                      type: object
                      description: >-
                        Installed LlmHook CRs this Host runs, grouped by lifecycle
                        phase. Each entry references an LlmHook CR by name (llm-hooks
                        namespace) plus the expected image digest (§8.2 resolution).
                      properties:
                        preToolUse:
                          type: array
                          items:
                            type: object
                            required:
                              - id
                            properties:
                              id:
                                type: string
                              digest:
                                type: string
                        postToolUse:
                          type: array
                          items:
                            type: object
                            required:
                              - id
                            properties:
                              id:
                                type: string
                              digest:
                                type: string
                        preCall:
                          type: array
                          items:
                            type: object
                            required:
                              - id
                            properties:
                              id:
                                type: string
                              digest:
                                type: string
                        moderate:
                          type: array
                          items:
                            type: object
                            required:
                              - id
                            properties:
                              id:
                                type: string
                              digest:
                                type: string
                        postCallSuccess:
                          type: array
                          items:
                            type: object
                            required:
                              - id
                            properties:
                              id:
                                type: string
                              digest:
                                type: string
                        onError:
                          type: array
                          items:
                            type: object
                            required:
                              - id
                            properties:
                              id:
                                type: string
                              digest:
                                type: string
                    builtins:
                      type: array
                      description: >-
                        First-party hooks compiled into mcp-host (§7.2). Each entry:
                        { type: prompt-shaping|token-trim|…, order, failMode,
                        timeoutMs, config } — shape validated by mcp-host.
                      items:
                        type: object
                        x-kubernetes-preserve-unknown-fields: true
                    minInstalledHookTrustLevel:
                      type: string
                      enum:
                        - low
                        - mid
                        - high
                      description: Minimum platform-assigned trust level an installed LlmHook must carry to run on this Host.
                    approvalPolicies:
                      type: array
                      description: >-
                        Approval policies available to guardrail `ask` decisions.
                        NOTE: overlaps conceptually with spec.approval.defaultPolicy;
                        reconciling the two is a follow-up decision.
                      items:
                        type: string
                        enum:
                          - cli_only
                          - channel_users
                          - designated_approvers
                    capabilityCeiling:
                      type: array
                      description: Upper bound on capabilities any installed hook may exercise on this Host.
                      items:
                        type: string
                        enum:
                          - may_deny
                          - may_rewrite
                          - may_substitute_result
                          - may_add_context
                    limits:
                      type: object
                      description: Guardrail sizing limits (defaults applied by mcp-host when omitted).
                      properties:
                        maxRules:
                          type: integer
                          default: 100
                        maxHooksPerPhase:
                          type: integer
                          default: 8
                        maxHookTimeoutMs:
                          type: integer
                          default: 5000
                        maxHookOutputBytes:
                          type: integer
                          default: 65536
            status:
              type: object
              properties:
                lifecycle:
                  type: object
                  description: >-
                    Durable stateless-lifecycle state. host-context-controller
                    derives Deployment replicas from state on every reconcile,
                    so a suspended Host survives controller restarts and
                    periodic resyncs.
                  required:
                    - state
                    - wakeHandledGeneration
                  properties:
                    state:
                      type: string
                      enum:
                        - active
                        - draining
                        - suspended
                    wakeHandledGeneration:
                      type: integer
                      description: Highest observed Host generation whose wake trigger has been handled.
                    reason:
                      type: string
                      description: Human-readable explanation when the stateless request was rejected.
                conditions:
                  type: array
                  items:
                    type: object
                    required:
                      - type
                      - status
                    properties:
                      type:
                        type: string
                      status:
                        type: string
                        enum:
                          - 'True'
                          - 'False'
                          - 'Unknown'
                      reason:
                        type: string
                      message:
                        type: string
                      lastTransitionTime:
                        type: string
      additionalPrinterColumns:
        - name: Host
          type: string
          jsonPath: .spec.host
        - name: Context
          type: string
          jsonPath: .spec.contextRef
        - name: Secret
          type: string
          jsonPath: .spec.secretRef
        - name: Provider
          type: string
          jsonPath: .spec.model.provider
      subresources:
        status: {}