{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/percia-ai/json-schema/percia-ai-agent-schema.json",
  "title": "Agent",
  "x-generated": "2026-11-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/percia-ai-openapi.yml#/components/schemas/Agent",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "publishedVersion": {
      "type": [
        "integer",
        "null"
      ]
    },
    "draftChanged": {
      "type": "boolean",
      "description": "True before the first publish, or when the draft differs from the published config."
    },
    "deploymentCount": {
      "type": "integer"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "draft": {
      "$ref": "#/$defs/AgentConfig"
    },
    "published": {
      "type": [
        "object",
        "null"
      ],
      "description": "Config of the latest published version, null before the first publish.",
      "properties": {
        "concerns": {
          "type": "array",
          "minItems": 1,
          "maxItems": 10,
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Slug, at most 32 characters, unique within the agent."
              },
              "text": {
                "type": "string",
                "description": "5 to 500 characters."
              },
              "kind": {
                "enum": [
                  "event",
                  "state"
                ]
              },
              "zones": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "excludeZones": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "ignore": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "minConfidence": {
                "type": "number",
                "minimum": 0.5,
                "maximum": 0.95
              },
              "rearmS": {
                "type": "integer",
                "minimum": 10,
                "maximum": 3600
              },
              "recheckS": {
                "type": "integer",
                "minimum": 5,
                "maximum": 600
              },
              "cooldownS": {
                "type": "integer",
                "minimum": 0,
                "maximum": 86400
              }
            },
            "required": [
              "id",
              "text",
              "kind"
            ]
          }
        },
        "budget": {
          "type": "object",
          "properties": {
            "maxRequestsPerMin": {
              "type": "integer",
              "minimum": 1,
              "maximum": 30,
              "default": 6
            }
          }
        },
        "outputs": {
          "type": "array",
          "maxItems": 10,
          "description": "Typed values read from the event's keyframe by a language model and stored on the event as `outputs`.",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "Identifier, at most 32 characters."
              },
              "type": {
                "enum": [
                  "string",
                  "number",
                  "boolean",
                  "enum"
                ]
              },
              "description": {
                "type": "string"
              },
              "options": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Required for enum, 2 to 20 values."
              }
            },
            "required": [
              "name",
              "type",
              "description"
            ]
          }
        },
        "actions": {
          "type": "array",
          "maxItems": 5,
          "description": "MCP tool calls made after an event is stored. String values in `arguments` may use {{event.reason}}, {{event.concern}}, {{event.at}}, {{event.confidence}}, {{watch.name}}, {{site.name}} and {{outputs.<name>}}. A secret header is written with `value` and read back as `hasSecret`.",
          "items": {
            "type": "object",
            "properties": {
              "on": {
                "type": "string",
                "description": "\"*\" or a concern id."
              },
              "type": {
                "enum": [
                  "mcp"
                ]
              },
              "serverUrl": {
                "type": "string",
                "description": "Public https URL of a streamable-HTTP MCP server."
              },
              "tool": {
                "type": "string"
              },
              "arguments": {
                "type": "object"
              },
              "secretHeader": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string",
                    "description": "Write only."
                  },
                  "hasSecret": {
                    "type": "boolean",
                    "description": "Read only."
                  }
                },
                "required": [
                  "name"
                ]
              }
            },
            "required": [
              "on",
              "type",
              "serverUrl",
              "tool"
            ]
          }
        }
      },
      "required": [
        "concerns"
      ]
    },
    "versions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "version": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    }
  },
  "$defs": {
    "AgentConfig": {
      "type": "object",
      "description": "Up to 10 concerns plus a request budget. A zone is a polygon of 3 to 12 [x, y] points, each 0..1 (fractions of the frame).",
      "properties": {
        "concerns": {
          "type": "array",
          "minItems": 1,
          "maxItems": 10,
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Slug, at most 32 characters, unique within the agent."
              },
              "text": {
                "type": "string",
                "description": "5 to 500 characters."
              },
              "kind": {
                "enum": [
                  "event",
                  "state"
                ]
              },
              "zones": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "excludeZones": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              "ignore": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "minConfidence": {
                "type": "number",
                "minimum": 0.5,
                "maximum": 0.95
              },
              "rearmS": {
                "type": "integer",
                "minimum": 10,
                "maximum": 3600
              },
              "recheckS": {
                "type": "integer",
                "minimum": 5,
                "maximum": 600
              },
              "cooldownS": {
                "type": "integer",
                "minimum": 0,
                "maximum": 86400
              }
            },
            "required": [
              "id",
              "text",
              "kind"
            ]
          }
        },
        "budget": {
          "type": "object",
          "properties": {
            "maxRequestsPerMin": {
              "type": "integer",
              "minimum": 1,
              "maximum": 30,
              "default": 6
            }
          }
        },
        "outputs": {
          "type": "array",
          "maxItems": 10,
          "description": "Typed values read from the event's keyframe by a language model and stored on the event as `outputs`.",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "Identifier, at most 32 characters."
              },
              "type": {
                "enum": [
                  "string",
                  "number",
                  "boolean",
                  "enum"
                ]
              },
              "description": {
                "type": "string"
              },
              "options": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Required for enum, 2 to 20 values."
              }
            },
            "required": [
              "name",
              "type",
              "description"
            ]
          }
        },
        "actions": {
          "type": "array",
          "maxItems": 5,
          "description": "MCP tool calls made after an event is stored. String values in `arguments` may use {{event.reason}}, {{event.concern}}, {{event.at}}, {{event.confidence}}, {{watch.name}}, {{site.name}} and {{outputs.<name>}}. A secret header is written with `value` and read back as `hasSecret`.",
          "items": {
            "type": "object",
            "properties": {
              "on": {
                "type": "string",
                "description": "\"*\" or a concern id."
              },
              "type": {
                "enum": [
                  "mcp"
                ]
              },
              "serverUrl": {
                "type": "string",
                "description": "Public https URL of a streamable-HTTP MCP server."
              },
              "tool": {
                "type": "string"
              },
              "arguments": {
                "type": "object"
              },
              "secretHeader": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "value": {
                    "type": "string",
                    "description": "Write only."
                  },
                  "hasSecret": {
                    "type": "boolean",
                    "description": "Read only."
                  }
                },
                "required": [
                  "name"
                ]
              }
            },
            "required": [
              "on",
              "type",
              "serverUrl",
              "tool"
            ]
          }
        }
      },
      "required": [
        "concerns"
      ]
    }
  }
}