{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://api-evangelist.github.io/warp/json-schema/warp-run-schema.json",
  "title": "RunItem",
  "description": "Represents a Warp Oz cloud agent run, including its state, metadata, and execution details.",
  "type": "object",
  "required": ["run_id", "task_id", "title", "state", "prompt", "created_at", "updated_at"],
  "properties": {
    "run_id": {
      "type": "string",
      "description": "Unique identifier for the run"
    },
    "task_id": {
      "type": "string",
      "description": "Unique identifier for the task (typically matches run_id). Deprecated — use run_id instead.",
      "deprecated": true
    },
    "title": {
      "type": "string",
      "description": "Human-readable title for the run"
    },
    "state": {
      "type": "string",
      "description": "Current state of the run",
      "enum": ["queued", "running", "completed", "failed", "cancelled", "paused"]
    },
    "execution_location": {
      "type": "string",
      "description": "Where the run is being executed (cloud or self-hosted)"
    },
    "prompt": {
      "type": "string",
      "description": "The prompt/instruction given to the agent"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the run was created (RFC3339)"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Timestamp when the run was last updated (RFC3339)"
    },
    "started_at": {
      "type": ["string", "null"],
      "format": "date-time",
      "description": "Timestamp when the agent started working on the run (RFC3339)"
    },
    "run_time": {
      "type": "string",
      "format": "duration",
      "description": "Total runtime as an ISO 8601 duration (e.g. PT2M30S)"
    },
    "status_message": {
      "type": "object",
      "description": "Human-readable status message for the run",
      "properties": {
        "message": { "type": "string" },
        "timestamp": { "type": "string", "format": "date-time" }
      }
    },
    "source": {
      "type": "string",
      "description": "How the run was triggered",
      "enum": ["api", "cli", "terminal", "schedule", "webhook", "slack", "github"]
    },
    "session_id": {
      "type": "string",
      "description": "UUID of the shared session (if available)"
    },
    "session_link": {
      "type": "string",
      "format": "uri",
      "description": "URL to view the agent session"
    },
    "trigger_url": {
      "type": "string",
      "format": "uri",
      "description": "URL to the run trigger (e.g. Slack thread, Linear issue, schedule)"
    },
    "conversation_id": {
      "type": "string",
      "description": "UUID of the conversation associated with the run"
    },
    "creator": {
      "type": "object",
      "description": "Information about who created the run",
      "properties": {
        "user_id": { "type": "string" },
        "email": { "type": "string", "format": "email" },
        "display_name": { "type": "string" }
      }
    },
    "executor": {
      "type": "object",
      "description": "Information about who executed the run (may differ from creator for agent identities)",
      "properties": {
        "user_id": { "type": "string" },
        "email": { "type": "string", "format": "email" },
        "display_name": { "type": "string" }
      }
    },
    "request_usage": {
      "type": "object",
      "description": "Token and cost usage for the run",
      "properties": {
        "input_tokens": { "type": "integer" },
        "output_tokens": { "type": "integer" },
        "total_cost_usd": { "type": "number" }
      }
    },
    "schedule": {
      "type": "object",
      "description": "Schedule information if the run was triggered by a schedule",
      "properties": {
        "schedule_id": { "type": "string" },
        "cron": { "type": "string" },
        "next_run_at": { "type": "string", "format": "date-time" }
      }
    }
  }
}
