{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "ace://schemas/runtime-tool-spec-registry/1.0.0",
  "title": "ACE Runtime Tool Spec Registry",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "version",
    "updated_at",
    "tools"
  ],
  "properties": {
    "version": {
      "type": "integer",
      "const": 1
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "tools": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/tool_spec"
      }
    }
  },
  "$defs": {
    "scalar_enum_item": {
      "type": [
        "string",
        "number",
        "boolean",
        "null"
      ]
    },
    "schema_node": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "object",
            "array",
            "string",
            "number",
            "integer",
            "boolean",
            "null"
          ]
        },
        "description": {
          "type": "string"
        },
        "enum": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/scalar_enum_item"
          }
        },
        "properties": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/schema_node"
          }
        },
        "required": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "additionalProperties": {
          "type": "boolean"
        },
        "items": {
          "$ref": "#/$defs/schema_node"
        }
      }
    },
    "executor": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "command"
      ],
      "properties": {
        "command": {
          "type": "string",
          "minLength": 1
        },
        "cwd": {
          "type": "string"
        },
        "timeout_ms": {
          "type": "integer",
          "minimum": 1
        },
        "env": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    },
    "tool_spec": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "description",
        "input_schema",
        "executor"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "input_schema": {
          "$ref": "#/$defs/schema_node"
        },
        "success_schema": {
          "$ref": "#/$defs/schema_node"
        },
        "failure_schema": {
          "$ref": "#/$defs/schema_node"
        },
        "executor": {
          "$ref": "#/$defs/executor"
        }
      }
    }
  }
}
