Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 1 | import type { ComputeKind, Reservation } from "./compute"; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 2 | import type { User, Viewer } from "./identity"; |
| 3 | import type { RepoPath } from "./repos"; | |
| 4 | import type { Result } from "./result"; | |
| 5 | ||
| 6 | /** Millionths of a US dollar in one dollar: the unit money is held in. */ | |
| 7 | export const MICROS_PER_DOLLAR = 1_000_000; | |
| 8 | ||
| 9 | /** Whether workspaces are charged for agents at all, and with real money. */ | |
| 10 | export type BillingStatus = { | |
| 11 | /** | |
| 12 | * False when no card processor is configured: nothing is charged, and who | |
| 13 | * may run agents is decided some other way. | |
| 14 | */ | |
| 15 | enabled: boolean; | |
| 16 | /** False while the card processor is in its test mode, where cards are not real. */ | |
| 17 | live: boolean; | |
| Free while g1t is being built out; agents can check out their own forks | 18 | /** |
| 19 | * True while g1t is being built out: runs are recorded with what they | |
| 20 | * cost, but nothing is charged and no credit is needed. Not forever. | |
| 21 | */ | |
| 22 | free?: boolean; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 23 | }; |
| 24 | ||
| 25 | /** A workspace's standing. */ | |
| 26 | export type BillingAccount = { | |
| 27 | workspace: string; | |
| 28 | /** | |
| 29 | * Credit left, in millionths of a dollar. Can dip below zero by the cost | |
| 30 | * of the runs that were under way when it ran out. | |
| 31 | */ | |
| 32 | balanceMicros: number; | |
| 33 | status: BillingStatus; | |
| 34 | /** What is added to a run's cost, in percent. */ | |
| 35 | marginPercent: number; | |
| Billing on Stripe's pages, month-end charges, warnings; sudo by workspace | 36 | /** The card charged near the limit and when a month closes, if one is saved. */ |
| 37 | card?: { brand: string; last4: string; expMonth: number; expYear: number } | null; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 38 | }; |
| 39 | ||
| 40 | /** One line of a workspace's statement. */ | |
| 41 | export type LedgerEntry = { | |
| 42 | id: string; | |
| 43 | /** Credit bought with a card, or an agent's run. */ | |
| 44 | kind: "top_up" | "usage"; | |
| 45 | /** Positive for credit added, negative for usage. */ | |
| 46 | amountMicros: number; | |
| 47 | description: string; | |
| 48 | /** For usage: the repository and pull request the agent worked on. */ | |
| 49 | repo: string | null; | |
| 50 | number: number | null; | |
| 51 | /** For usage: `implement`, `review` or `update`. */ | |
| 52 | task: string | null; | |
| 53 | /** For usage: the model, by its public name. */ | |
| 54 | model: string | null; | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 55 | /** For usage: who paid the model provider. */ |
| 56 | billedTo: "g1t" | "workspace"; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 57 | /** For a top-up: the username of whoever paid. */ |
| 58 | createdBy: string | null; | |
| 59 | /** RFC 3339. */ | |
| 60 | createdAt: string; | |
| Billing on Stripe's pages, month-end charges, warnings; sudo by workspace | 61 | /** The workspace the line belongs to, which tells an enterprise's lines apart. */ |
| 62 | workspace?: string | null; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 63 | /** For usage: what the plan's included usage paid of it. `amountMicros` is what is left to pay. */ |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 64 | creditMicros?: number; |
| 65 | /** For usage: what the workspace's trial credit paid of it. */ | |
| 66 | trialMicros?: number; | |
| 67 | /** For usage: what g1t's open-source pool paid of it. */ | |
| 68 | ossMicros?: number; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 69 | /** For usage: what g1t covered itself, such as a trial's last run past its credit. */ |
| 70 | givenMicros?: number; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 71 | }; |
| 72 | ||
| 73 | /** What lets a sandbox, and nothing else, report what its run cost. */ | |
| 74 | export type RunTicket = { runId: string; token: string }; | |
| 75 | ||
| 76 | /** | |
| 77 | * What agents cost, charged to the workspace they worked for. A workspace | |
| 78 | * buys credit; each run deducts its cost plus g1t's margin; with no credit, | |
| 79 | * no agent starts. | |
| 80 | */ | |
| A free allowance on g1t's models, so anyone can try its agents | 81 | /** |
| 82 | * The free allowance on g1t's hosted models for a workspace not otherwise | |
| 83 | * open to them: a few dollars of model cost each, out of one pool, until a | |
| 84 | * date. Mirrors `Trial` in `crates/contracts/src/billing.rs`. | |
| 85 | */ | |
| Billing accounts, terms and enterprises; g1t is no longer free | 86 | /** How an account is charged. Standard unless g1t set otherwise in sudo. */ |
| 87 | export type Terms = { | |
| 88 | kind: "standard" | "comped" | "custom"; | |
| 89 | discountPercent: number; | |
| 90 | ceilingMicros: number | null; | |
| 91 | note: string; | |
| 92 | until: string | null; | |
| 93 | setBy: string | null; | |
| 94 | setAt: string | null; | |
| 95 | }; | |
| 96 | ||
| 97 | /** | |
| 98 | * Who pays: a workspace's own account, or an enterprise's, which pays for | |
| 99 | * several workspaces with one bill and one limit. | |
| 100 | */ | |
| 101 | export type PayingAccount = { | |
| 102 | id: string; | |
| 103 | kind: "workspace" | "enterprise"; | |
| 104 | name: string; | |
| 105 | terms: Terms; | |
| 106 | workspaces: string[]; | |
| Stripe webhooks, enterprise invoices, and sudo for both | 107 | /** Where an enterprise's invoices go. */ |
| 108 | billingEmail?: string | null; | |
| 109 | /** An enterprise's invoices, newest first. */ | |
| 110 | invoices?: EnterpriseInvoice[]; | |
| Billing accounts, terms and enterprises; g1t is no longer free | 111 | createdAt: string; |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 112 | /** What g1t staff set for the account beyond its terms. */ |
| 113 | allowances?: Allowances; | |
| 114 | }; | |
| 115 | ||
| 116 | /** Set per account by g1t staff in sudo, on top of its terms. */ | |
| 117 | export type Allowances = { | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 118 | /** The g1t plan without its monthly price; usage is charged as usual. Comped accounts have it anyway. */ |
| 119 | plan: boolean; | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 120 | /** Each public repository's monthly cap on g1t's open-source pool; null for the default. */ |
| 121 | ossRepoMicros: number | null; | |
| 122 | /** Each workspace's trial credit, outside the monthly pool; null for the default. */ | |
| 123 | trialMicros: number | null; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 124 | /** Agents at once, in place of the plan's (2 in the first month or on the trial, then 10); null for the default. */ |
| 125 | maxConcurrentAgents?: number | null; | |
| 126 | /** One run's spend cap, in place of the owners' and the default $2; null for none. */ | |
| 127 | runCapMicros?: number | null; | |
| 128 | /** What one issue's agents may spend in all, in place of the owners' and the default $10; null for none. */ | |
| 129 | issueCapMicros?: number | null; | |
| 130 | /** A hold on new compute, with why; null for none. */ | |
| 131 | hold?: string | null; | |
| Billing accounts, terms and enterprises; g1t is no longer free | 132 | }; |
| 133 | ||
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 134 | // --- Entitlements, and compute started under a reservation ------------------ |
| 135 | // | |
| 136 | // Every service that starts compute asks billing first: | |
| 137 | // 1. `entitlements(workspace)`: what it may do at all, its caps, and whether compute is paused. | |
| 138 | // 2. `reserve(...)`: holds the estimate against what may pay for it, so starts at the same moment | |
| 139 | // cannot overshoot together. Answers who pays first, or refuses with a stable code | |
| 140 | // (`not_paid`, `trial_used`, `limit`, `paused`, `oss_pool_empty`) and a message for the owner. | |
| 141 | // 3. `settle(reservationId, actualMicros)`: releases the hold. The charge goes on the ledger the usual way. | |
| 142 | // A reservation never settled lapses after `RESERVATION_HOURS`. | |
| 143 | ||
| 144 | /** A reservation that is never settled stops holding after this long. */ | |
| 145 | export const RESERVATION_HOURS = 3; | |
| 146 | /** What a ceiling reads as when there is none (g1t's own workspaces). */ | |
| 147 | export const UNLIMITED_MICROS = 1_000_000_000_000_000; | |
| 148 | ||
| 149 | /** What a workspace pays g1t on, as far as compute is concerned. Mirrors `PlanKind`. */ | |
| 150 | export type PlanKind = "free" | "paid" | "internal" | "enterprise"; | |
| 151 | ||
| 152 | // `ComputeKind` (what compute is for), `PaidBy` (who pays first: credit, trial, oss, on_demand) and | |
| 153 | // `Reservation` are in `./compute`, with the gate that calls `reserve` and `settle`. | |
| 154 | ||
| 155 | /** One level reached: 50, 75, 90 or 100 percent. */ | |
| 156 | export type UsageAlert = { | |
| 157 | /** `included` (the plan's included usage), `spend_limit` or `ceiling`. */ | |
| 158 | meter: "included" | "spend_limit" | "ceiling" | string; | |
| 159 | level: number; | |
| 160 | usedMicros: number; | |
| 161 | limitMicros: number; | |
| 162 | message: string; | |
| 163 | }; | |
| 164 | ||
| 165 | /** An hour's spend well above the workspace's usual: new compute waits for an owner. */ | |
| 166 | export type Spike = { | |
| 167 | id: string; | |
| 168 | /** `open` (waiting), `continued` (keep going) or `stopped`. */ | |
| 169 | status: "open" | "continued" | "stopped" | string; | |
| 170 | hourMicros: number; | |
| 171 | averageMicros: number; | |
| 172 | detectedAt: string; | |
| 173 | decidedBy?: string | null; | |
| 174 | decidedAt?: string | null; | |
| 175 | /** While continued: until when, unless spend doubles again first. */ | |
| 176 | until?: string | null; | |
| 177 | }; | |
| 178 | ||
| 179 | /** What a workspace may do now. Mirrors `Entitlements` in `crates/contracts/src/billing.rs`. */ | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 180 | export type Entitlements = { |
| 181 | workspace: string; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 182 | plan: PlanKind; |
| 183 | /** May start sandboxes, models, deployments and semantic search at all: paid, internal, enterprise, or free with trial credit left. */ | |
| 184 | compute: boolean; | |
| 185 | /** The one-time trial credit left; 0 if none or used. */ | |
| 186 | trialMicrosLeft: number; | |
| 187 | /** A card check has been done; the trial and the open-source pool need it. */ | |
| 188 | trialVerified: boolean; | |
| 189 | /** A paid workspace still in its first billing cycle. */ | |
| 190 | firstMonth: boolean; | |
| 191 | /** 2 in the first month or on the trial, 10 after; staff can override it. */ | |
| 192 | maxConcurrentAgents: number; | |
| 193 | /** 60 in the first month or on the trial; otherwise the guardrails' own caps. */ | |
| 194 | maxRunMinutes: number; | |
| 195 | /** One run's spend cap, $2 by default; staff can override it. */ | |
| 196 | runCapMicros: number; | |
| 197 | /** Agent spend on one issue in all, $10 by default. */ | |
| 198 | issueCapMicros: number; | |
| 199 | /** g1t's ceiling on usage not yet paid for; `UNLIMITED_MICROS` for g1t's own; 0 for free. */ | |
| 200 | ceilingMicros: number; | |
| 201 | /** Usage not yet paid for this month, prepayment taken off. */ | |
| 202 | exposureMicros: number; | |
| 203 | /** Why new compute is paused, for the owner; null when it is not. */ | |
| 204 | paused: string | null; | |
| 205 | /** What open reservations hold now. */ | |
| 206 | heldMicros?: number; | |
| 207 | /** Paid in advance and not used yet. */ | |
| 208 | prepaidMicros?: number; | |
| 209 | /** The plan's included usage each month, and what of it is used. */ | |
| 210 | includedMicros?: number; | |
| 211 | includedUsedMicros?: number; | |
| 212 | /** How far back the audit log can be read and exported: the same on every plan. */ | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 213 | auditRetentionDays: number; |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 214 | /** Private repository storage free for every workspace: past it, the plan pays and a free workspace's pushes stop. */ |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 215 | freePrivateStorageBytes: number; |
| 216 | /** The last daily measure of the workspace's private repositories (a lower bound). */ | |
| 217 | privateStorageBytes: number; | |
| 218 | /** What g1t's open-source pool paid for the workspace this month. */ | |
| 219 | ossPaidMicros: number; | |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 220 | /** Deploy build time this month, every second of it metered. */ |
| 221 | buildSecondsUsed?: number; | |
| 222 | /** Git operations this month, and how many are free for every workspace. */ | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 223 | gitOperations?: number; |
| 224 | gitOperationsIncluded?: number; | |
| 225 | /** The smallest amount a card is charged when a month closes. */ | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 226 | minChargeMicros: number; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 227 | /** A spend spike waiting for an owner, or decided. */ |
| 228 | spike?: Spike | null; | |
| 229 | /** Where usage stands against what is included and the limits, from 50%. */ | |
| 230 | alerts?: UsageAlert[]; | |
| 231 | }; | |
| 232 | ||
| 233 | /** A hold on a start's estimated cost, as billing answers it (`Reservation` in `./compute`, and more). */ | |
| 234 | export type ReservationHeld = Reservation & { | |
| 235 | /** What is held, at cost; may be less than the estimate for a free workspace's last bit of trial. */ | |
| 236 | heldMicros?: number; | |
| 237 | /** When the hold lapses if never settled. */ | |
| 238 | expiresAt?: string; | |
| 239 | }; | |
| 240 | ||
| 241 | /** A request to g1t: a higher limit, or help with usage past what was meant. */ | |
| 242 | export type LimitRequest = { | |
| 243 | id: string; | |
| 244 | workspace: string; | |
| 245 | kind: "limit" | "overage" | string; | |
| 246 | amountMicros: number; | |
| 247 | reason: string; | |
| 248 | expectedMonthlyMicros: number; | |
| 249 | status: "open" | "approved" | "declined" | string; | |
| 250 | decidedMicros?: number | null; | |
| 251 | decidedBy?: string | null; | |
| 252 | /** The answer, as the owner sees it. */ | |
| 253 | answer?: string | null; | |
| 254 | createdBy: string; | |
| 255 | createdAt: string; | |
| 256 | decidedAt?: string | null; | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 257 | }; |
| 258 | ||
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 259 | /** What staff see beside a request. */ |
| 260 | export type WorkspaceHistory = { | |
| 261 | plan: PlanKind | null; | |
| 262 | months: MonthFigures[]; | |
| 263 | paidClearedMicros: number; | |
| 264 | payments: number; | |
| 265 | disputes: number; | |
| 266 | declines: number; | |
| 267 | firstSeen: string | null; | |
| 268 | ceilingMicros: number | null; | |
| 269 | maxCeilingMicros: number | null; | |
| 270 | spendLimitMicros: number | null; | |
| 271 | lastHourMicros: number; | |
| 272 | averageHourMicros: number; | |
| 273 | lastDayMicros: number; | |
| 274 | }; | |
| 275 | ||
| 276 | export type LimitRequestReview = { request: LimitRequest; history: WorkspaceHistory }; | |
| 277 | ||
| 278 | /** What a one-time goodwill credit comes to: the margin on the overage, always, plus its cost up to the cap. */ | |
| 279 | export type Goodwill = { | |
| 280 | overageMicros: number; | |
| 281 | marginMicros: number; | |
| 282 | costMicros: number; | |
| 283 | creditMicros: number; | |
| 284 | absorbedMicros: number; | |
| 285 | }; | |
| 286 | ||
| 287 | /** A workspace whose month went well past its usual, or hit a spike. */ | |
| 288 | export type Overage = { | |
| 289 | workspace: string; | |
| 290 | plan: PlanKind; | |
| 291 | typicalMonthMicros: number; | |
| 292 | thisMonthMicros: number; | |
| 293 | costMicros: number; | |
| 294 | marginMicros: number; | |
| 295 | spike: Spike | null; | |
| 296 | topEntries: LedgerEntry[]; | |
| 297 | goodwill: Goodwill; | |
| 298 | goodwillAvailable: boolean; | |
| 299 | lastGoodwillAt: string | null; | |
| 300 | request: LimitRequest | null; | |
| 301 | }; | |
| 302 | ||
| 303 | /** One workspace's recent pace. */ | |
| 304 | export type Velocity = { | |
| 305 | workspace: string; | |
| 306 | plan: PlanKind; | |
| 307 | lastHourMicros: number; | |
| 308 | averageHourMicros: number; | |
| 309 | lastDayMicros: number; | |
| 310 | thisMonthMicros: number; | |
| 311 | ratio: number; | |
| 312 | spike: Spike | null; | |
| 313 | firstSeen: string | null; | |
| 314 | }; | |
| 315 | ||
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 316 | /** g1t's capped budgets for free usage this month. */ |
| 317 | export type Pools = { | |
| 318 | month: string; | |
| 319 | trialGrantedMicros: number; | |
| 320 | trialPoolMicros: number; | |
| 321 | trialGrants: number; | |
| 322 | ossUsedMicros: number; | |
| 323 | ossPoolMicros: number; | |
| 324 | ossRepoMicros: number; | |
| 325 | }; | |
| 326 | ||
| Billing accounts, terms and enterprises; g1t is no longer free | 327 | export type AccountSummary = { |
| 328 | account: PayingAccount; | |
| 329 | limit: Limit; | |
| 330 | chargedMicros: number; | |
| 331 | costMicros: number; | |
| 332 | paidMicros: number; | |
| Billing on Stripe's pages, month-end charges, warnings; sudo by workspace | 333 | /** The same figures for each of the account's workspaces that has any. */ |
| 334 | byWorkspace: WorkspaceFigures[]; | |
| Two limits, real invoices, trust that grows by itself, sales signals | 335 | /** The last six months, oldest first. */ |
| 336 | months?: MonthFigures[]; | |
| Billing on Stripe's pages, month-end charges, warnings; sudo by workspace | 337 | }; |
| 338 | ||
| 339 | /** One workspace's share of an `AccountSummary`. */ | |
| 340 | export type WorkspaceFigures = { workspace: string; chargedMicros: number; costMicros: number; paidMicros: number }; | |
| 341 | ||
| Stripe webhooks, enterprise invoices, and sudo for both | 342 | export type StripeStatus = { |
| 343 | /** `test` or `live`, from the key; `off` without one. */ | |
| 344 | mode: "test" | "live" | "off" | string; | |
| Stripe's webhook secret is a Worker secret, STRIPE_WEBHOOK_SECRET, from a destination made in Stripe's dashboard | 345 | /** Whether `STRIPE_WEBHOOK_SECRET` is set, so events can be checked. */ |
| 346 | secretSet: boolean; | |
| 347 | /** The destination at billing's address in Stripe, as Stripe has it. */ | |
| 348 | webhook: { url: string; endpointId: string; status: "enabled" | "disabled" | string; events: string[]; createdAt: string } | null; | |
| 349 | /** Events billing handles that the destination does not send. */ | |
| 350 | missingEvents: string[]; | |
| Stripe webhooks, enterprise invoices, and sudo for both | 351 | recentEvents: { id: string; kind: string; outcome: string; receivedAt: string }[]; |
| 352 | error: string | null; | |
| 353 | }; | |
| 354 | ||
| 355 | /** An enterprise's invoice: one line per workspace, paid on Stripe's page. */ | |
| 356 | export type EnterpriseInvoice = { | |
| 357 | invoiceId: string; | |
| 358 | hostedUrl: string | null; | |
| 359 | amountMicros: number; | |
| 360 | status: "open" | "paid" | "overdue" | "void" | string; | |
| 361 | period: string; | |
| 362 | lines: { workspace: string; amountMicros: number }[]; | |
| 363 | createdAt: string; | |
| 364 | }; | |
| 365 | ||
| Two limits, real invoices, trust that grows by itself, sales signals | 366 | /** A workspace's invoice: monthly, or when charged near its limit. Itemised, in Stripe's billing page. */ |
| 367 | export type WorkspaceInvoice = { | |
| 368 | invoiceId: string; | |
| 369 | workspace: string; | |
| 370 | reason: "month" | "threshold" | string; | |
| 371 | period: string; | |
| 372 | amountMicros: number; | |
| 373 | status: "paid" | "open" | "failed" | "void" | string; | |
| 374 | hostedUrl: string | null; | |
| 375 | pdfUrl: string | null; | |
| 376 | lines: { description: string; amountMicros: number }[]; | |
| 377 | createdAt: string; | |
| 378 | }; | |
| 379 | ||
| The statement is a month at a time, a line per kind of charge | 380 | /** A month of the ledger, grouped by day or project, a line per kind of charge. */ |
| 381 | export type Statement = { | |
| 382 | month: string; | |
| 383 | months: string[]; | |
| 384 | groups: { | |
| 385 | key: string; | |
| 386 | label: string; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 387 | /** `coveredMicros`: what the plan's included usage, the trial, the open-source pool or g1t paid, not in `chargedMicros`. */ |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 388 | lines: { kind: string; count: number; chargedMicros: number; costMicros: number; coveredMicros?: number }[]; |
| The statement is a month at a time, a line per kind of charge | 389 | chargedMicros: number; |
| 390 | }[]; | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 391 | totals: { |
| 392 | chargedMicros: number; | |
| 393 | paidMicros: number; | |
| 394 | costMicros: number; | |
| 395 | entries: number; | |
| 396 | /** What paid for usage before it was charged, such as "Paid by g1t's open-source pool". */ | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 397 | covered?: { source: "included" | "trial" | "oss_pool" | "given" | string; label: string; micros: number }[]; |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 398 | /** Owed when the month closed but under the minimum charge: on the next invoice. */ |
| 399 | carriedMicros?: number; | |
| 400 | }; | |
| The statement is a month at a time, a line per kind of charge | 401 | }; |
| 402 | ||
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 403 | export type MonthFigures = { |
| 404 | month: string; | |
| 405 | /** Usage charged, after what paid for it first. */ | |
| 406 | chargedMicros: number; | |
| 407 | /** What usage cost g1t: never a workspace's own model provider. */ | |
| 408 | costMicros: number; | |
| 409 | paidMicros: number; | |
| 410 | /** The plan's monthly price, paid. */ | |
| 411 | plansMicros?: number; | |
| 412 | /** What g1t gave at price (internal use, trials, the open-source pool, goodwill, covered). Not margin. */ | |
| 413 | givenMicros?: number; | |
| 414 | }; | |
| 415 | ||
| 416 | /** What g1t gave this month from one source. */ | |
| 417 | export type GivenFigures = { source: "internal" | "trial" | "oss_pool" | "goodwill" | "covered" | string; label: string; micros: number; costMicros: number }; | |
| 418 | ||
| 419 | /** One internal workspace's use this month, and why it is not charged. */ | |
| 420 | export type InternalUse = { workspace: string; reason: string; costMicros: number; entries: number }; | |
| Two limits, real invoices, trust that grows by itself, sales signals | 421 | |
| Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily | 422 | export type SignalKind = "at_limit" | "near_ceiling" | "declined" | "growing" | "established" | "first_payment" | "high_spend" | "cost_over_revenue"; |
| Two limits, real invoices, trust that grows by itself, sales signals | 423 | |
| 424 | /** Why a workspace is worth reaching out to. */ | |
| 425 | export type Signal = { | |
| 426 | workspace: string; | |
| 427 | kind: SignalKind; | |
| 428 | detail: string; | |
| 429 | valueMicros: number; | |
| 430 | stage: string | null; | |
| 431 | owner: string | null; | |
| Billing lists every invoice and every staff change; signals carry follow-ups | 432 | nextStep?: string | null; |
| 433 | /** When the next step is due, YYYY-MM-DD. */ | |
| 434 | nextAt?: string | null; | |
| 435 | }; | |
| 436 | ||
| 437 | /** One invoice g1t has sent, a workspace's or an enterprise's. */ | |
| 438 | export type InvoiceSummary = { | |
| 439 | invoiceId: string; | |
| 440 | kind: "workspace" | "enterprise"; | |
| 441 | account: string; | |
| 442 | name: string; | |
| 443 | reason: string; | |
| 444 | period: string; | |
| 445 | amountMicros: number; | |
| 446 | status: string; | |
| 447 | hostedUrl: string | null; | |
| 448 | createdAt: string; | |
| 449 | paidAt: string | null; | |
| Two limits, real invoices, trust that grows by itself, sales signals | 450 | }; |
| 451 | ||
| 452 | export type SalesStage = "none" | "lead" | "contacted" | "negotiating" | "won" | "lost" | "churn_risk"; | |
| 453 | ||
| 454 | export type SalesRecord = { | |
| 455 | workspace: string; | |
| 456 | stage: SalesStage | string; | |
| 457 | owner: string | null; | |
| 458 | nextStep: string | null; | |
| 459 | nextAt: string | null; | |
| 460 | notes: { id: string; text: string; by: string; createdAt: string }[]; | |
| 461 | updatedAt: string | null; | |
| 462 | }; | |
| 463 | ||
| 464 | export type Overview = { | |
| 465 | month: string; | |
| 466 | months: MonthFigures[]; | |
| 467 | byKind: { kind: string; chargedMicros: number; costMicros: number }[]; | |
| 468 | payingWorkspaces: number; | |
| 469 | stopped: number; | |
| 470 | nearCeiling: number; | |
| 471 | declined: number; | |
| 472 | openInvoicesMicros: number; | |
| 473 | followUpsDue: number; | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 474 | /** g1t's capped budgets for free usage, this month. */ |
| 475 | pools?: Pools | null; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 476 | /** Usage charged plus the plan's price paid, this month. */ |
| 477 | revenueMicros?: number; | |
| 478 | activePlans?: number; | |
| 479 | planMrrMicros?: number; | |
| 480 | /** What g1t gave this month, by source, apart from its margin. */ | |
| 481 | given?: GivenFigures[]; | |
| 482 | /** g1t's own and Flagon's workspaces: what their use cost, and why they are not charged. */ | |
| 483 | internal?: InternalUse[]; | |
| 484 | openRequests?: number; | |
| 485 | overages?: number; | |
| 486 | openSpikes?: number; | |
| Two limits, real invoices, trust that grows by itself, sales signals | 487 | }; |
| 488 | ||
| Billing on Stripe's pages, month-end charges, warnings; sudo by workspace | 489 | /** A customer's Stripe billing page, for staff to send them. */ |
| 490 | export type BillingLink = { | |
| 491 | /** One-time and short-lived, signed in already. */ | |
| 492 | portalUrl: string; | |
| 493 | /** The page's sign-in, which does not expire: the customer signs in by email. */ | |
| 494 | loginUrl: string | null; | |
| 495 | customerEmail: string | null; | |
| 496 | expiresNote: string; | |
| Billing accounts, terms and enterprises; g1t is no longer free | 497 | }; |
| 498 | ||
| 499 | export type AdminAction = { id: string; account: string; action: string; detail: string; by: string; createdAt: string }; | |
| 500 | ||
| 501 | export type AccountDetail = { | |
| 502 | summary: AccountSummary; | |
| 503 | workspaces: Limit[]; | |
| 504 | ledger: LedgerEntry[]; | |
| 505 | audit: AdminAction[]; | |
| 506 | }; | |
| 507 | ||
| 508 | /** Staff-only billing, for sudo.g1t.sh. Every change names who made it. */ | |
| 509 | export interface BillingAdminApi { | |
| 510 | accounts(query?: string): Promise<AccountSummary[]>; | |
| 511 | account(id: string): Promise<Result<AccountDetail>>; | |
| 512 | setTerms(id: string, terms: Terms, by: string): Promise<Result<PayingAccount>>; | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 513 | /** Team on or off without charge, and the account's share of the pools. Needs a note. */ |
| 514 | setAllowances(id: string, allowances: Allowances, note: string, by: string): Promise<Result<PayingAccount>>; | |
| Billing accounts, terms and enterprises; g1t is no longer free | 515 | createEnterprise(name: string, workspaces: string[], by: string): Promise<Result<PayingAccount>>; |
| 516 | attach(workspace: string, account: string | null, by: string): Promise<Result<PayingAccount>>; | |
| 517 | credit(workspace: string, amountMicros: number, note: string, by: string): Promise<Result<LedgerEntry>>; | |
| Billing on Stripe's pages, month-end charges, warnings; sudo by workspace | 518 | /** The workspace's Stripe billing page, to send to the customer. Logged. */ |
| 519 | billingLink(workspace: string, by: string): Promise<Result<BillingLink>>; | |
| Stripe webhooks, enterprise invoices, and sudo for both | 520 | /** Where billing stands with Stripe; with `setup`, registers the webhook first. */ |
| Stripe's webhook secret is a Worker secret, STRIPE_WEBHOOK_SECRET, from a destination made in Stripe's dashboard | 521 | /** Stripe's state for billing; `fix` enables the destination and adds missing events first. */ |
| 522 | stripe(fix?: boolean, by?: string): Promise<StripeStatus>; | |
| Stripe webhooks, enterprise invoices, and sudo for both | 523 | /** Where an enterprise's invoices go; makes its Stripe customer. */ |
| 524 | enterpriseBilling(id: string, email: string, by: string): Promise<Result<PayingAccount>>; | |
| 525 | /** Sends an enterprise its invoice now, for what its workspaces owe. */ | |
| 526 | invoiceEnterprise(id: string, by: string): Promise<Result<EnterpriseInvoice>>; | |
| 527 | /** Exactly these workspaces' accounts, such as one page of the list. */ | |
| 528 | accountsFor(workspaces: string[]): Promise<AccountSummary[]>; | |
| Two limits, real invoices, trust that grows by itself, sales signals | 529 | /** Every workspace worth reaching out to, most urgent first. */ |
| 530 | signals(): Promise<Signal[]>; | |
| 531 | /** The business at a glance. */ | |
| 532 | overview(): Promise<Overview>; | |
| 533 | /** A workspace's sales record. */ | |
| 534 | sales(workspace: string): Promise<SalesRecord>; | |
| 535 | setSales(workspace: string, record: { stage: string; owner?: string | null; nextStep?: string | null; nextAt?: string | null }, by: string): Promise<Result<SalesRecord>>; | |
| 536 | addNote(workspace: string, text: string, by: string): Promise<Result<SalesRecord>>; | |
| 537 | /** A workspace's invoices from g1t, for staff. */ | |
| 538 | workspaceInvoices(workspace: string): Promise<WorkspaceInvoice[]>; | |
| Billing lists every invoice and every staff change; signals carry follow-ups | 539 | /** Every invoice g1t has sent, newest first. */ |
| 540 | allInvoices(filter?: { status?: string; month?: string }): Promise<InvoiceSummary[]>; | |
| 541 | /** Every change made in sudo and by Stripe, newest first, 100 at a time. */ | |
| 542 | audit(filter?: { by?: string; action?: string; before?: string }): Promise<AdminAction[]>; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 543 | /** Limit and overage requests, with each workspace's history; `open` by default. */ |
| 544 | limitRequests(status?: "open" | "approved" | "declined" | "all"): Promise<LimitRequestReview[]>; | |
| 545 | /** Approve (at the amount asked, or another) or decline; the owner is told in the app and by email. */ | |
| 546 | decideLimitRequest(id: string, decision: "approve" | "decline", amountMicros: number | null, note: string, by: string): Promise<Result<LimitRequest>>; | |
| 547 | /** The Overages queue. */ | |
| 548 | overages(): Promise<Overage[]>; | |
| 549 | /** A goodwill credit; no amount is the one-click credit. Larger, or a second in 12 months, needs a reason. */ | |
| 550 | goodwill(workspace: string, amountMicros: number | null, reason: string, by: string, day?: string | null): Promise<Result<LedgerEntry>>; | |
| 551 | /** Workspaces spending in the last day, fastest first. */ | |
| 552 | velocity(): Promise<Velocity[]>; | |
| 553 | /** Money that reached g1t outside the card pages, such as a bank transfer: entered as a payment. */ | |
| 554 | recordPayment(workspace: string, amountMicros: number, reference: string, note: string, by: string): Promise<Result<LedgerEntry>>; | |
| Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily | 555 | /** Costs & margin: Cloudflare's bill against what g1t charged, over the last `days` (7 to 90, 30 by default). */ |
| 556 | costs(days?: number): Promise<CostsReport>; | |
| 557 | /** The open margin alerts, for the banner on every page. */ | |
| 558 | costAlerts(): Promise<MarginAlert[]>; | |
| Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays | 559 | /** g1t's own spend against its caps: the daily breaker and comped budgets. */ |
| 560 | spendCaps(): Promise<SpendCaps>; | |
| 561 | /** Lets hosted-model runs start again for the rest of today (UTC); needs a note. */ | |
| 562 | liftBreaker(note: string, by: string): Promise<Result<SpendCaps>>; | |
| Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily | 563 | /** Approve or reject a price proposal; a rejection needs a note. An approved rise waits out the notice period. */ |
| 564 | decideProposal(id: string, decision: "approve" | "reject", note: string, by: string): Promise<Result<PriceProposal>>; | |
| 565 | setCostSettings(settings: CostSettings, by: string): Promise<Result<CostSettings>>; | |
| 566 | setCostMapping(mapping: CostMappingInput, by: string): Promise<Result<CostMapping>>; | |
| 567 | /** Reads Cloudflare's bill and reconciles now, as the daily run does. */ | |
| 568 | runCosts(by: string): Promise<Result<CostsRun>>; | |
| Billing accounts, terms and enterprises; g1t is no longer free | 569 | } |
| 570 | ||
| Usage limits: unpaid usage can only go so far | 571 | /** How much a workspace has earned g1t's trust with money. */ |
| Two limits, real invoices, trust that grows by itself, sales signals | 572 | export type Trust = "new" | "paid" | "established" | "reviewed" | "internal"; |
| Usage limits: unpaid usage can only go so far | 573 | |
| 574 | /** | |
| 575 | * How far a workspace's unpaid usage has gone this month, and where its | |
| 576 | * work stops: past `ceilingMicros`, no new sandboxes, builds or app | |
| 577 | * requests. Usage counts at its cost to g1t or its charge, whichever is | |
| 578 | * more, so it counts while g1t is free too. | |
| 579 | */ | |
| 580 | export type Limit = { | |
| 581 | workspace: string; | |
| Billing accounts, terms and enterprises; g1t is no longer free | 582 | /** The account that pays: the workspace's own (`ws_<slug>`), or its enterprise's. */ |
| 583 | account: string; | |
| 584 | accountName: string; | |
| Usage limits: unpaid usage can only go so far | 585 | trust: Trust; |
| 586 | exposureMicros: number; | |
| 587 | /** The lower of g1t's ceiling and the owner's spend limit; null for g1t's own. */ | |
| 588 | ceilingMicros: number | null; | |
| 589 | trustCeilingMicros: number | null; | |
| 590 | spendLimitMicros: number | null; | |
| 591 | state: "ok" | "warning" | "stopped"; | |
| 592 | message: string | null; | |
| Two limits, real invoices, trust that grows by itself, sales signals | 593 | /** Charged this month: what the spend limit is measured against. */ |
| 594 | spentMicros?: number; | |
| 595 | /** True while the owners have not chosen a limit, so the automatic one applies: $200, or twice last month's spend. */ | |
| 596 | defaultSpendLimit?: boolean; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 597 | /** The most owners may set their own limit to without asking: the highest ceiling ever, plus what is prepaid. */ |
| Two limits, real invoices, trust that grows by itself, sales signals | 598 | availableMicros?: number | null; |
| 599 | /** How the ceiling grows from here, in a sentence. */ | |
| 600 | growth?: string | null; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 601 | /** Paid in advance and not used yet; raises what can be used before work stops by as much. */ |
| 602 | prepaidMicros?: number; | |
| 603 | /** The highest ceiling the workspace has had. */ | |
| 604 | maxCeilingMicros?: number | null; | |
| 605 | /** The most owners may raise the limit to themselves, once: twice the highest ceiling. Null once used. */ | |
| 606 | raiseOnceMicros?: number | null; | |
| 607 | /** When the one-time raise was used. */ | |
| 608 | raisedAt?: string | null; | |
| 609 | /** A paid workspace's first billing cycle, on the starting ceiling. */ | |
| 610 | firstMonth?: boolean; | |
| Usage limits: unpaid usage can only go so far | 611 | }; |
| 612 | ||
| Prices keep themselves current with what g1t pays | 613 | /** One metered unit: what it costs g1t and what it is sold at; the price follows the cost. */ |
| 614 | export type Price = { | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 615 | meter: |
| 616 | | "sandbox_second" | |
| 617 | | "build_second" | |
| 618 | | "app_requests" | |
| 619 | | "app_cpu" | |
| 620 | | "app_month" | |
| 621 | | "custom_domain_month" | |
| 622 | | "private_storage" | |
| 623 | | "embedding_tokens" | |
| 624 | | "scan_cpu" | |
| 625 | | "scan_rows" | |
| 626 | | string; | |
| Prices keep themselves current with what g1t pays | 627 | title: string; |
| 628 | unit: string; | |
| 629 | costMicros: number; | |
| 630 | markupPercent: number; | |
| 631 | priceMicros: number; | |
| 632 | /** `list`: Cloudflare's published price. `cloudflare`: measured from Cloudflare's bill. */ | |
| 633 | source: "list" | "cloudflare" | string; | |
| 634 | checkedAt: string | null; | |
| 635 | updatedAt: string; | |
| 636 | }; | |
| 637 | ||
| 638 | export type PriceChange = { | |
| 639 | meter: string; | |
| 640 | oldCostMicros: number; | |
| 641 | newCostMicros: number; | |
| 642 | markupPercent: number; | |
| Prices are what g1t pays plus 20%, from the first second | 643 | /** The markup before, when the change was to the markup rather than the cost. */ |
| 644 | oldMarkupPercent?: number; | |
| Prices keep themselves current with what g1t pays | 645 | reason: string; |
| 646 | createdAt: string; | |
| Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily | 647 | /** When a change still to come takes effect: a rise is announced before it is charged. */ |
| 648 | effectiveAt?: string; | |
| Prices keep themselves current with what g1t pays | 649 | }; |
| 650 | ||
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 651 | export type PriceBook = { |
| 652 | prices: Price[]; | |
| 653 | changes: PriceChange[]; | |
| 654 | modelMarginPercent: number; | |
| 655 | /** Every plan, as sold now. */ | |
| 656 | plans?: FeaturePlan[]; | |
| 657 | /** What is free, and the capped budgets that pay for it. */ | |
| 658 | free?: FreeTier | null; | |
| 659 | }; | |
| Prices keep themselves current with what g1t pays | 660 | |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 661 | /** One kind of meter's usage this month, from `usage_meters`. */ |
| 662 | export type MeterUsage = { | |
| 663 | /** `agents`, `builds`, `requests`, `domains`, `git_storage` or `search_scans`. */ | |
| 664 | key: string; | |
| 665 | label: string; | |
| 666 | /** At price (cost plus 20%, on the account's terms), before what paid for it. */ | |
| 667 | micros: number; | |
| 668 | /** How much, when it is known: `12 runs`, `41 build minutes`. */ | |
| 669 | quantity?: string | null; | |
| 670 | }; | |
| 671 | ||
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 672 | /** What g1t gives without a plan; each is paid for by a capped budget. */ |
| 673 | export type FreeTier = { | |
| 674 | /** Each new workspace's trial credit, once. */ | |
| 675 | trialWorkspaceMicros: number; | |
| 676 | /** Trial grants each month, in all; new trials wait when it is spent. */ | |
| 677 | trialMonthlyPoolMicros: number; | |
| 678 | /** g1t's open-source pool each month, and any one repository's share. */ | |
| 679 | ossPoolMicros: number; | |
| 680 | ossRepoMicros: number; | |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 681 | /** Private repository storage free for every workspace. Past it, the plan pays; a free workspace's pushes stop. */ |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 682 | freePrivateStorageBytes: number; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 683 | /** Days of audit log, the same on every plan. */ |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 684 | auditRetentionDays: number; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 685 | /** The smallest amount a card is charged when a month closes; less carries over. */ |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 686 | minChargeMicros: number; |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 687 | /** Git operations free for every workspace each month. Past it, the plan pays; a free workspace is slowed down. */ |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 688 | gitOperationsIncluded?: number; |
| 689 | /** A new paid workspace's ceiling in its first month. */ | |
| 690 | paidStartCeilingMicros?: number; | |
| 691 | /** The most a one-click goodwill credit can cost g1t. */ | |
| 692 | overageForgiveCostMicros?: number; | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 693 | }; |
| 694 | ||
| 695 | /** | |
| 696 | * A workspace's trial credit: one grant per workspace, made the first time | |
| 697 | * it uses something, out of a pool that resets each calendar month. Mirrors | |
| 698 | * `Trial` in `crates/contracts/src/billing.rs`. | |
| 699 | */ | |
| A free allowance on g1t's models, so anyone can try its agents | 700 | export type Trial = { |
| 701 | open: boolean; | |
| 702 | usedMicros: number; | |
| 703 | limitMicros: number; | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 704 | /** No longer used: trials do not end on a date. */ |
| A free allowance on g1t's models, so anyone can try its agents | 705 | endsAt: string | null; |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 706 | /** Why it is closed: `off`, `used` (this workspace's grant is spent) or `pool` (this month's are given out). */ |
| A free allowance on g1t's models, so anyone can try its agents | 707 | reason: "off" | "ended" | "used" | "pool" | null; |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 708 | /** Whether the workspace has its grant already. */ |
| 709 | granted?: boolean; | |
| 710 | /** With `pool`: when new trials start again, the first of next month. */ | |
| 711 | waitsUntil?: string | null; | |
| A free allowance on g1t's models, so anyone can try its agents | 712 | }; |
| 713 | ||
| Paid features: a workspace turns on Deployments with a monthly plan | 714 | /** |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 715 | * What a workspace pays a monthly price for: the g1t plan (`plan`). Deployments |
| 716 | * are part of it; `has_feature` for `deployments` answers whether the workspace | |
| 717 | * has the plan. Mirrors `Feature` in `crates/contracts/src/billing.rs`. | |
| Paid features: a workspace turns on Deployments with a monthly plan | 718 | */ |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 719 | export type Feature = "plan" | "deployments"; |
| Paid features: a workspace turns on Deployments with a monthly plan | 720 | |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 721 | /** |
| 722 | * What deployments cost g1t, in millionths of a dollar: fallbacks for when | |
| 723 | * billing's price book cannot be read. Not an allowance: on the plan every | |
| 724 | * unit is metered from the first, at cost plus 20%, and drawn from the | |
| 725 | * plan's included usage first. Projects, previews and the apps behind them | |
| 726 | * are not metered at all. Mirrors `deployment_costs`. | |
| 727 | */ | |
| 728 | export const DEPLOYMENT_COSTS = { | |
| Paid features: a workspace turns on Deployments with a monthly plan | 729 | microsPerMillionRequests: 300_000, |
| 730 | microsPerMillionCpuMs: 20_000, | |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 731 | /** One second of a build's sandbox: a fallback; billing charges the price book's `build_second`. */ |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 732 | microsPerBuildSecond: 15, |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 733 | /** One custom domain for a month. */ |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 734 | microsPerDomainMonth: 100_000, |
| Paid features: a workspace turns on Deployments with a monthly plan | 735 | } as const; |
| 736 | ||
| 737 | export type FeaturePlan = { | |
| 738 | feature: Feature; | |
| 739 | title: string; | |
| 740 | /** Charged every month while the plan is on, in cents. */ | |
| 741 | monthlyCents: number; | |
| 742 | /** What the price includes, one line each. */ | |
| 743 | includes: string[]; | |
| 744 | /** How usage past the allowance is charged. */ | |
| 745 | overage: string; | |
| 746 | }; | |
| 747 | ||
| 748 | export type SubscriptionStatus = "active" | "canceling" | "past_due" | "canceled"; | |
| 749 | ||
| 750 | export type Subscription = { | |
| 751 | feature: Feature; | |
| 752 | status: SubscriptionStatus; | |
| 753 | /** RFC 3339: when the period paid for ends. */ | |
| 754 | periodEnd: string | null; | |
| 755 | startedBy: string; | |
| 756 | startedAt: string; | |
| 757 | }; | |
| 758 | ||
| 759 | /** A feature as a workspace sees it. */ | |
| 760 | export type FeatureState = { | |
| 761 | plan: FeaturePlan; | |
| 762 | subscription: Subscription | null; | |
| 763 | /** Whether the feature works for the workspace now. */ | |
| 764 | on: boolean; | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 765 | /** On without a plan: comped terms, or given by g1t. Nothing to pay or turn off. */ |
| 766 | included?: boolean; | |
| Paid features: a workspace turns on Deployments with a monthly plan | 767 | }; |
| 768 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 769 | export interface BillingApi { |
| 770 | status(): Promise<BillingStatus>; | |
| 771 | /** Members of the workspace only. */ | |
| 772 | account(workspace: string, viewer: Viewer): Promise<Result<BillingAccount>>; | |
| 773 | /** Newest first. Members of the workspace only. */ | |
| 774 | ledger(workspace: string, viewer: Viewer): Promise<Result<LedgerEntry[]>>; | |
| The statement is a month at a time, a line per kind of charge | 775 | /** A month of the ledger, grouped by `day` (default) or `project`. Members only. */ |
| 776 | statement(workspace: string, viewer: Viewer, month?: string | null, group?: "day" | "project"): Promise<Result<Statement>>; | |
| 777 | /** One statement line's entries, 50 at a time; `before` is the last id seen. */ | |
| 778 | statementEntries( | |
| 779 | workspace: string, | |
| 780 | viewer: Viewer, | |
| 781 | filter: { month: string; kind: string; day?: string | null; project?: string | null; before?: string | null }, | |
| 782 | ): Promise<Result<LedgerEntry[]>>; | |
| Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request | 783 | /** What the workspace's agents cost since `since`, broken down. Members only. */ |
| 784 | usage(workspace: string, viewer: Viewer, since: string): Promise<Result<Usage>>; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 785 | /** |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 786 | * Prepays usage ($25 at least) and returns the page to send the person to: |
| 787 | * by card with 3-D Secure, or by bank transfer from $1,000. Owners only. | |
| 788 | * The payment's id comes back to `returnUrl` as `session`. | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 789 | */ |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 790 | checkout( |
| 791 | actor: User, | |
| 792 | workspace: string, | |
| 793 | amountCents: number, | |
| 794 | returnUrl: string, | |
| 795 | method?: "card" | "bank_transfer", | |
| 796 | ): Promise<Result<{ url: string }>>; | |
| Billing on Stripe's pages, month-end charges, warnings; sudo by workspace | 797 | /** |
| 798 | * Stripe's hosted billing page for the workspace: card, invoices, billing | |
| 799 | * email and address. g1t never handles card numbers. Owners only. | |
| 800 | */ | |
| 801 | billingPortal(actor: User, workspace: string, returnUrl: string): Promise<Result<{ url: string }>>; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 802 | /** Credits a payment once the processor says it was made. Safe to repeat. */ |
| 803 | confirm(workspace: string, viewer: Viewer, session: string): Promise<Result<BillingAccount>>; | |
| 804 | /** | |
| 805 | * Whether a workspace may start an agent now, asked before anything is | |
| 806 | * opened for it. A failure, with the reason to show, when it has no credit. | |
| 807 | */ | |
| 808 | canStart(workspace: string): Promise<Result<boolean>>; | |
| A free allowance on g1t's models, so anyone can try its agents | 809 | /** A workspace's free allowance on g1t's hosted models; `exempt` are open to them anyway. */ |
| 810 | trial(workspace: string, exempt: string[]): Promise<Trial>; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 811 | /** |
| 812 | * Asks whether a workspace may start an agent and opens the run it will be | |
| 813 | * charged for. Null when billing is off; a failure when there is no credit. | |
| 814 | */ | |
| Paid features: a workspace turns on Deployments with a monthly plan | 815 | /** Every paid feature and the workspace's plan for each. Members only. */ |
| 816 | features(workspace: string, viewer: Viewer): Promise<Result<FeatureState[]>>; | |
| 817 | /** | |
| 818 | * Starts the card page for a feature's monthly plan. Owners only. The | |
| 819 | * page's id comes back to `returnUrl` as `session`. | |
| 820 | */ | |
| 821 | subscribe(actor: User, workspace: string, feature: Feature, returnUrl: string): Promise<Result<{ url: string }>>; | |
| 822 | /** Turns the feature on once the plan is paid for. Safe to repeat. */ | |
| 823 | confirmSubscription(workspace: string, viewer: Viewer, session: string): Promise<Result<FeatureState>>; | |
| 824 | /** Ends a plan at the end of its period, or (`resume`) takes that back. Owners only. */ | |
| 825 | cancelSubscription(actor: User, workspace: string, feature: Feature, resume?: boolean): Promise<Result<FeatureState>>; | |
| 826 | /** Whether a feature works for a workspace now; a failure with the reason when not. */ | |
| 827 | hasFeature(workspace: string, feature: Feature): Promise<Result<boolean>>; | |
| 828 | /** | |
| 829 | * Usage past a plan's allowance, charged from credit at cost plus the | |
| 830 | * margin, once per `reference`. False if it was charged before. | |
| 831 | */ | |
| 832 | chargeFeature(charge: { | |
| 833 | workspace: string; | |
| 834 | feature: Feature; | |
| 835 | costMicros: number; | |
| 836 | description: string; | |
| 837 | repo?: string | null; | |
| 838 | reference: string; | |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 839 | /** For a build: how long it ran, so the plan's included build time pays for what it can. */ |
| 840 | buildSeconds?: number | null; | |
| Paid features: a workspace turns on Deployments with a monthly plan | 841 | }): Promise<Result<boolean>>; |
| Prices keep themselves current with what g1t pays | 842 | /** |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 843 | * What a source cost g1t so far this month, so the workspace's limit |
| 844 | * counts it now. Replaces the last report. Billing charges `context` | |
| 845 | * and `security` itself once the month is over; `deployments` charges | |
| 846 | * its own. | |
| Prices keep themselves current with what g1t pays | 847 | */ |
| status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas | 848 | notePending( |
| 849 | workspace: string, | |
| 850 | source: "deployments" | "domains" | "context" | "security", | |
| 851 | costMicros: number, | |
| 852 | /** How much of it, for the Billing page: `1.2 million requests and 3.4 million CPU ms`. */ | |
| 853 | detail?: string | null, | |
| 854 | ): Promise<boolean>; | |
| 855 | /** | |
| 856 | * This month's usage, one line per kind of meter, at what it is charged | |
| 857 | * before the plan's included usage or a pool paid for it. Members only. | |
| 858 | */ | |
| 859 | usageMeters(workspace: string, viewer: Viewer): Promise<Result<MeterUsage[]>>; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 860 | /** What the workspace may do now: its plan, caps, pause, trial, and what the plan gives it. */ |
| Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put | 861 | entitlements(workspace: string): Promise<Entitlements>; |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 862 | /** |
| 863 | * Holds a start's estimated cost before the work starts. A failure's code says why not: | |
| 864 | * `paused`, `limit`, `not_paid`, `trial_used` or `oss_pool_empty`, with a message for the owner. | |
| 865 | */ | |
| 866 | reserve(reservation: { | |
| 867 | workspace: string; | |
| 868 | repo: RepoPath; | |
| 869 | public: boolean; | |
| 870 | kind: ComputeKind; | |
| 871 | /** The most the work is expected to cost g1t, before the margin. */ | |
| 872 | estimateMicros: number; | |
| 873 | }): Promise<Result<ReservationHeld>>; | |
| 874 | /** Releases a reservation's hold with what the work cost g1t, before the margin. Safe to repeat. */ | |
| 875 | settle(reservationId: string, actualMicros: number): Promise<Result<boolean>>; | |
| 876 | /** Stripe's page to save and verify a card (3-D Secure, never charged). Owners only. */ | |
| 877 | cardCheck(actor: User, workspace: string, returnUrl: string): Promise<Result<{ url: string }>>; | |
| 878 | /** Records the card check once Stripe says it passed, and grants the trial if it can. Safe to repeat. */ | |
| 879 | confirmCardCheck(workspace: string, viewer: Viewer, session: string): Promise<Result<Entitlements>>; | |
| 880 | /** An owner asks for a higher limit, or for help with usage past what was meant. */ | |
| 881 | requestLimit( | |
| 882 | actor: User, | |
| 883 | workspace: string, | |
| 884 | request: { kind: "limit" | "overage"; amountMicros: number; reason: string; expectedMonthlyMicros: number }, | |
| 885 | ): Promise<Result<LimitRequest>>; | |
| 886 | /** The workspace's requests and their answers, newest first. Members only. */ | |
| 887 | limitRequests(workspace: string, viewer: Viewer): Promise<Result<LimitRequest[]>>; | |
| 888 | /** | |
| 889 | * The owners' own caps on agents: one run's spend ($0.10 to $100) and one issue's ($1 to $1,000). | |
| 890 | * Null goes back to the default ($2 and $10). A cap staff set wins. Owners only. | |
| 891 | */ | |
| 892 | setCaps(actor: User, workspace: string, caps: { runCapMicros: number | null; issueCapMicros: number | null }): Promise<Result<Entitlements>>; | |
| 893 | /** An owner's answer to a spend spike: keep going for 24 hours, or stop. */ | |
| 894 | confirmSpike(actor: User, workspace: string, keepGoing: boolean): Promise<Result<Entitlements>>; | |
| Prices keep themselves current with what g1t pays | 895 | /** Every metered price and the recent changes. Public. */ |
| 896 | prices(): Promise<PriceBook>; | |
| Usage limits: unpaid usage can only go so far | 897 | /** A workspace's limit, for its members. */ |
| 898 | limit(workspace: string, viewer: Viewer): Promise<Result<Limit>>; | |
| 899 | /** The same, for the services that enforce it. */ | |
| 900 | checkLimit(workspace: string): Promise<Result<Limit>>; | |
| Every sandbox is metered by the second | 901 | /** |
| Two limits, real invoices, trust that grows by itself, sales signals | 902 | * The owners' own monthly limit, up to what is available; null goes back |
| 903 | * to the default, and `useFullLimit` uses everything available. Owners only. | |
| 904 | */ | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 905 | setSpendLimit( |
| 906 | actor: User, | |
| 907 | workspace: string, | |
| 908 | spendLimitMicros: number | null, | |
| 909 | useFullLimit?: boolean, | |
| 910 | /** Use the one-time raise: up to twice the highest ceiling, once per workspace. */ | |
| 911 | raiseOnce?: boolean, | |
| 912 | ): Promise<Result<Limit>>; | |
| Two limits, real invoices, trust that grows by itself, sales signals | 913 | /** The workspace's invoices from g1t, newest first. Members only. */ |
| 914 | invoices(workspace: string, viewer: Viewer): Promise<Result<WorkspaceInvoice[]>>; | |
| 915 | /** | |
| Every sandbox is metered by the second | 916 | * How long a sandbox ran for a workspace, reported when it stops. Its |
| Prices are what g1t pays plus 20%, from the first second | 917 | * cost is recorded and every second is charged, from the first. False if |
| 918 | * `reference` was recorded before. | |
| Every sandbox is metered by the second | 919 | */ |
| 920 | recordSandbox(usage: { | |
| 921 | workspace: string; | |
| 922 | seconds: number; | |
| 923 | description: string; | |
| 924 | repo?: string | null; | |
| 925 | reference: string; | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 926 | /** What ran; checks, workflows and the merge queue on public repositories may use the open-source pool. */ |
| 927 | kind?: ComputeKind | null; | |
| 928 | /** vCPU-seconds used, when the sandbox can tell: the run is priced on its own CPU. */ | |
| 929 | cpuSeconds?: number | null; | |
| 930 | /** The reservation it started under, settled with this cost. */ | |
| 931 | reservationId?: string | null; | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 932 | /** It ran on one of the workspace's self-hosted runners: its minutes go on usage at $0. */ |
| 933 | selfHosted?: boolean; | |
| 934 | /** The machine it ran on, by label (`g1t-4core`); absent, the standard one. */ | |
| 935 | instance?: string | null; | |
| Every sandbox is metered by the second | 936 | }): Promise<Result<boolean>>; |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 937 | startRun(run: { |
| 938 | workspace: string; | |
| 939 | repo: RepoPath; | |
| 940 | number: number; | |
| 941 | task: string; | |
| 942 | model: string; | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 943 | /** `workspace` when the run uses the workspace's own model provider. */ |
| 944 | billedTo?: "g1t" | "workspace"; | |
| Prices keep themselves current with what g1t pays | 945 | /** The model session's id, so the run can be settled at AI Gateway's price. */ |
| 946 | session?: string | null; | |
| Auto model routing: the cheapest tier that can do each piece of work, a retry goes up a tier, and each run records its tier | 947 | /** `small` or `large`: the tier g1t routed the run to, on its hosted models. */ |
| 948 | tier?: "small" | "large" | null; | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 949 | }): Promise<Result<RunTicket | null>>; |
| 950 | } | |
| Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request | 951 | |
| 952 | ||
| 953 | /** One slice of usage: what it was for, what it cost, how many runs. */ | |
| 954 | export type UsageSlice = { key: string; micros: number; runs: number }; | |
| 955 | ||
| 956 | /** What a workspace's agents cost over a period. */ | |
| 957 | export type Usage = { | |
| 958 | since: string; | |
| 959 | /** Charged, including g1t's margin. */ | |
| 960 | spentMicros: number; | |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 961 | /** What g1t's model provider charged, before the margin. */ |
| Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request | 962 | costMicros: number; |
| Integrations: your own model provider, alerts that open issues, tickets agents read | 963 | /** What runs on the workspace's own provider cost there, estimated. Not charged by g1t. */ |
| 964 | providerMicros: number; | |
| Usage while free is shown at cost; agents get rustfmt and clippy | 965 | /** What the runs used, at cost: g1t's models and the workspace's own provider together. */ |
| 966 | usedMicros: number; | |
| 967 | /** g1t charges nothing for now; the slices then measure usage at cost. */ | |
| 968 | free: boolean; | |
| Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request | 969 | runs: number; |
| 970 | /** Spend per day and task, keyed `YYYY-MM-DD/task`. */ | |
| 971 | byDay: UsageSlice[]; | |
| 972 | byTask: UsageSlice[]; | |
| 973 | byRepo: UsageSlice[]; | |
| 974 | /** Keyed `namespace/name#number`. */ | |
| 975 | byPull: UsageSlice[]; | |
| 976 | byModel: UsageSlice[]; | |
| 977 | /** Credit bought in the period. */ | |
| 978 | addedMicros: number; | |
| 979 | }; | |
| Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily | 980 | |
| 981 | /** One of g1t's products (a "bucket") on one day. Money in micros. */ | |
| 982 | export type CostDay = { day: string; bucket: string; cfCostMicros: number; ownCostMicros: number; valueMicros: number; cashMicros: number }; | |
| 983 | ||
| 984 | /** One product over the range: what customers were charged at price against what it cost. */ | |
| 985 | export type ProductMargin = { | |
| 986 | bucket: string; | |
| 987 | title: string; | |
| 988 | /** Cloudflare's bill, or g1t's own figure where Cloudflare does not bill it (`costSource`). */ | |
| 989 | costMicros: number; | |
| 990 | cfCostMicros: number; | |
| 991 | ownCostMicros: number; | |
| 992 | valueMicros: number; | |
| 993 | marginMicros: number; | |
| 994 | marginPercent: number | null; | |
| 995 | costSource: "cloudflare" | "ledger" | string; | |
| 996 | /** Running g1t, paid for by the plan. */ | |
| 997 | overhead: boolean; | |
| 998 | }; | |
| 999 | ||
| 1000 | /** All of g1t: money in (usage and the plan) against every cost. */ | |
| 1001 | export type OverallMargin = { usageMicros: number; plansMicros: number; costMicros: number; marginMicros: number; marginPercent: number | null }; | |
| 1002 | ||
| 1003 | /** A count, cost or leak that does not add up. */ | |
| 1004 | export type CostDrift = { | |
| 1005 | bucket: string; | |
| 1006 | title: string; | |
| 1007 | kind: "count" | "cost" | "leak" | string; | |
| 1008 | ours: number; | |
| 1009 | cloudflare: number; | |
| 1010 | deltaPercent: number | null; | |
| 1011 | detail: string; | |
| 1012 | foundAt: string; | |
| 1013 | }; | |
| 1014 | ||
| 1015 | export type MarginAlert = { | |
| 1016 | id: string; | |
| 1017 | kind: "margin" | "overall" | "leak" | "drift" | "workspace" | string; | |
| 1018 | /** The product, or the workspace. */ | |
| 1019 | subject: string; | |
| 1020 | detail: string; | |
| 1021 | since: string; | |
| 1022 | openedAt: string; | |
| 1023 | emailedAt: string | null; | |
| 1024 | }; | |
| 1025 | ||
| 1026 | /** A change to a price, measured from what Cloudflare charged. */ | |
| 1027 | export type PriceProposal = { | |
| 1028 | id: string; | |
| 1029 | meter: string; | |
| 1030 | title: string; | |
| 1031 | unit: string; | |
| 1032 | currentCostMicros: number; | |
| 1033 | proposedCostMicros: number; | |
| 1034 | changePercent: number; | |
| 1035 | markupPercent: number; | |
| 1036 | reason: string; | |
| 1037 | source: "keeper" | "reconciler" | string; | |
| 1038 | /** Far off the current cost: look before approving. */ | |
| 1039 | suspect: boolean; | |
| 1040 | status: "open" | "applied" | "approved" | "rejected" | "superseded" | string; | |
| 1041 | createdAt: string; | |
| 1042 | decidedAt: string | null; | |
| 1043 | decidedBy: string | null; | |
| 1044 | note: string | null; | |
| 1045 | effectiveAt: string | null; | |
| 1046 | }; | |
| 1047 | ||
| 1048 | /** One version of one meter's price; never changed once written. */ | |
| 1049 | export type PriceVersion = { | |
| 1050 | id: string; | |
| 1051 | meter: string; | |
| 1052 | version: number; | |
| 1053 | costMicros: number; | |
| 1054 | markupPercent: number; | |
| 1055 | priceMicros: number; | |
| 1056 | effectiveAt: string; | |
| 1057 | reason: string; | |
| 1058 | createdBy: string; | |
| 1059 | appliedAt: string | null; | |
| 1060 | }; | |
| 1061 | ||
| 1062 | export type WorkspaceCost = { workspace: string; costMicros: number; revenueMicros: number; internal: boolean }; | |
| 1063 | ||
| 1064 | export type CostLineSummary = { | |
| 1065 | product: string; | |
| 1066 | meter: string; | |
| 1067 | rawName: string; | |
| 1068 | unit: string; | |
| 1069 | source: string; | |
| 1070 | quantity: number; | |
| 1071 | costMicros: number; | |
| 1072 | /** Absent when no mapping claims it. */ | |
| 1073 | bucket: string | null; | |
| 1074 | }; | |
| 1075 | ||
| 1076 | export type CostMapping = { | |
| 1077 | product: string; | |
| 1078 | meter: string; | |
| 1079 | bucket: string; | |
| 1080 | priceMeter: string | null; | |
| 1081 | ownMeter: string | null; | |
| 1082 | scaleToOwn: boolean; | |
| 1083 | driftPercent: number; | |
| 1084 | note: string; | |
| 1085 | updatedAt: string; | |
| 1086 | updatedBy: string; | |
| 1087 | }; | |
| 1088 | ||
| 1089 | export type CostMappingInput = { | |
| 1090 | product: string; | |
| 1091 | meter: string; | |
| 1092 | bucket?: string; | |
| 1093 | priceMeter?: string | null; | |
| 1094 | ownMeter?: string | null; | |
| 1095 | scaleToOwn?: boolean; | |
| 1096 | driftPercent?: number | null; | |
| 1097 | note?: string; | |
| 1098 | remove?: boolean; | |
| 1099 | }; | |
| 1100 | ||
| 1101 | export type CostSettings = { | |
| 1102 | autoApply: boolean; | |
| 1103 | autoApplyPercent: number; | |
| 1104 | noticeDays: number; | |
| 1105 | marginFloorPercent: number; | |
| 1106 | alertDays: number; | |
| 1107 | minDailyCostMicros: number; | |
| 1108 | anomalyFactor: number; | |
| 1109 | anomalyFloorMicros: number; | |
| 1110 | }; | |
| 1111 | ||
| 1112 | export type CostsReport = { | |
| 1113 | configured: boolean; | |
| 1114 | fetchedAt: string | null; | |
| 1115 | since: string; | |
| 1116 | until: string; | |
| 1117 | days: CostDay[]; | |
| 1118 | products: ProductMargin[]; | |
| 1119 | overall: OverallMargin; | |
| 1120 | drift: CostDrift[]; | |
| 1121 | alerts: MarginAlert[]; | |
| 1122 | proposals: PriceProposal[]; | |
| 1123 | versions: PriceVersion[]; | |
| 1124 | topWorkspaces: WorkspaceCost[]; | |
| 1125 | lines: CostLineSummary[]; | |
| 1126 | mappings: CostMapping[]; | |
| 1127 | settings: CostSettings; | |
| Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays | 1128 | /** g1t's own spend against its two caps. */ |
| 1129 | caps: SpendCaps; | |
| 1130 | }; | |
| 1131 | ||
| 1132 | /** What g1t pays for itself, at cost, against its caps (billing's `budget`). */ | |
| 1133 | export type SpendCaps = { | |
| 1134 | /** Today (UTC), YYYY-MM-DD, and this month, YYYY-MM. */ | |
| 1135 | day: string; | |
| 1136 | month: string; | |
| 1137 | /** What g1t paid for itself today across every workspace. */ | |
| 1138 | todayMicros: number; | |
| 1139 | /** `PLATFORM_DAILY_SPEND_CAP_MICROS`; 0: no breaker. */ | |
| 1140 | dailyCapMicros: number; | |
| 1141 | /** New hosted-model agent runs g1t would pay for are paused. */ | |
| 1142 | tripped: boolean; | |
| 1143 | trippedAt: string | null; | |
| 1144 | liftedBy: string | null; | |
| 1145 | liftedAt: string | null; | |
| 1146 | liftNote: string | null; | |
| 1147 | /** This month so far, by what paid: comped, trial, oss, given, unpaid. */ | |
| 1148 | monthBuckets: { bucket: string; title: string; micros: number }[]; | |
| 1149 | comped: CompedBudget[]; | |
| 1150 | /** Free workspaces' share of reconciled costs this month (git, storage, platform). */ | |
| 1151 | freeTierMicros: number; | |
| 1152 | /** `CLOUDFLARE_FIXED_MONTHLY_MICROS`: Cloudflare subscriptions, an estimate. */ | |
| 1153 | fixedMonthlyMicros: number; | |
| 1154 | /** Money in this month, through the last reconciled day. */ | |
| 1155 | revenueMicros: number; | |
| 1156 | }; | |
| 1157 | ||
| 1158 | /** A comped account's monthly budget, at cost. */ | |
| 1159 | export type CompedBudget = { | |
| 1160 | account: string; | |
| 1161 | name: string; | |
| 1162 | usedMicros: number; | |
| 1163 | /** 0: no budget. */ | |
| 1164 | ceilingMicros: number; | |
| 1165 | /** `COMPED_MONTHLY_CEILING_MICROS`, not the account's own limit. */ | |
| 1166 | defaultCeiling: boolean; | |
| 1167 | /** 50, 75, 90, 100, or 0. */ | |
| 1168 | level: number; | |
| Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily | 1169 | }; |
| 1170 | ||
| 1171 | export type CostsRun = { lines: number; days: number; proposals: number; alerts: number; problems: string[] }; |