@agent-finops/core 0.9.5 → 0.9.6

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.
@@ -66,9 +66,9 @@ export declare const activitySnapshotApiEquivalentWindowSchema: z.ZodObject<{
66
66
  missing: "missing";
67
67
  }>;
68
68
  coverage: z.ZodEnum<{
69
- missing: "missing";
70
69
  complete: "complete";
71
70
  partial: "partial";
71
+ missing: "missing";
72
72
  }>;
73
73
  }, z.core.$strict>;
74
74
  export type ActivitySnapshotApiEquivalentWindow = z.infer<typeof activitySnapshotApiEquivalentWindowSchema>;
@@ -77,13 +77,13 @@ export declare const activitySnapshotBilledWindowSchema: z.ZodObject<{
77
77
  recordCount: z.ZodNumber;
78
78
  basis: z.ZodLiteral<"provider_billed">;
79
79
  financialEvidence: z.ZodEnum<{
80
- verified: "verified";
81
80
  missing: "missing";
81
+ verified: "verified";
82
82
  }>;
83
83
  coverage: z.ZodEnum<{
84
- missing: "missing";
85
84
  complete: "complete";
86
85
  partial: "partial";
86
+ missing: "missing";
87
87
  }>;
88
88
  }, z.core.$strict>;
89
89
  export type ActivitySnapshotBilledWindow = z.infer<typeof activitySnapshotBilledWindowSchema>;
@@ -97,9 +97,9 @@ export declare const activitySnapshotApiEquivalentWindowsSchema: z.ZodObject<{
97
97
  missing: "missing";
98
98
  }>;
99
99
  coverage: z.ZodEnum<{
100
- missing: "missing";
101
100
  complete: "complete";
102
101
  partial: "partial";
102
+ missing: "missing";
103
103
  }>;
104
104
  }, z.core.$strict>;
105
105
  sevenDays: z.ZodObject<{
@@ -111,9 +111,9 @@ export declare const activitySnapshotApiEquivalentWindowsSchema: z.ZodObject<{
111
111
  missing: "missing";
112
112
  }>;
113
113
  coverage: z.ZodEnum<{
114
- missing: "missing";
115
114
  complete: "complete";
116
115
  partial: "partial";
116
+ missing: "missing";
117
117
  }>;
118
118
  }, z.core.$strict>;
119
119
  thirtyDays: z.ZodObject<{
@@ -125,9 +125,9 @@ export declare const activitySnapshotApiEquivalentWindowsSchema: z.ZodObject<{
125
125
  missing: "missing";
126
126
  }>;
127
127
  coverage: z.ZodEnum<{
128
- missing: "missing";
129
128
  complete: "complete";
130
129
  partial: "partial";
130
+ missing: "missing";
131
131
  }>;
132
132
  }, z.core.$strict>;
133
133
  }, z.core.$strict>;
@@ -138,13 +138,13 @@ export declare const activitySnapshotBilledWindowsSchema: z.ZodObject<{
138
138
  recordCount: z.ZodNumber;
139
139
  basis: z.ZodLiteral<"provider_billed">;
140
140
  financialEvidence: z.ZodEnum<{
141
- verified: "verified";
142
141
  missing: "missing";
142
+ verified: "verified";
143
143
  }>;
144
144
  coverage: z.ZodEnum<{
145
- missing: "missing";
146
145
  complete: "complete";
147
146
  partial: "partial";
147
+ missing: "missing";
148
148
  }>;
149
149
  }, z.core.$strict>;
150
150
  sevenDays: z.ZodObject<{
@@ -152,13 +152,13 @@ export declare const activitySnapshotBilledWindowsSchema: z.ZodObject<{
152
152
  recordCount: z.ZodNumber;
153
153
  basis: z.ZodLiteral<"provider_billed">;
154
154
  financialEvidence: z.ZodEnum<{
155
- verified: "verified";
156
155
  missing: "missing";
156
+ verified: "verified";
157
157
  }>;
158
158
  coverage: z.ZodEnum<{
159
- missing: "missing";
160
159
  complete: "complete";
161
160
  partial: "partial";
161
+ missing: "missing";
162
162
  }>;
163
163
  }, z.core.$strict>;
164
164
  thirtyDays: z.ZodObject<{
@@ -166,13 +166,13 @@ export declare const activitySnapshotBilledWindowsSchema: z.ZodObject<{
166
166
  recordCount: z.ZodNumber;
167
167
  basis: z.ZodLiteral<"provider_billed">;
168
168
  financialEvidence: z.ZodEnum<{
169
- verified: "verified";
170
169
  missing: "missing";
170
+ verified: "verified";
171
171
  }>;
172
172
  coverage: z.ZodEnum<{
173
- missing: "missing";
174
173
  complete: "complete";
175
174
  partial: "partial";
175
+ missing: "missing";
176
176
  }>;
177
177
  }, z.core.$strict>;
178
178
  }, z.core.$strict>;
@@ -193,9 +193,9 @@ export declare const activitySnapshotSubscriptionAgentSchema: z.ZodObject<{
193
193
  agent: z.ZodString & z.ZodType<ActivitySnapshotAgent, string, z.core.$ZodTypeInternals<ActivitySnapshotAgent, string>>;
194
194
  billing: z.ZodLiteral<"subscription">;
195
195
  planId: z.ZodNullable<z.ZodEnum<{
196
- "claude-max-20x": "claude-max-20x";
197
- "claude-max-5x": "claude-max-5x";
198
196
  "claude-pro": "claude-pro";
197
+ "claude-max-5x": "claude-max-5x";
198
+ "claude-max-20x": "claude-max-20x";
199
199
  "chatgpt-plus": "chatgpt-plus";
200
200
  "chatgpt-pro": "chatgpt-pro";
201
201
  }>>;
@@ -210,9 +210,9 @@ export declare const activitySnapshotSubscriptionAgentSchema: z.ZodObject<{
210
210
  missing: "missing";
211
211
  }>;
212
212
  coverage: z.ZodEnum<{
213
- missing: "missing";
214
213
  complete: "complete";
215
214
  partial: "partial";
215
+ missing: "missing";
216
216
  }>;
217
217
  }, z.core.$strict>;
218
218
  sevenDays: z.ZodObject<{
@@ -224,9 +224,9 @@ export declare const activitySnapshotSubscriptionAgentSchema: z.ZodObject<{
224
224
  missing: "missing";
225
225
  }>;
226
226
  coverage: z.ZodEnum<{
227
- missing: "missing";
228
227
  complete: "complete";
229
228
  partial: "partial";
229
+ missing: "missing";
230
230
  }>;
231
231
  }, z.core.$strict>;
232
232
  thirtyDays: z.ZodObject<{
@@ -238,9 +238,9 @@ export declare const activitySnapshotSubscriptionAgentSchema: z.ZodObject<{
238
238
  missing: "missing";
239
239
  }>;
240
240
  coverage: z.ZodEnum<{
241
- missing: "missing";
242
241
  complete: "complete";
243
242
  partial: "partial";
243
+ missing: "missing";
244
244
  }>;
245
245
  }, z.core.$strict>;
246
246
  }, z.core.$strict>;
@@ -269,11 +269,11 @@ export type ActivitySnapshotSubscriptionAgent = z.infer<typeof activitySnapshotS
269
269
  */
270
270
  export declare const activitySnapshotProviderSubscriptionSchema: z.ZodObject<{
271
271
  provider: z.ZodEnum<{
272
- anthropic: "anthropic";
273
272
  openai: "openai";
273
+ anthropic: "anthropic";
274
274
  cursor: "cursor";
275
- other: "other";
276
275
  "github-copilot": "github-copilot";
276
+ other: "other";
277
277
  }>;
278
278
  billing: z.ZodLiteral<"subscription">;
279
279
  planLabel: z.ZodNullable<z.ZodString>;
@@ -283,13 +283,13 @@ export declare const activitySnapshotProviderSubscriptionSchema: z.ZodObject<{
283
283
  recordCount: z.ZodNumber;
284
284
  basis: z.ZodLiteral<"provider_billed">;
285
285
  financialEvidence: z.ZodEnum<{
286
- verified: "verified";
287
286
  missing: "missing";
287
+ verified: "verified";
288
288
  }>;
289
289
  coverage: z.ZodEnum<{
290
- missing: "missing";
291
290
  complete: "complete";
292
291
  partial: "partial";
292
+ missing: "missing";
293
293
  }>;
294
294
  }, z.core.$strict>;
295
295
  }, z.core.$strict>;
@@ -330,17 +330,17 @@ export declare const activitySnapshotCoverageSchema: z.ZodObject<{
330
330
  nonFinancialBytesPrefiltered: z.ZodNumber;
331
331
  jsonlValidationCoverage: z.ZodEnum<{
332
332
  complete: "complete";
333
- not_reported: "not_reported";
334
333
  financial_events_only: "financial_events_only";
334
+ not_reported: "not_reported";
335
335
  }>;
336
336
  }, z.core.$strict>>;
337
337
  providers: z.ZodArray<z.ZodObject<{
338
338
  provider: z.ZodEnum<{
339
- anthropic: "anthropic";
340
339
  openai: "openai";
340
+ anthropic: "anthropic";
341
341
  cursor: "cursor";
342
- other: "other";
343
342
  "github-copilot": "github-copilot";
343
+ other: "other";
344
344
  }>;
345
345
  status: z.ZodEnum<{
346
346
  error: "error";
@@ -385,30 +385,30 @@ export declare const activitySnapshotSchema: z.ZodObject<{
385
385
  }, z.core.$strict>, z.ZodObject<{
386
386
  status: z.ZodLiteral<"error">;
387
387
  errorCode: z.ZodEnum<{
388
- unknown: "unknown";
389
- timeout: "timeout";
390
388
  scan_failed: "scan_failed";
391
389
  source_unreadable: "source_unreadable";
392
390
  invalid_evidence: "invalid_evidence";
391
+ timeout: "timeout";
393
392
  cache_write_failed: "cache_write_failed";
393
+ unknown: "unknown";
394
394
  }>;
395
395
  }, z.core.$strict>], "status">;
396
396
  mode: z.ZodEnum<{
397
- error: "error";
398
- empty: "empty";
399
- subscription: "subscription";
400
397
  metered: "metered";
398
+ subscription: "subscription";
401
399
  mixed: "mixed";
402
400
  unresolved: "unresolved";
401
+ empty: "empty";
402
+ error: "error";
403
403
  }>;
404
404
  subscription: z.ZodNullable<z.ZodObject<{
405
405
  agents: z.ZodArray<z.ZodObject<{
406
406
  agent: z.ZodString & z.ZodType<ActivitySnapshotAgent, string, z.core.$ZodTypeInternals<ActivitySnapshotAgent, string>>;
407
407
  billing: z.ZodLiteral<"subscription">;
408
408
  planId: z.ZodNullable<z.ZodEnum<{
409
- "claude-max-20x": "claude-max-20x";
410
- "claude-max-5x": "claude-max-5x";
411
409
  "claude-pro": "claude-pro";
410
+ "claude-max-5x": "claude-max-5x";
411
+ "claude-max-20x": "claude-max-20x";
412
412
  "chatgpt-plus": "chatgpt-plus";
413
413
  "chatgpt-pro": "chatgpt-pro";
414
414
  }>>;
@@ -423,9 +423,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
423
423
  missing: "missing";
424
424
  }>;
425
425
  coverage: z.ZodEnum<{
426
- missing: "missing";
427
426
  complete: "complete";
428
427
  partial: "partial";
428
+ missing: "missing";
429
429
  }>;
430
430
  }, z.core.$strict>;
431
431
  sevenDays: z.ZodObject<{
@@ -437,9 +437,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
437
437
  missing: "missing";
438
438
  }>;
439
439
  coverage: z.ZodEnum<{
440
- missing: "missing";
441
440
  complete: "complete";
442
441
  partial: "partial";
442
+ missing: "missing";
443
443
  }>;
444
444
  }, z.core.$strict>;
445
445
  thirtyDays: z.ZodObject<{
@@ -451,9 +451,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
451
451
  missing: "missing";
452
452
  }>;
453
453
  coverage: z.ZodEnum<{
454
- missing: "missing";
455
454
  complete: "complete";
456
455
  partial: "partial";
456
+ missing: "missing";
457
457
  }>;
458
458
  }, z.core.$strict>;
459
459
  }, z.core.$strict>;
@@ -478,9 +478,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
478
478
  agent: z.ZodString & z.ZodType<ActivitySnapshotAgent, string, z.core.$ZodTypeInternals<ActivitySnapshotAgent, string>>;
479
479
  billing: z.ZodLiteral<"api_key">;
480
480
  planId: z.ZodNullable<z.ZodEnum<{
481
- "claude-max-20x": "claude-max-20x";
482
- "claude-max-5x": "claude-max-5x";
483
481
  "claude-pro": "claude-pro";
482
+ "claude-max-5x": "claude-max-5x";
483
+ "claude-max-20x": "claude-max-20x";
484
484
  "chatgpt-plus": "chatgpt-plus";
485
485
  "chatgpt-pro": "chatgpt-pro";
486
486
  }>>;
@@ -495,9 +495,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
495
495
  missing: "missing";
496
496
  }>;
497
497
  coverage: z.ZodEnum<{
498
- missing: "missing";
499
498
  complete: "complete";
500
499
  partial: "partial";
500
+ missing: "missing";
501
501
  }>;
502
502
  }, z.core.$strict>;
503
503
  sevenDays: z.ZodObject<{
@@ -509,9 +509,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
509
509
  missing: "missing";
510
510
  }>;
511
511
  coverage: z.ZodEnum<{
512
- missing: "missing";
513
512
  complete: "complete";
514
513
  partial: "partial";
514
+ missing: "missing";
515
515
  }>;
516
516
  }, z.core.$strict>;
517
517
  thirtyDays: z.ZodObject<{
@@ -523,9 +523,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
523
523
  missing: "missing";
524
524
  }>;
525
525
  coverage: z.ZodEnum<{
526
- missing: "missing";
527
526
  complete: "complete";
528
527
  partial: "partial";
528
+ missing: "missing";
529
529
  }>;
530
530
  }, z.core.$strict>;
531
531
  }, z.core.$strict>;
@@ -535,13 +535,13 @@ export declare const activitySnapshotSchema: z.ZodObject<{
535
535
  recordCount: z.ZodNumber;
536
536
  basis: z.ZodLiteral<"provider_billed">;
537
537
  financialEvidence: z.ZodEnum<{
538
- verified: "verified";
539
538
  missing: "missing";
539
+ verified: "verified";
540
540
  }>;
541
541
  coverage: z.ZodEnum<{
542
- missing: "missing";
543
542
  complete: "complete";
544
543
  partial: "partial";
544
+ missing: "missing";
545
545
  }>;
546
546
  }, z.core.$strict>;
547
547
  sevenDays: z.ZodObject<{
@@ -549,13 +549,13 @@ export declare const activitySnapshotSchema: z.ZodObject<{
549
549
  recordCount: z.ZodNumber;
550
550
  basis: z.ZodLiteral<"provider_billed">;
551
551
  financialEvidence: z.ZodEnum<{
552
- verified: "verified";
553
552
  missing: "missing";
553
+ verified: "verified";
554
554
  }>;
555
555
  coverage: z.ZodEnum<{
556
- missing: "missing";
557
556
  complete: "complete";
558
557
  partial: "partial";
558
+ missing: "missing";
559
559
  }>;
560
560
  }, z.core.$strict>;
561
561
  thirtyDays: z.ZodObject<{
@@ -563,13 +563,13 @@ export declare const activitySnapshotSchema: z.ZodObject<{
563
563
  recordCount: z.ZodNumber;
564
564
  basis: z.ZodLiteral<"provider_billed">;
565
565
  financialEvidence: z.ZodEnum<{
566
- verified: "verified";
567
566
  missing: "missing";
567
+ verified: "verified";
568
568
  }>;
569
569
  coverage: z.ZodEnum<{
570
- missing: "missing";
571
570
  complete: "complete";
572
571
  partial: "partial";
572
+ missing: "missing";
573
573
  }>;
574
574
  }, z.core.$strict>;
575
575
  }, z.core.$strict>;
@@ -579,9 +579,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
579
579
  agent: z.ZodString & z.ZodType<ActivitySnapshotAgent, string, z.core.$ZodTypeInternals<ActivitySnapshotAgent, string>>;
580
580
  billing: z.ZodLiteral<"unknown">;
581
581
  planId: z.ZodNullable<z.ZodEnum<{
582
- "claude-max-20x": "claude-max-20x";
583
- "claude-max-5x": "claude-max-5x";
584
582
  "claude-pro": "claude-pro";
583
+ "claude-max-5x": "claude-max-5x";
584
+ "claude-max-20x": "claude-max-20x";
585
585
  "chatgpt-plus": "chatgpt-plus";
586
586
  "chatgpt-pro": "chatgpt-pro";
587
587
  }>>;
@@ -596,9 +596,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
596
596
  missing: "missing";
597
597
  }>;
598
598
  coverage: z.ZodEnum<{
599
- missing: "missing";
600
599
  complete: "complete";
601
600
  partial: "partial";
601
+ missing: "missing";
602
602
  }>;
603
603
  }, z.core.$strict>;
604
604
  sevenDays: z.ZodObject<{
@@ -610,9 +610,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
610
610
  missing: "missing";
611
611
  }>;
612
612
  coverage: z.ZodEnum<{
613
- missing: "missing";
614
613
  complete: "complete";
615
614
  partial: "partial";
615
+ missing: "missing";
616
616
  }>;
617
617
  }, z.core.$strict>;
618
618
  thirtyDays: z.ZodObject<{
@@ -624,20 +624,20 @@ export declare const activitySnapshotSchema: z.ZodObject<{
624
624
  missing: "missing";
625
625
  }>;
626
626
  coverage: z.ZodEnum<{
627
- missing: "missing";
628
627
  complete: "complete";
629
628
  partial: "partial";
629
+ missing: "missing";
630
630
  }>;
631
631
  }, z.core.$strict>;
632
632
  }, z.core.$strict>;
633
633
  }, z.core.$strict>>;
634
634
  providers: z.ZodNullable<z.ZodArray<z.ZodObject<{
635
635
  provider: z.ZodEnum<{
636
- anthropic: "anthropic";
637
636
  openai: "openai";
637
+ anthropic: "anthropic";
638
638
  cursor: "cursor";
639
- other: "other";
640
639
  "github-copilot": "github-copilot";
640
+ other: "other";
641
641
  }>;
642
642
  billing: z.ZodLiteral<"subscription">;
643
643
  planLabel: z.ZodNullable<z.ZodString>;
@@ -647,13 +647,13 @@ export declare const activitySnapshotSchema: z.ZodObject<{
647
647
  recordCount: z.ZodNumber;
648
648
  basis: z.ZodLiteral<"provider_billed">;
649
649
  financialEvidence: z.ZodEnum<{
650
- verified: "verified";
651
650
  missing: "missing";
651
+ verified: "verified";
652
652
  }>;
653
653
  coverage: z.ZodEnum<{
654
- missing: "missing";
655
654
  complete: "complete";
656
655
  partial: "partial";
656
+ missing: "missing";
657
657
  }>;
658
658
  }, z.core.$strict>;
659
659
  }, z.core.$strict>>>;
@@ -690,17 +690,17 @@ export declare const activitySnapshotSchema: z.ZodObject<{
690
690
  nonFinancialBytesPrefiltered: z.ZodNumber;
691
691
  jsonlValidationCoverage: z.ZodEnum<{
692
692
  complete: "complete";
693
- not_reported: "not_reported";
694
693
  financial_events_only: "financial_events_only";
694
+ not_reported: "not_reported";
695
695
  }>;
696
696
  }, z.core.$strict>>;
697
697
  providers: z.ZodArray<z.ZodObject<{
698
698
  provider: z.ZodEnum<{
699
- anthropic: "anthropic";
700
699
  openai: "openai";
700
+ anthropic: "anthropic";
701
701
  cursor: "cursor";
702
- other: "other";
703
702
  "github-copilot": "github-copilot";
703
+ other: "other";
704
704
  }>;
705
705
  status: z.ZodEnum<{
706
706
  error: "error";
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { aggregateCalls, dedupeCumulativeSessionCalls } from "./localAgentLogs.js";
3
3
  import { localAgentFormatDescriptors } from "./localAgentFormats/registry.js";
4
- import { canPriceTokenUsageAtScope, estimateTokenCostUsd, PRICING_TABLE_AS_OF } from "./modelPricing.js";
4
+ import { canPriceTokenUsageAtScope, estimateTokenCostsUsd, PRICING_TABLE_AS_OF } from "./modelPricing.js";
5
5
  import { subscriptionPlans } from "./planMath.js";
6
6
  import { isBundledSampleUsage } from "./schema.js";
7
7
  import { sourceValidationCoverageValues } from "./sourceStatus.js";
@@ -937,13 +937,22 @@ function apiEquivalentObservations(records, calls, trustedProviderIds) {
937
937
  }
938
938
  return observations;
939
939
  }
940
+ /**
941
+ * One call's API-equivalent cost with its tier taken from the largest single
942
+ * request it contains, matching the report's aggregation. Weighting a
943
+ * session-cumulative slice at its own cache-inflated prompt would put it on the
944
+ * wrong tier and skew the allocation.
945
+ */
946
+ function callAmountUsd(call) {
947
+ return estimateTokenCostsUsd(call.model, [call.usage], [call.maxRequestPromptTokens]);
948
+ }
940
949
  function allocateAggregateAmount(amountUsd, calls) {
941
950
  if (amountUsd === null)
942
951
  return calls.map(() => null);
943
- const priceable = calls.map((call) => canPriceTokenUsageAtScope(call.model, call.usage, call.usageScope === "turn" ? "request" : "aggregate") && estimateTokenCostUsd(call.model, call.usage) !== undefined);
952
+ const priceable = calls.map((call) => canPriceTokenUsageAtScope(call.model, call.usage, call.usageScope === "turn" ? "request" : "aggregate", call.maxRequestPromptTokens) && callAmountUsd(call) !== undefined);
944
953
  if (priceable.some((supported) => !supported))
945
954
  return calls.map(() => null);
946
- const weights = calls.map((call) => estimateTokenCostUsd(call.model, call.usage) ?? 0);
955
+ const weights = calls.map((call) => callAmountUsd(call) ?? 0);
947
956
  const totalWeight = weights.reduce((sum, weight) => sum + weight, 0);
948
957
  if (totalWeight <= 0) {
949
958
  return amountUsd === 0 ? calls.map(() => 0) : calls.map(() => null);