{
  "$id": "https://docs.spinrun.ai/schemas/workflow-v1.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "kind": {
      "$ref": "#/$defs/__schema0"
    },
    "slug": {
      "$ref": "#/$defs/__schema1"
    },
    "name": {
      "$ref": "#/$defs/__schema2"
    },
    "description": {
      "$ref": "#/$defs/__schema3"
    },
    "enabled": {
      "$ref": "#/$defs/__schema5"
    },
    "updated_at": {
      "$ref": "#/$defs/__schema6"
    },
    "space": {
      "$ref": "#/$defs/__schema8"
    },
    "send_as": {
      "$ref": "#/$defs/__schema11"
    },
    "inputs": {
      "$ref": "#/$defs/__schema13"
    },
    "schedule": {
      "$ref": "#/$defs/__schema20"
    },
    "steps": {
      "$ref": "#/$defs/__schema22"
    },
    "output": {
      "$ref": "#/$defs/__schema39"
    }
  },
  "required": [
    "kind",
    "slug",
    "name",
    "description",
    "enabled",
    "space",
    "send_as",
    "inputs",
    "schedule",
    "steps",
    "output"
  ],
  "description": "A whole workflow as one JSON document.",
  "$defs": {
    "__schema0": {
      "type": "string",
      "const": "spinrun.workflow/v1",
      "description": "Document discriminator."
    },
    "__schema1": {
      "type": "string",
      "maxLength": 80,
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
      "description": "URL slug. Cannot change after creation."
    },
    "__schema2": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "description": "Display name."
    },
    "__schema3": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema4"
        },
        {
          "type": "null"
        }
      ],
      "description": "What the workflow does."
    },
    "__schema4": {
      "type": "string",
      "maxLength": 500
    },
    "__schema5": {
      "type": "boolean",
      "description": "Whether the workflow runs."
    },
    "__schema6": {
      "description": "Version stamp. Required on replace.",
      "$ref": "#/$defs/__schema7"
    },
    "__schema7": {
      "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))$"
    },
    "__schema8": {
      "type": "object",
      "properties": {
        "team": {
          "$ref": "#/$defs/__schema9"
        }
      },
      "required": [
        "team"
      ],
      "description": "Where the workflow lives."
    },
    "__schema9": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema10"
        },
        {
          "type": "null"
        }
      ],
      "description": "Team slug, or null."
    },
    "__schema10": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    },
    "__schema11": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema12"
        },
        {
          "type": "null"
        }
      ],
      "description": "Identity runs send as."
    },
    "__schema12": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    },
    "__schema13": {
      "type": "object",
      "propertyNames": {
        "$ref": "#/$defs/__schema14"
      },
      "additionalProperties": {
        "$ref": "#/$defs/__schema15"
      },
      "description": "Inputs with optional defaults."
    },
    "__schema14": {
      "type": "string",
      "maxLength": 40,
      "pattern": "^[a-z0-9_]+$",
      "description": "Input name."
    },
    "__schema15": {
      "type": "object",
      "properties": {
        "description": {
          "$ref": "#/$defs/__schema16"
        },
        "default": {
          "$ref": "#/$defs/__schema18"
        }
      },
      "description": "One workflow input."
    },
    "__schema16": {
      "description": "What the input is for.",
      "$ref": "#/$defs/__schema17"
    },
    "__schema17": {
      "type": "string",
      "maxLength": 200
    },
    "__schema18": {
      "description": "Default value.",
      "$ref": "#/$defs/__schema19"
    },
    "__schema19": {},
    "__schema20": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema21"
        },
        {
          "type": "null"
        }
      ],
      "description": "Optional schedule."
    },
    "__schema21": {
      "type": "object",
      "properties": {
        "cron": {
          "type": "string",
          "minLength": 9,
          "maxLength": 120,
          "description": "Cron expression."
        },
        "timezone": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "description": "IANA timezone."
        }
      },
      "required": [
        "cron",
        "timezone"
      ]
    },
    "__schema22": {
      "minItems": 1,
      "maxItems": 10,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema23"
      },
      "description": "One to ten steps."
    },
    "__schema23": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "$ref": "#/$defs/__schema24"
            },
            "kind": {
              "$ref": "#/$defs/__schema25"
            },
            "tool": {
              "$ref": "#/$defs/__schema26"
            },
            "args": {
              "$ref": "#/$defs/__schema27"
            },
            "after": {
              "$ref": "#/$defs/__schema29"
            },
            "note": {
              "$ref": "#/$defs/__schema31"
            }
          },
          "required": [
            "id",
            "kind",
            "tool"
          ],
          "description": "One tool call in a workflow."
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "$ref": "#/$defs/__schema24"
            },
            "kind": {
              "$ref": "#/$defs/__schema33"
            },
            "agent": {
              "$ref": "#/$defs/__schema34"
            },
            "args": {
              "$ref": "#/$defs/__schema35"
            },
            "after": {
              "$ref": "#/$defs/__schema37"
            },
            "note": {
              "$ref": "#/$defs/__schema31"
            }
          },
          "required": [
            "id",
            "kind",
            "agent",
            "args"
          ],
          "description": "One agent call in a workflow."
        }
      ]
    },
    "__schema24": {
      "type": "string",
      "maxLength": 40,
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
      "description": "Step handle a later step references."
    },
    "__schema25": {
      "type": "string",
      "const": "tool",
      "description": "Step kind."
    },
    "__schema26": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "description": "Tool slug to call."
    },
    "__schema27": {
      "default": {},
      "description": "Arguments for the tool.",
      "$ref": "#/$defs/__schema28"
    },
    "__schema28": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    },
    "__schema29": {
      "default": [],
      "description": "Steps this one waits for.",
      "$ref": "#/$defs/__schema30"
    },
    "__schema30": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema24"
      }
    },
    "__schema31": {
      "description": "Author note, not executed.",
      "$ref": "#/$defs/__schema32"
    },
    "__schema32": {
      "type": "string",
      "maxLength": 300
    },
    "__schema33": {
      "type": "string",
      "const": "agent",
      "description": "Step kind."
    },
    "__schema34": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160,
      "description": "Agent slug or id to run."
    },
    "__schema35": {
      "type": "object",
      "properties": {
        "prompt": {
          "$ref": "#/$defs/__schema36"
        }
      },
      "required": [
        "prompt"
      ],
      "additionalProperties": false,
      "description": "The agent's input."
    },
    "__schema36": {
      "type": "string",
      "minLength": 1,
      "description": "Prompt for the agent."
    },
    "__schema37": {
      "default": [],
      "description": "Steps this one waits for.",
      "$ref": "#/$defs/__schema38"
    },
    "__schema38": {
      "maxItems": 10,
      "type": "array",
      "items": {
        "$ref": "#/$defs/__schema24"
      }
    },
    "__schema39": {
      "anyOf": [
        {
          "$ref": "#/$defs/__schema40"
        },
        {
          "type": "null"
        }
      ],
      "description": "Which step's output is the workflow's output."
    },
    "__schema40": {
      "type": "string"
    }
  }
}
