@phosphorco/bb-thread-metrics 0.1.0 → 0.2.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.
@@ -1,6 +1,6 @@
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 { RecentSnapshotInput, RecentSnapshotResult, ReadInput, ReadResult, DetailInput, DetailResult, Capabilities, OwnerErrorKind } from './index.js';
4
4
  export type MetricsSdk = {
5
5
  readonly plugins: Pick<BbPluginApi['sdk']['plugins'], 'list' | 'callRpc'>;
6
6
  } | {
@@ -10,6 +10,7 @@ export interface MetricsPort {
10
10
  capabilities: Capabilities;
11
11
  read(input: ReadInput): Promise<ReadResult>;
12
12
  detail?(input: DetailInput): Promise<DetailResult>;
13
+ recentSnapshot?(input: RecentSnapshotInput): Promise<RecentSnapshotResult>;
13
14
  }
14
15
  export declare function registerThreadMetricsOwner(bb: Pick<BbPluginApi, 'rpc'>, port: MetricsPort): void;
15
16
  export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: string): {
@@ -21,6 +22,429 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
21
22
  } | {
22
23
  kind: "incompatible";
23
24
  }>;
25
+ recentSnapshot(raw?: RecentSnapshotInput, signal?: AbortSignal): Promise<{
26
+ version: 1;
27
+ revision: string;
28
+ unchanged: false;
29
+ currency: "USD";
30
+ estimated: true;
31
+ cutoffLastFoldAt: number | null;
32
+ asOf: number;
33
+ rankAsOf: number;
34
+ recentWindowMs: number;
35
+ config: {
36
+ revision: string;
37
+ value: {
38
+ mode: "percentile";
39
+ gates: {
40
+ m20: number;
41
+ h24: number;
42
+ d7: number;
43
+ };
44
+ schemaVersion: 2;
45
+ providerWeights: Record<string, number>;
46
+ } | {
47
+ mode: "absolute";
48
+ thresholds: {
49
+ m20: number;
50
+ h24: number;
51
+ d7: number;
52
+ lifetime: number;
53
+ };
54
+ schemaVersion: 2;
55
+ providerWeights: Record<string, number>;
56
+ };
57
+ };
58
+ coverage: "complete" | "partial" | "unknown";
59
+ coverageReasons: string[];
60
+ materializationPending: number;
61
+ omittedRows: {
62
+ count: number;
63
+ exact: boolean;
64
+ };
65
+ population: {
66
+ own: {
67
+ dollars: {
68
+ m20: {
69
+ count: number;
70
+ coverage: "complete" | "partial" | "unknown";
71
+ };
72
+ h24: {
73
+ count: number;
74
+ coverage: "complete" | "partial" | "unknown";
75
+ };
76
+ d7: {
77
+ count: number;
78
+ coverage: "complete" | "partial" | "unknown";
79
+ };
80
+ };
81
+ scores: {
82
+ m20: {
83
+ count: number;
84
+ coverage: "complete" | "partial" | "unknown";
85
+ };
86
+ h24: {
87
+ count: number;
88
+ coverage: "complete" | "partial" | "unknown";
89
+ };
90
+ d7: {
91
+ count: number;
92
+ coverage: "complete" | "partial" | "unknown";
93
+ };
94
+ };
95
+ };
96
+ family: {
97
+ dollars: {
98
+ m20: {
99
+ count: number;
100
+ coverage: "complete" | "partial" | "unknown";
101
+ };
102
+ h24: {
103
+ count: number;
104
+ coverage: "complete" | "partial" | "unknown";
105
+ };
106
+ d7: {
107
+ count: number;
108
+ coverage: "complete" | "partial" | "unknown";
109
+ };
110
+ };
111
+ scores: {
112
+ m20: {
113
+ count: number;
114
+ coverage: "complete" | "partial" | "unknown";
115
+ };
116
+ h24: {
117
+ count: number;
118
+ coverage: "complete" | "partial" | "unknown";
119
+ };
120
+ d7: {
121
+ count: number;
122
+ coverage: "complete" | "partial" | "unknown";
123
+ };
124
+ };
125
+ };
126
+ };
127
+ rows: {
128
+ threadId: string;
129
+ revision: string;
130
+ configRevision: string;
131
+ asOf: number;
132
+ ownLastFoldAt: number | null;
133
+ familyLastFoldAt: number | null;
134
+ own: {
135
+ memberCount: number;
136
+ coverage: "complete" | "partial" | "unknown";
137
+ coverageReasons: string[];
138
+ priceVersion: string;
139
+ approximation: {
140
+ approximate: boolean;
141
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
142
+ };
143
+ windows: {
144
+ m20: {
145
+ kind: "estimate";
146
+ amount: number;
147
+ } | {
148
+ kind: "floor";
149
+ amount: number;
150
+ } | {
151
+ kind: "unavailable";
152
+ amount: null;
153
+ };
154
+ h24: {
155
+ kind: "estimate";
156
+ amount: number;
157
+ } | {
158
+ kind: "floor";
159
+ amount: number;
160
+ } | {
161
+ kind: "unavailable";
162
+ amount: null;
163
+ };
164
+ d7: {
165
+ kind: "estimate";
166
+ amount: number;
167
+ } | {
168
+ kind: "floor";
169
+ amount: number;
170
+ } | {
171
+ kind: "unavailable";
172
+ amount: null;
173
+ };
174
+ lifetime: {
175
+ kind: "estimate";
176
+ amount: number;
177
+ } | {
178
+ kind: "floor";
179
+ amount: number;
180
+ } | {
181
+ kind: "unavailable";
182
+ amount: null;
183
+ };
184
+ };
185
+ scores: {
186
+ m20: {
187
+ kind: "estimate";
188
+ amount: number;
189
+ } | {
190
+ kind: "floor";
191
+ amount: number;
192
+ } | {
193
+ kind: "unavailable";
194
+ amount: null;
195
+ };
196
+ h24: {
197
+ kind: "estimate";
198
+ amount: number;
199
+ } | {
200
+ kind: "floor";
201
+ amount: number;
202
+ } | {
203
+ kind: "unavailable";
204
+ amount: null;
205
+ };
206
+ d7: {
207
+ kind: "estimate";
208
+ amount: number;
209
+ } | {
210
+ kind: "floor";
211
+ amount: number;
212
+ } | {
213
+ kind: "unavailable";
214
+ amount: null;
215
+ };
216
+ lifetime: {
217
+ kind: "estimate";
218
+ amount: number;
219
+ } | {
220
+ kind: "floor";
221
+ amount: number;
222
+ } | {
223
+ kind: "unavailable";
224
+ amount: null;
225
+ };
226
+ };
227
+ providers: {
228
+ providerId: string;
229
+ windows: {
230
+ m20: {
231
+ kind: "estimate";
232
+ amount: number;
233
+ } | {
234
+ kind: "floor";
235
+ amount: number;
236
+ } | {
237
+ kind: "unavailable";
238
+ amount: null;
239
+ };
240
+ h24: {
241
+ kind: "estimate";
242
+ amount: number;
243
+ } | {
244
+ kind: "floor";
245
+ amount: number;
246
+ } | {
247
+ kind: "unavailable";
248
+ amount: null;
249
+ };
250
+ d7: {
251
+ kind: "estimate";
252
+ amount: number;
253
+ } | {
254
+ kind: "floor";
255
+ amount: number;
256
+ } | {
257
+ kind: "unavailable";
258
+ amount: null;
259
+ };
260
+ lifetime: {
261
+ kind: "estimate";
262
+ amount: number;
263
+ } | {
264
+ kind: "floor";
265
+ amount: number;
266
+ } | {
267
+ kind: "unavailable";
268
+ amount: null;
269
+ };
270
+ };
271
+ approximation: {
272
+ approximate: boolean;
273
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
274
+ };
275
+ }[];
276
+ omittedProviders: number;
277
+ dollarRanks: {
278
+ m20: number | null;
279
+ h24: number | null;
280
+ d7: number | null;
281
+ };
282
+ scoreRanks: {
283
+ m20: number | null;
284
+ h24: number | null;
285
+ d7: number | null;
286
+ };
287
+ };
288
+ family: {
289
+ memberCount: number;
290
+ coverage: "complete" | "partial" | "unknown";
291
+ coverageReasons: string[];
292
+ priceVersion: string;
293
+ approximation: {
294
+ approximate: boolean;
295
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
296
+ };
297
+ windows: {
298
+ m20: {
299
+ kind: "estimate";
300
+ amount: number;
301
+ } | {
302
+ kind: "floor";
303
+ amount: number;
304
+ } | {
305
+ kind: "unavailable";
306
+ amount: null;
307
+ };
308
+ h24: {
309
+ kind: "estimate";
310
+ amount: number;
311
+ } | {
312
+ kind: "floor";
313
+ amount: number;
314
+ } | {
315
+ kind: "unavailable";
316
+ amount: null;
317
+ };
318
+ d7: {
319
+ kind: "estimate";
320
+ amount: number;
321
+ } | {
322
+ kind: "floor";
323
+ amount: number;
324
+ } | {
325
+ kind: "unavailable";
326
+ amount: null;
327
+ };
328
+ lifetime: {
329
+ kind: "estimate";
330
+ amount: number;
331
+ } | {
332
+ kind: "floor";
333
+ amount: number;
334
+ } | {
335
+ kind: "unavailable";
336
+ amount: null;
337
+ };
338
+ };
339
+ scores: {
340
+ m20: {
341
+ kind: "estimate";
342
+ amount: number;
343
+ } | {
344
+ kind: "floor";
345
+ amount: number;
346
+ } | {
347
+ kind: "unavailable";
348
+ amount: null;
349
+ };
350
+ h24: {
351
+ kind: "estimate";
352
+ amount: number;
353
+ } | {
354
+ kind: "floor";
355
+ amount: number;
356
+ } | {
357
+ kind: "unavailable";
358
+ amount: null;
359
+ };
360
+ d7: {
361
+ kind: "estimate";
362
+ amount: number;
363
+ } | {
364
+ kind: "floor";
365
+ amount: number;
366
+ } | {
367
+ kind: "unavailable";
368
+ amount: null;
369
+ };
370
+ lifetime: {
371
+ kind: "estimate";
372
+ amount: number;
373
+ } | {
374
+ kind: "floor";
375
+ amount: number;
376
+ } | {
377
+ kind: "unavailable";
378
+ amount: null;
379
+ };
380
+ };
381
+ providers: {
382
+ providerId: string;
383
+ windows: {
384
+ m20: {
385
+ kind: "estimate";
386
+ amount: number;
387
+ } | {
388
+ kind: "floor";
389
+ amount: number;
390
+ } | {
391
+ kind: "unavailable";
392
+ amount: null;
393
+ };
394
+ h24: {
395
+ kind: "estimate";
396
+ amount: number;
397
+ } | {
398
+ kind: "floor";
399
+ amount: number;
400
+ } | {
401
+ kind: "unavailable";
402
+ amount: null;
403
+ };
404
+ d7: {
405
+ kind: "estimate";
406
+ amount: number;
407
+ } | {
408
+ kind: "floor";
409
+ amount: number;
410
+ } | {
411
+ kind: "unavailable";
412
+ amount: null;
413
+ };
414
+ lifetime: {
415
+ kind: "estimate";
416
+ amount: number;
417
+ } | {
418
+ kind: "floor";
419
+ amount: number;
420
+ } | {
421
+ kind: "unavailable";
422
+ amount: null;
423
+ };
424
+ };
425
+ approximation: {
426
+ approximate: boolean;
427
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
428
+ };
429
+ }[];
430
+ omittedProviders: number;
431
+ dollarRanks: {
432
+ m20: number | null;
433
+ h24: number | null;
434
+ d7: number | null;
435
+ };
436
+ scoreRanks: {
437
+ m20: number | null;
438
+ h24: number | null;
439
+ d7: number | null;
440
+ };
441
+ };
442
+ }[];
443
+ } | {
444
+ version: 1;
445
+ revision: string;
446
+ unchanged: true;
447
+ }>;
24
448
  read(raw: ReadInput, signal?: AbortSignal): Promise<{
25
449
  version: 1;
26
450
  rows: ({
@@ -67,7 +491,7 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
67
491
  scope: "own" | "family";
68
492
  memberCount: number;
69
493
  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")[];
494
+ coverageReasons: ("source-gap" | "unpriced" | "root-unattested" | "history-unavailable" | "missing-thread" | "member-cap" | "depth-cap" | "edge-cap" | "retention" | "row-cap" | "pagination" | "population-incomplete")[];
71
495
  asOf: number;
72
496
  revision: string;
73
497
  priceVersion: string;
@@ -75,12 +499,12 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
75
499
  estimated: true;
76
500
  approximation: {
77
501
  approximate: boolean;
78
- reasons: ("source-gap" | "closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price")[];
502
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
79
503
  rates?: {
80
504
  providerId: string;
81
505
  modelId: string;
82
506
  rateId: string | null;
83
- basis: "unpriced" | "closest-model" | "provider-default" | "matched";
507
+ basis: "closest-model" | "provider-default" | "unpriced" | "matched";
84
508
  }[] | undefined;
85
509
  };
86
510
  ranks: {
@@ -121,7 +545,7 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
121
545
  scope: "own" | "family";
122
546
  memberCount: number;
123
547
  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")[];
548
+ coverageReasons: ("source-gap" | "unpriced" | "root-unattested" | "history-unavailable" | "missing-thread" | "member-cap" | "depth-cap" | "edge-cap" | "retention" | "row-cap" | "pagination" | "population-incomplete")[];
125
549
  asOf: number;
126
550
  revision: string;
127
551
  priceVersion: string;
@@ -129,12 +553,12 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
129
553
  estimated: true;
130
554
  approximation: {
131
555
  approximate: boolean;
132
- reasons: ("source-gap" | "closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price")[];
556
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
133
557
  rates?: {
134
558
  providerId: string;
135
559
  modelId: string;
136
560
  rateId: string | null;
137
- basis: "unpriced" | "closest-model" | "provider-default" | "matched";
561
+ basis: "closest-model" | "provider-default" | "unpriced" | "matched";
138
562
  }[] | undefined;
139
563
  };
140
564
  ranks: {
@@ -173,7 +597,7 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
173
597
  version: 1;
174
598
  threadId: string;
175
599
  scope: "own" | "family";
176
- axis: "model" | "time";
600
+ axis: "time" | "model";
177
601
  window: "m20" | "h24" | "d7" | "lifetime";
178
602
  asOf: number;
179
603
  revision: string;
@@ -181,15 +605,15 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
181
605
  currency: "USD";
182
606
  estimated: true;
183
607
  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")[];
608
+ coverageReasons: ("source-gap" | "unpriced" | "root-unattested" | "history-unavailable" | "missing-thread" | "member-cap" | "depth-cap" | "edge-cap" | "retention" | "row-cap" | "pagination" | "population-incomplete")[];
185
609
  approximation: {
186
610
  approximate: boolean;
187
- reasons: ("source-gap" | "closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price")[];
611
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
188
612
  rates?: {
189
613
  providerId: string;
190
614
  modelId: string;
191
615
  rateId: string | null;
192
- basis: "unpriced" | "closest-model" | "provider-default" | "matched";
616
+ basis: "closest-model" | "provider-default" | "unpriced" | "matched";
193
617
  }[] | undefined;
194
618
  };
195
619
  total: {
@@ -214,12 +638,12 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
214
638
  };
215
639
  approximation: {
216
640
  approximate: boolean;
217
- reasons: ("source-gap" | "closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price")[];
641
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
218
642
  rates?: {
219
643
  providerId: string;
220
644
  modelId: string;
221
645
  rateId: string | null;
222
- basis: "unpriced" | "closest-model" | "provider-default" | "matched";
646
+ basis: "closest-model" | "provider-default" | "unpriced" | "matched";
223
647
  }[] | undefined;
224
648
  };
225
649
  } | {
@@ -235,12 +659,12 @@ export declare function createThreadMetricsClient(sdk: MetricsSdk, pluginId: str
235
659
  };
236
660
  approximation: {
237
661
  approximate: boolean;
238
- reasons: ("source-gap" | "closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price")[];
662
+ reasons: ("closest-model" | "provider-default" | "model-attribution" | "bucket-boundary" | "missing-price" | "source-gap")[];
239
663
  rates?: {
240
664
  providerId: string;
241
665
  modelId: string;
242
666
  rateId: string | null;
243
- basis: "unpriced" | "closest-model" | "provider-default" | "matched";
667
+ basis: "closest-model" | "provider-default" | "unpriced" | "matched";
244
668
  }[] | undefined;
245
669
  };
246
670
  })[];