Cotton code
1428 lines · 34.9 KB · JSONRaw
{  "format_version": 1,  "id": "session",  "list_route": "/code",  "scope": "personal",  "setup": true,  "name": "Session",  "plural": "Sessions",  "record_route": "/sessions/[id]",  "picture": {"photo": "photo:2cac6e32a9504d6cb1dbe03334e4a29f9b9e865ba6c8d67ebe83d6e8c670e353", "object": "tool-code"},  "builtin": true,  "engine": "sessions",  "screen_family": "sessions",  "columns": [    {      "key": "title",      "type": "text",      "name": "Name"    },    {      "key": "project_id",      "name": "Project",      "type": "link",      "link_to": "project"    },    {      "key": "tool",      "name": "Agent",      "type": "choice",      "choices": [        "claude-code",        "codex",        "kimi",        "gemini",        "opencode",        "other"      ],      "readonly": true    },    {      "key": "state",      "type": "choice",      "choices": [        "queued",        "starting",        "running",        "idle",        "waiting",        "ended",        "failed",        "withdrawn"      ],      "readonly": true    },    {      "key": "waiting_kind",      "name": "Waiting for",      "type": "choice",      "choices": [        "permission",        "question",        "input"      ],      "readonly": true    },    {      "key": "machine",      "type": "text",      "readonly": true    },    {      "key": "account",      "type": "text",      "readonly": true    },    {      "key": "repo_url",      "name": "Repository",      "type": "text",      "readonly": true    },    {      "key": "branch",      "type": "text",      "readonly": true    },    {      "key": "cwd",      "name": "Folder",      "type": "text",      "readonly": true    },    {      "key": "started_at",      "name": "Started",      "type": "date",      "readonly": true    },    {      "key": "last_active_at",      "name": "Last active",      "type": "date",      "readonly": true    },    {      "key": "ended_at",      "name": "Ended",      "type": "date",      "readonly": true    },    {      "key": "summary",      "type": "longtext",      "readonly": true    },    {      "key": "model",      "type": "text",      "readonly": true    },    {      "key": "last_line",      "name": "Last line",      "type": "text",      "readonly": true    },    {      "key": "prompt",      "name": "Task",      "type": "longtext",      "readonly": true    },    {      "key": "hold_reason",      "name": "Held because",      "type": "text",      "readonly": true    },    {      "key": "error",      "type": "text",      "readonly": true    },    {      "key": "exit_code",      "name": "Exit code",      "type": "number",      "readonly": true    },    {      "key": "turn_count",      "name": "Turns",      "type": "number",      "readonly": true    },    {      "key": "prompt_count",      "name": "Prompts",      "type": "number",      "readonly": true    },    {      "key": "todo_id",      "name": "Todo",      "type": "link",      "link_to": "todo",      "readonly": true    },    {      "key": "parent_session_id",      "name": "Started from",      "type": "link",      "link_to": "session",      "readonly": true    },    {      "key": "permission_mode",      "name": "Permissions",      "type": "choice",      "choices": [        "bypass",        "ask"      ],      "readonly": true    },    {      "key": "host_owned",      "name": "Runs in a terminal here",      "type": "bool",      "readonly": true    },    {      "key": "kind",      "type": "choice",      "choices": [        "conversation",        "thread"      ],      "readonly": true    },    {      "key": "heading",      "name": "Heading",      "type": "text",      "readonly": true    },    {      "key": "section",      "name": "Section",      "type": "choice",      "choices": [        "needs_you",        "running",        "quiet",        "from_terminal",        "ended"      ],      "readonly": true    },    {      "key": "project_slug",      "name": "Project slug",      "type": "text",      "readonly": true    },    {      "key": "line",      "name": "Now",      "type": "text",      "readonly": true    },    {      "key": "facts",      "name": "Facts",      "type": "text",      "readonly": true    },    {      "key": "state_line",      "name": "State",      "type": "text",      "readonly": true    },    {      "key": "notice",      "name": "Notice",      "type": "text",      "readonly": true    },    {      "key": "pending_decision",      "name": "Answered",      "type": "text",      "readonly": true    },    {      "key": "answering",      "name": "Answering",      "type": "text",      "readonly": true    },    {      "key": "open_questions",      "name": "Open questions",      "type": "longtext",      "readonly": true    },    {      "key": "can_resume",      "name": "Can resume",      "type": "bool",      "readonly": true    },    {      "key": "tasks",      "type": "longtext",      "readonly": true,      "name": "Task list"    },    {      "key": "tasks_count",      "name": "Tasks",      "type": "text",      "readonly": true    },    {      "key": "shipped",      "type": "longtext",      "readonly": true    },    {      "key": "transcript_ref",      "name": "Transcript",      "type": "text",      "readonly": true    },    {      "key": "active_at",      "name": "Active",      "type": "date",      "readonly": true    }  ],  "title": "heading",  "date": "active_at",  "project": "project_id",  "order": null,  "slip": {    "title": "heading",    "subtitle": "line",    "trailing": "active_at",    "caption": {      "columns": [        "facts"      ],      "dates": [        "active_at"      ]    },    "photo": null,    "toggle": null  },  "tile": {    "face": "slip-list"  },  "lists": [    {      "heading": "Repositories",      "above": true,      "list": {        "table": "repository",        "empty": "No repositories yet. A repository appears here once a project names it and the Mac that serves you has read it.",        "limit": 3      }    }  ],  "links": [    {      "label": "Machines",      "table": "agent_login",      "above": true    },    {      "label": "Runners",      "table": "code_runner",      "above": true    },    {      "label": "Credentials",      "table": "code_credential",      "above": true    }  ],  "menu": [    {      "label": "Session defaults",      "path": "/code/defaults"    }  ],  "page": [    {      "heading": null,      "columns": [        "title",        "state",        "waiting_kind",        "machine",        "tool",        "account",        "project_id"      ]    },    {      "heading": "Tasks",      "columns": [        "tasks_count",        "tasks"      ]    },    {      "heading": "Task",      "columns": [        "prompt",        "hold_reason",        "error",        "last_line"      ]    },    {      "heading": "Changes",      "columns": [        "branch",        "cwd",        "repo_url",        "shipped"      ]    },    {      "heading": "Summary",      "columns": [        "summary"      ]    },    {      "heading": "Details",      "columns": [        "model",        "permission_mode",        "host_owned",        "started_at",        "ended_at",        "turn_count",        "prompt_count",        "exit_code",        "todo_id",        "parent_session_id",        "kind",        "transcript_ref"      ]    }  ],  "instructions": "A session is one coding agent session, such as Claude Code or Codex, running on one of the owner's Macs and logged into a project. State says whether it is queued, running, waiting on the owner, idle or ended. A session found in an agent's transcript rather than started here has no terminal, so it cannot be stopped or given permission from here.",  "add": false,  "page_parts": ["title", "facts", "messages"],  "group": {    "column": "section",    "sections": [      {        "heading": "Needs you",        "values": [          "needs_you"        ]      },      {        "heading": "Running",        "values": [          "running"        ]      },      {        "heading": "Quiet",        "values": [          "quiet"        ]      },      {        "heading": "From the terminal",        "values": [          "from_terminal"        ],        "closed": true      },      {        "heading": "Ended",        "values": [          "ended"        ],        "closed": true      }    ]  },  "listed_when": "section",  "empty": {    "title": "Nothing running.",    "message": "Start a session and describe what an agent should do on one of your Macs."  },  "sort": {    "column": "active_at",    "descending": true  },  "conversation": {    "table": "session_message",    "links": [      "to_session_id",      "from_session_id",      "claimed_by_session_id"    ],    "body": "body",    "at": "created_at",    "mine": {      "column": "from_kind",      "values": [        "owner"      ]    },    "footer": [      "delivery",      "delivered_on"    ],    "media": "media",    "ended": "ended_at",    "started": {      "at": "started_at",      "words": [        "machine",        "account"      ]    },    "header": [      "pending_decision",      "answering",      "state_line",      "last_line",      "facts",      "notice",      "tasks_count"    ],    "placeholder": "Send an instruction — a session that isn't listening picks it up on its next poll",    "sends": {      "kind": "instruction",      "to_kind": "session",      "from_kind": "owner"    },    "also": [      {        "table": "prompt",        "links": [          "session_id"        ],        "body": "text",        "at": "ts",        "mine": {          "column": "role",          "values": [            "user"          ]        }      }    ]  },  "parts": {    "shape": "desk",    "head": {      "facts": [        "title",        "tool"      ]    },    "links": [      "project_id",      "todo_id",      "parent_session_id"    ],    "body": "summary",    "lists": [],    "acts": {      "more": []    },    "strip": [      {"column": "state"},      {"column": "project_id"},      {"column": "machine"},      {"column": "branch"},      {"column": "model"},      {"column": "todo_id"},      {"column": "hold_reason"},      {"column": "error"}    ]  },  "delete": false,  "tool": {    "name": "Code",    "key": "code",    "card_stock": "cream",    "icon": "code",    "route": "/code",    "figures": [      {        "read": "runningSessions",        "many": "{n} running"      },      {        "read": "waitingSessions",        "many": "{n} waiting"      }    ],    "tables": [      "session",      "repository",      "commit",      "repo_file",      "repo_label",      "repo_rule",      "repo_var",      "code_default"    ]  ,"purpose":"Repositories, changes and coding sessions."},  "tables": [    {      "name": "cotton_sessions",      "columns": [        {          "name": "id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": true,          "declaration": "\n    id TEXT PRIMARY KEY",          "position": 0        },        {          "name": "workspace_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    workspace_id TEXT NOT NULL",          "position": 1        },        {          "name": "project_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    project_id TEXT",          "position": 2        },        {          "name": "tool",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    tool TEXT NOT NULL",          "position": 3        },        {          "name": "external_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    external_id TEXT",          "position": 4        },        {          "name": "machine",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    machine TEXT",          "position": 5        },        {          "name": "repo_url",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    repo_url TEXT",          "position": 6        },        {          "name": "branch",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    branch TEXT",          "position": 7        },        {          "name": "cwd",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    cwd TEXT",          "position": 8        },        {          "name": "started_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    started_at TEXT",          "position": 9        },        {          "name": "last_active_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    last_active_at TEXT NOT NULL",          "position": 10        },        {          "name": "ended_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    ended_at TEXT",          "position": 11        },        {          "name": "summary",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    summary TEXT",          "position": 12        },        {          "name": "title",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    title TEXT",          "position": 13        },        {          "name": "shipped",          "type": "TEXT",          "default": "'[]'",          "nullable": false,          "primary_key": false,          "declaration": "\n    shipped TEXT NOT NULL DEFAULT '[]'",          "position": 14        },        {          "name": "turn_count",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    turn_count INTEGER NOT NULL DEFAULT 0",          "position": 15        },        {          "name": "prompt_count",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    prompt_count INTEGER NOT NULL DEFAULT 0",          "position": 16        },        {          "name": "transcript_ref",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    transcript_ref TEXT",          "position": 17        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 18        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 19        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 20        },        {          "name": "account",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " account TEXT",          "position": 21        },        {          "name": "listened_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " listened_at TEXT",          "position": 22        },        {          "name": "model",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " model TEXT",          "position": 23        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 24        },        {          "name": "device_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    device_id TEXT",          "position": 25        },        {          "name": "state",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    state TEXT CHECK (state IS NULL OR state IN ('queued', 'starting', 'running', 'idle', 'waiting', 'ended', 'failed', 'withdrawn'))",          "position": 26        },        {          "name": "state_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    state_at TEXT",          "position": 27        },        {          "name": "waiting_kind",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    waiting_kind TEXT CHECK (waiting_kind IS NULL OR waiting_kind IN ('permission', 'question', 'input'))",          "position": 28        },        {          "name": "waiting_ref",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    waiting_ref TEXT",          "position": 29        },        {          "name": "last_line",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    last_line TEXT CHECK (last_line IS NULL OR length(last_line) <= 280)",          "position": 30        },        {          "name": "exit_code",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    exit_code INTEGER",          "position": 31        },        {          "name": "permission_mode",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    permission_mode TEXT CHECK (permission_mode IS NULL OR permission_mode IN ('bypass', 'ask'))",          "position": 32        },        {          "name": "host_owned",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    host_owned INTEGER NOT NULL DEFAULT 0 CHECK (host_owned IN (0, 1))",          "position": 33        },        {          "name": "todo_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    todo_id TEXT",          "position": 34        },        {          "name": "requested_device_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    requested_device_id TEXT",          "position": 35        },        {          "name": "chosen_by",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    chosen_by TEXT CHECK (chosen_by IS NULL OR chosen_by IN ('owner', 'dispatcher'))",          "position": 36        },        {          "name": "prompt",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    prompt TEXT NOT NULL DEFAULT ''",          "position": 37        },        {          "name": "hold_reason",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    hold_reason TEXT CHECK (hold_reason IS NULL OR length(hold_reason) <= 200)",          "position": 38        },        {          "name": "claimed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    claimed_at TEXT",          "position": 39        },        {          "name": "report_message_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    report_message_id TEXT",          "position": 40        },        {          "name": "error",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    error TEXT",          "position": 41        },        {          "name": "kind",          "type": "TEXT",          "default": "'thread'",          "nullable": false,          "primary_key": false,          "declaration": "\n    kind TEXT NOT NULL DEFAULT 'thread' CHECK (kind IN ('conversation', 'thread'))",          "position": 42        },        {          "name": "parent_session_id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    parent_session_id TEXT",          "position": 43        },        {          "name": "todo_database",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    todo_database TEXT CHECK (todo_database IS NULL OR length(todo_database) > 0)",          "position": 44        },        {          "name": "trashed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": " trashed_at TEXT",          "position": 45        }      ],      "constraints": [        {          "declaration": "\n    UNIQUE (tool, external_id)",          "position": 46        },        {          "declaration": "\n    CHECK (tool IN ('claude-code', 'codex', 'kimi', 'gemini', 'opencode', 'other'))",          "position": 47        },        {          "declaration": "\n    CHECK (external_id IS NULL OR length(trim(external_id)) > 0)",          "position": 48        },        {          "declaration": "\n    CHECK (machine IS NULL OR length(trim(machine)) > 0)",          "position": 49        },        {          "declaration": "\n    CHECK ((summary IS NULL) OR (length(summary) <= 2000))",          "position": 50        },        {          "declaration": "\n    CHECK ((title IS NULL) OR (length(title) <= 140))",          "position": 51        },        {          "declaration": "\n    CHECK (json_type(shipped) = 'array')",          "position": 52        },        {          "declaration": "\n    CHECK (turn_count >= 0)",          "position": 53        },        {          "declaration": "\n    CHECK (prompt_count >= 0)",          "position": 54        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 55        }      ],      "prefix": "CREATE TABLE cotton_sessions (",      "suffix": ")",      "indexes": [        "CREATE INDEX idx_cotton_sessions_recent ON cotton_sessions (workspace_id, last_active_at DESC)",        "CREATE INDEX idx_cotton_sessions_project ON cotton_sessions (project_id, last_active_at DESC) WHERE project_id IS NOT NULL",        "CREATE INDEX idx_cotton_sessions_machine ON cotton_sessions (workspace_id, machine, last_active_at DESC)",        "CREATE INDEX idx_cotton_sessions_queue ON cotton_sessions (workspace_id, state, device_id)",        "CREATE INDEX IF NOT EXISTS idx_cotton_sessions_author ON cotton_sessions (substr(_hlc, 20), _hlc)",        "CREATE UNIQUE INDEX IF NOT EXISTS idx_cotton_sessions_conversation ON cotton_sessions (project_id) WHERE kind = 'conversation'",        "CREATE INDEX IF NOT EXISTS idx_cotton_sessions_parent ON cotton_sessions (parent_session_id, last_active_at DESC) WHERE parent_session_id IS NOT NULL"      ],      "full_text": [],      "triggers": []    },    {      "name": "cotton_session_tasks",      "columns": [        {          "name": "id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": true,          "declaration": "\n    id TEXT PRIMARY KEY",          "position": 0        },        {          "name": "workspace_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    workspace_id TEXT NOT NULL",          "position": 1        },        {          "name": "session_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    session_id TEXT NOT NULL",          "position": 2        },        {          "name": "seq",          "type": "INTEGER",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    seq INTEGER NOT NULL",          "position": 3        },        {          "name": "text",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    text TEXT NOT NULL",          "position": 4        },        {          "name": "state",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    state TEXT NOT NULL",          "position": 5        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 6        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 7        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 8        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 9        }      ],      "constraints": [        {          "declaration": "\n    UNIQUE (session_id, seq)",          "position": 10        },        {          "declaration": "\n    CHECK (seq >= 0)",          "position": 11        },        {          "declaration": "\n    CHECK (length(text) <= 500)",          "position": 12        },        {          "declaration": "\n    CHECK (state IN ('open', 'active', 'done'))",          "position": 13        },        {          "declaration": "\n    FOREIGN KEY (session_id) REFERENCES cotton_sessions(id)",          "position": 14        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 15        }      ],      "prefix": "CREATE TABLE IF NOT EXISTS cotton_session_tasks (",      "suffix": ")",      "indexes": [        "CREATE INDEX IF NOT EXISTS idx_cotton_session_tasks_author ON cotton_session_tasks (substr(_hlc, 20), _hlc)",        "CREATE INDEX IF NOT EXISTS idx_cotton_session_tasks_session ON cotton_session_tasks (session_id, seq)"      ],      "full_text": [],      "triggers": []    },    {      "name": "cotton_dev_jobs",      "columns": [        {          "name": "id",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": true,          "declaration": "\n    id TEXT PRIMARY KEY",          "position": 0        },        {          "name": "workspace_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    workspace_id TEXT NOT NULL",          "position": 1        },        {          "name": "device_id",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    device_id TEXT NOT NULL",          "position": 2        },        {          "name": "command",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    command TEXT NOT NULL",          "position": 3        },        {          "name": "cwd",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    cwd TEXT",          "position": 4        },        {          "name": "timeout_seconds",          "type": "INTEGER",          "default": "300",          "nullable": false,          "primary_key": false,          "declaration": "\n    timeout_seconds INTEGER NOT NULL DEFAULT 300",          "position": 5        },        {          "name": "state",          "type": "TEXT",          "default": "'queued'",          "nullable": false,          "primary_key": false,          "declaration": "\n    state TEXT NOT NULL DEFAULT 'queued'",          "position": 6        },        {          "name": "exit_code",          "type": "INTEGER",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    exit_code INTEGER",          "position": 7        },        {          "name": "failure",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    failure TEXT",          "position": 8        },        {          "name": "log_path",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    log_path TEXT",          "position": 9        },        {          "name": "log_bytes",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    log_bytes INTEGER NOT NULL DEFAULT 0",          "position": 10        },        {          "name": "log_lines",          "type": "INTEGER",          "default": "0",          "nullable": false,          "primary_key": false,          "declaration": "\n    log_lines INTEGER NOT NULL DEFAULT 0",          "position": 11        },        {          "name": "output_tail",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    output_tail TEXT",          "position": 12        },        {          "name": "created_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    created_at TEXT NOT NULL",          "position": 13        },        {          "name": "claimed_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    claimed_at TEXT",          "position": 14        },        {          "name": "finished_at",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    finished_at TEXT",          "position": 15        },        {          "name": "updated_at",          "type": "TEXT",          "default": null,          "nullable": false,          "primary_key": false,          "declaration": "\n    updated_at TEXT NOT NULL",          "position": 16        },        {          "name": "_hlc",          "type": "TEXT",          "default": "''",          "nullable": false,          "primary_key": false,          "declaration": "\n    _hlc TEXT NOT NULL DEFAULT ''",          "position": 17        },        {          "name": "_born",          "type": "TEXT",          "default": null,          "nullable": true,          "primary_key": false,          "declaration": "\n    _born TEXT",          "position": 18        }      ],      "constraints": [        {          "declaration": "\n    CHECK (length(device_id) > 0)",          "position": 19        },        {          "declaration": "\n    CHECK (length(trim(command)) > 0)",          "position": 20        },        {          "declaration": "\n    CHECK (length(command) <= 4096)",          "position": 21        },        {          "declaration": "\n    CHECK (cwd IS NULL OR length(trim(cwd)) > 0)",          "position": 22        },        {          "declaration": "\n    CHECK (timeout_seconds > 0)",          "position": 23        },        {          "declaration": "\n    CHECK (timeout_seconds <= 3600)",          "position": 24        },        {          "declaration": "\n    CHECK (state IN ('queued', 'running', 'done', 'failed', 'expired'))",          "position": 25        },        {          "declaration": "\n    CHECK (log_bytes >= 0)",          "position": 26        },        {          "declaration": "\n    CHECK (log_lines >= 0)",          "position": 27        },        {          "declaration": "\n    CHECK (output_tail IS NULL OR length(output_tail) <= 65536)",          "position": 28        },        {          "declaration": "\n    CHECK (failure IS NULL OR length(failure) <= 2048)",          "position": 29        },        {          "declaration": "\n    FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n  ",          "position": 30        }      ],      "prefix": "CREATE TABLE IF NOT EXISTS cotton_dev_jobs (",      "suffix": ")",      "indexes": [        "CREATE INDEX IF NOT EXISTS idx_cotton_dev_jobs_author ON cotton_dev_jobs (substr(_hlc, 20), _hlc)",        "CREATE INDEX IF NOT EXISTS idx_cotton_dev_jobs_queue ON cotton_dev_jobs (workspace_id, device_id, state, created_at)"      ],      "full_text": [],      "triggers": []    }  ]}