| 1 | -- Budgets per person (docs.g1t.sh/guides/agent-budgets/): what the agents |
| 2 | -- working for one person, the replies and sessions that person asked for, |
| 3 | -- may spend together in a month. Budgets nest: the workspace's spend limit |
| 4 | -- (billing), the workspace's agent budget, a person's, an agent's, a task's. |
| 5 | |
| 6 | -- The budget every person has unless they have their own. Null: none. |
| 7 | ALTER TABLE agent_policies ADD COLUMN person_monthly_micros INTEGER; |
| 8 | |
| 9 | -- A person's own budget, set by an owner. 0: no budget at all, whatever |
| 10 | -- the default. No row: the default. |
| 11 | CREATE TABLE person_budgets ( |
| 12 | workspace_id TEXT NOT NULL, |
| 13 | username TEXT NOT NULL, |
| 14 | monthly_micros INTEGER NOT NULL, |
| 15 | updated_by TEXT NOT NULL, |
| 16 | updated_at TEXT NOT NULL, |
| 17 | PRIMARY KEY (workspace_id, username) |
| 18 | ); |
| 19 | |
| 20 | -- What a person's agents spent is summed from the replies and sessions they |
| 21 | -- asked for, so it counts from the first one, before any budget was set. |
| 22 | CREATE INDEX agent_replies_asker ON agent_replies (workspace_id, asked_by_username, created_at); |
| 23 | CREATE INDEX agent_sessions_asker ON agent_sessions (workspace_id, asked_by_username, created_at); |