@encoredigitalgroup/opencode 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/Quota/core/errors.d.ts +21 -0
  3. package/dist/lib/Quota/core/pace.d.ts +14 -0
  4. package/dist/lib/Quota/core/persist.d.ts +55 -0
  5. package/dist/lib/Quota/core/provider-source.d.ts +43 -0
  6. package/dist/lib/Quota/core/redact.d.ts +30 -0
  7. package/dist/lib/Quota/core/rows.d.ts +19 -0
  8. package/dist/lib/Quota/core/selection.d.ts +14 -0
  9. package/dist/lib/Quota/core/store.d.ts +99 -0
  10. package/dist/lib/Quota/core/types.d.ts +167 -0
  11. package/dist/lib/Quota/core/validate.d.ts +11 -0
  12. package/dist/lib/Quota/core/windows.d.ts +23 -0
  13. package/dist/lib/Quota/lib/accounting-format.d.ts +3 -0
  14. package/dist/lib/Quota/lib/anthropic.d.ts +113 -0
  15. package/dist/lib/Quota/lib/api-key-resolver.d.ts +124 -0
  16. package/dist/lib/Quota/lib/atomic-json.d.ts +13 -0
  17. package/dist/lib/Quota/lib/calendar-date.d.ts +14 -0
  18. package/dist/lib/Quota/lib/config-file-utils.d.ts +6 -0
  19. package/dist/lib/Quota/lib/config-write-target.d.ts +23 -0
  20. package/dist/lib/Quota/lib/cursor-pricing.d.ts +107 -0
  21. package/dist/lib/Quota/lib/display-sanitize.d.ts +11 -0
  22. package/dist/lib/Quota/lib/entries.d.ts +87 -0
  23. package/dist/lib/Quota/lib/env-template.d.ts +25 -0
  24. package/dist/lib/Quota/lib/file-lock.d.ts +20 -0
  25. package/dist/lib/Quota/lib/format-utils.d.ts +8 -0
  26. package/dist/lib/Quota/lib/home-dir-display.d.ts +6 -0
  27. package/dist/lib/Quota/lib/http.d.ts +95 -0
  28. package/dist/lib/Quota/lib/json-guards.d.ts +10 -0
  29. package/dist/lib/Quota/lib/modelsdev-pricing.d.ts +85 -0
  30. package/dist/lib/Quota/lib/openai.d.ts +65 -0
  31. package/dist/lib/Quota/lib/opencode-auth.d.ts +154 -0
  32. package/dist/lib/Quota/lib/opencode-config-files.d.ts +33 -0
  33. package/dist/lib/Quota/lib/opencode-db-path.d.ts +8 -0
  34. package/dist/lib/Quota/lib/opencode-runtime-paths.d.ts +16 -0
  35. package/dist/lib/Quota/lib/pricing-key.d.ts +55 -0
  36. package/dist/lib/Quota/lib/provider-availability.d.ts +12 -0
  37. package/dist/lib/Quota/lib/provider-metadata.d.ts +25 -0
  38. package/dist/lib/Quota/lib/provider-model-matching.d.ts +12 -0
  39. package/dist/lib/Quota/lib/provider-registration.d.ts +222 -0
  40. package/dist/lib/Quota/lib/quota-export-types.d.ts +102 -0
  41. package/dist/lib/Quota/lib/quota-export.d.ts +33 -0
  42. package/dist/lib/Quota/lib/quota-providers.d.ts +201 -0
  43. package/dist/lib/Quota/lib/resolved-auth-identity.d.ts +52 -0
  44. package/dist/lib/Quota/lib/runtime-provider-ids.d.ts +3 -0
  45. package/dist/lib/Quota/lib/token-buckets.d.ts +22 -0
  46. package/dist/lib/Quota/lib/types.d.ts +208 -0
  47. package/dist/lib/Quota/plugin.d.ts +8 -0
  48. package/dist/lib/Quota/providers/anthropic.d.ts +6 -0
  49. package/dist/lib/Quota/providers/contract.d.ts +104 -0
  50. package/dist/lib/Quota/providers/openai.d.ts +5 -0
  51. package/dist/lib/Quota/providers/registry.d.ts +6 -0
  52. package/dist/lib/Quota/providers/result-helpers.d.ts +37 -0
  53. package/dist/lib/Quota/providers/xai.d.ts +8 -0
  54. package/dist/lib/Quota/rpc.d.ts +50 -0
  55. package/dist/lib/Quota/settings/convert.d.ts +59 -0
  56. package/dist/lib/Quota/settings/file.d.ts +89 -0
  57. package/dist/lib/Quota/settings/index.d.ts +10 -0
  58. package/dist/lib/Quota/settings/live.d.ts +42 -0
  59. package/dist/lib/Quota/settings/schema.d.ts +638 -0
  60. package/dist/lib/Quota/tui/client.d.ts +56 -0
  61. package/dist/lib/Quota/tui/index.d.ts +5 -0
  62. package/dist/lib/Quota/tui/sidebar.d.ts +42 -0
  63. package/dist/lib/Quota/tui/theme.d.ts +43 -0
  64. package/dist/lib/Quota/view/columns.d.ts +14 -0
  65. package/dist/lib/Quota/view/format.d.ts +80 -0
  66. package/dist/lib/Quota/view/row-facts.d.ts +52 -0
  67. package/dist/lib/Quota/view/select.d.ts +68 -0
  68. package/dist/lib/Quota/view/text.d.ts +160 -0
  69. package/dist/server/index.js +9112 -35
  70. package/dist/tui/index.js +5916 -213
  71. package/package.json +7 -3
  72. package/dist/lib/FilePickerCommands.test.d.ts +0 -1
  73. package/dist/lib/TodoTracker.test.d.ts +0 -1
  74. package/dist/package.integration.test.d.ts +0 -1
  75. package/dist/server/index.test.d.ts +0 -1
  76. package/dist/tui/index.test.d.ts +0 -1
@@ -0,0 +1,42 @@
1
+ import type { JSX } from "@opentui/solid";
2
+ import type { Surface } from "../view/select.js";
3
+ import { type Line } from "../view/text.js";
4
+ import type { QuotaClient } from "./client.js";
5
+ import type { Settings } from "../settings/schema.js";
6
+ import { type Theme } from "./theme.js";
7
+ /** What the quota window's Settings tabs tell the surfaces while you edit them. */
8
+ export type SurfaceEditing = {
9
+ /** The provider or row id selected on the tab that edits `surface`; that surface marks it. */
10
+ marked(surface: Surface): string | undefined;
11
+ /** The Sidebar tab shows the panel expanded, the Collapsed tab collapsed. */
12
+ panelOpen(): boolean | undefined;
13
+ /** A sidebar panel is on screen until the returned function runs. */
14
+ sidebarShown(): () => void;
15
+ /** Some sidebar panel is on screen. */
16
+ sidebarOnScreen(): boolean;
17
+ /** The Settings tab of `surface` is open. */
18
+ tabOpen(surface: Surface): boolean;
19
+ };
20
+ /** What every always-on surface reads. */
21
+ export type SurfaceHost = {
22
+ theme: () => Theme;
23
+ /**
24
+ * The saved display settings, or the draft while the Settings tabs edit it. Surfaces take
25
+ * their words from here, so unsaved words show while you edit them.
26
+ */
27
+ display: () => Settings;
28
+ quota: QuotaClient;
29
+ editing: SurfaceEditing;
30
+ };
31
+ /** One line of a surface, each segment in its color. A marked line has a soft background. */
32
+ export declare function LineText(props: {
33
+ line: Line;
34
+ host: SurfaceHost;
35
+ marked?: boolean;
36
+ }): JSX.Element;
37
+ export declare function SidebarPanel(props: {
38
+ host: SurfaceHost;
39
+ sessionID: string;
40
+ open: () => boolean;
41
+ setOpen: (open: boolean) => void;
42
+ }): JSX.Element;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Quota's colors from the user's OpenCode theme. Every color role follows a named theme color
3
+ * unless the display settings pick another one or a fixed "#rrggbb". The theme is read on every
4
+ * call, so a surface that colors inside its JSX follows a theme or light/dark switch at once.
5
+ */
6
+ import { RGBA } from "@opentui/core";
7
+ import type { Settings } from "../settings/schema.js";
8
+ import type { ColorRole, Segment } from "../view/text.js";
9
+ type ColorChoice = NonNullable<Settings["colors"]["good"]>;
10
+ type ColorName = Exclude<ColorChoice, "bar" | `#${string}`>;
11
+ /** The theme tokens quota reads (OpenCode's `ResolvedTheme`). */
12
+ export type Theme = {
13
+ text: {
14
+ base: RGBA;
15
+ muted: RGBA;
16
+ /** The label of the line the Settings tabs have selected, on a surface. */
17
+ action: {
18
+ primary: {
19
+ selected: RGBA;
20
+ };
21
+ };
22
+ feedback: Record<"success" | "warning" | "error" | "info", {
23
+ base: RGBA;
24
+ }>;
25
+ };
26
+ /** Behind the line the Settings tabs have selected, on a surface. */
27
+ background: {
28
+ raised: {
29
+ high: RGBA;
30
+ };
31
+ };
32
+ hue: {
33
+ accent: Record<number, RGBA>;
34
+ };
35
+ };
36
+ export declare function namedColor(theme: Theme, name: ColorName): RGBA;
37
+ /** The bar color for a remaining percent: low, high, or nearly complete usage. */
38
+ export declare function levelColor(theme: Theme, display: Settings, percent: number): RGBA;
39
+ /** A role's color. A role set to "bar" takes the level color of the row's percent. */
40
+ export declare function roleColor(theme: Theme, display: Settings, role: ColorRole, percent?: number): RGBA;
41
+ /** The color of one line segment. */
42
+ export declare function segmentColor(theme: Theme, display: Settings, segment: Segment): RGBA;
43
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Terminal columns: how wide text shows in a terminal, and cutting or padding text to a width
3
+ * without splitting a character. East Asian wide characters and emoji take two columns;
4
+ * control, format and combining characters on their own take none.
5
+ */
6
+ export declare function columnsOf(text: string): number;
7
+ /** The longest start of `text` that fits in `width` columns. */
8
+ export declare function sliceColumns(text: string, width: number): string;
9
+ /** `text` cut to `width` columns, ending in "…" when cut. */
10
+ export declare function truncateColumns(text: string, width: number): string;
11
+ /** `text` with spaces after it up to `width` columns (never cut). */
12
+ export declare function padEndColumns(text: string, width: number): string;
13
+ /** `text` with spaces before it up to `width` columns (never cut). */
14
+ export declare function padStartColumns(text: string, width: number): string;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Words and numbers every quota and usage surface shows: percents, reset times, bars, amounts,
3
+ * money, token counts and shares. Pure functions, shared by the TUI, the Web text and the CLI.
4
+ * Money, token counts and shares are written the way T3 Code's usage page writes them, always
5
+ * in US English, so the text is the same on every machine.
6
+ */
7
+ import type { Amount, QuotaRow, SessionTokens, Words } from "../core/types.js";
8
+ import type { Settings } from "../settings/schema.js";
9
+ /** "$1,234.56", "$0.00", and "<$0.01" for an amount above 0 that would show as $0.00. */
10
+ export declare function formatUsd(usd: number): string;
11
+ /** Whole below 1,000, then always three significant digits: "950", "12.3K", "8.00M", "13.4B". */
12
+ export declare function formatTokens(count: number): string;
13
+ /** A 0..1 share with one decimal: "92.5%", "5.0%", "100.0%"; "<0.1%" above 0; "0%" for 0. */
14
+ export declare function formatShare(share: number): string;
15
+ /** The words until the server sends its own (docs/v6-build.local.md §5). */
16
+ export declare const DEFAULT_WORDS: Words;
17
+ /** The word after every quota percentage. */
18
+ export declare function percentWord(words: Words): string;
19
+ /** A raw percent remaining displayed as the consumed percentage: "42% used". */
20
+ export declare function percentText(words: Words, percentRemaining: number, withWord: boolean): string;
21
+ /**
22
+ * docs/v6-plan.local.md §4.7. Zero units are dropped in every style; the past is "now".
23
+ * "smart" rounds to the nearest: a day or more in days with one decimal ("4.5d"), from 12 hours
24
+ * in whole hours ("23h"), below that like "exact" ("11h 35m"). A time that rounds to 24 hours
25
+ * is "1.0d".
26
+ */
27
+ export declare function formatDuration(ms: number, style: Words["reset"], decimals: number): string;
28
+ export type BarShape = Settings["layout"]["bar"];
29
+ /** A bar in two parts: consumed quota, then the unfilled portion. */
30
+ export declare function barParts(shape: BarShape, percentRemaining: number, width: number): [string, string];
31
+ /**
32
+ * The cell of a bar `width` cells wide where even use would be (the │ mark): `evenLeft` is the
33
+ * percent even use leaves now (`core/pace.ts`), so the bar places its inverse used percentage.
34
+ */
35
+ export declare function evenUseCell(evenLeft: number, width: number): number;
36
+ export type Level = "good" | "warning" | "low";
37
+ export type Thresholds = {
38
+ warningBelow: number;
39
+ lowBelow: number;
40
+ };
41
+ /** Low, high, or nearly complete usage; "nearly complete" wins where both would. */
42
+ export declare function levelOf(percentRemaining: number, thresholds: Thresholds): Level;
43
+ /**
44
+ * "$12.40", "12.40 EUR", "1 request", "1,200 requests", "30 nano". A count unit is one word
45
+ * ("request"); it is plural for every number but 1, and the plain "unit" is not shown.
46
+ */
47
+ export declare function amountText(amount: Amount): string;
48
+ /** The value of a row without a percent: its text, used amount, used/limit, or yes/no. */
49
+ export declare function rowValueText(row: QuotaRow): string;
50
+ /** "12.3K in · 2.10K out". */
51
+ export declare function sessionTokensText(tokens: SessionTokens): string;
52
+ /** Marks a low cache hit. */
53
+ export declare const LOW_CACHE_MARK = "\u26A0";
54
+ /** A model's input tokens by kind: new input, cache reads and cache writes. */
55
+ export type InputTokens = {
56
+ input: number;
57
+ cacheRead: number;
58
+ cacheWrite: number;
59
+ };
60
+ /** The share of a model's input tokens read from the cache. */
61
+ export type CacheHit = {
62
+ /** Cache reads ÷ all input tokens. */
63
+ share: number;
64
+ /** Whole percents, rounded down so a low cache hit never reads "50%": "35%". */
65
+ text: string;
66
+ /** At least 200K input tokens: enough to tell a good cache hit from a low one. */
67
+ judged: boolean;
68
+ /** Judged, and less than half of the input tokens read from the cache. */
69
+ low: boolean;
70
+ };
71
+ /**
72
+ * The cache hit of `tokens`; undefined without input tokens, or without cache reads and cache
73
+ * writes (the provider reports no cache numbers).
74
+ */
75
+ export declare function cacheHit(tokens: InputTokens): CacheHit | undefined;
76
+ /**
77
+ * `text` cut to `width` terminal columns with "…" ("Copilot…", not "Copilot …"), else padded
78
+ * to it. Wide characters count two columns and are never split.
79
+ */
80
+ export declare function fit(text: string, width: number): string;
@@ -0,0 +1,52 @@
1
+ import type { Words } from "../core/types.js";
2
+ import type { Group, VisibleRow } from "./select.js";
3
+ /** How one place shows rows. */
4
+ export type Place = {
5
+ words: Words;
6
+ nowMs: number;
7
+ /**
8
+ * "words" (sidebar, collapsed sidebar, status line, toasts, /quota text): your name; else, with
9
+ * `words.rowNames` "short", its window's short name ("5h", "7d") when no other row of its group
10
+ * has the same one; else its label. "label" (Limits, the Settings tree, Web and terminal
11
+ * text): your name, else its label.
12
+ */
13
+ names: "words" | "label";
14
+ /**
15
+ * "number": "42%", the place says the word elsewhere. "words": "42% used", and "usedWord":
16
+ * "42%" except where the consumed-usage label is needed.
17
+ */
18
+ percent: "number" | "words" | "usedWord";
19
+ /** Reset and pace times in this style, whatever the words (Limits: always "exact"). */
20
+ times?: Words["reset"];
21
+ /** The place draws the even-use mark, so its facts have `evenLeft`. */
22
+ evenUse?: boolean;
23
+ /**
24
+ * The pace words it shows, none without: "runsOut" only "runs out in 2h" (before the reset),
25
+ * "fast" also "faster than it refills", "all" also "using less than planned" and "on track".
26
+ */
27
+ pace?: "runsOut" | "fast" | "all";
28
+ };
29
+ export type RowFacts = {
30
+ /** The row's id, for the lines that show it. */
31
+ id: string;
32
+ name: string;
33
+ /** Its remaining percent as the row has it, for bars and level colors; undefined without one. */
34
+ percent?: number;
35
+ /** Its percent in the place's style, or the value of a row without one ("$1,240.50 used"). */
36
+ value: string;
37
+ /** The time until it resets in the place's style ("2h 14m", "3.2d"); "" without a percent. */
38
+ reset: string;
39
+ /** The same in the short style ("2h", "4d 12h"), for a place short of room. */
40
+ shortReset: string;
41
+ /** Where even use would be (the percent it would leave now), when the place draws the mark. */
42
+ evenLeft?: number;
43
+ /** The pace words the place shows; `fast` when the row is used faster than it refills. */
44
+ pace?: {
45
+ words: string;
46
+ fast: boolean;
47
+ };
48
+ };
49
+ /** `item`, one of `group`'s rows, as `place` shows it. */
50
+ export declare function rowFacts(item: VisibleRow, group: Pick<Group, "rows">, place: Place): RowFacts;
51
+ /** The words for a group's last error ("Sign in again"); undefined when its last check worked. */
52
+ export declare function errorWords(group: Pick<Group, "error" | "name">, nowMs: number): string | undefined;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Which providers and rows a surface shows, in which order and under which names. Pure:
3
+ * every surface (TUI, Web text, CLI) picks its rows here from the snapshot and the display
4
+ * settings.
5
+ */
6
+ import type { QuotaError, QuotaRow, QuotaSnapshot, QuotaWindow, Words } from "../core/types.js";
7
+ export type Surface = "sidebar" | "collapsed" | "statusLine" | "toast";
8
+ /**
9
+ * What one surface shows: its section of the settings (`sidebar.hidden`, …). Ids not named in an
10
+ * order follow in the snapshot's order.
11
+ */
12
+ export type SurfaceRows = {
13
+ /** Provider ids and row ids this surface leaves out. */
14
+ hidden: string[];
15
+ providerOrder: string[];
16
+ /** Row ids per provider id. */
17
+ rowOrder: Record<string, string[]>;
18
+ /**
19
+ * Your names for rows, by row id: on the sidebar, which the collapsed sidebar and the status
20
+ * line share, and on the toast.
21
+ */
22
+ names?: Record<string, string>;
23
+ };
24
+ /** The window a provider shows in the collapsed sidebar and the status line. */
25
+ export type WindowChoice = "lowest" | QuotaWindow;
26
+ /** The part of the settings that picks rows: every surface's section. */
27
+ export type RowSettings = Record<Surface, SurfaceRows>;
28
+ /** A row as a place shows it: `label` is your name for it, or its own; `named` says you named it. */
29
+ export type VisibleRow = {
30
+ row: QuotaRow;
31
+ label: string;
32
+ named: boolean;
33
+ };
34
+ /** `row` under your name for it in `names`, else its own label. */
35
+ export declare function visibleRow(row: QuotaRow, names: Readonly<Record<string, string>>): VisibleRow;
36
+ /** One provider account on a surface: its title, its rows, and its last error. */
37
+ export type Group = {
38
+ /** Provider id, or `${providerId} (account)` when it has several accounts. */
39
+ id: string;
40
+ providerId: string;
41
+ /** "Claude" or "Claude (work)". */
42
+ title: string;
43
+ name: string;
44
+ account?: string;
45
+ rows: VisibleRow[];
46
+ error?: QuotaError;
47
+ /** True before the provider was ever checked. */
48
+ unchecked: boolean;
49
+ };
50
+ /** `ids` first in the given order, then the rest in their own order. */
51
+ export declare function ordered<T>(items: readonly T[], idOf: (item: T) => string, order: readonly string[]): T[];
52
+ /**
53
+ * The providers and rows `surface` shows, in order, with your row names: the toast's on toasts,
54
+ * the sidebar's everywhere else.
55
+ */
56
+ export declare function visibleGroups(snapshot: QuotaSnapshot, settings: RowSettings, surface: Surface, words: Words): Group[];
57
+ /**
58
+ * The window a group shows in the collapsed sidebar or the status line, and the one its Settings
59
+ * ‹ › shows: its provider's own pick; else the pick for all providers when one of its rows with a
60
+ * percent has that window; else "lowest" (where `pickRow` would fall back anyway).
61
+ */
62
+ export declare function windowFor(windows: Readonly<Record<string, WindowChoice>>, group: Pick<Group, "providerId" | "rows">): WindowChoice;
63
+ /**
64
+ * The one row a group shows in the collapsed sidebar and the status line: the preferred
65
+ * window's row; with "lowest", or when the group has no row of that window, the row with the
66
+ * most used; else the first row.
67
+ */
68
+ export declare function pickRow(group: Pick<Group, "rows">, choice?: WindowChoice): VisibleRow | undefined;
@@ -0,0 +1,160 @@
1
+ /**
2
+ * The lines of every quota surface, built from the visible groups (`select.ts`). The TUI
3
+ * draws each segment in its color role; the Web and terminal `/quota` text print the plain
4
+ * text.
5
+ */
6
+ import type { QuotaSnapshot, SessionTokens, Words } from "../core/types.js";
7
+ import type { Settings } from "../settings/schema.js";
8
+ import { type BarShape } from "./format.js";
9
+ import { type Group, type WindowChoice } from "./select.js";
10
+ /** Every colored thing quota draws; the TUI maps each to a theme color. */
11
+ export type ColorRole = "title" | "provider" | "account" | "label" | "good" | "warning" | "low" | "empty" | "percent" | "reset" | "value" | "error" | "statusName" | "separator" | "arrows";
12
+ /**
13
+ * A piece of a line. `role` "bar" is the filled part of a bar, drawn in its level color.
14
+ * `percent` is the row's remaining percent, for roles that follow the bar color.
15
+ */
16
+ export type Segment = {
17
+ text: string;
18
+ role: ColorRole | "bar";
19
+ percent?: number;
20
+ bold?: boolean;
21
+ };
22
+ /** A line of a surface. `id` is the provider or row it shows ("" for a spacer). */
23
+ export type Line = {
24
+ id: string;
25
+ segments: Segment[];
26
+ };
27
+ export type Layout = Settings["layout"];
28
+ export declare function lineText(line: Line): string;
29
+ /**
30
+ * A bar in two parts: used quota in its level color, then the remaining part. With `evenLeft`, the
31
+ * percent even use would leave now (`core/pace.ts`), the ┃ mark takes the place of the cell where
32
+ * even use would be, in the row labels' color; a bar under 3 cells gets no mark.
33
+ */
34
+ export declare function barSegments(shape: BarShape, percent: number, width: number, evenLeft?: number): Segment[];
35
+ type SidebarInput = {
36
+ groups: Group[];
37
+ layout: Layout;
38
+ words: Words;
39
+ nowMs: number;
40
+ /** Columns the sidebar gives quota. */
41
+ width: number;
42
+ sessionTokens?: SessionTokens;
43
+ /** A "runs out in 2h" line under each row that runs out before its reset. */
44
+ runsOut?: boolean;
45
+ };
46
+ /** §4.1: the expanded panel's title, with the rows' consumed-usage word: "▼ Quota used". */
47
+ export declare function sidebarTitle(words: Words): string;
48
+ /**
49
+ * §4.1: the expanded Quota panel, below its title line (`sidebarTitle`). The name column fits
50
+ * the longest name next to a bar; a row without a bar (a balance) starts its value there, or 2
51
+ * columns after a longer name.
52
+ */
53
+ export declare function sidebarLines(input: SidebarInput): Line[];
54
+ /** §4.2: the collapsed panel's title. A provider with several accounts counts once. */
55
+ export declare function collapsedTitle(groups: Group[]): string;
56
+ type CollapsedInput = {
57
+ groups: Group[];
58
+ layout: Layout;
59
+ words: Words;
60
+ nowMs: number;
61
+ width: number;
62
+ /** Preferred window by provider id, or for all providers (`windowFor`). */
63
+ window: Record<string, WindowChoice>;
64
+ /** A "runs out in 2h" line under each provider whose shown row runs out before its reset. */
65
+ runsOut?: boolean;
66
+ };
67
+ /**
68
+ * §4.2: one line per provider with its preferred window. When the last check failed, the
69
+ * error's words take the place of the reset time next to the rows kept from before. The bar
70
+ * takes the room the names, the percent and the longest reset time leave, at most 10 cells.
71
+ */
72
+ export declare function collapsedLines(input: CollapsedInput): Line[];
73
+ /** How much one status line segment shows, from the most to the least. */
74
+ export type StatusLevel = "full" | "bar" | "reset" | "numbers";
75
+ export type StatusInput = {
76
+ groups: Group[];
77
+ layout: Layout;
78
+ words: Words;
79
+ nowMs: number;
80
+ window: Record<string, WindowChoice>;
81
+ /** "(runs out in 2h)" after each provider whose shown row runs out before its reset. */
82
+ runsOut?: boolean;
83
+ };
84
+ export type StatusLayout = {
85
+ level: StatusLevel;
86
+ /** The first group shown (the line scrolls when not all groups fit). */
87
+ start: number;
88
+ shown: Line[];
89
+ /** Groups after the shown ones: the "+N ›" marker. */
90
+ hiddenAfter: number;
91
+ };
92
+ /**
93
+ * §4.3 "all" mode: the most detail that fits every group in `room` columns ("% only" when
94
+ * nothing else fits), then the groups that fit from `start`, keeping room for the "‹ " and
95
+ * " +N ›" markers. When not even the first of them fits, its name is cut short, so the
96
+ * markers stay. `level` fixes the detail instead of "auto".
97
+ */
98
+ export declare function statusLayout(input: StatusInput, room: number, start: number, level: StatusLevel | "auto"): StatusLayout;
99
+ /**
100
+ * §4.3 "one provider, big bar" (v5's prompt bar): the first group with a 10-cell bar. The
101
+ * error's words take the place of the reset time; without a percent row the line shows the
102
+ * group's error or value instead of a bar. Cut to `width` columns when given, keeping " ⚠"
103
+ * when the error's words don't fit.
104
+ */
105
+ export declare function bigStatusLine(input: StatusInput, width?: number): Line | undefined;
106
+ /**
107
+ * §4.4: plain text: per provider, one line per visible row, then a line for its error or
108
+ * "not checked yet". The terminal command `opencode-quota show` prints these.
109
+ */
110
+ export declare function plainLines(params: {
111
+ groups: Group[];
112
+ words: Words;
113
+ nowMs: number;
114
+ sessionTokens?: SessionTokens;
115
+ /** "runs out in 2h" after each row that runs out before its reset. */
116
+ runsOut?: boolean;
117
+ }): string[];
118
+ /**
119
+ * How a toast lays out its rows: one line per row under its provider's name ("grouped"), or
120
+ * each row on two lines with a bar as wide as the toast ("detailed").
121
+ */
122
+ export type ToastLayout = Settings["toast"]["layout"];
123
+ export type ToastInput = {
124
+ groups: Group[];
125
+ words: Words;
126
+ nowMs: number;
127
+ /** The bar shape and the even-use mark; a toast's bars take the room it has. */
128
+ layout: Layout;
129
+ toastLayout: ToastLayout;
130
+ /** Columns of text inside the toast (`toastRoom`); no line is wider. */
131
+ room: number;
132
+ /** A "runs out in 2h" line under each row that runs out before its reset. */
133
+ runsOut?: boolean;
134
+ sessionTokens?: SessionTokens;
135
+ };
136
+ /** The segments without the spaces at the end of their line. */
137
+ export declare function trimEnd(segments: Segment[]): Segment[];
138
+ /** §4.4: a quota toast's lines in its layout, none wider than `room` columns. */
139
+ export declare function toastLines(input: ToastInput): Line[];
140
+ /** Where a surface draws: the time, and its columns (a toast's inside the toast, `toastRoom`). */
141
+ export type SurfaceView = {
142
+ nowMs: number;
143
+ width: number;
144
+ };
145
+ /**
146
+ * §4.1 and §4.2: the Quota panel in the session sidebar, expanded (`open`) or collapsed: its
147
+ * title, then its lines. A collapsed panel that is off keeps its title; before the first
148
+ * snapshot there are no lines.
149
+ */
150
+ export declare function sidebarPanel(snapshot: QuotaSnapshot | undefined, settings: Settings, view: SurfaceView & {
151
+ open: boolean;
152
+ }): {
153
+ title: string;
154
+ lines: Line[];
155
+ };
156
+ /** §4.3: what the status line lays out (`statusLayout`, `bigStatusLine`). */
157
+ export declare function statusLineInput(snapshot: QuotaSnapshot, settings: Settings, nowMs: number): StatusInput;
158
+ /** §4.4: what a quota toast lays out (`toastLines`): its rows, then the tokens when it shows them. */
159
+ export declare function toastInput(snapshot: QuotaSnapshot, settings: Settings, view: SurfaceView): ToastInput;
160
+ export {};