{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "bridge_invocation_id": {
      "pattern": "^inv_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
      "type": "string"
    },
    "input": {
      "oneOf": [
        {
          "properties": {
            "json": {},
            "kind": {
              "const": "inline",
              "type": "string"
            }
          },
          "required": [
            "kind",
            "json"
          ],
          "type": "object"
        },
        {
          "properties": {
            "kind": {
              "const": "evidence",
              "type": "string"
            },
            "sha256": {
              "pattern": "^[0-9a-f]{64}$",
              "type": "string"
            },
            "size_bytes": {
              "maximum": 9007199254740991,
              "minimum": 0,
              "type": "integer"
            },
            "uri": {
              "type": "string"
            }
          },
          "required": [
            "uri",
            "sha256",
            "size_bytes",
            "kind"
          ],
          "type": "object"
        }
      ]
    },
    "product_id": {
      "pattern": "^prod_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
      "type": "string"
    },
    "received_at": {
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$",
      "type": "string"
    },
    "request": {
      "oneOf": [
        {
          "properties": {
            "action": {
              "const": "generate",
              "type": "string"
            },
            "id": {
              "const": "ai.generate",
              "type": "string"
            },
            "max_tokens": {
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991,
              "type": "integer"
            },
            "model_kind": {
              "enum": [
                "text",
                "embedding"
              ],
              "type": "string"
            }
          },
          "required": [
            "id",
            "action",
            "model_kind",
            "max_tokens"
          ],
          "type": "object"
        },
        {
          "properties": {
            "action": {
              "enum": [
                "read",
                "write",
                "delete",
                "list"
              ],
              "type": "string"
            },
            "bytes": {
              "maximum": 9007199254740991,
              "minimum": 0,
              "type": "integer"
            },
            "id": {
              "const": "storage.object",
              "type": "string"
            },
            "key": {
              "pattern": "^\\/(?!.*\\.\\.).*$",
              "type": "string"
            }
          },
          "required": [
            "id",
            "action",
            "key"
          ],
          "type": "object"
        },
        {
          "properties": {
            "action": {
              "enum": [
                "get",
                "set",
                "delete",
                "list",
                "increment"
              ],
              "type": "string"
            },
            "bytes": {
              "maximum": 9007199254740991,
              "minimum": 0,
              "type": "integer"
            },
            "id": {
              "const": "data.kv",
              "type": "string"
            },
            "key": {
              "pattern": "^\\/(?!.*\\.\\.).*$",
              "type": "string"
            }
          },
          "required": [
            "id",
            "action",
            "key"
          ],
          "type": "object"
        },
        {
          "properties": {
            "action": {
              "const": "send",
              "type": "string"
            },
            "bytes": {
              "maximum": 9007199254740991,
              "minimum": 0,
              "type": "integer"
            },
            "from": {
              "maxLength": 254,
              "pattern": "^(?!.*[A-Z])(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[ !#-[\\]-~]|\\\\[ -~])*\")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$",
              "type": "string"
            },
            "id": {
              "const": "email.send",
              "type": "string"
            },
            "recipients": {
              "items": {
                "maxLength": 254,
                "pattern": "^(?!.*[A-Z])(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[ !#-[\\]-~]|\\\\[ -~])*\")@(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$",
                "type": "string"
              },
              "maxItems": 50,
              "minItems": 1,
              "type": "array"
            }
          },
          "required": [
            "id",
            "action",
            "from",
            "recipients",
            "bytes"
          ],
          "type": "object"
        }
      ]
    },
    "revision_id": {
      "pattern": "^rev_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
      "type": "string"
    },
    "service_identity_id": {
      "pattern": "^svc_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
      "type": "string"
    },
    "workspace_id": {
      "pattern": "^ws_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$",
      "type": "string"
    }
  },
  "required": [
    "bridge_invocation_id",
    "service_identity_id",
    "workspace_id",
    "product_id",
    "revision_id",
    "request",
    "input",
    "received_at"
  ],
  "type": "object"
}
