{
  "functions": [
    {
      "id": "fn_lkparse",
      "type": "parse",
      "enabled": true,
      "filter": "body.startsWith(\"{\")",
      "description": "Parse JSON agent logs (python-json-logger, pino) into attributes",
      "source": "body",
      "format": "json",
      "keep_source": false
    },
    {
      "id": "fn_lkmsg",
      "type": "rename",
      "enabled": true,
      "description": "Use the message field as the log body",
      "fields": [
        {"from": "attributes.message", "to": "body"},
        {"from": "attributes.msg", "to": "body"}
      ]
    },
    {
      "id": "fn_lkroom",
      "type": "rename",
      "enabled": true,
      "description": "Map common agent fields to the Logthread LiveKit attribute names",
      "fields": [
        {"from": "attributes.room", "to": "attributes.livekit.room.name"},
        {"from": "attributes.room_name", "to": "attributes.livekit.room.name"},
        {"from": "attributes.room_sid", "to": "attributes.livekit.room.sid"},
        {"from": "attributes.roomID", "to": "attributes.livekit.room.sid"},
        {"from": "attributes.participant", "to": "attributes.livekit.participant.identity"},
        {"from": "attributes.job_id", "to": "attributes.livekit.job.id"},
        {"from": "attributes.worker_id", "to": "attributes.livekit.worker.id"}
      ]
    },
    {
      "id": "fn_lkcorr",
      "type": "set",
      "enabled": true,
      "filter": "attributes[\"livekit.room.sid\"] != \"\"",
      "description": "The room session id is the correlation id",
      "fields": [
        {"path": "attributes.correlation_id", "expr": "attributes[\"livekit.room.sid\"]"}
      ]
    },
    {
      "id": "fn_lkpii",
      "type": "remove",
      "enabled": true,
      "description": "Drop LiveKit Agents PII span/log fields (lk.pii.*: user text, transcripts). Replace with a mask function to keep the keys instead.",
      "fields": ["attributes.lk.pii.*"]
    },
    {
      "id": "fn_lkmask",
      "type": "mask",
      "enabled": true,
      "description": "Redact secrets and card numbers that slip into free-text bodies",
      "fields": ["body"],
      "detectors": ["card", "jwt", "bearer", "secret_kv", "aws_key"],
      "mode": "redact"
    }
  ]
}
