Skip to content
60 linesCodeBlameRaw

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.

Pricing says it plainly: models at the provider's price, the agent rate for what g1t runs around every model call (the gateway, secrets, routing, context and pass-through to your own provider, so your own keys too), everything else at cost plus 20%, your own runners free, no seats; Security and quality comes with the plan with no separate fee, and live activations end. Each agent has an effort setting, Auto to Max, with what a typical task has cost at each level, and Spend's Spend less, keep quality suggests a lower level only when the agent's own past work shows quality held, to apply or dismiss. The pricing, spend and agents guides say how.1/**
2 * Effort and suggestions, as the pages say them (components/effort.tsx).
3 * Pure, so it is tested on its own. Every cost
4 * shown comes from the agents service's measured sessions; a level an
5 * agent has not run at says so instead of a number.
6 */
7import type { AgentEffort, AgentEffortCosts, AgentRecommendation, AgentRecommendations, EffortCost, EffortLevel } from "@g1t/contracts";
8
Money is written one way. A single formatter turns millionths of a dollar into dollars, rounding half up on whole micros rather than on a float, so the same sum reads the same on every page: under a cent reads <$0.01 on a total and exactly nothing is $0.00, while the statement's lines, a session's receipt, the price book and an agent's effort costs carry up to four places where the fraction of a cent is the point; the six formatters that each rounded their own way are gone. This month is the calendar month in UTC from its first day to today everywhere, and billing counts the month's not-yet-closed usage in any range that reaches into the current month, so the top bar's pill, Spend, Home and Usage ask for the same days and get the same figure; Home now reads the usage report the others read instead of adding up statements. Usage's pending sentence says what of that usage the close will charge after the discount and included usage, which the billing API returns as pending_charged_micros. A reconciliation test holds the pill, Spend, Home and Usage to one number for one month. The usage and billing guide says how amounts are written and what this month means.9import { money } from "./money.ts";
Pricing says it plainly: models at the provider's price, the agent rate for what g1t runs around every model call (the gateway, secrets, routing, context and pass-through to your own provider, so your own keys too), everything else at cost plus 20%, your own runners free, no seats; Security and quality comes with the plan with no separate fee, and live activations end. Each agent has an effort setting, Auto to Max, with what a typical task has cost at each level, and Spend's Spend less, keep quality suggests a lower level only when the agent's own past work shows quality held, to apply or dismiss. The pricing, spend and agents guides say how.10
11export const EFFORT_OPTIONS: { key: AgentEffort; label: string; about: string }[] = [
12 { key: "auto", label: "Auto", about: "Picks per piece of work: medium, and high on a session someone has had to steer." },
13 { key: "low", label: "Low", about: "The fast tier, light reasoning, up to 5 steps a session. For routine work." },
14 { key: "medium", label: "Medium", about: "Starts where the work would, moderate reasoning, up to 8 steps a session." },
15 { key: "high", label: "High", about: "The standard tier or above, deep reasoning, up to 10 steps a session." },
16 { key: "max", label: "Max", about: "The most capable tier, the most reasoning, up to 12 steps a session." },
17];
18
19export function effortLabel(effort: AgentEffort | null | undefined): string {
20 return EFFORT_OPTIONS.find((o) => o.key === effort)?.label ?? "Auto";
21}
22
23/** An agent's setting from its routing; none is Auto. */
24export function effortSetting(routing: { effort?: AgentEffort } | null | undefined): AgentEffort {
25 const value = routing?.effort;
26 return EFFORT_OPTIONS.some((o) => o.key === value) ? (value as AgentEffort) : "auto";
27}
28
29/** One level's measured cost, or null when the agent has not run at it. */
30export function costAt(costs: AgentEffortCosts | null, level: EffortLevel): EffortCost | null {
31 const found = costs?.levels.find((l) => l.effort === level);
32 return found && found.sessions > 0 && found.typical_micros != null ? found : null;
33}
34
35/** What a setting has cost per typical task: "$0.42 a typical task, from 14 sessions", or why there is no figure. */
36export function costLine(costs: AgentEffortCosts | null, effort: AgentEffort): string {
37 if (!costs) return "Costs couldn't be read right now.";
38 // Auto runs as medium, and high once steered: its figure is medium's.
39 const level: EffortLevel = effort === "auto" ? "medium" : effort;
40 const at = costAt(costs, level);
41 const days = `in the last ${costs.window_days} days`;
42 if (!at) return effort === "auto" ? `No sessions at Medium ${days}, so no figure yet.` : `No sessions at ${effortLabel(effort)} ${days}, so no figure yet.`;
43 const sessions = `${at.sessions.toLocaleString("en-US")} session${at.sessions === 1 ? "" : "s"}`;
Money is written one way. A single formatter turns millionths of a dollar into dollars, rounding half up on whole micros rather than on a float, so the same sum reads the same on every page: under a cent reads <$0.01 on a total and exactly nothing is $0.00, while the statement's lines, a session's receipt, the price book and an agent's effort costs carry up to four places where the fraction of a cent is the point; the six formatters that each rounded their own way are gone. This month is the calendar month in UTC from its first day to today everywhere, and billing counts the month's not-yet-closed usage in any range that reaches into the current month, so the top bar's pill, Spend, Home and Usage ask for the same days and get the same figure; Home now reads the usage report the others read instead of adding up statements. Usage's pending sentence says what of that usage the close will charge after the discount and included usage, which the billing API returns as pending_charged_micros. A reconciliation test holds the pill, Spend, Home and Usage to one number for one month. The usage and billing guide says how amounts are written and what this month means.44 return `${money(at.typical_micros!, { precise: true })} a typical task${effort === "auto" ? " at Medium" : ""}, from ${sessions} ${days}`;
Pricing says it plainly: models at the provider's price, the agent rate for what g1t runs around every model call (the gateway, secrets, routing, context and pass-through to your own provider, so your own keys too), everything else at cost plus 20%, your own runners free, no seats; Security and quality comes with the plan with no separate fee, and live activations end. Each agent has an effort setting, Auto to Max, with what a typical task has cost at each level, and Spend's Spend less, keep quality suggests a lower level only when the agent's own past work shows quality held, to apply or dismiss. The pricing, spend and agents guides say how.45}
46
47/** "92%" of sessions finished with nobody stepping in, or empty. */
48export function acceptedLabel(cost: EffortCost | null): string {
49 return cost?.accepted_share != null ? `${Math.round(cost.accepted_share * 100)}%` : "";
50}
51
52/** What the open suggestions together would save a month. */
53export function totalSaving(recs: AgentRecommendations | null): number {
54 return (recs?.open ?? []).reduce((n, r) => n + (r.saving_month_micros ?? 0), 0);
55}
56
57/** "About $31 a month" from a suggestion's measured saving. */
58export function savingLabel(rec: Pick<AgentRecommendation, "saving_month_micros">): string {
59 return rec.saving_month_micros != null && rec.saving_month_micros > 0 ? `About ${money(rec.saving_month_micros)} a month` : "";
60}