{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://toolhouse.ai/schemas/toolhouse/agent.json",
  "title": "Toolhouse Agent",
  "description": "Represents an AI agent in the Toolhouse platform, including its configuration, tools, schedules, and execution metadata.",
  "type": "object",
  "required": ["agentId", "name", "type"],
  "properties": {
    "agentId": {
      "type": "string",
      "description": "Unique identifier for the agent (UUID format).",
      "format": "uuid"
    },
    "name": {
      "type": "string",
      "description": "Human-readable name of the agent.",
      "minLength": 1
    },
    "description": {
      "type": "string",
      "description": "Detailed description of what the agent does."
    },
    "type": {
      "type": "string",
      "description": "The type of entity this schema represents.",
      "enum": ["agent", "tool", "schedule", "bundle"]
    },
    "slug": {
      "type": "string",
      "description": "URL-friendly vanity slug for the agent."
    },
    "model": {
      "type": "string",
      "description": "The LLM model used by the agent (e.g., gpt-4, claude-3)."
    },
    "system_prompt": {
      "type": "string",
      "description": "System prompt that defines the agent's behavior and personality."
    },
    "is_public": {
      "type": "boolean",
      "description": "Whether the agent is publicly accessible without authentication.",
      "default": false
    },
    "tools": {
      "$ref": "#/$defs/ToolSet",
      "description": "Collection of tools available to the agent."
    },
    "bundles": {
      "type": "array",
      "description": "Tool bundles assigned to the agent.",
      "items": {
        "$ref": "#/$defs/Bundle"
      }
    },
    "files": {
      "type": "array",
      "description": "Files attached to the agent for RAG or reference.",
      "items": {
        "$ref": "#/$defs/AgentFile"
      }
    },
    "schedule": {
      "$ref": "#/$defs/Schedule",
      "description": "Scheduled execution configuration for the agent."
    },
    "auth_required": {
      "type": "boolean",
      "description": "Whether Bearer token authentication is required to invoke the agent.",
      "default": true
    },
    "tags": {
      "type": "array",
      "description": "Categorization tags for the agent.",
      "items": {
        "type": "string"
      }
    },
    "theme": {
      "$ref": "#/$defs/ThemePreference",
      "description": "Visual theme customization for the agent."
    },
    "monetization": {
      "$ref": "#/$defs/Monetization",
      "description": "Monetization settings for the agent."
    }
  },
  "$defs": {
    "ToolSet": {
      "type": "object",
      "description": "A collection of tools available to an agent.",
      "properties": {
        "installed": {
          "type": "array",
          "description": "List of tools installed and available for the agent.",
          "items": {
            "$ref": "#/$defs/Tool"
          }
        }
      }
    },
    "Tool": {
      "type": "object",
      "description": "A single tool that can be executed by an agent.",
      "required": ["toolId", "name"],
      "properties": {
        "toolId": {
          "type": "string",
          "description": "Unique identifier for the tool."
        },
        "name": {
          "type": "string",
          "description": "Human-readable name of the tool.",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "description": "Description of what the tool does."
        },
        "category": {
          "type": "string",
          "description": "Category the tool belongs to."
        },
        "inputs": {
          "$ref": "#/$defs/InputSchema",
          "description": "JSON Schema describing the tool's input parameters."
        }
      }
    },
    "Bundle": {
      "type": "object",
      "description": "A named collection of tools grouped together.",
      "required": ["bundleId", "name"],
      "properties": {
        "bundleId": {
          "type": "string",
          "description": "Unique identifier for the bundle."
        },
        "name": {
          "type": "string",
          "description": "Name of the bundle."
        },
        "description": {
          "type": "string",
          "description": "Description of the bundle's purpose."
        },
        "tools": {
          "type": "array",
          "description": "Tools included in this bundle.",
          "items": {
            "$ref": "#/$defs/Tool"
          }
        }
      }
    },
    "AgentFile": {
      "type": "object",
      "description": "A file attached to an agent.",
      "required": ["fileId"],
      "properties": {
        "fileId": {
          "type": "string",
          "description": "Unique identifier for the file."
        },
        "name": {
          "type": "string",
          "description": "File name."
        },
        "position": {
          "type": "integer",
          "description": "Display position of the file."
        }
      }
    },
    "Schedule": {
      "type": "object",
      "description": "Scheduled execution configuration using cron expressions.",
      "properties": {
        "scheduleId": {
          "type": "string",
          "description": "Unique identifier for the schedule."
        },
        "cron_expression": {
          "type": "string",
          "description": "Cron expression defining the execution schedule."
        },
        "is_active": {
          "type": "boolean",
          "description": "Whether the schedule is currently active.",
          "default": true
        }
      }
    },
    "ThemePreference": {
      "type": "object",
      "description": "Visual theme customization for the agent UI.",
      "properties": {
        "theme": {
          "type": "string",
          "description": "Theme identifier or configuration."
        }
      }
    },
    "Monetization": {
      "type": "object",
      "description": "Monetization configuration for a paid agent.",
      "properties": {
        "is_monetized": {
          "type": "boolean",
          "description": "Whether the agent charges for access."
        },
        "price": {
          "type": "number",
          "description": "Subscription price for the agent."
        },
        "subscriber_count": {
          "type": "integer",
          "description": "Number of active subscribers."
        }
      }
    },
    "InputSchema": {
      "type": "object",
      "description": "Schema describing the input parameters for a tool or operation.",
      "properties": {
        "type": {
          "type": "string",
          "const": "object"
        },
        "required": {
          "type": "array",
          "description": "List of required input parameter names.",
          "items": {
            "type": "string"
          }
        },
        "properties": {
          "type": "object",
          "description": "Map of parameter names to their type definitions.",
          "additionalProperties": {
            "$ref": "#/$defs/InputParameter"
          }
        }
      }
    },
    "InputParameter": {
      "type": "object",
      "description": "Definition of a single input parameter.",
      "properties": {
        "type": {
          "type": "string",
          "description": "The data type of the parameter.",
          "enum": ["string", "integer", "number", "boolean", "array", "object"]
        },
        "description": {
          "type": "string",
          "description": "Human-readable description of the parameter."
        },
        "enum": {
          "type": "array",
          "description": "Allowed values for the parameter."
        },
        "default": {
          "description": "Default value for the parameter when not provided."
        },
        "format": {
          "type": "string",
          "description": "Format hint for the parameter value, such as 'email', 'uri', or 'date-time'."
        }
      }
    }
  }
}
