{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "RootConfigFile",
  "description": "Serializable model for the root `config.toml` file.",
  "type": "object",
  "properties": {
    "agent": {
      "description": "Agent id to structured config mapping under `[agent.<id>]`.",
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/AgentConfigFile"
      },
      "default": {}
    },
    "default_playground": {
      "description": "Optional playground id used when `apg` runs without an explicit id.",
      "type": [
        "string",
        "null"
      ]
    },
    "playground": {
      "description": "Optional defaults inherited by all playgrounds.",
      "$ref": "#/$defs/PlaygroundConfig"
    },
    "saved_playgrounds_dir": {
      "description": "Optional directory for persisted playground snapshots.\n\nRelative paths are resolved against [`ConfigPaths::root_dir`].",
      "type": [
        "string",
        "null"
      ]
    }
  },
  "$defs": {
    "AgentConfigFile": {
      "description": "Serializable model for one `[agent.<id>]` entry in root `config.toml`.",
      "type": "object",
      "properties": {
        "cmd": {
          "description": "Command used to launch the agent.",
          "type": [
            "string",
            "null"
          ]
        },
        "config_dir": {
          "description": "Relative destination directory copied during `apg init --agent <id>`.",
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "CreateMode": {
      "description": "Strategy used to materialize playground contents into a temporary directory.",
      "oneOf": [
        {
          "description": "Recursively copy files into the temporary directory.",
          "type": "string",
          "const": "copy"
        },
        {
          "description": "Create symlinks from the temporary directory back to the playground.",
          "type": "string",
          "const": "symlink"
        },
        {
          "description": "Recreate directories and hard-link regular files into the temporary directory.",
          "type": "string",
          "const": "hardlink"
        }
      ]
    },
    "PlaygroundConfig": {
      "description": "Shared playground-scoped config fields used by root defaults and per-playground overrides.",
      "type": "object",
      "properties": {
        "create_mode": {
          "description": "Optional strategy for creating the temporary playground working tree.",
          "anyOf": [
            {
              "$ref": "#/$defs/CreateMode"
            },
            {
              "type": "null"
            }
          ]
        },
        "default_agent": {
          "description": "Optional default agent id override.",
          "type": [
            "string",
            "null"
          ]
        },
        "load_env": {
          "description": "Optional flag controlling `.env` loading in playground runs.",
          "type": [
            "boolean",
            "null"
          ]
        }
      }
    }
  }
}