{
  "openapi": "3.0.3",
  "info": {
    "title": "Handtecs Agent Reception API",
    "description": "成都黑岩科技外部 Agent 接待接口。公开只读知识；询价写入线索。无需 API Key。 说明页 https://handtecs.com/ai-ready/ ；静态知识 /ai-ready/knowledge.json",
    "version": "1.0.0",
    "contact": {
      "name": "Handtecs",
      "email": "edwardstianyi@handtecs.com",
      "url": "https://handtecs.com/ai-ready/"
    }
  },
  "servers": [
    {
      "url": "https://handtecs.com",
      "description": "Production"
    },
    {
      "url": "http://127.0.0.1:8787",
      "description": "Local API only"
    }
  ],
  "paths": {
    "/agent-api/v1/company": {
      "get": {
        "summary": "公司结构化信息",
        "operationId": "getCompany",
        "tags": [
          "read"
        ],
        "responses": {
          "200": {
            "description": "Company object",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/agent-api/v1/knowledge": {
      "get": {
        "summary": "检索知识库（关键词）",
        "operationId": "searchKnowledge",
        "tags": [
          "read"
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "关键词；空则返回摘要索引"
          }
        ],
        "responses": {
          "200": {
            "description": "Search hits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/agent-api/v1/inquire": {
      "post": {
        "summary": "提交询价 / 留线索",
        "operationId": "postInquire",
        "tags": [
          "write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InquireRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InquireResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation error"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "InquireRequest": {
        "type": "object",
        "required": [
          "company",
          "contact_name",
          "message"
        ],
        "properties": {
          "company": {
            "type": "string",
            "maxLength": 200,
            "description": "来访公司/组织"
          },
          "contact_name": {
            "type": "string",
            "maxLength": 100
          },
          "email": {
            "type": "string",
            "format": "email",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "maxLength": 40,
            "nullable": true
          },
          "intent": {
            "type": "string",
            "enum": [
              "inquire",
              "knowledge",
              "other"
            ],
            "default": "inquire"
          },
          "message": {
            "type": "string",
            "maxLength": 4000
          },
          "agent_id": {
            "type": "string",
            "maxLength": 200,
            "nullable": true,
            "description": "可选：外部 Agent 标识"
          },
          "source_url": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          }
        },
        "description": "email 与 phone 至少填一个"
      },
      "InquireResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "ticket_id": {
            "type": "string"
          },
          "next_step": {
            "type": "string"
          }
        }
      }
    }
  }
}
