{
  "openapi": "3.0.1",
  "info": {
    "title": "Codex API",
    "description": "CQRS-based API using OpenHarbor.CQRS framework",
    "version": "v1"
  },
  "paths": {
    "/api/command/createAgent": {
      "post": {
        "tags": [
          "createAgent"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAgentCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAgentCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAgentCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/command/deleteAgent": {
      "post": {
        "tags": [
          "deleteAgent"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteAgentCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteAgentCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteAgentCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/query/getAgent": {
      "post": {
        "tags": [
          "getAgent"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GetAgentQuery"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/GetAgentQuery"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/GetAgentQuery"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetAgentQueryResult"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "getAgent"
        ],
        "parameters": [
          {
            "name": "Id",
            "in": "query",
            "description": "ID of the agent to retrieve",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetAgentQueryResult"
                }
              }
            }
          }
        }
      }
    },
    "/api/query/health": {
      "post": {
        "tags": [
          "health"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HealthQuery"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/HealthQuery"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/HealthQuery"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "health"
        ],
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/HealthQuery"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      }
    },
    "/api/command/updateAgent": {
      "post": {
        "tags": [
          "updateAgent"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAgentCommand"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAgentCommand"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAgentCommand"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AgentStatus": {
        "enum": [
          "Active",
          "Inactive",
          "Error"
        ],
        "type": "string",
        "description": "Represents the current status of an agent."
      },
      "AgentType": {
        "enum": [
          "CodeGenerator",
          "CodeReviewer",
          "Debugger",
          "Documenter",
          "Custom"
        ],
        "type": "string",
        "description": "Specifies the type/purpose of the agent."
      },
      "CreateAgentCommand": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Display name of the agent",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Description of the agent's purpose and capabilities",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/AgentType"
          },
          "modelProvider": {
            "type": "string",
            "description": "Model provider name (e.g., \"openai\", \"anthropic\", \"ollama\")",
            "nullable": true
          },
          "modelName": {
            "type": "string",
            "description": "Specific model name (e.g., \"gpt-4o\", \"claude-3.5-sonnet\", \"codellama:7b\")",
            "nullable": true
          },
          "providerType": {
            "$ref": "#/components/schemas/ModelProviderType"
          },
          "modelEndpoint": {
            "type": "string",
            "description": "Model endpoint URL (required for LocalEndpoint, optional for CloudApi)",
            "nullable": true
          },
          "apiKey": {
            "type": "string",
            "description": "API key for cloud providers (will be encrypted). Not required for local endpoints.",
            "nullable": true
          },
          "temperature": {
            "type": "number",
            "description": "Temperature parameter for model generation (0.0 to 2.0, default: 0.7)",
            "format": "double"
          },
          "maxTokens": {
            "type": "integer",
            "description": "Maximum tokens to generate in response (default: 4000)",
            "format": "int32"
          },
          "systemPrompt": {
            "type": "string",
            "description": "System prompt defining agent behavior and instructions",
            "nullable": true
          },
          "enableMemory": {
            "type": "boolean",
            "description": "Whether conversation memory is enabled for this agent (default: true)"
          },
          "conversationWindowSize": {
            "type": "integer",
            "description": "Number of recent messages to include in context (default: 10, range: 1-100)",
            "format": "int32"
          }
        },
        "additionalProperties": false,
        "description": "Command to create a new AI agent with configuration"
      },
      "DeleteAgentCommand": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID of the agent to delete",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "description": "Command to soft-delete an agent"
      },
      "GetAgentQuery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID of the agent to retrieve",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "description": "Query to get a single agent by ID"
      },
      "GetAgentQueryResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/AgentType"
          },
          "modelProvider": {
            "type": "string",
            "nullable": true
          },
          "modelName": {
            "type": "string",
            "nullable": true
          },
          "providerType": {
            "$ref": "#/components/schemas/ModelProviderType"
          },
          "modelEndpoint": {
            "type": "string",
            "nullable": true
          },
          "temperature": {
            "type": "number",
            "format": "double"
          },
          "maxTokens": {
            "type": "integer",
            "format": "int32"
          },
          "systemPrompt": {
            "type": "string",
            "nullable": true
          },
          "enableMemory": {
            "type": "boolean"
          },
          "conversationWindowSize": {
            "type": "integer",
            "format": "int32"
          },
          "status": {
            "$ref": "#/components/schemas/AgentStatus"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Response containing agent details"
      },
      "HealthQuery": {
        "type": "object",
        "additionalProperties": false,
        "description": "Health check query to verify API availability"
      },
      "ModelProviderType": {
        "enum": [
          "CloudApi",
          "LocalEndpoint",
          "Custom"
        ],
        "type": "string",
        "description": "Specifies the type of model provider (cloud API or local endpoint)."
      },
      "UpdateAgentCommand": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID of the agent to update",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "Display name of the agent",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "Description of the agent's purpose and capabilities",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/AgentType"
          },
          "modelProvider": {
            "type": "string",
            "description": "Model provider name (e.g., \"openai\", \"anthropic\", \"ollama\")",
            "nullable": true
          },
          "modelName": {
            "type": "string",
            "description": "Specific model name (e.g., \"gpt-4o\", \"claude-3.5-sonnet\", \"codellama:7b\")",
            "nullable": true
          },
          "providerType": {
            "$ref": "#/components/schemas/ModelProviderType"
          },
          "modelEndpoint": {
            "type": "string",
            "description": "Model endpoint URL (required for LocalEndpoint, optional for CloudApi)",
            "nullable": true
          },
          "apiKey": {
            "type": "string",
            "description": "API key for cloud providers (will be encrypted). Leave null to keep existing key.",
            "nullable": true
          },
          "temperature": {
            "type": "number",
            "description": "Temperature parameter for model generation (0.0 to 2.0)",
            "format": "double"
          },
          "maxTokens": {
            "type": "integer",
            "description": "Maximum tokens to generate in response",
            "format": "int32"
          },
          "systemPrompt": {
            "type": "string",
            "description": "System prompt defining agent behavior and instructions",
            "nullable": true
          },
          "enableMemory": {
            "type": "boolean",
            "description": "Whether conversation memory is enabled for this agent"
          },
          "conversationWindowSize": {
            "type": "integer",
            "description": "Number of recent messages to include in context (1-100)",
            "format": "int32"
          },
          "status": {
            "$ref": "#/components/schemas/AgentStatus"
          }
        },
        "additionalProperties": false,
        "description": "Command to update an existing agent's configuration"
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "apiKey",
        "description": "JWT Authorization header using the Bearer scheme. Example: \"Bearer {token}\"",
        "name": "Authorization",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "Bearer": [ ]
    }
  ]
}