{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://animstream.com/game-sdk/agent-kit/manifest.schema.json",
  "title": "AnimStream Originals game manifest (protocol 1)",
  "description": "Manifest of an AnimStream Originals game build: gift actions, optional raw event codes, suggested default gift rules, gift rule presets, the leaderboard label and the layout of the game's Gift Wall. Normative reference: https://animstream.com/game-sdk/PROTOCOL.md, section 7. This schema checks every rule JSON Schema can express. Rules it cannot express are listed in the descriptions below: unique action IDs and parameter keys, enum option values, stackable references, defaults within bounds, default gift rules against their action, case-insensitively unique gift names and the 48 KiB size limit. Lengths count UTF-16 code units (JavaScript String.length); JSON Schema validators count code points, so strings with characters outside the Basic Multilingual Plane, such as emoji, can pass this schema and still exceed a limit. Run `node tools/mock-studio/mock-studio.mjs validate manifest.json` to check all rules exactly as AnimStream does.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "gameId",
    "title",
    "actions",
    "events"
  ],
  "properties": {
    "schemaVersion": {
      "description": "Always 1.",
      "const": 1
    },
    "gameId": {
      "description": "Immutable game ID from the AnimStream developer dashboard. Must equal ANIMSTREAM_GAME_ID at launch.",
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]{0,95}$"
    },
    "title": {
      "$ref": "#/$defs/text160",
      "description": "Game title in German and English, each non-blank and at most 160 characters."
    },
    "description": {
      "$ref": "#/$defs/text1000",
      "description": "Optional short description in German and English, each non-blank and at most 1000 characters."
    },
    "actions": {
      "description": "Gift actions Studio can send. At most 128. Action IDs must be unique within the manifest (not expressible in JSON Schema).",
      "type": "array",
      "maxItems": 128,
      "items": {
        "$ref": "#/$defs/action"
      }
    },
    "events": {
      "description": "Normalized event codes Studio forwards as raw `event` messages. May be empty. Use gift rules (actions) for gameplay effects; a raw GIFT event and a gift rule must never produce the same effect.",
      "type": "array",
      "maxItems": 20,
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/eventCode"
      }
    },
    "defaultBindings": {
      "description": "Optional default gift rules (at most 32). On the first start of the game without gift rules, Studio creates them right away (with a one-time Undo notice); it never overwrites or duplicates existing rules. Gift names must be unique case-insensitively (not expressible in JSON Schema). Studio versions that do not announce this extension receive the manifest without it.",
      "type": "array",
      "maxItems": 32,
      "items": {
        "$ref": "#/$defs/defaultBinding"
      }
    },
    "presets": {
      "description": "Optional gift rule presets (1 to 6, unique IDs, not expressible in JSON Schema). Studio offers them before the first start; new presets in an update are offered, never applied over existing rules. Keep defaultBindings for Studio versions that do not announce the presets extension: they receive the manifest without presets.",
      "type": "array",
      "minItems": 1,
      "maxItems": 6,
      "items": {
        "$ref": "#/$defs/preset"
      }
    },
    "leaderboard": {
      "$ref": "#/$defs/leaderboard",
      "description": "Optional label and sort order of the game's global leaderboard. Without it the leaderboard uses the label \"Punkte\"/\"Score\" and order \"desc\"."
    },
    "giftWall": {
      "$ref": "#/$defs/giftWall",
      "description": "Optional layout of the Gift Wall Studio creates for the game on its first start. Without it Studio uses its own defaults. When a newer build changes it, Studio applies the changed values to every field the streamer has not changed. Studio versions that do not announce the gift-wall extension receive the manifest without it."
    }
  },
  "$defs": {
    "string40": {
      "type": "string",
      "minLength": 1,
      "maxLength": 40,
      "pattern": "\\S"
    },
    "string128": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "\\S"
    },
    "string160": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160,
      "pattern": "\\S"
    },
    "string1000": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1000,
      "pattern": "\\S"
    },
    "text40": {
      "type": "object",
      "description": "German and English text, each non-blank and at most 40 characters.",
      "additionalProperties": false,
      "required": [
        "de",
        "en"
      ],
      "properties": {
        "de": {
          "$ref": "#/$defs/string40"
        },
        "en": {
          "$ref": "#/$defs/string40"
        }
      }
    },
    "text160": {
      "type": "object",
      "description": "German and English text, each non-blank and at most 160 characters.",
      "additionalProperties": false,
      "required": [
        "de",
        "en"
      ],
      "properties": {
        "de": {
          "$ref": "#/$defs/string160"
        },
        "en": {
          "$ref": "#/$defs/string160"
        }
      }
    },
    "text1000": {
      "type": "object",
      "description": "German and English text, each non-blank and at most 1000 characters.",
      "additionalProperties": false,
      "required": [
        "de",
        "en"
      ],
      "properties": {
        "de": {
          "$ref": "#/$defs/string1000"
        },
        "en": {
          "$ref": "#/$defs/string1000"
        }
      }
    },
    "key": {
      "description": "Lowercase ASCII letter followed by up to 63 lowercase letters, digits or hyphens.",
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]{0,63}$"
    },
    "bound": {
      "description": "Finite number with an absolute value of at most 10^9.",
      "type": "number",
      "minimum": -1000000000,
      "maximum": 1000000000
    },
    "value": {
      "description": "Primitive parameter value. Strings at most 256 characters, numbers within plus or minus 10^9.",
      "anyOf": [
        {
          "type": "string",
          "maxLength": 256
        },
        {
          "type": "number",
          "minimum": -1000000000,
          "maximum": 1000000000
        },
        {
          "type": "boolean"
        }
      ]
    },
    "eventCode": {
      "description": "Uppercase normalized event code.",
      "enum": [
        "GIFT",
        "FOLLOW",
        "LIKE",
        "SHARE",
        "COMMENT",
        "JOIN",
        "SUBSCRIBE",
        "TEAM_JOIN",
        "LEVEL_UP",
        "MULTIPLIER",
        "MULTIPLIER_GIFT",
        "BOOSTED_GIFT",
        "MULTIPLIER_PREDICT",
        "CHEER",
        "RAID",
        "RESUBSCRIBE",
        "SUB_GIFT",
        "REWARD",
        "SHOUTOUT",
        "CHARITY_DONATE"
      ]
    },
    "action": {
      "description": "One gift action. Studio validates every parameter against this definition before sending; the game validates again.",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "label",
        "parameters"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/key",
          "description": "Stable action ID. Gift rules reference it; keep it unchanged across updates."
        },
        "label": {
          "$ref": "#/$defs/text160",
          "description": "Label shown in Studio's game control window, in gift rules and on Gift Walls."
        },
        "description": {
          "$ref": "#/$defs/text1000",
          "description": "Short explanation of the action shown in Studio's preset builder, on the store page and in the game control window. Allowed up to 1000 characters, but keep it at most 120 per language: the tools warn above 120."
        },
        "image": {
          "description": "Action image: a path inside the build ZIP, exactly one file directly under \"media/actions/\" ending in .png or .webp (name at most 96 characters, no \"..\", no reserved Windows name; animstream-pack copies it from next to manifest.json into every ZIP), or the https URL of an uploaded image on AnimStream's CDN under game-media/<this gameId>/. The file must be a still, square PNG or WebP of 256 to 1024 px with an alpha channel (transparent background) and at most 300 KB (checked by animstream-pack and the build verification; the gameId match and \"..\" are not expressible in JSON Schema). Studios receive only the resolved CDN URL, and only if they announce the action-images extension.",
          "type": "string",
          "maxLength": 512,
          "pattern": "^(?:media/actions/(?!(?:[Cc][Oo][Nn]|[Pp][Rr][Nn]|[Aa][Uu][Xx]|[Nn][Uu][Ll]|[Cc][Oo][Mm][0-9]|[Ll][Pp][Tt][0-9])\\.)[A-Za-z0-9_-][A-Za-z0-9._-]{0,95}\\.(?:[Pp][Nn][Gg]|[Ww][Ee][Bb][Pp])|https://(?:animstream\\.b-cdn\\.net|(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)*animstream\\.com)/game-media/[a-z0-9][a-z0-9-]{0,95}/(?:[A-Za-z0-9_-][A-Za-z0-9._-]{0,127}/){0,2}[A-Za-z0-9_-][A-Za-z0-9._-]{0,127}\\.(?:png|webp))$"
        },
        "parameters": {
          "description": "At most 16 parameters. Parameter keys must be unique within the action (not expressible in JSON Schema).",
          "type": "array",
          "maxItems": 16,
          "items": {
            "$ref": "#/$defs/parameter"
          }
        },
        "stackable": {
          "$ref": "#/$defs/key",
          "description": "Key of an integer parameter of this action with min >= 1 and max set. Studio merges waiting actions of the same gift rule, viewer and gift and sums this parameter, bounded by its max. The schema only checks that some parameter qualifies; that the named parameter qualifies is not expressible in JSON Schema."
        },
        "effect": {
          "description": "What the action does to the streamer (action-effects extension): \"help\" (mercy: helps the streamer, green in ART-DIRECTION.md, the help side of a split Gift Wall, left by default), \"sabotage\" (gets in the streamer's way, red, the other side) or \"neutral\" (neither; use it rarely). Omitted = unclassified, treated like neutral. Classify every action of an Original. Studios that do not announce action-effects receive the manifest without it.",
          "enum": [
            "help",
            "sabotage",
            "neutral"
          ]
        }
      },
      "dependentSchemas": {
        "stackable": {
          "properties": {
            "parameters": {
              "type": "array",
              "contains": {
                "type": "object",
                "required": [
                  "type",
                  "min",
                  "max"
                ],
                "properties": {
                  "type": {
                    "const": "integer"
                  },
                  "min": {
                    "type": "number",
                    "minimum": 1
                  },
                  "max": {
                    "type": "number"
                  }
                }
              }
            }
          }
        }
      }
    },
    "parameter": {
      "description": "Typed, bounded action parameter. `min` must not exceed `max`, and `default` must satisfy min, max, maxLength or options (not expressible in JSON Schema).",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "key",
        "label",
        "type"
      ],
      "properties": {
        "key": {
          "$ref": "#/$defs/key",
          "description": "Stable parameter key. Gift rules store values under it; keep it unchanged across updates."
        },
        "label": {
          "$ref": "#/$defs/text160"
        },
        "type": {
          "enum": [
            "integer",
            "number",
            "boolean",
            "string",
            "enum"
          ]
        },
        "required": {
          "type": "boolean"
        },
        "default": {
          "$ref": "#/$defs/value"
        },
        "min": {
          "$ref": "#/$defs/bound",
          "description": "Lower bound for integer and number parameters."
        },
        "max": {
          "$ref": "#/$defs/bound",
          "description": "Upper bound for integer and number parameters."
        },
        "maxLength": {
          "description": "Maximum length of a string parameter, 1 to 256. Without it strings may have up to 256 characters.",
          "type": "integer",
          "minimum": 1,
          "maximum": 256
        },
        "options": {
          "description": "Choices of an enum parameter: 1 to 32 options with unique values (uniqueness is not expressible in JSON Schema).",
          "type": "array",
          "minItems": 1,
          "maxItems": 32,
          "items": {
            "$ref": "#/$defs/option"
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "integer"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "properties": {
              "maxLength": false,
              "options": false,
              "default": {
                "type": "integer",
                "minimum": -1000000000,
                "maximum": 1000000000
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "number"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "properties": {
              "maxLength": false,
              "options": false,
              "default": {
                "type": "number",
                "minimum": -1000000000,
                "maximum": 1000000000
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "boolean"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "properties": {
              "min": false,
              "max": false,
              "maxLength": false,
              "options": false,
              "default": {
                "type": "boolean"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "string"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "properties": {
              "min": false,
              "max": false,
              "options": false,
              "default": {
                "type": "string",
                "maxLength": 256
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "enum"
              }
            },
            "required": [
              "type"
            ]
          },
          "then": {
            "required": [
              "options"
            ],
            "properties": {
              "min": false,
              "max": false,
              "maxLength": false,
              "default": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128,
                "pattern": "\\S"
              }
            }
          }
        }
      ]
    },
    "option": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "value",
        "label"
      ],
      "properties": {
        "value": {
          "$ref": "#/$defs/string128"
        },
        "label": {
          "$ref": "#/$defs/text160"
        }
      }
    },
    "defaultBinding": {
      "description": "Suggested gift rule. `actionId` must name an action of this manifest and `params` are validated against it, with parameter defaults filling missing values (not expressible in JSON Schema).",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "giftName",
        "actionId"
      ],
      "properties": {
        "giftName": {
          "description": "TikTok gift display name, for example \"Rose\". Studio matches gifts by name because gift IDs differ between regional servers. 1 to 80 characters, no leading or trailing whitespace, no control characters or * | \\ [ ] { }, and not starting with \"min-coins:\".",
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "pattern": "^(?![Mm][Ii][Nn]-[Cc][Oo][Ii][Nn][Ss]\\s*:)[^\\s\\x00-\\x1f\\x7f*|\\\\\\[\\]{}](?:[^\\x00-\\x1f\\x7f*|\\\\\\[\\]{}]*[^\\s\\x00-\\x1f\\x7f*|\\\\\\[\\]{}])?$"
        },
        "giftId": {
          "description": "Optional gift ID hint. Matching uses the name.",
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{1,40}$"
        },
        "actionId": {
          "$ref": "#/$defs/key",
          "description": "ID of an action in this manifest."
        },
        "params": {
          "description": "Parameter values for the action. Optional; missing values use the parameter defaults, and null is treated like an empty object.",
          "anyOf": [
            {
              "type": "object",
              "maxProperties": 16,
              "propertyNames": {
                "$ref": "#/$defs/key"
              },
              "additionalProperties": {
                "$ref": "#/$defs/value"
              }
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "leaderboard": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "label"
      ],
      "properties": {
        "label": {
          "$ref": "#/$defs/text40",
          "description": "What the score measures, for example \"Waves survived\". At most 40 characters per language."
        },
        "order": {
          "description": "\"desc\": higher scores rank first (default). \"asc\": lower scores rank first, for example durations in milliseconds.",
          "enum": [
            "desc",
            "asc"
          ],
          "default": "desc"
        }
      }
    },
    "giftWall": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "columns"
      ],
      "properties": {
        "columns": {
          "description": "Number of columns, 1 to 12.",
          "type": "integer",
          "minimum": 1,
          "maximum": 12
        },
        "sort": {
          "description": "Cell order: \"coins-asc\" (cheapest gift first), \"coins-desc\" (most expensive first), \"preset\" (order of the chosen preset's gift rules) or \"manifest\" (the same: preset order, else the order of defaultBindings). Without it Studio keeps the order of the gift rules. Studio versions without the presets extension receive \"manifest\" instead of \"preset\".",
          "enum": [
            "coins-asc",
            "coins-desc",
            "manifest",
            "preset"
          ]
        },
        "showCoins": {
          "description": "Show the coin value of each gift. Studio default: false.",
          "type": "boolean"
        },
        "showLabels": {
          "description": "Show the action name of each gift rule. Studio default: true.",
          "type": "boolean"
        },
        "title": {
          "$ref": "#/$defs/text40",
          "description": "Optional heading of the wall, at most 40 characters per language."
        },
        "split": {
          "description": "Split Gift Wall (action-effects extension, optional, recommended for Originals): help actions on one side, sabotage actions on the other, each under a header. true = split with the defaults below, false = plain wall, or an object to choose the options. Studio applies it when it creates the game's wall and never overwrites a streamer's later change. Studios that do not announce action-effects receive giftWall without it.",
          "oneOf": [
            {
              "type": "boolean"
            },
            {
              "$ref": "#/$defs/giftWallSplit"
            }
          ]
        }
      }
    },
    "string120": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120,
      "pattern": "\\S"
    },
    "text120": {
      "type": "object",
      "description": "German and English text, each non-blank and at most 120 characters.",
      "additionalProperties": false,
      "required": [
        "de",
        "en"
      ],
      "properties": {
        "de": {
          "$ref": "#/$defs/string120"
        },
        "en": {
          "$ref": "#/$defs/string120"
        }
      }
    },
    "preset": {
      "description": "Gift rule preset Studio offers before the first start (picking one creates its gift rules and the Gift Wall). Gift names must be unique within the preset case-insensitively, actionId must name an action of this manifest and params are validated against it (not expressible in JSON Schema). Recommended: three presets by coin value (every gift <= 30 coins, 99-299, >= 500) mixing sabotage and mercy actions.",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "title",
        "bindings"
      ],
      "properties": {
        "id": {
          "description": "Stable preset ID, unique within the manifest. Keep it unchanged across updates.",
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]{0,31}$"
        },
        "title": {
          "$ref": "#/$defs/text40",
          "description": "Title of the preset card, at most 40 characters per language."
        },
        "description": {
          "$ref": "#/$defs/text120",
          "description": "Optional subtitle of the preset card, at most 120 characters per language."
        },
        "bindings": {
          "description": "1 to 8 gift rules (giftName, actionId, params) with the rules of defaultBindings; giftName unique within the preset.",
          "type": "array",
          "minItems": 1,
          "maxItems": 8,
          "items": {
            "$ref": "#/$defs/presetBinding"
          }
        }
      }
    },
    "presetBinding": {
      "description": "One combination of a preset: same rules as a default binding, without giftId. actionId must name an action of this manifest and params are validated against it (not expressible in JSON Schema).",
      "type": "object",
      "additionalProperties": false,
      "required": [
        "giftName",
        "actionId"
      ],
      "properties": {
        "giftName": {
          "description": "TikTok gift display name, for example \"Rose\". Studio matches gifts by name because gift IDs differ between regional servers. 1 to 80 characters, no leading or trailing whitespace, no control characters or * | \\ [ ] { }, and not starting with \"min-coins:\".",
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "pattern": "^(?![Mm][Ii][Nn]-[Cc][Oo][Ii][Nn][Ss]\\s*:)[^\\s\\x00-\\x1f\\x7f*|\\\\\\[\\]{}](?:[^\\x00-\\x1f\\x7f*|\\\\\\[\\]{}]*[^\\s\\x00-\\x1f\\x7f*|\\\\\\[\\]{}])?$"
        },
        "actionId": {
          "$ref": "#/$defs/key",
          "description": "ID of an action in this manifest."
        },
        "params": {
          "description": "Parameter values for the action. Optional; missing values use the parameter defaults, and null is treated like an empty object.",
          "anyOf": [
            {
              "type": "object",
              "maxProperties": 16,
              "propertyNames": {
                "$ref": "#/$defs/key"
              },
              "additionalProperties": {
                "$ref": "#/$defs/value"
              }
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "giftWallSplit": {
      "description": "Options of a split Gift Wall; every key is optional.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "helpSide": {
          "description": "Side of the help actions. Default: \"left\" (sabotage on the right).",
          "enum": [
            "left",
            "right"
          ],
          "default": "left"
        },
        "helpTitle": {
          "$ref": "#/$defs/text40",
          "description": "Header of the help side, at most 40 characters per language. Default: Studio's own text (\"Hilft dem Streamer\" / \"Helps the streamer\")."
        },
        "sabotageTitle": {
          "$ref": "#/$defs/text40",
          "description": "Header of the sabotage side, at most 40 characters per language. Default: Studio's own text (\"Gegen den Streamer\" / \"Against the streamer\")."
        },
        "showHeaders": {
          "description": "Show the side headers. Default: true.",
          "type": "boolean",
          "default": true
        },
        "neutral": {
          "description": "Where neutral and unclassified actions go: \"help\" side, \"sabotage\" side, or \"bottom\" (a row below both sides). Default: \"bottom\".",
          "enum": [
            "help",
            "sabotage",
            "bottom"
          ],
          "default": "bottom"
        }
      }
    }
  }
}
