{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.dissent.chat/schema/plugin-manifest-v2.json",
  "title": "Dissent plugin manifest, version 2",
  "description": "What a Dissent node reads from a plugin's manifest.json. Version 1 manifests (no manifest_version) stay valid: every permission in declared_permissions is asked when the plugin first opens. Unknown fields are ignored by the node. Commands arrived in session 10, events and webhooks in 12, message_actions and roles:assign in 13 (platform spec 2026-11-10 §3.0).",
  "type": "object",
  "required": [
    "id",
    "name",
    "url",
    "tier"
  ],
  "properties": {
    "manifest_version": {
      "const": 2,
      "description": "2 turns on permissions + optional_permissions. Absent or 1 = a v1 manifest."
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9-]+$",
      "maxLength": 64
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128
    },
    "version": {
      "type": "string",
      "maxLength": 64
    },
    "description": {
      "type": "string",
      "maxLength": 1000
    },
    "icon": {
      "type": "string",
      "maxLength": 200,
      "pattern": "^assets/([A-Za-z0-9_-][A-Za-z0-9._-]*/)*[A-Za-z0-9_-][A-Za-z0-9._-]*\\.([pP][nN][gG]|[wW][eE][bB][pP]|[sS][vV][gG])$",
      "description": "Row 17h: the plugin's icon — a png, webp or svg file of its own under assets/ (at most 64 KB, square). Never a web address: Dissent shows it only from the copy on the viewer's own node; a plugin not copied there keeps its letter tile."
    },
    "author": {
      "type": "string",
      "maxLength": 128
    },
    "tier": {
      "enum": [
        1,
        2,
        3
      ],
      "description": "A label only (Passive, Interactive, Activity). Grants nothing."
    },
    "context": {
      "type": "array",
      "items": {
        "enum": [
          "channel",
          "sidebar",
          "profile",
          "embed",
          "personal",
          "games"
        ]
      },
      "uniqueItems": true
    },
    "url": {
      "type": "string",
      "format": "uri",
      "maxLength": 512
    },
    "permissions": {
      "$ref": "#/$defs/permissionList",
      "description": "v2: asked on Dissent's card when a member first opens the plugin. Keep it short — the plugin's basic job."
    },
    "optional_permissions": {
      "$ref": "#/$defs/permissionList",
      "description": "v2: asked by Dissent's own card the first time the plugin calls one (Allow / Not now). A server admin can turn any of them off. sparks:award, tournaments:report and roles:assign cannot be optional — only the server half uses them."
    },
    "declared_permissions": {
      "$ref": "#/$defs/permissionList",
      "description": "v1 name for the permissions asked at open. A v2 manifest may use it too; it is merged with permissions."
    },
    "allowed_fetch_domains": {
      "type": "array",
      "maxItems": 64,
      "items": {
        "type": "string",
        "pattern": "^[^/:@\\s]+$",
        "maxLength": 253
      },
      "description": "Exact hostnames Dissent.fetch() may reach."
    },
    "config_schema": {
      "type": [
        "object",
        "null"
      ]
    },
    "maker": {
      "type": "object",
      "properties": {
        "support_url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://"
        }
      },
      "description": "Who the maker is comes from the publishing account, never from this field."
    },
    "commands": {
      "type": "array",
      "maxItems": 25,
      "description": "v2: what members can type in the chat box (Dissent suggests them with your plugin's name). The node reads the options from what was typed and runs the command in your server half (trigger \"command\") or, without one, in your panel (Dissent.onCommand).",
      "items": {
        "type": "object",
        "required": [
          "name",
          "description"
        ],
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_-]{0,31}$",
            "not": {
              "enum": [
                "gif",
                "me",
                "poll"
              ]
            }
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "options": {
            "type": "array",
            "maxItems": 10,
            "description": "Required options first. Typed as name:value, or in this order; the last string option takes the rest of the line.",
            "items": {
              "type": "object",
              "required": [
                "name"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "pattern": "^[a-z0-9][a-z0-9_-]{0,31}$"
                },
                "type": {
                  "enum": [
                    "string",
                    "integer",
                    "number",
                    "boolean"
                  ],
                  "default": "string"
                },
                "description": {
                  "type": "string",
                  "maxLength": 100
                },
                "required": {
                  "type": "boolean"
                }
              }
            }
          },
          "reply": {
            "enum": [
              "private",
              "public"
            ],
            "default": "private",
            "description": "private: only the person who typed it sees the answer. public: posted in the channel as your plugin — needs bot:post."
          }
        }
      }
    },
    "events": {
      "type": "array",
      "uniqueItems": true,
      "description": "v2: server events your server half is told about (trigger \"event\"). Ids and names only, never what anybody wrote. Shown to the admin at install and on the plugin's Permissions tab; an update that adds one waits for the admin.",
      "items": {
        "enum": [
          "member.joined",
          "member.left",
          "voice.joined",
          "voice.left",
          "reaction.on_own_post",
          "game.round_ended"
        ]
      }
    },
    "game_adapter": {
      "type": "object",
      "additionalProperties": false,
      "description": "Row 18: a game Dissent does not read itself. ONE source the DESKTOP app reads for this plugin (the frame only parses): tcp/http on a 127.0.0.1 port the game's own process owns, gsi (the game posts to Dissent after Dissent writes its own cfg), or files in the game's own folders. Rules across fields (deny-listed ports, exes and folders; the permission the kind needs: game:telemetry for live kinds, game:saves for files) are checked by the node and the kit (game-adapter-vector.json).",
      "required": [
        "game",
        "exe",
        "kind"
      ],
      "properties": {
        "game": {
          "type": "string",
          "minLength": 1,
          "maxLength": 48
        },
        "exe": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9 ._()+-]{0,59}\\.[Ee][Xx][Ee]$"
        },
        "kind": {
          "type": "string",
          "enum": [
            "tcp",
            "http",
            "gsi",
            "files"
          ]
        },
        "format": {
          "type": "string",
          "enum": [
            "json",
            "text"
          ]
        },
        "port": {
          "type": "integer",
          "minimum": 1024,
          "maximum": 65535
        },
        "path": {
          "type": "string",
          "maxLength": 128,
          "pattern": "^/[A-Za-z0-9/_.~%=&?-]*$"
        },
        "poll_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 60
        },
        "gsi": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "folder",
            "sections"
          ],
          "properties": {
            "folder": {
              "type": "string",
              "minLength": 1
            },
            "sections": {
              "type": "array",
              "minItems": 1,
              "maxItems": 16,
              "items": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_]{0,31}$"
              }
            }
          }
        },
        "files": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "root",
            "folder",
            "pattern"
          ],
          "properties": {
            "root": {
              "type": "string",
              "enum": [
                "steam_game",
                "appdata",
                "local_appdata",
                "locallow",
                "my_games",
                "saved_games"
              ]
            },
            "folder": {
              "type": "string",
              "minLength": 1
            },
            "pattern": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_*. -]{1,64}$"
            },
            "max_bytes": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1048576
            }
          }
        },
        "round_end": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "pointer",
            "equals"
          ],
          "properties": {
            "pointer": {
              "type": "string",
              "pattern": "^/",
              "maxLength": 128
            },
            "equals": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          }
        }
      }
    },
    "webhooks": {
      "type": "array",
      "maxItems": 5,
      "description": "v2: named webhooks. A server admin switches each on and gets a secret link; a POST to it runs your server half with trigger \"webhook\".",
      "items": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_-]{0,31}$"
          },
          "description": {
            "type": "string",
            "maxLength": 100
          }
        }
      }
    },
    "message_actions": {
      "type": "array",
      "maxItems": 5,
      "description": "v2: \"Send to <plugin>\" entries on the message menu (right-click / long-press). A member picks one, sees the message in Dissent's confirm card, and only then is that ONE message sent to your plugin (trigger \"message_action\", or Dissent.onMessageAction in your panel).",
      "items": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "description": "What the menu shows, e.g. \"Translate\". One line, unique (case-insensitive)."
          },
          "description": {
            "type": "string",
            "maxLength": 100
          }
        }
      }
    },
    "resources": {
      "type": "array"
    },
    "server_module": {
      "type": "object",
      "description": "The signed server half. Verified by the node."
    },
    "overlay": {
      "type": "object"
    },
    "game": {
      "type": "object"
    },
    "screenshots": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "$defs": {
    "permission": {
      "enum": [
        "profile:read",
        "bot:post",
        "fetch:external",
        "storage:user",
        "storage:server",
        "storage:local",
        "storage:log",
        "realtime",
        "identity",
        "members:read",
        "wallet",
        "voice",
        "media:embed",
        "game:telemetry",
        "game:saves",
        "overlay:context",
        "net:direct",
        "friends:link",
        "ai:choose",
        "ai:regions",
        "ai:read",
        "sparks:read",
        "sparks:award",
        "sparks:charge",
        "tournaments:report",
        "roles:assign"
      ]
    },
    "permissionList": {
      "type": "array",
      "maxItems": 32,
      "uniqueItems": true,
      "items": {
        "$ref": "#/$defs/permission"
      }
    }
  }
}
