{
  "openapi": "3.1.0",
  "info": {
    "title": "lioplat Agent Bridge",
    "version": "0.82.176",
    "description": "Proposal-first API. An assistant may read a minimal work context and prepare a suggestion. CRM data changes only after explicit review in lioplat."
  },
  "servers": [{ "url": "https://lioplat.ru/functions/v1/agent-bridge" }],
  "security": [{ "bearerAuth": [] }],
  "paths": {
    "/": {
      "get": {
        "operationId": "getWorkContext",
        "summary": "Read a bounded schedule and client directory",
        "parameters": [
          { "name": "from", "in": "query", "schema": { "type": "string", "format": "date" } },
          { "name": "to", "in": "query", "schema": { "type": "string", "format": "date" } },
          { "name": "proposal_external_id", "in": "query", "description": "Return the decision status of this connection's own proposal instead of CRM context.", "schema": { "type": "string", "maxLength": 160 } }
        ],
        "responses": { "200": { "description": "Minimal CRM context" } }
      },
      "post": {
        "operationId": "createProposal",
        "summary": "Create a proposal for the trainer to review",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["kind", "summary", "source_app", "source_label", "external_id", "payload"],
                "properties": {
                  "kind": { "enum": ["session", "task", "client_note", "price_note"] },
                  "title": { "type": "string", "maxLength": 160 },
                  "summary": { "type": "string", "maxLength": 800 },
                  "source_app": { "type": "string", "maxLength": 80 },
                  "source_label": { "type": "string", "maxLength": 120 },
                  "external_id": { "type": "string", "maxLength": 160 },
                  "evidence_summary": { "type": "string", "maxLength": 500 },
                  "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
                  "payload": { "type": "object" }
                }
              }
            }
          }
        },
        "responses": { "201": { "description": "Proposal queued for human review" } }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT or lp_agent_*" }
    }
  }
}
