| 1 | -- People's own model API keys for agent tasks (agentic/keys.ts), encrypted per |
| 2 | -- account and provider. Write-only: nothing ever returns `ciphertext` decrypted |
| 3 | -- except the model proxy, while a task of that person runs. |
| 4 | CREATE TABLE model_keys ( |
| 5 | account_id TEXT NOT NULL, |
| 6 | provider TEXT NOT NULL, |
| 7 | ciphertext TEXT NOT NULL, |
| 8 | hint TEXT NOT NULL, |
| 9 | opted_in_at TEXT NOT NULL, |
| 10 | created_at TEXT NOT NULL, |
| 11 | updated_at TEXT NOT NULL, |
| 12 | PRIMARY KEY (account_id, provider) |
| 13 | ); |
| 14 | |
| 15 | -- An index of agent tasks across repositories (each repository's ProjectDO holds |
| 16 | -- the tasks themselves), for Today and task lists. |
| 17 | CREATE TABLE agent_tasks ( |
| 18 | id TEXT PRIMARY KEY, |
| 19 | repo_id TEXT NOT NULL, |
| 20 | number INTEGER NOT NULL, |
| 21 | title TEXT NOT NULL, |
| 22 | runtime TEXT NOT NULL, |
| 23 | agent_id TEXT NOT NULL, |
| 24 | started_by TEXT NOT NULL, |
| 25 | state TEXT NOT NULL, |
| 26 | pr_number INTEGER, |
| 27 | created_at TEXT NOT NULL, |
| 28 | updated_at TEXT NOT NULL |
| 29 | ); |
| 30 | CREATE INDEX agent_tasks_person ON agent_tasks(started_by, updated_at); |
| 31 | CREATE INDEX agent_tasks_agent ON agent_tasks(agent_id, updated_at); |
| 32 | CREATE UNIQUE INDEX agent_tasks_repo ON agent_tasks(repo_id, number); |