{
  "name": "Chat",
  "label": "Chat",
  "description": "Chat table for storing chat metadata and information",
  "tags": ["agent", "system"],
  "builtin": true,
  "readonly": true,
  "sort": 9999,
  "table": { "name": "agent_chat", "comment": "Agent chat table" },
  "columns": [
    {
      "name": "id",
      "type": "ID",
      "label": "Chat ID",
      "comment": "Unique chat identifier"
    },
    {
      "name": "chat_id",
      "type": "string",
      "label": "Chat ID",
      "comment": "Chat identifier",
      "length": 200,
      "nullable": false,
      "unique": true,
      "index": true
    },
    {
      "name": "title",
      "type": "string",
      "label": "Title",
      "comment": "Chat title",
      "length": 200,
      "nullable": true
    },
    {
      "name": "assistant_id",
      "type": "string",
      "label": "Assistant ID",
      "comment": "Assistant identifier",
      "length": 200,
      "nullable": true,
      "index": true
    },
    {
      "name": "silent",
      "type": "boolean",
      "label": "Silent Mode",
      "comment": "Whether this is a silent chat",
      "default": false,
      "index": true
    }
  ],
  "relations": {
    "assistant": {
      "type": "hasOne",
      "model": "__yao.agent.assistant",
      "key": "assistant_id",
      "foreign": "assistant_id"
    },
    "history": {
      "type": "hasMany",
      "model": "__yao.agent.history",
      "key": "chat_id",
      "foreign": "cid"
    }
  },
  "indexes": [
    {
      "name": "idx_agent_chat_silent",
      "columns": ["silent", "created_at"],
      "type": "index",
      "comment": "Index for silent mode filtering"
    }
  ],
  "option": { "timestamps": true, "soft_deletes": false, "permission": true }
}
