{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://omni.local/contracts/route.schema.json",
  "title": "OMNI Route Contract v1",
  "description": "Request and decision objects used by the deterministic-first intent router.",
  "oneOf": [
    {
      "$ref": "#/$defs/RouteRequest"
    },
    {
      "$ref": "#/$defs/RouteDecision"
    }
  ],
  "$defs": {
    "RouteRequest": {
      "title": "RouteRequest",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "text"
      ],
      "properties": {
        "text": {
          "type": "string",
          "minLength": 1,
          "maxLength": 32000
        },
        "needs_vision": {
          "type": "boolean",
          "default": false
        },
        "language": {
          "oneOf": [
            {
              "type": "string",
              "minLength": 2,
              "maxLength": 24
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      }
    },
    "RouteDecision": {
      "title": "RouteDecision",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "route",
        "confidence",
        "needs_vision",
        "risk",
        "reason_code",
        "ack"
      ],
      "properties": {
        "route": {
          "enum": [
            "dialogue",
            "hermes",
            "video",
            "image",
            "cancel",
            "clarify"
          ]
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "needs_vision": {
          "type": "boolean"
        },
        "risk": {
          "enum": [
            "low",
            "medium",
            "high"
          ]
        },
        "reason_code": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "pattern": "^[a-z][a-z0-9_]*$"
        },
        "ack": {
          "type": "string",
          "minLength": 1,
          "maxLength": 240
        }
      }
    }
  },
  "examples": [
    {
      "text": "Öffne den Browser und korrigiere den Code.",
      "needs_vision": true,
      "language": "de"
    },
    {
      "route": "hermes",
      "confidence": 0.97,
      "needs_vision": true,
      "risk": "medium",
      "reason_code": "computer_action",
      "ack": "Ich kümmere mich darum."
    }
  ]
}
