{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.finnest.com.br/customer-cli/schemas/envelope/2.0.0.json",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "schemaUrl",
    "command",
    "runId",
    "status",
    "exitCode",
    "data",
    "error",
    "startedAt",
    "completedAt",
    "durationMs",
    "cliVersion",
    "meta"
  ],
  "properties": {
    "schemaVersion": {
      "const": "2.0.0"
    },
    "schemaUrl": {
      "const": "https://docs.finnest.com.br/customer-cli/schemas/envelope/2.0.0.json"
    },
    "command": {
      "type": "string"
    },
    "runId": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": ["ok", "error"]
    },
    "exitCode": {
      "type": "integer"
    },
    "data": {},
    "error": {},
    "startedAt": {
      "type": "string"
    },
    "completedAt": {
      "type": "string"
    },
    "durationMs": {
      "type": "number"
    },
    "cliVersion": {
      "type": "string"
    },
    "meta": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "args",
        "outputTier",
        "evidenceEnabled",
        "planeCapabilities",
        "profile",
        "warnings"
      ],
      "properties": {
        "args": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "outputTier": {
          "type": "string",
          "enum": ["headless", "tty"]
        },
        "evidenceEnabled": {
          "type": "boolean"
        },
        "evidencePath": {
          "type": "string"
        },
        "planeCapabilities": {
          "type": "object",
          "additionalProperties": {
            "type": "boolean"
          }
        },
        "profile": {
          "type": "string"
        },
        "cloud": {
          "type": "string",
          "enum": ["aws", "azure"]
        },
        "environment": {
          "type": "string",
          "enum": ["sandbox", "prod"]
        },
        "traceId": {
          "type": "string"
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}
