Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

40 linesCodeBlameRaw
1-- Provider cost reports (src/provider_costs.rs): a workspace's AI
2-- provider admin key, and what that provider's own cost report says the
3-- organization spent, by day.
4
5-- One per workspace and provider. The key is sealed with BILLING_KEY,
6-- bound to the row's id; `hint` is its last four characters, the only
7-- part ever shown.
8CREATE TABLE provider_connections (
9 id TEXT PRIMARY KEY,
10 workspace TEXT NOT NULL,
11 provider TEXT NOT NULL,
12 credential TEXT NOT NULL,
13 hint TEXT NOT NULL,
14 connected_by TEXT NOT NULL,
15 connected_at TEXT NOT NULL,
16 last_synced_at TEXT,
17 last_error TEXT,
18 -- YYYY-MM-DD: the first day asked for. Unset until the first read,
19 -- which goes back 90 days.
20 synced_from TEXT,
21 UNIQUE (workspace, provider)
22);
23
24-- What the provider reported, per UTC day, line item (Anthropic's
25-- description, OpenAI's line item) and the provider's own workspace or
26-- project (`scope`, empty for its default). Each read replaces the days
27-- it covers, since providers revise recent days.
28CREATE TABLE provider_costs (
29 workspace TEXT NOT NULL,
30 provider TEXT NOT NULL,
31 day TEXT NOT NULL,
32 item TEXT NOT NULL DEFAULT '',
33 scope TEXT NOT NULL DEFAULT '',
34 micros INTEGER NOT NULL,
35 currency TEXT NOT NULL DEFAULT 'USD',
36 synced_at TEXT NOT NULL,
37 PRIMARY KEY (workspace, provider, day, item, scope)
38);
39
40CREATE INDEX provider_costs_by_day ON provider_costs (workspace, day);