{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Cortex Agent Session",
  "type": "object",
  "required": ["session_id", "agent_id", "role", "status", "started_at"],
  "properties": {
    "session_id": { "type": "string" },
    "agent_id": { "type": "string" },
    "role": { "type": "string" },
    "status": { "type": "string", "enum": ["running", "paused", "closed", "stale"] },
    "phase": { "type": ["string", "null"] },
    "activity": { "type": ["string", "null"] },
    "current_run_id": { "type": ["string", "null"] },
    "current_task_id": { "type": ["string", "null"] },
    "worktree_path": { "type": ["string", "null"] },
    "started_at": { "type": "string" },
    "last_heartbeat_at": { "type": ["string", "null"] },
    "updated_at": { "type": "string", "format": "date-time" },
    "updated_by_gate": { "type": "string", "enum": ["owner", "handoff", "user", "mission"] },
    "closed_at": { "type": "string", "format": "date-time" },
    "server": {
      "type": "object",
      "properties": {
        "url": { "type": "string" },
        "port": { "type": "number" }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
