{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://registry.drej.dev/schema/agent-item.json",
  "title": "AgentSpec",
  "description": "JSON spec for a drej agent, fetched by `drejx add` and run by `@drej/agent`'s Agent.load(). See https://docs.drej.dev/docs/drejx/registry/schema for the full field reference.",
  "type": "object",
  "required": ["name", "cli"],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Editor/tooling hint pointing back at this schema."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "Unique identifier. Used as the saved filename (<name>.json) and the sandbox session name."
    },
    "title": {
      "type": "string",
      "description": "Human-readable display name."
    },
    "description": {
      "type": "string",
      "description": "Shown by `drejx list`, falling back from `title` if unset."
    },
    "author": {
      "type": "string",
      "description": "Author name and optional URL."
    },
    "categories": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Tags for discovery. Informational only."
    },
    "cli": {
      "const": "pi",
      "description": "CLI to run inside the sandbox. Only \"pi\" is currently accepted."
    },
    "cliVersion": {
      "type": "string",
      "description": "npm version specifier for the Pi CLI, e.g. \"1.2.3\", \"^1.2.0\", or a dist-tag like \"latest\"."
    },
    "provider": {
      "type": "string",
      "description": "AI provider passed to Pi via --provider. Omit for a direct Google API key (Pi's default)."
    },
    "model": {
      "type": "string",
      "description": "Model ID passed to Pi via --model."
    },
    "packages": {
      "type": "array",
      "items": { "type": "string" },
      "description": "APT packages installed before the CLI starts. nodejs/nodejs_22 are silently ignored (base image is node:22)."
    },
    "env": {
      "type": "object",
      "additionalProperties": { "type": "string" },
      "description": "Environment variables available inside the sandbox. Values may reference host env vars: \"${MY_API_KEY}\"."
    },
    "resources": {
      "type": "object",
      "properties": {
        "cpu": { "type": "string" },
        "memory": { "type": "string" },
        "gpu": { "type": "string" }
      },
      "required": ["cpu", "memory"],
      "additionalProperties": false,
      "description": "Falls back to defaults.resources in drej.config.json if omitted."
    },
    "metadata": {
      "type": "object",
      "additionalProperties": { "type": "string" },
      "description": "Not read anywhere in @drej/agent; has no effect on the sandbox."
    },
    "registryDependencies": {
      "type": "array",
      "items": { "type": "string" },
      "description": "URLs of other agent specs. drejx add fetches and saves each one first, depth-first. No cycle detection."
    },
    "setup": {
      "type": "array",
      "description": "Steps run inside the sandbox after CLI install, before the checkpoint.",
      "items": {
        "type": "object",
        "required": ["name", "run"],
        "properties": {
          "name": { "type": "string", "description": "Human-readable label shown in logs." },
          "run": { "type": "string", "description": "Shell command to run (bash)." },
          "cwd": {
            "type": "string",
            "description": "If set, the command runs as `cd <cwd> && <run>`."
          }
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": true
}
