{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "contract": {
      "type": "string",
      "const": "AgentSessionViewModel"
    },
    "sessionId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "snapshot": {
      "type": "object",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "chat",
            "work"
          ]
        },
        "modelId": {
          "type": "string",
          "minLength": 1
        },
        "capabilities": {
          "type": "object",
          "properties": {
            "text": {
              "default": true,
              "type": "boolean"
            },
            "reasoning": {
              "default": false,
              "type": "boolean"
            },
            "plan": {
              "default": false,
              "type": "boolean"
            },
            "tasks": {
              "default": false,
              "type": "boolean"
            },
            "tools": {
              "default": false,
              "type": "boolean"
            },
            "mcp": {
              "default": false,
              "type": "boolean"
            },
            "shell": {
              "default": false,
              "type": "boolean"
            },
            "fileChange": {
              "default": false,
              "type": "boolean"
            },
            "skills": {
              "default": false,
              "type": "boolean"
            },
            "approval": {
              "default": false,
              "type": "boolean"
            },
            "artifacts": {
              "default": false,
              "type": "boolean"
            },
            "usage": {
              "default": false,
              "type": "boolean"
            },
            "resume": {
              "default": false,
              "type": "boolean"
            },
            "diff": {
              "default": false,
              "type": "boolean"
            },
            "workspaceFiles": {
              "default": false,
              "type": "boolean"
            },
            "terminal": {
              "default": false,
              "type": "boolean"
            },
            "testResults": {
              "default": false,
              "type": "boolean"
            },
            "threadForking": {
              "default": false,
              "type": "boolean"
            },
            "editAndRerun": {
              "default": false,
              "type": "boolean"
            },
            "steering": {
              "default": false,
              "type": "boolean"
            },
            "summary": {
              "default": false,
              "type": "boolean"
            }
          },
          "required": [
            "text",
            "reasoning",
            "plan",
            "tasks",
            "tools",
            "mcp",
            "shell",
            "fileChange",
            "skills",
            "approval",
            "artifacts",
            "usage",
            "resume",
            "diff",
            "workspaceFiles",
            "terminal",
            "testResults",
            "threadForking",
            "editAndRerun",
            "steering",
            "summary"
          ],
          "additionalProperties": false
        },
        "permissionProfile": {
          "type": "string",
          "enum": [
            "approval-required",
            "auto-approve",
            "full-access"
          ]
        }
      },
      "required": [
        "mode",
        "modelId",
        "capabilities"
      ],
      "additionalProperties": false
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "waiting_approval",
        "stopping",
        "stopped",
        "completed",
        "failed"
      ]
    },
    "events": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "message"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "messageId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "user",
                      "assistant",
                      "system"
                    ]
                  },
                  "operation": {
                    "default": "append",
                    "type": "string",
                    "enum": [
                      "append",
                      "replace"
                    ]
                  },
                  "parts": {
                    "type": "array",
                    "items": {
                      "$ref": "#/$defs/__schema0"
                    }
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "streaming",
                      "completed",
                      "failed"
                    ]
                  }
                },
                "required": [
                  "messageId",
                  "role",
                  "operation",
                  "parts"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "reasoning"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "reasoningId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "text": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "streaming",
                      "completed"
                    ]
                  }
                },
                "required": [
                  "reasoningId",
                  "text",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "plan"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "planId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "title": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "running",
                      "completed",
                      "failed"
                    ]
                  },
                  "steps": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 256
                        },
                        "title": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending",
                            "running",
                            "completed",
                            "failed",
                            "skipped"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "title",
                        "status"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "planId",
                  "status",
                  "steps"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "task"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "taskId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "title": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "running",
                      "completed",
                      "failed",
                      "skipped"
                    ]
                  },
                  "detail": {
                    "type": "string"
                  }
                },
                "required": [
                  "taskId",
                  "title",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "tool"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "toolCallId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "toolName": {
                    "type": "string",
                    "minLength": 1
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "running",
                      "completed",
                      "failed",
                      "denied"
                    ]
                  },
                  "input": {
                    "$ref": "#/$defs/__schema0"
                  },
                  "output": {
                    "$ref": "#/$defs/__schema0"
                  },
                  "error": {
                    "type": "string"
                  },
                  "startedAt": {
                    "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  },
                  "completedAt": {
                    "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  }
                },
                "required": [
                  "toolCallId",
                  "toolName",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "approval"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "approvalId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "toolCallId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "requested",
                      "approved",
                      "rejected",
                      "expired"
                    ]
                  },
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "requestedAction": {
                    "$ref": "#/$defs/__schema0"
                  }
                },
                "required": [
                  "approvalId",
                  "status",
                  "title"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "status"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "queued",
                      "running",
                      "waiting_approval",
                      "stopping",
                      "stopped",
                      "completed",
                      "failed"
                    ]
                  },
                  "detail": {
                    "type": "string"
                  },
                  "startedAt": {
                    "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  },
                  "stoppingRequestedAt": {
                    "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  },
                  "stoppedAt": {
                    "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  },
                  "completedAt": {
                    "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  },
                  "failedAt": {
                    "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  },
                  "durationMs": {
                    "type": "number",
                    "minimum": 0
                  }
                },
                "required": [
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "artifact"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "artifactId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "file",
                      "image",
                      "video",
                      "audio",
                      "web",
                      "other"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "ready",
                      "failed"
                    ]
                  },
                  "mimeType": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "size": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "sourceEventId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  }
                },
                "required": [
                  "artifactId",
                  "name",
                  "kind",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "usage"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "inputTokens": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "outputTokens": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "totalTokens": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "contextTokens": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  },
                  "contextWindow": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "resume"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "resumable": {
                    "type": "boolean"
                  },
                  "state": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "$ref": "#/$defs/__schema0"
                    }
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "resumable"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "error"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "minLength": 1
                  },
                  "message": {
                    "type": "string"
                  },
                  "retryable": {
                    "type": "boolean"
                  },
                  "sourceEventId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "details": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string"
                    },
                    "additionalProperties": {
                      "$ref": "#/$defs/__schema0"
                    }
                  }
                },
                "required": [
                  "code",
                  "message",
                  "retryable"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "diff"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "path": {
                    "type": "string",
                    "minLength": 1
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "added",
                      "modified",
                      "deleted",
                      "renamed"
                    ]
                  },
                  "patch": {
                    "type": "string"
                  }
                },
                "required": [
                  "path",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "workspace-file"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "path": {
                    "type": "string",
                    "minLength": 1
                  },
                  "operation": {
                    "type": "string",
                    "enum": [
                      "upsert",
                      "delete"
                    ]
                  },
                  "mimeType": {
                    "type": "string"
                  },
                  "size": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "path",
                  "operation"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "terminal"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "terminalId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "stream": {
                    "type": "string",
                    "enum": [
                      "stdin",
                      "stdout",
                      "stderr",
                      "status"
                    ]
                  },
                  "chunk": {
                    "type": "string"
                  },
                  "exitCode": {
                    "type": "integer",
                    "minimum": -9007199254740991,
                    "maximum": 9007199254740991
                  }
                },
                "required": [
                  "terminalId",
                  "stream",
                  "chunk"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "test-result"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "testId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "name": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "running",
                      "passed",
                      "failed",
                      "skipped"
                    ]
                  },
                  "durationMs": {
                    "type": "number",
                    "minimum": 0
                  },
                  "output": {
                    "type": "string"
                  }
                },
                "required": [
                  "testId",
                  "name",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "steer"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "commandId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "targetRunId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "text": {
                    "type": "string",
                    "minLength": 1
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "accepted",
                      "applied",
                      "failed"
                    ]
                  },
                  "error": {
                    "type": "object",
                    "properties": {
                      "code": {
                        "type": "string",
                        "enum": [
                          "SESSION_NOT_FOUND",
                          "RUN_NOT_FOUND",
                          "ACTIVE_RUN_NOT_FOUND",
                          "RUN_ALREADY_FINISHED",
                          "STOP_TIMEOUT",
                          "COMMAND_NOT_SUPPORTED",
                          "CAPABILITY_UNAVAILABLE",
                          "SEQUENCE_CONFLICT",
                          "INVALID_SESSION_STATE",
                          "TARGET_EVENT_NOT_FOUND",
                          "TARGET_EVENT_NOT_RETRYABLE",
                          "APPROVAL_NOT_FOUND",
                          "APPROVAL_ALREADY_RESOLVED",
                          "SOURCE_THREAD_NOT_FOUND",
                          "SOURCE_MESSAGE_NOT_FOUND",
                          "SOURCE_RUN_NOT_FOUND",
                          "SOURCE_LINEAGE_INVALID",
                          "ACTIVE_BRANCH_NOT_FOUND",
                          "COMMAND_EXECUTION_FAILED"
                        ]
                      },
                      "message": {
                        "type": "string"
                      },
                      "retryable": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "code",
                      "message",
                      "retryable"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "commandId",
                  "targetRunId",
                  "text",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "contract": {
                "type": "string",
                "const": "AgentSessionEvent"
              },
              "eventId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sessionId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "runId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sourceMessageId": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "sequence": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              "idempotencyKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              "occurredAt": {
                "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              "eventType": {
                "type": "string",
                "const": "summary"
              },
              "payload": {
                "type": "object",
                "properties": {
                  "summaryId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "runId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 256
                  },
                  "text": {
                    "type": "string"
                  },
                  "highlights": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "pendingItems": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "generating",
                      "completed",
                      "failed"
                    ]
                  }
                },
                "required": [
                  "summaryId",
                  "runId",
                  "text",
                  "highlights",
                  "pendingItems",
                  "status"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "contract",
              "eventId",
              "sessionId",
              "sequence",
              "idempotencyKey",
              "occurredAt",
              "eventType",
              "payload"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "lastSequence": {
      "type": "integer",
      "minimum": -1,
      "maximum": 9007199254740991
    },
    "resumable": {
      "default": false,
      "type": "boolean"
    },
    "lineage": {
      "type": "object",
      "properties": {
        "forkedFromThreadId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "forkedFromMessageId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "sourceRunId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        }
      },
      "required": [
        "forkedFromThreadId",
        "forkedFromMessageId",
        "sourceRunId"
      ],
      "additionalProperties": false
    },
    "activeBranch": {
      "type": "object",
      "properties": {
        "branchId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "threadId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "sourceMessageId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "runId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256
        },
        "lineage": {
          "type": "object",
          "properties": {
            "forkedFromThreadId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "forkedFromMessageId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            },
            "sourceRunId": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256
            }
          },
          "required": [
            "forkedFromThreadId",
            "forkedFromMessageId",
            "sourceRunId"
          ],
          "additionalProperties": false
        },
        "createdAt": {
          "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+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        }
      },
      "required": [
        "branchId",
        "threadId",
        "sourceMessageId",
        "runId",
        "createdAt"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "contract",
    "sessionId",
    "snapshot",
    "status",
    "events",
    "lastSequence",
    "resumable"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    }
  },
  "$id": "https://schemas.infmonkeys.com/contracts/agent-session-view-model.schema.json",
  "title": "agent-session-view-model"
}
