{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/office-server-room.schema.json",
  "title": "Server room control panel",
  "description": "What GET /v1/server-room returns and `office-server-room.mjs --json` prints: every Claude Code session from the activity document with its current work, last step, tokens, estimated cost and duration; today's tokens per model; the skills called in the last 30 days from the local skill-usage log; and health lights read from health-report.mjs's JSON (never probed). The rack status is the health report's worst section. Local only.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "contractVersion",
    "generatedAt",
    "rack",
    "lights",
    "sessions",
    "today",
    "skills",
    "health"
  ],
  "$defs": {
    "status": { "enum": ["green", "yellow", "red"] },
    "count": { "type": "integer", "minimum": 0 }
  },
  "properties": {
    "contractVersion": {
      "type": "string",
      "pattern": "^1\\.[0-9]+\\.[0-9]+$",
      "x-sensitivity": "none"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time",
      "x-sensitivity": "none"
    },
    "rack": {
      "type": "object",
      "additionalProperties": false,
      "required": ["status", "red", "yellow"],
      "x-sensitivity": "none",
      "properties": {
        "status": { "$ref": "#/$defs/status" },
        "red": { "$ref": "#/$defs/count" },
        "yellow": { "$ref": "#/$defs/count" }
      }
    },
    "lights": {
      "type": "array",
      "minItems": 6,
      "maxItems": 6,
      "x-sensitivity": "none",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "status", "reason", "text"],
        "properties": {
          "id": { "enum": ["doctor", "hooks", "toolkit", "gate", "errors", "autopilot"] },
          "status": { "$ref": "#/$defs/status" },
          "reason": {
            "type": "string",
            "maxLength": 160,
            "description": "health-report's own fixed-shape reason, or a fixed phrase; never a message from a failed source. Always English."
          },
          "message": {
            "type": "object",
            "additionalProperties": false,
            "required": ["id"],
            "description": "The reason as a health-messages catalogue message: a stable id plus its parameters, the same shape health-report.mjs --json carries beside each section reason. Absent when the source section carried none the catalogue knows.",
            "properties": {
              "id": { "type": "string", "pattern": "^[a-z]+\\.[A-Za-z]+$" },
              "params": { "type": "object" }
            }
          },
          "text": {
            "type": "string",
            "maxLength": 160,
            "description": "The message rendered in the panel page's language (prefs outputLanguage, the one the page is stamped with), else the English reason."
          },
          "checks": {
            "type": "array",
            "items": { "enum": ["hook-coverage", "hook-reachability"] }
          },
          "tags": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["tag", "count"],
              "properties": {
                "tag": { "type": "string", "maxLength": 80 },
                "count": { "$ref": "#/$defs/count" }
              }
            }
          }
        }
      }
    },
    "sessions": {
      "type": "array",
      "maxItems": 100,
      "x-sensitivity": "local",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "sessionId",
          "kind",
          "repo",
          "title",
          "work",
          "lastStep",
          "phase",
          "tokens",
          "estUsd",
          "costSource",
          "elapsedSeconds",
          "live",
          "waitingForYou"
        ],
        "properties": {
          "id": { "type": "string" },
          "sessionId": { "type": ["string", "null"] },
          "kind": { "type": "string" },
          "repo": { "type": "string" },
          "title": { "type": ["string", "null"], "maxLength": 160 },
          "work": {
            "type": ["string", "null"],
            "maxLength": 160,
            "description": "The task in progress, else the title, else the command."
          },
          "lastStep": {
            "type": ["string", "null"],
            "maxLength": 160,
            "description": "What the seat holding the work is doing, else the run's now line."
          },
          "phase": { "type": ["string", "null"] },
          "tokens": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": ["in", "out", "cached"],
                "properties": {
                  "in": { "$ref": "#/$defs/count" },
                  "out": { "$ref": "#/$defs/count" },
                  "cached": { "$ref": "#/$defs/count" }
                }
              },
              { "type": "null" }
            ]
          },
          "estUsd": { "type": ["number", "null"], "minimum": 0 },
          "costSource": { "type": "string" },
          "elapsedSeconds": { "type": ["integer", "null"], "minimum": 0 },
          "live": { "type": ["boolean", "null"] },
          "waitingForYou": { "type": "boolean" }
        }
      }
    },
    "today": {
      "x-sensitivity": "none",
      "oneOf": [
        { "type": "null" },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "since",
            "models",
            "totals",
            "unpricedModels",
            "truncatedFiles",
            "estimated"
          ],
          "properties": {
            "since": { "type": ["string", "null"] },
            "models": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "model",
                  "input",
                  "output",
                  "cacheRead",
                  "cacheCreation",
                  "messages",
                  "usd"
                ],
                "properties": {
                  "model": { "type": "string", "maxLength": 81 },
                  "input": { "$ref": "#/$defs/count" },
                  "output": { "$ref": "#/$defs/count" },
                  "cacheRead": { "$ref": "#/$defs/count" },
                  "cacheCreation": { "$ref": "#/$defs/count" },
                  "messages": { "$ref": "#/$defs/count" },
                  "usd": { "type": ["number", "null"], "minimum": 0 }
                }
              }
            },
            "totals": {
              "type": "object",
              "additionalProperties": false,
              "required": ["input", "output", "cacheRead", "cacheCreation", "usd"],
              "properties": {
                "input": { "$ref": "#/$defs/count" },
                "output": { "$ref": "#/$defs/count" },
                "cacheRead": { "$ref": "#/$defs/count" },
                "cacheCreation": { "$ref": "#/$defs/count" },
                "usd": { "type": "number", "minimum": 0 }
              }
            },
            "unpricedModels": { "type": "array", "items": { "type": "string" } },
            "truncatedFiles": { "$ref": "#/$defs/count" },
            "estimated": { "const": true }
          }
        }
      ]
    },
    "skills": {
      "x-sensitivity": "local",
      "description": "The last 30 days of the local skill-usage log (skill-usage.mjs summary): calls and failed calls in total, the ten most used skills, and how many installed skills were not called at all. Null when the log cannot be read. Skill names only; the log holds no arguments, prompts or output.",
      "oneOf": [
        { "type": "null" },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["enabled", "windowDays", "total", "errors", "top", "unused"],
          "properties": {
            "enabled": {
              "type": "boolean",
              "description": "False when prefs turn the log off (skillUsage.enabled false or usageLog.optOut true); rows written earlier are still counted."
            },
            "windowDays": { "$ref": "#/$defs/count" },
            "total": { "$ref": "#/$defs/count" },
            "errors": { "$ref": "#/$defs/count" },
            "top": {
              "type": "array",
              "maxItems": 10,
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": ["name", "count", "errors", "lastUsed"],
                "properties": {
                  "name": { "type": "string", "maxLength": 96 },
                  "count": { "$ref": "#/$defs/count" },
                  "errors": { "$ref": "#/$defs/count" },
                  "lastUsed": { "type": ["string", "null"] }
                }
              }
            },
            "unused": { "$ref": "#/$defs/count" },
            "coversWindow": {
              "type": "boolean",
              "description": "Whether the log's first row is older than the window. While false, unused is not yet a prune list."
            },
            "coverageStart": {
              "type": ["string", "null"],
              "format": "date-time",
              "description": "Time of the log's first row, or null when the log is empty."
            }
          }
        }
      ]
    },
    "health": {
      "x-sensitivity": "none",
      "oneOf": [
        { "type": "null" },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["generatedAt", "probed", "status"],
          "properties": {
            "generatedAt": { "type": ["string", "null"] },
            "probed": { "const": false },
            "status": { "$ref": "#/$defs/status" }
          }
        }
      ]
    }
  }
}
