@unravel-tech/ccusage-amp 18.0.5 → 18.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 ryoppippi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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 = "@unravel-tech/ccusage-amp";
1146
- var version = "18.0.5";
1146
+ var version = "18.2.1";
1147
1147
  var description = "Usage analysis tool for Amp CLI sessions";
1148
1148
 
1149
1149
  //#endregion
@@ -8546,6 +8546,12 @@ async function prefetchAmpPricing() {
8546
8546
  //#endregion
8547
8547
  //#region src/pricing.ts
8548
8548
  const AMP_PROVIDER_PREFIXES = ["anthropic/"];
8549
+ const ZERO_MODEL_PRICING = {
8550
+ inputCostPerMToken: 0,
8551
+ cachedInputCostPerMToken: 0,
8552
+ cacheCreationCostPerMToken: 0,
8553
+ outputCostPerMToken: 0
8554
+ };
8549
8555
  function toPerMillion(value, fallback) {
8550
8556
  return (value ?? fallback ?? 0) * MILLION;
8551
8557
  }
@@ -8567,7 +8573,10 @@ var AmpPricingSource = class {
8567
8573
  const directLookup = await this.fetcher.getModelPricing(model);
8568
8574
  if (isFailure(directLookup)) throw directLookup.error;
8569
8575
  const pricing = directLookup.value;
8570
- if (pricing == null) throw new Error(`Pricing not found for model ${model}`);
8576
+ if (pricing == null) {
8577
+ logger.warn(`Pricing not found for model ${model}; defaulting to zero-cost pricing.`);
8578
+ return ZERO_MODEL_PRICING;
8579
+ }
8571
8580
  return {
8572
8581
  inputCostPerMToken: toPerMillion(pricing.input_cost_per_token),
8573
8582
  cachedInputCostPerMToken: toPerMillion(pricing.cache_read_input_token_cost, pricing.input_cost_per_token),
@@ -8636,6 +8645,20 @@ if (import.meta.vitest != null) describe("AmpPricingSource", () => {
8636
8645
  _usingCtx3.d();
8637
8646
  }
8638
8647
  });
8648
+ it("falls back to zero pricing for unknown models", async () => {
8649
+ try {
8650
+ var _usingCtx4 = _usingCtx();
8651
+ const pricing = await _usingCtx4.u(new AmpPricingSource({
8652
+ offline: true,
8653
+ offlineLoader: async () => ({})
8654
+ })).getPricing("anthropic/unknown");
8655
+ expect(pricing).toEqual(ZERO_MODEL_PRICING);
8656
+ } catch (_$1) {
8657
+ _usingCtx4.e = _$1;
8658
+ } finally {
8659
+ _usingCtx4.d();
8660
+ }
8661
+ });
8639
8662
  });
8640
8663
 
8641
8664
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unravel-tech/ccusage-amp",
3
3
  "type": "module",
4
- "version": "18.0.5",
4
+ "version": "18.2.1",
5
5
  "description": "Usage analysis tool for Amp CLI sessions",
6
6
  "author": "ryoppippi",
7
7
  "license": "MIT",
@@ -18,15 +18,12 @@
18
18
  "main": "./dist/index.js",
19
19
  "module": "./dist/index.js",
20
20
  "bin": {
21
- "ccusage-amp": "./src/index.ts"
21
+ "ccusage-amp": "./dist/index.js"
22
22
  },
23
23
  "files": [
24
24
  "dist"
25
25
  ],
26
26
  "publishConfig": {
27
- "bin": {
28
- "ccusage-amp": "./dist/index.js"
29
- },
30
27
  "access": "public"
31
28
  },
32
29
  "engines": {
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { run } from './run.ts';
4
-
5
- // eslint-disable-next-line antfu/no-top-level-await
6
- await run();