{
  "name": "Assistant",
  "label": "Assistant",
  "description": "Assistant table for storing AI assistant configurations and metadata",
  "tags": ["agent", "system"],
  "builtin": true,
  "readonly": true,
  "sort": 9999,
  "table": { "name": "agent_assistant", "comment": "Agent assistant table" },
  "columns": [
    {
      "name": "id",
      "type": "ID",
      "label": "Assistant ID",
      "comment": "Unique assistant identifier"
    },
    {
      "name": "assistant_id",
      "type": "string",
      "label": "Assistant ID",
      "comment": "Assistant identifier",
      "length": 200,
      "nullable": false,
      "unique": true,
      "index": true
    },
    {
      "name": "type",
      "type": "string",
      "label": "Type",
      "comment": "Assistant type",
      "length": 200,
      "default": "assistant",
      "index": true
    },
    {
      "name": "name",
      "type": "string",
      "label": "Name",
      "comment": "Assistant name",
      "length": 200,
      "nullable": true
    },
    {
      "name": "avatar",
      "type": "string",
      "label": "Avatar",
      "comment": "Assistant avatar URL",
      "length": 200,
      "nullable": true
    },
    {
      "name": "connector",
      "type": "string",
      "label": "Connector",
      "comment": "Assistant default connector, if not set, use the global default connector",
      "length": 200,
      "nullable": false
    },
    {
      "name": "connector_options",
      "type": "json",
      "label": "Connector Options",
      "comment": "Connector selection options: optional flag, available connectors list, and capability filters",
      "nullable": true
    },
    {
      "name": "description",
      "type": "string",
      "label": "Description",
      "comment": "Assistant description",
      "length": 600,
      "nullable": true,
      "index": true
    },
    {
      "name": "capabilities",
      "type": "string",
      "label": "Capabilities",
      "comment": "Assistant capabilities description, useful for Robot orchestration",
      "length": 600,
      "nullable": true,
      "index": true
    },
    {
      "name": "path",
      "type": "string",
      "label": "Path",
      "comment": "Assistant storage path",
      "length": 200,
      "nullable": true
    },
    {
      "name": "sort",
      "type": "integer",
      "label": "Sort",
      "comment": "Assistant sort order",
      "default": 9999,
      "index": true
    },
    {
      "name": "built_in",
      "type": "boolean",
      "label": "Built In",
      "comment": "Whether this is a built-in assistant",
      "default": false,
      "index": true
    },
    {
      "name": "placeholder",
      "type": "json",
      "label": "Placeholder",
      "comment": "Assistant placeholder",
      "nullable": true
    },
    {
      "name": "options",
      "type": "json",
      "label": "Options",
      "comment": "Assistant options",
      "nullable": true
    },
    {
      "name": "prompts",
      "type": "json",
      "label": "Prompts",
      "comment": "Assistant default prompts",
      "nullable": true
    },
    {
      "name": "prompt_presets",
      "type": "json",
      "label": "Prompt Presets",
      "comment": "Prompt presets organized by mode (e.g., chat, task, etc.)",
      "nullable": true
    },
    {
      "name": "disable_global_prompts",
      "type": "boolean",
      "label": "Disable Global Prompts",
      "comment": "Whether to disable global prompts for this assistant",
      "default": false,
      "index": true
    },
    {
      "name": "workflow",
      "type": "json",
      "label": "Workflow",
      "comment": "Assistant workflow",
      "nullable": true
    },
    {
      "name": "kb",
      "type": "json",
      "label": "Knowledge Base",
      "comment": "Assistant knowledge base collections",
      "nullable": true
    },
    {
      "name": "db",
      "type": "json",
      "label": "Database",
      "comment": "Assistant database models",
      "nullable": true
    },
    {
      "name": "mcp",
      "type": "json",
      "label": "MCP Servers",
      "comment": "MCP servers available for the assistant to use",
      "nullable": true
    },
    {
      "name": "sandbox",
      "type": "json",
      "label": "Sandbox",
      "comment": "Sandbox configuration for coding agents (command, image, timeout, etc.)",
      "nullable": true
    },
    {
      "name": "source",
      "type": "text",
      "label": "Source",
      "comment": "Hook script source code",
      "nullable": true
    },
    {
      "name": "tags",
      "type": "json",
      "label": "Tags",
      "comment": "Assistant tags",
      "nullable": true
    },
    {
      "name": "modes",
      "type": "json",
      "label": "Modes",
      "comment": "Supported modes (e.g., chat, task), null means all modes are supported",
      "nullable": true
    },
    {
      "name": "default_mode",
      "type": "string",
      "label": "Default Mode",
      "comment": "Default mode for the assistant",
      "length": 50,
      "nullable": true
    },
    {
      "name": "readonly",
      "type": "boolean",
      "label": "Readonly",
      "comment": "Assistant readonly status",
      "default": false,
      "index": true
    },

    {
      "name": "public",
      "type": "boolean",
      "label": "Public Assistant",
      "comment": "Whether this assistant is shared across all teams in the platform",
      "default": false,
      "nullable": false
    },
    {
      "name": "share",
      "type": "enum",
      "label": "Share",
      "comment": "Assistant sharing scope",
      "option": [
        "private", // Only visible to the owner
        "team" // Visible to all team members
      ],
      "default": "private",
      "nullable": false,
      "index": true
    },

    {
      "name": "locales",
      "type": "json",
      "label": "Locales",
      "comment": "Assistant i18n locales",
      "nullable": true
    },
    {
      "name": "uses",
      "type": "json",
      "label": "Uses",
      "comment": "Assistant-specific wrapper configurations for vision, audio, etc. If not set, use global settings",
      "nullable": true
    },
    {
      "name": "search",
      "type": "json",
      "label": "Search",
      "comment": "Search configuration (web, kb, db, citation, weights, etc.)",
      "nullable": true
    },
    {
      "name": "dependencies",
      "type": "json",
      "label": "Dependencies",
      "comment": "Dependencies on other MCP Clients (name -> version constraint)",
      "nullable": true
    },
    {
      "name": "automated",
      "type": "boolean",
      "label": "Automated",
      "comment": "Assistant automated status",
      "default": true,
      "index": true
    },
    {
      "name": "mentionable",
      "type": "boolean",
      "label": "Mentionable",
      "comment": "Whether this assistant can appear in @ mention list",
      "default": true,
      "index": true
    }
  ],
  "relations": {
    "chats": {
      "type": "hasMany",
      "model": "__yao.agent.chat",
      "key": "assistant_id",
      "foreign": "assistant_id"
    }
  },
  "indexes": [
    {
      "name": "idx_agent_assistant_type_builtin",
      "columns": ["type", "built_in"],
      "type": "index",
      "comment": "Index for assistant type and built-in status"
    },
    {
      "name": "idx_agent_assistant_sort",
      "columns": ["sort", "automated"],
      "type": "index",
      "comment": "Index for assistant sorting and automation"
    }
  ],
  "option": { "timestamps": true, "soft_deletes": false, "permission": true }
}
