{
  "openapi": "3.1.0",
  "info": {
    "title": "Agent rekrutacyjny Marcina Chylińskiego",
    "version": "1.0.0",
    "description": "Agent odpowiada na pytania o CV, doświadczenie, projekty, kompetencje i ograniczenia Marcina Chylińskiego. Odpowiada wyłącznie na podstawie jego materiałów i mówi wprost, gdy czegoś nie wie. Ten sam agent jest dostępny jako serwer MCP (POST /mcp) i agent A2A (POST /a2a, karta: /.well-known/agent-card.json)."
  },
  "servers": [
    {
      "url": "https://agent.aioptymalizacje.pl"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/api/v1/chat": {
      "post": {
        "summary": "Zadaj pytanie agentowi",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "message"
                ],
                "properties": {
                  "message": {
                    "type": "string",
                    "maxLength": 2000,
                    "example": "Jakie ma doświadczenie z integracjami API?"
                  },
                  "conversation_id": {
                    "type": "string",
                    "description": "Z poprzedniej odpowiedzi, żeby kontynuować rozmowę (ważne 24 h)."
                  },
                  "stream": {
                    "type": "boolean",
                    "description": "true: odpowiedź jako Server-Sent Events (zdarzenia delta, done, error). Zdarzenie done ma ten sam kształt co odpowiedź JSON."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Odpowiedź agenta",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "answer": {
                      "type": "string"
                    },
                    "conversation_id": {
                      "type": "string"
                    },
                    "refused": {
                      "type": "boolean",
                      "description": "true, gdy agent odmówił (np. próba prompt injection)."
                    },
                    "sources": {
                      "type": "array",
                      "description": "Fragmenty materiałów kandydata zacytowane przez model (Claude citations).",
                      "items": {
                        "type": "object",
                        "properties": {
                          "section": {
                            "type": "string"
                          },
                          "text": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "usage": {
                      "type": "object",
                      "properties": {
                        "input_tokens": {
                          "type": "integer"
                        },
                        "output_tokens": {
                          "type": "integer"
                        },
                        "requests_today": {
                          "type": "integer"
                        },
                        "daily_request_limit": {
                          "type": "integer"
                        },
                        "cost_usd": {
                          "type": "number"
                        },
                        "budget_left_usd": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Niepoprawne dane wejściowe",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Brak albo nieprawidłowy token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Przekroczony limit zapytań albo budżet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Model chwilowo niedostępny albo wyczerpany dzienny limit kosztów usługi",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/fit": {
      "post": {
        "summary": "Dopasowanie do opisu stanowiska, z dowodami zweryfikowanymi przez serwer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "job_description"
                ],
                "properties": {
                  "job_description": {
                    "type": "string",
                    "minLength": 30,
                    "maxLength": 6000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Wymagania ze statusem i dowodami",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "summary": {
                      "type": "string"
                    },
                    "requirements": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "requirement": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "potwierdzone",
                              "częściowo",
                              "brak w materiałach"
                            ]
                          },
                          "evidence": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "Dosłowne fragmenty materiałów (sprawdzone przez serwer)."
                          },
                          "comment": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "unverified_evidence_removed": {
                      "type": "integer",
                      "description": "Ile dowodów modelu odrzucił serwer, bo nie były dosłownym fragmentem materiałów."
                    },
                    "usage": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Niepoprawny opis albo próba zmiany instrukcji",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Brak tokenu",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Model niedostępny",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/profile": {
      "get": {
        "summary": "Profil kandydata jako dane strukturalne (bez modelu językowego)",
        "responses": {
          "200": {
            "description": "Profil"
          },
          "401": {
            "description": "Brak tokenu",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/usage": {
      "get": {
        "summary": "Zużycie i limity Twojego tokenu",
        "responses": {
          "200": {
            "description": "Limity"
          },
          "401": {
            "description": "Brak tokenu",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}