{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.nylorun.com/schemas/agent-folder/v1/agent-md.json",
  "title": "Nylorun agent folder: AGENT.md frontmatter",
  "description": "The frontmatter of an agent folder's AGENT.md; the body below it is the instructions",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",
      "description": "The agent manifest's name, the folder's when it is saved under one"
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "description": "What the agent does, in a sentence"
    },
    "format": {
      "const": 1,
      "description": "The folder's format: 1 (agent-folder/1), the default"
    },
    "harness": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]{1,62}$",
      "description": "The harness that runs the loop: nylorun (ours, the default) or a custom harness's id"
    },
    "inputSchema": {
      "$ref": "#/$defs/JsonSchemaOrPath",
      "description": "A flow's input (a folder with flow.json); an agent's input is the message"
    },
    "outputSchema": {
      "$ref": "#/$defs/JsonSchemaOrPath",
      "description": "The JSON Schema of the agent's final answer"
    },
    "mcpServers": {
      "type": "object",
      "propertyNames": {
        "pattern": "^[A-Za-z0-9_-]{1,64}$"
      },
      "additionalProperties": {
        "$ref": "#/$defs/McpServerSettings"
      },
      "description": "How this agent uses each MCP server of mcp.json or a plugin, by its name"
    },
    "skills": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "secrets": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
            },
            "description": "The secret slots the skill's scripts read, as environment variables"
          }
        },
        "additionalProperties": false
      },
      "description": "This agent's settings for each skill of skills/ or a plugin, by its name"
    },
    "memory": {
      "type": "object",
      "properties": {
        "access": {
          "description": "`read_write` (the default) or `read_only`",
          "type": "string",
          "enum": [
            "read_write",
            "read_only"
          ]
        },
        "instructions": {
          "description": "What this agent should remember, after the engine's own memory rules",
          "type": "string",
          "maxLength": 4096
        }
      },
      "additionalProperties": false,
      "description": "The Agent's memory: Markdown files under /memories it keeps across sessions"
    },
    "loop": {
      "type": "object",
      "description": "The harness's own settings, passed to it each turn; the nylorun harness reads none yet"
    },
    "metadata": {
      "type": "object",
      "description": "The manifest's metadata, as it is"
    }
  },
  "required": [
    "name",
    "description"
  ],
  "additionalProperties": false,
  "$defs": {
    "JsonSchemaOrPath": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "\\.json$",
          "description": "The path of a JSON Schema file in the folder (./output.schema.json; /schemas/x.json from the uploaded folder's root), named *.schema.json or kept under schemas/"
        },
        {
          "type": "object",
          "description": "A JSON Schema (2020-12), inline"
        }
      ]
    },
    "McpServerSettings": {
      "type": "object",
      "properties": {
        "deferred": {
          "type": "boolean",
          "description": "Offer the server's tools on demand, by search, instead of in every turn"
        },
        "tools": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "deferred": {
                "type": "boolean"
              }
            },
            "additionalProperties": false
          },
          "description": "Settings for each of the server's tools by name, \"*\" for the rest; approval is the Tenant's tool policy, not set here"
        },
        "credential": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._-]{1,64}$",
          "description": "The secret slot a plugin's server authenticates with, which the plugin cannot name; a server of mcp.json names it in a header"
        }
      },
      "additionalProperties": false
    }
  }
}
