@agent-finops/core 0.7.3 → 0.8.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.
package/README.md CHANGED
@@ -2,12 +2,45 @@
2
2
 
3
3
  The canonical local-first evidence and decision engine for
4
4
  [aibill](https://github.com/futurastudio/ai-spend-agent): Claude Code/Codex
5
- activity ingestion, provider cost semantics, attribution, provenance, runway,
6
- Context Health, and the shared Glance contract.
5
+ activity ingestion, experimental Gemini CLI financial ingestion, provider cost
6
+ semantics, attribution, provenance, runway, Context Health, and the shared
7
+ Glance contract. Gemini support is fixture-verified and does not enter the
8
+ Glance/status-line or Context Health contracts.
7
9
 
8
10
  Most users should run `npx aibill`. This package is for integrations that
9
11
  need the same evidence-labeled calculations as the CLI and MCP server.
10
12
 
13
+ ## Supported library preview
14
+
15
+ Use Node.js 22+ ESM and import only from the package root:
16
+
17
+ ```ts
18
+ import { analyzeSpend, parseUsageRecord } from "@agent-finops/core";
19
+ ```
20
+
21
+ The supported 0.x subset covers usage-record validation/parsing,
22
+ `analyzeSpend`, Receipt v0 creation/parsing, opaque source-record references,
23
+ and the explicitly version-pinned FOCUS, OpenTelemetry GenAI, and Tokenomics
24
+ projections. Tokenomics remains a `not_published`, zero-row tracking stub.
25
+
26
+ An explicit export map blocks unsupported deep imports. Other historical root
27
+ exports remain available for compatibility but are not stabilized by this
28
+ narrow preview. See the complete
29
+ [library contract](https://github.com/futurastudio/ai-spend-agent/blob/main/docs/LIBRARY.md),
30
+ including the runnable JavaScript/TypeScript example and 0.x deprecation
31
+ policy.
32
+
33
+ The supported functions are local, deterministic operations on caller-supplied
34
+ objects for a given package version. Importing this package does not read
35
+ transcripts or credentials, write state, call a provider, upload evidence, or
36
+ send telemetry.
37
+
38
+ Schema parsing checks structure and internal consistency; it does not
39
+ authenticate a source, verify a price, or reconcile an invoice. Callers must
40
+ keep provenance and confidence labels truthful: reserve `verified` for
41
+ official provider-reported financial evidence, keep modeled/local value
42
+ `estimated` or `missing`, and leave unvalidated adapters `untested`.
43
+
11
44
  This is the open foundation for aibill's financial-accountability mission. It
12
45
  does not yet implement company-wide ownership, accepted outcomes, approvals,
13
46
  invoice reconciliation, or ROI.
@@ -4,8 +4,8 @@ import type { LocalAgentFormatId } from "./localAgentFormats/types.js";
4
4
  import type { DetectedPlan } from "./planDetection.js";
5
5
  import { type UsageRecord } from "./schema.js";
6
6
  import { type SourceValidationCoverage } from "./sourceStatus.js";
7
- export declare const activitySnapshotAgentValues: readonly LocalAgentFormatId[];
8
- export type ActivitySnapshotAgent = LocalAgentFormatId;
7
+ export type ActivitySnapshotAgent = Extract<LocalAgentFormatId, "claude-code" | "codex">;
8
+ export declare const activitySnapshotAgentValues: readonly ActivitySnapshotAgent[];
9
9
  export declare const activitySnapshotPlanIdValues: readonly ["claude-pro", "claude-max-5x", "claude-max-20x", "chatgpt-plus", "chatgpt-pro"];
10
10
  export type ActivitySnapshotPlanId = typeof activitySnapshotPlanIdValues[number];
11
11
  export declare const activitySnapshotProviderValues: readonly ["openai", "anthropic", "cursor", "github-copilot", "other"];
@@ -54,9 +54,9 @@ export declare const activitySnapshotApiEquivalentWindowSchema: z.ZodObject<{
54
54
  missing: "missing";
55
55
  }>;
56
56
  coverage: z.ZodEnum<{
57
- missing: "missing";
58
57
  complete: "complete";
59
58
  partial: "partial";
59
+ missing: "missing";
60
60
  }>;
61
61
  }, z.core.$strict>;
62
62
  export type ActivitySnapshotApiEquivalentWindow = z.infer<typeof activitySnapshotApiEquivalentWindowSchema>;
@@ -65,13 +65,13 @@ export declare const activitySnapshotBilledWindowSchema: z.ZodObject<{
65
65
  recordCount: z.ZodNumber;
66
66
  basis: z.ZodLiteral<"provider_billed">;
67
67
  financialEvidence: z.ZodEnum<{
68
- verified: "verified";
69
68
  missing: "missing";
69
+ verified: "verified";
70
70
  }>;
71
71
  coverage: z.ZodEnum<{
72
- missing: "missing";
73
72
  complete: "complete";
74
73
  partial: "partial";
74
+ missing: "missing";
75
75
  }>;
76
76
  }, z.core.$strict>;
77
77
  export type ActivitySnapshotBilledWindow = z.infer<typeof activitySnapshotBilledWindowSchema>;
@@ -85,9 +85,9 @@ export declare const activitySnapshotApiEquivalentWindowsSchema: z.ZodObject<{
85
85
  missing: "missing";
86
86
  }>;
87
87
  coverage: z.ZodEnum<{
88
- missing: "missing";
89
88
  complete: "complete";
90
89
  partial: "partial";
90
+ missing: "missing";
91
91
  }>;
92
92
  }, z.core.$strict>;
93
93
  sevenDays: z.ZodObject<{
@@ -99,9 +99,9 @@ export declare const activitySnapshotApiEquivalentWindowsSchema: z.ZodObject<{
99
99
  missing: "missing";
100
100
  }>;
101
101
  coverage: z.ZodEnum<{
102
- missing: "missing";
103
102
  complete: "complete";
104
103
  partial: "partial";
104
+ missing: "missing";
105
105
  }>;
106
106
  }, z.core.$strict>;
107
107
  thirtyDays: z.ZodObject<{
@@ -113,9 +113,9 @@ export declare const activitySnapshotApiEquivalentWindowsSchema: z.ZodObject<{
113
113
  missing: "missing";
114
114
  }>;
115
115
  coverage: z.ZodEnum<{
116
- missing: "missing";
117
116
  complete: "complete";
118
117
  partial: "partial";
118
+ missing: "missing";
119
119
  }>;
120
120
  }, z.core.$strict>;
121
121
  }, z.core.$strict>;
@@ -126,13 +126,13 @@ export declare const activitySnapshotBilledWindowsSchema: z.ZodObject<{
126
126
  recordCount: z.ZodNumber;
127
127
  basis: z.ZodLiteral<"provider_billed">;
128
128
  financialEvidence: z.ZodEnum<{
129
- verified: "verified";
130
129
  missing: "missing";
130
+ verified: "verified";
131
131
  }>;
132
132
  coverage: z.ZodEnum<{
133
- missing: "missing";
134
133
  complete: "complete";
135
134
  partial: "partial";
135
+ missing: "missing";
136
136
  }>;
137
137
  }, z.core.$strict>;
138
138
  sevenDays: z.ZodObject<{
@@ -140,13 +140,13 @@ export declare const activitySnapshotBilledWindowsSchema: z.ZodObject<{
140
140
  recordCount: z.ZodNumber;
141
141
  basis: z.ZodLiteral<"provider_billed">;
142
142
  financialEvidence: z.ZodEnum<{
143
- verified: "verified";
144
143
  missing: "missing";
144
+ verified: "verified";
145
145
  }>;
146
146
  coverage: z.ZodEnum<{
147
- missing: "missing";
148
147
  complete: "complete";
149
148
  partial: "partial";
149
+ missing: "missing";
150
150
  }>;
151
151
  }, z.core.$strict>;
152
152
  thirtyDays: z.ZodObject<{
@@ -154,13 +154,13 @@ export declare const activitySnapshotBilledWindowsSchema: z.ZodObject<{
154
154
  recordCount: z.ZodNumber;
155
155
  basis: z.ZodLiteral<"provider_billed">;
156
156
  financialEvidence: z.ZodEnum<{
157
- verified: "verified";
158
157
  missing: "missing";
158
+ verified: "verified";
159
159
  }>;
160
160
  coverage: z.ZodEnum<{
161
- missing: "missing";
162
161
  complete: "complete";
163
162
  partial: "partial";
163
+ missing: "missing";
164
164
  }>;
165
165
  }, z.core.$strict>;
166
166
  }, z.core.$strict>;
@@ -178,12 +178,12 @@ export declare const activitySnapshotLimitSchema: z.ZodObject<{
178
178
  }, z.core.$strict>;
179
179
  export type ActivitySnapshotLimit = z.infer<typeof activitySnapshotLimitSchema>;
180
180
  export declare const activitySnapshotSubscriptionAgentSchema: z.ZodObject<{
181
- agent: z.ZodString & z.ZodType<LocalAgentFormatId, string, z.core.$ZodTypeInternals<LocalAgentFormatId, string>>;
181
+ agent: z.ZodString & z.ZodType<ActivitySnapshotAgent, string, z.core.$ZodTypeInternals<ActivitySnapshotAgent, string>>;
182
182
  billing: z.ZodLiteral<"subscription">;
183
183
  planId: z.ZodNullable<z.ZodEnum<{
184
- "claude-max-20x": "claude-max-20x";
185
- "claude-max-5x": "claude-max-5x";
186
184
  "claude-pro": "claude-pro";
185
+ "claude-max-5x": "claude-max-5x";
186
+ "claude-max-20x": "claude-max-20x";
187
187
  "chatgpt-plus": "chatgpt-plus";
188
188
  "chatgpt-pro": "chatgpt-pro";
189
189
  }>>;
@@ -197,9 +197,9 @@ export declare const activitySnapshotSubscriptionAgentSchema: z.ZodObject<{
197
197
  missing: "missing";
198
198
  }>;
199
199
  coverage: z.ZodEnum<{
200
- missing: "missing";
201
200
  complete: "complete";
202
201
  partial: "partial";
202
+ missing: "missing";
203
203
  }>;
204
204
  }, z.core.$strict>;
205
205
  sevenDays: z.ZodObject<{
@@ -211,9 +211,9 @@ export declare const activitySnapshotSubscriptionAgentSchema: z.ZodObject<{
211
211
  missing: "missing";
212
212
  }>;
213
213
  coverage: z.ZodEnum<{
214
- missing: "missing";
215
214
  complete: "complete";
216
215
  partial: "partial";
216
+ missing: "missing";
217
217
  }>;
218
218
  }, z.core.$strict>;
219
219
  thirtyDays: z.ZodObject<{
@@ -225,9 +225,9 @@ export declare const activitySnapshotSubscriptionAgentSchema: z.ZodObject<{
225
225
  missing: "missing";
226
226
  }>;
227
227
  coverage: z.ZodEnum<{
228
- missing: "missing";
229
228
  complete: "complete";
230
229
  partial: "partial";
230
+ missing: "missing";
231
231
  }>;
232
232
  }, z.core.$strict>;
233
233
  }, z.core.$strict>;
@@ -258,7 +258,7 @@ export declare const activitySnapshotOverageSchema: z.ZodObject<{
258
258
  export type ActivitySnapshotOverage = z.infer<typeof activitySnapshotOverageSchema>;
259
259
  export declare const activitySnapshotCoverageSchema: z.ZodObject<{
260
260
  agents: z.ZodArray<z.ZodObject<{
261
- agent: z.ZodString & z.ZodType<LocalAgentFormatId, string, z.core.$ZodTypeInternals<LocalAgentFormatId, string>>;
261
+ agent: z.ZodString & z.ZodType<ActivitySnapshotAgent, string, z.core.$ZodTypeInternals<ActivitySnapshotAgent, string>>;
262
262
  directoryStatus: z.ZodEnum<{
263
263
  missing: "missing";
264
264
  readable: "readable";
@@ -282,11 +282,11 @@ export declare const activitySnapshotCoverageSchema: z.ZodObject<{
282
282
  }, z.core.$strict>>;
283
283
  providers: z.ZodArray<z.ZodObject<{
284
284
  provider: z.ZodEnum<{
285
- anthropic: "anthropic";
286
285
  openai: "openai";
286
+ anthropic: "anthropic";
287
287
  cursor: "cursor";
288
- other: "other";
289
288
  "github-copilot": "github-copilot";
289
+ other: "other";
290
290
  }>;
291
291
  status: z.ZodEnum<{
292
292
  error: "error";
@@ -309,10 +309,10 @@ export declare const activitySnapshotCoverageSchema: z.ZodObject<{
309
309
  recordsPriced: z.ZodNumber;
310
310
  recordsUnpriced: z.ZodNumber;
311
311
  validationStatus: z.ZodEnum<{
312
- failed: "failed";
313
312
  complete: "complete";
314
- not_checked: "not_checked";
315
313
  partial: "partial";
314
+ failed: "failed";
315
+ not_checked: "not_checked";
316
316
  }>;
317
317
  pricingAsOf: z.ZodString;
318
318
  networkUploaded: z.ZodLiteral<false>;
@@ -331,30 +331,30 @@ export declare const activitySnapshotSchema: z.ZodObject<{
331
331
  }, z.core.$strict>, z.ZodObject<{
332
332
  status: z.ZodLiteral<"error">;
333
333
  errorCode: z.ZodEnum<{
334
- unknown: "unknown";
335
334
  scan_failed: "scan_failed";
336
335
  source_unreadable: "source_unreadable";
337
336
  invalid_evidence: "invalid_evidence";
338
337
  timeout: "timeout";
339
338
  cache_write_failed: "cache_write_failed";
339
+ unknown: "unknown";
340
340
  }>;
341
341
  }, z.core.$strict>], "status">;
342
342
  mode: z.ZodEnum<{
343
- error: "error";
344
- subscription: "subscription";
345
343
  metered: "metered";
344
+ subscription: "subscription";
346
345
  mixed: "mixed";
347
346
  unresolved: "unresolved";
348
347
  empty: "empty";
348
+ error: "error";
349
349
  }>;
350
350
  subscription: z.ZodNullable<z.ZodObject<{
351
351
  agents: z.ZodArray<z.ZodObject<{
352
- agent: z.ZodString & z.ZodType<LocalAgentFormatId, string, z.core.$ZodTypeInternals<LocalAgentFormatId, string>>;
352
+ agent: z.ZodString & z.ZodType<ActivitySnapshotAgent, string, z.core.$ZodTypeInternals<ActivitySnapshotAgent, string>>;
353
353
  billing: z.ZodLiteral<"subscription">;
354
354
  planId: z.ZodNullable<z.ZodEnum<{
355
- "claude-max-20x": "claude-max-20x";
356
- "claude-max-5x": "claude-max-5x";
357
355
  "claude-pro": "claude-pro";
356
+ "claude-max-5x": "claude-max-5x";
357
+ "claude-max-20x": "claude-max-20x";
358
358
  "chatgpt-plus": "chatgpt-plus";
359
359
  "chatgpt-pro": "chatgpt-pro";
360
360
  }>>;
@@ -368,9 +368,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
368
368
  missing: "missing";
369
369
  }>;
370
370
  coverage: z.ZodEnum<{
371
- missing: "missing";
372
371
  complete: "complete";
373
372
  partial: "partial";
373
+ missing: "missing";
374
374
  }>;
375
375
  }, z.core.$strict>;
376
376
  sevenDays: z.ZodObject<{
@@ -382,9 +382,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
382
382
  missing: "missing";
383
383
  }>;
384
384
  coverage: z.ZodEnum<{
385
- missing: "missing";
386
385
  complete: "complete";
387
386
  partial: "partial";
387
+ missing: "missing";
388
388
  }>;
389
389
  }, z.core.$strict>;
390
390
  thirtyDays: z.ZodObject<{
@@ -396,9 +396,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
396
396
  missing: "missing";
397
397
  }>;
398
398
  coverage: z.ZodEnum<{
399
- missing: "missing";
400
399
  complete: "complete";
401
400
  partial: "partial";
401
+ missing: "missing";
402
402
  }>;
403
403
  }, z.core.$strict>;
404
404
  }, z.core.$strict>;
@@ -420,12 +420,12 @@ export declare const activitySnapshotSchema: z.ZodObject<{
420
420
  }, z.core.$strict>>;
421
421
  metered: z.ZodNullable<z.ZodObject<{
422
422
  agents: z.ZodArray<z.ZodObject<{
423
- agent: z.ZodString & z.ZodType<LocalAgentFormatId, string, z.core.$ZodTypeInternals<LocalAgentFormatId, string>>;
423
+ agent: z.ZodString & z.ZodType<ActivitySnapshotAgent, string, z.core.$ZodTypeInternals<ActivitySnapshotAgent, string>>;
424
424
  billing: z.ZodLiteral<"api_key">;
425
425
  planId: z.ZodNullable<z.ZodEnum<{
426
- "claude-max-20x": "claude-max-20x";
427
- "claude-max-5x": "claude-max-5x";
428
426
  "claude-pro": "claude-pro";
427
+ "claude-max-5x": "claude-max-5x";
428
+ "claude-max-20x": "claude-max-20x";
429
429
  "chatgpt-plus": "chatgpt-plus";
430
430
  "chatgpt-pro": "chatgpt-pro";
431
431
  }>>;
@@ -440,9 +440,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
440
440
  missing: "missing";
441
441
  }>;
442
442
  coverage: z.ZodEnum<{
443
- missing: "missing";
444
443
  complete: "complete";
445
444
  partial: "partial";
445
+ missing: "missing";
446
446
  }>;
447
447
  }, z.core.$strict>;
448
448
  sevenDays: z.ZodObject<{
@@ -454,9 +454,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
454
454
  missing: "missing";
455
455
  }>;
456
456
  coverage: z.ZodEnum<{
457
- missing: "missing";
458
457
  complete: "complete";
459
458
  partial: "partial";
459
+ missing: "missing";
460
460
  }>;
461
461
  }, z.core.$strict>;
462
462
  thirtyDays: z.ZodObject<{
@@ -468,9 +468,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
468
468
  missing: "missing";
469
469
  }>;
470
470
  coverage: z.ZodEnum<{
471
- missing: "missing";
472
471
  complete: "complete";
473
472
  partial: "partial";
473
+ missing: "missing";
474
474
  }>;
475
475
  }, z.core.$strict>;
476
476
  }, z.core.$strict>;
@@ -480,13 +480,13 @@ export declare const activitySnapshotSchema: z.ZodObject<{
480
480
  recordCount: z.ZodNumber;
481
481
  basis: z.ZodLiteral<"provider_billed">;
482
482
  financialEvidence: z.ZodEnum<{
483
- verified: "verified";
484
483
  missing: "missing";
484
+ verified: "verified";
485
485
  }>;
486
486
  coverage: z.ZodEnum<{
487
- missing: "missing";
488
487
  complete: "complete";
489
488
  partial: "partial";
489
+ missing: "missing";
490
490
  }>;
491
491
  }, z.core.$strict>;
492
492
  sevenDays: z.ZodObject<{
@@ -494,13 +494,13 @@ export declare const activitySnapshotSchema: z.ZodObject<{
494
494
  recordCount: z.ZodNumber;
495
495
  basis: z.ZodLiteral<"provider_billed">;
496
496
  financialEvidence: z.ZodEnum<{
497
- verified: "verified";
498
497
  missing: "missing";
498
+ verified: "verified";
499
499
  }>;
500
500
  coverage: z.ZodEnum<{
501
- missing: "missing";
502
501
  complete: "complete";
503
502
  partial: "partial";
503
+ missing: "missing";
504
504
  }>;
505
505
  }, z.core.$strict>;
506
506
  thirtyDays: z.ZodObject<{
@@ -508,25 +508,25 @@ export declare const activitySnapshotSchema: z.ZodObject<{
508
508
  recordCount: z.ZodNumber;
509
509
  basis: z.ZodLiteral<"provider_billed">;
510
510
  financialEvidence: z.ZodEnum<{
511
- verified: "verified";
512
511
  missing: "missing";
512
+ verified: "verified";
513
513
  }>;
514
514
  coverage: z.ZodEnum<{
515
- missing: "missing";
516
515
  complete: "complete";
517
516
  partial: "partial";
517
+ missing: "missing";
518
518
  }>;
519
519
  }, z.core.$strict>;
520
520
  }, z.core.$strict>;
521
521
  }, z.core.$strict>>;
522
522
  unresolved: z.ZodNullable<z.ZodObject<{
523
523
  agents: z.ZodArray<z.ZodObject<{
524
- agent: z.ZodString & z.ZodType<LocalAgentFormatId, string, z.core.$ZodTypeInternals<LocalAgentFormatId, string>>;
524
+ agent: z.ZodString & z.ZodType<ActivitySnapshotAgent, string, z.core.$ZodTypeInternals<ActivitySnapshotAgent, string>>;
525
525
  billing: z.ZodLiteral<"unknown">;
526
526
  planId: z.ZodNullable<z.ZodEnum<{
527
- "claude-max-20x": "claude-max-20x";
528
- "claude-max-5x": "claude-max-5x";
529
527
  "claude-pro": "claude-pro";
528
+ "claude-max-5x": "claude-max-5x";
529
+ "claude-max-20x": "claude-max-20x";
530
530
  "chatgpt-plus": "chatgpt-plus";
531
531
  "chatgpt-pro": "chatgpt-pro";
532
532
  }>>;
@@ -541,9 +541,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
541
541
  missing: "missing";
542
542
  }>;
543
543
  coverage: z.ZodEnum<{
544
- missing: "missing";
545
544
  complete: "complete";
546
545
  partial: "partial";
546
+ missing: "missing";
547
547
  }>;
548
548
  }, z.core.$strict>;
549
549
  sevenDays: z.ZodObject<{
@@ -555,9 +555,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
555
555
  missing: "missing";
556
556
  }>;
557
557
  coverage: z.ZodEnum<{
558
- missing: "missing";
559
558
  complete: "complete";
560
559
  partial: "partial";
560
+ missing: "missing";
561
561
  }>;
562
562
  }, z.core.$strict>;
563
563
  thirtyDays: z.ZodObject<{
@@ -569,9 +569,9 @@ export declare const activitySnapshotSchema: z.ZodObject<{
569
569
  missing: "missing";
570
570
  }>;
571
571
  coverage: z.ZodEnum<{
572
- missing: "missing";
573
572
  complete: "complete";
574
573
  partial: "partial";
574
+ missing: "missing";
575
575
  }>;
576
576
  }, z.core.$strict>;
577
577
  }, z.core.$strict>;
@@ -586,7 +586,7 @@ export declare const activitySnapshotSchema: z.ZodObject<{
586
586
  }, z.core.$strict>>;
587
587
  coverage: z.ZodObject<{
588
588
  agents: z.ZodArray<z.ZodObject<{
589
- agent: z.ZodString & z.ZodType<LocalAgentFormatId, string, z.core.$ZodTypeInternals<LocalAgentFormatId, string>>;
589
+ agent: z.ZodString & z.ZodType<ActivitySnapshotAgent, string, z.core.$ZodTypeInternals<ActivitySnapshotAgent, string>>;
590
590
  directoryStatus: z.ZodEnum<{
591
591
  missing: "missing";
592
592
  readable: "readable";
@@ -610,11 +610,11 @@ export declare const activitySnapshotSchema: z.ZodObject<{
610
610
  }, z.core.$strict>>;
611
611
  providers: z.ZodArray<z.ZodObject<{
612
612
  provider: z.ZodEnum<{
613
- anthropic: "anthropic";
614
613
  openai: "openai";
614
+ anthropic: "anthropic";
615
615
  cursor: "cursor";
616
- other: "other";
617
616
  "github-copilot": "github-copilot";
617
+ other: "other";
618
618
  }>;
619
619
  status: z.ZodEnum<{
620
620
  error: "error";
@@ -637,10 +637,10 @@ export declare const activitySnapshotSchema: z.ZodObject<{
637
637
  recordsPriced: z.ZodNumber;
638
638
  recordsUnpriced: z.ZodNumber;
639
639
  validationStatus: z.ZodEnum<{
640
- failed: "failed";
641
640
  complete: "complete";
642
- not_checked: "not_checked";
643
641
  partial: "partial";
642
+ failed: "failed";
643
+ not_checked: "not_checked";
644
644
  }>;
645
645
  pricingAsOf: z.ZodString;
646
646
  networkUploaded: z.ZodLiteral<false>;
@@ -1,11 +1,13 @@
1
1
  import { z } from "zod";
2
2
  import { aggregateCalls, dedupeCumulativeSessionCalls } from "./localAgentLogs.js";
3
3
  import { localAgentFormatDescriptors } from "./localAgentFormats/registry.js";
4
- import { estimateTokenCostUsd, PRICING_TABLE_AS_OF } from "./modelPricing.js";
4
+ import { canPriceTokenUsageAtScope, estimateTokenCostUsd, PRICING_TABLE_AS_OF } from "./modelPricing.js";
5
5
  import { isBundledSampleUsage } from "./schema.js";
6
6
  import { sourceValidationCoverageValues } from "./sourceStatus.js";
7
7
  const DAY_MS = 24 * 60 * 60 * 1_000;
8
- export const activitySnapshotAgentValues = Object.freeze(localAgentFormatDescriptors.map((descriptor) => descriptor.id));
8
+ export const activitySnapshotAgentValues = Object.freeze(localAgentFormatDescriptors
9
+ .filter((descriptor) => descriptor.capabilities.statuslineSnapshot)
10
+ .map((descriptor) => descriptor.id));
9
11
  const activitySnapshotAgentValueSet = new Set(activitySnapshotAgentValues);
10
12
  const activitySnapshotAgentLimit = activitySnapshotAgentValues.length;
11
13
  export const activitySnapshotPlanIdValues = [
@@ -459,7 +461,12 @@ export function buildActivitySnapshot(input) {
459
461
  const horizonStartMs = asOfMs - 30 * DAY_MS;
460
462
  // Horizon filtering must precede ID conflict detection: stale history must
461
463
  // neither activate a cohort nor suppress a current row that reused an ID.
462
- const horizonRecords = input.records.filter((record) => validRecordTimestampInHorizon(record, horizonStartMs, asOfMs));
464
+ const horizonRecords = input.records.filter((record) => validRecordTimestampInHorizon(record, horizonStartMs, asOfMs) &&
465
+ // The statusline cache is a deliberately narrower contract than the full
466
+ // parser registry. Registry-native sources join only after their snapshot
467
+ // capability has its own host/UI verification.
468
+ (record.providerCostType !== "local_agent_logs" ||
469
+ record.agentId === undefined || isSnapshotAgent(record.agentId)));
463
470
  const deduplicated = deduplicateRecords(horizonRecords);
464
471
  const classified = deduplicated.records
465
472
  .map((record) => ({
@@ -468,10 +475,10 @@ export function buildActivitySnapshot(input) {
468
475
  }));
469
476
  // Keep later same-day calls available only for proportionally splitting a
470
477
  // daily aggregate at asOf; activity and limit selection remain <= asOf.
471
- const allCalls = dedupeCumulativeSessionCalls([...(input.calls ?? [])].filter((call) =>
472
- // One preceding bucket is needed to preserve the denominator when a
473
- // daily aggregate straddles the 30-day cutoff.
474
- validCallAtOrAfter(call, horizonStartMs - DAY_MS)));
478
+ const allCalls = dedupeCumulativeSessionCalls([...(input.calls ?? [])].filter((call) => isSnapshotAgent(call.agent) &&
479
+ // One preceding bucket is needed to preserve the denominator when a
480
+ // daily aggregate straddles the 30-day cutoff.
481
+ validCallAtOrAfter(call, horizonStartMs - DAY_MS)));
475
482
  const calls = allCalls.filter((call) => validCallAtOrBefore(call, asOfMs));
476
483
  const subscriptionAgents = activitySubscriptionAgents(classified, calls, allCalls, plans, scans, trustedIds, asOfMs);
477
484
  const meteredApiRecords = classified
@@ -794,10 +801,14 @@ function apiEquivalentObservations(records, calls, trustedProviderIds) {
794
801
  function allocateAggregateAmount(amountUsd, calls) {
795
802
  if (amountUsd === null)
796
803
  return calls.map(() => null);
804
+ const priceable = calls.map((call) => canPriceTokenUsageAtScope(call.model, call.usage, call.usageScope === "turn" ? "request" : "aggregate") && estimateTokenCostUsd(call.model, call.usage) !== undefined);
805
+ if (priceable.some((supported) => !supported))
806
+ return calls.map(() => null);
797
807
  const weights = calls.map((call) => estimateTokenCostUsd(call.model, call.usage) ?? 0);
798
808
  const totalWeight = weights.reduce((sum, weight) => sum + weight, 0);
799
- if (totalWeight <= 0)
800
- return calls.map(() => amountUsd / calls.length);
809
+ if (totalWeight <= 0) {
810
+ return amountUsd === 0 ? calls.map(() => 0) : calls.map(() => null);
811
+ }
801
812
  return weights.map((weight) => amountUsd * weight / totalWeight);
802
813
  }
803
814
  function observationsForWindow(observations, asOfMs, days) {