ccusage 0.8.0 → 9.0.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.
Files changed (37) hide show
  1. package/README.md +41 -6
  2. package/dist/calculate-cost.d.ts +2 -2
  3. package/dist/chunk-BLXvPPr8.js +30 -0
  4. package/dist/{data-loader-Bz6Vemxw.js → data-loader-CotJGlGF.js} +235 -294
  5. package/dist/{data-loader-amTZCtBR.d.ts → data-loader-OGaMjZTD.d.ts} +8 -80
  6. package/dist/data-loader.d.ts +3 -3
  7. package/dist/data-loader.js +5 -5
  8. package/dist/{debug-DQXeZIjf.js → debug-DH_5GWYh.js} +5 -4
  9. package/dist/debug.js +5 -5
  10. package/dist/{dist-DAarI-SJ.js → dist-BZzwBtZs.js} +1 -1
  11. package/dist/{effect-WSjEuzC9-ChJ5OQQf.js → effect-WSjEuzC9-DHMVzzyB.js} +1 -1
  12. package/dist/{esm-Dqsc1zmX.js → esm-BU3FhOe-.js} +1 -1
  13. package/dist/{index-CISmcbXk-x9eVmhGM.js → index-CISmcbXk-CW1Gj6Ab.js} +5 -5
  14. package/dist/index.js +199 -1760
  15. package/dist/{logger-DN-RT9jL.js → logger-BgKOQAEs.js} +3 -3
  16. package/dist/logger.js +1 -1
  17. package/dist/{mcp-DZXbfmbs.js → mcp-BUmEAQZm.js} +42 -50
  18. package/dist/mcp.d.ts +2 -2
  19. package/dist/mcp.js +7 -7
  20. package/dist/pricing-fetcher-1KHPTXC3.js +205 -0
  21. package/dist/{pricing-fetcher-Dq-OLBp4.d.ts → pricing-fetcher-BkSZh4lR.d.ts} +83 -3
  22. package/dist/pricing-fetcher.d.ts +2 -2
  23. package/dist/pricing-fetcher.js +3 -3
  24. package/dist/{sury-DmrZ3_Oj-l0qqtY-f.js → sury-DmrZ3_Oj-Cpjsc2Lm.js} +1 -1
  25. package/dist/utils.table-DRzF8vZJ.js +1838 -0
  26. package/dist/utils.table.d.ts +24 -0
  27. package/dist/utils.table.js +3 -0
  28. package/dist/valibot-CQk-M5rL-BcaCeUrF.js +10 -0
  29. package/dist/{zod-Db63SLXj-N1oN-yiY.js → zod-Db63SLXj-BIXn64AP.js} +3 -3
  30. package/package.json +2 -1
  31. package/dist/pricing-fetcher-DMNBE90M.js +0 -79
  32. package/dist/valibot-CQk-M5rL-BNHzwpA0.js +0 -10
  33. /package/dist/{arktype-C-GObzDh-Bx7Fdrqj.js → arktype-C-GObzDh-CNoBqQrr.js} +0 -0
  34. /package/dist/{core-B0ovMhJe.js → core-DHCbAXJf.js} +0 -0
  35. /package/dist/{dist-BEQ1tJCL.js → dist-DCvt9hEv.js} +0 -0
  36. /package/dist/{prompt-CUbwSrjo.js → prompt-DtZgx4wU.js} +0 -0
  37. /package/dist/{types-DS8M8QF_.js → types-BlyCnKwN.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { sep } from "node:path";
2
- import { formatWithOptions } from "node:util";
3
2
  import process$1 from "node:process";
3
+ import { formatWithOptions } from "node:util";
4
4
  import * as tty from "node:tty";
5
5
 
6
6
  //#region node_modules/consola/dist/core.mjs
@@ -949,7 +949,7 @@ function createConsola$1(options = {}) {
949
949
  defaults: { level },
950
950
  stdout: process.stdout,
951
951
  stderr: process.stderr,
952
- prompt: (...args) => import("./prompt-CUbwSrjo.js").then((m) => m.prompt(...args)),
952
+ prompt: (...args) => import("./prompt-DtZgx4wU.js").then((m) => m.prompt(...args)),
953
953
  reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
954
954
  ...options
955
955
  });
@@ -965,7 +965,7 @@ const consola = createConsola$1();
965
965
  //#endregion
966
966
  //#region package.json
967
967
  var name = "ccusage";
968
- var version = "0.8.0";
968
+ var version = "9.0.1";
969
969
  var description = "Usage analysis tool for Claude Code";
970
970
 
971
971
  //#endregion
package/dist/logger.js CHANGED
@@ -1,3 +1,3 @@
1
- import { log, logger } from "./logger-DN-RT9jL.js";
1
+ import { log, logger } from "./logger-BgKOQAEs.js";
2
2
 
3
3
  export { log, logger };
@@ -1,8 +1,10 @@
1
- import { __commonJS, __require, __toESM, getDefaultClaudePath, loadDailyUsageData, loadSessionData } from "./data-loader-Bz6Vemxw.js";
2
- import { description, literal, object, optional, pipe, regex, string, union } from "./dist-BEQ1tJCL.js";
3
- import { name, version } from "./logger-DN-RT9jL.js";
4
- import { anyType, arrayType, booleanType, discriminatedUnionType, enumType, literalType, numberType, objectType, optionalType, recordType, stringType, unionType, unknownType } from "./types-DS8M8QF_.js";
5
- import { toJsonSchema } from "./index-CISmcbXk-x9eVmhGM.js";
1
+ import { __commonJS, __require, __toESM } from "./chunk-BLXvPPr8.js";
2
+ import { getDefaultClaudePath, loadDailyUsageData, loadSessionData } from "./data-loader-CotJGlGF.js";
3
+ import { description, literal, object, optional, pipe, union } from "./dist-DCvt9hEv.js";
4
+ import { name, version } from "./logger-BgKOQAEs.js";
5
+ import { CostModes, dateSchema } from "./pricing-fetcher-1KHPTXC3.js";
6
+ import { anyType, arrayType, booleanType, discriminatedUnionType, enumType, literalType, numberType, objectType, optionalType, recordType, stringType, unionType, unknownType } from "./types-BlyCnKwN.js";
7
+ import { toJsonSchema } from "./index-CISmcbXk-CW1Gj6Ab.js";
6
8
  import process$1 from "node:process";
7
9
  import { EventEmitter } from "events";
8
10
  import { randomUUID } from "node:crypto";
@@ -11,16 +13,6 @@ import http from "http";
11
13
  import { randomUUID as randomUUID$1 } from "crypto";
12
14
  import { setTimeout as setTimeout$1 } from "timers/promises";
13
15
 
14
- //#region src/types.internal.ts
15
- const dateSchema = pipe(string(), regex(/^\d{8}$/, "Date must be in YYYYMMDD format"));
16
- const CostModes = [
17
- "auto",
18
- "calculate",
19
- "display"
20
- ];
21
- const SortOrders = ["desc", "asc"];
22
-
23
- //#endregion
24
16
  //#region node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
25
17
  const LATEST_PROTOCOL_VERSION = "2025-03-26";
26
18
  const SUPPORTED_PROTOCOL_VERSIONS = [
@@ -12095,8 +12087,8 @@ var require_raw_body = __commonJS({ "node_modules/raw-body/index.js"(exports, mo
12095
12087
  type: "request.size.invalid"
12096
12088
  }));
12097
12089
  else {
12098
- var string$1 = decoder ? buffer$2 + (decoder.end() || "") : Buffer.concat(buffer$2);
12099
- done(null, string$1);
12090
+ var string = decoder ? buffer$2 + (decoder.end() || "") : Buffer.concat(buffer$2);
12091
+ done(null, string);
12100
12092
  }
12101
12093
  }
12102
12094
  function cleanup() {
@@ -12189,17 +12181,17 @@ var require_content_type = __commonJS({ "node_modules/content-type/index.js"(exp
12189
12181
  var parameters = obj.parameters;
12190
12182
  var type = obj.type;
12191
12183
  if (!type || !TYPE_REGEXP.test(type)) throw new TypeError("invalid type");
12192
- var string$1 = type;
12184
+ var string = type;
12193
12185
  if (parameters && typeof parameters === "object") {
12194
12186
  var param;
12195
12187
  var params = Object.keys(parameters).sort();
12196
12188
  for (var i$3 = 0; i$3 < params.length; i$3++) {
12197
12189
  param = params[i$3];
12198
12190
  if (!TOKEN_REGEXP.test(param)) throw new TypeError("invalid parameter name");
12199
- string$1 += "; " + param + "=" + qstring(parameters[param]);
12191
+ string += "; " + param + "=" + qstring(parameters[param]);
12200
12192
  }
12201
12193
  }
12202
- return string$1;
12194
+ return string;
12203
12195
  }
12204
12196
  /**
12205
12197
  * Parse media type to object.
@@ -12208,9 +12200,9 @@ var require_content_type = __commonJS({ "node_modules/content-type/index.js"(exp
12208
12200
  * @return {Object}
12209
12201
  * @public
12210
12202
  */
12211
- function parse(string$1) {
12212
- if (!string$1) throw new TypeError("argument string is required");
12213
- var header = typeof string$1 === "object" ? getcontenttype(string$1) : string$1;
12203
+ function parse(string) {
12204
+ if (!string) throw new TypeError("argument string is required");
12205
+ var header = typeof string === "object" ? getcontenttype(string) : string;
12214
12206
  if (typeof header !== "string") throw new TypeError("argument string is required to be a string");
12215
12207
  var index = header.indexOf(";");
12216
12208
  var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
@@ -13236,15 +13228,15 @@ var require_uri_all = __commonJS({ "node_modules/uri-js/dist/es5/uri.all.js"(exp
13236
13228
  * @returns {Array} A new string of characters returned by the callback
13237
13229
  * function.
13238
13230
  */
13239
- function mapDomain(string$1, fn) {
13240
- var parts = string$1.split("@");
13231
+ function mapDomain(string, fn) {
13232
+ var parts = string.split("@");
13241
13233
  var result = "";
13242
13234
  if (parts.length > 1) {
13243
13235
  result = parts[0] + "@";
13244
- string$1 = parts[1];
13236
+ string = parts[1];
13245
13237
  }
13246
- string$1 = string$1.replace(regexSeparators, ".");
13247
- var labels = string$1.split(".");
13238
+ string = string.replace(regexSeparators, ".");
13239
+ var labels = string.split(".");
13248
13240
  var encoded = map$1(labels, fn).join(".");
13249
13241
  return result + encoded;
13250
13242
  }
@@ -13261,14 +13253,14 @@ var require_uri_all = __commonJS({ "node_modules/uri-js/dist/es5/uri.all.js"(exp
13261
13253
  * @param {String} string The Unicode input string (UCS-2).
13262
13254
  * @returns {Array} The new array of code points.
13263
13255
  */
13264
- function ucs2decode(string$1) {
13256
+ function ucs2decode(string) {
13265
13257
  var output = [];
13266
13258
  var counter = 0;
13267
- var length = string$1.length;
13259
+ var length = string.length;
13268
13260
  while (counter < length) {
13269
- var value = string$1.charCodeAt(counter++);
13261
+ var value = string.charCodeAt(counter++);
13270
13262
  if (value >= 55296 && value <= 56319 && counter < length) {
13271
- var extra = string$1.charCodeAt(counter++);
13263
+ var extra = string.charCodeAt(counter++);
13272
13264
  if ((extra & 64512) == 56320) output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
13273
13265
  else {
13274
13266
  output.push(value);
@@ -13480,8 +13472,8 @@ var require_uri_all = __commonJS({ "node_modules/uri-js/dist/es5/uri.all.js"(exp
13480
13472
  * string.
13481
13473
  */
13482
13474
  var toUnicode = function toUnicode$1(input) {
13483
- return mapDomain(input, function(string$1) {
13484
- return regexPunycode.test(string$1) ? decode(string$1.slice(4).toLowerCase()) : string$1;
13475
+ return mapDomain(input, function(string) {
13476
+ return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
13485
13477
  });
13486
13478
  };
13487
13479
  /**
@@ -13496,8 +13488,8 @@ var require_uri_all = __commonJS({ "node_modules/uri-js/dist/es5/uri.all.js"(exp
13496
13488
  * email address.
13497
13489
  */
13498
13490
  var toASCII = function toASCII$1(input) {
13499
- return mapDomain(input, function(string$1) {
13500
- return regexNonASCII.test(string$1) ? "xn--" + encode(string$1) : string$1;
13491
+ return mapDomain(input, function(string) {
13492
+ return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
13501
13493
  });
13502
13494
  };
13503
13495
  /** Define the public API */
@@ -15369,7 +15361,7 @@ var require_formats = __commonJS({ "node_modules/ajv/lib/compile/formats.js"(exp
15369
15361
  hostname: HOSTNAME,
15370
15362
  ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
15371
15363
  ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
15372
- regex: regex$1,
15364
+ regex,
15373
15365
  uuid: UUID,
15374
15366
  "json-pointer": JSON_POINTER,
15375
15367
  "json-pointer-uri-fragment": JSON_POINTER_URI_FRAGMENT,
@@ -15387,7 +15379,7 @@ var require_formats = __commonJS({ "node_modules/ajv/lib/compile/formats.js"(exp
15387
15379
  hostname: HOSTNAME,
15388
15380
  ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
15389
15381
  ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
15390
- regex: regex$1,
15382
+ regex,
15391
15383
  uuid: UUID,
15392
15384
  "json-pointer": JSON_POINTER,
15393
15385
  "json-pointer-uri-fragment": JSON_POINTER_URI_FRAGMENT,
@@ -15423,7 +15415,7 @@ var require_formats = __commonJS({ "node_modules/ajv/lib/compile/formats.js"(exp
15423
15415
  return NOT_URI_FRAGMENT.test(str) && URI.test(str);
15424
15416
  }
15425
15417
  var Z_ANCHOR = /[^\\]\\Z/;
15426
- function regex$1(str) {
15418
+ function regex(str) {
15427
15419
  if (Z_ANCHOR.test(str)) return false;
15428
15420
  try {
15429
15421
  new RegExp(str);
@@ -18233,10 +18225,10 @@ var require_ajv = __commonJS({ "node_modules/ajv/lib/ajv.js"(exports, module) {
18233
18225
  }
18234
18226
  return this;
18235
18227
  }
18236
- function _removeAllSchemas(self, schemas, regex$2) {
18228
+ function _removeAllSchemas(self, schemas, regex$1) {
18237
18229
  for (var keyRef in schemas) {
18238
18230
  var schemaObj = schemas[keyRef];
18239
- if (!schemaObj.meta && (!regex$2 || regex$2.test(keyRef))) {
18231
+ if (!schemaObj.meta && (!regex$1 || regex$1.test(keyRef))) {
18240
18232
  self._cache.del(schemaObj.cacheKey);
18241
18233
  delete schemas[keyRef];
18242
18234
  }
@@ -35644,14 +35636,14 @@ var require_websocketstream = __commonJS({ "node_modules/undici/lib/web/websocke
35644
35636
  data = new Uint8Array(ArrayBuffer.isView(chunk) ? new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength) : chunk);
35645
35637
  opcode = opcodes.BINARY;
35646
35638
  } else {
35647
- let string$1;
35639
+ let string;
35648
35640
  try {
35649
- string$1 = webidl$1.converters.DOMString(chunk);
35641
+ string = webidl$1.converters.DOMString(chunk);
35650
35642
  } catch (e) {
35651
35643
  promise.reject(e);
35652
35644
  return;
35653
35645
  }
35654
- data = new TextEncoder().encode(string$1);
35646
+ data = new TextEncoder().encode(string);
35655
35647
  opcode = opcodes.TEXT;
35656
35648
  }
35657
35649
  if (!this.#handler.closeState.has(sentCloseFrameState.SENT) && !this.#handler.closeState.has(sentCloseFrameState.RECEIVED)) {
@@ -36507,14 +36499,14 @@ var require_uri_templates = __commonJS({ "node_modules/uri-templates/uri-templat
36507
36499
  };
36508
36500
  var uriTemplateSuffices = { "*": true };
36509
36501
  var urlEscapedChars = /[:/&?#]/;
36510
- function notReallyPercentEncode(string$1) {
36511
- return encodeURI(string$1).replace(/%25[0-9][0-9]/g, function(doubleEncoded) {
36502
+ function notReallyPercentEncode(string) {
36503
+ return encodeURI(string).replace(/%25[0-9][0-9]/g, function(doubleEncoded) {
36512
36504
  return "%" + doubleEncoded.substring(3);
36513
36505
  });
36514
36506
  }
36515
- function isPercentEncoded(string$1) {
36516
- string$1 = string$1.replace(/%../g, "");
36517
- return encodeURIComponent(string$1) === string$1;
36507
+ function isPercentEncoded(string) {
36508
+ string = string.replace(/%../g, "");
36509
+ return encodeURIComponent(string) === string;
36518
36510
  }
36519
36511
  function uriTemplateSubstitution(spec) {
36520
36512
  var modifier = "";
@@ -37592,4 +37584,4 @@ function createMcpServer({ claudePath } = defaultOptions) {
37592
37584
  }
37593
37585
 
37594
37586
  //#endregion
37595
- export { CostModes, SortOrders, createMcpServer, dateSchema };
37587
+ export { createMcpServer };
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { LoadOptions } from "./data-loader-amTZCtBR.js";
2
- import "./pricing-fetcher-Dq-OLBp4.js";
1
+ import "./pricing-fetcher-BkSZh4lR.js";
2
+ import { LoadOptions } from "./data-loader-OGaMjZTD.js";
3
3
  import { FastMCP } from "fastmcp";
4
4
 
5
5
  //#region src/mcp.d.ts
package/dist/mcp.js CHANGED
@@ -1,9 +1,9 @@
1
- import "./data-loader-Bz6Vemxw.js";
2
- import "./dist-BEQ1tJCL.js";
3
- import "./logger-DN-RT9jL.js";
4
- import "./pricing-fetcher-DMNBE90M.js";
5
- import { createMcpServer } from "./mcp-DZXbfmbs.js";
6
- import "./types-DS8M8QF_.js";
7
- import "./index-CISmcbXk-x9eVmhGM.js";
1
+ import "./data-loader-CotJGlGF.js";
2
+ import "./dist-DCvt9hEv.js";
3
+ import "./logger-BgKOQAEs.js";
4
+ import "./pricing-fetcher-1KHPTXC3.js";
5
+ import "./types-BlyCnKwN.js";
6
+ import { createMcpServer } from "./mcp-BUmEAQZm.js";
7
+ import "./index-CISmcbXk-CW1Gj6Ab.js";
8
8
 
9
9
  export { createMcpServer };
@@ -0,0 +1,205 @@
1
+ import { number, object, optional, pipe, regex, safeParse, string } from "./dist-DCvt9hEv.js";
2
+ import { logger } from "./logger-BgKOQAEs.js";
3
+
4
+ //#region src/consts.internal.ts
5
+ const LITELLM_PRICING_URL = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json";
6
+
7
+ //#endregion
8
+ //#region src/types.internal.ts
9
+ const dateSchema = pipe(string(), regex(/^\d{8}$/, "Date must be in YYYYMMDD format"));
10
+ const CostModes = [
11
+ "auto",
12
+ "calculate",
13
+ "display"
14
+ ];
15
+ const SortOrders = ["desc", "asc"];
16
+ const ModelPricingSchema = object({
17
+ input_cost_per_token: optional(number()),
18
+ output_cost_per_token: optional(number()),
19
+ cache_creation_input_token_cost: optional(number()),
20
+ cache_read_input_token_cost: optional(number())
21
+ });
22
+
23
+ //#endregion
24
+ //#region src/pricing-fetcher.ts
25
+ var PricingFetcher = class {
26
+ cachedPricing = null;
27
+ offline;
28
+ constructor(offline = false) {
29
+ this.offline = offline;
30
+ }
31
+ [Symbol.dispose]() {
32
+ this.clearCache();
33
+ }
34
+ clearCache() {
35
+ this.cachedPricing = null;
36
+ }
37
+ async ensurePricingLoaded() {
38
+ if (this.cachedPricing != null) return this.cachedPricing;
39
+ if (this.offline) {
40
+ const pricing = new Map(Object.entries({
41
+ "claude-instant-1": {
42
+ "input_cost_per_token": 163e-8,
43
+ "output_cost_per_token": 551e-8
44
+ },
45
+ "claude-instant-1.2": {
46
+ "input_cost_per_token": 163e-9,
47
+ "output_cost_per_token": 551e-9
48
+ },
49
+ "claude-2": {
50
+ "input_cost_per_token": 8e-6,
51
+ "output_cost_per_token": 24e-6
52
+ },
53
+ "claude-2.1": {
54
+ "input_cost_per_token": 8e-6,
55
+ "output_cost_per_token": 24e-6
56
+ },
57
+ "claude-3-haiku-20240307": {
58
+ "input_cost_per_token": 25e-8,
59
+ "output_cost_per_token": 125e-8,
60
+ "cache_creation_input_token_cost": 3e-7,
61
+ "cache_read_input_token_cost": 3e-8
62
+ },
63
+ "claude-3-5-haiku-20241022": {
64
+ "input_cost_per_token": 8e-7,
65
+ "output_cost_per_token": 4e-6,
66
+ "cache_creation_input_token_cost": 1e-6,
67
+ "cache_read_input_token_cost": 8e-8
68
+ },
69
+ "claude-3-5-haiku-latest": {
70
+ "input_cost_per_token": 1e-6,
71
+ "output_cost_per_token": 5e-6,
72
+ "cache_creation_input_token_cost": 125e-8,
73
+ "cache_read_input_token_cost": 1e-7
74
+ },
75
+ "claude-3-opus-latest": {
76
+ "input_cost_per_token": 15e-6,
77
+ "output_cost_per_token": 75e-6,
78
+ "cache_creation_input_token_cost": 1875e-8,
79
+ "cache_read_input_token_cost": 15e-7
80
+ },
81
+ "claude-3-opus-20240229": {
82
+ "input_cost_per_token": 15e-6,
83
+ "output_cost_per_token": 75e-6,
84
+ "cache_creation_input_token_cost": 1875e-8,
85
+ "cache_read_input_token_cost": 15e-7
86
+ },
87
+ "claude-3-sonnet-20240229": {
88
+ "input_cost_per_token": 3e-6,
89
+ "output_cost_per_token": 15e-6
90
+ },
91
+ "claude-3-5-sonnet-latest": {
92
+ "input_cost_per_token": 3e-6,
93
+ "output_cost_per_token": 15e-6,
94
+ "cache_creation_input_token_cost": 375e-8,
95
+ "cache_read_input_token_cost": 3e-7
96
+ },
97
+ "claude-3-5-sonnet-20240620": {
98
+ "input_cost_per_token": 3e-6,
99
+ "output_cost_per_token": 15e-6,
100
+ "cache_creation_input_token_cost": 375e-8,
101
+ "cache_read_input_token_cost": 3e-7
102
+ },
103
+ "claude-opus-4-20250514": {
104
+ "input_cost_per_token": 15e-6,
105
+ "output_cost_per_token": 75e-6,
106
+ "cache_creation_input_token_cost": 1875e-8,
107
+ "cache_read_input_token_cost": 15e-7
108
+ },
109
+ "claude-sonnet-4-20250514": {
110
+ "input_cost_per_token": 3e-6,
111
+ "output_cost_per_token": 15e-6,
112
+ "cache_creation_input_token_cost": 375e-8,
113
+ "cache_read_input_token_cost": 3e-7
114
+ },
115
+ "claude-4-opus-20250514": {
116
+ "input_cost_per_token": 15e-6,
117
+ "output_cost_per_token": 75e-6,
118
+ "cache_creation_input_token_cost": 1875e-8,
119
+ "cache_read_input_token_cost": 15e-7
120
+ },
121
+ "claude-4-sonnet-20250514": {
122
+ "input_cost_per_token": 3e-6,
123
+ "output_cost_per_token": 15e-6,
124
+ "cache_creation_input_token_cost": 375e-8,
125
+ "cache_read_input_token_cost": 3e-7
126
+ },
127
+ "claude-3-7-sonnet-latest": {
128
+ "input_cost_per_token": 3e-6,
129
+ "output_cost_per_token": 15e-6,
130
+ "cache_creation_input_token_cost": 375e-8,
131
+ "cache_read_input_token_cost": 3e-7
132
+ },
133
+ "claude-3-7-sonnet-20250219": {
134
+ "input_cost_per_token": 3e-6,
135
+ "output_cost_per_token": 15e-6,
136
+ "cache_creation_input_token_cost": 375e-8,
137
+ "cache_read_input_token_cost": 3e-7
138
+ },
139
+ "claude-3-5-sonnet-20241022": {
140
+ "input_cost_per_token": 3e-6,
141
+ "output_cost_per_token": 15e-6,
142
+ "cache_creation_input_token_cost": 375e-8,
143
+ "cache_read_input_token_cost": 3e-7
144
+ }
145
+ }));
146
+ this.cachedPricing = pricing;
147
+ return pricing;
148
+ }
149
+ try {
150
+ logger.warn("Fetching latest model pricing from LiteLLM...");
151
+ const response = await fetch(LITELLM_PRICING_URL);
152
+ if (!response.ok) throw new Error(`Failed to fetch pricing data: ${response.statusText}`);
153
+ const data = await response.json();
154
+ const pricing = /* @__PURE__ */ new Map();
155
+ for (const [modelName, modelData] of Object.entries(data)) if (typeof modelData === "object" && modelData !== null) {
156
+ const parsed = safeParse(ModelPricingSchema, modelData);
157
+ if (parsed.success) pricing.set(modelName, parsed.output);
158
+ }
159
+ this.cachedPricing = pricing;
160
+ logger.info(`Loaded pricing for ${pricing.size} models`);
161
+ return pricing;
162
+ } catch (error) {
163
+ logger.error("Failed to fetch model pricing:", error);
164
+ throw new Error("Could not fetch model pricing data");
165
+ }
166
+ }
167
+ async fetchModelPricing() {
168
+ return this.ensurePricingLoaded();
169
+ }
170
+ async getModelPricing(modelName) {
171
+ const pricing = await this.ensurePricingLoaded();
172
+ const directMatch = pricing.get(modelName);
173
+ if (directMatch != null) return directMatch;
174
+ const variations = [
175
+ modelName,
176
+ `anthropic/${modelName}`,
177
+ `claude-3-5-${modelName}`,
178
+ `claude-3-${modelName}`,
179
+ `claude-${modelName}`
180
+ ];
181
+ for (const variant of variations) {
182
+ const match = pricing.get(variant);
183
+ if (match != null) return match;
184
+ }
185
+ const lowerModel = modelName.toLowerCase();
186
+ for (const [key, value] of pricing) if (key.toLowerCase().includes(lowerModel) || lowerModel.includes(key.toLowerCase())) return value;
187
+ return null;
188
+ }
189
+ async calculateCostFromTokens(tokens, modelName) {
190
+ const pricing = await this.getModelPricing(modelName);
191
+ if (pricing == null) return 0;
192
+ return this.calculateCostFromPricing(tokens, pricing);
193
+ }
194
+ calculateCostFromPricing(tokens, pricing) {
195
+ let cost = 0;
196
+ if (pricing.input_cost_per_token != null) cost += tokens.input_tokens * pricing.input_cost_per_token;
197
+ if (pricing.output_cost_per_token != null) cost += tokens.output_tokens * pricing.output_cost_per_token;
198
+ if (tokens.cache_creation_input_tokens != null && pricing.cache_creation_input_token_cost != null) cost += tokens.cache_creation_input_tokens * pricing.cache_creation_input_token_cost;
199
+ if (tokens.cache_read_input_tokens != null && pricing.cache_read_input_token_cost != null) cost += tokens.cache_read_input_tokens * pricing.cache_read_input_token_cost;
200
+ return cost;
201
+ }
202
+ };
203
+
204
+ //#endregion
205
+ export { CostModes, PricingFetcher, SortOrders, dateSchema };
@@ -1,3 +1,76 @@
1
+ //#region node_modules/type-fest/source/observable-like.d.ts
2
+ declare global {
3
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
4
+ interface SymbolConstructor {
5
+ readonly observable: symbol;
6
+ }
7
+ }
8
+
9
+ /**
10
+ @remarks
11
+ The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
12
+ As well, some guidance on making an `Observable` to not include `closed` property.
13
+ @see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
14
+ @see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
15
+ @see https://github.com/benlesh/symbol-observable#making-an-object-observable
16
+
17
+ @category Observable
18
+ */
19
+
20
+ //#endregion
21
+ //#region node_modules/type-fest/source/tuple-to-union.d.ts
22
+ /**
23
+ Convert a tuple/array into a union type of its elements.
24
+
25
+ This can be useful when you have a fixed set of allowed values and want a type defining only the allowed values, but do not want to repeat yourself.
26
+
27
+ @example
28
+ ```
29
+ import type {TupleToUnion} from 'type-fest';
30
+
31
+ const destinations = ['a', 'b', 'c'] as const;
32
+
33
+ type Destination = TupleToUnion<typeof destinations>;
34
+ //=> 'a' | 'b' | 'c'
35
+
36
+ function verifyDestination(destination: unknown): destination is Destination {
37
+ return destinations.includes(destination as any);
38
+ }
39
+
40
+ type RequestBody = {
41
+ deliverTo: Destination;
42
+ };
43
+
44
+ function verifyRequestBody(body: unknown): body is RequestBody {
45
+ const deliverTo = (body as any).deliverTo;
46
+ return typeof body === 'object' && body !== null && verifyDestination(deliverTo);
47
+ }
48
+ ```
49
+
50
+ Alternatively, you may use `typeof destinations[number]`. If `destinations` is a tuple, there is no difference. However if `destinations` is a string, the resulting type will the union of the characters in the string. Other types of `destinations` may result in a compile error. In comparison, TupleToUnion will return `never` if a tuple is not provided.
51
+
52
+ @example
53
+ ```
54
+ const destinations = ['a', 'b', 'c'] as const;
55
+
56
+ type Destination = typeof destinations[number];
57
+ //=> 'a' | 'b' | 'c'
58
+
59
+ const erroringType = new Set(['a', 'b', 'c']);
60
+
61
+ type ErroringType = typeof erroringType[number];
62
+ //=> Type 'Set<string>' has no matching index signature for type 'number'. ts(2537)
63
+
64
+ const numberBool: { [n: number]: boolean } = { 1: true };
65
+
66
+ type NumberBool = typeof numberBool[number];
67
+ //=> boolean
68
+ ```
69
+
70
+ @category Array
71
+ */
72
+ type TupleToUnion<ArrayType> = ArrayType extends readonly unknown[] ? ArrayType[number] : never;
73
+ //#endregion
1
74
  //#region node_modules/valibot/dist/index.d.ts
2
75
 
3
76
  /**
@@ -1559,7 +1632,11 @@ declare function regex<TInput extends string, const TMessage extends ErrorMessag
1559
1632
  * Returns action type.
1560
1633
  */
1561
1634
  //#endregion
1562
- //#region src/pricing-fetcher.d.ts
1635
+ //#region src/types.internal.d.ts
1636
+ declare const CostModes: readonly ["auto", "calculate", "display"];
1637
+ type CostMode = TupleToUnion<typeof CostModes>;
1638
+ declare const SortOrders: readonly ["desc", "asc"];
1639
+ type SortOrder = TupleToUnion<typeof SortOrders>;
1563
1640
  declare const ModelPricingSchema: ObjectSchema<{
1564
1641
  readonly input_cost_per_token: OptionalSchema<NumberSchema<undefined>, undefined>;
1565
1642
  readonly output_cost_per_token: OptionalSchema<NumberSchema<undefined>, undefined>;
@@ -1567,9 +1644,12 @@ declare const ModelPricingSchema: ObjectSchema<{
1567
1644
  readonly cache_read_input_token_cost: OptionalSchema<NumberSchema<undefined>, undefined>;
1568
1645
  }, undefined>;
1569
1646
  type ModelPricing = InferOutput<typeof ModelPricingSchema>;
1647
+ //#endregion
1648
+ //#region src/pricing-fetcher.d.ts
1570
1649
  declare class PricingFetcher implements Disposable {
1571
1650
  private cachedPricing;
1572
- constructor();
1651
+ private readonly offline;
1652
+ constructor(offline?: boolean);
1573
1653
  [Symbol.dispose](): void;
1574
1654
  clearCache(): void;
1575
1655
  private ensurePricingLoaded;
@@ -1589,4 +1669,4 @@ declare class PricingFetcher implements Disposable {
1589
1669
  }, pricing: ModelPricing): number;
1590
1670
  }
1591
1671
  //#endregion
1592
- export { ArraySchema, InferOutput, ModelPricing, NumberSchema, ObjectSchema, OptionalSchema, PricingFetcher, RegexAction, SchemaWithPipe, StringSchema };
1672
+ export { ArraySchema, CostMode, InferOutput, NumberSchema, ObjectSchema, OptionalSchema, PricingFetcher, RegexAction, SchemaWithPipe, SortOrder, StringSchema };
@@ -1,2 +1,2 @@
1
- import { ModelPricing, PricingFetcher } from "./pricing-fetcher-Dq-OLBp4.js";
2
- export { ModelPricing, PricingFetcher };
1
+ import { PricingFetcher } from "./pricing-fetcher-BkSZh4lR.js";
2
+ export { PricingFetcher };
@@ -1,5 +1,5 @@
1
- import "./dist-BEQ1tJCL.js";
2
- import "./logger-DN-RT9jL.js";
3
- import { PricingFetcher } from "./pricing-fetcher-DMNBE90M.js";
1
+ import "./dist-DCvt9hEv.js";
2
+ import "./logger-BgKOQAEs.js";
3
+ import { PricingFetcher } from "./pricing-fetcher-1KHPTXC3.js";
4
4
 
5
5
  export { PricingFetcher };
@@ -1,4 +1,4 @@
1
- import { tryImport } from "./index-CISmcbXk-x9eVmhGM.js";
1
+ import { tryImport } from "./index-CISmcbXk-CW1Gj6Ab.js";
2
2
 
3
3
  //#region node_modules/xsschema/dist/sury-DmrZ3_Oj.js
4
4
  const getToJsonSchemaFn = async () => {