{ "openapi": "3.0.1", "info": { "title": "Codex API", "description": "CQRS-based API using OpenHarbor.CQRS framework", "version": "v1" }, "paths": { "/api/agents": { "get": { "tags": [ "Agents" ], "summary": "Get all agents", "description": "Returns a list of all active agents with metadata. Limit: 100 most recent.", "operationId": "GetAllAgents", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { } } } } } } }, "/api/agents/{id}/conversations": { "get": { "tags": [ "Agents" ], "summary": "Get conversations for an agent", "description": "Returns all conversations associated with a specific agent.", "operationId": "GetAgentConversations", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { } } } } } } }, "/api/agents/{id}/executions": { "get": { "tags": [ "Agents" ], "summary": "Get execution history for an agent", "description": "Returns the 100 most recent executions for a specific agent.", "operationId": "GetAgentExecutions", "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { } } } } } } }, "/api/command/completeAgentExecution": { "post": { "tags": [ "completeAgentExecution" ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CompleteAgentExecutionCommand" } }, "text/json": { "schema": { "$ref": "#/components/schemas/CompleteAgentExecutionCommand" } }, "application/*+json": { "schema": { "$ref": "#/components/schemas/CompleteAgentExecutionCommand" } } } }, "responses": { "200": { "description": "OK" } } } }, "/api/conversations": { "get": { "tags": [ "Conversations" ], "summary": "Get all conversations", "description": "Returns the 100 most recent conversations.", "operationId": "GetAllConversations", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { } } } } } } }, "/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/createConversation": { "post": { "tags": [ "createConversation" ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateConversationCommand" } }, "text/json": { "schema": { "$ref": "#/components/schemas/CreateConversationCommand" } }, "application/*+json": { "schema": { "$ref": "#/components/schemas/CreateConversationCommand" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "string", "format": "uuid" } } } } } } }, "/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/executions": { "get": { "tags": [ "Executions" ], "summary": "Get all executions", "description": "Returns the 100 most recent executions across all agents.", "operationId": "GetAllExecutions", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { } } } } } } }, "/api/executions/status/{status}": { "get": { "tags": [ "Executions" ], "summary": "Get executions by status", "description": "Returns executions filtered by status (Pending, Running, Completed, Failed, Cancelled).", "operationId": "GetExecutionsByStatus", "parameters": [ { "name": "status", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { } } } }, "400": { "description": "Bad Request" } } } }, "/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/getAgentExecution": { "post": { "tags": [ "getAgentExecution" ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GetAgentExecutionQuery" } }, "text/json": { "schema": { "$ref": "#/components/schemas/GetAgentExecutionQuery" } }, "application/*+json": { "schema": { "$ref": "#/components/schemas/GetAgentExecutionQuery" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AgentExecutionDetails" } } } } } }, "get": { "tags": [ "getAgentExecution" ], "parameters": [ { "name": "Id", "in": "query", "description": "Execution ID", "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/AgentExecutionDetails" } } } } } } }, "/api/query/getConversation": { "post": { "tags": [ "getConversation" ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/GetConversationQuery" } }, "text/json": { "schema": { "$ref": "#/components/schemas/GetConversationQuery" } }, "application/*+json": { "schema": { "$ref": "#/components/schemas/GetConversationQuery" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ConversationDetails" } } } } } }, "get": { "tags": [ "getConversation" ], "parameters": [ { "name": "Id", "in": "query", "description": "Conversation ID", "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ConversationDetails" } } } } } } }, "/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/sendMessage": { "post": { "tags": [ "sendMessage" ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SendMessageCommand" } }, "text/json": { "schema": { "$ref": "#/components/schemas/SendMessageCommand" } }, "application/*+json": { "schema": { "$ref": "#/components/schemas/SendMessageCommand" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SendMessageResult" } } } } } } }, "/api/command/startAgentExecution": { "post": { "tags": [ "startAgentExecution" ], "requestBody": { "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StartAgentExecutionCommand" } }, "text/json": { "schema": { "$ref": "#/components/schemas/StartAgentExecutionCommand" } }, "application/*+json": { "schema": { "$ref": "#/components/schemas/StartAgentExecutionCommand" } } } }, "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "string", "format": "uuid" } } } } } } }, "/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": { "AgentExecutionDetails": { "type": "object", "properties": { "id": { "type": "string", "description": "Unique execution identifier", "format": "uuid" }, "agentId": { "type": "string", "description": "Agent identifier", "format": "uuid" }, "agentName": { "type": "string", "description": "Agent name", "nullable": true }, "conversationId": { "type": "string", "description": "Conversation identifier if part of a conversation", "format": "uuid", "nullable": true }, "userPrompt": { "type": "string", "description": "Full user prompt", "nullable": true }, "input": { "type": "string", "description": "Additional input context or parameters", "nullable": true }, "output": { "type": "string", "description": "Agent's complete output/response", "nullable": true }, "status": { "$ref": "#/components/schemas/ExecutionStatus" }, "startedAt": { "type": "string", "description": "Execution start timestamp", "format": "date-time" }, "completedAt": { "type": "string", "description": "Execution completion timestamp", "format": "date-time", "nullable": true }, "executionTimeMs": { "type": "integer", "description": "Execution time in milliseconds", "format": "int64", "nullable": true }, "inputTokens": { "type": "integer", "description": "Input tokens consumed", "format": "int32", "nullable": true }, "outputTokens": { "type": "integer", "description": "Output tokens generated", "format": "int32", "nullable": true }, "totalTokens": { "type": "integer", "description": "Total tokens used", "format": "int32", "nullable": true }, "estimatedCost": { "type": "number", "description": "Estimated cost in USD", "format": "double", "nullable": true }, "toolCalls": { "type": "string", "description": "Tool calls made during execution (JSON array)", "nullable": true }, "toolCallResults": { "type": "string", "description": "Tool execution results (JSON array)", "nullable": true }, "errorMessage": { "type": "string", "description": "Error message if execution failed", "nullable": true } }, "additionalProperties": false, "description": "Detailed agent execution information" }, "AgentResponseDto": { "type": "object", "properties": { "content": { "type": "string", "description": "Response content from the agent", "nullable": true }, "timestamp": { "type": "string", "description": "When the response was generated", "format": "date-time" }, "inputTokens": { "type": "integer", "description": "Number of input tokens processed", "format": "int32", "nullable": true }, "outputTokens": { "type": "integer", "description": "Number of output tokens generated", "format": "int32", "nullable": true }, "estimatedCost": { "type": "number", "description": "Estimated cost of the request in USD", "format": "double", "nullable": true } }, "additionalProperties": false, "description": "Agent response with token usage and cost information" }, "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." }, "CompleteAgentExecutionCommand": { "type": "object", "properties": { "executionId": { "type": "string", "description": "Execution ID to complete", "format": "uuid" }, "output": { "type": "string", "description": "Agent's output/response", "nullable": true }, "status": { "$ref": "#/components/schemas/ExecutionStatus" }, "inputTokens": { "type": "integer", "description": "Input tokens consumed", "format": "int32", "nullable": true }, "outputTokens": { "type": "integer", "description": "Output tokens generated", "format": "int32", "nullable": true }, "estimatedCost": { "type": "number", "description": "Estimated cost in USD", "format": "double", "nullable": true }, "toolCalls": { "type": "string", "description": "Tool calls made (JSON array)", "nullable": true }, "toolCallResults": { "type": "string", "description": "Tool call results (JSON array)", "nullable": true }, "errorMessage": { "type": "string", "description": "Error message if failed", "nullable": true } }, "additionalProperties": false, "description": "Completes an agent execution with results and metrics" }, "ConversationDetails": { "type": "object", "properties": { "id": { "type": "string", "description": "Unique conversation identifier", "format": "uuid" }, "title": { "type": "string", "description": "Conversation title", "nullable": true }, "summary": { "type": "string", "description": "Conversation summary", "nullable": true }, "isActive": { "type": "boolean", "description": "Whether conversation is active" }, "startedAt": { "type": "string", "description": "Conversation start timestamp", "format": "date-time" }, "lastMessageAt": { "type": "string", "description": "Last message timestamp", "format": "date-time" }, "messageCount": { "type": "integer", "description": "Total message count", "format": "int32" }, "messages": { "type": "array", "items": { "$ref": "#/components/schemas/ConversationMessageItem" }, "description": "All messages in conversation", "nullable": true } }, "additionalProperties": false, "description": "Detailed conversation information with messages" }, "ConversationMessageItem": { "type": "object", "properties": { "id": { "type": "string", "description": "Message identifier", "format": "uuid" }, "conversationId": { "type": "string", "description": "Conversation identifier", "format": "uuid" }, "executionId": { "type": "string", "description": "Execution identifier if from agent execution", "format": "uuid", "nullable": true }, "role": { "$ref": "#/components/schemas/MessageRole" }, "content": { "type": "string", "description": "Message content", "nullable": true }, "messageIndex": { "type": "integer", "description": "Message index/order in conversation", "format": "int32" }, "isInActiveWindow": { "type": "boolean", "description": "Whether message is in active context window" }, "createdAt": { "type": "string", "description": "Message creation timestamp", "format": "date-time" } }, "additionalProperties": false, "description": "Individual message within a conversation" }, "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" }, "CreateConversationCommand": { "type": "object", "properties": { "title": { "type": "string", "description": "Conversation title", "nullable": true }, "summary": { "type": "string", "description": "Optional summary or description", "nullable": true } }, "additionalProperties": false, "description": "Creates a new conversation for grouping related messages" }, "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" }, "ExecutionStatus": { "enum": [ "Running", "Completed", "Failed", "Cancelled" ], "type": "string", "description": "Represents the status of an agent execution." }, "GetAgentExecutionQuery": { "type": "object", "properties": { "id": { "type": "string", "description": "Execution ID", "format": "uuid" } }, "additionalProperties": false, "description": "Get detailed agent execution by ID" }, "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" }, "GetConversationQuery": { "type": "object", "properties": { "id": { "type": "string", "description": "Conversation ID", "format": "uuid" } }, "additionalProperties": false, "description": "Get conversation with all messages by ID" }, "HealthQuery": { "type": "object", "additionalProperties": false, "description": "Health check query to verify API availability" }, "MessageDto": { "type": "object", "properties": { "content": { "type": "string", "description": "Message content", "nullable": true }, "timestamp": { "type": "string", "description": "When the message was created", "format": "date-time" } }, "additionalProperties": false, "description": "Simplified message data transfer object" }, "MessageRole": { "enum": [ "User", "Assistant", "System", "Tool" ], "type": "string", "description": "Represents the role of a message in a conversation." }, "ModelProviderType": { "enum": [ "CloudApi", "LocalEndpoint", "Custom" ], "type": "string", "description": "Specifies the type of model provider (cloud API or local endpoint)." }, "SendMessageCommand": { "type": "object", "properties": { "agentId": { "type": "string", "description": "ID of the agent to send the message to", "format": "uuid" }, "conversationId": { "type": "string", "description": "ID of existing conversation, or null to create a new conversation", "format": "uuid", "nullable": true }, "message": { "type": "string", "description": "User's message content", "nullable": true }, "userId": { "type": "string", "description": "Optional user identifier for future authentication support", "nullable": true } }, "additionalProperties": false, "description": "Sends a user message to an agent and receives a response.\r\nCreates a new conversation if ConversationId is not provided." }, "SendMessageResult": { "type": "object", "properties": { "conversationId": { "type": "string", "description": "ID of the conversation (new or existing)", "format": "uuid" }, "messageId": { "type": "string", "description": "ID of the stored user message", "format": "uuid" }, "agentResponseId": { "type": "string", "description": "ID of the stored agent response message", "format": "uuid" }, "userMessage": { "$ref": "#/components/schemas/MessageDto" }, "agentResponse": { "$ref": "#/components/schemas/AgentResponseDto" } }, "additionalProperties": false, "description": "Result containing the user message, agent response, and conversation metadata" }, "StartAgentExecutionCommand": { "type": "object", "properties": { "agentId": { "type": "string", "description": "Agent ID to execute", "format": "uuid" }, "userPrompt": { "type": "string", "description": "User's input prompt", "nullable": true }, "conversationId": { "type": "string", "description": "Optional conversation ID to link execution to", "format": "uuid", "nullable": true }, "input": { "type": "string", "description": "Optional additional input context (JSON)", "nullable": true } }, "additionalProperties": false, "description": "Starts a new agent execution" }, "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": [ ] } ] }