{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/multi-agent-ecosystem/multi-agent-pipeline/pipeline/schemas/shared-routine.schema.json",
  "title": "Shared routine",
  "description": "What GET /v1/routines/shared/{id} returns (`routine-share.mjs fetch`): one shared routine with its body, after the body was checked against its sha256, with the payload digest an import confirms. localNameTaken is true when a routine or any command directory holding a SKILL.md (shipped, or a local-only command the registry does not track) already has its name here, so an import needs another name.",
  "type": "object",
  "additionalProperties": false,
  "required": ["contractVersion", "routine", "localNameTaken"],
  "properties": {
    "contractVersion": {
      "type": "string",
      "pattern": "^1\\.[0-9]+\\.[0-9]+$",
      "x-sensitivity": "none"
    },
    "routine": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "owner",
        "version",
        "description",
        "descriptionTr",
        "sha256",
        "digest",
        "updatedAt",
        "argumentHint",
        "body"
      ],
      "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",
          "description": "Exactly as import writes it into the frontmatter, unscrubbed; show it as text."
        },
        "descriptionTr": {
          "type": ["string", "null"]
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "digest": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Hex SHA-256 of the canonical JSON of {argumentHint, body, description, descriptionTr, name}, keys sorted, no whitespace, an absent optional field as \"\" (routine-registry.mjs payloadDigest, equal to the sharing server's content digest): everything the import installs."
        },
        "updatedAt": {
          "type": ["string", "null"]
        },
        "argumentHint": {
          "type": ["string", "null"],
          "description": "Exactly as import writes it into the frontmatter, unscrubbed; show it as text."
        },
        "body": {
          "type": "string",
          "description": "The procedure text exactly as import installs it; its sha256 is sha256."
        }
      }
    },
    "localNameTaken": {
      "type": "boolean"
    }
  }
}
