@ccusage/amp 18.0.7 → 18.0.8
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/dist/index.js +25 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1143,7 +1143,7 @@ async function executeCommand(cmd, ctx, name$1) {
|
|
|
1143
1143
|
//#endregion
|
|
1144
1144
|
//#region package.json
|
|
1145
1145
|
var name = "@ccusage/amp";
|
|
1146
|
-
var version = "18.0.
|
|
1146
|
+
var version = "18.0.8";
|
|
1147
1147
|
var description = "Usage analysis tool for Amp CLI sessions";
|
|
1148
1148
|
|
|
1149
1149
|
//#endregion
|
|
@@ -8545,6 +8545,12 @@ async function prefetchAmpPricing() {
|
|
|
8545
8545
|
//#endregion
|
|
8546
8546
|
//#region src/pricing.ts
|
|
8547
8547
|
const AMP_PROVIDER_PREFIXES = ["anthropic/"];
|
|
8548
|
+
const ZERO_MODEL_PRICING = {
|
|
8549
|
+
inputCostPerMToken: 0,
|
|
8550
|
+
cachedInputCostPerMToken: 0,
|
|
8551
|
+
cacheCreationCostPerMToken: 0,
|
|
8552
|
+
outputCostPerMToken: 0
|
|
8553
|
+
};
|
|
8548
8554
|
function toPerMillion(value, fallback) {
|
|
8549
8555
|
return (value ?? fallback ?? 0) * MILLION;
|
|
8550
8556
|
}
|
|
@@ -8566,7 +8572,10 @@ var AmpPricingSource = class {
|
|
|
8566
8572
|
const directLookup = await this.fetcher.getModelPricing(model);
|
|
8567
8573
|
if (isFailure(directLookup)) throw directLookup.error;
|
|
8568
8574
|
const pricing = directLookup.value;
|
|
8569
|
-
if (pricing == null)
|
|
8575
|
+
if (pricing == null) {
|
|
8576
|
+
logger.warn(`Pricing not found for model ${model}; defaulting to zero-cost pricing.`);
|
|
8577
|
+
return ZERO_MODEL_PRICING;
|
|
8578
|
+
}
|
|
8570
8579
|
return {
|
|
8571
8580
|
inputCostPerMToken: toPerMillion(pricing.input_cost_per_token),
|
|
8572
8581
|
cachedInputCostPerMToken: toPerMillion(pricing.cache_read_input_token_cost, pricing.input_cost_per_token),
|
|
@@ -8635,6 +8644,20 @@ if (import.meta.vitest != null) describe("AmpPricingSource", () => {
|
|
|
8635
8644
|
_usingCtx3.d();
|
|
8636
8645
|
}
|
|
8637
8646
|
});
|
|
8647
|
+
it("falls back to zero pricing for unknown models", async () => {
|
|
8648
|
+
try {
|
|
8649
|
+
var _usingCtx4 = _usingCtx();
|
|
8650
|
+
const pricing = await _usingCtx4.u(new AmpPricingSource({
|
|
8651
|
+
offline: true,
|
|
8652
|
+
offlineLoader: async () => ({})
|
|
8653
|
+
})).getPricing("anthropic/unknown");
|
|
8654
|
+
expect(pricing).toEqual(ZERO_MODEL_PRICING);
|
|
8655
|
+
} catch (_$1) {
|
|
8656
|
+
_usingCtx4.e = _$1;
|
|
8657
|
+
} finally {
|
|
8658
|
+
_usingCtx4.d();
|
|
8659
|
+
}
|
|
8660
|
+
});
|
|
8638
8661
|
});
|
|
8639
8662
|
|
|
8640
8663
|
//#endregion
|