{
  "$id": "https://ui.kitn.ai/schemas/construct/v1.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "name": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9]*-[a-z0-9-]+$"
    },
    "layout": {
      "type": "string",
      "enum": [
        "widget",
        "fullscreen",
        "aside",
        "split",
        "custom"
      ]
    },
    "provider": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "mode": {
              "type": "string",
              "const": "mock"
            }
          },
          "required": [
            "mode"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "mode": {
              "type": "string",
              "const": "endpoint"
            },
            "url": {
              "type": "string",
              "minLength": 1
            },
            "wire": {
              "type": "string",
              "enum": [
                "openai",
                "anthropic"
              ]
            }
          },
          "required": [
            "mode",
            "url",
            "wire"
          ],
          "additionalProperties": false
        }
      ]
    },
    "userId": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[\\x20-\\x7E]+$"
    },
    "theme": {
      "type": "object",
      "properties": {
        "accent": {
          "type": "string"
        },
        "unreadColor": {
          "type": "string"
        },
        "mode": {
          "default": "system",
          "type": "string",
          "enum": [
            "light",
            "dark",
            "system"
          ]
        },
        "tokens": {
          "type": "object",
          "properties": {
            "light": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            },
            "dark": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            },
            "radius": {
              "type": "string",
              "minLength": 1
            },
            "fonts": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {
                "type": "string"
              }
            }
          },
          "additionalProperties": false
        }
      },
      "required": [
        "mode"
      ],
      "additionalProperties": false
    },
    "header": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1
        },
        "themeToggle": {
          "type": "boolean"
        },
        "actions": {
          "minItems": 1,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string",
                "minLength": 1
              },
              "variant": {
                "type": "string",
                "enum": [
                  "default",
                  "ghost",
                  "subtle",
                  "outline",
                  "destructive"
                ]
              }
            },
            "required": [
              "label"
            ],
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "empty": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "icon": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "title"
      ],
      "additionalProperties": false
    },
    "home": {
      "type": "object",
      "properties": {
        "greeting": {
          "type": "object",
          "properties": {
            "title": {
              "type": "string",
              "minLength": 1
            },
            "subtitle": {
              "type": "string",
              "minLength": 1
            }
          },
          "additionalProperties": false
        },
        "recentConversation": {
          "type": "boolean",
          "const": true
        },
        "newConversation": {
          "type": "object",
          "properties": {
            "label": {
              "type": "string",
              "minLength": 1
            }
          },
          "additionalProperties": false
        },
        "links": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string",
                "minLength": 1
              },
              "href": {
                "type": "string",
                "minLength": 1
              },
              "description": {
                "type": "string",
                "minLength": 1
              },
              "icon": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "label"
            ],
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "capabilities": {
      "type": "object",
      "properties": {
        "starters": {
          "minItems": 1,
          "maxItems": 6,
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "attachments": {
          "type": "object",
          "properties": {
            "accept": {
              "minItems": 1,
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "required": [
            "accept"
          ],
          "additionalProperties": false
        },
        "history": {
          "type": "object",
          "properties": {
            "persistence": {
              "type": "string",
              "enum": [
                "none",
                "local",
                "endpoint"
              ]
            },
            "url": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "persistence"
          ],
          "additionalProperties": false
        },
        "reasoning": {
          "type": "string",
          "enum": [
            "full",
            "compact",
            "off"
          ]
        },
        "reasoningOpen": {
          "type": "boolean"
        },
        "conversations": {
          "type": "boolean",
          "const": true
        },
        "messageActions": {
          "type": "object",
          "properties": {
            "user": {
              "minItems": 1,
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "copy",
                  "like",
                  "dislike",
                  "regenerate",
                  "edit",
                  "speak"
                ]
              }
            },
            "assistant": {
              "minItems": 1,
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "copy",
                  "like",
                  "dislike",
                  "regenerate",
                  "edit",
                  "speak"
                ]
              }
            }
          },
          "additionalProperties": false
        },
        "sources": {
          "type": "object",
          "properties": {
            "strip": {
              "type": "boolean"
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "cards": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$"
          },
          "schema": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "required": [
          "name",
          "schema"
        ],
        "additionalProperties": false
      }
    },
    "slots": {
      "minItems": 1,
      "maxItems": 8,
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9-]*$"
      }
    },
    "widget": {
      "type": "object",
      "properties": {
        "position": {
          "type": "string",
          "enum": [
            "bottom-end",
            "bottom-start",
            "top-end",
            "top-start"
          ]
        },
        "launcherIcon": {
          "type": "string",
          "minLength": 1
        },
        "defaultOpen": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "aside": {
      "type": "object",
      "properties": {
        "position": {
          "type": "string",
          "enum": [
            "start",
            "end"
          ]
        },
        "width": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "workSurface": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "artifact",
            "preview"
          ]
        },
        "url": {
          "type": "string",
          "minLength": 1
        },
        "codeUrl": {
          "type": "string",
          "minLength": 1
        },
        "chrome": {
          "type": "object",
          "properties": {
            "deviceToggle": {
              "type": "boolean"
            },
            "urlBar": {
              "type": "boolean"
            },
            "openInNewTab": {
              "type": "boolean"
            },
            "expand": {
              "type": "boolean"
            },
            "codeView": {
              "type": "boolean"
            }
          },
          "additionalProperties": false
        }
      },
      "required": [
        "kind",
        "url"
      ],
      "additionalProperties": false
    },
    "shell": {
      "type": "object",
      "properties": {
        "commandPalette": {
          "type": "boolean",
          "const": true
        },
        "userMenu": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1
            },
            "plan": {
              "type": "string",
              "minLength": 1
            }
          },
          "required": [
            "name"
          ],
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "composer": {
      "type": "object",
      "properties": {
        "triggers": {
          "type": "object",
          "properties": {
            "slash": {
              "minItems": 1,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1
                  },
                  "description": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "id",
                  "label"
                ],
                "additionalProperties": false
              }
            },
            "mention": {
              "minItems": 1,
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1
                  },
                  "description": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "id",
                  "label"
                ],
                "additionalProperties": false
              }
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "name",
    "layout",
    "provider"
  ],
  "additionalProperties": false
}
