opencode-usage-insights 0.2.0 → 0.3.0

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.
@@ -2,6 +2,7 @@ import { type LineFields, type LineLabels, type TurnStats, type TurnTotalsView }
2
2
  import type { CacheDropRow, LatencyReport, ModelUsage, Overview, Range, SessionUsage, TurnUsage, TtlEvidenceRow } from "./stats/queries";
3
3
  import type { DbInfo } from "./stats/maintenance";
4
4
  import type { CacheStats, CoverageReport, ProviderRow, ProviderSummary, GapReport, LatencyGroupRow, PeriodGranularity, PeriodRow, SwitchRow } from "./stats/aggregates";
5
+ import { QUOTA_VIEW, type QuotaFetch } from "./quota";
5
6
  /**
6
7
  * View models and formatting for the stats panel. Everything here is pure:
7
8
  * the panel component feeds query results in and renders the lines out, which
@@ -10,7 +11,13 @@ import type { CacheStats, CoverageReport, ProviderRow, ProviderSummary, GapRepor
10
11
  */
11
12
  export declare const PANEL_NAME = "usage-insights";
12
13
  export declare const PANEL_VIEWS: readonly ["overview", "models", "providers", "cache", "periods", "latency", "sessions", "turns", "db"];
13
- export type PanelView = (typeof PANEL_VIEWS)[number];
14
+ /**
15
+ * The panel catalogue seen by the TUI and the Desktop. `go` is client-side
16
+ * because the server part cannot reach the host's usage-limits endpoint; the
17
+ * database-backed views stay in `PANEL_VIEWS`.
18
+ */
19
+ export declare const CLIENT_VIEWS: readonly ["overview", "models", "providers", "cache", "periods", "latency", "sessions", "turns", "db", "go"];
20
+ export type PanelView = (typeof PANEL_VIEWS)[number] | typeof QUOTA_VIEW;
14
21
  export declare const RANGE_KEYS: readonly ["session", "today", "7d", "30d", "all"];
15
22
  export type RangeKey = (typeof RANGE_KEYS)[number];
16
23
  export declare const GRANULARITIES: readonly ["day", "week", "month"];
@@ -33,9 +40,15 @@ export type PanelLine = {
33
40
  export declare const SORT_KEYS: Partial<Record<PanelView, readonly string[]>>;
34
41
  export declare function sortKeys(view: PanelView): readonly string[];
35
42
  export declare function defaultSort(view: PanelView): string;
43
+ /**
44
+ * The Desktop view menu places Go immediately after Overview, because it is
45
+ * live host state rather than a database report. The TUI keeps its numeric
46
+ * key order (9 is db, 0 is go); only the Desktop dropdown uses this order.
47
+ */
48
+ export declare function desktopViewOrder(views: readonly PanelView[]): readonly PanelView[];
36
49
  export declare function nextSort(view: PanelView, current: string, step: number): string;
37
50
  /** The views and ranges, as the command and the panel header understand them. */
38
- export declare function parseArgs(input: string | undefined): {
51
+ export declare function parseArgs(input: string | undefined, views?: readonly PanelView[]): {
39
52
  view?: PanelView;
40
53
  range?: RangeKey;
41
54
  };
@@ -62,7 +75,7 @@ export type PanelSettings = {
62
75
  };
63
76
  export declare const DEFAULT_SETTINGS: PanelSettings;
64
77
  /** Merge persisted state with the defaults, dropping anything unrecognized. */
65
- export declare function sanitizeSettings(raw: Partial<PanelSettings> | undefined): PanelSettings;
78
+ export declare function sanitizeSettings(raw: Partial<PanelSettings> | undefined, views?: readonly PanelView[]): PanelSettings;
66
79
  export declare function formatPercent(value: number | undefined, digits?: number): string;
67
80
  export declare function formatCount(value: number): string;
68
81
  export declare function formatMs(value: number | undefined): string;
@@ -127,7 +140,7 @@ export declare function usageBuckets(usage: {
127
140
  * clearly; on a narrow panel the names shorten instead of wrapping, and the
128
141
  * active view always keeps its full name.
129
142
  */
130
- export declare function viewBar(view: PanelView, width?: number): PanelLine;
143
+ export declare function viewBar(view: PanelView, width?: number, views?: readonly PanelView[]): PanelLine;
131
144
  export declare function keysFor(of: PanelView): string;
132
145
  export declare function filterSummary(filters: {
133
146
  modelID?: string | undefined;
@@ -136,6 +149,16 @@ export declare function filterSummary(filters: {
136
149
  export declare function granularityLabel(granularity: PeriodGranularity): string;
137
150
  /** Help overlay: the keys and the exact meaning of every number. */
138
151
  export declare function helpLines(width: number): PanelLine[];
152
+ /** The full `go` view: the three meters, the monthly forecast and renewal. */
153
+ export declare function goQuotaLines(state: QuotaFetch | undefined, options: {
154
+ now: number;
155
+ width: number;
156
+ name?: string | undefined;
157
+ loading?: boolean | undefined;
158
+ error?: string | undefined;
159
+ }): PanelLine[];
160
+ /** The compact block the TUI sidebar and Desktop Turns panel show before the session summary. */
161
+ export declare function goSidebarLines(state: QuotaFetch | undefined, now: number, width: number, name?: string): PanelLine[];
139
162
  export declare function overviewLines(data: {
140
163
  usage: Overview;
141
164
  session: Overview | undefined;
package/dist/panel.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { Context, PanelInput } from "@opencode/plugin/tui/context";
2
- import { type PanelSettings } from "./panel-data";
2
+ import { type PanelSettings, type PanelView } from "./panel-data";
3
+ import { type QuotaResource } from "./quota";
3
4
  /**
4
- * The `/usage` panel. One read-only view over the stats database at a time,
5
+ * The `/usage-insights` panel. One read-only view over the stats database at a time,
5
6
  * driven entirely from the keyboard: a cursor over the selectable lines,
6
7
  * Enter drills into the row under it, and the views, range, sort, bucket and
7
8
  * filters are part of the state the host persists between openings.
@@ -25,4 +26,10 @@ export declare function Panel(props: {
25
26
  readonly settings: PanelSettings;
26
27
  readonly update: (mutation: (draft: PanelSettings) => void) => void;
27
28
  readonly maintenance?: boolean | undefined;
29
+ /** The views this client offers (`go` is omitted when quota is off). */
30
+ readonly views: readonly PanelView[];
31
+ /** Live OpenCode Go allowance, shared with the sidebar. */
32
+ readonly quota: QuotaResource;
33
+ /** Full subscription label shown above the meters. */
34
+ readonly quotaName: string;
28
35
  }): any;
@@ -0,0 +1,13 @@
1
+ import type { OpenCodeClient } from "@opencode/client";
2
+ import type { QuotaFetch } from "./quota";
3
+ /**
4
+ * Reads the host's usage-limits endpoint. The plugin never talks to the
5
+ * Console and never sees the API key: OpenCode itself resolves the Go
6
+ * subscription from the stored Console session and exposes the meters here.
7
+ */
8
+ export type QuotaLocation = {
9
+ directory?: string | undefined;
10
+ };
11
+ /** Validate and normalize the endpoint payload; exported for tests. */
12
+ export declare function normalizeQuota(data: unknown, now?: number): QuotaFetch;
13
+ export declare function fetchGoQuota(client: OpenCodeClient, location?: QuotaLocation | undefined, signal?: AbortSignal | undefined): Promise<QuotaFetch>;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * OpenCode Go allowance math and formatting.
3
+ *
4
+ * The host publishes one meter per window: `rolling` (5 hours), `weekly` and
5
+ * `monthly`. Each meter carries the percentage used, whether Go refuses
6
+ * requests until it resets, and the reset instant. The host does not publish
7
+ * when the monthly cycle started, so the forecast infers it as one calendar
8
+ * month before the reset. That assumption is shown in the UI instead of being
9
+ * hidden in the number.
10
+ */
11
+ export declare const QUOTA_VIEW: "go";
12
+ export declare const QUOTA_POLL_MS = 60000;
13
+ /** The host does not expose the paid plan; this is the conservative default. */
14
+ export declare const DEFAULT_QUOTA_NAME = "OpenCode Go";
15
+ /**
16
+ * The subscription label shown in the UI. The host's usage payload has no
17
+ * `planType` (Go and Go Plus share the same meters), so an explicit
18
+ * `quotaName` wins; otherwise use the provider's display name if the host
19
+ * provides one, and finally the full default name.
20
+ */
21
+ export declare function quotaNameOf(explicit?: string | undefined, providerName?: string | undefined): string;
22
+ export type GoMeter = {
23
+ percent: number;
24
+ limited: boolean;
25
+ resetsAt: number;
26
+ };
27
+ export type GoWorkspace = {
28
+ id: string;
29
+ name?: string | undefined;
30
+ usageURL?: string | undefined;
31
+ };
32
+ export type GoQuota = {
33
+ workspace?: GoWorkspace | undefined;
34
+ rolling: GoMeter;
35
+ weekly: GoMeter;
36
+ monthly: GoMeter;
37
+ observedAt: number;
38
+ };
39
+ /** What a successful or explanatory quota read means for the UI. */
40
+ export type QuotaFetch = {
41
+ kind: "ok";
42
+ quota: GoQuota;
43
+ } | {
44
+ kind: "none";
45
+ reason: "console" | "subscription";
46
+ };
47
+ /** Reactive quota state shared by the TUI panel and sidebar. */
48
+ export type QuotaResource = {
49
+ readonly state: () => QuotaFetch | undefined;
50
+ readonly loading: () => boolean;
51
+ readonly error: () => string | undefined;
52
+ readonly refresh: () => void;
53
+ };
54
+ export type MonthlyForecast = {
55
+ /** Inferred start of the monthly cycle. */
56
+ startAt: number;
57
+ /** Monthly reset reported by the host. */
58
+ endAt: number;
59
+ elapsedMs: number;
60
+ remainingMs: number;
61
+ /** Percentage points used per day over the cycle so far. */
62
+ ratePerDay: number;
63
+ /** Percentage at the reset if the current pace continues. */
64
+ projectedPercent: number;
65
+ /** When the monthly allowance reaches 100% before the reset. */
66
+ exhaustAt?: number | undefined;
67
+ /** The meter is already limited or at 100%. */
68
+ reached: boolean;
69
+ /** The cycle has run long enough for the projection to mean something. */
70
+ available: boolean;
71
+ /** The limit is expected before the reset. */
72
+ willExhaust: boolean;
73
+ };
74
+ export type QuotaChart = {
75
+ /** Whole percentage used now, clamped to 0-100. */
76
+ current: number;
77
+ /** Whole percentage at the reset, clamped to 0-100. */
78
+ forecast: number;
79
+ /** Percentage points left at the reset. */
80
+ headroom: number;
81
+ /** The projection goes past 100%. */
82
+ over: boolean;
83
+ /** The meter is already at 100%; the projection is not useful. */
84
+ reached: boolean;
85
+ available: boolean;
86
+ /** Monthly reset reported by the host. */
87
+ resetsAt: number;
88
+ exhaustAt?: number | undefined;
89
+ };
90
+ /**
91
+ * The start of the cycle that ends at `endAt`, assuming the paid period has
92
+ * the same day in the previous month. A shorter previous month uses its last
93
+ * day, so 31 March maps to 28/29 February instead of overflowing into March.
94
+ */
95
+ export declare function previousCycleStart(endAt: number): number;
96
+ /**
97
+ * Project the month's percentage to its reset from the cycle's average pace.
98
+ * The projection is intentionally simple: with one observation per window it
99
+ * is the only honest forecast the host data supports. It never invents a
100
+ * sample history.
101
+ */
102
+ export declare function forecastMonthly(meter: GoMeter, now: number): MonthlyForecast;
103
+ /** The values a bar chart needs, with the projection clamped to the track. */
104
+ export declare function quotaChart(meter: GoMeter, now: number): QuotaChart;
105
+ /** A ten-cell ASCII bar that fits the TUI panel and the sidebar. */
106
+ export declare function quotaBar(percent: number, width?: number): string;
107
+ /** `15 Dec 2026 22:06` in the user's local time, or a fixed zone in tests. */
108
+ export declare function formatRenewal(at: number, timeZone?: string | undefined): string;
109
+ /** `15 Dec 22:06` for the narrow sidebar. */
110
+ export declare function formatRenewalCompact(at: number, timeZone?: string | undefined): string;
111
+ /** `in 2d 4h`; a reset in the past reads `due`. */
112
+ export declare function formatCountdown(at: number, now: number): string;
113
+ /** The status line shared by the TUI and the chart. */
114
+ export declare function quotaStatus(quota: GoQuota): string;
package/dist/rpc.d.ts CHANGED
@@ -80,7 +80,7 @@ export declare const UsageInsights: {
80
80
  readonly properties: {
81
81
  readonly view: {
82
82
  readonly type: "string";
83
- readonly enum: readonly ["overview", "models", "providers", "cache", "periods", "latency", "sessions", "turns", "db"];
83
+ readonly enum: readonly ["overview", "models", "providers", "cache", "periods", "latency", "sessions", "turns", "db", "go"];
84
84
  };
85
85
  readonly range: {
86
86
  readonly type: "string";
package/dist/rpc.js CHANGED
@@ -42,7 +42,7 @@ var PanelLineSchema = {
42
42
  var PanelSettingsSchema = {
43
43
  type: "object",
44
44
  properties: {
45
- view: { type: "string", enum: ["overview", "models", "providers", "cache", "periods", "latency", "sessions", "turns", "db"] },
45
+ view: { type: "string", enum: ["overview", "models", "providers", "cache", "periods", "latency", "sessions", "turns", "db", "go"] },
46
46
  range: { type: "string", enum: ["session", "today", "7d", "30d", "all"] },
47
47
  sort: { type: "string", maxLength: 40 },
48
48
  sortDesc: { type: "boolean" },
@@ -291,4 +291,4 @@ export {
291
291
  UsageInsights
292
292
  };
293
293
 
294
- //# debugId=6C681C5E17FF4D6764756E2164756E21
294
+ //# debugId=353CEB0AA16B78BF64756E2164756E21
package/dist/rpc.js.map CHANGED
@@ -2,10 +2,10 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/rpc.ts", "../src/limits.ts"],
4
4
  "sourcesContent": [
5
- "import { Rpc } from \"@opencode/plugin/rpc\"\nimport { MAX_PANEL_WIDTH, MAX_TURNS } from \"./limits\"\nimport type { LineFormatOptions, PanelLine, PanelRow, PanelSettings } from \"./panel-data\"\nimport type { BackfillResult, DbInfo, PruneResult } from \"./stats/maintenance\"\nimport type { FilterOption } from \"./stats/queries\"\n\n/**\n * The usage-insights RPC contract. One definition is served by the server\n * part and consumed by the TUI and the desktop GUI, so both clients read the\n * same database through the same validated surface.\n *\n * JSON Schema keeps the contract portable: the server does not need a newer\n * `effect` runtime, and a client can be a TUI, an Electron window or a plain\n * HTTP client. TypeScript types are declared next to the schemas and are the\n * only thing imported with `import type`; the schemas are the runtime truth.\n */\n\nexport type PanelInput = {\n sessionID: string\n settings: PanelSettings\n detail?: PanelRow | undefined\n width: number\n busy?: boolean | undefined\n}\n\nexport type PanelOutput = {\n lines: PanelLine[]\n database?: DbInfo | undefined\n}\n\nexport type TurnsInput = {\n sessionID: string\n limit: number\n width: number\n}\n\nexport type TurnsOutput = {\n summary: PanelLine[]\n history: PanelLine[]\n}\n\nexport type ListCostInput = {\n sessionID: string\n}\n\nexport type ListCostOutput = {\n cost: number\n}\n\nexport type FiltersOutput = {\n models: FilterOption[]\n providers: FilterOption[]\n}\n\nexport type PruneInput = {\n days: number\n confirm: true\n}\n\nexport type WipeInput = {\n confirm: true\n}\n\nexport type VacuumInput = {\n confirm: true\n}\n\nexport type BackfillInput = {\n confirm: true\n}\n\nexport type VacuumOutput = {\n before: number\n after: number\n freed: number\n}\n\nexport type RecordedEvent = {\n sessionID?: string | undefined\n at: number\n}\n\nexport type UsageFormat = LineFormatOptions\n\nconst Tone = { type: \"string\", enum: [\"base\", \"muted\", \"warning\", \"accent\"] } as const\n\nconst PanelRowSchema = {\n type: \"object\",\n properties: {\n kind: { type: \"string\", enum: [\"model\", \"session\", \"period\", \"provider\", \"turn\", \"prune\", \"wipe\"] },\n value: { type: \"string\", maxLength: 500 },\n variant: { type: \"string\", maxLength: 200 },\n },\n required: [\"kind\", \"value\"],\n additionalProperties: false,\n} as const\n\nconst PanelLineSchema = {\n type: \"object\",\n properties: {\n text: { type: \"string\" },\n tone: Tone,\n hint: { type: \"boolean\" },\n row: PanelRowSchema,\n },\n required: [\"text\"],\n additionalProperties: false,\n} as const\n\nconst PanelSettingsSchema = {\n type: \"object\",\n properties: {\n view: { type: \"string\", enum: [\"overview\", \"models\", \"providers\", \"cache\", \"periods\", \"latency\", \"sessions\", \"turns\", \"db\"] },\n range: { type: \"string\", enum: [\"session\", \"today\", \"7d\", \"30d\", \"all\"] },\n sort: { type: \"string\", maxLength: 40 },\n sortDesc: { type: \"boolean\" },\n granularity: { type: \"string\", enum: [\"day\", \"week\", \"month\"] },\n turnsScope: { type: \"string\", enum: [\"session\", \"all\"] },\n modelID: { type: \"string\", maxLength: 300 },\n providerID: { type: \"string\", maxLength: 300 },\n },\n required: [\"view\", \"range\", \"sort\", \"sortDesc\", \"granularity\", \"turnsScope\", \"modelID\", \"providerID\"],\n additionalProperties: false,\n} as const\n\nconst TableSizeSchema = {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n rows: { type: \"number\" },\n },\n required: [\"name\", \"rows\"],\n additionalProperties: false,\n} as const\n\nconst DbInfoSchema = {\n type: \"object\",\n properties: {\n path: { type: \"string\" },\n bytes: { type: \"number\" },\n walBytes: { type: \"number\" },\n schemaVersion: { type: \"number\" },\n tables: { type: \"array\", items: TableSizeSchema },\n firstAt: { type: \"number\" },\n lastAt: { type: \"number\" },\n removable: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: { days: { type: \"number\" }, steps: { type: \"number\" } },\n required: [\"days\", \"steps\"],\n additionalProperties: false,\n },\n },\n unpriced: { type: \"number\" },\n },\n required: [\"path\", \"bytes\", \"schemaVersion\", \"tables\", \"removable\", \"unpriced\"],\n additionalProperties: false,\n} as const\n\nconst FilterOptionSchema = {\n type: \"object\",\n properties: { value: { type: \"string\" }, steps: { type: \"number\" } },\n required: [\"value\", \"steps\"],\n additionalProperties: false,\n} as const\n\nconst PruneResultSchema = {\n type: \"object\",\n properties: {\n steps: { type: \"number\" },\n prompts: { type: \"number\" },\n events: { type: \"number\" },\n usage: { type: \"number\" },\n },\n required: [\"steps\", \"prompts\", \"events\", \"usage\"],\n additionalProperties: false,\n} as const\n\nconst WipeResultSchema = {\n type: \"object\",\n properties: {\n steps: { type: \"number\" },\n prompts: { type: \"number\" },\n events: { type: \"number\" },\n usage: { type: \"number\" },\n sessions: { type: \"number\" },\n },\n required: [\"steps\", \"prompts\", \"events\", \"usage\", \"sessions\"],\n additionalProperties: false,\n} as const\n\nconst BackfillResultSchema = {\n type: \"object\",\n properties: {\n candidates: { type: \"number\" },\n updated: { type: \"number\" },\n },\n required: [\"candidates\", \"updated\"],\n additionalProperties: false,\n} as const\n\nconst VacuumResultSchema = {\n type: \"object\",\n properties: {\n before: { type: \"number\" },\n after: { type: \"number\" },\n freed: { type: \"number\" },\n },\n required: [\"before\", \"after\", \"freed\"],\n additionalProperties: false,\n} as const\n\nconst NoInput = { type: \"object\", properties: {}, additionalProperties: false } as const\n\nconst ErrorSchema = {\n type: \"object\",\n properties: { message: { type: \"string\", maxLength: 500 } },\n additionalProperties: false,\n} as const\n\nconst errors = {\n busy: ErrorSchema,\n unavailable: ErrorSchema,\n disabled: ErrorSchema,\n invalid: ErrorSchema,\n} as const\n\nexport const UsageInsights = Rpc.define({\n id: \"usage-insights\",\n methods: {\n panel: {\n input: {\n type: \"object\",\n properties: {\n sessionID: { type: \"string\", maxLength: 200 },\n settings: PanelSettingsSchema,\n detail: PanelRowSchema,\n width: { type: \"number\", minimum: 20, maximum: MAX_PANEL_WIDTH },\n busy: { type: \"boolean\" },\n },\n required: [\"sessionID\", \"settings\", \"width\"],\n additionalProperties: false,\n },\n output: {\n type: \"object\",\n properties: {\n lines: { type: \"array\", items: PanelLineSchema },\n database: DbInfoSchema,\n },\n required: [\"lines\"],\n additionalProperties: false,\n },\n errors,\n },\n turns: {\n input: {\n type: \"object\",\n properties: {\n sessionID: { type: \"string\", maxLength: 200 },\n limit: { type: \"number\", minimum: 1, maximum: MAX_TURNS },\n width: { type: \"number\", minimum: 20, maximum: 120 },\n },\n required: [\"sessionID\", \"limit\", \"width\"],\n additionalProperties: false,\n },\n output: {\n type: \"object\",\n properties: {\n summary: { type: \"array\", items: PanelLineSchema },\n history: { type: \"array\", items: PanelLineSchema },\n },\n required: [\"summary\", \"history\"],\n additionalProperties: false,\n },\n errors,\n },\n listCost: {\n input: {\n type: \"object\",\n properties: { sessionID: { type: \"string\", maxLength: 200 } },\n required: [\"sessionID\"],\n additionalProperties: false,\n },\n output: {\n type: \"object\",\n properties: { cost: { type: \"number\" } },\n required: [\"cost\"],\n additionalProperties: false,\n },\n errors,\n },\n filters: {\n input: NoInput,\n output: {\n type: \"object\",\n properties: {\n models: { type: \"array\", items: FilterOptionSchema },\n providers: { type: \"array\", items: FilterOptionSchema },\n },\n required: [\"models\", \"providers\"],\n additionalProperties: false,\n },\n errors,\n },\n dbInfo: {\n input: NoInput,\n output: DbInfoSchema,\n errors,\n },\n prune: {\n input: {\n type: \"object\",\n properties: {\n days: { type: \"number\", minimum: 1, maximum: 3650 },\n confirm: { type: \"boolean\", enum: [true] },\n },\n required: [\"days\", \"confirm\"],\n additionalProperties: false,\n },\n output: PruneResultSchema,\n errors,\n },\n wipe: {\n input: {\n type: \"object\",\n properties: { confirm: { type: \"boolean\", enum: [true] } },\n required: [\"confirm\"],\n additionalProperties: false,\n },\n output: WipeResultSchema,\n errors,\n },\n vacuum: {\n input: {\n type: \"object\",\n properties: { confirm: { type: \"boolean\", enum: [true] } },\n required: [\"confirm\"],\n additionalProperties: false,\n },\n output: VacuumResultSchema,\n errors,\n },\n backfill: {\n input: {\n type: \"object\",\n properties: { confirm: { type: \"boolean\", enum: [true] } },\n required: [\"confirm\"],\n additionalProperties: false,\n },\n output: BackfillResultSchema,\n errors,\n },\n },\n events: {\n recorded: {\n schema: {\n type: \"object\",\n properties: {\n sessionID: { type: \"string\", maxLength: 200 },\n at: { type: \"number\" },\n },\n required: [\"at\"],\n additionalProperties: false,\n },\n },\n },\n})\n",
5
+ "import { Rpc } from \"@opencode/plugin/rpc\"\nimport { MAX_PANEL_WIDTH, MAX_TURNS } from \"./limits\"\nimport type { LineFormatOptions, PanelLine, PanelRow, PanelSettings } from \"./panel-data\"\nimport type { BackfillResult, DbInfo, PruneResult } from \"./stats/maintenance\"\nimport type { FilterOption } from \"./stats/queries\"\n\n/**\n * The usage-insights RPC contract. One definition is served by the server\n * part and consumed by the TUI and the desktop GUI, so both clients read the\n * same database through the same validated surface.\n *\n * JSON Schema keeps the contract portable: the server does not need a newer\n * `effect` runtime, and a client can be a TUI, an Electron window or a plain\n * HTTP client. TypeScript types are declared next to the schemas and are the\n * only thing imported with `import type`; the schemas are the runtime truth.\n */\n\nexport type PanelInput = {\n sessionID: string\n settings: PanelSettings\n detail?: PanelRow | undefined\n width: number\n busy?: boolean | undefined\n}\n\nexport type PanelOutput = {\n lines: PanelLine[]\n database?: DbInfo | undefined\n}\n\nexport type TurnsInput = {\n sessionID: string\n limit: number\n width: number\n}\n\nexport type TurnsOutput = {\n summary: PanelLine[]\n history: PanelLine[]\n}\n\nexport type ListCostInput = {\n sessionID: string\n}\n\nexport type ListCostOutput = {\n cost: number\n}\n\nexport type FiltersOutput = {\n models: FilterOption[]\n providers: FilterOption[]\n}\n\nexport type PruneInput = {\n days: number\n confirm: true\n}\n\nexport type WipeInput = {\n confirm: true\n}\n\nexport type VacuumInput = {\n confirm: true\n}\n\nexport type BackfillInput = {\n confirm: true\n}\n\nexport type VacuumOutput = {\n before: number\n after: number\n freed: number\n}\n\nexport type RecordedEvent = {\n sessionID?: string | undefined\n at: number\n}\n\nexport type UsageFormat = LineFormatOptions\n\nconst Tone = { type: \"string\", enum: [\"base\", \"muted\", \"warning\", \"accent\"] } as const\n\nconst PanelRowSchema = {\n type: \"object\",\n properties: {\n kind: { type: \"string\", enum: [\"model\", \"session\", \"period\", \"provider\", \"turn\", \"prune\", \"wipe\"] },\n value: { type: \"string\", maxLength: 500 },\n variant: { type: \"string\", maxLength: 200 },\n },\n required: [\"kind\", \"value\"],\n additionalProperties: false,\n} as const\n\nconst PanelLineSchema = {\n type: \"object\",\n properties: {\n text: { type: \"string\" },\n tone: Tone,\n hint: { type: \"boolean\" },\n row: PanelRowSchema,\n },\n required: [\"text\"],\n additionalProperties: false,\n} as const\n\nconst PanelSettingsSchema = {\n type: \"object\",\n properties: {\n view: { type: \"string\", enum: [\"overview\", \"models\", \"providers\", \"cache\", \"periods\", \"latency\", \"sessions\", \"turns\", \"db\", \"go\"] },\n range: { type: \"string\", enum: [\"session\", \"today\", \"7d\", \"30d\", \"all\"] },\n sort: { type: \"string\", maxLength: 40 },\n sortDesc: { type: \"boolean\" },\n granularity: { type: \"string\", enum: [\"day\", \"week\", \"month\"] },\n turnsScope: { type: \"string\", enum: [\"session\", \"all\"] },\n modelID: { type: \"string\", maxLength: 300 },\n providerID: { type: \"string\", maxLength: 300 },\n },\n required: [\"view\", \"range\", \"sort\", \"sortDesc\", \"granularity\", \"turnsScope\", \"modelID\", \"providerID\"],\n additionalProperties: false,\n} as const\n\nconst TableSizeSchema = {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n rows: { type: \"number\" },\n },\n required: [\"name\", \"rows\"],\n additionalProperties: false,\n} as const\n\nconst DbInfoSchema = {\n type: \"object\",\n properties: {\n path: { type: \"string\" },\n bytes: { type: \"number\" },\n walBytes: { type: \"number\" },\n schemaVersion: { type: \"number\" },\n tables: { type: \"array\", items: TableSizeSchema },\n firstAt: { type: \"number\" },\n lastAt: { type: \"number\" },\n removable: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: { days: { type: \"number\" }, steps: { type: \"number\" } },\n required: [\"days\", \"steps\"],\n additionalProperties: false,\n },\n },\n unpriced: { type: \"number\" },\n },\n required: [\"path\", \"bytes\", \"schemaVersion\", \"tables\", \"removable\", \"unpriced\"],\n additionalProperties: false,\n} as const\n\nconst FilterOptionSchema = {\n type: \"object\",\n properties: { value: { type: \"string\" }, steps: { type: \"number\" } },\n required: [\"value\", \"steps\"],\n additionalProperties: false,\n} as const\n\nconst PruneResultSchema = {\n type: \"object\",\n properties: {\n steps: { type: \"number\" },\n prompts: { type: \"number\" },\n events: { type: \"number\" },\n usage: { type: \"number\" },\n },\n required: [\"steps\", \"prompts\", \"events\", \"usage\"],\n additionalProperties: false,\n} as const\n\nconst WipeResultSchema = {\n type: \"object\",\n properties: {\n steps: { type: \"number\" },\n prompts: { type: \"number\" },\n events: { type: \"number\" },\n usage: { type: \"number\" },\n sessions: { type: \"number\" },\n },\n required: [\"steps\", \"prompts\", \"events\", \"usage\", \"sessions\"],\n additionalProperties: false,\n} as const\n\nconst BackfillResultSchema = {\n type: \"object\",\n properties: {\n candidates: { type: \"number\" },\n updated: { type: \"number\" },\n },\n required: [\"candidates\", \"updated\"],\n additionalProperties: false,\n} as const\n\nconst VacuumResultSchema = {\n type: \"object\",\n properties: {\n before: { type: \"number\" },\n after: { type: \"number\" },\n freed: { type: \"number\" },\n },\n required: [\"before\", \"after\", \"freed\"],\n additionalProperties: false,\n} as const\n\nconst NoInput = { type: \"object\", properties: {}, additionalProperties: false } as const\n\nconst ErrorSchema = {\n type: \"object\",\n properties: { message: { type: \"string\", maxLength: 500 } },\n additionalProperties: false,\n} as const\n\nconst errors = {\n busy: ErrorSchema,\n unavailable: ErrorSchema,\n disabled: ErrorSchema,\n invalid: ErrorSchema,\n} as const\n\nexport const UsageInsights = Rpc.define({\n id: \"usage-insights\",\n methods: {\n panel: {\n input: {\n type: \"object\",\n properties: {\n sessionID: { type: \"string\", maxLength: 200 },\n settings: PanelSettingsSchema,\n detail: PanelRowSchema,\n width: { type: \"number\", minimum: 20, maximum: MAX_PANEL_WIDTH },\n busy: { type: \"boolean\" },\n },\n required: [\"sessionID\", \"settings\", \"width\"],\n additionalProperties: false,\n },\n output: {\n type: \"object\",\n properties: {\n lines: { type: \"array\", items: PanelLineSchema },\n database: DbInfoSchema,\n },\n required: [\"lines\"],\n additionalProperties: false,\n },\n errors,\n },\n turns: {\n input: {\n type: \"object\",\n properties: {\n sessionID: { type: \"string\", maxLength: 200 },\n limit: { type: \"number\", minimum: 1, maximum: MAX_TURNS },\n width: { type: \"number\", minimum: 20, maximum: 120 },\n },\n required: [\"sessionID\", \"limit\", \"width\"],\n additionalProperties: false,\n },\n output: {\n type: \"object\",\n properties: {\n summary: { type: \"array\", items: PanelLineSchema },\n history: { type: \"array\", items: PanelLineSchema },\n },\n required: [\"summary\", \"history\"],\n additionalProperties: false,\n },\n errors,\n },\n listCost: {\n input: {\n type: \"object\",\n properties: { sessionID: { type: \"string\", maxLength: 200 } },\n required: [\"sessionID\"],\n additionalProperties: false,\n },\n output: {\n type: \"object\",\n properties: { cost: { type: \"number\" } },\n required: [\"cost\"],\n additionalProperties: false,\n },\n errors,\n },\n filters: {\n input: NoInput,\n output: {\n type: \"object\",\n properties: {\n models: { type: \"array\", items: FilterOptionSchema },\n providers: { type: \"array\", items: FilterOptionSchema },\n },\n required: [\"models\", \"providers\"],\n additionalProperties: false,\n },\n errors,\n },\n dbInfo: {\n input: NoInput,\n output: DbInfoSchema,\n errors,\n },\n prune: {\n input: {\n type: \"object\",\n properties: {\n days: { type: \"number\", minimum: 1, maximum: 3650 },\n confirm: { type: \"boolean\", enum: [true] },\n },\n required: [\"days\", \"confirm\"],\n additionalProperties: false,\n },\n output: PruneResultSchema,\n errors,\n },\n wipe: {\n input: {\n type: \"object\",\n properties: { confirm: { type: \"boolean\", enum: [true] } },\n required: [\"confirm\"],\n additionalProperties: false,\n },\n output: WipeResultSchema,\n errors,\n },\n vacuum: {\n input: {\n type: \"object\",\n properties: { confirm: { type: \"boolean\", enum: [true] } },\n required: [\"confirm\"],\n additionalProperties: false,\n },\n output: VacuumResultSchema,\n errors,\n },\n backfill: {\n input: {\n type: \"object\",\n properties: { confirm: { type: \"boolean\", enum: [true] } },\n required: [\"confirm\"],\n additionalProperties: false,\n },\n output: BackfillResultSchema,\n errors,\n },\n },\n events: {\n recorded: {\n schema: {\n type: \"object\",\n properties: {\n sessionID: { type: \"string\", maxLength: 200 },\n at: { type: \"number\" },\n },\n required: [\"at\"],\n additionalProperties: false,\n },\n },\n },\n})\n",
6
6
  "/**\n * Shared request bounds.\n *\n * The RPC schemas, the clients and the service use the same numbers: a client\n * must clamp before it calls the RPC, because schema validation runs before the\n * service can clamp. These constants keep the three layers from drifting.\n */\n\n/** Widest panel the server formats. */\nexport const MAX_PANEL_WIDTH = 200\n\n/** Most turns the server returns for a history request. */\nexport const MAX_TURNS = 50\n\n/** A finite width within the panel bounds. */\nexport function clampPanelWidth(value: number): number {\n if (!Number.isFinite(value)) return 20\n return Math.min(MAX_PANEL_WIDTH, Math.max(20, Math.round(value)))\n}\n\n/** A finite turn limit within the history bounds. */\nexport function clampTurnsLimit(value: number): number {\n if (!Number.isFinite(value)) return 1\n return Math.min(MAX_TURNS, Math.max(1, Math.round(value)))\n}\n"
7
7
  ],
8
- "mappings": ";;AAAA;;;ACSO,IAAM,kBAAkB;AAGxB,IAAM,YAAY;AAGlB,SAAS,eAAe,CAAC,OAAuB;AAAA,EACrD,IAAI,CAAC,OAAO,SAAS,KAAK;AAAA,IAAG,OAAO;AAAA,EACpC,OAAO,KAAK,IAAI,iBAAiB,KAAK,IAAI,IAAI,KAAK,MAAM,KAAK,CAAC,CAAC;AAAA;AAI3D,SAAS,eAAe,CAAC,OAAuB;AAAA,EACrD,IAAI,CAAC,OAAO,SAAS,KAAK;AAAA,IAAG,OAAO;AAAA,EACpC,OAAO,KAAK,IAAI,WAAW,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,CAAC,CAAC;AAAA;;;AD6D3D,IAAM,OAAO,EAAE,MAAM,UAAU,MAAM,CAAC,QAAQ,SAAS,WAAW,QAAQ,EAAE;AAE5E,IAAM,iBAAiB;AAAA,EACrB,MAAM;AAAA,EACN,YAAY;AAAA,IACV,MAAM,EAAE,MAAM,UAAU,MAAM,CAAC,SAAS,WAAW,UAAU,YAAY,QAAQ,SAAS,MAAM,EAAE;AAAA,IAClG,OAAO,EAAE,MAAM,UAAU,WAAW,IAAI;AAAA,IACxC,SAAS,EAAE,MAAM,UAAU,WAAW,IAAI;AAAA,EAC5C;AAAA,EACA,UAAU,CAAC,QAAQ,OAAO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ACN,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,MAAM,CAAC,IAAI,EAAE,EAAE;AAAA,QACzD,UAAU,CAAC,SAAS;AAAA,QACpB,sBAAsB;AAAA,MACxB;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN,UAAU;AAAA,MACR,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,YAAY;AAAA,UACV,WAAW,EAAE,MAAM,UAAU,WAAW,IAAI;AAAA,UAC5C,IAAI,EAAE,MAAM,SAAS;AAAA,QACvB;AAAA,QACA,UAAU,CAAC,IAAI;AAAA,QACf,sBAAsB;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACF,CAAC;",
9
+ "debugId": "353CEB0AA16B78BF64756E2164756E21",
10
10
  "names": []
11
11
  }
package/dist/sidebar.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Context } from "@opencode/plugin/tui/context";
2
+ import type { QuotaFetch } from "./quota";
2
3
  /**
3
4
  * Sidebar history: the session's accumulated usage, then the last finished
4
5
  * turns — when and through which provider, the model when it changed, and the
@@ -17,4 +18,8 @@ export declare function TurnsSidebar(props: {
17
18
  readonly sessionID: string;
18
19
  readonly ctx: Context;
19
20
  readonly deps: TurnsSidebarDeps;
21
+ /** Live Go allowance; omitted when `quota: "off"`. */
22
+ readonly quota?: (() => QuotaFetch | undefined) | undefined;
23
+ /** Full subscription label. */
24
+ readonly quotaName?: string | undefined;
20
25
  }): any;