{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "fvcms.cms-local.ai.001",
  "title": "Local CMS Module — AI Config",
  "description": "Per-app AI agent config. The AI agent lives in the chrome (per FvCMS Pact §3.11-§3.14). Local app can override the model, system prompt, and tool allowlist.",
  "type": "object",
  "required": ["schema"],
  "properties": {
    "schema": { "const": "fvcms.cms-local.ai.001" },
    "model": {
      "type": "object",
      "description": "LLM model + provider",
      "properties": {
        "provider": { "type": "string", "enum": ["openai", "anthropic", "google", "local", "glm"] },
        "name":     { "type": "string" },
        "temperature": { "type": "number", "minimum": 0, "maximum": 2 },
        "maxTokens":   { "type": "integer", "minimum": 1 }
      }
    },
    "systemPrompt": { "type": "string" },
    "tools": {
      "type": "object",
      "description": "Tool allowlist + per-tool config",
      "additionalProperties": true
    },
    "rateLimit": {
      "type": "object",
      "properties": {
        "requestsPerMinute": { "type": "integer" },
        "tokensPerDay":      { "type": "integer" }
      }
    },
    "fallback": {
      "type": "object",
      "description": "What to do when the AI fails",
      "properties": {
        "model": { "type": "string" },
        "action": { "type": "string", "enum": ["retry", "queue", "defer", "abort"] }
      }
    }
  },
  "additionalProperties": true
}
