{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/flashdata-dev/json-schema/flashdata-dev-agent-connection-schema.json",
  "title": "AgentConnection",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/flashdata-dev-agent-connections-api-openapi.yml#/components/schemas/AgentConnection",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "audience": {
      "type": "string",
      "enum": [
        "coding",
        "personal",
        "unspecified"
      ]
    },
    "ownership": {
      "type": "string",
      "enum": [
        "owned",
        "unowned"
      ]
    },
    "lifecycle": {
      "type": "string",
      "enum": [
        "valid",
        "revoked",
        "expired"
      ]
    },
    "access": {
      "type": "string",
      "enum": [
        "ready",
        "fenced",
        "blocked"
      ]
    },
    "scopes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Actual scopes on the current API key. May be empty on an unowned claim-only connection; every data-source request is then forbidden."
    },
    "requestedScopes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Original owner-access request. Claim approval can only reduce this set. Legacy connections retain their original scopes."
    },
    "trialScopes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Saved subset eligible for the temporary key. Never expanded by catalog changes."
    },
    "permissions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AgentPermission"
      }
    },
    "generation": {
      "type": "integer",
      "minimum": 0
    },
    "installed": {
      "type": "boolean"
    },
    "trialExpiresAt": {
      "type": "string",
      "format": "date-time"
    },
    "fundingMode": {
      "type": "string",
      "enum": [
        "trial",
        "account_balance"
      ]
    },
    "trialCredits": {
      "type": "number"
    },
    "trialRequestCounts": {}
  },
  "required": [
    "id",
    "name",
    "audience",
    "ownership",
    "lifecycle",
    "access",
    "scopes",
    "generation",
    "installed",
    "trialExpiresAt",
    "fundingMode",
    "trialCredits",
    "trialRequestCounts"
  ],
  "$defs": {
    "AgentPermission": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "source",
        "name",
        "product",
        "trialEligible",
        "ownerAllowed",
        "requiresStorageDestination"
      ],
      "properties": {
        "source": {
          "type": "string",
          "pattern": "^[a-z_]{1,80}$"
        },
        "name": {
          "type": "string"
        },
        "product": {
          "type": "string"
        },
        "trialEligible": {
          "type": "boolean"
        },
        "ownerAllowed": {
          "type": "boolean"
        },
        "requiresStorageDestination": {
          "type": "boolean"
        }
      },
      "description": "Catalog-derived agent permissions. Trial eligibility is an explicit opt-in independent of owner approval. Storage and variable-price sources require owner access."
    }
  }
}