{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "format": {
      "type": "number",
      "const": 1
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]{1,23}$"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 60
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
    },
    "author": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "licence": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "homepage": {
      "type": "string",
      "format": "uri"
    },
    "summary": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "minApp": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
    },
    "instructions": {
      "type": "string",
      "maxLength": 200,
      "pattern": "^[A-Za-z0-9_][A-Za-z0-9._-]*(\\/[A-Za-z0-9_][A-Za-z0-9._-]*)*$"
    },
    "data": {
      "default": {},
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_]{0,31}$"
      },
      "additionalProperties": {
        "type": "string",
        "maxLength": 200,
        "pattern": "^[A-Za-z0-9_][A-Za-z0-9._-]*(\\/[A-Za-z0-9_][A-Za-z0-9._-]*)*$"
      }
    },
    "assets": {
      "default": [],
      "maxItems": 500,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9_-]{0,63}$"
          },
          "path": {
            "type": "string",
            "maxLength": 200,
            "pattern": "^[A-Za-z0-9_][A-Za-z0-9._-]*(\\/[A-Za-z0-9_][A-Za-z0-9._-]*)*$"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "type": {
            "type": "string",
            "enum": [
              "image/png",
              "image/jpeg",
              "image/webp"
            ]
          },
          "bytes": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20000000
          },
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "licence": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "source": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          }
        },
        "required": [
          "id",
          "type",
          "bytes",
          "sha256",
          "licence",
          "source"
        ],
        "additionalProperties": false
      }
    },
    "tools": {
      "default": [],
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{0,31}$"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          },
          "parameters": {
            "default": {},
            "type": "object",
            "propertyNames": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,31}$"
            },
            "additionalProperties": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "string",
                    "number",
                    "integer",
                    "boolean"
                  ]
                },
                "description": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 300
                },
                "enum": {
                  "minItems": 1,
                  "maxItems": 100,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  }
                },
                "enumFrom": {
                  "type": "object",
                  "properties": {
                    "table": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,31}$"
                    },
                    "column": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64
                    }
                  },
                  "required": [
                    "table",
                    "column"
                  ],
                  "additionalProperties": false
                },
                "required": {
                  "default": false,
                  "type": "boolean"
                },
                "default": {
                  "type": [
                    "string",
                    "number",
                    "boolean"
                  ]
                },
                "minimum": {
                  "type": "number"
                },
                "maximum": {
                  "type": "number"
                }
              },
              "required": [
                "type",
                "description"
              ],
              "additionalProperties": false
            }
          },
          "steps": {
            "minItems": 1,
            "maxItems": 20,
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "use": {
                      "type": "string",
                      "const": "draw"
                    },
                    "as": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,31}$"
                    },
                    "table": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,31}$"
                    },
                    "count": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\$[a-z][a-z0-9_]*(\\.[A-Za-z0-9_]+)*$"
                        },
                        {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 100
                        }
                      ]
                    },
                    "slots": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\$[a-z][a-z0-9_]*(\\.[A-Za-z0-9_]+)*$"
                        },
                        {
                          "minItems": 1,
                          "maxItems": 100,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 60
                          }
                        }
                      ]
                    },
                    "reversed": {
                      "default": 0,
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\$[a-z][a-z0-9_]*(\\.[A-Za-z0-9_]+)*$"
                        },
                        {
                          "anyOf": [
                            {
                              "type": "number",
                              "minimum": 0,
                              "maximum": 1
                            },
                            {
                              "type": "boolean"
                            }
                          ]
                        }
                      ]
                    }
                  },
                  "required": [
                    "use",
                    "as",
                    "table"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "use": {
                      "type": "string",
                      "const": "roll"
                    },
                    "as": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,31}$"
                    },
                    "dice": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\$[a-z][a-z0-9_]*(\\.[A-Za-z0-9_]+)*$"
                        },
                        {
                          "type": "string",
                          "pattern": "^\\d{0,2}d\\d{1,3}([+-]\\d{1,3})?$"
                        }
                      ]
                    }
                  },
                  "required": [
                    "use",
                    "as",
                    "dice"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "use": {
                      "type": "string",
                      "const": "lookup"
                    },
                    "as": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,31}$"
                    },
                    "table": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,31}$"
                    },
                    "key": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\$[a-z][a-z0-9_]*(\\.[A-Za-z0-9_]+)*$"
                        },
                        {
                          "anyOf": [
                            {
                              "type": "string",
                              "minLength": 1
                            },
                            {
                              "type": "number"
                            }
                          ]
                        }
                      ]
                    },
                    "by": {
                      "default": "id",
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 64
                    }
                  },
                  "required": [
                    "use",
                    "as",
                    "table",
                    "key"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "use": {
                      "type": "string",
                      "const": "template"
                    },
                    "as": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,31}$"
                    },
                    "text": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 2000
                    }
                  },
                  "required": [
                    "use",
                    "as",
                    "text"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "use": {
                      "type": "string",
                      "const": "state"
                    },
                    "as": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,31}$"
                    },
                    "op": {
                      "type": "string",
                      "enum": [
                        "get",
                        "set",
                        "append",
                        "clear"
                      ]
                    },
                    "key": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,31}$"
                    },
                    "value": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\$[a-z][a-z0-9_]*(\\.[A-Za-z0-9_]+)*$"
                        },
                        {
                          "$ref": "#/$defs/__schema0"
                        }
                      ]
                    }
                  },
                  "required": [
                    "use",
                    "op",
                    "key"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "use": {
                      "type": "string",
                      "const": "show"
                    },
                    "board": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,31}$"
                    },
                    "items": {
                      "type": "string",
                      "pattern": "^\\$[a-z][a-z0-9_]*(\\.[A-Za-z0-9_]+)*$"
                    },
                    "title": {
                      "anyOf": [
                        {
                          "type": "string",
                          "pattern": "^\\$[a-z][a-z0-9_]*(\\.[A-Za-z0-9_]+)*$"
                        },
                        {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2000
                        }
                      ]
                    }
                  },
                  "required": [
                    "use",
                    "board",
                    "items"
                  ],
                  "additionalProperties": false
                }
              ]
            }
          },
          "returns": {
            "minItems": 1,
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,31}$"
            }
          },
          "policy": {
            "default": "auto",
            "type": "string",
            "enum": [
              "auto",
              "ask"
            ]
          }
        },
        "required": [
          "name",
          "description",
          "steps",
          "returns"
        ],
        "additionalProperties": false
      }
    },
    "boards": {
      "default": {},
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_]{0,31}$"
      },
      "additionalProperties": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "layout": {
                "type": "string",
                "const": "cards"
              },
              "where": {
                "default": "screen",
                "type": "string",
                "enum": [
                  "screen",
                  "whiteboard"
                ]
              },
              "image": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              },
              "caption": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2000
              },
              "flip": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
              }
            },
            "required": [
              "layout",
              "image",
              "caption"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "layout": {
                "type": "string",
                "const": "list"
              },
              "where": {
                "default": "screen",
                "type": "string",
                "enum": [
                  "screen",
                  "whiteboard"
                ]
              },
              "line": {
                "type": "string",
                "minLength": 1,
                "maxLength": 2000
              }
            },
            "required": [
              "layout",
              "line"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "mcp": {
      "default": [],
      "maxItems": 10,
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_]{0,31}$"
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "transport": {
                "type": "string",
                "const": "http"
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "id",
              "name",
              "transport",
              "url"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_]{0,31}$"
              },
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "transport": {
                "type": "string",
                "const": "stdio"
              },
              "command": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200
              },
              "args": {
                "default": [],
                "maxItems": 40,
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 500
                }
              }
            },
            "required": [
              "id",
              "name",
              "transport",
              "command"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "schedules": {
      "default": [],
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{0,31}$"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "cron": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "taskPrompt": {
            "type": "string",
            "maxLength": 2000
          },
          "tools": {
            "default": [],
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 64
            }
          },
          "delivery": {
            "type": "string",
            "enum": [
              "speak_next_session",
              "notify",
              "silent_log"
            ]
          },
          "catchUp": {
            "default": "skip",
            "type": "string",
            "enum": [
              "skip",
              "run_once",
              "run_all"
            ]
          }
        },
        "required": [
          "id",
          "description",
          "cron",
          "taskPrompt",
          "delivery"
        ],
        "additionalProperties": false
      }
    },
    "settings": {
      "default": {},
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_]{0,31}$"
      },
      "additionalProperties": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "text"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "default": {
                "type": "string",
                "maxLength": 500
              }
            },
            "required": [
              "type",
              "label",
              "default"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "number"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "default": {
                "type": "number"
              },
              "minimum": {
                "type": "number"
              },
              "maximum": {
                "type": "number"
              }
            },
            "required": [
              "type",
              "label",
              "default"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "switch"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "default": {
                "type": "boolean"
              }
            },
            "required": [
              "type",
              "label",
              "default"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "choice"
              },
              "label": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "choices": {
                "minItems": 2,
                "maxItems": 20,
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 60
                }
              },
              "default": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "type",
              "label",
              "choices",
              "default"
            ],
            "additionalProperties": false
          }
        ]
      }
    }
  },
  "required": [
    "format",
    "id",
    "name",
    "version",
    "author",
    "licence",
    "summary",
    "minApp",
    "instructions"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    }
  },
  "title": "latentPresence plugin manifest",
  "description": "plugin.json, format 1 (ADR-72). Cross-references are checked by `pnpm plugin:check`."
}
