burnoff 1.0.0 → 1.1.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.
- package/.github/workflows/burnoff-pr-gate.yml +75 -0
- package/README.md +100 -14
- package/bin/burnoff.mjs +71 -16
- package/hooks/hook-io.mjs +8 -11
- package/package.json +3 -2
- package/src/ci/ci-gate.mjs +62 -9
- package/src/ci/pr-cost.mjs +167 -14
- package/src/ci/team-digest.mjs +1 -1
- package/src/cli/audit.mjs +74 -5
- package/src/cli/doctor.mjs +22 -12
- package/src/cli/init.mjs +92 -5
- package/src/cli/startup-audit.mjs +2348 -0
- package/src/config/catalog.json +188 -45
- package/src/config/loader.mjs +85 -9
- package/src/config/paths.mjs +30 -0
- package/src/config/policy.mjs +69 -12
- package/src/config/pricing.mjs +1022 -0
- package/src/config/uncached-attribution.mjs +719 -0
- package/src/guards/loop-breaker.mjs +72 -14
- package/src/guards/post-tool-engine.mjs +33 -12
- package/src/guards/pre-tool-engine.mjs +54 -2
- package/src/guards/read-clamp.mjs +73 -59
- package/src/guards/shell-guard.mjs +45 -19
- package/src/storage/atomic-io.mjs +2 -2
- package/src/storage/file-lock.mjs +53 -9
- package/src/storage/fts5-archive.mjs +27 -12
- package/src/storage/jsonl-parser.mjs +202 -19
- package/src/storage/ledger.mjs +7 -9
- package/src/storage/sqlite-client.mjs +31 -9
package/src/config/catalog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "2026.11.15",
|
|
3
3
|
"catalogVersion": "2026-11-15",
|
|
4
|
-
"source": "
|
|
4
|
+
"source": "OpenRouter /api/v1/models (2026-11-15) & Claude Code 2.1.325 bakedCatalog",
|
|
5
5
|
"dateRead": "2026-11-15",
|
|
6
6
|
"defaultModel": "claude-sonnet-5-5",
|
|
7
7
|
"cacheWriteMultipliers": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"write1h": 2,
|
|
37
37
|
"read": 0.025
|
|
38
38
|
},
|
|
39
|
-
"source": "
|
|
39
|
+
"source": "OpenRouter /api/v1/models",
|
|
40
40
|
"sourceUrl": "https://openrouter.ai/api/v1/models",
|
|
41
41
|
"verifiedAt": "2026-11-15",
|
|
42
42
|
"dateRead": "2026-11-15",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"write1h": 2,
|
|
63
63
|
"read": 0.025
|
|
64
64
|
},
|
|
65
|
-
"source": "
|
|
65
|
+
"source": "OpenRouter /api/v1/models",
|
|
66
66
|
"sourceUrl": "https://openrouter.ai/api/v1/models",
|
|
67
67
|
"verifiedAt": "2026-11-15",
|
|
68
68
|
"dateRead": "2026-11-15",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"write1h": 2,
|
|
89
89
|
"read": 0.1
|
|
90
90
|
},
|
|
91
|
-
"source": "
|
|
91
|
+
"source": "OpenRouter /api/v1/models & Claude Code 2.1.325 bakedCatalog (tier_10_50)",
|
|
92
92
|
"dateRead": "2026-11-15",
|
|
93
93
|
"pricingCliff": null
|
|
94
94
|
},
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"write1h": 2,
|
|
113
113
|
"read": 0.05
|
|
114
114
|
},
|
|
115
|
-
"source": "
|
|
115
|
+
"source": "OpenRouter /api/v1/models",
|
|
116
116
|
"sourceUrl": "https://openrouter.ai/api/v1/models",
|
|
117
117
|
"verifiedAt": "2026-11-15",
|
|
118
118
|
"dateRead": "2026-11-15",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"write1h": 2,
|
|
139
139
|
"read": 0.05
|
|
140
140
|
},
|
|
141
|
-
"source": "
|
|
141
|
+
"source": "OpenRouter /api/v1/models",
|
|
142
142
|
"sourceUrl": "https://openrouter.ai/api/v1/models",
|
|
143
143
|
"verifiedAt": "2026-11-15",
|
|
144
144
|
"dateRead": "2026-11-15",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"write1h": 2,
|
|
165
165
|
"read": 0.1
|
|
166
166
|
},
|
|
167
|
-
"source": "
|
|
167
|
+
"source": "OpenRouter /api/v1/models & Claude Code 2.1.325 bakedCatalog (haiku_55)",
|
|
168
168
|
"dateRead": "2026-11-15",
|
|
169
169
|
"pricingCliff": {
|
|
170
170
|
"thresholdTokens": 100000,
|
|
@@ -307,13 +307,41 @@
|
|
|
307
307
|
"write1h": 2,
|
|
308
308
|
"read": 0.1
|
|
309
309
|
},
|
|
310
|
+
"rateSchedules": [
|
|
311
|
+
{
|
|
312
|
+
"id": "carbon-introductory-pre-2026-12-01",
|
|
313
|
+
"window": "introductory",
|
|
314
|
+
"effectiveFrom": "1970-01-01T00:00:00Z",
|
|
315
|
+
"effectiveUntil": "2026-11-30T23:59:59Z",
|
|
316
|
+
"ratesPer1M": {
|
|
317
|
+
"input": 2,
|
|
318
|
+
"output": 10,
|
|
319
|
+
"write5m": 2,
|
|
320
|
+
"write1h": 2,
|
|
321
|
+
"read": 0.1
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"id": "carbon-standard-from-2026-12-01",
|
|
326
|
+
"window": "post_introductory",
|
|
327
|
+
"effectiveFrom": "2026-12-01T00:00:00Z",
|
|
328
|
+
"effectiveUntil": null,
|
|
329
|
+
"ratesPer1M": {
|
|
330
|
+
"input": 4,
|
|
331
|
+
"output": 20,
|
|
332
|
+
"write5m": 4,
|
|
333
|
+
"write1h": 4,
|
|
334
|
+
"read": 0.2
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
],
|
|
310
338
|
"multipliers": {
|
|
311
339
|
"write5m": 1,
|
|
312
340
|
"write1h": 1,
|
|
313
341
|
"read": 0.05
|
|
314
342
|
},
|
|
315
343
|
"source": "config/modelCatalog.json",
|
|
316
|
-
"dateRead": "2026-11-
|
|
344
|
+
"dateRead": "2026-11-27",
|
|
317
345
|
"pricingCliff": null
|
|
318
346
|
},
|
|
319
347
|
"gemini-4-argon": {
|
|
@@ -325,19 +353,47 @@
|
|
|
325
353
|
"contextCeiling": 1048576,
|
|
326
354
|
"operationalSoftCeiling": 200000,
|
|
327
355
|
"ratesPer1M": {
|
|
328
|
-
"input":
|
|
329
|
-
"output":
|
|
330
|
-
"write5m":
|
|
331
|
-
"write1h":
|
|
332
|
-
"read": 0.
|
|
356
|
+
"input": 2,
|
|
357
|
+
"output": 10,
|
|
358
|
+
"write5m": 2,
|
|
359
|
+
"write1h": 2,
|
|
360
|
+
"read": 0.1
|
|
333
361
|
},
|
|
362
|
+
"rateSchedules": [
|
|
363
|
+
{
|
|
364
|
+
"id": "argon-introductory-pre-2026-12-01",
|
|
365
|
+
"window": "introductory",
|
|
366
|
+
"effectiveFrom": "1970-01-01T00:00:00Z",
|
|
367
|
+
"effectiveUntil": "2026-11-30T23:59:59Z",
|
|
368
|
+
"ratesPer1M": {
|
|
369
|
+
"input": 2,
|
|
370
|
+
"output": 10,
|
|
371
|
+
"write5m": 2,
|
|
372
|
+
"write1h": 2,
|
|
373
|
+
"read": 0.1
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"id": "argon-standard-from-2026-12-01",
|
|
378
|
+
"window": "post_introductory",
|
|
379
|
+
"effectiveFrom": "2026-12-01T00:00:00Z",
|
|
380
|
+
"effectiveUntil": null,
|
|
381
|
+
"ratesPer1M": {
|
|
382
|
+
"input": 4,
|
|
383
|
+
"output": 20,
|
|
384
|
+
"write5m": 4,
|
|
385
|
+
"write1h": 4,
|
|
386
|
+
"read": 0.2
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
],
|
|
334
390
|
"multipliers": {
|
|
335
391
|
"write5m": 1,
|
|
336
392
|
"write1h": 1,
|
|
337
393
|
"read": 0.05
|
|
338
394
|
},
|
|
339
395
|
"source": "config/modelCatalog.json",
|
|
340
|
-
"dateRead": "2026-11-
|
|
396
|
+
"dateRead": "2026-11-27",
|
|
341
397
|
"pricingCliff": null
|
|
342
398
|
},
|
|
343
399
|
"gemini-4-neon": {
|
|
@@ -349,11 +405,11 @@
|
|
|
349
405
|
"contextCeiling": 1048576,
|
|
350
406
|
"operationalSoftCeiling": 200000,
|
|
351
407
|
"ratesPer1M": {
|
|
352
|
-
"input":
|
|
353
|
-
"output":
|
|
354
|
-
"write5m":
|
|
355
|
-
"write1h":
|
|
356
|
-
"read": 0.
|
|
408
|
+
"input": 3,
|
|
409
|
+
"output": 15,
|
|
410
|
+
"write5m": 3,
|
|
411
|
+
"write1h": 3,
|
|
412
|
+
"read": 0.15
|
|
357
413
|
},
|
|
358
414
|
"multipliers": {
|
|
359
415
|
"write5m": 1,
|
|
@@ -361,7 +417,7 @@
|
|
|
361
417
|
"read": 0.05
|
|
362
418
|
},
|
|
363
419
|
"source": "config/modelCatalog.json",
|
|
364
|
-
"dateRead": "2026-11-
|
|
420
|
+
"dateRead": "2026-11-27",
|
|
365
421
|
"pricingCliff": null
|
|
366
422
|
},
|
|
367
423
|
"gemini-4-hydrogen": {
|
|
@@ -370,14 +426,19 @@
|
|
|
370
426
|
"shortLabel": "Hydrogen",
|
|
371
427
|
"family": "hydrogen",
|
|
372
428
|
"generation": "4",
|
|
429
|
+
"aliases": [
|
|
430
|
+
"gemini-4-hydrogen-tiered-high",
|
|
431
|
+
"gemini-4-hydrogen-tiered-medium",
|
|
432
|
+
"gemini-4-hydrogen-tiered-low"
|
|
433
|
+
],
|
|
373
434
|
"contextCeiling": 1048576,
|
|
374
435
|
"operationalSoftCeiling": 200000,
|
|
375
436
|
"ratesPer1M": {
|
|
376
|
-
"input":
|
|
377
|
-
"output":
|
|
378
|
-
"write5m":
|
|
379
|
-
"write1h":
|
|
380
|
-
"read": 0.
|
|
437
|
+
"input": 1.5,
|
|
438
|
+
"output": 7.5,
|
|
439
|
+
"write5m": 1.5,
|
|
440
|
+
"write1h": 1.5,
|
|
441
|
+
"read": 0.075
|
|
381
442
|
},
|
|
382
443
|
"multipliers": {
|
|
383
444
|
"write5m": 1,
|
|
@@ -385,7 +446,7 @@
|
|
|
385
446
|
"read": 0.05
|
|
386
447
|
},
|
|
387
448
|
"source": "config/modelCatalog.json",
|
|
388
|
-
"dateRead": "2026-11-
|
|
449
|
+
"dateRead": "2026-11-27",
|
|
389
450
|
"pricingCliff": null
|
|
390
451
|
},
|
|
391
452
|
"gemini-3-8-flash": {
|
|
@@ -397,19 +458,47 @@
|
|
|
397
458
|
"contextCeiling": 1000000,
|
|
398
459
|
"operationalSoftCeiling": 200000,
|
|
399
460
|
"ratesPer1M": {
|
|
400
|
-
"input": 0.
|
|
401
|
-
"output":
|
|
402
|
-
"write5m": 0.
|
|
403
|
-
"write1h": 0.
|
|
404
|
-
"read": 0.
|
|
405
|
-
},
|
|
461
|
+
"input": 0.75,
|
|
462
|
+
"output": 3.75,
|
|
463
|
+
"write5m": 0.75,
|
|
464
|
+
"write1h": 0.75,
|
|
465
|
+
"read": 0.075
|
|
466
|
+
},
|
|
467
|
+
"rateSchedules": [
|
|
468
|
+
{
|
|
469
|
+
"id": "flash-38-pre-2027-01-01",
|
|
470
|
+
"window": "introductory",
|
|
471
|
+
"effectiveFrom": "1970-01-01T00:00:00Z",
|
|
472
|
+
"effectiveUntil": "2026-12-31T23:59:59Z",
|
|
473
|
+
"ratesPer1M": {
|
|
474
|
+
"input": 0.75,
|
|
475
|
+
"output": 3.75,
|
|
476
|
+
"write5m": 0.75,
|
|
477
|
+
"write1h": 0.75,
|
|
478
|
+
"read": 0.075
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"id": "flash-38-from-2027-01-01",
|
|
483
|
+
"window": "post_introductory",
|
|
484
|
+
"effectiveFrom": "2027-01-01T00:00:00Z",
|
|
485
|
+
"effectiveUntil": null,
|
|
486
|
+
"ratesPer1M": {
|
|
487
|
+
"input": 1.5,
|
|
488
|
+
"output": 7.5,
|
|
489
|
+
"write5m": 1.5,
|
|
490
|
+
"write1h": 1.5,
|
|
491
|
+
"read": 0.15
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
],
|
|
406
495
|
"multipliers": {
|
|
407
496
|
"write5m": 1,
|
|
408
497
|
"write1h": 1,
|
|
409
498
|
"read": 0.1
|
|
410
499
|
},
|
|
411
500
|
"source": "config/modelCatalog.json",
|
|
412
|
-
"dateRead": "2026-11-
|
|
501
|
+
"dateRead": "2026-11-27",
|
|
413
502
|
"pricingCliff": null
|
|
414
503
|
},
|
|
415
504
|
"claude-opus-5": {
|
|
@@ -432,7 +521,7 @@
|
|
|
432
521
|
"write1h": 2,
|
|
433
522
|
"read": 0.1
|
|
434
523
|
},
|
|
435
|
-
"source": "
|
|
524
|
+
"source": "OpenRouter /api/v1/models",
|
|
436
525
|
"dateRead": "2026-11-15",
|
|
437
526
|
"pricingCliff": null
|
|
438
527
|
},
|
|
@@ -456,7 +545,7 @@
|
|
|
456
545
|
"write1h": 2,
|
|
457
546
|
"read": 0.1
|
|
458
547
|
},
|
|
459
|
-
"source": "
|
|
548
|
+
"source": "OpenRouter /api/v1/models",
|
|
460
549
|
"dateRead": "2026-11-15",
|
|
461
550
|
"pricingCliff": null
|
|
462
551
|
},
|
|
@@ -480,7 +569,7 @@
|
|
|
480
569
|
"write1h": 2,
|
|
481
570
|
"read": 0.1
|
|
482
571
|
},
|
|
483
|
-
"source": "
|
|
572
|
+
"source": "OpenRouter /api/v1/models",
|
|
484
573
|
"dateRead": "2026-11-15",
|
|
485
574
|
"pricingCliff": {
|
|
486
575
|
"thresholdTokens": 200000,
|
|
@@ -517,7 +606,7 @@
|
|
|
517
606
|
"write1h": 2,
|
|
518
607
|
"read": 0.1
|
|
519
608
|
},
|
|
520
|
-
"source": "
|
|
609
|
+
"source": "OpenRouter /api/v1/models",
|
|
521
610
|
"dateRead": "2026-11-15",
|
|
522
611
|
"pricingCliff": {
|
|
523
612
|
"thresholdTokens": 200000,
|
|
@@ -554,9 +643,22 @@
|
|
|
554
643
|
"write1h": 2,
|
|
555
644
|
"read": 0.1
|
|
556
645
|
},
|
|
557
|
-
"source": "
|
|
646
|
+
"source": "OpenRouter /api/v1/models",
|
|
558
647
|
"dateRead": "2026-11-15",
|
|
559
|
-
"pricingCliff":
|
|
648
|
+
"pricingCliff": {
|
|
649
|
+
"thresholdTokens": 200000,
|
|
650
|
+
"preCliffWarningTokens": 180000,
|
|
651
|
+
"multiplier": 2,
|
|
652
|
+
"cachedReadMultiplier": 2,
|
|
653
|
+
"outputMultiplier": 1.5,
|
|
654
|
+
"ratesPer1MAboveCliff": {
|
|
655
|
+
"input": 10,
|
|
656
|
+
"output": 37.5,
|
|
657
|
+
"write5m": 12.5,
|
|
658
|
+
"write1h": 20,
|
|
659
|
+
"read": 1
|
|
660
|
+
}
|
|
661
|
+
}
|
|
560
662
|
},
|
|
561
663
|
"claude-opus-4-5": {
|
|
562
664
|
"id": "claude-opus-4-5",
|
|
@@ -578,7 +680,7 @@
|
|
|
578
680
|
"write1h": 2,
|
|
579
681
|
"read": 0.1
|
|
580
682
|
},
|
|
581
|
-
"source": "
|
|
683
|
+
"source": "OpenRouter /api/v1/models",
|
|
582
684
|
"dateRead": "2026-11-15",
|
|
583
685
|
"pricingCliff": null
|
|
584
686
|
},
|
|
@@ -602,7 +704,7 @@
|
|
|
602
704
|
"write1h": 2,
|
|
603
705
|
"read": 0.1
|
|
604
706
|
},
|
|
605
|
-
"source": "
|
|
707
|
+
"source": "OpenRouter /api/v1/models",
|
|
606
708
|
"dateRead": "2026-11-15",
|
|
607
709
|
"pricingCliff": null
|
|
608
710
|
},
|
|
@@ -650,9 +752,22 @@
|
|
|
650
752
|
"write1h": 2,
|
|
651
753
|
"read": 0.1
|
|
652
754
|
},
|
|
653
|
-
"source": "
|
|
755
|
+
"source": "OpenRouter /api/v1/models",
|
|
654
756
|
"dateRead": "2026-11-15",
|
|
655
|
-
"pricingCliff":
|
|
757
|
+
"pricingCliff": {
|
|
758
|
+
"thresholdTokens": 200000,
|
|
759
|
+
"preCliffWarningTokens": 180000,
|
|
760
|
+
"multiplier": 2,
|
|
761
|
+
"cachedReadMultiplier": 2,
|
|
762
|
+
"outputMultiplier": 1.5,
|
|
763
|
+
"ratesPer1MAboveCliff": {
|
|
764
|
+
"input": 6,
|
|
765
|
+
"output": 22.5,
|
|
766
|
+
"write5m": 7.5,
|
|
767
|
+
"write1h": 12,
|
|
768
|
+
"read": 0.6
|
|
769
|
+
}
|
|
770
|
+
}
|
|
656
771
|
},
|
|
657
772
|
"claude-sonnet-4-5": {
|
|
658
773
|
"id": "claude-sonnet-4-5",
|
|
@@ -674,7 +789,7 @@
|
|
|
674
789
|
"write1h": 2,
|
|
675
790
|
"read": 0.1
|
|
676
791
|
},
|
|
677
|
-
"source": "
|
|
792
|
+
"source": "OpenRouter /api/v1/models",
|
|
678
793
|
"dateRead": "2026-11-15",
|
|
679
794
|
"pricingCliff": null
|
|
680
795
|
},
|
|
@@ -722,7 +837,7 @@
|
|
|
722
837
|
"write1h": 2,
|
|
723
838
|
"read": 0.1
|
|
724
839
|
},
|
|
725
|
-
"source": "
|
|
840
|
+
"source": "OpenRouter /api/v1/models",
|
|
726
841
|
"dateRead": "2026-11-15",
|
|
727
842
|
"pricingCliff": null
|
|
728
843
|
},
|
|
@@ -869,6 +984,34 @@
|
|
|
869
984
|
"source": "Claude Code 2.1.325 bakedCatalog (tier_8_40_cache_read_0_20; OpenRouter price unverified)",
|
|
870
985
|
"dateRead": "2026-11-15",
|
|
871
986
|
"pricingCliff": null
|
|
987
|
+
},
|
|
988
|
+
"gpt-6-1-sol": {
|
|
989
|
+
"id": "gpt-6-1-sol",
|
|
990
|
+
"label": "GPT-6.1 Sol",
|
|
991
|
+
"shortLabel": "GPT-6.1 Sol",
|
|
992
|
+
"family": "openai-gpt6",
|
|
993
|
+
"generation": "6.1",
|
|
994
|
+
"aliases": [
|
|
995
|
+
"gpt-6.1-sol",
|
|
996
|
+
"openai/gpt-6.1-sol"
|
|
997
|
+
],
|
|
998
|
+
"contextCeiling": 1048576,
|
|
999
|
+
"operationalSoftCeiling": 200000,
|
|
1000
|
+
"ratesPer1M": {
|
|
1001
|
+
"input": 3,
|
|
1002
|
+
"output": 15,
|
|
1003
|
+
"write5m": 3.75,
|
|
1004
|
+
"write1h": 3.75,
|
|
1005
|
+
"read": 0.15
|
|
1006
|
+
},
|
|
1007
|
+
"multipliers": {
|
|
1008
|
+
"write5m": 1.25,
|
|
1009
|
+
"write1h": 1.25,
|
|
1010
|
+
"read": 0.05
|
|
1011
|
+
},
|
|
1012
|
+
"source": "config/modelCatalog.json",
|
|
1013
|
+
"dateRead": "2026-11-27",
|
|
1014
|
+
"pricingCliff": null
|
|
872
1015
|
}
|
|
873
1016
|
}
|
|
874
1017
|
}
|
package/src/config/loader.mjs
CHANGED
|
@@ -4,18 +4,23 @@ import { getHomeDir } from './paths.mjs';
|
|
|
4
4
|
|
|
5
5
|
const CATALOG_URL = new URL('./catalog.json', import.meta.url);
|
|
6
6
|
let cachedBaseCatalog = null;
|
|
7
|
+
const customCeilingsCache = new Map();
|
|
8
|
+
const CUSTOM_CEILINGS_TTL_MS = 500;
|
|
7
9
|
|
|
8
10
|
export const UNKNOWN_MODEL_ID = 'unknown';
|
|
9
11
|
|
|
10
12
|
export function loadModelCatalog(options = {}) {
|
|
11
13
|
if (!cachedBaseCatalog) {
|
|
12
14
|
const raw = fs.readFileSync(CATALOG_URL, 'utf8');
|
|
13
|
-
cachedBaseCatalog = JSON.parse(raw);
|
|
15
|
+
cachedBaseCatalog = Object.freeze(JSON.parse(raw));
|
|
14
16
|
}
|
|
15
|
-
const cloned = JSON.parse(JSON.stringify(cachedBaseCatalog));
|
|
16
17
|
const customCeilings = options.customCeilings !== undefined
|
|
17
18
|
? options.customCeilings
|
|
18
19
|
: loadCustomCeilings(options);
|
|
20
|
+
if (!customCeilings || typeof customCeilings !== 'object') {
|
|
21
|
+
return cachedBaseCatalog;
|
|
22
|
+
}
|
|
23
|
+
const cloned = JSON.parse(JSON.stringify(cachedBaseCatalog));
|
|
19
24
|
return applyCeilingOverrides(cloned, customCeilings);
|
|
20
25
|
}
|
|
21
26
|
|
|
@@ -75,6 +80,7 @@ function canonicalizeModelToken(rawModelId = '') {
|
|
|
75
80
|
.replace(/\./g, '-')
|
|
76
81
|
.replace(/-v\d+(?::\d+)?$/i, '')
|
|
77
82
|
.replace(/[@-]\d{8}$/i, '')
|
|
83
|
+
.replace(/-tiered-(?:xhigh|extra-high|high|medium|med|low)$/i, '')
|
|
78
84
|
.replace(/-(?:thinking|fast|latest|xhigh|extra-high|high|medium|med|low)$/i, '');
|
|
79
85
|
|
|
80
86
|
const altOrder = s.match(/^claude-([4-9]\d*-\d+)-(opus|sonnet|haiku|fable|mythos)$/);
|
|
@@ -101,35 +107,49 @@ export function loadCustomCeilings(options = {}) {
|
|
|
101
107
|
return options.customCeilings;
|
|
102
108
|
}
|
|
103
109
|
|
|
110
|
+
const cwd = options.cwd || process.cwd();
|
|
111
|
+
const homeDir = options.homeDir || getHomeDir();
|
|
112
|
+
const explicitPath = typeof options.customCeilingsPath === 'string' ? options.customCeilingsPath.trim() : '';
|
|
113
|
+
const cacheKey = `${cwd}|${homeDir}|${explicitPath}`;
|
|
114
|
+
const nowMs = Date.now();
|
|
115
|
+
const cached = customCeilingsCache.get(cacheKey);
|
|
116
|
+
if (cached && nowMs - cached.ts < CUSTOM_CEILINGS_TTL_MS) {
|
|
117
|
+
return cached.value;
|
|
118
|
+
}
|
|
119
|
+
|
|
104
120
|
const candidatePaths = [];
|
|
105
|
-
if (
|
|
106
|
-
candidatePaths.push(
|
|
121
|
+
if (explicitPath) {
|
|
122
|
+
candidatePaths.push(explicitPath);
|
|
107
123
|
}
|
|
108
124
|
|
|
109
|
-
const cwd = options.cwd || process.cwd();
|
|
110
125
|
if (cwd && cwd !== '.') {
|
|
111
126
|
candidatePaths.push(path.join(cwd, '.claude', 'burnoff', 'customCeilings.json'));
|
|
112
127
|
candidatePaths.push(path.join(cwd, 'customCeilings.json'));
|
|
113
128
|
candidatePaths.push(path.join(cwd, '.claude', 'customCeilings.json'));
|
|
114
129
|
}
|
|
115
130
|
|
|
116
|
-
const homeDir = options.homeDir || getHomeDir();
|
|
117
131
|
if (homeDir) {
|
|
118
132
|
candidatePaths.push(path.join(homeDir, '.burnoff', 'customCeilings.json'));
|
|
119
133
|
candidatePaths.push(path.join(homeDir, '.claude', 'customCeilings.json'));
|
|
120
134
|
}
|
|
121
135
|
|
|
136
|
+
let resolved = null;
|
|
122
137
|
for (const candidate of candidatePaths) {
|
|
123
138
|
try {
|
|
124
139
|
if (fs.existsSync(candidate)) {
|
|
125
140
|
const parsed = JSON.parse(fs.readFileSync(candidate, 'utf8'));
|
|
126
|
-
if (parsed && typeof parsed === 'object')
|
|
141
|
+
if (parsed && typeof parsed === 'object') {
|
|
142
|
+
resolved = parsed;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
127
145
|
}
|
|
128
146
|
} catch {
|
|
129
147
|
// ignore: invalid customCeilings override falls back cleanly
|
|
130
148
|
}
|
|
131
149
|
}
|
|
132
|
-
|
|
150
|
+
if (customCeilingsCache.size > 64) customCeilingsCache.clear();
|
|
151
|
+
customCeilingsCache.set(cacheKey, { ts: nowMs, value: resolved });
|
|
152
|
+
return resolved;
|
|
133
153
|
}
|
|
134
154
|
|
|
135
155
|
export function isKnownCatalogModel(rawModelId = '', options = {}) {
|
|
@@ -444,6 +464,41 @@ export function computeTotalPromptTokens(usage = {}) {
|
|
|
444
464
|
return Math.max(computedPromptTokens, explicitSingleTurnTotal);
|
|
445
465
|
}
|
|
446
466
|
|
|
467
|
+
function parseScheduleTimestampMs(rawTs) {
|
|
468
|
+
if (typeof rawTs === 'number' && Number.isFinite(rawTs)) {
|
|
469
|
+
return rawTs > 0 && rawTs < 1e12 ? rawTs * 1000 : rawTs;
|
|
470
|
+
}
|
|
471
|
+
if (rawTs instanceof Date) {
|
|
472
|
+
const ms = rawTs.getTime();
|
|
473
|
+
return Number.isFinite(ms) ? ms : Date.now();
|
|
474
|
+
}
|
|
475
|
+
if (typeof rawTs === 'string' && rawTs.trim()) {
|
|
476
|
+
const parsed = Date.parse(rawTs.trim());
|
|
477
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
478
|
+
}
|
|
479
|
+
return Date.now();
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function isWithinRateSchedule(tsMs, sched) {
|
|
483
|
+
if (!sched || typeof sched !== 'object') return false;
|
|
484
|
+
if (sched.effectiveFrom) {
|
|
485
|
+
const fromMs = Date.parse(sched.effectiveFrom);
|
|
486
|
+
if (Number.isFinite(fromMs) && tsMs < fromMs) return false;
|
|
487
|
+
}
|
|
488
|
+
if (sched.effectiveUntil) {
|
|
489
|
+
const untilStr = String(sched.effectiveUntil).trim();
|
|
490
|
+
const untilMs = Date.parse(untilStr);
|
|
491
|
+
if (Number.isFinite(untilMs)) {
|
|
492
|
+
if (untilStr.endsWith('00:00:00Z')) {
|
|
493
|
+
if (tsMs >= untilMs) return false;
|
|
494
|
+
} else if (tsMs > untilMs + 999) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
501
|
+
|
|
447
502
|
export function resolveEffectiveRates(modelId = 'claude-sonnet-5-5', totalPromptTokens = 0, options = {}) {
|
|
448
503
|
const spec = getModelSpec(modelId, options);
|
|
449
504
|
const promptTokens = Math.max(0, Number(totalPromptTokens || 0));
|
|
@@ -453,6 +508,9 @@ export function resolveEffectiveRates(modelId = 'claude-sonnet-5-5', totalPrompt
|
|
|
453
508
|
modelId: UNKNOWN_MODEL_ID,
|
|
454
509
|
rawModelId: spec.rawModelId || String(modelId || '').trim(),
|
|
455
510
|
unknownModel: true,
|
|
511
|
+
unmappedModel: true,
|
|
512
|
+
unmapped_model: true,
|
|
513
|
+
cachedReadWeight: 0.05,
|
|
456
514
|
label: spec.label,
|
|
457
515
|
shortLabel: spec.shortLabel || 'Unknown Model',
|
|
458
516
|
family: 'unknown',
|
|
@@ -474,6 +532,21 @@ export function resolveEffectiveRates(modelId = 'claude-sonnet-5-5', totalPrompt
|
|
|
474
532
|
};
|
|
475
533
|
}
|
|
476
534
|
|
|
535
|
+
let baseRates = spec.ratesPer1M;
|
|
536
|
+
let scheduleWindow = 'standard';
|
|
537
|
+
if (Array.isArray(spec.rateSchedules) && spec.rateSchedules.length > 0) {
|
|
538
|
+
const tsMs = parseScheduleTimestampMs(
|
|
539
|
+
options.eventTimestampUtc ?? options.timestampMs ?? options.timestamp ?? null
|
|
540
|
+
);
|
|
541
|
+
const matched =
|
|
542
|
+
spec.rateSchedules.find((s) => isWithinRateSchedule(tsMs, s)) ||
|
|
543
|
+
spec.rateSchedules[spec.rateSchedules.length - 1];
|
|
544
|
+
if (matched?.ratesPer1M) {
|
|
545
|
+
baseRates = matched.ratesPer1M;
|
|
546
|
+
scheduleWindow = matched.window || 'standard';
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
477
550
|
const cliff = spec.pricingCliff || null;
|
|
478
551
|
const cliffTriggered = Boolean(cliff && promptTokens > cliff.thresholdTokens);
|
|
479
552
|
const preCliffWarningTriggered = Boolean(
|
|
@@ -482,14 +555,17 @@ export function resolveEffectiveRates(modelId = 'claude-sonnet-5-5', totalPrompt
|
|
|
482
555
|
|
|
483
556
|
const activeRates = cliffTriggered && cliff.ratesPer1MAboveCliff
|
|
484
557
|
? cliff.ratesPer1MAboveCliff
|
|
485
|
-
:
|
|
558
|
+
: baseRates;
|
|
486
559
|
|
|
487
560
|
return {
|
|
488
561
|
modelId: spec.id,
|
|
489
562
|
unknownModel: false,
|
|
563
|
+
unmappedModel: false,
|
|
564
|
+
unmapped_model: false,
|
|
490
565
|
label: spec.label,
|
|
491
566
|
shortLabel: spec.shortLabel || spec.label,
|
|
492
567
|
family: spec.family,
|
|
568
|
+
pricingWindow: cliffTriggered ? 'above_cliff' : scheduleWindow,
|
|
493
569
|
contextCeiling: spec.contextCeiling,
|
|
494
570
|
operationalSoftCeiling: spec.operationalSoftCeiling,
|
|
495
571
|
inputPer1M: activeRates.input,
|
package/src/config/paths.mjs
CHANGED
|
@@ -120,6 +120,35 @@ export function getClaudeProjectsDir(homeDirOverride = null) {
|
|
|
120
120
|
return path.join(home, '.claude', 'projects');
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Resolves Claude Code configuration, rules, MCP, and transcript paths for a workspace.
|
|
125
|
+
*/
|
|
126
|
+
export function resolveClaudeConfigPaths({
|
|
127
|
+
homeDir = getHomeDir(),
|
|
128
|
+
cwd = process.cwd(),
|
|
129
|
+
platform = process.platform
|
|
130
|
+
} = {}) {
|
|
131
|
+
const resolvedHome = homeDir || getHomeDir();
|
|
132
|
+
const resolvedCwd = path.resolve(cwd || process.cwd());
|
|
133
|
+
return {
|
|
134
|
+
homeDir: resolvedHome,
|
|
135
|
+
cwd: resolvedCwd,
|
|
136
|
+
platform,
|
|
137
|
+
claudeJson: path.join(resolvedHome, '.claude.json'),
|
|
138
|
+
userSettings: path.join(resolvedHome, '.claude', 'settings.json'),
|
|
139
|
+
projectSettings: path.join(resolvedCwd, '.claude', 'settings.json'),
|
|
140
|
+
projectLocalSettings: path.join(resolvedCwd, '.claude', 'settings.local.json'),
|
|
141
|
+
projectMcpJson: path.join(resolvedCwd, '.mcp.json'),
|
|
142
|
+
projectsDir: path.join(resolvedHome, '.claude', 'projects'),
|
|
143
|
+
rulesFiles: [
|
|
144
|
+
path.join(resolvedHome, '.claude', 'CLAUDE.md'),
|
|
145
|
+
path.join(resolvedCwd, 'CLAUDE.md'),
|
|
146
|
+
path.join(resolvedCwd, '.claude', 'CLAUDE.md'),
|
|
147
|
+
path.join(resolvedCwd, 'AGENTS.md')
|
|
148
|
+
]
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
123
152
|
export function ensureDirSync(dirPath, mode = 0o700) {
|
|
124
153
|
if (!dirPath) return '';
|
|
125
154
|
const resolved = path.resolve(dirPath);
|
|
@@ -190,6 +219,7 @@ export default {
|
|
|
190
219
|
getBurnoffLedgerDir,
|
|
191
220
|
getBurnoffRunDir,
|
|
192
221
|
getClaudeProjectsDir,
|
|
222
|
+
resolveClaudeConfigPaths,
|
|
193
223
|
ensureDirSync,
|
|
194
224
|
formatNodeUpgradeHint,
|
|
195
225
|
ensureSupportedNodeVersion
|