{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agdc.dev/arcotheon/schema/capability-1.json",
  "title": "Arcotheon capability manifest (.adcap v1)",
  "type": "object",
  "required": ["adcap", "id", "version", "name", "summary", "license", "publisher"],
  "additionalProperties": false,
  "properties": {
    "$schema": { "type": "string" },
    "adcap": { "const": "1.0", "description": "Specification version this manifest follows." },
    "id": { "$ref": "#/$defs/capabilityId" },
    "version": { "$ref": "#/$defs/semver" },
    "name": { "type": "string", "minLength": 1, "maxLength": 80 },
    "summary": { "type": "string", "minLength": 1, "maxLength": 200 },
    "description": { "type": "string", "maxLength": 20000 },
    "license": { "type": "string", "minLength": 1, "description": "SPDX expression, or LicenseRef-* for proprietary terms." },
    "homepage": { "type": "string", "format": "uri" },
    "repository": { "type": "string", "format": "uri" },
    "stability": { "enum": ["stable", "experimental"], "default": "stable", "description": "experimental marks a capability whose behaviour or interface may change; hosts label it." },
    "categories": { "type": "array", "maxItems": 5, "uniqueItems": true, "items": { "enum": ["skills", "tools", "workflows", "knowledge", "media", "design", "development", "data", "research", "automation", "other"] } },
    "keywords": { "type": "array", "maxItems": 20, "uniqueItems": true, "items": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,31}$" } },
    "publisher": {
      "type": "object", "required": ["id"], "additionalProperties": false,
      "properties": { "id": { "$ref": "#/$defs/slug" }, "name": { "type": "string" }, "url": { "type": "string", "format": "uri" } }
    },
    "distribution": {
      "type": "object", "additionalProperties": false,
      "properties": {
        "tier": { "enum": ["free", "pro"], "default": "free", "description": "Product tier a host should require. Hosts enforce it; the registry only records it." },
        "access": { "enum": ["public", "entitled"], "default": "public", "description": "public: anyone may download. entitled: the download needs a host-issued authorisation." },
        "entitlement": { "type": "string", "description": "Entitlement key a host checks, e.g. agentdock.pro." }
      }
    },
    "compat": {
      "type": "object", "additionalProperties": false,
      "properties": {
        "platforms": { "type": "array", "minItems": 1, "uniqueItems": true, "items": { "$ref": "#/$defs/platform" }, "description": "Platforms the whole capability supports. Absent means any." },
        "agents": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Host agent id to semver range, e.g. {\"agentdock\": \">=1.0.0\"}. A host not listed is assumed compatible with skills-only capabilities." },
        "runtimes": { "type": "object", "additionalProperties": { "type": "string" }, "description": "Runtime id to semver range, e.g. {\"node\": \">=22\", \"python\": \">=3.10\"}." }
      }
    },
    "skills": {
      "type": "array", "uniqueItems": true,
      "items": { "type": "object", "required": ["path"], "additionalProperties": false, "properties": { "path": { "$ref": "#/$defs/relPath", "description": "Directory containing a standard Agent Skills SKILL.md." } } }
    },
    "tools": { "type": "array", "items": { "$ref": "#/$defs/tool" } },
    "workflows": { "type": "array", "items": { "$ref": "#/$defs/workflow" } },
    "knowledge": { "type": "array", "items": { "$ref": "#/$defs/knowledge" } },
    "assets": { "type": "array", "items": { "$ref": "#/$defs/asset" } },
    "resources": { "type": "array", "items": { "$ref": "#/$defs/resource" } },
    "adapters": { "type": "array", "items": { "$ref": "#/$defs/adapter" } },
    "dependencies": { "type": "object", "propertyNames": { "$ref": "#/$defs/capabilityId" }, "additionalProperties": { "type": "string" } },
    "permissions": { "type": "array", "items": { "$ref": "#/$defs/permission" } },
    "x": { "type": "object", "description": "Extension space. Keys are vendor or publisher names; consumers must ignore what they do not understand. Never used for anything that affects security.", "propertyNames": { "pattern": "^[a-z0-9][a-z0-9-]*$" } },
    "files": { "type": "array", "items": { "$ref": "#/$defs/fileEntry" }, "description": "Written by `arcotheon build`: every file in the archive except capability.json and SIGNATURE.json." }
  },
  "$defs": {
    "slug": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,38}$" },
    "capabilityId": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,38}/[a-z0-9][a-z0-9-]{0,62}$" },
    "semver": { "type": "string", "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$" },
    "platform": { "enum": ["any", "linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64", "win32-x64", "win32-arm64"] },
    "relPath": { "type": "string", "minLength": 1, "maxLength": 240, "pattern": "^(?!/)(?!.*(^|/)\\.\\.?(/|$))[^\\\\\\u0000-\\u001f]+$" },
    "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
    "fileEntry": {
      "type": "object", "required": ["path", "sha256", "size"], "additionalProperties": false,
      "properties": { "path": { "$ref": "#/$defs/relPath" }, "sha256": { "$ref": "#/$defs/sha256" }, "size": { "type": "integer", "minimum": 0 }, "executable": { "type": "boolean" } }
    },
    "permission": {
      "type": "object", "required": ["id", "reason"], "additionalProperties": false,
      "properties": {
        "id": { "enum": ["fs:read", "fs:write", "net:connect", "process:spawn", "env:read", "gpu", "secrets"] },
        "scope": { "type": "string", "description": "fs:*: capability | workspace | cache. net:connect: a host name (no wildcard except a leading *.). process:spawn: a program name. env:read: a variable name. secrets: the secret name. gpu: omit." },
        "reason": { "type": "string", "minLength": 4, "maxLength": 240 }
      }
    },
    "permissionRef": {
      "type": "object", "required": ["id"], "additionalProperties": false,
      "properties": { "id": { "type": "string" }, "scope": { "type": "string" } }
    },
    "tool": {
      "type": "object", "required": ["name", "description", "runtime", "inputSchema"], "additionalProperties": false,
      "properties": {
        "name": { "type": "string", "pattern": "^[a-z][a-z0-9_]{0,62}$" },
        "description": { "type": "string", "minLength": 1, "maxLength": 1000 },
        "runtime": {
          "type": "object", "required": ["type"], "additionalProperties": false,
          "properties": {
            "type": { "enum": ["node", "python", "binary", "wasm", "mcp", "http"] },
            "entry": { "$ref": "#/$defs/relPath", "description": "node/python/wasm: the file to run." },
            "entries": { "type": "object", "propertyNames": { "$ref": "#/$defs/platform" }, "additionalProperties": { "$ref": "#/$defs/relPath" }, "description": "binary: platform to executable (built per platform, listed in files with sha256)." },
            "args": { "type": "array", "items": { "type": "string" } },
            "version": { "type": "string", "description": "Semver range of the interpreter, e.g. >=3.10." }
          }
        },
        "inputSchema": { "type": "object", "description": "JSON Schema (draft 2020-12) of the input." },
        "outputSchema": { "type": "object" },
        "permissions": { "type": "array", "items": { "$ref": "#/$defs/permissionRef" }, "description": "Subset of the capability permissions this tool uses." },
        "resources": { "type": "array", "items": { "$ref": "#/$defs/slug" }, "description": "Resource ids the host must materialise locally before running the tool." },
        "timeoutMs": { "type": "integer", "minimum": 100, "maximum": 3600000, "default": 30000 },
        "limits": { "type": "object", "additionalProperties": false, "properties": { "memoryMb": { "type": "integer", "minimum": 32, "maximum": 4096, "default": 1024 }, "processes": { "type": "integer", "minimum": 4, "maximum": 512, "default": 64 } }, "description": "Resource ceilings the tool needs. The host may lower them; it never raises them above 4096 MiB and 512 processes." },
        "platforms": { "type": "array", "items": { "$ref": "#/$defs/platform" } }
      }
    },
    "workflow": {
      "type": "object", "required": ["id", "path"], "additionalProperties": false,
      "properties": {
        "id": { "$ref": "#/$defs/slug" },
        "path": { "$ref": "#/$defs/relPath", "description": "A workflow document: see spec section 8." },
        "description": { "type": "string" }
      }
    },
    "knowledge": {
      "type": "object", "required": ["id", "type"], "additionalProperties": false,
      "properties": {
        "id": { "$ref": "#/$defs/slug" },
        "type": { "enum": ["markdown", "jsonl", "sqlite", "index"] },
        "path": { "$ref": "#/$defs/relPath" },
        "resource": { "$ref": "#/$defs/slug", "description": "Alternatively, a remote resource id." },
        "description": { "type": "string" }
      },
      "oneOf": [{ "required": ["path"] }, { "required": ["resource"] }]
    },
    "asset": {
      "type": "object", "required": ["path", "kind"], "additionalProperties": false,
      "properties": {
        "path": { "$ref": "#/$defs/relPath" },
        "kind": { "enum": ["image", "video", "audio", "font", "document", "other"] },
        "mime": { "type": "string" },
        "description": { "type": "string" },
        "license": { "type": "string" }
      }
    },
    "resource": {
      "type": "object", "required": ["id", "kind", "sources", "sha256", "size"], "additionalProperties": false,
      "properties": {
        "id": { "$ref": "#/$defs/slug" },
        "kind": { "enum": ["dataset", "index", "model", "media", "archive", "other"] },
        "description": { "type": "string" },
        "sources": { "type": "array", "minItems": 1, "items": { "type": "string", "format": "uri", "pattern": "^https://" }, "description": "HTTPS mirrors tried in order." },
        "sha256": { "$ref": "#/$defs/sha256" },
        "size": { "type": "integer", "minimum": 1 },
        "access": { "enum": ["public", "entitled"], "default": "public" },
        "license": { "type": "string" },
        "lazy": { "type": "boolean", "default": true, "description": "Fetched on first use rather than at install." },
        "format": { "type": "string", "description": "Free-form hint such as jsonl, faiss, safetensors, parquet. The value shardset is defined by the spec: the resource is a JSON shard map and its shards are fetched one by one on demand." }
      }
    },
    "adapter": {
      "type": "object", "required": ["id", "kind"], "additionalProperties": false,
      "properties": {
        "id": { "$ref": "#/$defs/slug" },
        "kind": { "enum": ["model", "inference-backend"] },
        "provider": { "type": "string" },
        "protocol": { "enum": ["openai-compatible", "http-json", "local-process", "other"] },
        "endpoint": { "type": "string", "format": "uri", "description": "Default endpoint; always overridable by the host. Never contains credentials." },
        "model": { "type": "string" },
        "resource": { "$ref": "#/$defs/slug", "description": "Weights resource, for a local model." },
        "description": { "type": "string" }
      }
    }
  }
}
