{
  "$id": "https://sessionpipe.org/schema/v1/event-data.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "session.started": {
      "type": "object",
      "properties": {
        "source": {
          "type": "string",
          "enum": [
            "startup",
            "resume",
            "clear",
            "compact",
            "fork",
            "unknown"
          ]
        }
      },
      "required": [
        "source"
      ],
      "additionalProperties": {}
    },
    "session.heartbeat": {
      "type": "object",
      "properties": {},
      "additionalProperties": {}
    },
    "session.ended": {
      "type": "object",
      "properties": {
        "reason": {
          "type": "string",
          "enum": [
            "clear",
            "logout",
            "exit",
            "other"
          ]
        }
      },
      "required": [
        "reason"
      ],
      "additionalProperties": {}
    },
    "session.backfill": {
      "type": "object",
      "properties": {
        "started_at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}(?:Z))$"
        },
        "last_at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}(?:Z))$"
        },
        "turns": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "started_at",
        "last_at"
      ],
      "additionalProperties": {}
    },
    "session.forgotten": {
      "type": "object",
      "properties": {},
      "additionalProperties": {}
    },
    "turn.started": {
      "type": "object",
      "properties": {
        "turn_id": {
          "type": "string",
          "maxLength": 128
        },
        "prompt_chars": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "additionalProperties": {}
    },
    "turn.ended": {
      "type": "object",
      "properties": {
        "turn_id": {
          "type": "string",
          "maxLength": 128
        },
        "reason": {
          "type": "string",
          "enum": [
            "stop",
            "interrupt",
            "error"
          ]
        },
        "ms": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "required": [
        "reason"
      ],
      "additionalProperties": {}
    },
    "turn.transcript": {
      "type": "object",
      "properties": {
        "turn": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "user": {
          "type": "string",
          "maxLength": 20000
        },
        "assistant": {
          "type": "string",
          "maxLength": 20000
        },
        "at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}(?:Z))$"
        }
      },
      "required": [
        "turn",
        "user",
        "assistant",
        "at"
      ],
      "additionalProperties": {}
    },
    "tool.started": {
      "type": "object",
      "properties": {
        "tool": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.:-]{1,120}$"
        },
        "call_id": {
          "type": "string",
          "maxLength": 128
        },
        "turn_id": {
          "type": "string",
          "maxLength": 128
        },
        "agent_id": {
          "type": "string",
          "maxLength": 128
        },
        "input": {}
      },
      "required": [
        "tool"
      ],
      "additionalProperties": {}
    },
    "tool.ended": {
      "type": "object",
      "properties": {
        "tool": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.:-]{1,120}$"
        },
        "call_id": {
          "type": "string",
          "maxLength": 128
        },
        "turn_id": {
          "type": "string",
          "maxLength": 128
        },
        "agent_id": {
          "type": "string",
          "maxLength": 128
        },
        "ms": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "ok": {
          "type": "boolean"
        },
        "error": {
          "type": "string",
          "maxLength": 2000
        },
        "input": {},
        "output": {}
      },
      "required": [
        "tool",
        "ok"
      ],
      "additionalProperties": {}
    },
    "files.changed": {
      "type": "object",
      "properties": {
        "paths": {
          "maxItems": 500,
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 1024
          }
        }
      },
      "required": [
        "paths"
      ],
      "additionalProperties": {}
    },
    "attention.needed": {
      "type": "object",
      "properties": {
        "attention_id": {
          "type": "string",
          "maxLength": 128
        },
        "kind": {
          "type": "string",
          "enum": [
            "permission",
            "question",
            "elicitation",
            "idle",
            "error"
          ]
        },
        "tool": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_.:-]{1,120}$"
        },
        "message": {
          "type": "string",
          "maxLength": 200
        }
      },
      "required": [
        "attention_id",
        "kind"
      ],
      "additionalProperties": {}
    },
    "attention.cleared": {
      "type": "object",
      "properties": {
        "attention_id": {
          "type": "string",
          "maxLength": 128
        },
        "how": {
          "type": "string",
          "enum": [
            "answered",
            "cancelled",
            "timeout",
            "unknown"
          ]
        }
      },
      "required": [
        "attention_id",
        "how"
      ],
      "additionalProperties": {}
    },
    "subagent.started": {
      "type": "object",
      "properties": {
        "agent_id": {
          "type": "string",
          "maxLength": 128
        },
        "agent_type": {
          "type": "string",
          "maxLength": 128
        }
      },
      "required": [
        "agent_id"
      ],
      "additionalProperties": {}
    },
    "subagent.ended": {
      "type": "object",
      "properties": {
        "agent_id": {
          "type": "string",
          "maxLength": 128
        },
        "agent_type": {
          "type": "string",
          "maxLength": 128
        }
      },
      "required": [
        "agent_id"
      ],
      "additionalProperties": {}
    },
    "context.compacted": {
      "type": "object",
      "properties": {
        "trigger": {
          "type": "string",
          "enum": [
            "manual",
            "auto"
          ]
        }
      },
      "required": [
        "trigger"
      ],
      "additionalProperties": {}
    },
    "native": {
      "type": "object",
      "properties": {},
      "additionalProperties": {}
    }
  },
  "required": [
    "session.started",
    "session.heartbeat",
    "session.ended",
    "session.backfill",
    "session.forgotten",
    "turn.started",
    "turn.ended",
    "turn.transcript",
    "tool.started",
    "tool.ended",
    "files.changed",
    "attention.needed",
    "attention.cleared",
    "subagent.started",
    "subagent.ended",
    "context.compacted",
    "native"
  ]
}
