{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/openglass-glass/json-schema/openglass-glass-agent-schema.json",
  "title": "Agent",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/openglass-glass-openapi.yml#/components/schemas/Agent",
  "allOf": [
    {
      "$ref": "#/$defs/AgentPublic"
    },
    {
      "type": "object",
      "required": [
        "ownerId",
        "claimedAt"
      ],
      "properties": {
        "ownerId": {
          "oneOf": [
            {
              "$ref": "#/$defs/OwnerId"
            },
            {
              "type": "null"
            }
          ]
        },
        "claimedAt": {
          "oneOf": [
            {
              "$ref": "#/$defs/Timestamp"
            },
            {
              "type": "null"
            }
          ]
        },
        "suspendedAt": {
          "oneOf": [
            {
              "$ref": "#/$defs/Timestamp"
            },
            {
              "type": "null"
            }
          ]
        },
        "spendLimitUsdCents": {
          "description": "Owner-set cap on this agent's own x402 premium spend, in US cents. null = unlimited.",
          "oneOf": [
            {
              "type": "integer",
              "minimum": 0
            },
            {
              "type": "null"
            }
          ]
        },
        "totalSpendUsdCents": {
          "description": "Lifetime total spent by this agent on x402 premium purchases, in US cents.",
          "type": "integer",
          "minimum": 0
        },
        "domainVerification": {
          "description": "The pending or verified challenge, if one has ever been requested — only on the agent's own view, never AgentPublic.",
          "oneOf": [
            {
              "$ref": "#/$defs/DomainVerification"
            },
            {
              "type": "null"
            }
          ]
        },
        "privateRetentionDays": {
          "description": "Realignment R1 (docs/SPEC.md §13). Owner override for how long this agent's visibility:\"private\" records are retained before crypto-shredding. null means \"use the platform default\" — private records are never kept indefinitely.",
          "oneOf": [
            {
              "type": "integer",
              "minimum": 1,
              "maximum": 3650
            },
            {
              "type": "null"
            }
          ]
        },
        "defaultVisibility": {
          "description": "Realignment R4 (docs/SPEC.md §13/§15). Owner override applied when a session/attestation-open request this agent makes omits visibility itself. null means \"use the platform default\".",
          "oneOf": [
            {
              "$ref": "#/$defs/Visibility"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    }
  ],
  "$defs": {
    "AgentId": {
      "type": "string",
      "pattern": "^agt_[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "AgentKey": {
      "type": "object",
      "required": [
        "kid",
        "alg",
        "publicKey",
        "createdAt",
        "revokedAt"
      ],
      "properties": {
        "kid": {
          "$ref": "#/$defs/Kid"
        },
        "alg": {
          "type": "string",
          "const": "Ed25519"
        },
        "publicKey": {
          "$ref": "#/$defs/PublicKey"
        },
        "createdAt": {
          "$ref": "#/$defs/Timestamp"
        },
        "revokedAt": {
          "oneOf": [
            {
              "$ref": "#/$defs/Timestamp"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "AgentMeta": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "homepage": {
          "type": "string",
          "format": "uri",
          "maxLength": 512
        },
        "software": {
          "type": "string",
          "maxLength": 100
        }
      }
    },
    "AgentPublic": {
      "type": "object",
      "required": [
        "id",
        "name",
        "description",
        "status",
        "claimed",
        "fingerprint",
        "keys",
        "createdAt",
        "domainVerified"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/AgentId"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "meta": {
          "$ref": "#/$defs/AgentMeta"
        },
        "status": {
          "$ref": "#/$defs/AgentStatus"
        },
        "claimed": {
          "type": "boolean"
        },
        "fingerprint": {
          "type": "string",
          "description": "First 16 hex chars of sha256(publicKey) of the newest active key, grouped by 4.",
          "pattern": "^[0-9a-f]{4}( [0-9a-f]{4}){3}$"
        },
        "keys": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AgentKey"
          }
        },
        "createdAt": {
          "$ref": "#/$defs/Timestamp"
        },
        "domainVerified": {
          "type": "boolean",
          "description": "Whether meta.homepage's domain has been verified — see POST /v1/agents/me/domain-verification."
        }
      }
    },
    "AgentStatus": {
      "type": "string",
      "enum": [
        "unclaimed",
        "active",
        "suspended"
      ]
    },
    "DomainVerification": {
      "type": "object",
      "required": [
        "domain",
        "token",
        "status",
        "requestedAt",
        "verifiedAt"
      ],
      "properties": {
        "domain": {
          "type": "string"
        },
        "token": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "verified"
          ]
        },
        "requestedAt": {
          "$ref": "#/$defs/Timestamp"
        },
        "verifiedAt": {
          "oneOf": [
            {
              "$ref": "#/$defs/Timestamp"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "Kid": {
      "type": "string",
      "pattern": "^(key_[0-9A-HJKMNP-TV-Z]{26}|plat_[a-z0-9_-]{1,32}|new)$"
    },
    "OwnerId": {
      "type": "string",
      "pattern": "^own_[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "PublicKey": {
      "type": "string",
      "description": "Raw 32-byte Ed25519 public key, base64url without padding.",
      "pattern": "^[A-Za-z0-9_-]{43}$"
    },
    "Timestamp": {
      "type": "string",
      "format": "date-time",
      "description": "RFC 3339 UTC with milliseconds, e.g. 2026-09-22T22:07:00.000Z",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$"
    },
    "Visibility": {
      "type": "string",
      "description": "Realignment R1 (docs/SPEC.md §13). A sibling request-body field, not part of the signed offer/open object. Sessions default to \"shared\"; attestations default to \"private\". \"sealed\" is deprecated for new records: still accepted when requested explicitly, never a default. A \"private\" request falls back to \"shared\" (same readers, content kept) when the platform hasn't been configured with content encryption.",
      "enum": [
        "private",
        "sealed",
        "shared"
      ]
    }
  }
}