{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://contio.ai/schemas/toolkit-manifest.schema.json",
  "$ref": "#/$defs/ToolkitManifest",
  "$defs": {
    "ManifestRef": {
      "properties": {
        "$ref": {
          "type": "string",
          "description": "Reference to an entity defined in the same manifest via its $id value. Use this to link to templates and next steps and action buttons defined elsewhere in this manifest."
        },
        "$id": {
          "type": "string",
          "description": "Reference to an existing entity by its database ID. Use this to link to pre-existing templates and next steps and action buttons that are not defined in this manifest."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "NextStepActionButtonRelation": {
      "properties": {
        "action_button": {
          "$ref": "#/$defs/ManifestRef",
          "description": "Reference to the action button entity. Use $ref for manifest-defined action buttons or $id for existing database entities."
        },
        "sort_order": {
          "type": "integer",
          "description": "Display order of this action button within the next step. Lower values appear first."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "action_button"
      ]
    },
    "TemplateNextStepRelation": {
      "properties": {
        "next_step": {
          "$ref": "#/$defs/ManifestRef",
          "description": "Reference to the next step entity. Use $ref for manifest-defined next steps or $id for existing database entities."
        },
        "sort_order": {
          "type": "integer",
          "description": "Display order of this next step within the template. Lower values appear first."
        },
        "autopilot": {
          "type": "boolean",
          "description": "When enabled the next step will automatically execute when the meeting is finalized."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "next_step"
      ]
    },
    "ToolkitActionButtonSpec": {
      "properties": {
        "$id": {
          "type": "string",
          "description": "Manifest-internal identifier for this action button. Other entries in the manifest can reference this action button using $ref with this value."
        },
        "name": {
          "type": "string",
          "description": "The display name of the action button."
        },
        "icon_url": {
          "type": "string",
          "description": "URL to an icon image for the action button."
        },
        "delivery_mechanism": {
          "type": "string",
          "enum": [
            "clipboard",
            "email",
            "os_email_client",
            "file_download",
            "integration",
            "webhook",
            "redirect"
          ],
          "title": "DeliveryType",
          "description": "How the action button delivers its output. Values: clipboard | email | os_email_client | file_download | integration | webhook | redirect."
        },
        "integration_type": {
          "type": "string",
          "description": "The type of integration such as 'slack' or 'salesforce'. Required when delivery_mechanism is 'integration'."
        },
        "webhook_url": {
          "type": "string",
          "description": "URL to send webhook payload. Required when delivery_mechanism is 'webhook'."
        },
        "redirect_url": {
          "type": "string",
          "description": "URL to redirect to. Required when delivery_mechanism is 'redirect'."
        },
        "file_format": {
          "type": "string",
          "description": "File format for downloads such as 'pdf' or 'docx'. Required when delivery_mechanism is 'file_download'."
        },
        "content_format": {
          "type": "string",
          "enum": [
            "rich_text",
            "markdown",
            "plain_text",
            "html"
          ],
          "title": "ContentFormat",
          "description": "The format of the action button output. Values: rich_text | markdown | plain_text | html."
        },
        "requires_connected_integration": {
          "type": "boolean",
          "description": "When enabled the user must have the integration connected before using this action button."
        },
        "is_default_for_next_step": {
          "type": "boolean",
          "description": "When enabled this action button is the default for its parent next step."
        },
        "sort_order": {
          "type": "integer",
          "description": "Display order of this action button. Lower values appear first."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name",
        "delivery_mechanism",
        "content_format"
      ]
    },
    "ToolkitManifest": {
      "properties": {
        "templates": {
          "items": {
            "$ref": "#/$defs/ToolkitManifestTemplate"
          },
          "type": "array",
          "description": "Meeting templates to include in the toolkit. Each entry can reference an existing template (by id) or define a new template to create (via spec)."
        },
        "next_steps": {
          "items": {
            "$ref": "#/$defs/ToolkitManifestNextStep"
          },
          "type": "array",
          "description": "Next steps to include in the toolkit. Each entry can reference an existing next step (by id) or define a new next step to create (via spec)."
        },
        "action_buttons": {
          "items": {
            "$ref": "#/$defs/ToolkitManifestActionButton"
          },
          "type": "array",
          "description": "Action buttons to include in the toolkit. Each entry can reference an existing action button (by id) or define a new action button to create (via spec)."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "ToolkitManifestActionButton": {
      "properties": {
        "id": {
          "type": "string",
          "description": "Reference an existing action button by its database ID. Mutually exclusive with spec."
        },
        "spec": {
          "$ref": "#/$defs/ToolkitActionButtonSpec",
          "description": "Define a new action button to create during toolkit installation. Mutually exclusive with id."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "ToolkitManifestNextStep": {
      "properties": {
        "id": {
          "type": "string",
          "description": "Reference an existing next step by its database ID. Mutually exclusive with spec."
        },
        "spec": {
          "$ref": "#/$defs/ToolkitNextStepSpec",
          "description": "Define a new next step to create during toolkit installation. Mutually exclusive with id."
        },
        "action_buttons": {
          "items": {
            "$ref": "#/$defs/NextStepActionButtonRelation"
          },
          "type": "array",
          "description": "Action buttons to attach to this next step. Each entry includes the action button reference and junction table fields (sort_order)."
        },
        "default_action_button": {
          "$ref": "#/$defs/ManifestRef",
          "description": "The default action button for this next step. This button will be highlighted or pre-selected in the UI."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "ToolkitManifestTemplate": {
      "properties": {
        "id": {
          "type": "string",
          "description": "Reference an existing meeting template by its database ID. Mutually exclusive with spec."
        },
        "spec": {
          "$ref": "#/$defs/ToolkitTemplateSpec",
          "description": "Define a new meeting template to create during toolkit installation. Mutually exclusive with id."
        },
        "next_steps": {
          "items": {
            "$ref": "#/$defs/TemplateNextStepRelation"
          },
          "type": "array",
          "description": "Next steps to attach to this template. Each entry includes the next step reference and junction table fields such as sort_order and autopilot."
        }
      },
      "additionalProperties": false,
      "type": "object"
    },
    "ToolkitNextStepSpec": {
      "properties": {
        "$id": {
          "type": "string",
          "description": "Manifest-internal identifier for this next step. Other entries in the manifest can reference this next step using $ref with this value."
        },
        "name": {
          "type": "string",
          "description": "The display name of the next step."
        },
        "description": {
          "type": "string",
          "description": "Optional description of the next step."
        },
        "icon_name": {
          "type": "string",
          "description": "Icon name from the icon library to display for this next step."
        },
        "color": {
          "type": "string",
          "description": "Color code (hex or named) for the next step display."
        },
        "ai_prompt": {
          "type": "string",
          "description": "AI prompt template used when type is 'ai'. This prompt is sent to the AI model to generate the next step content."
        },
        "type": {
          "type": "string",
          "enum": [
            "ai",
            "redirect"
          ],
          "title": "NextStepType",
          "description": "The type of next step: 'ai' for AI-powered prompts or 'redirect' for URL navigation."
        },
        "redirect_url": {
          "type": "string",
          "description": "URL to redirect to when type is 'redirect'. Required when type is 'redirect'."
        },
        "sort_order": {
          "type": "integer",
          "description": "Display order of this next step. Lower values appear first."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name",
        "type"
      ]
    },
    "ToolkitTemplateSpec": {
      "properties": {
        "$id": {
          "type": "string",
          "description": "Manifest-internal identifier for this template. Other entries in the manifest can reference this template using $ref with this value."
        },
        "name": {
          "type": "string",
          "description": "The display name of the meeting template."
        },
        "description": {
          "type": "string",
          "description": "Optional description of the meeting template."
        },
        "backing_meeting_id": {
          "type": "string",
          "description": "Reference an existing meeting to use as the content source for this template. The meeting's agenda items and participants and documents and talking points are copied to the new template during installation."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "name"
      ]
    }
  },
  "title": "Contio Toolkit Manifest",
  "description": "Schema for Contio Partner API toolkit manifests. A Toolkit defines a set of templates, next steps, and action buttons that are bundled together and can be installed on workspaces.",
  "x-api-version": "1.5"
}
