| 1 | -- A hand-off from the Assistant to the team: the Assistant turn it came |
| 2 | -- from, the Coordinator message that carries the person's words, the |
| 3 | -- Assistant's context, the key it was made with (one row per key), open |
| 4 | -- or cancelled, and the digest of the summary the person was last told. |
| 5 | CREATE TABLE chat_handoffs (id text PRIMARY KEY, person text, assistant_turn text, message_id text, context text, ledger_key text, state text, digest text, created_at datetime, updated_at datetime); |
| 6 | CREATE UNIQUE INDEX chat_handoff_key ON chat_handoffs(ledger_key); |
| 7 | CREATE INDEX chat_handoff_person ON chat_handoffs(person); |
| 8 | CREATE INDEX chat_handoff_message ON chat_handoffs(message_id); |
| 9 | -- A hand-off's turns: the Coordinator turns that carry its words or an |
| 10 | -- answer to its question, and its team_update turns. A turn has one. |
| 11 | CREATE TABLE chat_handoff_turns (handoff_id text, turn_id text PRIMARY KEY); |
| 12 | CREATE INDEX chat_handoff_turn_handoff ON chat_handoff_turns(handoff_id); |
| 13 | -- The tasks a hand-off follows; created when one of its turns recorded it. |
| 14 | CREATE TABLE chat_handoff_tasks (handoff_id text, task_id text, created numeric, PRIMARY KEY (handoff_id, task_id)); |
| 15 | CREATE INDEX chat_handoff_task ON chat_handoff_tasks(task_id); |
| 16 | -- A team_update turn's text: the summary it tells. |
| 17 | ALTER TABLE chat_turns ADD COLUMN note text; |
| 18 | |