@encoredigitalgroup/opencode 0.2.7 → 0.2.8

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 +101 -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 +9125 -35
  70. package/dist/tui/index.js +5926 -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,638 @@
1
+ import type { Node } from "jsonc-parser";
2
+ import type { QuotaWindow } from "../core/types.js";
3
+ import { describeQuotaProviderRequest, type QuotaProviderDefinition } from "../lib/quota-providers.js";
4
+ type NumberBounds = {
5
+ min?: number;
6
+ above?: number;
7
+ max?: number;
8
+ };
9
+ export type SettingRule = ({
10
+ kind: "boolean";
11
+ } | {
12
+ kind: "choice";
13
+ values: readonly string[];
14
+ }
15
+ /**
16
+ * `above` is an exclusive lower bound, `min` and `max` inclusive ones. `word` is a word the
17
+ * setting takes instead of a number ("fill").
18
+ */
19
+ | ({
20
+ kind: "number";
21
+ integer: boolean;
22
+ nullable?: boolean;
23
+ word?: string;
24
+ } & NumberBounds)
25
+ /** An absolute or `~/` path without `..`; also "" or a command name when allowed. */
26
+ | {
27
+ kind: "path";
28
+ allowEmpty?: boolean;
29
+ allowCommand?: boolean;
30
+ } | {
31
+ kind: "providers" | "customProviders" | "strings" | "names" | "rowOrder" | "window" | "color" | "separator";
32
+ }) & {
33
+ default: unknown;
34
+ /** Only the file sets it (by hand or by an agent): `saveSettings` needs `allowFileOnly`. */
35
+ fileOnly?: boolean;
36
+ };
37
+ /** The names a color setting takes besides "#rrggbb": theme colors, and the row's bar color. */
38
+ export declare const THEME_COLOR_NAMES: readonly ["text", "muted", "accent", "green", "yellow", "red", "blue", "bar"];
39
+ /** Every setting by its dotted key with its default, in the order a new file lists them. */
40
+ export declare const SETTINGS_SCHEMA: {
41
+ readonly version: {
42
+ readonly default: 6;
43
+ readonly kind: "number";
44
+ readonly integer: true;
45
+ readonly min: number;
46
+ readonly max: number | undefined;
47
+ };
48
+ readonly "sidebar.show": {
49
+ readonly kind: "boolean";
50
+ readonly default: boolean;
51
+ };
52
+ readonly "sidebar.sessionTokens": {
53
+ readonly kind: "boolean";
54
+ readonly default: boolean;
55
+ };
56
+ readonly "sidebar.runsOut": {
57
+ readonly kind: "boolean";
58
+ readonly default: boolean;
59
+ };
60
+ readonly "sidebar.hidden": {
61
+ readonly kind: "strings";
62
+ readonly default: readonly [];
63
+ };
64
+ readonly "sidebar.providerOrder": {
65
+ readonly kind: "strings";
66
+ readonly default: readonly [];
67
+ };
68
+ readonly "sidebar.rowOrder": {
69
+ readonly kind: "rowOrder";
70
+ readonly default: {};
71
+ };
72
+ readonly "sidebar.names": {
73
+ readonly kind: "names";
74
+ readonly default: {};
75
+ };
76
+ readonly "collapsed.show": {
77
+ readonly kind: "boolean";
78
+ readonly default: boolean;
79
+ };
80
+ readonly "collapsed.runsOut": {
81
+ readonly kind: "boolean";
82
+ readonly default: boolean;
83
+ };
84
+ readonly "collapsed.hidden": {
85
+ readonly kind: "strings";
86
+ readonly default: readonly [];
87
+ };
88
+ readonly "collapsed.providerOrder": {
89
+ readonly kind: "strings";
90
+ readonly default: readonly [];
91
+ };
92
+ readonly "collapsed.rowOrder": {
93
+ readonly kind: "rowOrder";
94
+ readonly default: {};
95
+ };
96
+ /** A window by provider id; `ALL_PROVIDERS` ("*") for every provider without its own. */
97
+ readonly "collapsed.window": {
98
+ readonly kind: "window";
99
+ readonly default: {};
100
+ };
101
+ readonly "statusLine.show": {
102
+ readonly kind: "boolean";
103
+ readonly default: boolean;
104
+ };
105
+ /** Also while a sidebar panel shows quota; else only when none is on screen. */
106
+ readonly "statusLine.withSidebar": {
107
+ readonly kind: "boolean";
108
+ readonly default: boolean;
109
+ };
110
+ readonly "statusLine.runsOut": {
111
+ readonly kind: "boolean";
112
+ readonly default: boolean;
113
+ };
114
+ readonly "statusLine.hidden": {
115
+ readonly kind: "strings";
116
+ readonly default: readonly [];
117
+ };
118
+ readonly "statusLine.providerOrder": {
119
+ readonly kind: "strings";
120
+ readonly default: readonly [];
121
+ };
122
+ readonly "statusLine.rowOrder": {
123
+ readonly kind: "rowOrder";
124
+ readonly default: {};
125
+ };
126
+ readonly "statusLine.window": {
127
+ readonly kind: "window";
128
+ readonly default: {};
129
+ };
130
+ readonly "statusLine.detail": {
131
+ readonly kind: "choice";
132
+ readonly values: readonly ["auto", "one", "full", "bar", "reset", "numbers"];
133
+ readonly default: "auto" | "one" | "full" | "bar" | "reset" | "numbers";
134
+ };
135
+ readonly "statusLine.width": {
136
+ readonly default: 0;
137
+ readonly kind: "number";
138
+ readonly integer: true;
139
+ readonly min: number;
140
+ readonly max: number | undefined;
141
+ };
142
+ readonly "statusLine.autoScrollSeconds": {
143
+ readonly default: 0;
144
+ readonly kind: "number";
145
+ readonly integer: true;
146
+ readonly min: number;
147
+ readonly max: number | undefined;
148
+ };
149
+ readonly "statusLine.home": {
150
+ readonly kind: "boolean";
151
+ readonly default: boolean;
152
+ };
153
+ readonly "toast.show": {
154
+ readonly kind: "boolean";
155
+ readonly default: boolean;
156
+ };
157
+ readonly "toast.runsOut": {
158
+ readonly kind: "boolean";
159
+ readonly default: boolean;
160
+ };
161
+ readonly "toast.hidden": {
162
+ readonly kind: "strings";
163
+ readonly default: readonly [];
164
+ };
165
+ readonly "toast.providerOrder": {
166
+ readonly kind: "strings";
167
+ readonly default: readonly [];
168
+ };
169
+ readonly "toast.rowOrder": {
170
+ readonly kind: "rowOrder";
171
+ readonly default: {};
172
+ };
173
+ readonly "toast.names": {
174
+ readonly kind: "names";
175
+ readonly default: {};
176
+ };
177
+ readonly "toast.afterReply": {
178
+ readonly kind: "choice";
179
+ readonly values: readonly ["off", "always", "low"];
180
+ readonly default: "low" | "off" | "always";
181
+ };
182
+ readonly "toast.afterQuestion": {
183
+ readonly kind: "boolean";
184
+ readonly default: boolean;
185
+ };
186
+ readonly "toast.afterCompaction": {
187
+ readonly kind: "boolean";
188
+ readonly default: boolean;
189
+ };
190
+ readonly "toast.whenAllFail": {
191
+ readonly kind: "boolean";
192
+ readonly default: boolean;
193
+ };
194
+ readonly "toast.resetNotice": {
195
+ readonly kind: "choice";
196
+ readonly values: readonly ["off", "weekly", "all"];
197
+ readonly default: "weekly" | "off" | "all";
198
+ };
199
+ /** "grouped": a line per row under its provider; "detailed": v5's two lines per row. */
200
+ readonly "toast.layout": {
201
+ readonly kind: "choice";
202
+ readonly values: readonly ["grouped", "detailed"];
203
+ readonly default: "grouped" | "detailed";
204
+ };
205
+ readonly "toast.seconds": {
206
+ readonly default: 9;
207
+ readonly kind: "number";
208
+ readonly integer: true;
209
+ readonly min: number;
210
+ readonly max: number | undefined;
211
+ };
212
+ readonly "toast.sessionTokens": {
213
+ readonly kind: "boolean";
214
+ readonly default: boolean;
215
+ };
216
+ readonly "colors.good": {
217
+ readonly kind: "color";
218
+ readonly default: undefined;
219
+ };
220
+ readonly "colors.warning": {
221
+ readonly kind: "color";
222
+ readonly default: undefined;
223
+ };
224
+ readonly "colors.low": {
225
+ readonly kind: "color";
226
+ readonly default: undefined;
227
+ };
228
+ readonly "colors.empty": {
229
+ readonly kind: "color";
230
+ readonly default: undefined;
231
+ };
232
+ readonly "colors.title": {
233
+ readonly kind: "color";
234
+ readonly default: undefined;
235
+ };
236
+ readonly "colors.provider": {
237
+ readonly kind: "color";
238
+ readonly default: undefined;
239
+ };
240
+ readonly "colors.account": {
241
+ readonly kind: "color";
242
+ readonly default: undefined;
243
+ };
244
+ readonly "colors.label": {
245
+ readonly kind: "color";
246
+ readonly default: undefined;
247
+ };
248
+ readonly "colors.percent": {
249
+ readonly kind: "color";
250
+ readonly default: undefined;
251
+ };
252
+ readonly "colors.reset": {
253
+ readonly kind: "color";
254
+ readonly default: undefined;
255
+ };
256
+ readonly "colors.value": {
257
+ readonly kind: "color";
258
+ readonly default: undefined;
259
+ };
260
+ readonly "colors.error": {
261
+ readonly kind: "color";
262
+ readonly default: undefined;
263
+ };
264
+ readonly "colors.statusName": {
265
+ readonly kind: "color";
266
+ readonly default: undefined;
267
+ };
268
+ readonly "colors.separator": {
269
+ readonly kind: "color";
270
+ readonly default: undefined;
271
+ };
272
+ readonly "colors.arrows": {
273
+ readonly kind: "color";
274
+ readonly default: undefined;
275
+ };
276
+ readonly "colors.warningBelow": {
277
+ readonly default: 50;
278
+ readonly kind: "number";
279
+ readonly integer: true;
280
+ readonly min: number;
281
+ readonly max: number | undefined;
282
+ };
283
+ readonly "colors.lowBelow": {
284
+ readonly default: 20;
285
+ readonly kind: "number";
286
+ readonly integer: true;
287
+ readonly min: number;
288
+ readonly max: number | undefined;
289
+ };
290
+ readonly "layout.bar": {
291
+ readonly kind: "choice";
292
+ readonly values: readonly ["blocks", "shades", "line", "squares", "dots", "none"];
293
+ readonly default: "none" | "blocks" | "shades" | "line" | "squares" | "dots";
294
+ };
295
+ /** "fill": the room the other columns leave, up to each place's most. */
296
+ readonly "layout.barWidth": {
297
+ readonly word: "fill";
298
+ readonly default: "fill";
299
+ readonly kind: "number";
300
+ readonly integer: true;
301
+ readonly min: number;
302
+ readonly max: number | undefined;
303
+ };
304
+ /** The ┃ mark where even use would be, in every place's bars (the Limits tab always has it). */
305
+ readonly "layout.evenUse": {
306
+ readonly kind: "boolean";
307
+ readonly default: boolean;
308
+ };
309
+ readonly "layout.indent": {
310
+ readonly default: 1;
311
+ readonly kind: "number";
312
+ readonly integer: true;
313
+ readonly min: number;
314
+ readonly max: number | undefined;
315
+ };
316
+ /** The most columns a row name takes; the name column fits the names next to a bar. */
317
+ readonly "layout.labelWidth": {
318
+ readonly default: 8;
319
+ readonly kind: "number";
320
+ readonly integer: true;
321
+ readonly min: number;
322
+ readonly max: number | undefined;
323
+ };
324
+ /** Empty lines between providers in the sidebar. */
325
+ readonly "layout.providerGap": {
326
+ readonly default: 1;
327
+ readonly kind: "number";
328
+ readonly integer: true;
329
+ readonly min: number;
330
+ readonly max: number | undefined;
331
+ };
332
+ /** Between providers on the status line. */
333
+ readonly "layout.separator": {
334
+ readonly kind: "separator";
335
+ readonly default: " · ";
336
+ };
337
+ /** The words every client uses: "58% left", "58% remaining", "58%", or "42% used". */
338
+ readonly "words.percent": {
339
+ readonly kind: "choice";
340
+ readonly values: readonly ["left", "remaining", "bare", "used"];
341
+ readonly default: "used" | "remaining" | "left" | "bare";
342
+ };
343
+ /** "4.5d" (smart), "2h 14m", "2h14m", "2h", or "2.2h" (with `resetDecimals`). */
344
+ readonly "words.reset": {
345
+ readonly kind: "choice";
346
+ readonly values: readonly ["smart", "exact", "compact", "short", "decimal"];
347
+ readonly default: "compact" | "decimal" | "smart" | "exact" | "short";
348
+ };
349
+ /** Decimals of the "decimal" reset style. */
350
+ readonly "words.resetDecimals": {
351
+ readonly default: 1;
352
+ readonly kind: "number";
353
+ readonly integer: true;
354
+ readonly min: number;
355
+ readonly max: number | undefined;
356
+ };
357
+ /**
358
+ * How the sidebar, the collapsed panel, the status line and toasts name a row: "short" by its
359
+ * window ("5h", "7d") unless another row of its provider has the same one, "full" by its label.
360
+ * A row you renamed shows your name in both.
361
+ */
362
+ readonly "words.rowNames": {
363
+ readonly kind: "choice";
364
+ readonly values: readonly ["short", "full"];
365
+ readonly default: "full" | "short";
366
+ };
367
+ /** "detailed" also shows supplementary rows. */
368
+ readonly "words.detail": {
369
+ readonly kind: "choice";
370
+ readonly values: readonly ["summary", "detailed"];
371
+ readonly default: "detailed" | "summary";
372
+ };
373
+ /** Show only the providers serving the session's current model. */
374
+ readonly "words.onlyCurrentModel": {
375
+ readonly kind: "boolean";
376
+ readonly default: boolean;
377
+ };
378
+ /** Session tokens of this session, or with its subagents. */
379
+ readonly "words.sessionTokens": {
380
+ readonly kind: "choice";
381
+ readonly values: readonly ["current", "tree"];
382
+ readonly default: "current" | "tree";
383
+ };
384
+ readonly "providers.off": {
385
+ readonly kind: "providers";
386
+ readonly default: readonly [];
387
+ };
388
+ readonly "providers.custom": {
389
+ readonly kind: "customProviders";
390
+ readonly default: readonly [];
391
+ readonly fileOnly: true;
392
+ };
393
+ /** The Claude CLI quota runs for Claude limits. */
394
+ readonly "providers.anthropic.binaryPath": {
395
+ readonly kind: "path";
396
+ readonly allowCommand: true;
397
+ readonly default: "claude";
398
+ readonly fileOnly: true;
399
+ };
400
+ readonly "providers.cursor.plan": {
401
+ readonly kind: "choice";
402
+ readonly values: readonly ["none", "pro", "pro-plus", "ultra"];
403
+ readonly default: "pro" | "none" | "pro-plus" | "ultra";
404
+ };
405
+ readonly "providers.cursor.includedApiUsd": {
406
+ readonly kind: "number";
407
+ readonly integer: false;
408
+ readonly above: 0;
409
+ readonly nullable: true;
410
+ readonly default: null;
411
+ };
412
+ readonly "providers.cursor.billingCycleStartDay": {
413
+ readonly nullable: true;
414
+ readonly default: null;
415
+ readonly kind: "number";
416
+ readonly integer: true;
417
+ readonly min: number;
418
+ readonly max: number | undefined;
419
+ };
420
+ readonly "providers.opencode.monthlyLimitUsd": {
421
+ readonly kind: "number";
422
+ readonly integer: false;
423
+ readonly above: 0;
424
+ readonly nullable: true;
425
+ readonly default: null;
426
+ };
427
+ readonly "providers.checking.minIntervalMs": {
428
+ readonly kind: "number";
429
+ readonly integer: false;
430
+ readonly above: 0;
431
+ readonly default: number;
432
+ };
433
+ readonly "providers.checking.requestTimeoutMs": {
434
+ readonly kind: "number";
435
+ readonly integer: false;
436
+ readonly above: 0;
437
+ readonly default: number;
438
+ };
439
+ readonly "providers.checking.waitForQuotaReset": {
440
+ readonly kind: "boolean";
441
+ readonly default: boolean;
442
+ };
443
+ readonly "providers.pricing.source": {
444
+ readonly kind: "choice";
445
+ readonly values: readonly ["auto", "bundled", "runtime"];
446
+ readonly default: "auto" | "bundled" | "runtime";
447
+ };
448
+ readonly "providers.pricing.autoRefreshDays": {
449
+ readonly default: 7;
450
+ readonly kind: "number";
451
+ readonly integer: true;
452
+ readonly min: number;
453
+ readonly max: number | undefined;
454
+ };
455
+ readonly "system.exportFile": {
456
+ readonly kind: "boolean";
457
+ readonly default: boolean;
458
+ };
459
+ /** "" = `$XDG_CACHE_HOME/opencode/quota-export.json`. */
460
+ readonly "system.exportPath": {
461
+ readonly kind: "path";
462
+ readonly allowEmpty: true;
463
+ readonly default: "";
464
+ readonly fileOnly: true;
465
+ };
466
+ readonly "system.telemetry": {
467
+ readonly kind: "boolean";
468
+ readonly default: boolean;
469
+ };
470
+ /** The 4.x and 5.x /tokens_* commands, each `/quota_usage` on its range. */
471
+ readonly "system.oldCommands": {
472
+ readonly kind: "boolean";
473
+ readonly default: boolean;
474
+ };
475
+ };
476
+ type KindValue = {
477
+ boolean: boolean;
478
+ number: number;
479
+ path: string;
480
+ providers: string[];
481
+ strings: string[];
482
+ names: Record<string, string>;
483
+ rowOrder: Record<string, string[]>;
484
+ window: Record<string, "lowest" | QuotaWindow>;
485
+ color: (typeof THEME_COLOR_NAMES)[number] | `#${string}` | undefined;
486
+ separator: string;
487
+ customProviders: QuotaProviderDefinition[];
488
+ };
489
+ type ValueOf<R> = R extends {
490
+ values: readonly (infer V)[];
491
+ } ? V : R extends {
492
+ word: infer W extends string;
493
+ } ? number | W : R extends {
494
+ nullable: true;
495
+ } ? number | null : R extends {
496
+ kind: infer K extends keyof KindValue;
497
+ } ? KindValue[K] : never;
498
+ type Head<K> = K extends `${infer Group}.${string}` ? Group : K;
499
+ type Under<T, Group extends string> = {
500
+ [K in keyof T as K extends `${Group}.${infer Rest}` ? Rest : never]: T[K];
501
+ };
502
+ /** `{ "a.b": X }` as `{ a: { b: X } }`. */
503
+ type Nest<T> = {
504
+ [K in keyof T as Head<K>]: K extends `${infer Group}.${string}` ? Nest<Under<T, Group>> : T[K];
505
+ };
506
+ type Schema = typeof SETTINGS_SCHEMA;
507
+ export type Settings = Nest<{
508
+ -readonly [K in keyof Schema]: ValueOf<Schema[K]>;
509
+ }>;
510
+ type Patch<T> = T extends readonly unknown[] ? T : T extends object ? {
511
+ [K in keyof T]?: Patch<T[K]> | null;
512
+ } : T;
513
+ /** A JSON merge patch of the settings: objects merge, null resets a key or a whole group. */
514
+ export type SettingsPatch = Patch<Settings>;
515
+ export declare function defaultSettings(): Settings;
516
+ export declare function isSettingsGroup(key: string): boolean;
517
+ /** Whether `key` is a file-only setting or a group that holds one. */
518
+ export declare function isFileOnly(key: string): boolean;
519
+ /** The names directly inside `group` ("" = the top level), in file order. */
520
+ export declare function keysUnder(group: string): string[];
521
+ /**
522
+ * A provider's id as `providers.off` stores it: the same id, except "custom" for the custom
523
+ * providers, which the registry and their rows call "quota-providers".
524
+ */
525
+ export declare function offProviderId(providerId: string): string;
526
+ /** Provider ids `providers.off` accepts; `custom` switches all custom providers off. */
527
+ export declare const PROVIDER_IDS: readonly string[];
528
+ /** What a rule accepts, in words, for issue messages and the agent tools. */
529
+ export declare function describeRule(rule: SettingRule): string;
530
+ export type SettingsIssue = {
531
+ key: string;
532
+ message: string;
533
+ };
534
+ /** A checked value: `value` to use when present, and what was wrong with it. */
535
+ export type CheckedSetting = {
536
+ value?: unknown;
537
+ issues: SettingsIssue[];
538
+ };
539
+ export declare function isRecordSetting(key: string): boolean;
540
+ /** Checks one value against its rule; `key` must be in SETTINGS_SCHEMA. */
541
+ export declare function checkSetting(key: string, value: unknown): CheckedSetting;
542
+ /** One `key: value` a file or a patch sets, in the order it sets them. */
543
+ type Assignment = {
544
+ key: string;
545
+ value: unknown;
546
+ };
547
+ /** How to walk a value: plain JSON values, or jsonc-parser nodes (which keep duplicate keys). */
548
+ type Walker<T> = {
549
+ entries(value: T): Array<[string, T]> | undefined;
550
+ leaf(value: T): unknown;
551
+ };
552
+ export declare const PLAIN_WALKER: Walker<unknown>;
553
+ export declare const NODE_WALKER: Walker<Node>;
554
+ /** A file sets a key twice: reading uses the last valid value, saving refuses. */
555
+ export declare const DUPLICATE_KEY = "duplicate key; the last valid value is used";
556
+ /** A name with a dot ("words.percent") is not read (settings nest), and saving refuses it. */
557
+ export declare const DOTTED_KEY = "a key with a dot is not read";
558
+ /**
559
+ * The settings an object sets, as dotted keys in order. Unknown, duplicate and dotted keys
560
+ * become issues; a group set to something other than an object becomes an assignment of the group
561
+ * key, so the caller decides (an issue when reading, a reset when a patch says null). An issue
562
+ * names a settings key, or the position of a name that is not one: a name that is not a setting
563
+ * is never repeated, so a secret typed as a key name stays out of every message.
564
+ */
565
+ export declare function flattenSettings<T>(walker: Walker<T>, value: T, prefix?: string): {
566
+ assignments: Assignment[];
567
+ issues: SettingsIssue[];
568
+ };
569
+ /** Sets a dotted key in a nested object, making the groups on the way. */
570
+ export declare function setPath(target: object, key: string, value: unknown): void;
571
+ /**
572
+ * The defaults with every valid assignment applied in order. An invalid value is reported and
573
+ * changes nothing, so a bad value later in the file never replaces a good one before it.
574
+ */
575
+ export declare function settingsFrom(assignments: readonly Assignment[]): {
576
+ settings: Settings;
577
+ issues: SettingsIssue[];
578
+ fromFile: string[];
579
+ };
580
+ /**
581
+ * Settings where no value is not the same as the default value: unset, the providers with their
582
+ * own request timeout use it; set, every provider uses that one.
583
+ */
584
+ export declare const UNSET_IS_NOT_DEFAULT: ReadonlySet<string>;
585
+ /**
586
+ * Every setting whose value differs between `before` and `after`. With the keys each file sets,
587
+ * a setting in `UNSET_IS_NOT_DEFAULT` the file does not set is null, so setting it to its
588
+ * default or removing it is a change too.
589
+ */
590
+ export declare function diffSettings(before: Settings, after: Settings, fromFile?: {
591
+ before: readonly string[];
592
+ after: readonly string[];
593
+ }): Array<{
594
+ key: string;
595
+ before: unknown;
596
+ after: unknown;
597
+ }>;
598
+ /** A custom provider as the quota window's Providers tab shows it, with its on/off switch. */
599
+ export type CustomProviderSwitch = {
600
+ id: string;
601
+ label: string;
602
+ enabled: boolean;
603
+ /** Where it sends its key, and which key; null for a local estimate, which sends nothing. */
604
+ request: ReturnType<typeof describeQuotaProviderRequest>;
605
+ /** `customProviderFingerprint`: switching it on sends it back, so it is this definition. */
606
+ fingerprint: string;
607
+ };
608
+ /** Why a custom provider is not switched on: its definition is not the one the user saw. */
609
+ export declare const CHANGED_SINCE_REVIEW = "changed since you reviewed it; look again";
610
+ /**
611
+ * A hash of what the user checks before switching a custom provider on (`request`) and of the
612
+ * fields that decide where its request goes and which key it reads.
613
+ */
614
+ export declare function customProviderFingerprint(definition: QuotaProviderDefinition): string;
615
+ /** The file settings a client shows and edits in the quota window. */
616
+ export type ClientSettings = {
617
+ /** Every setting but `version` and the file-only ones, by dotted key ("words.percent"). */
618
+ values: Record<string, unknown>;
619
+ /**
620
+ * The keys of `values` that settings.jsonc sets, with an invalid value too (shown as its
621
+ * default); the others follow their defaults.
622
+ */
623
+ fromFile: string[];
624
+ /** The ids `providers.off` takes, with their names. */
625
+ providers: Array<{
626
+ id: string;
627
+ label: string;
628
+ }>;
629
+ /** The custom providers in settings.jsonc, without the maintained tunings. */
630
+ custom: CustomProviderSwitch[];
631
+ };
632
+ /** `fromFile` and `issues` as `loadSettings` returns them. */
633
+ export declare function clientSettings({ settings, fromFile: fileKeys, issues, }: {
634
+ settings: Settings;
635
+ fromFile: readonly string[];
636
+ issues: readonly SettingsIssue[];
637
+ }): ClientSettings;
638
+ export {};
@@ -0,0 +1,56 @@
1
+ import type { QuotaSnapshot } from "../core/types.js";
2
+ import { QuotaRpc, type QuotaRpcSnapshotOutput } from "../rpc.js";
3
+ export type QuotaRpcCallOptions = {
4
+ location: {
5
+ directory: string;
6
+ };
7
+ signal: AbortSignal;
8
+ };
9
+ type Methods = (typeof QuotaRpc)["methods"];
10
+ type Carried<Schema> = Schema extends {
11
+ "~standard": {
12
+ types?: infer Types;
13
+ };
14
+ } ? NonNullable<Types> extends {
15
+ output: infer T;
16
+ } ? T : never : never;
17
+ export type QuotaRpcClient = {
18
+ [Name in keyof Methods]: (input: Carried<Methods[Name]["input"]>, options: QuotaRpcCallOptions) => Promise<Carried<Methods[Name]["output"]>>;
19
+ } & {
20
+ events: {
21
+ on(name: "changed", handler: (event: {
22
+ data: QuotaRpcSnapshotOutput;
23
+ }) => void, options?: {
24
+ signal?: AbortSignal;
25
+ }): () => void;
26
+ };
27
+ };
28
+ export type RpcLocationHost = {
29
+ location?: {
30
+ directory: string;
31
+ };
32
+ data: {
33
+ location?: {
34
+ default: () => {
35
+ directory: string;
36
+ };
37
+ };
38
+ };
39
+ };
40
+ export type ClientHost = RpcLocationHost & {
41
+ client: {
42
+ rpc: (definition: typeof QuotaRpc) => QuotaRpcClient;
43
+ };
44
+ };
45
+ export declare function quotaCallOptions(host: RpcLocationHost): QuotaRpcCallOptions;
46
+ export declare function rpcErrorMessage(error: unknown): string;
47
+ export declare function reportFailure(error: unknown): void;
48
+ export type QuotaClient = {
49
+ snapshot(sessionID?: string): QuotaSnapshot | undefined;
50
+ subscribe(listener: () => void): () => void;
51
+ watch(sessionID?: string): () => void;
52
+ refresh(reason: "poll" | "turn", sessionID?: string): Promise<QuotaSnapshot | undefined>;
53
+ start(): () => void;
54
+ };
55
+ export declare function createQuotaClient(host: ClientHost): QuotaClient;
56
+ export {};
@@ -0,0 +1,5 @@
1
+ /** @jsxImportSource @opentui/solid */
2
+ /** Quota sidebar for Anthropic, OpenAI, and xAI. */
3
+ import { Plugin } from "@opencode/plugin/tui";
4
+ declare const plugin: Plugin.Definition;
5
+ export default plugin;