{
  "openapi": "3.1.0",
  "info": {
    "title": "BapStack AI development prototype",
    "version": "0.3.0",
    "description": "Synthetic data only. Cookie workspace identity is not ACS authentication. Live plugin HTTP routes are not enabled."
  },
  "servers": [
    {
      "url": "https://ai-dev.bapstack.com"
    }
  ],
  "security": [
    {
      "demoSession": []
    }
  ],
  "components": {
    "securitySchemes": {
      "demoSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "bap_demo",
        "description": "Secure browser demo cookie. Issued by the prototype; no live app authority."
      }
    }
  },
  "paths": {
    "/api/runtime": {
      "get": {
        "summary": "Public runtime flags",
        "security": [],
        "responses": {
          "200": {
            "description": "Runtime mode"
          }
        }
      }
    },
    "/api/catalog": {
      "get": {
        "summary": "Scoped function discovery",
        "parameters": [
          {
            "name": "conversationId",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Scoped demo catalog, activity and usage"
          }
        }
      }
    },
    "/api/scope": {
      "post": {
        "summary": "Set chat app scope",
        "parameters": [
          {
            "in": "header",
            "name": "X-BapStack-Request",
            "required": true,
            "schema": {
              "type": "string",
              "const": "prototype"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "conversationId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "appIds": {
                    "type": "array",
                    "minItems": 1,
                    "uniqueItems": true,
                    "items": {
                      "type": "string",
                      "enum": [
                        "selectorcrate",
                        "samplehoarder",
                        "massivecue",
                        "waxbridge",
                        "mixtapebeacon",
                        "linkup-promoter"
                      ]
                    }
                  }
                },
                "required": [
                  "conversationId",
                  "appIds"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result or review proposal"
          },
          "400": {
            "description": "Invalid input or unavailable scope"
          },
          "403": {
            "description": "Origin rejected"
          }
        }
      }
    },
    "/api/chat": {
      "post": {
        "summary": "Query the deterministic chat router",
        "parameters": [
          {
            "in": "header",
            "name": "X-BapStack-Request",
            "required": true,
            "schema": {
              "type": "string",
              "const": "prototype"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "conversationId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "prompt": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  }
                },
                "required": [
                  "conversationId",
                  "prompt"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result or review proposal"
          },
          "400": {
            "description": "Invalid input or unavailable scope"
          },
          "403": {
            "description": "Origin rejected"
          }
        }
      }
    },
    "/api/prepare": {
      "post": {
        "summary": "Run a demo query or prepare a reviewed action",
        "parameters": [
          {
            "in": "header",
            "name": "X-BapStack-Request",
            "required": true,
            "schema": {
              "type": "string",
              "const": "prototype"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "capabilityId": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "input": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "conversationId": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "capabilityId",
                  "input"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result or review proposal"
          },
          "400": {
            "description": "Invalid input or unavailable scope"
          },
          "403": {
            "description": "Origin rejected"
          }
        }
      }
    },
    "/api/execute": {
      "post": {
        "summary": "Execute a reviewed demo action once",
        "parameters": [
          {
            "in": "header",
            "name": "X-BapStack-Request",
            "required": true,
            "schema": {
              "type": "string",
              "const": "prototype"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "proposalId": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "proposalId"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result or review proposal"
          },
          "400": {
            "description": "Invalid input or unavailable scope"
          },
          "403": {
            "description": "Origin rejected"
          }
        }
      }
    },
    "/api/audio": {
      "get": {
        "summary": "Stream known scoped audio; hosted previews are synthetic",
        "parameters": [
          {
            "name": "appId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "selectorcrate",
                "samplehoarder"
              ]
            }
          },
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 160
            }
          },
          {
            "name": "conversationId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Range",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Audio"
          },
          "206": {
            "description": "Single byte range"
          },
          "400": {
            "description": "Invalid or unscoped item"
          },
          "404": {
            "description": "Unavailable audio"
          },
          "416": {
            "description": "Unsatisfiable range"
          }
        }
      },
      "head": {
        "summary": "Stream known scoped audio; hosted previews are synthetic",
        "parameters": [
          {
            "name": "appId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "selectorcrate",
                "samplehoarder"
              ]
            }
          },
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 160
            }
          },
          {
            "name": "conversationId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "Range",
            "in": "header",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Audio"
          },
          "206": {
            "description": "Single byte range"
          },
          "400": {
            "description": "Invalid or unscoped item"
          },
          "404": {
            "description": "Unavailable audio"
          },
          "416": {
            "description": "Unsatisfiable range"
          }
        }
      }
    }
  }
}
