{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://intelligentliving.art/schemas/interaction/v1.json",
  "title": "Living Art Interaction Manifest v1",
  "type": "object",
  "required": [
    "type",
    "version",
    "identity",
    "presentation",
    "conversation",
    "grounding",
    "memory",
    "fallback"
  ],
  "properties": {
    "type": {
      "const": "https://intelligentliving.art/protocols/interaction-manifest/v1.json"
    },
    "version": {
      "const": "1.0.0"
    },
    "identity": {
      "type": "object",
      "required": [
        "name",
        "artwork",
        "interpretationDisclosure"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "artwork": {
          "type": "string",
          "description": "CAIP-style reference to the controlling artwork NFT."
        },
        "agent": {
          "type": "string",
          "description": "Optional CAIP-style reference to an ERC-8004 registration."
        },
        "interpretationDisclosure": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "presentation": {
      "type": "object",
      "required": [
        "cover",
        "poster",
        "states"
      ],
      "properties": {
        "cover": {
          "$ref": "#/$defs/media"
        },
        "poster": {
          "$ref": "#/$defs/media"
        },
        "states": {
          "type": "object",
          "required": [
            "looking",
            "thinking",
            "talking"
          ],
          "properties": {
            "looking": {
              "$ref": "#/$defs/media"
            },
            "thinking": {
              "$ref": "#/$defs/media"
            },
            "talking": {
              "$ref": "#/$defs/media"
            }
          },
          "additionalProperties": {
            "$ref": "#/$defs/media"
          }
        },
        "speech": {
          "type": "object",
          "required": [
            "preferredVoice",
            "locale",
            "outputs"
          ],
          "properties": {
            "preferredVoice": {
              "type": "string",
              "minLength": 1
            },
            "locale": {
              "type": "string",
              "minLength": 2
            },
            "outputs": {
              "type": "array",
              "items": {
                "enum": [
                  "canonical-endpoint",
                  "local-piper",
                  "browser-local"
                ]
              },
              "minItems": 1,
              "uniqueItems": true
            },
            "interpretationDisclosure": {
              "type": "string",
              "minLength": 1
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "conversation": {
      "type": "object",
      "required": [
        "protocol",
        "endpoint",
        "canonical",
        "responseMediaType"
      ],
      "properties": {
        "protocol": {
          "const": "living-art-conversation/1.0"
        },
        "endpoint": {
          "type": "string",
          "format": "uri-reference"
        },
        "canonical": {
          "type": "boolean"
        },
        "responseMediaType": {
          "const": "application/vnd.living-art.response+json;version=1"
        },
        "streamEndpoint": {
          "type": "string",
          "format": "uri-reference"
        },
        "a2aAgentCard": {
          "type": "string",
          "format": "uri-reference"
        },
        "mcpEndpoint": {
          "type": "string",
          "format": "uri-reference"
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        },
        "authentication": {
          "type": "array",
          "items": {
            "enum": [
              "anonymous",
              "siwe",
              "bearer"
            ]
          },
          "minItems": 1
        },
        "payment": {
          "type": "object",
          "properties": {
            "mode": {
              "enum": [
                "funded",
                "x402",
                "client-provided",
                "none"
              ]
            },
            "fund": {
              "type": "string"
            }
          },
          "required": [
            "mode"
          ],
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "grounding": {
      "type": "object",
      "required": [
        "required",
        "corpus",
        "historicalBoundary",
        "epistemicStates",
        "citationRequired"
      ],
      "properties": {
        "required": {
          "const": true
        },
        "strategy": {
          "enum": [
            "rag",
            "curated-context",
            "hybrid"
          ]
        },
        "corpus": {
          "type": "string",
          "format": "uri-reference"
        },
        "corpusHash": {
          "type": "string",
          "pattern": "^(0x)?[a-fA-F0-9]{64}$"
        },
        "historicalBoundary": {
          "type": "string",
          "format": "date"
        },
        "epistemicStates": {
          "type": "array",
          "items": {
            "enum": [
              "documented",
              "mixed",
              "inferred",
              "unknown"
            ]
          },
          "minItems": 4,
          "uniqueItems": true
        },
        "citationRequired": {
          "const": true
        },
        "sourceRoles": {
          "type": "array",
          "items": {
            "enum": [
              "subject",
              "editor",
              "correspondent",
              "scholar",
              "curator"
            ]
          },
          "uniqueItems": true
        }
      },
      "additionalProperties": false
    },
    "memory": {
      "type": "object",
      "required": [
        "default",
        "consentRequired",
        "onchainConversationData"
      ],
      "properties": {
        "default": {
          "enum": [
            "none",
            "session",
            "persistent"
          ]
        },
        "consentRequired": {
          "type": "boolean"
        },
        "onchainConversationData": {
          "const": false
        },
        "deletionEndpoint": {
          "type": "string",
          "format": "uri-reference"
        }
      },
      "additionalProperties": false
    },
    "fallback": {
      "type": "object",
      "required": [
        "offlineDocument",
        "message"
      ],
      "properties": {
        "offlineDocument": {
          "type": "string",
          "format": "uri-reference"
        },
        "message": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "extensions": {
      "type": "object"
    }
  },
  "$defs": {
    "media": {
      "type": "object",
      "required": [
        "uri",
        "mediaType",
        "sha256"
      ],
      "properties": {
        "uri": {
          "type": "string",
          "format": "uri-reference"
        },
        "mediaType": {
          "type": "string"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-fA-F0-9]{64}$"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
