{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "v": {
      "type": "number",
      "const": 1,
      "description": "Protocol major version."
    },
    "type": {
      "type": "string",
      "const": "agent.updated"
    },
    "id": {
      "type": "string",
      "pattern": "^evt_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
      "description": "The event's own id. Stable across a retry of the same event."
    },
    "ts": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
      "description": "When it happened, by Chips' clock. Stamped on the way in; a value the sender writes is replaced."
    },
    "workspace_id": {
      "type": "string",
      "pattern": "^ws_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
      "description": "A workspace identifier: `ws_` followed by a ULID."
    },
    "space_id": {
      "description": "The space, when the event belongs to one.",
      "type": "string",
      "pattern": "^spc_[0-7][0-9A-HJKMNP-TV-Z]{25}$"
    },
    "run_id": {
      "description": "The run, when the event belongs to one.",
      "type": "string",
      "pattern": "^run_[0-7][0-9A-HJKMNP-TV-Z]{25}$"
    },
    "seq": {
      "description": "Assigned by the server on append, monotonic per workspace. Absent on the way in.",
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "idempotency_key": {
      "description": "Required on every client-originated write. Sending the same key twice is a no-op.",
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "actor": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "person",
            "harness",
            "agent",
            "system"
          ],
          "description": "Whether a person, a harness, one of a harness's agents or Chips itself acted."
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "The participant id, or `system` for Chips."
        },
        "harness_id": {
          "description": "For an agent: the harness it speaks through, whose budget and runs are the agent's (ADR 0087). Filled in by Chips.",
          "type": "string",
          "pattern": "^hrn_[0-7][0-9A-HJKMNP-TV-Z]{25}$"
        }
      },
      "required": [
        "kind",
        "id"
      ],
      "description": "The participant an event is attributed to."
    },
    "agent_id": {
      "type": "string",
      "pattern": "^agt_[0-7][0-9A-HJKMNP-TV-Z]{25}$",
      "description": "The agent."
    },
    "name": {
      "description": "What it is called from here: nobody else's in the workspace, case and spaces aside, so it may be numbered, `Scout 2` (ADR 0091). With a person as the actor, a person named it, and its harness no longer renames it.",
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "state": {
      "description": "`archived` when the thing it is was put away in its harness (ADR 0087, rule 9), or a person archived it (ADR 0095); `active` when it came back. With a person as the actor, its harness archives or restores its side.",
      "type": "string",
      "enum": [
        "active",
        "archived"
      ]
    },
    "face": {
      "description": "The face a person chose for it (ADR 0089): a mark from Chips' library and the index of the ground it sits on, one for everybody in the workspace. `null` when the choice was taken back and it wears its initials again. Written by Chips for a person; a harness does not send it.",
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "icon": {
              "type": "string",
              "maxLength": 40,
              "pattern": "^[a-zA-Z]*$"
            },
            "ground": {
              "type": "integer",
              "minimum": 0,
              "maximum": 26
            },
            "letters": {
              "description": "One or two letters, or an emoji or two, the face wears on its ground in place of a mark (ADR 0139); the mark is empty beside them. Absent on a face that is a mark, or only a colour.",
              "type": "string",
              "minLength": 1,
              "maxLength": 32
            }
          },
          "required": [
            "icon",
            "ground"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "lead": {
      "description": "Whether it is its harness's Main agent from here (ADR 0183): `true` when the harness registered it as Main, `false` when its default agent took Main from it. A harness has one at most.",
      "type": "boolean"
    }
  },
  "required": [
    "v",
    "type",
    "id",
    "ts",
    "workspace_id",
    "actor",
    "agent_id"
  ],
  "description": "An agent was renamed, archived or brought back in its harness, made or no longer its harness's Main agent, or renamed or given a face by a person. What it said stays its, under the new name and face.",
  "$id": "https://chipschat.ai/schema/v1/agent.updated.json",
  "title": "AgentUpdated"
}
