{
  "openapi": "3.1.0",
  "info": {
    "title": "RunVero structured tool API",
    "version": "1.0.0",
    "description": "Integration reference for authenticated discovery and structured execution. Covers a supported subset of the data-plane API, not console management or all advanced execution fields. Tool availability and schemas are discovered at runtime. Cloud is in private preview."
  },
  "servers": [
    {
      "url": "https://api.runvero.dev",
      "description": "Cloud; use your authorized workspace endpoint."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/tools": {
      "get": {
        "operationId": "listTools",
        "summary": "Discover permitted tools and argument schemas",
        "responses": {
          "200": {
            "description": "Current catalog for this key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tools": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Tool"
                      }
                    }
                  },
                  "required": [
                    "tools"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Authentication or gateway failure; envelope may vary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/execute": {
      "post": {
        "operationId": "executeTool",
        "summary": "Execute a structured tool within policy",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "Required on Cloud. Reuse with the exact body for retries; changed body returns 409. Self-hosted gateways do not deduplicate.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExecuteRequest"
              },
              "example": {
                "tool": "sqlite-runner",
                "arguments": {
                  "query": "SELECT 3 * 1200 + 2 * 450 AS total_cents"
                },
                "fuel": 10000000,
                "memory_mb": 64,
                "timeout_ms": 5000,
                "allowed_hosts": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tool output and resource usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecuteResponse"
                }
              }
            }
          },
          "default": {
            "description": "Execution or gateway failure. Check status and code; do not assume retries are side-effect free.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Data-plane API key from your authorized workspace; not a console session token."
      }
    },
    "schemas": {
      "Tool": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "input_schema": {
            "type": "object"
          },
          "examples": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "resources": {
            "type": "object"
          },
          "capabilities": {
            "type": "object"
          }
        },
        "required": [
          "name",
          "input_schema"
        ]
      },
      "ExecuteRequest": {
        "type": "object",
        "properties": {
          "tool": {
            "type": "string"
          },
          "arguments": {
            "type": "object",
            "description": "Validate against the selected tool input_schema from GET /v1/tools."
          },
          "fuel": {
            "type": "integer",
            "minimum": 0
          },
          "memory_mb": {
            "type": "integer",
            "minimum": 0
          },
          "timeout_ms": {
            "type": "integer",
            "minimum": 0
          },
          "allowed_hosts": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Narrows the operator policy; an empty list disables outbound HTTP."
          }
        },
        "required": [
          "tool",
          "arguments"
        ],
        "additionalProperties": false,
        "description": "Structured catalog execution subset. Raw-string tools, inline secrets and raw sockets are intentionally outside this integration reference."
      },
      "ExecuteResponse": {
        "type": "object",
        "properties": {
          "execution_id": {
            "type": "string"
          },
          "output": {
            "type": "string",
            "description": "Tool-specific string; may contain JSON. Parse according to the tool contract."
          },
          "fuel_consumed": {
            "type": "integer",
            "minimum": 0
          },
          "memory_peak_bytes": {
            "type": "integer",
            "minimum": 0
          },
          "latency_ms": {
            "type": "number"
          },
          "egress_denials": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "output",
          "fuel_consumed"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          }
        },
        "required": []
      }
    }
  }
}
