{
  "$id": "https://echo.cc/schemas/config.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Version 1. Active profile/endpoint references must exist. openai-compatible requires an explicit base_url and model. Run ecc config validate for cross-field validation.",
  "properties": {
    "active_profile": {
      "type": "string"
    },
    "ai": {
      "additionalProperties": false,
      "properties": {
        "active_endpoint": {
          "type": "string"
        },
        "endpoints": {
          "additionalProperties": {
            "additionalProperties": false,
            "properties": {
              "api_key_file": {
                "description": "Absolute path or a path relative to this configuration file.",
                "minLength": 1,
                "type": "string"
              },
              "base_url": {
                "description": "No embedded credentials, query or fragment.",
                "format": "uri",
                "minLength": 1,
                "type": "string"
              },
              "model": {
                "type": "string"
              },
              "provider": {
                "type": "string"
              },
              "timeout": {
                "description": "Positive Go duration, for example 500ms or 90s.",
                "minLength": 1,
                "type": "string"
              }
            },
            "required": [
              "provider"
            ],
            "type": "object"
          },
          "type": "object"
        }
      },
      "type": "object"
    },
    "dashboard": {
      "additionalProperties": false,
      "properties": {
        "listen": {
          "type": "string"
        },
        "token_file": {
          "description": "Absolute path or a path relative to this configuration file.",
          "minLength": 1,
          "type": "string"
        }
      },
      "type": "object"
    },
    "hooks": {
      "additionalProperties": false,
      "properties": {
        "holds": {
          "enum": [
            "advisory",
            "enforce"
          ],
          "minLength": 1,
          "type": "string"
        },
        "mid_turn": {
          "enum": [
            "off",
            "on"
          ],
          "minLength": 1,
          "type": "string"
        },
        "subscribe": {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "limits": {
      "additionalProperties": false,
      "properties": {
        "dedupe_window": {
          "description": "Positive Go duration, for example 500ms or 90s.",
          "minLength": 1,
          "type": "string"
        },
        "drive_frame_bytes": {
          "maximum": 16777216,
          "minimum": 1024,
          "type": "integer"
        },
        "drive_write_timeout_ms": {
          "maximum": 60000,
          "minimum": 100,
          "type": "integer"
        },
        "hook_grace": {
          "description": "Positive Go duration, for example 500ms or 90s.",
          "minLength": 1,
          "type": "string"
        },
        "hook_start_grace": {
          "description": "Positive Go duration, for example 500ms or 90s.",
          "minLength": 1,
          "type": "string"
        },
        "max_hops": {
          "minimum": 1,
          "type": "integer"
        },
        "pair_limit": {
          "minimum": 1,
          "type": "integer"
        },
        "pair_window": {
          "description": "Positive Go duration, for example 500ms or 90s.",
          "minLength": 1,
          "type": "string"
        },
        "peer_storage_bytes": {
          "maximum": 17179869184,
          "minimum": 8388608,
          "type": "integer"
        },
        "send_burst": {
          "minimum": 1,
          "type": "integer"
        },
        "send_rate": {
          "exclusiveMinimum": 0,
          "type": "number"
        },
        "wake_poll": {
          "description": "Positive Go duration, for example 500ms or 90s.",
          "minLength": 1,
          "type": "string"
        },
        "wake_rate": {
          "minimum": 1,
          "type": "number"
        }
      },
      "type": "object"
    },
    "logging": {
      "additionalProperties": false,
      "properties": {
        "file": {
          "description": "Absolute path or a path relative to this configuration file.",
          "minLength": 1,
          "type": "string"
        },
        "format": {
          "enum": [
            "text",
            "json"
          ],
          "minLength": 1,
          "type": "string"
        },
        "level": {
          "enum": [
            "debug",
            "info",
            "warn",
            "error"
          ],
          "minLength": 1,
          "type": "string"
        }
      },
      "type": "object"
    },
    "metrics": {
      "additionalProperties": false,
      "properties": {
        "enabled": {
          "type": "boolean"
        }
      },
      "type": "object"
    },
    "profiles": {
      "additionalProperties": {
        "additionalProperties": false,
        "properties": {
          "credentials_file": {
            "description": "Absolute path or a path relative to this configuration file.",
            "minLength": 1,
            "type": "string"
          },
          "net": {
            "minLength": 1,
            "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
            "type": "string"
          },
          "org": {
            "type": "string"
          },
          "password_file": {
            "description": "Absolute path or a path relative to this configuration file.",
            "minLength": 1,
            "type": "string"
          },
          "security": {
            "additionalProperties": false,
            "properties": {
              "allow_insecure": {
                "type": "boolean"
              },
              "authority_public_key": {
                "minLength": 1,
                "pattern": "^[a-fA-F0-9]{64}$",
                "type": "string"
              },
              "encryption": {
                "enum": [
                  "off",
                  "required"
                ],
                "minLength": 1,
                "type": "string"
              },
              "operator_dir": {
                "description": "Absolute path or a path relative to this configuration file.",
                "minLength": 1,
                "type": "string"
              },
              "operator_service": {
                "type": "boolean"
              },
              "rbac": {
                "enum": [
                  "advisory",
                  "enforce",
                  "strict",
                  "off"
                ],
                "minLength": 1,
                "type": "string"
              }
            },
            "type": "object"
          },
          "server": {
            "description": "No embedded credentials, query or fragment.",
            "format": "uri",
            "minLength": 1,
            "type": "string"
          },
          "tls": {
            "additionalProperties": false,
            "properties": {
              "ca_file": {
                "description": "Absolute path or a path relative to this configuration file.",
                "minLength": 1,
                "type": "string"
              },
              "certificate_file": {
                "description": "Absolute path or a path relative to this configuration file.",
                "minLength": 1,
                "type": "string"
              },
              "enabled": {
                "type": "boolean"
              },
              "key_file": {
                "description": "Absolute path or a path relative to this configuration file.",
                "minLength": 1,
                "type": "string"
              }
            },
            "type": "object"
          },
          "token_file": {
            "description": "Absolute path or a path relative to this configuration file.",
            "minLength": 1,
            "type": "string"
          },
          "type": {
            "enum": [
              "self-hosted",
              "hosted"
            ],
            "minLength": 1,
            "type": "string"
          },
          "user": {
            "type": "string"
          }
        },
        "required": [
          "type",
          "server",
          "net"
        ],
        "type": "object"
      },
      "type": "object"
    },
    "quota": {
      "additionalProperties": false,
      "properties": {
        "run_pool_by_tool": {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        }
      },
      "type": "object"
    },
    "state": {
      "additionalProperties": false,
      "properties": {
        "directory": {
          "description": "Absolute path or a path relative to this configuration file.",
          "minLength": 1,
          "type": "string"
        },
        "host": {
          "minLength": 1,
          "pattern": "^[a-z0-9][a-z0-9-]{0,62}$",
          "type": "string"
        }
      },
      "type": "object"
    },
    "updates": {
      "additionalProperties": false,
      "properties": {
        "check": {
          "enum": [
            "manual",
            "scheduled"
          ],
          "minLength": 1,
          "type": "string"
        },
        "interval": {
          "description": "Positive Go duration, for example 500ms or 90s.",
          "minLength": 1,
          "type": "string"
        },
        "offline": {
          "type": "boolean"
        },
        "pin": {
          "minLength": 1,
          "pattern": "^v(0|[1-9][0-9]{0,9})\\.(0|[1-9][0-9]{0,9})\\.(0|[1-9][0-9]{0,9})@[a-f0-9]{40}$",
          "type": "string"
        },
        "source": {
          "description": "An https URL, a file:// URL, or a path relative to this configuration file.",
          "minLength": 1,
          "type": "string"
        }
      },
      "type": "object"
    },
    "version": {
      "const": 1,
      "type": "integer"
    }
  },
  "required": [
    "version",
    "active_profile",
    "profiles"
  ],
  "title": "echo.cc operator configuration",
  "type": "object"
}
