{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/scholarmuse-ai/json-schema/scholarmuse-ai-tool-result-schema.json",
  "title": "ToolResult",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/scholarmuse-ai-openapi.json#/components/schemas/ToolResult",
  "type": "object",
  "required": [
    "summary",
    "credits_used",
    "call_id"
  ],
  "properties": {
    "summary": {
      "type": "string"
    },
    "billing": {
      "$ref": "#/$defs/CreditStatus"
    },
    "records": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Record"
      }
    },
    "partial": {
      "type": "boolean"
    },
    "failedSources": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "error": {
            "type": "string"
          }
        }
      }
    },
    "files": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "mimeType": {
            "type": "string"
          }
        }
      }
    },
    "extra": {
      "type": "object"
    },
    "credits_used": {
      "type": "number"
    },
    "call_id": {
      "type": "string"
    }
  },
  "$defs": {
    "CreditStatus": {
      "type": "object",
      "required": [
        "creditsRemaining",
        "status",
        "lowBalanceThreshold",
        "topUpUrl",
        "pricingUrl",
        "checkedAt"
      ],
      "properties": {
        "creditsRemaining": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "description": "Spendable, unexpired balance at checkedAt; null if refresh failed. Credits reserved by pending figures are excluded."
        },
        "status": {
          "type": "string",
          "enum": [
            "ok",
            "low",
            "empty",
            "unavailable"
          ]
        },
        "lowBalanceThreshold": {
          "type": "integer"
        },
        "topUpUrl": {
          "type": "string",
          "format": "uri"
        },
        "pricingUrl": {
          "type": "string",
          "format": "uri"
        },
        "checkedAt": {
          "type": "string",
          "format": "date-time"
        },
        "notice": {
          "type": "string"
        }
      }
    },
    "Record": {
      "type": "object",
      "required": [
        "id",
        "type",
        "source",
        "retrievedAt",
        "data"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "source": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "license": {
          "type": "string"
        },
        "attribution": {
          "type": "string"
        },
        "retrievedAt": {
          "type": "string",
          "format": "date-time"
        },
        "data": {
          "type": "object"
        }
      }
    }
  }
}