{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://github.com/andrewhuot/headless-chat-sdk/schemas/agent-graph.schema.json",
  "title": "AgentGraph",
  "description": "Typed agent graph: routers, specialists, and route decisions. Mirrors packages/gecx-chat/src/agents/types.ts.",
  "definitions": {
    "AgentGraphNodeKind": {
      "type": "string",
      "enum": ["router", "specialist"]
    },
    "AgentGraphNodeSnapshot": {
      "type": "object",
      "required": ["id", "kind", "handoffTo"],
      "properties": {
        "id": { "type": "string" },
        "kind": { "$ref": "#/definitions/AgentGraphNodeKind" },
        "description": { "type": "string" },
        "handoffTo": { "type": "array", "items": { "type": "string" } },
        "intentName": { "type": "string" }
      }
    },
    "AgentGraphSnapshot": {
      "type": "object",
      "required": ["entry", "nodes"],
      "properties": {
        "entry": { "type": "string" },
        "nodes": {
          "type": "array",
          "items": { "$ref": "#/definitions/AgentGraphNodeSnapshot" }
        }
      }
    },
    "RouteDecision": {
      "type": "object",
      "required": ["from", "to", "latencyMs"],
      "properties": {
        "from": { "type": "string" },
        "to": { "type": "string", "description": "Node id, or the literal 'human' for an escalation." },
        "latencyMs": { "type": "number", "minimum": 0 },
        "reason": { "type": "string" },
        "ruleIndex": { "type": ["integer", "null"] },
        "intentLabel": { "type": "string" },
        "intentConfidence": { "type": "number", "minimum": 0, "maximum": 1 }
      }
    },
    "IntentClassification": {
      "type": "object",
      "required": ["label", "confidence"],
      "properties": {
        "label": { "type": "string" },
        "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
        "alternatives": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["label", "confidence"],
            "properties": {
              "label": { "type": "string" },
              "confidence": { "type": "number", "minimum": 0, "maximum": 1 }
            }
          }
        },
        "metadata": { "type": "object" }
      }
    },
    "AgentCard": {
      "type": "object",
      "required": ["name", "protocolVersion", "url"],
      "description": "Minimal Google A2A AgentCard (https://google.github.io/A2A). Only the subset the SDK reads is required.",
      "properties": {
        "name": { "type": "string" },
        "description": { "type": "string" },
        "protocolVersion": { "type": "string" },
        "url": { "type": "string", "format": "uri" },
        "authentication": {
          "type": "object",
          "properties": {
            "schemes": {
              "type": "array",
              "items": { "type": "string", "enum": ["none", "bearer", "oauth2", "apiKey"] }
            }
          }
        },
        "capabilities": {
          "type": "object",
          "properties": {
            "streaming": { "type": "boolean" },
            "pushNotifications": { "type": "boolean" },
            "stateTransitionHistory": { "type": "boolean" }
          }
        },
        "defaultInputModes": { "type": "array", "items": { "type": "string" } },
        "defaultOutputModes": { "type": "array", "items": { "type": "string" } },
        "skills": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "name"],
            "properties": {
              "id": { "type": "string" },
              "name": { "type": "string" },
              "description": { "type": "string" },
              "tags": { "type": "array", "items": { "type": "string" } },
              "examples": { "type": "array", "items": { "type": "string" } }
            }
          }
        }
      }
    },
    "A2ATaskState": {
      "type": "string",
      "enum": ["submitted", "working", "input-required", "completed", "failed", "cancelled"]
    }
  }
}
