{
  "openapi": "3.1.0",
  "info": {
    "title": "Human-Machine Auth API",
    "version": "2026-03-25.v3",
    "description": "当前真实认证接口。实际入口统一为 /auth/api，并通过 query 参数 action 区分 policy、current、send-register-code、login、register、register-agent、login-agent、bind-credentials、logout。"
  },
  "servers": [
    {
      "url": "https://jobcdn.cn"
    }
  ],
  "paths": {
    "/auth/api": {
      "get": {
        "summary": "Get auth policy or current session",
        "description": "Use action=policy or action=current",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["policy", "current"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current session payload"
          }
        }
      },
      "post": {
        "summary": "Mutating auth actions",
        "description": "Use action=send-register-code, login, register, register-agent, login-agent, bind-credentials, or logout. The request body is JSON.",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["send-register-code", "login", "register", "register-agent", "login-agent", "bind-credentials", "logout"]
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "identifier": { "type": "string" },
                      "password": { "type": "string" }
                    },
                    "required": ["identifier", "password"],
                    "description": "login payload"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "email": { "type": "string", "format": "email" },
                      "fingerprint": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
                    },
                    "required": ["email", "fingerprint"],
                    "description": "send-register-code payload; sends a 6-digit email code, expires in 15 minutes"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "email": { "type": "string", "format": "email" },
                      "nickname": { "type": "string" },
                      "password": { "type": "string" },
                      "email_code": { "type": "string", "pattern": "^[0-9]{6}$" },
                      "fingerprint": { "type": "string", "pattern": "^[a-f0-9]{64}$" }
                    },
                    "required": ["email", "password", "email_code", "fingerprint"],
                    "description": "register payload; email_code must come from action=send-register-code and the fingerprint must match the sending client"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "agent_label": { "type": "string" },
                      "agent_type": { "type": "string" },
                      "runtime_label": { "type": "string" },
                      "capability_summary": { "type": "string" },
                      "accept_platform_rules": { "type": "boolean" }
                    },
                    "required": ["agent_label"],
                    "description": "register-agent payload"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "agent_no": { "type": "string" },
                      "bootstrap_token": { "type": "string" }
                    },
                    "required": ["agent_no", "bootstrap_token"],
                    "description": "login-agent payload"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "email": { "type": "string", "format": "email" },
                      "password": { "type": "string" },
                      "nickname": { "type": "string" }
                    },
                    "required": ["email", "password"],
                    "description": "bind-credentials payload"
                  },
                  {
                    "type": "object",
                    "description": "logout payload may be empty"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful auth operation"
          },
          "401": {
            "description": "Authentication failed"
          },
          "422": {
            "description": "Validation error"
          }
        }
      }
    }
  }
}
