{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codai-ro/json-schema/codai-ro-prompt-schema.json",
  "title": "Prompt",
  "description": "A pending prompt. Timestamps are ISO strings or `null`.",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codai-ro-gateway-openapi.yml#/components/schemas/Prompt",
  "type": "object",
  "required": [
    "id",
    "title",
    "prompt",
    "status",
    "source",
    "repo",
    "tracker",
    "goal_key",
    "not_before",
    "auto_run",
    "target_device_id",
    "origin",
    "notified_at",
    "launched_at",
    "run_session_id",
    "done_at",
    "sent_at",
    "answered_at",
    "verified_at",
    "match_ref",
    "match_turn_id",
    "match_score",
    "base_sha",
    "head_sha",
    "report",
    "report_at",
    "created_at",
    "updated_at",
    "tags",
    "priority",
    "recurrence",
    "next_prompt_id",
    "launch",
    "is_template"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "title": {
      "type": "string",
      "description": "Defaults to the first line of the prompt (max 120 chars)."
    },
    "prompt": {
      "type": "string"
    },
    "status": {
      "$ref": "#/$defs/PromptStatus"
    },
    "source": {
      "$ref": "#/$defs/PromptSource"
    },
    "repo": {
      "type": [
        "string",
        "null"
      ]
    },
    "tracker": {
      "type": [
        "string",
        "null"
      ]
    },
    "goal_key": {
      "type": [
        "string",
        "null"
      ]
    },
    "not_before": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "The prompt is due from this moment on."
    },
    "auto_run": {
      "type": "boolean"
    },
    "target_device_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "origin": {
      "type": "object",
      "additionalProperties": true
    },
    "notified_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the due reminder was sent."
    },
    "launched_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "run_session_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "done_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "sent_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the prompt was seen sent in a chat."
    },
    "answered_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the chat turn that carried it ended."
    },
    "verified_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When a report first judged it done."
    },
    "match_ref": {
      "type": [
        "string",
        "null"
      ],
      "description": "Session id or key the prompt was sent in."
    },
    "match_turn_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Turn id of that chat turn."
    },
    "match_score": {
      "type": [
        "number",
        "null"
      ],
      "description": "Match confidence, 0–1."
    },
    "base_sha": {
      "type": [
        "string",
        "null"
      ],
      "description": "Repository HEAD when sent."
    },
    "head_sha": {
      "type": [
        "string",
        "null"
      ],
      "description": "Repository HEAD at the last verification."
    },
    "report": {
      "oneOf": [
        {
          "$ref": "#/$defs/PromptReport"
        },
        {
          "type": "null"
        }
      ],
      "description": "Last verification report, or `null`."
    },
    "report_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When `report` was produced."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Lowercased, deduplicated tags (max 20)."
    },
    "priority": {
      "type": "integer",
      "minimum": 0,
      "maximum": 3,
      "description": "0 none, 1 low, 2 normal, 3 high."
    },
    "recurrence": {
      "oneOf": [
        {
          "$ref": "#/$defs/PromptRecurrence"
        },
        {
          "type": "null"
        }
      ],
      "description": "Repeat rule, or `null`."
    },
    "next_prompt_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Prompt opened when this one becomes `done`."
    },
    "launch": {
      "oneOf": [
        {
          "$ref": "#/$defs/PromptLaunchConfig"
        },
        {
          "type": "null"
        }
      ],
      "description": "Launch preset, or `null`."
    },
    "is_template": {
      "type": "boolean",
      "description": "Template prompts are hidden from the default list and never notified or auto-run."
    }
  },
  "$defs": {
    "PromptLaunchConfig": {
      "type": "object",
      "additionalProperties": false,
      "description": "Preset used when the prompt is launched.",
      "properties": {
        "agent": {
          "type": "string",
          "maxLength": 200,
          "description": "Agent to run it with."
        },
        "model": {
          "type": "string",
          "maxLength": 200,
          "description": "Model to use."
        },
        "folder": {
          "type": "string",
          "maxLength": 200,
          "description": "Working folder."
        }
      }
    },
    "PromptRecurrence": {
      "description": "`{ every: day | week | month, at?: HH:MM }` (UTC): once the prompt left `open`, its next occurrence is created\nas a new `open` prompt due at the next slot (months keep the day, clamped to the month end).\n`{ on: session_end }`: the prompt is reopened when the session it ran in (or was captured from) ends a turn.\n",
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "every"
          ],
          "properties": {
            "every": {
              "type": "string",
              "enum": [
                "day",
                "week",
                "month"
              ]
            },
            "at": {
              "type": "string",
              "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$",
              "description": "Time of day, HH:MM UTC."
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "on"
          ],
          "properties": {
            "on": {
              "type": "string",
              "enum": [
                "session_end"
              ]
            }
          }
        }
      ]
    },
    "PromptReport": {
      "type": "object",
      "description": "LLM verification report of a prompt.",
      "required": [
        "verdict",
        "summary",
        "changed",
        "remaining",
        "evidence",
        "model",
        "at"
      ],
      "properties": {
        "verdict": {
          "type": "string",
          "enum": [
            "done",
            "partial",
            "not_started"
          ]
        },
        "summary": {
          "type": "string",
          "description": "Short summary in the language of the prompt."
        },
        "changed": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "What the chat evidently did."
        },
        "remaining": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "What is still missing."
        },
        "evidence": {
          "type": "string",
          "enum": [
            "transcript+diff",
            "transcript",
            "diff"
          ]
        },
        "model": {
          "type": "string",
          "description": "Model alias that produced the report."
        },
        "at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "PromptSource": {
      "type": "string",
      "enum": [
        "vscode",
        "cli",
        "desktop",
        "phone",
        "agent",
        "hub",
        "manual",
        "transcript"
      ]
    },
    "PromptStatus": {
      "type": "string",
      "enum": [
        "open",
        "launched",
        "sent",
        "answered",
        "verified",
        "done",
        "dismissed",
        "superseded"
      ]
    }
  }
}