427 lines · 10.5 KB · JSONRaw
{ "format_version": 1, "id": "assistant_run", "name": "Run", "plural": "Runs", "picture": null, "builtin": true, "engine": "assistant", "columns": [ { "key": "task", "name": "Task", "type": "text", "required": true, "readonly": true }, { "key": "state", "name": "State", "type": "choice", "choices": [ "queued", "running", "done", "failed", "cancelled" ], "stamps": { "done": "done" }, "red_when": [ "failed" ], "readonly": true, "labels": { "queued": "Queued", "running": "Running", "done": "Done", "failed": "Failed", "cancelled": "Cancelled" }}, { "key": "class", "name": "Kind", "type": "choice", "choices": [ "quick", "deep" ], "readonly": true }, { "key": "receipt", "name": "Receipt", "type": "text", "readonly": true }, { "key": "error", "name": "What stopped it", "type": "text", "readonly": true }, { "key": "spent", "name": "Spent", "type": "text", "readonly": true }, { "key": "turns", "name": "Turns", "type": "number", "readonly": true, "units": { "one": "turn", "other": "turns", "zero": "" } }, { "key": "stopped_reason", "name": "Stopped on", "type": "text", "readonly": true }, { "key": "cost_usd", "name": "Cost in dollars", "type": "number", "readonly": true }, { "key": "result_note_id", "name": "Note", "type": "link", "link_to": "note", "readonly": true, "contributes": false }, { "key": "queued_at", "name": "Asked", "type": "date", "readonly": true }, { "key": "started_at", "name": "Started", "type": "date", "readonly": true }, { "key": "finished_at", "name": "Finished", "type": "date", "readonly": true } ], "title": "task", "date": "queued_at", "project": null, "order": null, "slip": { "title": "task", "subtitle": [ "receipt", "spent", "error" ], "trailing": null, "photo": null, "toggle": null, "caption": { "columns": [ "state", "turns" ], "dates": [ "finished_at", "started_at", "queued_at" ] }, "answers": { "column": "state", "values": { "cancelled": "Cancel" }, "when": [ "queued" ], "leaves": false }, "edge": "receipt" }, "tile": { "face": "receipt" }, "page": [ { "heading": null, "columns": [ "task", "state", "receipt", "spent", "error" ] }, { "heading": "When", "columns": [ "queued_at", "started_at", "finished_at" ] } ], "opens": { "column": "result_note_id", "table": "note" }, "delete": false, "instructions": "One run of the assistant's worker, newest first. `task`, `receipt` and `error` are the server's own sentences and are shown exactly as written. A failed run says what stopped it and offers no retry: asking again unchanged fails the same way. Only a queued run can be cancelled — writing state `cancelled` takes it out of the queue and the run is gone; any other state is refused by name. A run that answered with a note opens that note.", "add": false, "tables": [ { "name": "cotton_assistant_runs", "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": "source_kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source_kind TEXT NOT NULL CHECK (source_kind IN ('thought','comment','session_message'))", "position": 2 }, { "name": "source_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source_id TEXT NOT NULL", "position": 3 }, { "name": "record_kind", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n record_kind TEXT", "position": 4 }, { "name": "record_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n record_id TEXT", "position": 5 }, { "name": "session_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n session_id TEXT", "position": 6 }, { "name": "class", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n class TEXT NOT NULL CHECK (class IN ('quick','deep'))", "position": 7 }, { "name": "state", "type": "TEXT", "default": "'queued'", "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL DEFAULT 'queued' CHECK (state IN ('queued','running','done','failed'))", "position": 8 }, { "name": "task", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n task TEXT NOT NULL CHECK (length(task) BETWEEN 1 AND 500)", "position": 9 }, { "name": "receipt", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n receipt TEXT NOT NULL", "position": 10 }, { "name": "turns", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n turns INTEGER NOT NULL DEFAULT 0", "position": 11 }, { "name": "input_tokens", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n input_tokens INTEGER NOT NULL DEFAULT 0", "position": 12 }, { "name": "output_tokens", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n output_tokens INTEGER NOT NULL DEFAULT 0", "position": 13 }, { "name": "cost_usd", "type": "REAL", "default": null, "nullable": true, "primary_key": false, "declaration": "\n cost_usd REAL", "position": 14 }, { "name": "result_note_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n result_note_id TEXT", "position": 15 }, { "name": "stopped_reason", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n stopped_reason TEXT CHECK (stopped_reason IS NULL OR stopped_reason IN ('answered','turn_ceiling','time_ceiling','no_key','model_refused'))", "position": 16 }, { "name": "error", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n error TEXT", "position": 17 }, { "name": "queued_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n queued_at TEXT NOT NULL", "position": 18 }, { "name": "started_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n started_at TEXT", "position": 19 }, { "name": "finished_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n finished_at TEXT", "position": 20 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 21 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 22 } ], "constraints": [ { "declaration": "\n CHECK ((state = 'failed') = (error IS NOT NULL))", "position": 23 }, { "declaration": "\n CHECK ((state IN ('done','failed')) = (finished_at IS NOT NULL))", "position": 24 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 25 } ], "prefix": "CREATE TABLE cotton_assistant_runs (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_assistant_runs_state ON cotton_assistant_runs (workspace_id, state, queued_at)", "CREATE INDEX idx_cotton_assistant_runs_source ON cotton_assistant_runs (source_kind, source_id)", "CREATE INDEX idx_cotton_assistant_runs_note ON cotton_assistant_runs (result_note_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_assistant_runs_author ON cotton_assistant_runs (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ]}