name: "xml-to-json-cli"
type: pipeline

config:
  input:
    stdin:
      codec: all
      max_buffer: 1048576

  pipeline:
    processors:
      - mapping: |
          meta trace_id = uuid_v4()
          let input = content().trim()

          # Parse XML to JSON
          let parsed = $input.parse_xml().catch(null)

          root.json = if $parsed != null { $parsed } else { {} }
          root.valid = $parsed != null
          root.error = if $parsed == null { "Invalid XML input" } else { "" }
          root.metadata = {"skill": "xml-to-json", "mode": "cli", "trace_id": meta("trace_id"), "timestamp": now()}

  output:
    stdout:
      codec: json_object
