{
  "openapi": "3.0.3",
  "info": {
    "title": "Delegentra Workbench — Local API",
    "version": "0.2",
    "description": "Partial reference for the Workbench endpoints. Local single-user runtime; no api.delegentra.com service is deployed. Other Foundation endpoints remain documented in the portable README."
  },
  "servers": [
    {
      "url": "http://127.0.0.1:8765",
      "description": "Local default; actual port comes from the terminal URL"
    }
  ],
  "components": {
    "securitySchemes": {
      "LocalSession": {
        "type": "apiKey",
        "in": "header",
        "name": "X-AF-Token"
      }
    }
  },
  "paths": {
    "/api/config": {
      "get": {
        "summary": "Sanitised runtime configuration",
        "security": [
          {
            "LocalSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Provider/model/pipeline and credential-present boolean"
          },
          "403": {
            "description": "Invalid or missing session token"
          }
        }
      }
    },
    "/api/state": {
      "get": {
        "summary": "Local tasks, roles, approvals and pause control",
        "security": [
          {
            "LocalSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "Single-user workspace state"
          },
          "403": {
            "description": "Invalid or missing session token"
          }
        }
      }
    },
    "/api/task": {
      "post": {
        "summary": "Queue a task; external actions are not executed",
        "security": [
          {
            "LocalSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "request"
                ],
                "properties": {
                  "request": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 12000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Queued task ID"
          },
          "400": {
            "description": "Invalid request or paused/full queue"
          },
          "403": {
            "description": "Invalid token, host or origin"
          }
        }
      }
    },
    "/api/task/{id}": {
      "get": {
        "summary": "Inspect task status and stage outputs",
        "security": [
          {
            "LocalSession": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Task record"
          },
          "400": {
            "description": "Task not found"
          },
          "403": {
            "description": "Invalid or missing session token"
          }
        }
      }
    },
    "/api/openapi.json": {
      "get": {
        "summary": "This local API reference",
        "security": [
          {
            "LocalSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "OpenAPI document"
          },
          "403": {
            "description": "Invalid or missing session token"
          }
        }
      }
    }
  }
}