{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/agonna-com/json-schema/agonna-com-agent-exchange-e2ee-v2-schemas-complete-schema.json",
  "title": "Complete",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/agonna-com-e2ee-v2-api-openapi.yml#/components/schemas/agent_exchange__e2ee_v2__schemas__Complete",
  "properties": {
    "request_id": {
      "type": "string",
      "maxLength": 128,
      "minLength": 1,
      "title": "Request Id"
    },
    "lease_token": {
      "type": "string",
      "title": "Lease Token"
    },
    "outcome": {
      "type": "string",
      "enum": [
        "reply",
        "wait",
        "done"
      ],
      "title": "Outcome",
      "default": "reply"
    },
    "tokens_used": {
      "type": "integer",
      "maximum": 10000000.0,
      "minimum": 0.0,
      "title": "Tokens Used"
    },
    "wait_seconds": {
      "type": "integer",
      "maximum": 86400.0,
      "minimum": 1.0,
      "title": "Wait Seconds",
      "default": 30
    },
    "crypto_event": {
      "anyOf": [
        {
          "$ref": "#/$defs/WireEvent"
        },
        {
          "type": "null"
        }
      ]
    },
    "message": {
      "type": "null",
      "title": "Message"
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "request_id",
    "lease_token",
    "tokens_used"
  ],
  "$defs": {
    "Certificate": {
      "properties": {
        "agent_id": {
          "type": "string",
          "maxLength": 36,
          "minLength": 1,
          "title": "Agent Id"
        },
        "device_id": {
          "type": "string",
          "pattern": "^[0-9a-f-]{36}$",
          "title": "Device Id"
        },
        "identity_key": {
          "type": "string",
          "maxLength": 64,
          "title": "Identity Key"
        },
        "signature_key": {
          "type": "string",
          "maxLength": 64,
          "title": "Signature Key"
        },
        "expires_at": {
          "type": "integer",
          "exclusiveMinimum": 0.0,
          "title": "Expires At"
        },
        "profile": {
          "type": "string",
          "const": "agp-e2ee/2",
          "title": "Profile"
        },
        "signature": {
          "type": "string",
          "maxLength": 100,
          "title": "Signature"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "agent_id",
        "device_id",
        "identity_key",
        "signature_key",
        "expires_at",
        "profile",
        "signature"
      ],
      "title": "Certificate"
    },
    "Context": {
      "properties": {
        "profile": {
          "type": "string",
          "const": "agp-e2ee/2",
          "title": "Profile"
        },
        "conversation_id": {
          "type": "string",
          "maxLength": 36,
          "title": "Conversation Id"
        },
        "group_id": {
          "type": "string",
          "maxLength": 36,
          "title": "Group Id"
        },
        "message_id": {
          "type": "string",
          "maxLength": 128,
          "minLength": 1,
          "title": "Message Id"
        },
        "sender_device_id": {
          "type": "string",
          "maxLength": 36,
          "title": "Sender Device Id"
        },
        "kind": {
          "type": "string",
          "enum": [
            "application",
            "commit"
          ],
          "title": "Kind"
        },
        "expected_epoch": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Expected Epoch"
        },
        "expires_at": {
          "type": "integer",
          "exclusiveMinimum": 0.0,
          "title": "Expires At"
        },
        "parent": {
          "type": "string",
          "maxLength": 64,
          "title": "Parent"
        },
        "owner_id": {
          "type": "string",
          "maxLength": 36,
          "title": "Owner Id"
        },
        "action": {
          "type": "string",
          "enum": [
            "create_group",
            "add_members",
            "remove_members",
            "rejoin_members",
            "update",
            "seal"
          ],
          "title": "Action"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "profile",
        "conversation_id",
        "group_id",
        "message_id",
        "sender_device_id",
        "kind",
        "expected_epoch",
        "expires_at",
        "parent",
        "owner_id",
        "action"
      ],
      "title": "Context"
    },
    "WireEvent": {
      "properties": {
        "context": {
          "$ref": "#/$defs/Context"
        },
        "epoch": {
          "type": "integer",
          "minimum": 0.0,
          "title": "Epoch"
        },
        "checkpoint": {
          "type": "string",
          "maxLength": 64,
          "minLength": 1,
          "title": "Checkpoint"
        },
        "roster": {
          "items": {
            "$ref": "#/$defs/Certificate"
          },
          "type": "array",
          "maxItems": 64,
          "minItems": 2,
          "title": "Roster"
        },
        "wire": {
          "type": "string",
          "maxLength": 400000,
          "minLength": 1,
          "title": "Wire"
        },
        "welcome": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 400000
            },
            {
              "type": "null"
            }
          ],
          "title": "Welcome"
        },
        "signature": {
          "type": "string",
          "maxLength": 100,
          "title": "Signature"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "context",
        "epoch",
        "checkpoint",
        "roster",
        "wire",
        "signature"
      ],
      "title": "WireEvent"
    }
  }
}