{
  "openapi": "3.1.0",
  "info": {
    "title": "Mosad360 — Public Demo & Audit API",
    "version": "1.0.0",
    "description": "מפרט OpenAPI לנקודות הקצה הציבוריות של מוסד360 הזמינות לכלי בינה מלאכותית, בוטים וביקורת חיצונית. כל הקריאות אינן דורשות אימות אלא אם צוין אחרת. אין כאן נתוני לקוחות אמיתיים — רק טננט דמו עם נתונים סינתטיים.",
    "contact": { "name": "Mosad360", "url": "https://mosad360.com" },
    "license": { "name": "Proprietary — read-only audit access", "url": "https://mosad360.com/trust" }
  },
  "servers": [
    { "url": "https://mosad360.com", "description": "Production" },
    { "url": "https://www.mosad360.com", "description": "Production (www)" },
    { "url": "https://360aimanagement.com", "description": "Open audit domain" }
  ],
  "tags": [
    { "name": "Discovery", "description": "מפות אתר ומלאי עובדתי לבוטים" },
    { "name": "Demo", "description": "מסכי דמו ציבוריים (HTML)" },
    { "name": "Audit", "description": "עמודי ביקורת, צילומי מסך ו-Lighthouse" },
    { "name": "Hooks", "description": "Webhooks פנימיים (דרושים מפתחות)" }
  ],
  "paths": {
    "/openapi.json": {
      "get": {
        "tags": ["Discovery"],
        "summary": "מפרט ה-OpenAPI הזה",
        "operationId": "getOpenApiSpec",
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 document",
            "content": { "application/json": { "schema": { "type": "object" } } }
          }
        }
      }
    },
    "/llms.txt": {
      "get": {
        "tags": ["Discovery"],
        "summary": "מלאי עובדתי של כל המסלולים, ה-Backend ומצב המימוש (תקן llmstxt.org)",
        "operationId": "getLlmsTxt",
        "responses": {
          "200": { "description": "Plain-text inventory", "content": { "text/plain": { "schema": { "type": "string" } } } }
        }
      }
    },
    "/robots.txt": {
      "get": {
        "tags": ["Discovery"],
        "summary": "מדיניות סריקה עבור בוטים (GPTBot, ClaudeBot, PerplexityBot וכו')",
        "operationId": "getRobotsTxt",
        "responses": { "200": { "description": "robots.txt", "content": { "text/plain": { "schema": { "type": "string" } } } } }
      }
    },
    "/sitemap.xml": {
      "get": {
        "tags": ["Discovery"],
        "summary": "מפת אתר XML",
        "operationId": "getSitemap",
        "responses": { "200": { "description": "Sitemap", "content": { "application/xml": { "schema": { "type": "string" } } } } }
      }
    },
    "/api/public/audit-access": {
      "get": {
        "tags": ["Audit"],
        "summary": "דוח גישה חיצוני לכל נתיבי הביקורת הציבוריים",
        "operationId": "getAuditAccessReport",
        "parameters": [
          {
            "name": "matrix",
            "in": "query",
            "required": false,
            "schema": { "type": "string", "enum": ["1"] },
            "description": "כאשר הערך 1, מריץ בדיקה מול כמה וריאציות Accept."
          }
        ],
        "responses": {
          "200": { "description": "כל הנתיבים נגישים", "content": { "application/json": { "schema": { "type": "object" } } } },
          "502": { "description": "לפחות נתיב אחד נכשל", "content": { "application/json": { "schema": { "type": "object" } } } }
        }
      }
    },
    "/audit-access.json": {
      "get": {
        "tags": ["Audit"],
        "summary": "Mirror שורש לדוח הגישה הציבורי",
        "operationId": "getAuditAccessReportRootMirror",
        "responses": {
          "200": { "description": "כל הנתיבים נגישים", "content": { "application/json": { "schema": { "type": "object" } } } },
          "502": { "description": "לפחות נתיב אחד נכשל", "content": { "application/json": { "schema": { "type": "object" } } } }
        }
      }
    },
    "/demo-map.json": {
      "get": {
        "tags": ["Discovery", "Demo"],
        "summary": "מפת כל מסכי הדמו עם כותרות, קבוצות וסיכומים",
        "operationId": "getDemoMap",
        "responses": {
          "200": {
            "description": "Demo map",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DemoMap" } } }
          }
        }
      }
    },
    "/demo-export.html": {
      "get": {
        "tags": ["Demo"],
        "summary": "ייצוא HTML סטטי של כל מסכי הדמו לקריאה ע\"י בוטים",
        "operationId": "getDemoExportHtml",
        "responses": { "200": { "description": "HTML export", "content": { "text/html": { "schema": { "type": "string" } } } } }
      }
    },
    "/demo": {
      "get": {
        "tags": ["Demo"],
        "summary": "פורטל הדמו הציבורי",
        "operationId": "getDemoPortal",
        "responses": { "200": { "description": "HTML page", "content": { "text/html": { "schema": { "type": "string" } } } } }
      }
    },
    "/demo/{slug}": {
      "get": {
        "tags": ["Demo"],
        "summary": "מסך דמו ספציפי (כל מסלול במערכת זמין תחת /demo/<slug>)",
        "operationId": "getDemoSlug",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "שם המסך, לדוגמה: mission-control, safety, budget, tabarim, letters, mosad, licensing. הרשימה המלאה ב-/demo-map.json.",
            "schema": { "type": "string" },
            "examples": {
              "mission-control": { "value": "mission-control" },
              "safety": { "value": "safety" },
              "tabarim": { "value": "tabarim" },
              "letters": { "value": "letters" }
            }
          }
        ],
        "responses": {
          "200": { "description": "HTML page", "content": { "text/html": { "schema": { "type": "string" } } } },
          "404": { "description": "Slug לא קיים" }
        }
      }
    },
    "/sample-report": {
      "get": {
        "tags": ["Demo"],
        "summary": "דוח מצב מוסד לדוגמה",
        "operationId": "getSampleReport",
        "responses": { "200": { "description": "HTML page", "content": { "text/html": { "schema": { "type": "string" } } } } }
      }
    },
    "/tour": {
      "get": {
        "tags": ["Demo"],
        "summary": "סיור מודרך 4 שלבים עם תרחיש 'Aha Moment'",
        "operationId": "getTour",
        "responses": { "200": { "description": "HTML page", "content": { "text/html": { "schema": { "type": "string" } } } } }
      }
    },
    "/llms": {
      "get": {
        "tags": ["Audit", "Discovery"],
        "summary": "מפת מסלולים בגרסת HTML עם צילומי מסך",
        "operationId": "getLlmsHtml",
        "responses": { "200": { "description": "HTML page", "content": { "text/html": { "schema": { "type": "string" } } } } }
      }
    },
    "/audit": {
      "get": {
        "tags": ["Audit"],
        "summary": "עמוד הביקורת הראשי",
        "operationId": "getAudit",
        "responses": { "200": { "description": "HTML page", "content": { "text/html": { "schema": { "type": "string" } } } } }
      }
    },
    "/audit/screenshots": {
      "get": {
        "tags": ["Audit"],
        "summary": "גלריית צילומי מסך אוטומטיים של כל המסכים",
        "operationId": "getAuditScreenshots",
        "responses": { "200": { "description": "HTML gallery", "content": { "text/html": { "schema": { "type": "string" } } } } }
      }
    },
    "/audit/lighthouse": {
      "get": {
        "tags": ["Audit"],
        "summary": "מגמת ציוני Lighthouse (ביצועים, נגישות, SEO, Best Practices) לאורך זמן",
        "operationId": "getAuditLighthouse",
        "responses": { "200": { "description": "HTML page with trend charts", "content": { "text/html": { "schema": { "type": "string" } } } } }
      }
    },
    "/lighthouse-reports/trends.json": {
      "get": {
        "tags": ["Audit"],
        "summary": "נתוני JSON גולמיים של מגמות Lighthouse",
        "operationId": "getLighthouseTrends",
        "responses": {
          "200": {
            "description": "Lighthouse trends data",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LighthouseTrends" } } }
          }
        }
      }
    },
    "/api/public/hooks/run-agent-schedules": {
      "post": {
        "tags": ["Hooks"],
        "summary": "מריץ סוכנים אוטונומיים שהגיע זמנם (pg_cron בלבד)",
        "description": "נקודת קצה פריבילגית — דורשת SUPABASE_SERVICE_ROLE_KEY או CRON_SECRET בכותרת `apikey` או `x-api-key`. לא מיועדת לקריאה ע\"י כלי בינה חיצוניים.",
        "operationId": "runAgentSchedules",
        "security": [{ "ApiKeyHeader": [] }, { "XApiKeyHeader": [] }],
        "responses": {
          "200": {
            "description": "תוצאות הרצה",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/RunAgentSchedulesResponse" }
              }
            }
          },
          "401": { "description": "Unauthorized" },
          "500": { "description": "שגיאת שרת" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": { "type": "apiKey", "in": "header", "name": "apikey" },
      "XApiKeyHeader": { "type": "apiKey", "in": "header", "name": "x-api-key" }
    },
    "schemas": {
      "DemoMap": {
        "type": "object",
        "required": ["generated", "site", "pages"],
        "properties": {
          "generated": { "type": "string", "format": "date" },
          "site": { "type": "string" },
          "purpose": { "type": "string" },
          "pages": { "type": "array", "items": { "$ref": "#/components/schemas/DemoMapPage" } }
        }
      },
      "DemoMapPage": {
        "type": "object",
        "required": ["path", "title", "demoPath"],
        "properties": {
          "path": { "type": "string", "description": "המסלול המקורי במערכת" },
          "title": { "type": "string" },
          "group": { "type": "string" },
          "section": { "type": "string" },
          "demoPath": { "type": "string", "description": "URL ציבורי בדמו" },
          "summary": { "type": "string" }
        }
      },
      "LighthouseTrends": {
        "type": "object",
        "description": "מערך הרצות Lighthouse לפי תאריך, רזולוציה וקטגוריה",
        "additionalProperties": true
      },
      "RunAgentSchedulesResponse": {
        "type": "object",
        "properties": {
          "processed": { "type": "integer" },
          "timestamp": { "type": "string", "format": "date-time" },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": { "type": "string", "format": "uuid" },
                "ok": { "type": "boolean" },
                "summary": { "type": "string" },
                "error": { "type": "string" }
              }
            }
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "מלאי עובדתי מלא של האתר",
    "url": "https://mosad360.com/llms.txt"
  }
}
