{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pentestkit.dev/schemas/agents/v2/telemetry.schema.json",
  "title": "PTK Agents SDK Telemetry Summary",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "schemaVersion",
    "runId",
    "startTime",
    "endTime",
    "totalDurationMs",
    "requestedMode",
    "actualMode",
    "fallbackMode",
    "fallbackReason",
    "routeCount",
    "routeShapeCount",
    "endpointCount",
    "formCount",
    "actionCount",
    "scenarioStepsCompleted",
    "actionsAttempted",
    "actionsChangedState",
    "actionsDidNothing",
    "noProgressActionCount",
    "navigationTimeMs",
    "observationTimeMs",
    "actionTimeMs",
    "waitTimeMs",
    "blockedTimeMs",
    "errorCount",
    "findingsCount"
  ],
  "properties": {
    "schemaVersion": { "const": "ptk-agent-v2-telemetry" },
    "runId": { "type": "string", "minLength": 1 },
    "startTime": { "type": "string", "format": "date-time" },
    "endTime": { "type": ["string", "null"], "format": "date-time" },
    "totalDurationMs": { "type": "number", "minimum": 0 },
    "requestedMode": { "type": "string", "minLength": 1 },
    "actualMode": { "type": "string", "minLength": 1 },
    "fallbackMode": { "type": ["string", "null"] },
    "fallbackReason": { "type": ["string", "null"] },
    "routeCount": { "type": "integer", "minimum": 0 },
    "routeShapeCount": { "type": "integer", "minimum": 0 },
    "endpointCount": { "type": "integer", "minimum": 0 },
    "formCount": { "type": "integer", "minimum": 0 },
    "actionCount": { "type": "integer", "minimum": 0 },
    "scenarioStepsCompleted": { "type": "integer", "minimum": 0 },
    "actionsAttempted": { "type": "integer", "minimum": 0 },
    "actionsChangedState": { "type": "integer", "minimum": 0 },
    "actionsDidNothing": { "type": "integer", "minimum": 0 },
    "noProgressActionCount": { "type": "integer", "minimum": 0 },
    "navigationTimeMs": { "type": "number", "minimum": 0 },
    "observationTimeMs": { "type": "number", "minimum": 0 },
    "actionTimeMs": { "type": "number", "minimum": 0 },
    "waitTimeMs": { "type": "number", "minimum": 0 },
    "blockedTimeMs": { "type": "number", "minimum": 0 },
    "errorCount": { "type": "integer", "minimum": 0 },
    "findingsCount": { "type": ["integer", "null"], "minimum": 0 },
    "routes": { "type": "array", "items": { "type": "object" } },
    "routeShapes": { "type": "array", "items": { "type": "string" } },
    "endpoints": { "type": "array", "items": { "type": "string" } },
    "errors": { "type": "array", "items": { "type": "object" } }
  },
  "$defs": {
    "timingArtifact": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schemaVersion",
        "runId",
        "startTime",
        "endTime",
        "totalDurationMs",
        "navigationTimeMs",
        "observationTimeMs",
        "actionTimeMs",
        "waitTimeMs",
        "blockedTimeMs"
      ],
      "properties": {
        "schemaVersion": { "const": "ptk-agent-v2-telemetry" },
        "runId": { "type": "string" },
        "startTime": { "type": "string", "format": "date-time" },
        "endTime": { "type": ["string", "null"], "format": "date-time" },
        "totalDurationMs": { "type": "number", "minimum": 0 },
        "navigationTimeMs": { "type": "number", "minimum": 0 },
        "observationTimeMs": { "type": "number", "minimum": 0 },
        "actionTimeMs": { "type": "number", "minimum": 0 },
        "waitTimeMs": { "type": "number", "minimum": 0 },
        "blockedTimeMs": { "type": "number", "minimum": 0 }
      }
    },
    "event": {
      "type": "object",
      "additionalProperties": true,
      "required": ["runId", "time", "type", "data"],
      "properties": {
        "runId": { "type": "string" },
        "time": { "type": "string", "format": "date-time" },
        "type": { "type": "string", "minLength": 1 },
        "data": { "type": "object" }
      }
    }
  }
}
