opencode-usage-insights 0.3.0 → 0.4.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.
Files changed (58) hide show
  1. package/README.md +66 -542
  2. package/dist/core.d.ts +15 -1
  3. package/dist/gui-experimental.cjs +3 -3
  4. package/dist/index.d.ts +0 -47
  5. package/dist/index.js +2066 -1363
  6. package/dist/index.js.map +25 -18
  7. package/dist/limits.d.ts +9 -0
  8. package/dist/line.d.ts +1 -0
  9. package/dist/panel-data.d.ts +56 -7
  10. package/dist/recorder.d.ts +1 -0
  11. package/dist/rpc.d.ts +4 -4
  12. package/dist/rpc.js +7 -6
  13. package/dist/rpc.js.map +4 -4
  14. package/dist/settings-client.d.ts +29 -0
  15. package/dist/settings-rpc.d.ts +746 -0
  16. package/dist/settings.d.ts +114 -0
  17. package/dist/sidebar.d.ts +3 -3
  18. package/dist/stats/aggregates.d.ts +19 -4
  19. package/dist/stats/constants.d.ts +7 -0
  20. package/dist/stats/db.d.ts +8 -128
  21. package/dist/stats/legacy.d.ts +25 -0
  22. package/dist/stats/maintenance.d.ts +1 -1
  23. package/dist/stats/migrate.d.ts +7 -0
  24. package/dist/stats/ndjson.d.ts +16 -0
  25. package/dist/stats/open.d.ts +15 -0
  26. package/dist/stats/paths.d.ts +5 -4
  27. package/dist/stats/queries.d.ts +25 -31
  28. package/dist/stats/records.d.ts +94 -0
  29. package/dist/stats/schema.d.ts +26 -0
  30. package/dist/stats-client.d.ts +9 -0
  31. package/dist/stats-worker.js +1012 -604
  32. package/dist/stats-worker.js.map +19 -14
  33. package/dist/text.d.ts +2 -0
  34. package/dist/tui-settings.d.ts +18 -0
  35. package/dist/tui.d.ts +1 -57
  36. package/dist/tui.js +1364 -384
  37. package/dist/tui.js.map +17 -13
  38. package/docs/cli.md +24 -0
  39. package/docs/configuration.md +108 -0
  40. package/docs/costs.md +44 -0
  41. package/docs/demo.md +94 -68
  42. package/docs/desktop.md +91 -0
  43. package/docs/images/desktop-overview-annotated.png +0 -0
  44. package/docs/images/desktop-overview.png +0 -0
  45. package/docs/images/desktop-settings.png +0 -0
  46. package/docs/images/desktop-turns-go-annotated.png +0 -0
  47. package/docs/images/desktop-turns.png +0 -0
  48. package/docs/images/line.png +0 -0
  49. package/docs/images/panel-cache.png +0 -0
  50. package/docs/images/panel-help.png +0 -0
  51. package/docs/images/panel-latency.png +0 -0
  52. package/docs/images/panel-overview.png +0 -0
  53. package/docs/images/panel-providers.png +0 -0
  54. package/docs/images/sidebar.png +0 -0
  55. package/docs/internals.md +87 -36
  56. package/docs/privacy.md +60 -0
  57. package/docs/tui.md +175 -0
  58. package/package.json +2 -1
package/dist/limits.d.ts CHANGED
@@ -7,9 +7,18 @@
7
7
  */
8
8
  /** Widest panel the server formats. */
9
9
  export declare const MAX_PANEL_WIDTH = 200;
10
+ /** Widest turn history the server formats. */
11
+ export declare const MAX_HISTORY_WIDTH = 120;
10
12
  /** Most turns the server returns for a history request. */
11
13
  export declare const MAX_TURNS = 50;
12
14
  /** A finite width within the panel bounds. */
13
15
  export declare function clampPanelWidth(value: number): number;
16
+ /**
17
+ * How many monospace cells fit in a panel body. The GUI measures the body and
18
+ * one glyph; both are CSS pixels, so the division is exact before the floor.
19
+ * A zero measurement means the body is not laid out (hidden or not mounted):
20
+ * the caller keeps its previous width instead of asking for a 20-column panel.
21
+ */
22
+ export declare function panelColumns(available: number, charWidth: number): number;
14
23
  /** A finite turn limit within the history bounds. */
15
24
  export declare function clampTurnsLimit(value: number): number;
package/dist/line.d.ts CHANGED
@@ -26,6 +26,7 @@ export type RuntimeMessage = {
26
26
  type?: string | undefined;
27
27
  time?: {
28
28
  created?: number | undefined;
29
+ firstToken?: number | undefined;
29
30
  streamed?: number | undefined;
30
31
  completed?: number | undefined;
31
32
  } | undefined;
@@ -1,5 +1,6 @@
1
1
  import { type LineFields, type LineLabels, type TurnStats, type TurnTotalsView } from "./core";
2
- import type { CacheDropRow, LatencyReport, ModelUsage, Overview, Range, SessionUsage, TurnUsage, TtlEvidenceRow } from "./stats/queries";
2
+ import type { LatencyReport, ModelUsage, Overview, Range, SessionUsage, TurnUsage } from "./stats/queries";
3
+ import type { CacheDropRow, TtlEvidenceRow } from "./stats/aggregates";
3
4
  import type { DbInfo } from "./stats/maintenance";
4
5
  import type { CacheStats, CoverageReport, ProviderRow, ProviderSummary, GapReport, LatencyGroupRow, PeriodGranularity, PeriodRow, SwitchRow } from "./stats/aggregates";
5
6
  import { QUOTA_VIEW, type QuotaFetch } from "./quota";
@@ -82,17 +83,18 @@ export declare function formatMs(value: number | undefined): string;
82
83
  export declare function formatTps(value: number | undefined): string;
83
84
  /** A rate that has to fit a sidebar: whole numbers from 10 up. */
84
85
  export declare function formatTpsCompact(value: number | undefined): string;
86
+ /**
87
+ * A bare rate for a line that supplies its own `tps`/`rtps` label. Adding the
88
+ * unit twice (`50/s tps`) is the easy mistake; this formatter exists so no
89
+ * caller has to remember which one carries it.
90
+ */
91
+ export declare function formatRateValue(value: number | undefined): string;
85
92
  /** Idle gaps are read at a glance: seconds, minutes, hours, days. */
86
93
  export declare function formatGap(value: number | undefined): string;
87
94
  /** Cut a value to the width, dropping control characters first. */
88
95
  export declare function truncate(value: string, width: number): string;
89
96
  /** Keep both ends of a long id: the family reads first, the `#variant` last. */
90
97
  export declare function truncateMiddle(value: string, width: number): string;
91
- /**
92
- * Pick the widest column layout that fits the panel. A table that overflows
93
- * wraps and stops reading as a table, so the columns are chosen, not squeezed.
94
- */
95
- export declare function tableWidths(width: number, layouts: readonly (readonly number[])[]): number[];
96
98
  /**
97
99
  * A model cell keeps the variant visible: two rows of the same family must not
98
100
  * read alike after truncation.
@@ -100,6 +102,45 @@ export declare function tableWidths(width: number, layouts: readonly (readonly n
100
102
  export declare function modelCell(modelID: string, variant: string | undefined, width: number): string;
101
103
  export declare function padCell(value: string, width: number, align?: "left" | "right"): string;
102
104
  export declare function formatTableRow(cells: readonly string[], widths: readonly number[], aligns?: readonly ("left" | "right")[]): string;
105
+ /**
106
+ * One column in a table that has to fit a panel width. `width` is the compact
107
+ * width (and the fixed width when `max` is omitted); `max` is the widest it may
108
+ * grow into leftover space; optional columns carry a priority and are added
109
+ * only when they fit. `reserve` keeps the space an optional column would
110
+ * otherwise take from the text column before it (a model name, a provider).
111
+ */
112
+ export type TableColumnFit = {
113
+ width: number;
114
+ max?: number | undefined;
115
+ priority?: number | undefined;
116
+ reserve?: number | undefined;
117
+ };
118
+ export type FittedWidth = {
119
+ index: number;
120
+ width: number;
121
+ };
122
+ /**
123
+ * Fit a table's columns into the panel width. Required columns are kept,
124
+ * optional ones are added in priority order while they fit, and the leftover
125
+ * goes to the columns in display order, each up to its maximum. Dropped
126
+ * columns are absent from the result, so a caller never renders a zero-width
127
+ * cell. The growth order is the display order: the text column is first.
128
+ */
129
+ export declare function fitTableColumns(columns: readonly TableColumnFit[], width: number): FittedWidth[];
130
+ /** A fitted column ready to render: header, final width, alignment and cell. */
131
+ export type FittedTableColumn<Row> = {
132
+ /** The column's position in the input, so callers can find a special one. */
133
+ index: number;
134
+ header: string;
135
+ width: number;
136
+ align: "left" | "right";
137
+ cell: (row: Row) => string;
138
+ };
139
+ export declare function fitTable<Row>(columns: readonly (TableColumnFit & {
140
+ header: string;
141
+ align?: "left" | "right" | undefined;
142
+ cell: (row: Row) => string;
143
+ })[], width: number): FittedTableColumn<Row>[];
103
144
  export declare function count(n: number, singular: string, plural?: string): string;
104
145
  /** Two label/value pairs per row, collapsed to one pair on narrow panels. */
105
146
  export declare function kvGrid(pairs: readonly (readonly [string, string])[], width: number): PanelLine[];
@@ -227,10 +268,18 @@ export type LineFormatOptions = {
227
268
  };
228
269
  /** The line's own view of a recorded turn, so both render identically. */
229
270
  export declare function turnStats(turn: TurnUsage): TurnStats;
271
+ /**
272
+ * A budget form of the turn line for a panel too narrow for the live line.
273
+ * It always keeps the money and the identity, then adds the token volumes
274
+ * while they fit. `turnsLines` uses the full line whenever it fits, so this
275
+ * only changes the rows that would otherwise have their tail cut off.
276
+ */
277
+ export declare function compactTurnLine(stats: TurnStats, width: number, options?: LineFormatOptions): string;
230
278
  /**
231
279
  * Per-prompt history: one line per finished turn, rendered by the same
232
280
  * formatter as the live line (without the session segment, which would repeat
233
- * the same totals on every row).
281
+ * the same totals on every row). A narrow panel uses `compactTurnLine` rather
282
+ * than cutting the money off the end of the line.
234
283
  */
235
284
  export declare function turnsLines(rows: readonly TurnUsage[], width: number, options?: LineFormatOptions & {
236
285
  sessionTitles?: Map<string, string> | undefined;
@@ -59,6 +59,7 @@ export type PendingStep = {
59
59
  messageID: string;
60
60
  sessionID: string;
61
61
  started: number | undefined;
62
+ firstToken: number | undefined;
62
63
  streamed: number | undefined;
63
64
  model: SessionModelRef | undefined;
64
65
  };
package/dist/rpc.d.ts CHANGED
@@ -731,14 +731,14 @@ export declare const UsageInsights: {
731
731
  readonly prompts: {
732
732
  readonly type: "number";
733
733
  };
734
- readonly events: {
734
+ readonly compactions: {
735
735
  readonly type: "number";
736
736
  };
737
737
  readonly usage: {
738
738
  readonly type: "number";
739
739
  };
740
740
  };
741
- readonly required: readonly ["steps", "prompts", "events", "usage"];
741
+ readonly required: readonly ["steps", "prompts", "compactions", "usage"];
742
742
  readonly additionalProperties: false;
743
743
  };
744
744
  readonly errors: {
@@ -805,7 +805,7 @@ export declare const UsageInsights: {
805
805
  readonly prompts: {
806
806
  readonly type: "number";
807
807
  };
808
- readonly events: {
808
+ readonly compactions: {
809
809
  readonly type: "number";
810
810
  };
811
811
  readonly usage: {
@@ -815,7 +815,7 @@ export declare const UsageInsights: {
815
815
  readonly type: "number";
816
816
  };
817
817
  };
818
- readonly required: readonly ["steps", "prompts", "events", "usage", "sessions"];
818
+ readonly required: readonly ["steps", "prompts", "compactions", "usage", "sessions"];
819
819
  readonly additionalProperties: false;
820
820
  };
821
821
  readonly errors: {
package/dist/rpc.js CHANGED
@@ -4,6 +4,7 @@ import { Rpc } from "@opencode/plugin/rpc";
4
4
 
5
5
  // src/limits.ts
6
6
  var MAX_PANEL_WIDTH = 200;
7
+ var MAX_HISTORY_WIDTH = 120;
7
8
  var MAX_TURNS = 50;
8
9
  function clampPanelWidth(value) {
9
10
  if (!Number.isFinite(value))
@@ -98,10 +99,10 @@ var PruneResultSchema = {
98
99
  properties: {
99
100
  steps: { type: "number" },
100
101
  prompts: { type: "number" },
101
- events: { type: "number" },
102
+ compactions: { type: "number" },
102
103
  usage: { type: "number" }
103
104
  },
104
- required: ["steps", "prompts", "events", "usage"],
105
+ required: ["steps", "prompts", "compactions", "usage"],
105
106
  additionalProperties: false
106
107
  };
107
108
  var WipeResultSchema = {
@@ -109,11 +110,11 @@ var WipeResultSchema = {
109
110
  properties: {
110
111
  steps: { type: "number" },
111
112
  prompts: { type: "number" },
112
- events: { type: "number" },
113
+ compactions: { type: "number" },
113
114
  usage: { type: "number" },
114
115
  sessions: { type: "number" }
115
116
  },
116
- required: ["steps", "prompts", "events", "usage", "sessions"],
117
+ required: ["steps", "prompts", "compactions", "usage", "sessions"],
117
118
  additionalProperties: false
118
119
  };
119
120
  var BackfillResultSchema = {
@@ -180,7 +181,7 @@ var UsageInsights = Rpc.define({
180
181
  properties: {
181
182
  sessionID: { type: "string", maxLength: 200 },
182
183
  limit: { type: "number", minimum: 1, maximum: MAX_TURNS },
183
- width: { type: "number", minimum: 20, maximum: 120 }
184
+ width: { type: "number", minimum: 20, maximum: MAX_HISTORY_WIDTH }
184
185
  },
185
186
  required: ["sessionID", "limit", "width"],
186
187
  additionalProperties: false
@@ -291,4 +292,4 @@ export {
291
292
  UsageInsights
292
293
  };
293
294
 
294
- //# debugId=353CEB0AA16B78BF64756E2164756E21
295
+ //# debugId=CA8589888C19446A64756E2164756E21
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\", \"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
- "/**\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"
5
+ "import { Rpc } from \"@opencode/plugin/rpc\"\nimport { MAX_HISTORY_WIDTH, 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 compactions: { type: \"number\" },\n usage: { type: \"number\" },\n },\n required: [\"steps\", \"prompts\", \"compactions\", \"usage\"],\n additionalProperties: false,\n} as const\n\nconst WipeResultSchema = {\n type: \"object\",\n properties: {\n steps: { type: \"number\" },\n prompts: { type: \"number\" },\n compactions: { type: \"number\" },\n usage: { type: \"number\" },\n sessions: { type: \"number\" },\n },\n required: [\"steps\", \"prompts\", \"compactions\", \"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: MAX_HISTORY_WIDTH },\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
+ "/**\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/** Widest turn history the server formats. */\nexport const MAX_HISTORY_WIDTH = 120\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/**\n * How many monospace cells fit in a panel body. The GUI measures the body and\n * one glyph; both are CSS pixels, so the division is exact before the floor.\n * A zero measurement means the body is not laid out (hidden or not mounted):\n * the caller keeps its previous width instead of asking for a 20-column panel.\n */\nexport function panelColumns(available: number, charWidth: number): number {\n if (!Number.isFinite(available) || !Number.isFinite(charWidth) || available <= 0 || charWidth <= 0) return 0\n return clampPanelWidth(Math.floor(available / charWidth))\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;AAAA,EAC1B,sBAAsB;AACxB;AAEA,IAAM,kBAAkB;AAAA,EACtB,MAAM;AAAA,EACN,YAAY;AAAA,IACV,MAAM,EAAE,MAAM,SAAS;AAAA,IACvB,MAAM;AAAA,IACN,MAAM,EAAE,MAAM,UAAU;AAAA,IACxB,KAAK;AAAA,EACP;AAAA,EACA,UAAU,CAAC,MAAM;AAAA,EACjB,sBAAsB;AACxB;AAEA,IAAM,sBAAsB;AAAA,EAC1B,MAA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AY;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": "CA8589888C19446A64756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -0,0 +1,29 @@
1
+ import type { OpenCodeClient } from "@opencode/client";
2
+ import { type UsageSettingsEnvelope, type UsageSettingsPatch } from "./settings";
3
+ /**
4
+ * The settings plumbing shared by the TUI and the desktop app: connect to the
5
+ * server's event stream, refresh on demand, send a partial update, reset, and
6
+ * stop. The two surfaces differ only in when they call these methods and how
7
+ * they show errors.
8
+ */
9
+ export type SettingsSync = {
10
+ connect(): void;
11
+ refresh(force?: boolean): Promise<void>;
12
+ update(patch: UsageSettingsPatch): Promise<void>;
13
+ reset(): Promise<void>;
14
+ stop(): void;
15
+ };
16
+ export type SettingsSyncOptions = {
17
+ /** Read the client where it is used: it changes after a server restart. */
18
+ readonly client: () => OpenCodeClient;
19
+ readonly set: (next: UsageSettingsEnvelope) => void;
20
+ /** Skip an incoming value while the caller has a local edit pending. */
21
+ readonly canApply?: (next: UsageSettingsEnvelope) => boolean;
22
+ /** Replace the default event acceptance check. Return false to ignore. */
23
+ readonly acceptEvent?: (next: UsageSettingsEnvelope) => boolean;
24
+ /** Load failures: fetch or event subscription. */
25
+ readonly onLoadError?: (message: string) => void;
26
+ /** Save and reset failures. */
27
+ readonly onSaveError?: (message: string) => void;
28
+ };
29
+ export declare function createSettingsSync(options: SettingsSyncOptions): SettingsSync;