{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/boshu2/agentops/docs/contracts/rpi-c2-events.schema.json",
  "title": "RPI C2 Events",
  "description": "Schema for .agents/rpi/runs/<run-id>/events.jsonl normalized control-plane/runtime events.",
  "type": "object",
  "required": [
    "schema_version",
    "event_id",
    "run_id",
    "type",
    "timestamp"
  ],
  "properties": {
    "schema_version": {
      "type": "integer",
      "const": 1
    },
    "event_id": {
      "type": "string",
      "minLength": 1
    },
    "run_id": {
      "type": "string",
      "minLength": 1
    },
    "command_id": {
      "type": "string"
    },
    "phase": {
      "type": "integer",
      "minimum": 1
    },
    "backend": {
      "type": "string",
      "enum": ["direct", "stream", "tmux", "claude", "codex", "unknown"]
    },
    "source": {
      "type": "string"
    },
    "worker_id": {
      "type": "string"
    },
    "type": {
      "type": "string",
      "minLength": 1
    },
    "message": {
      "type": "string"
    },
    "details": {
      "description": "Arbitrary event payload from runtime adapters or control-plane surfaces.",
      "oneOf": [
        {"type": "object", "additionalProperties": true},
        {"type": "array"},
        {"type": "string"},
        {"type": "number"},
        {"type": "boolean"},
        {"type": "null"}
      ]
    },
    "timestamp": {
      "type": "string",
      "format": "date-time"
    }
  },
  "additionalProperties": false
}
