{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "conversation.list result",
    "type": "object",
    "required": ["conversations"],
    "properties": {
        "conversations": {
            "type": "array",
            "items": { "$ref": "#/definitions/conversationSummary" }
        },
        "cursor": { "type": ["string", "null"] }
    },
    "additionalProperties": true,
    "definitions": {
        "conversationSummary": {
            "type": "object",
            "required": ["id", "title", "userId", "createdAt"],
            "properties": {
                "id": { "type": "string", "minLength": 1 },
                "title": { "type": "string" },
                "userId": { "type": "string", "minLength": 1 },
                "createdAt": { "type": "string", "format": "date-time" },
                "updatedAt": { "type": ["string", "null"], "format": "date-time" },
                "messageCount": { "type": ["integer", "null"], "minimum": 0 },
                "metadata": { "$ref": "#/definitions/messageMetadata" }
            },
            "additionalProperties": true
        },
        "messageMetadata": {
            "type": "object",
            "properties": {
                "secondOpinion": {
                    "type": "object",
                    "required": ["primary"],
                    "properties": {
                        "primary": { "$ref": "#/definitions/modelOpinion" },
                        "secondaryOpinions": {
                            "type": "array",
                            "items": { "$ref": "#/definitions/modelOpinion" }
                        },
                        "synthesis": { "$ref": "#/definitions/synthesis" }
                    },
                    "additionalProperties": true
                },
                "persistenceStatus": { "$ref": "#/definitions/persistenceStatus" }
            },
            "additionalProperties": true
        },
        "modelOpinion": {
            "type": "object",
            "required": ["model", "response"],
            "properties": {
                "model": { "type": "string", "minLength": 1 },
                "response": { "type": "string" },
                "tokensUsed": { "type": "integer", "minimum": 0 },
                "latencyMs": { "type": "number", "minimum": 0 },
                "citations": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "required": ["title", "url"],
                        "properties": {
                            "title": { "type": "string" },
                            "url": { "type": "string", "format": "uri" },
                            "snippet": { "type": "string" }
                        },
                        "additionalProperties": true
                    }
                }
            },
            "additionalProperties": true
        },
        "synthesis": {
            "type": "object",
            "required": ["model", "response"],
            "properties": {
                "model": { "type": "string", "minLength": 1 },
                "response": { "type": "string", "minLength": 1 },
                "modelId": { "type": "string" },
                "modelDisplayName": { "type": "string" },
                "tokensUsed": { "type": "integer", "minimum": 0 },
                "latencyMs": { "type": "number", "minimum": 0 },
                "cost": { "type": "number" },
                "sources": { "type": "array", "items": {} },
                "error": { "type": "boolean" }
            },
            "additionalProperties": true
        },
        "persistenceStatus": {
            "type": "object",
            "properties": {
                "userMessageSaved": { "type": "boolean" },
                "assistantMessageSaved": { "type": "boolean" },
                "userMessageId": { "type": ["string", "null"] },
                "assistantMessageId": { "type": ["string", "null"] },
                "error": { "type": ["string", "null"] }
            },
            "additionalProperties": true
        }
    }
}
