{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "artifact": {
      "description": "Something the chat made, kept with it in versions: an app (a frame app not yet published, or published from the chat), or a view (a tile the model named).",
      "properties": {
        "key": {
          "description": "The model's name for it, unique in the chat: 1 to 40 of a-z, 0-9 and -.",
          "maxLength": 40,
          "minLength": 1,
          "type": "string"
        },
        "kind": {
          "knownValues": [
            "app",
            "view"
          ],
          "maxLength": 32,
          "type": "string"
        },
        "latest": {
          "description": "Its newest version.",
          "minimum": 1,
          "type": "integer"
        },
        "name": {
          "description": "An app's name, a view's title, as its latest version has it.",
          "maxGraphemes": 200,
          "maxLength": 2000,
          "type": "string"
        },
        "published": {
          "ref": "#published",
          "type": "ref"
        },
        "versions": {
          "description": "The versions kept, oldest first: at most 10, the oldest dropped first, never a published one.",
          "items": {
            "ref": "#artifactVersion",
            "type": "ref"
          },
          "type": "array"
        }
      },
      "required": [
        "key",
        "kind",
        "name",
        "latest",
        "versions"
      ],
      "type": "object"
    },
    "artifactEvent": {
      "description": "The answer made a version of an artifact (made, with the artifact as it is now), or tried to and was refused (made with problems).",
      "properties": {
        "artifact": {
          "ref": "#artifact",
          "type": "ref"
        },
        "made": {
          "ref": "#artifactRef",
          "type": "ref"
        },
        "turn": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "turn",
        "made"
      ],
      "type": "object"
    },
    "artifactRef": {
      "description": "A version of an artifact a turn made, or a version it tried to make and was refused: its problems, and no version.",
      "properties": {
        "key": {
          "maxLength": 40,
          "minLength": 1,
          "type": "string"
        },
        "problems": {
          "description": "Why the version was refused, each problem in a line.",
          "items": {
            "ref": "#problem",
            "type": "ref"
          },
          "maxLength": 50,
          "type": "array"
        },
        "version": {
          "description": "The version made.",
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "key"
      ],
      "type": "object"
    },
    "artifactVersion": {
      "description": "A version of an artifact. An app's document is read with get_app_source, and drawn at /a/chat/<chat>/<key>/<version>; a view's is its tile.",
      "properties": {
        "createdAt": {
          "format": "datetime",
          "type": "string"
        },
        "edits": {
          "description": "With how edits, how many.",
          "minimum": 1,
          "type": "integer"
        },
        "how": {
          "description": "whole: given whole; edits: the version before it, changed by edits.",
          "knownValues": [
            "whole",
            "edits"
          ],
          "maxLength": 32,
          "type": "string"
        },
        "name": {
          "description": "An app's name.",
          "maxGraphemes": 64,
          "maxLength": 640,
          "type": "string"
        },
        "origins": {
          "description": "The origins an app loads pictures and audio from; left out where it names none.",
          "items": {
            "ref": "place.hud.app#origin",
            "type": "ref"
          },
          "maxLength": 8,
          "type": "array"
        },
        "reads": {
          "description": "The public collections an app reads beyond its entries; left out where it names none.",
          "items": {
            "ref": "place.hud.app#collection",
            "type": "ref"
          },
          "maxLength": 16,
          "type": "array"
        },
        "summary": {
          "description": "An app's summary.",
          "maxGraphemes": 300,
          "maxLength": 3000,
          "type": "string"
        },
        "tile": {
          "description": "A view's tile.",
          "ref": "#tile",
          "type": "ref"
        },
        "turn": {
          "description": "The chat's turn that made it, where a turn did.",
          "minimum": 1,
          "type": "integer"
        },
        "version": {
          "minimum": 1,
          "type": "integer"
        },
        "writes": {
          "description": "The collections an app writes beyond its entries; left out where it names none.",
          "items": {
            "ref": "place.hud.app#collection",
            "type": "ref"
          },
          "maxLength": 8,
          "type": "array"
        }
      },
      "required": [
        "version",
        "createdAt",
        "how"
      ],
      "type": "object"
    },
    "chatSummary": {
      "description": "A chat, as the list of a person's chats shows it.",
      "properties": {
        "chat": {
          "description": "The chat's id: 12 hex digits.",
          "maxLength": 12,
          "minLength": 12,
          "type": "string"
        },
        "title": {
          "description": "Its first message, cut short.",
          "maxGraphemes": 200,
          "maxLength": 2000,
          "type": "string"
        },
        "updatedAt": {
          "description": "When its last message was written.",
          "format": "datetime",
          "type": "string"
        }
      },
      "required": [
        "chat",
        "title",
        "updatedAt"
      ],
      "type": "object"
    },
    "chatView": {
      "description": "A chat whole: every message, oldest first.",
      "properties": {
        "artifacts": {
          "description": "What the chat made, apps and views, oldest first, each with its versions.",
          "items": {
            "ref": "#artifact",
            "type": "ref"
          },
          "type": "array"
        },
        "chat": {
          "maxLength": 12,
          "minLength": 12,
          "type": "string"
        },
        "messages": {
          "items": {
            "ref": "#message",
            "type": "ref"
          },
          "type": "array"
        },
        "running": {
          "description": "Whether the model is answering its last message now: its progress comes on getChatEvents.",
          "type": "boolean"
        },
        "storage": {
          "ref": "#storage",
          "type": "ref"
        },
        "title": {
          "maxGraphemes": 200,
          "maxLength": 2000,
          "type": "string"
        }
      },
      "required": [
        "chat",
        "title",
        "messages",
        "running"
      ],
      "type": "object"
    },
    "doneEvent": {
      "description": "The answer is done, or ended early (error): the chat holds it whole now.",
      "properties": {
        "error": {
          "maxLength": 2000,
          "type": "string"
        },
        "turn": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "turn"
      ],
      "type": "object"
    },
    "message": {
      "description": "A message: the person's, or the model's answer to the one before.",
      "properties": {
        "artifacts": {
          "description": "The versions of the chat's artifacts the model's answer made, or tried to make and was refused, in order: an app's drawn as a card in the conversation.",
          "items": {
            "ref": "#artifactRef",
            "type": "ref"
          },
          "type": "array"
        },
        "createdAt": {
          "format": "datetime",
          "type": "string"
        },
        "error": {
          "description": "Why the model's answer ended before it was done, in a line.",
          "maxLength": 2000,
          "type": "string"
        },
        "role": {
          "knownValues": [
            "person",
            "model"
          ],
          "maxLength": 32,
          "type": "string"
        },
        "steps": {
          "description": "The tool calls the model made for its answer, in order: none for a person's.",
          "items": {
            "ref": "#step",
            "type": "ref"
          },
          "type": "array"
        },
        "text": {
          "description": "What was written, as plain text with Markdown's emphasis, links and lists.",
          "maxLength": 10000,
          "type": "string"
        },
        "tiles": {
          "description": "What its answer draws, in order: none for a person's.",
          "items": {
            "ref": "#tile",
            "type": "ref"
          },
          "type": "array"
        },
        "turn": {
          "description": "The exchange it belongs to: a person's message and the answer after it share one.",
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "turn",
        "role",
        "text",
        "steps",
        "tiles"
      ],
      "type": "object"
    },
    "problem": {
      "description": "A problem with what the model gave, in a line.",
      "properties": {
        "message": {
          "maxLength": 2000,
          "type": "string"
        }
      },
      "required": [
        "message"
      ],
      "type": "object"
    },
    "published": {
      "description": "Where an app artifact was published from the chat (place.hud.publishChatArtifact): its place.hud.app record and its page.",
      "properties": {
        "cid": {
          "format": "cid",
          "type": "string"
        },
        "uri": {
          "format": "at-uri",
          "type": "string"
        },
        "url": {
          "description": "The app's page, /a/<handle>/<rkey> on this server.",
          "format": "uri",
          "type": "string"
        },
        "version": {
          "description": "The version published last.",
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "uri",
        "cid",
        "url",
        "version"
      ],
      "type": "object"
    },
    "step": {
      "description": "A tool call the model made.",
      "properties": {
        "arguments": {
          "description": "What it was called with, an object.",
          "type": "unknown"
        },
        "call": {
          "description": "The call's id, the same on each event about it.",
          "maxLength": 64,
          "type": "string"
        },
        "ms": {
          "description": "How long it took, once done or failed.",
          "minimum": 0,
          "type": "integer"
        },
        "status": {
          "knownValues": [
            "running",
            "done",
            "failed"
          ],
          "maxLength": 32,
          "type": "string"
        },
        "summary": {
          "description": "The tool's own short summary of its answer, or why it failed.",
          "maxLength": 2000,
          "type": "string"
        },
        "tool": {
          "description": "The tool, by its MCP name.",
          "maxLength": 64,
          "type": "string"
        }
      },
      "required": [
        "call",
        "tool",
        "status"
      ],
      "type": "object"
    },
    "stepEvent": {
      "description": "A step began, or ended: the step as it is now, replacing the one of its id.",
      "properties": {
        "step": {
          "ref": "#step",
          "type": "ref"
        },
        "turn": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "turn",
        "step"
      ],
      "type": "object"
    },
    "storage": {
      "description": "Where the chat is kept: in a space of the person's own on their PDS (space, its uri), or in this server's files (file, and why).",
      "properties": {
        "kind": {
          "knownValues": [
            "space",
            "file"
          ],
          "maxLength": 32,
          "type": "string"
        },
        "reason": {
          "description": "Why it is in this server's files, in a line.",
          "maxLength": 2000,
          "type": "string"
        },
        "uri": {
          "description": "The space, at:space/<did>/place.hud.chat/<chat>.",
          "maxLength": 2000,
          "type": "string"
        }
      },
      "required": [
        "kind"
      ],
      "type": "object"
    },
    "textEvent": {
      "description": "More of the model's answer's words, to add to what came before.",
      "properties": {
        "text": {
          "maxLength": 10000,
          "type": "string"
        },
        "turn": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "turn",
        "text"
      ],
      "type": "object"
    },
    "tile": {
      "description": "What an answer draws: a read tool and its arguments, as a canvas's tile names them. The page calls the tool (callTool) to draw it, so it always draws what is there now.",
      "properties": {
        "arguments": {
          "description": "The tool's arguments, an object; at most 64 KiB as JSON.",
          "type": "unknown"
        },
        "artifact": {
          "description": "The key of the view artifact it is a version of, where the model named one: drawing the same key again is its next version.",
          "maxLength": 40,
          "type": "string"
        },
        "step": {
          "description": "The call of the step that drew it.",
          "maxLength": 64,
          "type": "string"
        },
        "title": {
          "description": "What the model calls what it draws.",
          "maxGraphemes": 200,
          "maxLength": 2000,
          "type": "string"
        },
        "tool": {
          "knownValues": [
            "describe_repo",
            "describe_app",
            "list_records",
            "get_record",
            "query",
            "open_app"
          ],
          "maxLength": 64,
          "type": "string"
        }
      },
      "required": [
        "step",
        "tool",
        "arguments"
      ],
      "type": "object"
    },
    "tileEvent": {
      "description": "The answer draws another tile.",
      "properties": {
        "tile": {
          "ref": "#tile",
          "type": "ref"
        },
        "turn": {
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "turn",
        "tile"
      ],
      "type": "object"
    }
  },
  "description": "What the chat's methods and its event stream hold: a chat, its messages, the steps a model took and the tiles it drew.",
  "id": "place.hud.chatDefs",
  "lexicon": 1
}
