{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/shared-routines.schema.json",
  "title": "Shared routines",
  "description": "What GET /v1/routines/shared returns (`routine-share.mjs browse`): the routines other site members shared that this machine may see, without bodies. available is false when sharing could not answer, with reason: no-usage-token (nothing to authenticate with), endpoint-not-allowed (not https and not loopback), unreachable, redirect-refused, unauthorized, or upstream-error; routines is then empty. importedAs is the local routine imported from that shared id, or null. Descriptions are scrubbed.",
  "type": "object",
  "additionalProperties": false,
  "required": ["contractVersion", "available", "routines"],
  "properties": {
    "contractVersion": {
      "type": "string",
      "pattern": "^1\\.[0-9]+\\.[0-9]+$",
      "x-sensitivity": "none"
    },
    "available": {
      "type": "boolean"
    },
    "reason": {
      "enum": [
        "no-usage-token",
        "endpoint-not-allowed",
        "unreachable",
        "redirect-refused",
        "unauthorized",
        "upstream-error"
      ]
    },
    "routines": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "owner",
          "version",
          "description",
          "descriptionTr",
          "sha256",
          "updatedAt",
          "mine",
          "importedAs"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9-]{0,63}$"
          },
          "name": {
            "type": "string"
          },
          "owner": {
            "type": "string"
          },
          "version": {
            "type": "integer",
            "minimum": 1
          },
          "description": {
            "type": "string"
          },
          "descriptionTr": {
            "type": ["string", "null"]
          },
          "sha256": {
            "type": ["string", "null"],
            "pattern": "^[0-9a-f]{64}$"
          },
          "updatedAt": {
            "type": ["string", "null"]
          },
          "mine": {
            "type": "boolean"
          },
          "importedAs": {
            "type": ["string", "null"]
          }
        }
      }
    }
  }
}
