{
  "$id": "https://docs.spinrun.ai/schemas/agent-v1.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "kind": {
      "$ref": "#/$defs/__schema0"
    },
    "id": {
      "$ref": "#/$defs/__schema1"
    },
    "slug": {
      "$ref": "#/$defs/__schema3"
    },
    "status": {
      "$ref": "#/$defs/__schema5"
    },
    "updated_at": {
      "$ref": "#/$defs/__schema7"
    },
    "name": {
      "$ref": "#/$defs/__schema9"
    },
    "description": {
      "$ref": "#/$defs/__schema10"
    },
    "icon": {
      "$ref": "#/$defs/__schema12"
    },
    "space": {
      "$ref": "#/$defs/__schema14"
    },
    "folder": {
      "$ref": "#/$defs/__schema16"
    },
    "instructions": {
      "$ref": "#/$defs/__schema18"
    },
    "model": {
      "$ref": "#/$defs/__schema19"
    },
    "max_steps": {
      "$ref": "#/$defs/__schema20"
    },
    "reasoning_effort": {
      "$ref": "#/$defs/__schema21"
    },
    "tools": {
      "$ref": "#/$defs/__schema23"
    },
    "skills": {
      "$ref": "#/$defs/__schema30"
    },
    "workspace_skills": {
      "$ref": "#/$defs/__schema31"
    },
    "workflows": {
      "$ref": "#/$defs/__schema32"
    },
    "schedule": {
      "$ref": "#/$defs/__schema33"
    },
    "email": {
      "$ref": "#/$defs/__schema42"
    },
    "whatsapp": {
      "$ref": "#/$defs/__schema55"
    },
    "triggers": {
      "$ref": "#/$defs/__schema58"
    },
    "eval_criteria": {
      "$ref": "#/$defs/__schema94"
    }
  },
  "required": [
    "kind",
    "name",
    "description",
    "icon",
    "space",
    "folder",
    "instructions",
    "model",
    "max_steps",
    "tools",
    "skills",
    "workspace_skills",
    "workflows",
    "schedule",
    "email",
    "whatsapp",
    "triggers",
    "eval_criteria"
  ],
  "description": "A whole agent as one JSON document.",
  "$defs": {
    "__schema0": {
      "type": "string",
      "const": "spinrun.agent/v1",
      "description": "Document discriminator."
    },
    "__schema1": {
      "description": "Server id. Omit when creating.",
      "$ref": "#/$defs/__schema2"
    },
    "__schema2": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "__schema3": {
      "description": "URL slug. Cannot change after creation.",
      "$ref": "#/$defs/__schema4"
    },
    "__schema4": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160,
      "description": "A human name for the thing: slug, address or id."
    },
    "__schema5": {
      "description": "Read-only lifecycle status.",
      "$ref": "#/$defs/__schema6"
    },
    "__schema6": {
      "type": "string",
      "enum": [
        "draft",
        "active",
        "archived"
      ]
    },
    "__schema7": {
      "description": "Version stamp. Required on replace; travels as If-Match too.",
      "$ref": "#/$defs/__schema8"
    },
    "__schema8": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "__schema9": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "description": "Display name."
    },
    "__schema10": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema11"
        },
        {
          "type": "null"
        }
      ],
      "description": "What the agent does."
    },
    "__schema11": {
      "type": "string",
      "maxLength": 500
    },
    "__schema12": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema13"
        },
        {
          "type": "null"
        }
      ],
      "description": "Icon preset."
    },
    "__schema13": {
      "type": "string",
      "maxLength": 40
    },
    "__schema14": {
      "type": "object",
      "properties": {
        "team": {
          "$ref": "#/$defs/__schema15"
        }
      },
      "required": [
        "team"
      ],
      "description": "Where the agent lives."
    },
    "__schema15": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema4"
        },
        {
          "type": "null"
        }
      ],
      "description": "Team slug, or null for the workspace space."
    },
    "__schema16": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema17"
        },
        {
          "type": "null"
        }
      ],
      "description": "Folder path within the space."
    },
    "__schema17": {
      "type": "string",
      "maxLength": 1000
    },
    "__schema18": {
      "type": "string",
      "maxLength": 8192,
      "description": "The system instructions."
    },
    "__schema19": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "description": "Model id, e.g. spinrun default or a named model."
    },
    "__schema20": {
      "type": "integer",
      "minimum": 1,
      "maximum": 40,
      "description": "Maximum tool steps per run."
    },
    "__schema21": {
      "description": "Absent = the model default.",
      "$ref": "#/$defs/__schema22"
    },
    "__schema22": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "low",
            "medium",
            "high"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "__schema23": {
      "type": "object",
      "properties": {
        "apps": {
          "$ref": "#/$defs/__schema24"
        },
        "connections": {
          "$ref": "#/$defs/__schema25"
        },
        "disabled_tools": {
          "$ref": "#/$defs/__schema28"
        },
        "approval": {
          "$ref": "#/$defs/__schema29"
        }
      },
      "required": [
        "apps",
        "connections",
        "disabled_tools",
        "approval"
      ],
      "description": "What the agent may touch."
    },
    "__schema24": {
      "maxItems": 50,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema4"
      },
      "description": "App slugs the agent may use."
    },
    "__schema25": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema26"
        },
        {
          "$ref": "#/$defs/__schema27"
        }
      ],
      "description": "\"all\" or explicit connection addresses."
    },
    "__schema26": {
      "type": "string",
      "const": "all"
    },
    "__schema27": {
      "minItems": 1,
      "maxItems": 200,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema4"
      }
    },
    "__schema28": {
      "maxItems": 200,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema4"
      },
      "description": "Tool slugs to hide."
    },
    "__schema29": {
      "type": "string",
      "enum": [
        "destructive",
        "write"
      ],
      "description": "Which tool calls need human approval."
    },
    "__schema30": {
      "maxItems": 50,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema4"
      },
      "description": "Marketplace skill slugs."
    },
    "__schema31": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema4"
      },
      "description": "Workspace skill names."
    },
    "__schema32": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema4"
      },
      "description": "Workflow slugs the agent may run."
    },
    "__schema33": {
      "type": "object",
      "properties": {
        "enabled": {
          "$ref": "#/$defs/__schema34"
        },
        "cron": {
          "$ref": "#/$defs/__schema36"
        },
        "timezone": {
          "$ref": "#/$defs/__schema38"
        },
        "prompt": {
          "$ref": "#/$defs/__schema40"
        }
      },
      "description": "When the agent runs on its own."
    },
    "__schema34": {
      "description": "Whether the schedule fires.",
      "$ref": "#/$defs/__schema35"
    },
    "__schema35": {
      "type": "boolean"
    },
    "__schema36": {
      "description": "Cron expression for the schedule.",
      "$ref": "#/$defs/__schema37"
    },
    "__schema37": {
      "type": "string",
      "maxLength": 120
    },
    "__schema38": {
      "description": "IANA timezone for the cron.",
      "$ref": "#/$defs/__schema39"
    },
    "__schema39": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    },
    "__schema40": {
      "description": "Prompt the scheduled run starts with.",
      "$ref": "#/$defs/__schema41"
    },
    "__schema41": {
      "type": "string",
      "maxLength": 4000
    },
    "__schema42": {
      "type": "object",
      "properties": {
        "enabled": {
          "$ref": "#/$defs/__schema43"
        },
        "allowed_senders": {
          "$ref": "#/$defs/__schema45"
        },
        "allowed_recipients": {
          "$ref": "#/$defs/__schema48"
        },
        "from_name": {
          "$ref": "#/$defs/__schema51"
        },
        "locale": {
          "$ref": "#/$defs/__schema53"
        }
      },
      "description": "The email channel."
    },
    "__schema43": {
      "description": "Whether the email channel is on.",
      "$ref": "#/$defs/__schema44"
    },
    "__schema44": {
      "type": "boolean"
    },
    "__schema45": {
      "description": "Senders the agent answers.",
      "$ref": "#/$defs/__schema46"
    },
    "__schema46": {
      "maxItems": 50,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema47"
      }
    },
    "__schema47": {
      "type": "string"
    },
    "__schema48": {
      "description": "Recipients the agent may mail.",
      "$ref": "#/$defs/__schema49"
    },
    "__schema49": {
      "maxItems": 50,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema50"
      }
    },
    "__schema50": {
      "type": "string"
    },
    "__schema51": {
      "description": "Display name on outbound mail.",
      "$ref": "#/$defs/__schema52"
    },
    "__schema52": {
      "type": "string",
      "maxLength": 80
    },
    "__schema53": {
      "description": "Locale for email rendering.",
      "$ref": "#/$defs/__schema54"
    },
    "__schema54": {
      "type": "string",
      "minLength": 2,
      "maxLength": 10
    },
    "__schema55": {
      "type": "object",
      "properties": {
        "enabled": {
          "$ref": "#/$defs/__schema56"
        }
      },
      "description": "The WhatsApp channel."
    },
    "__schema56": {
      "description": "Whether WhatsApp is on.",
      "$ref": "#/$defs/__schema57"
    },
    "__schema57": {
      "type": "boolean"
    },
    "__schema58": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "$ref": "#/$defs/AgentTrigger"
      },
      "description": "Event triggers, at most 20."
    },
    "AgentTrigger": {
      "oneOf": [
        {
          "$ref": "#/$defs/__schema59"
        },
        {
          "$ref": "#/$defs/__schema70"
        },
        {
          "$ref": "#/$defs/__schema82"
        }
      ],
      "description": "One trigger on an agent."
    },
    "__schema59": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/__schema60"
        },
        "kind": {
          "$ref": "#/$defs/__schema62"
        },
        "name": {
          "$ref": "#/$defs/__schema63"
        },
        "prompt": {
          "$ref": "#/$defs/__schema64"
        },
        "enabled": {
          "$ref": "#/$defs/__schema66"
        },
        "secret_prefix": {
          "$ref": "#/$defs/__schema68"
        }
      },
      "required": [
        "kind",
        "name"
      ],
      "description": "A webhook trigger. Its URL dies with it."
    },
    "__schema60": {
      "description": "Server-assigned trigger id. Omit when creating.",
      "$ref": "#/$defs/__schema61"
    },
    "__schema61": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "__schema62": {
      "type": "string",
      "const": "webhook",
      "description": "Trigger kind."
    },
    "__schema63": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "description": "Trigger name."
    },
    "__schema64": {
      "description": "Prompt the triggered run starts with.",
      "$ref": "#/$defs/__schema65"
    },
    "__schema65": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 4000
        },
        {
          "type": "null"
        }
      ]
    },
    "__schema66": {
      "description": "Whether the trigger fires.",
      "$ref": "#/$defs/__schema67"
    },
    "__schema67": {
      "type": "boolean"
    },
    "__schema68": {
      "description": "Read-only display prefix of the webhook secret.",
      "$ref": "#/$defs/__schema69"
    },
    "__schema69": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "__schema70": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/__schema60"
        },
        "kind": {
          "$ref": "#/$defs/__schema71"
        },
        "name": {
          "$ref": "#/$defs/__schema72"
        },
        "prompt": {
          "$ref": "#/$defs/__schema73"
        },
        "enabled": {
          "$ref": "#/$defs/__schema75"
        },
        "tool": {
          "$ref": "#/$defs/__schema77"
        },
        "args": {
          "$ref": "#/$defs/__schema78"
        },
        "cron": {
          "$ref": "#/$defs/__schema80"
        },
        "timezone": {
          "$ref": "#/$defs/__schema81"
        }
      },
      "required": [
        "kind",
        "name",
        "tool",
        "cron",
        "timezone"
      ],
      "description": "A polling trigger. The detector must be a read-only tool."
    },
    "__schema71": {
      "type": "string",
      "const": "poll",
      "description": "Trigger kind."
    },
    "__schema72": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "description": "Trigger name."
    },
    "__schema73": {
      "description": "Prompt the triggered run starts with.",
      "$ref": "#/$defs/__schema74"
    },
    "__schema74": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 4000
        },
        {
          "type": "null"
        }
      ]
    },
    "__schema75": {
      "description": "Whether the trigger fires.",
      "$ref": "#/$defs/__schema76"
    },
    "__schema76": {
      "type": "boolean"
    },
    "__schema77": {
      "description": "Read-only tool slug the poll watches with.",
      "$ref": "#/$defs/__schema4"
    },
    "__schema78": {
      "description": "Arguments for the detector tool.",
      "$ref": "#/$defs/__schema79"
    },
    "__schema79": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    },
    "__schema80": {
      "type": "string",
      "minLength": 9,
      "maxLength": 120,
      "description": "How often the detector runs."
    },
    "__schema81": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64,
      "description": "IANA timezone for the cron."
    },
    "__schema82": {
      "type": "object",
      "properties": {
        "id": {
          "$ref": "#/$defs/__schema60"
        },
        "kind": {
          "$ref": "#/$defs/__schema83"
        },
        "name": {
          "$ref": "#/$defs/__schema84"
        },
        "prompt": {
          "$ref": "#/$defs/__schema85"
        },
        "enabled": {
          "$ref": "#/$defs/__schema87"
        },
        "app": {
          "$ref": "#/$defs/__schema89"
        },
        "event": {
          "$ref": "#/$defs/__schema90"
        },
        "connection": {
          "$ref": "#/$defs/__schema91"
        },
        "config": {
          "$ref": "#/$defs/__schema92"
        }
      },
      "required": [
        "kind",
        "name",
        "app",
        "event",
        "connection"
      ],
      "description": "An app-event trigger."
    },
    "__schema83": {
      "type": "string",
      "const": "app_event",
      "description": "Trigger kind."
    },
    "__schema84": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "description": "Trigger name."
    },
    "__schema85": {
      "description": "Prompt the triggered run starts with.",
      "$ref": "#/$defs/__schema86"
    },
    "__schema86": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 4000
        },
        {
          "type": "null"
        }
      ]
    },
    "__schema87": {
      "description": "Whether the trigger fires.",
      "$ref": "#/$defs/__schema88"
    },
    "__schema88": {
      "type": "boolean"
    },
    "__schema89": {
      "description": "App slug the event belongs to.",
      "$ref": "#/$defs/__schema4"
    },
    "__schema90": {
      "description": "Event slug within the app.",
      "$ref": "#/$defs/__schema4"
    },
    "__schema91": {
      "description": "Connection address, e.g. github__main.",
      "$ref": "#/$defs/__schema4"
    },
    "__schema92": {
      "description": "Trigger configuration.",
      "$ref": "#/$defs/__schema93"
    },
    "__schema93": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    },
    "__schema94": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema95"
        },
        {
          "type": "null"
        }
      ],
      "description": "How a run is judged."
    },
    "__schema95": {
      "type": "string",
      "maxLength": 4000
    }
  }
}
