{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mojeeb-app/json-schema/mojeeb-app-agent-setup-schema.json",
  "title": "AgentSetup",
  "description": "Where the agent stands on the path to a working agent, and what to do next.",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mojeeb-app-openapi.yaml#/components/schemas/AgentSetup",
  "type": "object",
  "required": [
    "agent_id",
    "stage",
    "next",
    "steps",
    "optional",
    "attention",
    "facts",
    "guidance"
  ],
  "properties": {
    "agent_id": {
      "type": "string",
      "format": "uuid"
    },
    "stage": {
      "type": "string",
      "enum": [
        "empty",
        "instructed",
        "knowledge",
        "tested",
        "connected",
        "live"
      ],
      "description": "The furthest point reached on the path. `live` as soon as a customer has written, whatever the channels are today."
    },
    "next": {
      "$ref": "#/$defs/SetupNext"
    },
    "steps": {
      "type": "array",
      "description": "The path, in order: instructions, knowledge, test, channel, live.",
      "items": {
        "$ref": "#/$defs/SetupStep"
      }
    },
    "optional": {
      "type": "array",
      "description": "Beside the path: lead_capture, attachments, custom_api_tools.",
      "items": {
        "$ref": "#/$defs/SetupStep"
      }
    },
    "attention": {
      "type": "array",
      "description": "What to fix first, when something is off. Empty when nothing is.",
      "items": {
        "type": "string"
      }
    },
    "facts": {
      "$ref": "#/$defs/SetupFacts"
    },
    "guidance": {
      "type": "array",
      "description": "The house rules for a good agent, the same every time.",
      "items": {
        "type": "string"
      }
    }
  },
  "$defs": {
    "SetupFacts": {
      "type": "object",
      "description": "The live numbers the report was derived from.",
      "required": [
        "instructions_characters",
        "knowledge",
        "attachments",
        "tested",
        "has_customers",
        "lead_capture",
        "channels",
        "custom_api_tools",
        "assistants",
        "message_weight"
      ],
      "properties": {
        "instructions_characters": {
          "type": "integer",
          "description": "Characters in the Main Instructions."
        },
        "knowledge": {
          "type": "object",
          "required": [
            "entries",
            "characters",
            "recommended_max_characters",
            "updated_at"
          ],
          "properties": {
            "entries": {
              "type": "integer",
              "description": "Active knowledge base entries."
            },
            "characters": {
              "type": "integer",
              "description": "Their characters together."
            },
            "recommended_max_characters": {
              "type": "integer",
              "description": "Keep `characters` under this."
            },
            "updated_at": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time",
              "description": "When an entry last changed."
            }
          }
        },
        "attachments": {
          "type": "object",
          "required": [
            "count",
            "active"
          ],
          "properties": {
            "count": {
              "type": "integer"
            },
            "active": {
              "type": "integer",
              "description": "Switched on, so the agent can send them."
            }
          }
        },
        "tested": {
          "type": "boolean",
          "description": "A test chat exists (the Studio chat or sendTestChatMessage)."
        },
        "has_customers": {
          "type": "boolean",
          "description": "A customer has written on any channel."
        },
        "lead_capture": {
          "type": "object",
          "required": [
            true,
            "customised",
            "fields",
            "has_leads"
          ],
          "properties": {
            "true": {
              "type": "boolean",
              "description": "The agent has a Capture Lead tool (every new agent starts with one)."
            },
            "customised": {
              "type": "boolean",
              "description": "Its prompt is no longer the generic one every agent starts with: the business said what counts as a lead here and what to ask for."
            },
            "fields": {
              "type": "integer",
              "description": "Custom lead fields the business added with createLeadField, such as a booking date-time or a branch from a list."
            },
            "has_leads": {
              "type": "boolean",
              "description": "At least one lead was captured."
            }
          }
        },
        "channels": {
          "type": "array",
          "description": "Active channels: whatsapp, facebook, instagram.",
          "items": {
            "type": "string"
          }
        },
        "custom_api_tools": {
          "type": "integer",
          "description": "Active custom API tools."
        },
        "assistants": {
          "type": "array",
          "description": "AI assistants connected to the company (Claude, ChatGPT, Cursor, VS Code, or a host).",
          "items": {
            "type": "string"
          }
        },
        "message_weight": {
          "type": "object",
          "required": [
            "characters",
            "weight",
            "threshold_characters"
          ],
          "properties": {
            "characters": {
              "type": "integer",
              "description": "Instructions, active knowledge and attachments together, in characters, as the plan counts them."
            },
            "weight": {
              "type": "integer",
              "description": "What one reply counts as, in messages."
            },
            "threshold_characters": {
              "type": "integer",
              "description": "Every this many characters adds one."
            }
          }
        }
      }
    },
    "SetupNext": {
      "type": "object",
      "required": [
        "step",
        "say",
        "tool",
        "where"
      ],
      "properties": {
        "step": {
          "type": "string",
          "description": "The key of the step to take now."
        },
        "say": {
          "type": "string",
          "description": "One sentence for the person, in English; an assistant repeats it in their language."
        },
        "tool": {
          "type": [
            "string",
            "null"
          ],
          "description": "The operation that does it, named as the MCP tool; null when only the dashboard can."
        },
        "where": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "dashboard",
            null
          ]
        }
      }
    },
    "SetupStep": {
      "type": "object",
      "required": [
        "key",
        "status",
        "detail",
        "tool",
        "where"
      ],
      "properties": {
        "key": {
          "type": "string",
          "enum": [
            "instructions",
            "knowledge",
            "test",
            "channel",
            "live",
            "lead_capture",
            "attachments",
            "custom_api_tools"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "done",
            "next",
            "later"
          ],
          "description": "`next` marks the one step to take now (on the path only)."
        },
        "detail": {
          "type": "string",
          "description": "The step in a few words: what is there, or what is missing."
        },
        "tool": {
          "type": [
            "string",
            "null"
          ],
          "description": "The operation that does this step, named as the MCP tool (the operationId in snake_case). Null when only the dashboard can."
        },
        "where": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "dashboard",
            null
          ],
          "description": "`dashboard` when the step is done there, not through the API."
        }
      }
    }
  }
}