{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/repowise-dev/json-schema/repowise-dev-chat-turn-result-response-schema.json",
  "title": "ChatTurnResultResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/repowise-dev-chat-api-openapi.yml#/components/schemas/ChatTurnResultResponse",
  "properties": {
    "conversation_id": {
      "type": "string",
      "title": "Conversation Id"
    },
    "message_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Message Id"
    },
    "user_message_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "User Message Id"
    },
    "answer": {
      "type": "string",
      "title": "Answer"
    },
    "stop_reason": {
      "type": "string",
      "enum": [
        "answered",
        "loop_cap",
        "token_budget",
        "turn_budget",
        "refused",
        "cancelled",
        "error"
      ],
      "title": "Stop Reason"
    },
    "provider": {
      "type": "string",
      "title": "Provider"
    },
    "model": {
      "type": "string",
      "title": "Model"
    },
    "citations": {
      "items": {
        "$ref": "#/$defs/ChatCitation"
      },
      "type": "array",
      "title": "Citations",
      "default": []
    },
    "cards": {
      "items": {
        "additionalProperties": true,
        "type": "object"
      },
      "type": "array",
      "title": "Cards",
      "default": []
    },
    "views": {
      "items": {
        "additionalProperties": true,
        "type": "object"
      },
      "type": "array",
      "title": "Views",
      "default": []
    },
    "figures": {
      "items": {
        "$ref": "#/$defs/ChatFigure"
      },
      "type": "array",
      "title": "Figures",
      "default": []
    },
    "diagnostics": {
      "additionalProperties": {
        "type": "integer"
      },
      "type": "object",
      "title": "Diagnostics",
      "default": {}
    },
    "tool_trace": {
      "items": {
        "$ref": "#/$defs/ChatToolTraceEntry"
      },
      "type": "array",
      "title": "Tool Trace",
      "default": []
    },
    "follow_ups": {
      "items": {
        "$ref": "#/$defs/ChatSuggestion"
      },
      "type": "array",
      "title": "Follow Ups",
      "default": []
    },
    "usage": {
      "$ref": "#/$defs/ChatTurnUsage",
      "default": {
        "model_calls": 0
      }
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error"
    },
    "replayed": {
      "type": "boolean",
      "title": "Replayed",
      "default": false
    }
  },
  "type": "object",
  "required": [
    "conversation_id",
    "answer",
    "stop_reason",
    "provider",
    "model"
  ],
  "$defs": {
    "CardRef": {
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "repo",
            "file",
            "symbol",
            "module",
            "component",
            "commit",
            "change",
            "decision"
          ],
          "title": "Type"
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "title": "Id"
        },
        "start_line": {
          "anyOf": [
            {
              "type": "integer",
              "maximum": 9007199254740991.0,
              "minimum": 1.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Start Line"
        },
        "end_line": {
          "anyOf": [
            {
              "type": "integer",
              "maximum": 9007199254740991.0,
              "minimum": 1.0
            },
            {
              "type": "null"
            }
          ],
          "title": "End Line"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "type",
        "id"
      ],
      "title": "CardRef",
      "description": "An entity a card or view points at. Never a URL; the renderer resolves it."
    },
    "ChatCitation": {
      "properties": {
        "file_path": {
          "type": "string",
          "title": "File Path"
        },
        "symbol_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Symbol Name"
        },
        "start_line": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Start Line"
        },
        "end_line": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "End Line"
        },
        "artifact_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Artifact Id"
        },
        "ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/CardRef"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "type": "object",
      "required": [
        "file_path"
      ],
      "title": "ChatCitation",
      "description": "A file a tool result cited, and that result's ``artifact_id``."
    },
    "ChatFigure": {
      "properties": {
        "text": {
          "type": "string",
          "title": "Text"
        },
        "start": {
          "type": "integer",
          "title": "Start"
        },
        "end": {
          "type": "integer",
          "title": "End"
        },
        "verified": {
          "type": "boolean",
          "title": "Verified"
        },
        "artifact_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Artifact Id"
        },
        "derived": {
          "type": "boolean",
          "title": "Derived",
          "default": false
        }
      },
      "type": "object",
      "required": [
        "text",
        "start",
        "end",
        "verified"
      ],
      "title": "ChatFigure",
      "description": "A number the answer states. Offsets are UTF-16 units into ``answer``;\na verified figure carries the ``artifact_id`` of the result holding it."
    },
    "ChatSuggestion": {
      "properties": {
        "text": {
          "type": "string",
          "title": "Text"
        },
        "source": {
          "type": "string",
          "enum": [
            "static",
            "page",
            "followup"
          ],
          "title": "Source"
        },
        "toolHint": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Toolhint"
        }
      },
      "type": "object",
      "required": [
        "text",
        "source"
      ],
      "title": "ChatSuggestion",
      "description": "One composer chip. ``source`` lets a client rank a measured question\nabove the static tier it already ships."
    },
    "ChatToolTraceEntry": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "summary": {
          "type": "string",
          "title": "Summary"
        },
        "ok": {
          "type": "boolean",
          "title": "Ok"
        },
        "basis": {
          "type": "string",
          "title": "Basis"
        },
        "origin": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Origin"
        }
      },
      "type": "object",
      "required": [
        "name",
        "summary",
        "ok",
        "basis"
      ],
      "title": "ChatToolTraceEntry"
    },
    "ChatTurnUsage": {
      "properties": {
        "input_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Input Tokens"
        },
        "output_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Output Tokens"
        },
        "model_calls": {
          "type": "integer",
          "title": "Model Calls",
          "default": 0
        }
      },
      "type": "object",
      "title": "ChatTurnUsage",
      "description": "Null token counts mean the provider reported none."
    }
  }
}