{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://passageway.marceltov.de/reference/embedder-protocol.schema.json",
  "title": "passageway embedder protocol v1",
  "description": "The JSON objects of the embedder protocol, one per line, in the order asked. The core writes an infoRequest or an embedRequest to the embedder's stdin and reads one reply line from its stdout: an infoReply, an embedReply, or an errorReply. Unknown fields are allowed and ignored.",
  "$defs": {
    "infoRequest": {
      "type": "object",
      "required": ["op"],
      "properties": {"op": {"const": "info"}}
    },
    "infoReply": {
      "description": "Who the embedder is. The name identifies the model: the index stores it with the dimension, and a different name rebuilds the index.",
      "type": "object",
      "required": ["name", "dim"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "dim": {"type": "integer", "minimum": 1},
        "protocol": {"const": "1", "description": "Optional. The protocol version the embedder speaks."}
      }
    },
    "embedRequest": {
      "type": "object",
      "required": ["op", "kind", "texts"],
      "properties": {
        "op": {"const": "embed"},
        "kind": {"enum": ["query", "passage"], "description": "A query is what the user asks, a passage is what is indexed. Models that need a prefix for each add it themselves."},
        "texts": {"type": "array", "items": {"type": "string"}}
      }
    },
    "embedReply": {
      "description": "One vector per text, in the order of the texts, each with `dim` numbers. The core normalises them to unit length.",
      "type": "object",
      "required": ["vectors"],
      "properties": {"vectors": {"type": "array", "items": {"type": "array", "items": {"type": "number"}}}}
    },
    "errorReply": {
      "description": "Instead of any reply: this request failed. The process stays in use.",
      "type": "object",
      "required": ["error"],
      "properties": {"error": {"type": "string"}}
    }
  }
}
