@phosphorco/bb-thread-metrics 0.1.0 → 0.2.1

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.
@@ -1,15 +1,20 @@
1
1
  import type { BbPluginApi } from '@get-bb/plugin-sdk';
2
2
  import type { PluginBrowserBbSdk } from '@get-bb/plugin-sdk/app';
3
- import type { ReadInput, ReadResult, DetailInput, DetailResult, Capabilities, OwnerErrorKind } from './index.js';
3
+ import type { HeatSettingsPort } from './index.js';
4
+ import type { RecentSnapshotInput, RecentSnapshotResult, ReadInput, ReadResult, DetailInput, DetailResult, Capabilities, OwnerErrorKind } from './index.js';
4
5
  export type MetricsSdk = {
5
6
  readonly plugins: Pick<BbPluginApi['sdk']['plugins'], 'list' | 'callRpc'>;
6
7
  } | {
7
8
  readonly plugins: Pick<PluginBrowserBbSdk['plugins'], 'list' | 'callRpc'>;
8
9
  };
10
+ export declare function registerHeatSettingsOwner(bb: Pick<BbPluginApi, 'rpc'>, port: HeatSettingsPort): void;
11
+ export declare function createHeatSettingsClient(sdk: MetricsSdk, pluginId: string): HeatSettingsPort;
9
12
  export interface MetricsPort {
10
13
  capabilities: Capabilities;
11
14
  read(input: ReadInput): Promise<ReadResult>;
12
15
  detail?(input: DetailInput): Promise<DetailResult>;
16
+ recentSnapshot?(input: RecentSnapshotInput): Promise<RecentSnapshotResult>;
17
+ heatSettings?: HeatSettingsPort;
13
18
  }
14
19
  export declare function registerThreadMetricsOwner(bb: Pick<BbPluginApi, 'rpc'>, port: MetricsPort): void;
15
20
  export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: string): {
@@ -21,6 +26,1479 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
21
26
  } | {
22
27
  kind: "incompatible";
23
28
  }>;
29
+ recentSnapshot(raw?: RecentSnapshotInput, signal?: AbortSignal): Promise<{
30
+ version: 1;
31
+ revision: string;
32
+ unchanged: false;
33
+ currency: "USD";
34
+ estimated: true;
35
+ cutoffLastFoldAt: number | null;
36
+ asOf: number;
37
+ rankAsOf: number;
38
+ recentWindowMs: number;
39
+ config: {
40
+ revision: string;
41
+ value: {
42
+ mode: "percentile";
43
+ gates: {
44
+ m20: number;
45
+ h24: number;
46
+ d7: number;
47
+ };
48
+ schemaVersion: 2;
49
+ providerWeights: Record<string, number>;
50
+ } | {
51
+ mode: "absolute";
52
+ thresholds: {
53
+ m20: number;
54
+ h24: number;
55
+ d7: number;
56
+ lifetime: number;
57
+ };
58
+ schemaVersion: 2;
59
+ providerWeights: Record<string, number>;
60
+ lifetimeEnabled?: boolean | undefined;
61
+ } | {
62
+ mode: "percentile";
63
+ gates: {
64
+ m20: number;
65
+ h24: number;
66
+ d7: number;
67
+ };
68
+ schemaVersion: 3;
69
+ domain: {
70
+ version: 1;
71
+ kind: "root-family";
72
+ };
73
+ providerWeights: Record<string, number>;
74
+ } | {
75
+ mode: "absolute";
76
+ thresholds: {
77
+ m20: number;
78
+ h24: number;
79
+ d7: number;
80
+ lifetime: number;
81
+ };
82
+ schemaVersion: 3;
83
+ domain: {
84
+ version: 1;
85
+ kind: "root-family";
86
+ };
87
+ providerWeights: Record<string, number>;
88
+ lifetimeEnabled?: false | undefined;
89
+ };
90
+ };
91
+ coverage: "complete" | "partial" | "unknown";
92
+ coverageReasons: string[];
93
+ materializationPending: number;
94
+ omittedRows: {
95
+ count: number;
96
+ exact: boolean;
97
+ };
98
+ population: {
99
+ own: {
100
+ dollars: {
101
+ m20: {
102
+ count: number;
103
+ coverage: "complete" | "partial" | "unknown";
104
+ };
105
+ h24: {
106
+ count: number;
107
+ coverage: "complete" | "partial" | "unknown";
108
+ };
109
+ d7: {
110
+ count: number;
111
+ coverage: "complete" | "partial" | "unknown";
112
+ };
113
+ };
114
+ scores: {
115
+ m20: {
116
+ count: number;
117
+ coverage: "complete" | "partial" | "unknown";
118
+ };
119
+ h24: {
120
+ count: number;
121
+ coverage: "complete" | "partial" | "unknown";
122
+ };
123
+ d7: {
124
+ count: number;
125
+ coverage: "complete" | "partial" | "unknown";
126
+ };
127
+ };
128
+ };
129
+ family: {
130
+ dollars: {
131
+ m20: {
132
+ count: number;
133
+ coverage: "complete" | "partial" | "unknown";
134
+ };
135
+ h24: {
136
+ count: number;
137
+ coverage: "complete" | "partial" | "unknown";
138
+ };
139
+ d7: {
140
+ count: number;
141
+ coverage: "complete" | "partial" | "unknown";
142
+ };
143
+ };
144
+ scores: {
145
+ m20: {
146
+ count: number;
147
+ coverage: "complete" | "partial" | "unknown";
148
+ };
149
+ h24: {
150
+ count: number;
151
+ coverage: "complete" | "partial" | "unknown";
152
+ };
153
+ d7: {
154
+ count: number;
155
+ coverage: "complete" | "partial" | "unknown";
156
+ };
157
+ };
158
+ };
159
+ };
160
+ rows: {
161
+ threadId: string;
162
+ revision: string;
163
+ configRevision: string;
164
+ asOf: number;
165
+ ownLastFoldAt: number | null;
166
+ familyLastFoldAt: number | null;
167
+ own: {
168
+ memberCount: number;
169
+ coverage: "complete" | "partial" | "unknown";
170
+ coverageReasons: string[];
171
+ priceVersion: string;
172
+ approximation: {
173
+ approximate: boolean;
174
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
175
+ };
176
+ windows: {
177
+ m20: {
178
+ kind: "estimate";
179
+ amount: number;
180
+ } | {
181
+ kind: "floor";
182
+ amount: number;
183
+ } | {
184
+ kind: "unavailable";
185
+ amount: null;
186
+ };
187
+ h24: {
188
+ kind: "estimate";
189
+ amount: number;
190
+ } | {
191
+ kind: "floor";
192
+ amount: number;
193
+ } | {
194
+ kind: "unavailable";
195
+ amount: null;
196
+ };
197
+ d7: {
198
+ kind: "estimate";
199
+ amount: number;
200
+ } | {
201
+ kind: "floor";
202
+ amount: number;
203
+ } | {
204
+ kind: "unavailable";
205
+ amount: null;
206
+ };
207
+ lifetime: {
208
+ kind: "estimate";
209
+ amount: number;
210
+ } | {
211
+ kind: "floor";
212
+ amount: number;
213
+ } | {
214
+ kind: "unavailable";
215
+ amount: null;
216
+ };
217
+ };
218
+ scores: {
219
+ m20: {
220
+ kind: "estimate";
221
+ amount: number;
222
+ } | {
223
+ kind: "floor";
224
+ amount: number;
225
+ } | {
226
+ kind: "unavailable";
227
+ amount: null;
228
+ };
229
+ h24: {
230
+ kind: "estimate";
231
+ amount: number;
232
+ } | {
233
+ kind: "floor";
234
+ amount: number;
235
+ } | {
236
+ kind: "unavailable";
237
+ amount: null;
238
+ };
239
+ d7: {
240
+ kind: "estimate";
241
+ amount: number;
242
+ } | {
243
+ kind: "floor";
244
+ amount: number;
245
+ } | {
246
+ kind: "unavailable";
247
+ amount: null;
248
+ };
249
+ lifetime: {
250
+ kind: "estimate";
251
+ amount: number;
252
+ } | {
253
+ kind: "floor";
254
+ amount: number;
255
+ } | {
256
+ kind: "unavailable";
257
+ amount: null;
258
+ };
259
+ };
260
+ providers: {
261
+ providerId: string;
262
+ windows: {
263
+ m20: {
264
+ kind: "estimate";
265
+ amount: number;
266
+ } | {
267
+ kind: "floor";
268
+ amount: number;
269
+ } | {
270
+ kind: "unavailable";
271
+ amount: null;
272
+ };
273
+ h24: {
274
+ kind: "estimate";
275
+ amount: number;
276
+ } | {
277
+ kind: "floor";
278
+ amount: number;
279
+ } | {
280
+ kind: "unavailable";
281
+ amount: null;
282
+ };
283
+ d7: {
284
+ kind: "estimate";
285
+ amount: number;
286
+ } | {
287
+ kind: "floor";
288
+ amount: number;
289
+ } | {
290
+ kind: "unavailable";
291
+ amount: null;
292
+ };
293
+ lifetime: {
294
+ kind: "estimate";
295
+ amount: number;
296
+ } | {
297
+ kind: "floor";
298
+ amount: number;
299
+ } | {
300
+ kind: "unavailable";
301
+ amount: null;
302
+ };
303
+ };
304
+ approximation: {
305
+ approximate: boolean;
306
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
307
+ };
308
+ }[];
309
+ omittedProviders: number;
310
+ dollarRanks: {
311
+ m20: number | null;
312
+ h24: number | null;
313
+ d7: number | null;
314
+ };
315
+ scoreRanks: {
316
+ m20: number | null;
317
+ h24: number | null;
318
+ d7: number | null;
319
+ };
320
+ usage?: {
321
+ windows: {
322
+ m20: {
323
+ kind: "estimate";
324
+ value: {
325
+ inputUncached: number;
326
+ cacheRead: number;
327
+ cacheWrite: number;
328
+ output: number;
329
+ };
330
+ } | {
331
+ kind: "floor";
332
+ value: {
333
+ inputUncached: number;
334
+ cacheRead: number;
335
+ cacheWrite: number;
336
+ output: number;
337
+ };
338
+ } | {
339
+ kind: "unavailable";
340
+ value: null;
341
+ };
342
+ h24: {
343
+ kind: "estimate";
344
+ value: {
345
+ inputUncached: number;
346
+ cacheRead: number;
347
+ cacheWrite: number;
348
+ output: number;
349
+ };
350
+ } | {
351
+ kind: "floor";
352
+ value: {
353
+ inputUncached: number;
354
+ cacheRead: number;
355
+ cacheWrite: number;
356
+ output: number;
357
+ };
358
+ } | {
359
+ kind: "unavailable";
360
+ value: null;
361
+ };
362
+ d7: {
363
+ kind: "estimate";
364
+ value: {
365
+ inputUncached: number;
366
+ cacheRead: number;
367
+ cacheWrite: number;
368
+ output: number;
369
+ };
370
+ } | {
371
+ kind: "floor";
372
+ value: {
373
+ inputUncached: number;
374
+ cacheRead: number;
375
+ cacheWrite: number;
376
+ output: number;
377
+ };
378
+ } | {
379
+ kind: "unavailable";
380
+ value: null;
381
+ };
382
+ lifetime: {
383
+ kind: "estimate";
384
+ value: {
385
+ inputUncached: number;
386
+ cacheRead: number;
387
+ cacheWrite: number;
388
+ output: number;
389
+ };
390
+ } | {
391
+ kind: "floor";
392
+ value: {
393
+ inputUncached: number;
394
+ cacheRead: number;
395
+ cacheWrite: number;
396
+ output: number;
397
+ };
398
+ } | {
399
+ kind: "unavailable";
400
+ value: null;
401
+ };
402
+ };
403
+ providers: {
404
+ providerId: string;
405
+ windows: {
406
+ m20: {
407
+ kind: "estimate";
408
+ value: {
409
+ inputUncached: number;
410
+ cacheRead: number;
411
+ cacheWrite: number;
412
+ output: number;
413
+ };
414
+ } | {
415
+ kind: "floor";
416
+ value: {
417
+ inputUncached: number;
418
+ cacheRead: number;
419
+ cacheWrite: number;
420
+ output: number;
421
+ };
422
+ } | {
423
+ kind: "unavailable";
424
+ value: null;
425
+ };
426
+ h24: {
427
+ kind: "estimate";
428
+ value: {
429
+ inputUncached: number;
430
+ cacheRead: number;
431
+ cacheWrite: number;
432
+ output: number;
433
+ };
434
+ } | {
435
+ kind: "floor";
436
+ value: {
437
+ inputUncached: number;
438
+ cacheRead: number;
439
+ cacheWrite: number;
440
+ output: number;
441
+ };
442
+ } | {
443
+ kind: "unavailable";
444
+ value: null;
445
+ };
446
+ d7: {
447
+ kind: "estimate";
448
+ value: {
449
+ inputUncached: number;
450
+ cacheRead: number;
451
+ cacheWrite: number;
452
+ output: number;
453
+ };
454
+ } | {
455
+ kind: "floor";
456
+ value: {
457
+ inputUncached: number;
458
+ cacheRead: number;
459
+ cacheWrite: number;
460
+ output: number;
461
+ };
462
+ } | {
463
+ kind: "unavailable";
464
+ value: null;
465
+ };
466
+ lifetime: {
467
+ kind: "estimate";
468
+ value: {
469
+ inputUncached: number;
470
+ cacheRead: number;
471
+ cacheWrite: number;
472
+ output: number;
473
+ };
474
+ } | {
475
+ kind: "floor";
476
+ value: {
477
+ inputUncached: number;
478
+ cacheRead: number;
479
+ cacheWrite: number;
480
+ output: number;
481
+ };
482
+ } | {
483
+ kind: "unavailable";
484
+ value: null;
485
+ };
486
+ };
487
+ }[];
488
+ omittedProviders: number;
489
+ descendants: {
490
+ count: number;
491
+ exact: boolean;
492
+ };
493
+ } | undefined;
494
+ attribution?: {
495
+ unknownProvider: {
496
+ m20: {
497
+ kind: "estimate";
498
+ amount: number;
499
+ } | {
500
+ kind: "floor";
501
+ amount: number;
502
+ } | {
503
+ kind: "unavailable";
504
+ amount: null;
505
+ };
506
+ h24: {
507
+ kind: "estimate";
508
+ amount: number;
509
+ } | {
510
+ kind: "floor";
511
+ amount: number;
512
+ } | {
513
+ kind: "unavailable";
514
+ amount: null;
515
+ };
516
+ d7: {
517
+ kind: "estimate";
518
+ amount: number;
519
+ } | {
520
+ kind: "floor";
521
+ amount: number;
522
+ } | {
523
+ kind: "unavailable";
524
+ amount: null;
525
+ };
526
+ lifetime: {
527
+ kind: "estimate";
528
+ amount: number;
529
+ } | {
530
+ kind: "floor";
531
+ amount: number;
532
+ } | {
533
+ kind: "unavailable";
534
+ amount: null;
535
+ };
536
+ };
537
+ attributionComplete: {
538
+ m20: boolean;
539
+ h24: boolean;
540
+ d7: boolean;
541
+ lifetime: boolean;
542
+ };
543
+ unpriced: {
544
+ m20: boolean;
545
+ h24: boolean;
546
+ d7: boolean;
547
+ lifetime: boolean;
548
+ };
549
+ } | undefined;
550
+ };
551
+ family: {
552
+ memberCount: number;
553
+ coverage: "complete" | "partial" | "unknown";
554
+ coverageReasons: string[];
555
+ priceVersion: string;
556
+ approximation: {
557
+ approximate: boolean;
558
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
559
+ };
560
+ windows: {
561
+ m20: {
562
+ kind: "estimate";
563
+ amount: number;
564
+ } | {
565
+ kind: "floor";
566
+ amount: number;
567
+ } | {
568
+ kind: "unavailable";
569
+ amount: null;
570
+ };
571
+ h24: {
572
+ kind: "estimate";
573
+ amount: number;
574
+ } | {
575
+ kind: "floor";
576
+ amount: number;
577
+ } | {
578
+ kind: "unavailable";
579
+ amount: null;
580
+ };
581
+ d7: {
582
+ kind: "estimate";
583
+ amount: number;
584
+ } | {
585
+ kind: "floor";
586
+ amount: number;
587
+ } | {
588
+ kind: "unavailable";
589
+ amount: null;
590
+ };
591
+ lifetime: {
592
+ kind: "estimate";
593
+ amount: number;
594
+ } | {
595
+ kind: "floor";
596
+ amount: number;
597
+ } | {
598
+ kind: "unavailable";
599
+ amount: null;
600
+ };
601
+ };
602
+ scores: {
603
+ m20: {
604
+ kind: "estimate";
605
+ amount: number;
606
+ } | {
607
+ kind: "floor";
608
+ amount: number;
609
+ } | {
610
+ kind: "unavailable";
611
+ amount: null;
612
+ };
613
+ h24: {
614
+ kind: "estimate";
615
+ amount: number;
616
+ } | {
617
+ kind: "floor";
618
+ amount: number;
619
+ } | {
620
+ kind: "unavailable";
621
+ amount: null;
622
+ };
623
+ d7: {
624
+ kind: "estimate";
625
+ amount: number;
626
+ } | {
627
+ kind: "floor";
628
+ amount: number;
629
+ } | {
630
+ kind: "unavailable";
631
+ amount: null;
632
+ };
633
+ lifetime: {
634
+ kind: "estimate";
635
+ amount: number;
636
+ } | {
637
+ kind: "floor";
638
+ amount: number;
639
+ } | {
640
+ kind: "unavailable";
641
+ amount: null;
642
+ };
643
+ };
644
+ providers: {
645
+ providerId: string;
646
+ windows: {
647
+ m20: {
648
+ kind: "estimate";
649
+ amount: number;
650
+ } | {
651
+ kind: "floor";
652
+ amount: number;
653
+ } | {
654
+ kind: "unavailable";
655
+ amount: null;
656
+ };
657
+ h24: {
658
+ kind: "estimate";
659
+ amount: number;
660
+ } | {
661
+ kind: "floor";
662
+ amount: number;
663
+ } | {
664
+ kind: "unavailable";
665
+ amount: null;
666
+ };
667
+ d7: {
668
+ kind: "estimate";
669
+ amount: number;
670
+ } | {
671
+ kind: "floor";
672
+ amount: number;
673
+ } | {
674
+ kind: "unavailable";
675
+ amount: null;
676
+ };
677
+ lifetime: {
678
+ kind: "estimate";
679
+ amount: number;
680
+ } | {
681
+ kind: "floor";
682
+ amount: number;
683
+ } | {
684
+ kind: "unavailable";
685
+ amount: null;
686
+ };
687
+ };
688
+ approximation: {
689
+ approximate: boolean;
690
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
691
+ };
692
+ }[];
693
+ omittedProviders: number;
694
+ dollarRanks: {
695
+ m20: number | null;
696
+ h24: number | null;
697
+ d7: number | null;
698
+ };
699
+ scoreRanks: {
700
+ m20: number | null;
701
+ h24: number | null;
702
+ d7: number | null;
703
+ };
704
+ usage?: {
705
+ windows: {
706
+ m20: {
707
+ kind: "estimate";
708
+ value: {
709
+ inputUncached: number;
710
+ cacheRead: number;
711
+ cacheWrite: number;
712
+ output: number;
713
+ };
714
+ } | {
715
+ kind: "floor";
716
+ value: {
717
+ inputUncached: number;
718
+ cacheRead: number;
719
+ cacheWrite: number;
720
+ output: number;
721
+ };
722
+ } | {
723
+ kind: "unavailable";
724
+ value: null;
725
+ };
726
+ h24: {
727
+ kind: "estimate";
728
+ value: {
729
+ inputUncached: number;
730
+ cacheRead: number;
731
+ cacheWrite: number;
732
+ output: number;
733
+ };
734
+ } | {
735
+ kind: "floor";
736
+ value: {
737
+ inputUncached: number;
738
+ cacheRead: number;
739
+ cacheWrite: number;
740
+ output: number;
741
+ };
742
+ } | {
743
+ kind: "unavailable";
744
+ value: null;
745
+ };
746
+ d7: {
747
+ kind: "estimate";
748
+ value: {
749
+ inputUncached: number;
750
+ cacheRead: number;
751
+ cacheWrite: number;
752
+ output: number;
753
+ };
754
+ } | {
755
+ kind: "floor";
756
+ value: {
757
+ inputUncached: number;
758
+ cacheRead: number;
759
+ cacheWrite: number;
760
+ output: number;
761
+ };
762
+ } | {
763
+ kind: "unavailable";
764
+ value: null;
765
+ };
766
+ lifetime: {
767
+ kind: "estimate";
768
+ value: {
769
+ inputUncached: number;
770
+ cacheRead: number;
771
+ cacheWrite: number;
772
+ output: number;
773
+ };
774
+ } | {
775
+ kind: "floor";
776
+ value: {
777
+ inputUncached: number;
778
+ cacheRead: number;
779
+ cacheWrite: number;
780
+ output: number;
781
+ };
782
+ } | {
783
+ kind: "unavailable";
784
+ value: null;
785
+ };
786
+ };
787
+ providers: {
788
+ providerId: string;
789
+ windows: {
790
+ m20: {
791
+ kind: "estimate";
792
+ value: {
793
+ inputUncached: number;
794
+ cacheRead: number;
795
+ cacheWrite: number;
796
+ output: number;
797
+ };
798
+ } | {
799
+ kind: "floor";
800
+ value: {
801
+ inputUncached: number;
802
+ cacheRead: number;
803
+ cacheWrite: number;
804
+ output: number;
805
+ };
806
+ } | {
807
+ kind: "unavailable";
808
+ value: null;
809
+ };
810
+ h24: {
811
+ kind: "estimate";
812
+ value: {
813
+ inputUncached: number;
814
+ cacheRead: number;
815
+ cacheWrite: number;
816
+ output: number;
817
+ };
818
+ } | {
819
+ kind: "floor";
820
+ value: {
821
+ inputUncached: number;
822
+ cacheRead: number;
823
+ cacheWrite: number;
824
+ output: number;
825
+ };
826
+ } | {
827
+ kind: "unavailable";
828
+ value: null;
829
+ };
830
+ d7: {
831
+ kind: "estimate";
832
+ value: {
833
+ inputUncached: number;
834
+ cacheRead: number;
835
+ cacheWrite: number;
836
+ output: number;
837
+ };
838
+ } | {
839
+ kind: "floor";
840
+ value: {
841
+ inputUncached: number;
842
+ cacheRead: number;
843
+ cacheWrite: number;
844
+ output: number;
845
+ };
846
+ } | {
847
+ kind: "unavailable";
848
+ value: null;
849
+ };
850
+ lifetime: {
851
+ kind: "estimate";
852
+ value: {
853
+ inputUncached: number;
854
+ cacheRead: number;
855
+ cacheWrite: number;
856
+ output: number;
857
+ };
858
+ } | {
859
+ kind: "floor";
860
+ value: {
861
+ inputUncached: number;
862
+ cacheRead: number;
863
+ cacheWrite: number;
864
+ output: number;
865
+ };
866
+ } | {
867
+ kind: "unavailable";
868
+ value: null;
869
+ };
870
+ };
871
+ }[];
872
+ omittedProviders: number;
873
+ descendants: {
874
+ count: number;
875
+ exact: boolean;
876
+ };
877
+ } | undefined;
878
+ attribution?: {
879
+ unknownProvider: {
880
+ m20: {
881
+ kind: "estimate";
882
+ amount: number;
883
+ } | {
884
+ kind: "floor";
885
+ amount: number;
886
+ } | {
887
+ kind: "unavailable";
888
+ amount: null;
889
+ };
890
+ h24: {
891
+ kind: "estimate";
892
+ amount: number;
893
+ } | {
894
+ kind: "floor";
895
+ amount: number;
896
+ } | {
897
+ kind: "unavailable";
898
+ amount: null;
899
+ };
900
+ d7: {
901
+ kind: "estimate";
902
+ amount: number;
903
+ } | {
904
+ kind: "floor";
905
+ amount: number;
906
+ } | {
907
+ kind: "unavailable";
908
+ amount: null;
909
+ };
910
+ lifetime: {
911
+ kind: "estimate";
912
+ amount: number;
913
+ } | {
914
+ kind: "floor";
915
+ amount: number;
916
+ } | {
917
+ kind: "unavailable";
918
+ amount: null;
919
+ };
920
+ };
921
+ attributionComplete: {
922
+ m20: boolean;
923
+ h24: boolean;
924
+ d7: boolean;
925
+ lifetime: boolean;
926
+ };
927
+ unpriced: {
928
+ m20: boolean;
929
+ h24: boolean;
930
+ d7: boolean;
931
+ lifetime: boolean;
932
+ };
933
+ } | undefined;
934
+ };
935
+ presentation?: {
936
+ title: string | null;
937
+ navigation: {
938
+ kind: "personal";
939
+ } | {
940
+ kind: "project";
941
+ projectId: string;
942
+ } | null;
943
+ } | undefined;
944
+ heat?: {
945
+ topology: {
946
+ kind: "attested";
947
+ parentThreadId: string | null;
948
+ lifecycleOwnerThreadId: string | null;
949
+ deleted: boolean;
950
+ } | {
951
+ kind: "unknown";
952
+ reasons: string[];
953
+ };
954
+ rootDollarRanks: {
955
+ m20: number | null;
956
+ h24: number | null;
957
+ d7: number | null;
958
+ };
959
+ rootScoreRanks: {
960
+ m20: number | null;
961
+ h24: number | null;
962
+ d7: number | null;
963
+ };
964
+ decisions: {
965
+ contextRevision: string;
966
+ signals: {
967
+ m20: {
968
+ decision: "unavailable" | "qualifies" | "below" | "suppressed";
969
+ reason: "deleted" | "threshold-met" | "below-threshold" | "gate-met" | "below-gate" | "not-root" | "topology-unknown" | "unsupported-value" | "zero" | "insufficient-population" | "rank-unavailable" | "context-unavailable";
970
+ };
971
+ h24: {
972
+ decision: "unavailable" | "qualifies" | "below" | "suppressed";
973
+ reason: "deleted" | "threshold-met" | "below-threshold" | "gate-met" | "below-gate" | "not-root" | "topology-unknown" | "unsupported-value" | "zero" | "insufficient-population" | "rank-unavailable" | "context-unavailable";
974
+ };
975
+ d7: {
976
+ decision: "unavailable" | "qualifies" | "below" | "suppressed";
977
+ reason: "deleted" | "threshold-met" | "below-threshold" | "gate-met" | "below-gate" | "not-root" | "topology-unknown" | "unsupported-value" | "zero" | "insufficient-population" | "rank-unavailable" | "context-unavailable";
978
+ };
979
+ };
980
+ winner: "on-fire" | "hot" | "heavy" | null;
981
+ };
982
+ } | undefined;
983
+ }[];
984
+ publication?: {
985
+ instance: string;
986
+ sequence: number;
987
+ } | undefined;
988
+ heat?: {
989
+ version: 1;
990
+ domain: {
991
+ version: 1;
992
+ kind: "root-family";
993
+ };
994
+ contextRevision: string;
995
+ configRevision: string;
996
+ topologyRevision: string;
997
+ rankRevision: string;
998
+ rankAsOf: number;
999
+ windows: {
1000
+ m20: {
1001
+ start: number;
1002
+ end: number;
1003
+ };
1004
+ h24: {
1005
+ start: number;
1006
+ end: number;
1007
+ };
1008
+ d7: {
1009
+ start: number;
1010
+ end: number;
1011
+ };
1012
+ };
1013
+ population: {
1014
+ dollars: {
1015
+ m20: {
1016
+ count: number;
1017
+ coverage: "complete" | "partial" | "unknown";
1018
+ reasons: string[];
1019
+ };
1020
+ h24: {
1021
+ count: number;
1022
+ coverage: "complete" | "partial" | "unknown";
1023
+ reasons: string[];
1024
+ };
1025
+ d7: {
1026
+ count: number;
1027
+ coverage: "complete" | "partial" | "unknown";
1028
+ reasons: string[];
1029
+ };
1030
+ };
1031
+ scores: {
1032
+ m20: {
1033
+ count: number;
1034
+ coverage: "complete" | "partial" | "unknown";
1035
+ reasons: string[];
1036
+ };
1037
+ h24: {
1038
+ count: number;
1039
+ coverage: "complete" | "partial" | "unknown";
1040
+ reasons: string[];
1041
+ };
1042
+ d7: {
1043
+ count: number;
1044
+ coverage: "complete" | "partial" | "unknown";
1045
+ reasons: string[];
1046
+ };
1047
+ };
1048
+ };
1049
+ } | undefined;
1050
+ heatInputs?: {
1051
+ contextRevision: string;
1052
+ topologyRevision: string;
1053
+ cohortComplete: boolean;
1054
+ pending: number;
1055
+ omitted: {
1056
+ count: number;
1057
+ exact: boolean;
1058
+ };
1059
+ rows: {
1060
+ threadId: string;
1061
+ asOf: number;
1062
+ configRevision: string;
1063
+ family: {
1064
+ memberCount: number;
1065
+ coverage: "complete" | "partial" | "unknown";
1066
+ coverageReasons: string[];
1067
+ priceVersion: string;
1068
+ approximation: {
1069
+ approximate: boolean;
1070
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
1071
+ };
1072
+ windows: {
1073
+ m20: {
1074
+ kind: "estimate";
1075
+ amount: number;
1076
+ } | {
1077
+ kind: "floor";
1078
+ amount: number;
1079
+ } | {
1080
+ kind: "unavailable";
1081
+ amount: null;
1082
+ };
1083
+ h24: {
1084
+ kind: "estimate";
1085
+ amount: number;
1086
+ } | {
1087
+ kind: "floor";
1088
+ amount: number;
1089
+ } | {
1090
+ kind: "unavailable";
1091
+ amount: null;
1092
+ };
1093
+ d7: {
1094
+ kind: "estimate";
1095
+ amount: number;
1096
+ } | {
1097
+ kind: "floor";
1098
+ amount: number;
1099
+ } | {
1100
+ kind: "unavailable";
1101
+ amount: null;
1102
+ };
1103
+ lifetime: {
1104
+ kind: "estimate";
1105
+ amount: number;
1106
+ } | {
1107
+ kind: "floor";
1108
+ amount: number;
1109
+ } | {
1110
+ kind: "unavailable";
1111
+ amount: null;
1112
+ };
1113
+ };
1114
+ scores: {
1115
+ m20: {
1116
+ kind: "estimate";
1117
+ amount: number;
1118
+ } | {
1119
+ kind: "floor";
1120
+ amount: number;
1121
+ } | {
1122
+ kind: "unavailable";
1123
+ amount: null;
1124
+ };
1125
+ h24: {
1126
+ kind: "estimate";
1127
+ amount: number;
1128
+ } | {
1129
+ kind: "floor";
1130
+ amount: number;
1131
+ } | {
1132
+ kind: "unavailable";
1133
+ amount: null;
1134
+ };
1135
+ d7: {
1136
+ kind: "estimate";
1137
+ amount: number;
1138
+ } | {
1139
+ kind: "floor";
1140
+ amount: number;
1141
+ } | {
1142
+ kind: "unavailable";
1143
+ amount: null;
1144
+ };
1145
+ lifetime: {
1146
+ kind: "estimate";
1147
+ amount: number;
1148
+ } | {
1149
+ kind: "floor";
1150
+ amount: number;
1151
+ } | {
1152
+ kind: "unavailable";
1153
+ amount: null;
1154
+ };
1155
+ };
1156
+ providers: {
1157
+ providerId: string;
1158
+ windows: {
1159
+ m20: {
1160
+ kind: "estimate";
1161
+ amount: number;
1162
+ } | {
1163
+ kind: "floor";
1164
+ amount: number;
1165
+ } | {
1166
+ kind: "unavailable";
1167
+ amount: null;
1168
+ };
1169
+ h24: {
1170
+ kind: "estimate";
1171
+ amount: number;
1172
+ } | {
1173
+ kind: "floor";
1174
+ amount: number;
1175
+ } | {
1176
+ kind: "unavailable";
1177
+ amount: null;
1178
+ };
1179
+ d7: {
1180
+ kind: "estimate";
1181
+ amount: number;
1182
+ } | {
1183
+ kind: "floor";
1184
+ amount: number;
1185
+ } | {
1186
+ kind: "unavailable";
1187
+ amount: null;
1188
+ };
1189
+ lifetime: {
1190
+ kind: "estimate";
1191
+ amount: number;
1192
+ } | {
1193
+ kind: "floor";
1194
+ amount: number;
1195
+ } | {
1196
+ kind: "unavailable";
1197
+ amount: null;
1198
+ };
1199
+ };
1200
+ approximation: {
1201
+ approximate: boolean;
1202
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
1203
+ };
1204
+ }[];
1205
+ omittedProviders: number;
1206
+ dollarRanks: {
1207
+ m20: number | null;
1208
+ h24: number | null;
1209
+ d7: number | null;
1210
+ };
1211
+ scoreRanks: {
1212
+ m20: number | null;
1213
+ h24: number | null;
1214
+ d7: number | null;
1215
+ };
1216
+ usage?: {
1217
+ windows: {
1218
+ m20: {
1219
+ kind: "estimate";
1220
+ value: {
1221
+ inputUncached: number;
1222
+ cacheRead: number;
1223
+ cacheWrite: number;
1224
+ output: number;
1225
+ };
1226
+ } | {
1227
+ kind: "floor";
1228
+ value: {
1229
+ inputUncached: number;
1230
+ cacheRead: number;
1231
+ cacheWrite: number;
1232
+ output: number;
1233
+ };
1234
+ } | {
1235
+ kind: "unavailable";
1236
+ value: null;
1237
+ };
1238
+ h24: {
1239
+ kind: "estimate";
1240
+ value: {
1241
+ inputUncached: number;
1242
+ cacheRead: number;
1243
+ cacheWrite: number;
1244
+ output: number;
1245
+ };
1246
+ } | {
1247
+ kind: "floor";
1248
+ value: {
1249
+ inputUncached: number;
1250
+ cacheRead: number;
1251
+ cacheWrite: number;
1252
+ output: number;
1253
+ };
1254
+ } | {
1255
+ kind: "unavailable";
1256
+ value: null;
1257
+ };
1258
+ d7: {
1259
+ kind: "estimate";
1260
+ value: {
1261
+ inputUncached: number;
1262
+ cacheRead: number;
1263
+ cacheWrite: number;
1264
+ output: number;
1265
+ };
1266
+ } | {
1267
+ kind: "floor";
1268
+ value: {
1269
+ inputUncached: number;
1270
+ cacheRead: number;
1271
+ cacheWrite: number;
1272
+ output: number;
1273
+ };
1274
+ } | {
1275
+ kind: "unavailable";
1276
+ value: null;
1277
+ };
1278
+ lifetime: {
1279
+ kind: "estimate";
1280
+ value: {
1281
+ inputUncached: number;
1282
+ cacheRead: number;
1283
+ cacheWrite: number;
1284
+ output: number;
1285
+ };
1286
+ } | {
1287
+ kind: "floor";
1288
+ value: {
1289
+ inputUncached: number;
1290
+ cacheRead: number;
1291
+ cacheWrite: number;
1292
+ output: number;
1293
+ };
1294
+ } | {
1295
+ kind: "unavailable";
1296
+ value: null;
1297
+ };
1298
+ };
1299
+ providers: {
1300
+ providerId: string;
1301
+ windows: {
1302
+ m20: {
1303
+ kind: "estimate";
1304
+ value: {
1305
+ inputUncached: number;
1306
+ cacheRead: number;
1307
+ cacheWrite: number;
1308
+ output: number;
1309
+ };
1310
+ } | {
1311
+ kind: "floor";
1312
+ value: {
1313
+ inputUncached: number;
1314
+ cacheRead: number;
1315
+ cacheWrite: number;
1316
+ output: number;
1317
+ };
1318
+ } | {
1319
+ kind: "unavailable";
1320
+ value: null;
1321
+ };
1322
+ h24: {
1323
+ kind: "estimate";
1324
+ value: {
1325
+ inputUncached: number;
1326
+ cacheRead: number;
1327
+ cacheWrite: number;
1328
+ output: number;
1329
+ };
1330
+ } | {
1331
+ kind: "floor";
1332
+ value: {
1333
+ inputUncached: number;
1334
+ cacheRead: number;
1335
+ cacheWrite: number;
1336
+ output: number;
1337
+ };
1338
+ } | {
1339
+ kind: "unavailable";
1340
+ value: null;
1341
+ };
1342
+ d7: {
1343
+ kind: "estimate";
1344
+ value: {
1345
+ inputUncached: number;
1346
+ cacheRead: number;
1347
+ cacheWrite: number;
1348
+ output: number;
1349
+ };
1350
+ } | {
1351
+ kind: "floor";
1352
+ value: {
1353
+ inputUncached: number;
1354
+ cacheRead: number;
1355
+ cacheWrite: number;
1356
+ output: number;
1357
+ };
1358
+ } | {
1359
+ kind: "unavailable";
1360
+ value: null;
1361
+ };
1362
+ lifetime: {
1363
+ kind: "estimate";
1364
+ value: {
1365
+ inputUncached: number;
1366
+ cacheRead: number;
1367
+ cacheWrite: number;
1368
+ output: number;
1369
+ };
1370
+ } | {
1371
+ kind: "floor";
1372
+ value: {
1373
+ inputUncached: number;
1374
+ cacheRead: number;
1375
+ cacheWrite: number;
1376
+ output: number;
1377
+ };
1378
+ } | {
1379
+ kind: "unavailable";
1380
+ value: null;
1381
+ };
1382
+ };
1383
+ }[];
1384
+ omittedProviders: number;
1385
+ descendants: {
1386
+ count: number;
1387
+ exact: boolean;
1388
+ };
1389
+ } | undefined;
1390
+ attribution?: {
1391
+ unknownProvider: {
1392
+ m20: {
1393
+ kind: "estimate";
1394
+ amount: number;
1395
+ } | {
1396
+ kind: "floor";
1397
+ amount: number;
1398
+ } | {
1399
+ kind: "unavailable";
1400
+ amount: null;
1401
+ };
1402
+ h24: {
1403
+ kind: "estimate";
1404
+ amount: number;
1405
+ } | {
1406
+ kind: "floor";
1407
+ amount: number;
1408
+ } | {
1409
+ kind: "unavailable";
1410
+ amount: null;
1411
+ };
1412
+ d7: {
1413
+ kind: "estimate";
1414
+ amount: number;
1415
+ } | {
1416
+ kind: "floor";
1417
+ amount: number;
1418
+ } | {
1419
+ kind: "unavailable";
1420
+ amount: null;
1421
+ };
1422
+ lifetime: {
1423
+ kind: "estimate";
1424
+ amount: number;
1425
+ } | {
1426
+ kind: "floor";
1427
+ amount: number;
1428
+ } | {
1429
+ kind: "unavailable";
1430
+ amount: null;
1431
+ };
1432
+ };
1433
+ attributionComplete: {
1434
+ m20: boolean;
1435
+ h24: boolean;
1436
+ d7: boolean;
1437
+ lifetime: boolean;
1438
+ };
1439
+ unpriced: {
1440
+ m20: boolean;
1441
+ h24: boolean;
1442
+ d7: boolean;
1443
+ lifetime: boolean;
1444
+ };
1445
+ } | undefined;
1446
+ };
1447
+ heat: {
1448
+ topology: {
1449
+ kind: "attested";
1450
+ parentThreadId: string | null;
1451
+ lifecycleOwnerThreadId: string | null;
1452
+ deleted: boolean;
1453
+ } | {
1454
+ kind: "unknown";
1455
+ reasons: string[];
1456
+ };
1457
+ rootDollarRanks: {
1458
+ m20: number | null;
1459
+ h24: number | null;
1460
+ d7: number | null;
1461
+ };
1462
+ rootScoreRanks: {
1463
+ m20: number | null;
1464
+ h24: number | null;
1465
+ d7: number | null;
1466
+ };
1467
+ decisions: {
1468
+ contextRevision: string;
1469
+ signals: {
1470
+ m20: {
1471
+ decision: "unavailable" | "qualifies" | "below" | "suppressed";
1472
+ reason: "deleted" | "threshold-met" | "below-threshold" | "gate-met" | "below-gate" | "not-root" | "topology-unknown" | "unsupported-value" | "zero" | "insufficient-population" | "rank-unavailable" | "context-unavailable";
1473
+ };
1474
+ h24: {
1475
+ decision: "unavailable" | "qualifies" | "below" | "suppressed";
1476
+ reason: "deleted" | "threshold-met" | "below-threshold" | "gate-met" | "below-gate" | "not-root" | "topology-unknown" | "unsupported-value" | "zero" | "insufficient-population" | "rank-unavailable" | "context-unavailable";
1477
+ };
1478
+ d7: {
1479
+ decision: "unavailable" | "qualifies" | "below" | "suppressed";
1480
+ reason: "deleted" | "threshold-met" | "below-threshold" | "gate-met" | "below-gate" | "not-root" | "topology-unknown" | "unsupported-value" | "zero" | "insufficient-population" | "rank-unavailable" | "context-unavailable";
1481
+ };
1482
+ };
1483
+ winner: "on-fire" | "hot" | "heavy" | null;
1484
+ };
1485
+ };
1486
+ presentation?: {
1487
+ title: string | null;
1488
+ navigation: {
1489
+ kind: "personal";
1490
+ } | {
1491
+ kind: "project";
1492
+ projectId: string;
1493
+ } | null;
1494
+ } | undefined;
1495
+ }[];
1496
+ } | undefined;
1497
+ } | {
1498
+ version: 1;
1499
+ revision: string;
1500
+ unchanged: true;
1501
+ }>;
24
1502
  read(raw: ReadInput, signal?: AbortSignal): Promise<{
25
1503
  version: 1;
26
1504
  rows: ({
@@ -67,7 +1545,7 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
67
1545
  scope: "own" | "family";
68
1546
  memberCount: number;
69
1547
  coverage: "complete" | "partial" | "unknown";
70
- coverageReasons: ("source-gap" | "root-unattested" | "history-unavailable" | "member-cap" | "depth-cap" | "edge-cap" | "missing-thread" | "unpriced" | "retention" | "row-cap" | "pagination" | "population-incomplete")[];
1548
+ coverageReasons: ("unpriced" | "source-gap" | "root-unattested" | "history-unavailable" | "missing-thread" | "member-cap" | "depth-cap" | "edge-cap" | "retention" | "row-cap" | "pagination" | "population-incomplete")[];
71
1549
  asOf: number;
72
1550
  revision: string;
73
1551
  priceVersion: string;
@@ -75,7 +1553,7 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
75
1553
  estimated: true;
76
1554
  approximation: {
77
1555
  approximate: boolean;
78
- reasons: ("source-gap" | "closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price")[];
1556
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
79
1557
  rates?: {
80
1558
  providerId: string;
81
1559
  modelId: string;
@@ -121,7 +1599,7 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
121
1599
  scope: "own" | "family";
122
1600
  memberCount: number;
123
1601
  coverage: "complete" | "partial" | "unknown";
124
- coverageReasons: ("source-gap" | "root-unattested" | "history-unavailable" | "member-cap" | "depth-cap" | "edge-cap" | "missing-thread" | "unpriced" | "retention" | "row-cap" | "pagination" | "population-incomplete")[];
1602
+ coverageReasons: ("unpriced" | "source-gap" | "root-unattested" | "history-unavailable" | "missing-thread" | "member-cap" | "depth-cap" | "edge-cap" | "retention" | "row-cap" | "pagination" | "population-incomplete")[];
125
1603
  asOf: number;
126
1604
  revision: string;
127
1605
  priceVersion: string;
@@ -129,7 +1607,7 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
129
1607
  estimated: true;
130
1608
  approximation: {
131
1609
  approximate: boolean;
132
- reasons: ("source-gap" | "closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price")[];
1610
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
133
1611
  rates?: {
134
1612
  providerId: string;
135
1613
  modelId: string;
@@ -173,7 +1651,7 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
173
1651
  version: 1;
174
1652
  threadId: string;
175
1653
  scope: "own" | "family";
176
- axis: "model" | "time";
1654
+ axis: "time" | "model";
177
1655
  window: "m20" | "h24" | "d7" | "lifetime";
178
1656
  asOf: number;
179
1657
  revision: string;
@@ -181,10 +1659,10 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
181
1659
  currency: "USD";
182
1660
  estimated: true;
183
1661
  coverage: "complete" | "partial" | "unknown";
184
- coverageReasons: ("source-gap" | "root-unattested" | "history-unavailable" | "member-cap" | "depth-cap" | "edge-cap" | "missing-thread" | "unpriced" | "retention" | "row-cap" | "pagination" | "population-incomplete")[];
1662
+ coverageReasons: ("unpriced" | "source-gap" | "root-unattested" | "history-unavailable" | "missing-thread" | "member-cap" | "depth-cap" | "edge-cap" | "retention" | "row-cap" | "pagination" | "population-incomplete")[];
185
1663
  approximation: {
186
1664
  approximate: boolean;
187
- reasons: ("source-gap" | "closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price")[];
1665
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
188
1666
  rates?: {
189
1667
  providerId: string;
190
1668
  modelId: string;
@@ -214,7 +1692,7 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
214
1692
  };
215
1693
  approximation: {
216
1694
  approximate: boolean;
217
- reasons: ("source-gap" | "closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price")[];
1695
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
218
1696
  rates?: {
219
1697
  providerId: string;
220
1698
  modelId: string;
@@ -235,7 +1713,7 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
235
1713
  };
236
1714
  approximation: {
237
1715
  approximate: boolean;
238
- reasons: ("source-gap" | "closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price")[];
1716
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
239
1717
  rates?: {
240
1718
  providerId: string;
241
1719
  modelId: string;
@@ -284,3 +1762,5 @@ export declare function createThreadMetricsDiscovery(sdk: MetricsSdk): {
284
1762
  readonly outstandingReads: number;
285
1763
  discover(options?: Omit<DiscoveryOptions, "sdk">): Promise<DiscoveryResult>;
286
1764
  };
1765
+ export { createRecentSnapshotSession, RecentSnapshotSessionError, RecentSnapshotNotStarted } from './recent-session.js';
1766
+ export type { RecentSnapshotSource, RecentSnapshotObservation, RecentSnapshotSession, RecentSessionClock, RecentSessionFailure } from './recent-session.js';