ccusage 0.6.0 → 0.6.2

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 (46) hide show
  1. package/README.md +29 -22
  2. package/dist/calculate-cost.d.ts +11 -8
  3. package/dist/{core-BgFXUe_h.js → core-B0ovMhJe.js} +4 -4
  4. package/dist/data-loader-B0tJZeHI.d.ts +144 -0
  5. package/dist/{data-loader-CDv0IYZx.js → data-loader-BfnzLKGl.js} +503 -131
  6. package/dist/data-loader.d.ts +2 -4
  7. package/dist/data-loader.js +4 -4
  8. package/dist/{debug-Dk36WQTw.js → debug-Bf6GUNZE.js} +45 -40
  9. package/dist/debug.d.ts +4 -4
  10. package/dist/debug.js +5 -5
  11. package/dist/{dist-FwNhpFrW.js → dist-BEQ1tJCL.js} +1 -109
  12. package/dist/{dist-C_i5I27w.js → dist-DAarI-SJ.js} +5 -5
  13. package/dist/{effect-WSjEuzC9-BsxP11fz.js → effect-WSjEuzC9-ChJ5OQQf.js} +1 -1
  14. package/dist/{esm-vjyZjnpZ.js → esm-Dqsc1zmX.js} +1 -1
  15. package/dist/{index-CISmcbXk-BotItq1T.js → index-CISmcbXk-x9eVmhGM.js} +5 -5
  16. package/dist/index.js +108 -42
  17. package/dist/{logger-DhDyJEC5.js → logger-DixU80sg.js} +17 -17
  18. package/dist/logger.js +1 -1
  19. package/dist/{mcp-G-TIOcuj.js → mcp-nXxiNurt.js} +93 -78
  20. package/dist/mcp.d.ts +2 -4
  21. package/dist/mcp.js +7 -8
  22. package/dist/pricing-fetcher-BY3-ryVq.js +79 -0
  23. package/dist/{index-BurjgCfW.d.ts → pricing-fetcher-Dq-OLBp4.d.ts} +31 -249
  24. package/dist/pricing-fetcher.d.ts +2 -3
  25. package/dist/pricing-fetcher.js +4 -4
  26. package/dist/{prompt-IToGuko2.js → prompt-DljZqwMa.js} +4 -4
  27. package/dist/{sury-DmrZ3_Oj-DhGOjCNc.js → sury-DmrZ3_Oj-l0qqtY-f.js} +1 -1
  28. package/dist/{types-CFnCBr2I.js → types-DS8M8QF_.js} +4 -4
  29. package/dist/valibot-CQk-M5rL-BNHzwpA0.js +10 -0
  30. package/dist/{zod-Db63SLXj-BWdcigdx.js → zod-Db63SLXj-N1oN-yiY.js} +3 -3
  31. package/package.json +8 -11
  32. package/dist/data-loader-aUOjeZ06.d.ts +0 -67
  33. package/dist/pricing-fetcher-BCv1Vods.js +0 -60
  34. package/dist/pricing-fetcher-DygIroMj.d.ts +0 -21
  35. package/dist/shared-args-BtMSktLn.js +0 -68
  36. package/dist/shared-args.d.ts +0 -108
  37. package/dist/shared-args.js +0 -8
  38. package/dist/types-BcXIBMQk.js +0 -42
  39. package/dist/types-y1JQzaKZ.d.ts +0 -81
  40. package/dist/types.d.ts +0 -3
  41. package/dist/types.js +0 -4
  42. package/dist/utils-C7kg8MXN.js +0 -10
  43. package/dist/utils.d.ts +0 -5
  44. package/dist/utils.js +0 -3
  45. package/dist/valibot-CQk-M5rL-Cq5E7F3g.js +0 -10
  46. /package/dist/{arktype-C-GObzDh-Dj1DVoqC.js → arktype-C-GObzDh-Bx7Fdrqj.js} +0 -0
package/dist/mcp.js CHANGED
@@ -1,10 +1,9 @@
1
- import "./data-loader-CDv0IYZx.js";
2
- import "./dist-FwNhpFrW.js";
3
- import "./logger-DhDyJEC5.js";
4
- import "./pricing-fetcher-BCv1Vods.js";
5
- import "./types-BcXIBMQk.js";
6
- import "./types-CFnCBr2I.js";
7
- import { createMcpServer } from "./mcp-G-TIOcuj.js";
8
- import "./index-CISmcbXk-BotItq1T.js";
1
+ import "./data-loader-BfnzLKGl.js";
2
+ import "./dist-BEQ1tJCL.js";
3
+ import "./logger-DixU80sg.js";
4
+ import "./pricing-fetcher-BY3-ryVq.js";
5
+ import { createMcpServer } from "./mcp-nXxiNurt.js";
6
+ import "./types-DS8M8QF_.js";
7
+ import "./index-CISmcbXk-x9eVmhGM.js";
9
8
 
10
9
  export { createMcpServer };
@@ -0,0 +1,79 @@
1
+ import { number, object, optional, safeParse } from "./dist-BEQ1tJCL.js";
2
+ import { logger } from "./logger-DixU80sg.js";
3
+
4
+ //#region src/pricing-fetcher.ts
5
+ const ModelPricingSchema = object({
6
+ input_cost_per_token: optional(number()),
7
+ output_cost_per_token: optional(number()),
8
+ cache_creation_input_token_cost: optional(number()),
9
+ cache_read_input_token_cost: optional(number())
10
+ });
11
+ const LITELLM_PRICING_URL = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json";
12
+ var PricingFetcher = class {
13
+ cachedPricing = null;
14
+ constructor() {}
15
+ [Symbol.dispose]() {
16
+ this.clearCache();
17
+ }
18
+ clearCache() {
19
+ this.cachedPricing = null;
20
+ }
21
+ async ensurePricingLoaded() {
22
+ if (this.cachedPricing != null) return this.cachedPricing;
23
+ try {
24
+ logger.warn("Fetching latest model pricing from LiteLLM...");
25
+ const response = await fetch(LITELLM_PRICING_URL);
26
+ if (!response.ok) throw new Error(`Failed to fetch pricing data: ${response.statusText}`);
27
+ const data = await response.json();
28
+ const pricing = /* @__PURE__ */ new Map();
29
+ for (const [modelName, modelData] of Object.entries(data)) if (typeof modelData === "object" && modelData !== null) {
30
+ const parsed = safeParse(ModelPricingSchema, modelData);
31
+ if (parsed.success) pricing.set(modelName, parsed.output);
32
+ }
33
+ this.cachedPricing = pricing;
34
+ logger.info(`Loaded pricing for ${pricing.size} models`);
35
+ return pricing;
36
+ } catch (error) {
37
+ logger.error("Failed to fetch model pricing:", error);
38
+ throw new Error("Could not fetch model pricing data");
39
+ }
40
+ }
41
+ async fetchModelPricing() {
42
+ return this.ensurePricingLoaded();
43
+ }
44
+ async getModelPricing(modelName) {
45
+ const pricing = await this.ensurePricingLoaded();
46
+ const directMatch = pricing.get(modelName);
47
+ if (directMatch != null) return directMatch;
48
+ const variations = [
49
+ modelName,
50
+ `anthropic/${modelName}`,
51
+ `claude-3-5-${modelName}`,
52
+ `claude-3-${modelName}`,
53
+ `claude-${modelName}`
54
+ ];
55
+ for (const variant of variations) {
56
+ const match = pricing.get(variant);
57
+ if (match != null) return match;
58
+ }
59
+ const lowerModel = modelName.toLowerCase();
60
+ for (const [key, value] of pricing) if (key.toLowerCase().includes(lowerModel) || lowerModel.includes(key.toLowerCase())) return value;
61
+ return null;
62
+ }
63
+ async calculateCostFromTokens(tokens, modelName) {
64
+ const pricing = await this.getModelPricing(modelName);
65
+ if (pricing == null) return 0;
66
+ return this.calculateCostFromPricing(tokens, pricing);
67
+ }
68
+ calculateCostFromPricing(tokens, pricing) {
69
+ let cost = 0;
70
+ if (pricing.input_cost_per_token != null) cost += tokens.input_tokens * pricing.input_cost_per_token;
71
+ if (pricing.output_cost_per_token != null) cost += tokens.output_tokens * pricing.output_cost_per_token;
72
+ 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;
73
+ 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;
74
+ return cost;
75
+ }
76
+ };
77
+
78
+ //#endregion
79
+ export { PricingFetcher };
@@ -994,63 +994,6 @@ declare function array<const TItem extends BaseSchema<unknown, unknown, BaseIssu
994
994
  * Array schema interface.
995
995
  */
996
996
 
997
- /**
998
- * Boolean issue interface.
999
- */
1000
- interface BooleanIssue extends BaseIssue<unknown> {
1001
- /**
1002
- * The issue kind.
1003
- */
1004
- readonly kind: 'schema';
1005
- /**
1006
- * The issue type.
1007
- */
1008
- readonly type: 'boolean';
1009
- /**
1010
- * The expected property.
1011
- */
1012
- readonly expected: 'boolean';
1013
- }
1014
- /**
1015
- * Boolean schema interface.
1016
- */
1017
- interface BooleanSchema<TMessage extends ErrorMessage<BooleanIssue> | undefined> extends BaseSchema<boolean, boolean, BooleanIssue> {
1018
- /**
1019
- * The schema type.
1020
- */
1021
- readonly type: 'boolean';
1022
- /**
1023
- * The schema reference.
1024
- */
1025
- readonly reference: typeof boolean;
1026
- /**
1027
- * The expected property.
1028
- */
1029
- readonly expects: 'boolean';
1030
- /**
1031
- * The error message.
1032
- */
1033
- readonly message: TMessage;
1034
- }
1035
- /**
1036
- * Creates a boolean schema.
1037
- *
1038
- * @returns A boolean schema.
1039
- */
1040
- declare function boolean(): BooleanSchema<undefined>;
1041
- /**
1042
- * Creates a boolean schema.
1043
- *
1044
- * @param message The error message.
1045
- *
1046
- * @returns A boolean schema.
1047
- */
1048
- declare function boolean<const TMessage extends ErrorMessage<BooleanIssue> | undefined>(message: TMessage): BooleanSchema<TMessage>;
1049
-
1050
- /**
1051
- * Custom issue interface.
1052
- */
1053
-
1054
997
  /**
1055
998
  * Exact optional schema interface.
1056
999
  */
@@ -1141,75 +1084,6 @@ declare function exactOptionalAsync<const TWrapped extends BaseSchema<unknown, u
1141
1084
  * File issue interface.
1142
1085
  */
1143
1086
 
1144
- /**
1145
- * Union issue interface.
1146
- */
1147
- interface UnionIssue<TSubIssue extends BaseIssue<unknown>> extends BaseIssue<unknown> {
1148
- /**
1149
- * The issue kind.
1150
- */
1151
- readonly kind: 'schema';
1152
- /**
1153
- * The issue type.
1154
- */
1155
- readonly type: 'union';
1156
- /**
1157
- * The expected property.
1158
- */
1159
- readonly expected: string;
1160
- /**
1161
- * The sub issues.
1162
- */
1163
- readonly issues?: [TSubIssue, ...TSubIssue[]];
1164
- }
1165
-
1166
- /**
1167
- * Union options type.
1168
- */
1169
- type UnionOptions = MaybeReadonly<BaseSchema<unknown, unknown, BaseIssue<unknown>>[]>;
1170
- /**
1171
- * Union schema interface.
1172
- */
1173
- interface UnionSchema<TOptions extends UnionOptions, TMessage extends ErrorMessage<UnionIssue<InferIssue<TOptions[number]>>> | undefined> extends BaseSchema<InferInput<TOptions[number]>, InferOutput<TOptions[number]>, UnionIssue<InferIssue<TOptions[number]>> | InferIssue<TOptions[number]>> {
1174
- /**
1175
- * The schema type.
1176
- */
1177
- readonly type: 'union';
1178
- /**
1179
- * The schema reference.
1180
- */
1181
- readonly reference: typeof union;
1182
- /**
1183
- * The union options.
1184
- */
1185
- readonly options: TOptions;
1186
- /**
1187
- * The error message.
1188
- */
1189
- readonly message: TMessage;
1190
- }
1191
- /**
1192
- * Creates an union schema.
1193
- *
1194
- * @param options The union options.
1195
- *
1196
- * @returns An union schema.
1197
- */
1198
- declare function union<const TOptions extends UnionOptions>(options: TOptions): UnionSchema<TOptions, undefined>;
1199
- /**
1200
- * Creates an union schema.
1201
- *
1202
- * @param options The union options.
1203
- * @param message The error message.
1204
- *
1205
- * @returns An union schema.
1206
- */
1207
- declare function union<const TOptions extends UnionOptions, const TMessage extends ErrorMessage<UnionIssue<InferIssue<TOptions[number]>>> | undefined>(options: TOptions, message: TMessage): UnionSchema<TOptions, TMessage>;
1208
-
1209
- /**
1210
- * Union options async type.
1211
- */
1212
-
1213
1087
  /**
1214
1088
  * Infer nullish output type.
1215
1089
  */
@@ -1524,110 +1398,6 @@ declare function optionalAsync<const TWrapped extends BaseSchema<unknown, unknow
1524
1398
  * Picklist options type.
1525
1399
  */
1526
1400
 
1527
- /**
1528
- * Record issue interface.
1529
- */
1530
- interface RecordIssue extends BaseIssue<unknown> {
1531
- /**
1532
- * The issue kind.
1533
- */
1534
- readonly kind: 'schema';
1535
- /**
1536
- * The issue type.
1537
- */
1538
- readonly type: 'record';
1539
- /**
1540
- * The expected property.
1541
- */
1542
- readonly expected: 'Object';
1543
- }
1544
- /**
1545
- * Is literal type.
1546
- */
1547
- type IsLiteral<TKey extends string | number | symbol> = string extends TKey ? false : number extends TKey ? false : symbol extends TKey ? false : TKey extends Brand<string | number | symbol> ? false : true;
1548
- /**
1549
- * Optional keys type.
1550
- */
1551
- type OptionalKeys<TObject extends Record<string | number | symbol, unknown>> = { [TKey in keyof TObject]: IsLiteral<TKey> extends true ? TKey : never }[keyof TObject];
1552
- /**
1553
- * With question marks type.
1554
- *
1555
- * Hint: We mark an entry as optional if we detect that its key is a literal
1556
- * type. The reason for this is that it is not technically possible to detect
1557
- * missing literal keys without restricting the key schema to `string`, `enum`
1558
- * and `picklist`. However, if `enum` and `picklist` are used, it is better to
1559
- * use `object` with `entriesFromList` because it already covers the needed
1560
- * functionality. This decision also reduces the bundle size of `record`,
1561
- * because it only needs to check the entries of the input and not any missing
1562
- * keys.
1563
- */
1564
- type WithQuestionMarks<TObject extends Record<string | number | symbol, unknown>> = MarkOptional<TObject, OptionalKeys<TObject>>;
1565
- /**
1566
- * With readonly type.
1567
- */
1568
- type WithReadonly<TValue extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>, TObject extends WithQuestionMarks<Record<string | number | symbol, unknown>>> = TValue extends SchemaWithPipe<infer TPipe> | SchemaWithPipeAsync<infer TPipe> ? ReadonlyAction<any> extends TPipe[number] ? Readonly<TObject> : TObject : TObject;
1569
- /**
1570
- * Infer record input type.
1571
- */
1572
- type InferRecordInput<TKey extends BaseSchema<string, string | number | symbol, BaseIssue<unknown>> | BaseSchemaAsync<string, string | number | symbol, BaseIssue<unknown>>, TValue extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = Prettify<WithQuestionMarks<Record<InferInput<TKey>, InferInput<TValue>>>>;
1573
- /**
1574
- * Infer record output type.
1575
- */
1576
- type InferRecordOutput<TKey extends BaseSchema<string, string | number | symbol, BaseIssue<unknown>> | BaseSchemaAsync<string, string | number | symbol, BaseIssue<unknown>>, TValue extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>> = Prettify<WithReadonly<TValue, WithQuestionMarks<Record<InferOutput<TKey>, InferOutput<TValue>>>>>;
1577
-
1578
- /**
1579
- * Record schema interface.
1580
- */
1581
- interface RecordSchema<TKey extends BaseSchema<string, string | number | symbol, BaseIssue<unknown>>, TValue extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, TMessage extends ErrorMessage<RecordIssue> | undefined> extends BaseSchema<InferRecordInput<TKey, TValue>, InferRecordOutput<TKey, TValue>, RecordIssue | InferIssue<TKey> | InferIssue<TValue>> {
1582
- /**
1583
- * The schema type.
1584
- */
1585
- readonly type: 'record';
1586
- /**
1587
- * The schema reference.
1588
- */
1589
- readonly reference: typeof record;
1590
- /**
1591
- * The expected property.
1592
- */
1593
- readonly expects: 'Object';
1594
- /**
1595
- * The record key schema.
1596
- */
1597
- readonly key: TKey;
1598
- /**
1599
- * The record value schema.
1600
- */
1601
- readonly value: TValue;
1602
- /**
1603
- * The error message.
1604
- */
1605
- readonly message: TMessage;
1606
- }
1607
- /**
1608
- * Creates a record schema.
1609
- *
1610
- * @param key The key schema.
1611
- * @param value The value schema.
1612
- *
1613
- * @returns A record schema.
1614
- */
1615
- declare function record<const TKey extends BaseSchema<string, string | number | symbol, BaseIssue<unknown>>, const TValue extends BaseSchema<unknown, unknown, BaseIssue<unknown>>>(key: TKey, value: TValue): RecordSchema<TKey, TValue, undefined>;
1616
- /**
1617
- * Creates a record schema.
1618
- *
1619
- * @param key The key schema.
1620
- * @param value The value schema.
1621
- * @param message The error message.
1622
- *
1623
- * @returns A record schema.
1624
- */
1625
- declare function record<const TKey extends BaseSchema<string, string | number | symbol, BaseIssue<unknown>>, const TValue extends BaseSchema<unknown, unknown, BaseIssue<unknown>>, const TMessage extends ErrorMessage<RecordIssue> | undefined>(key: TKey, value: TValue, message: TMessage): RecordSchema<TKey, TValue, TMessage>;
1626
-
1627
- /**
1628
- * Record schema async interface.
1629
- */
1630
-
1631
1401
  /**
1632
1402
  * String issue interface.
1633
1403
  */
@@ -1685,24 +1455,6 @@ declare function string<const TMessage extends ErrorMessage<StringIssue> | undef
1685
1455
  * Symbol issue interface.
1686
1456
  */
1687
1457
 
1688
- /**
1689
- * Brand symbol.
1690
- */
1691
- declare const BrandSymbol: unique symbol;
1692
- /**
1693
- * Brand name type.
1694
- */
1695
- type BrandName = string | number | symbol;
1696
- /**
1697
- * Brand interface.
1698
- */
1699
- interface Brand<TName extends BrandName> {
1700
- [BrandSymbol]: { [TValue in TName]: TValue };
1701
- }
1702
- /**
1703
- * Brand action interface.
1704
- */
1705
-
1706
1458
  /**
1707
1459
  * Readonly output type.
1708
1460
  */
@@ -1807,4 +1559,34 @@ declare function regex<TInput extends string, const TMessage extends ErrorMessag
1807
1559
  * Returns action type.
1808
1560
  */
1809
1561
  //#endregion
1810
- export { ArraySchema, BooleanSchema, InferOutput, NumberSchema, ObjectSchema, OptionalSchema, RecordSchema, RegexAction, SchemaWithPipe, StringSchema, UnionSchema };
1562
+ //#region src/pricing-fetcher.d.ts
1563
+ declare const ModelPricingSchema: ObjectSchema<{
1564
+ readonly input_cost_per_token: OptionalSchema<NumberSchema<undefined>, undefined>;
1565
+ readonly output_cost_per_token: OptionalSchema<NumberSchema<undefined>, undefined>;
1566
+ readonly cache_creation_input_token_cost: OptionalSchema<NumberSchema<undefined>, undefined>;
1567
+ readonly cache_read_input_token_cost: OptionalSchema<NumberSchema<undefined>, undefined>;
1568
+ }, undefined>;
1569
+ type ModelPricing = InferOutput<typeof ModelPricingSchema>;
1570
+ declare class PricingFetcher implements Disposable {
1571
+ private cachedPricing;
1572
+ constructor();
1573
+ [Symbol.dispose](): void;
1574
+ clearCache(): void;
1575
+ private ensurePricingLoaded;
1576
+ fetchModelPricing(): Promise<Map<string, ModelPricing>>;
1577
+ getModelPricing(modelName: string): Promise<ModelPricing | null>;
1578
+ calculateCostFromTokens(tokens: {
1579
+ input_tokens: number;
1580
+ output_tokens: number;
1581
+ cache_creation_input_tokens?: number;
1582
+ cache_read_input_tokens?: number;
1583
+ }, modelName: string): Promise<number>;
1584
+ calculateCostFromPricing(tokens: {
1585
+ input_tokens: number;
1586
+ output_tokens: number;
1587
+ cache_creation_input_tokens?: number;
1588
+ cache_read_input_tokens?: number;
1589
+ }, pricing: ModelPricing): number;
1590
+ }
1591
+ //#endregion
1592
+ export { ArraySchema, InferOutput, ModelPricing, NumberSchema, ObjectSchema, OptionalSchema, PricingFetcher, RegexAction, SchemaWithPipe, StringSchema };
@@ -1,3 +1,2 @@
1
- import "./index-BurjgCfW.js";
2
- import { ModelPricing, calculateCostFromTokens$1 as calculateCostFromTokens, clearPricingCache$1 as clearPricingCache, fetchModelPricing$1 as fetchModelPricing, getModelPricing$1 as getModelPricing } from "./pricing-fetcher-DygIroMj.js";
3
- export { ModelPricing, calculateCostFromTokens, clearPricingCache, fetchModelPricing, getModelPricing };
1
+ import { ModelPricing, PricingFetcher } from "./pricing-fetcher-Dq-OLBp4.js";
2
+ export { ModelPricing, PricingFetcher };
@@ -1,5 +1,5 @@
1
- import "./dist-FwNhpFrW.js";
2
- import "./logger-DhDyJEC5.js";
3
- import { calculateCostFromTokens, clearPricingCache, fetchModelPricing, getModelPricing } from "./pricing-fetcher-BCv1Vods.js";
1
+ import "./dist-BEQ1tJCL.js";
2
+ import "./logger-DixU80sg.js";
3
+ import { PricingFetcher } from "./pricing-fetcher-BY3-ryVq.js";
4
4
 
5
- export { calculateCostFromTokens, clearPricingCache, fetchModelPricing, getModelPricing };
5
+ export { PricingFetcher };
@@ -1,4 +1,4 @@
1
- import process$1, { stdin, stdout } from "node:process";
1
+ import g$1, { stdin, stdout } from "node:process";
2
2
  import { WriteStream } from "node:tty";
3
3
  import f from "node:readline";
4
4
 
@@ -265,7 +265,7 @@ Object.keys(r.modifier);
265
265
  const tD = Object.keys(r.color), eD = Object.keys(r.bgColor);
266
266
  [...tD, ...eD];
267
267
  function sD() {
268
- const t = new Map();
268
+ const t = /* @__PURE__ */ new Map();
269
269
  for (const [u$1, F$1] of Object.entries(r)) {
270
270
  for (const [e$1, s] of Object.entries(F$1)) r[e$1] = {
271
271
  open: `\x1B[${s[0]}m`,
@@ -448,7 +448,7 @@ var AD = Object.defineProperty, pD = (t, u$1, F$1) => u$1 in t ? AD(t, u$1, {
448
448
  }) : t[u$1] = F$1, h = (t, u$1, F$1) => (pD(t, typeof u$1 != "symbol" ? u$1 + "" : u$1, F$1), F$1);
449
449
  var x = class {
450
450
  constructor(u$1, F$1 = true) {
451
- h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
451
+ h(this, "input"), h(this, "output"), h(this, "_abortSignal"), h(this, "rl"), h(this, "opts"), h(this, "_render"), h(this, "_track", false), h(this, "_prevFrame", ""), h(this, "_subscribers", /* @__PURE__ */ new Map()), h(this, "_cursor", 0), h(this, "state", "initial"), h(this, "error", ""), h(this, "value");
452
452
  const { input: e$1 = stdin, output: s = stdout, render: i, signal: D,...C$1 } = u$1;
453
453
  this.opts = C$1, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = F$1, this._abortSignal = D, this.input = e$1, this.output = s;
454
454
  }
@@ -650,7 +650,7 @@ var PD = class extends x {
650
650
  }
651
651
  };
652
652
  function ce() {
653
- return process$1.platform !== "win32" ? process$1.env.TERM !== "linux" : !!process$1.env.CI || !!process$1.env.WT_SESSION || !!process$1.env.TERMINUS_SUBLIME || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
653
+ return g$1.platform !== "win32" ? g$1.env.TERM !== "linux" : !!g$1.env.CI || !!g$1.env.WT_SESSION || !!g$1.env.TERMINUS_SUBLIME || g$1.env.ConEmuTask === "{cmd::Cmder}" || g$1.env.TERM_PROGRAM === "Terminus-Sublime" || g$1.env.TERM_PROGRAM === "vscode" || g$1.env.TERM === "xterm-256color" || g$1.env.TERM === "alacritty" || g$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
654
654
  }
655
655
  const V = ce(), u = (t, n) => V ? t : n, le = u("❯", ">"), L = u("■", "x"), W = u("▲", "x"), C = u("✔", "√"), o = u(""), d = u(""), k = u("●", ">"), P = u("○", " "), A = u("◻", "[•]"), T = u("◼", "[+]"), F = u("◻", "[ ]"), w = (t) => {
656
656
  switch (t) {
@@ -1,4 +1,4 @@
1
- import { tryImport } from "./index-CISmcbXk-BotItq1T.js";
1
+ import { tryImport } from "./index-CISmcbXk-x9eVmhGM.js";
2
2
 
3
3
  //#region node_modules/xsschema/dist/sury-DmrZ3_Oj.js
4
4
  const getToJsonSchemaFn = async () => {
@@ -2511,7 +2511,7 @@ var ZodDiscriminatedUnion = class ZodDiscriminatedUnion extends ZodType {
2511
2511
  * @param params
2512
2512
  */
2513
2513
  static create(discriminator, options, params) {
2514
- const optionsMap = new Map();
2514
+ const optionsMap = /* @__PURE__ */ new Map();
2515
2515
  for (const type of options) {
2516
2516
  const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2517
2517
  if (!discriminatorValues.length) throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
@@ -2749,7 +2749,7 @@ var ZodMap = class extends ZodType {
2749
2749
  };
2750
2750
  });
2751
2751
  if (ctx.common.async) {
2752
- const finalMap = new Map();
2752
+ const finalMap = /* @__PURE__ */ new Map();
2753
2753
  return Promise.resolve().then(async () => {
2754
2754
  for (const pair of pairs) {
2755
2755
  const key = await pair.key;
@@ -2764,7 +2764,7 @@ var ZodMap = class extends ZodType {
2764
2764
  };
2765
2765
  });
2766
2766
  } else {
2767
- const finalMap = new Map();
2767
+ const finalMap = /* @__PURE__ */ new Map();
2768
2768
  for (const pair of pairs) {
2769
2769
  const key = pair.key;
2770
2770
  const value = pair.value;
@@ -2827,7 +2827,7 @@ var ZodSet = class ZodSet extends ZodType {
2827
2827
  }
2828
2828
  const valueType = this._def.valueType;
2829
2829
  function finalizeSet(elements$1) {
2830
- const parsedSet = new Set();
2830
+ const parsedSet = /* @__PURE__ */ new Set();
2831
2831
  for (const element of elements$1) {
2832
2832
  if (element.status === "aborted") return INVALID;
2833
2833
  if (element.status === "dirty") status.dirty();
@@ -0,0 +1,10 @@
1
+ import { tryImport } from "./index-CISmcbXk-x9eVmhGM.js";
2
+
3
+ //#region node_modules/xsschema/dist/valibot-CQk-M5rL.js
4
+ const getToJsonSchemaFn = async () => {
5
+ const { toJsonSchema } = await tryImport(import("./dist-DAarI-SJ.js"), "@valibot/to-json-schema");
6
+ return (schema) => toJsonSchema(schema);
7
+ };
8
+
9
+ //#endregion
10
+ export { getToJsonSchemaFn };
@@ -1,4 +1,4 @@
1
- import { missingDependenciesUrl } from "./index-CISmcbXk-BotItq1T.js";
1
+ import { missingDependenciesUrl } from "./index-CISmcbXk-x9eVmhGM.js";
2
2
 
3
3
  //#region node_modules/xsschema/dist/zod-Db63SLXj.js
4
4
  const getToJsonSchemaFn = async () => {
@@ -9,13 +9,13 @@ const getToJsonSchemaFn = async () => {
9
9
  throw new Error(`xsschema: Missing zod v3 dependencies "zod-to-json-schema". see ${missingDependenciesUrl}`);
10
10
  };
11
11
  try {
12
- const { toJSONSchema } = await import("./core-BgFXUe_h.js");
12
+ const { toJSONSchema } = await import("./core-B0ovMhJe.js");
13
13
  zodV4toJSONSchema = toJSONSchema;
14
14
  } catch (err) {
15
15
  if (err instanceof Error) console.error(err.message);
16
16
  }
17
17
  try {
18
- const { zodToJsonSchema } = await import("./esm-vjyZjnpZ.js");
18
+ const { zodToJsonSchema } = await import("./esm-Dqsc1zmX.js");
19
19
  zodV3ToJSONSchema = zodToJsonSchema;
20
20
  } catch (err) {
21
21
  if (err instanceof Error) console.error(err.message);
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "ccusage",
3
- "version": "0.6.0",
3
+ "type": "module",
4
+ "version": "0.6.2",
4
5
  "description": "Usage analysis tool for Claude Code",
6
+ "author": "ryoppippi",
7
+ "license": "MIT",
8
+ "funding": "https://github.com/ryoppippi/ccusage?sponsor=1",
5
9
  "homepage": "https://github.com/ryoppippi/ccusage#readme",
6
- "bugs": {
7
- "url": "https://github.com/ryoppippi/ccusage/issues"
8
- },
9
10
  "repository": {
10
11
  "type": "git",
11
12
  "url": "git+https://github.com/ryoppippi/ccusage.git"
12
13
  },
13
- "funding": "https://github.com/ryoppippi/ccusage?sponsor=1",
14
- "license": "MIT",
15
- "author": "ryoppippi",
16
- "type": "module",
14
+ "bugs": {
15
+ "url": "https://github.com/ryoppippi/ccusage/issues"
16
+ },
17
17
  "exports": {
18
18
  ".": "./dist/index.js",
19
19
  "./calculate-cost": "./dist/calculate-cost.js",
@@ -22,9 +22,6 @@
22
22
  "./logger": "./dist/logger.js",
23
23
  "./mcp": "./dist/mcp.js",
24
24
  "./pricing-fetcher": "./dist/pricing-fetcher.js",
25
- "./shared-args": "./dist/shared-args.js",
26
- "./types": "./dist/types.js",
27
- "./utils": "./dist/utils.js",
28
25
  "./package.json": "./package.json"
29
26
  },
30
27
  "main": "./dist/index.js",
@@ -1,67 +0,0 @@
1
- import { ArraySchema, InferOutput, NumberSchema, ObjectSchema, OptionalSchema, RegexAction, SchemaWithPipe, StringSchema } from "./index-BurjgCfW.js";
2
- import { ModelPricing } from "./pricing-fetcher-DygIroMj.js";
3
- import { CostMode, SortOrder } from "./types-y1JQzaKZ.js";
4
-
5
- //#region src/data-loader.d.ts
6
- declare const getDefaultClaudePath: () => string;
7
- declare const UsageDataSchema: ObjectSchema<{
8
- readonly timestamp: StringSchema<undefined>;
9
- readonly version: OptionalSchema<StringSchema<undefined>, undefined>;
10
- readonly message: ObjectSchema<{
11
- readonly usage: ObjectSchema<{
12
- readonly input_tokens: NumberSchema<undefined>;
13
- readonly output_tokens: NumberSchema<undefined>;
14
- readonly cache_creation_input_tokens: OptionalSchema<NumberSchema<undefined>, undefined>;
15
- readonly cache_read_input_tokens: OptionalSchema<NumberSchema<undefined>, undefined>;
16
- }, undefined>;
17
- readonly model: OptionalSchema<StringSchema<undefined>, undefined>;
18
- }, undefined>;
19
- readonly costUSD: OptionalSchema<NumberSchema<undefined>, undefined>;
20
- }, undefined>;
21
- type UsageData = InferOutput<typeof UsageDataSchema>;
22
- declare const DailyUsageSchema: ObjectSchema<{
23
- readonly date: SchemaWithPipe<readonly [StringSchema<undefined>, RegexAction<string, undefined>]>;
24
- readonly inputTokens: NumberSchema<undefined>;
25
- readonly outputTokens: NumberSchema<undefined>;
26
- readonly cacheCreationTokens: NumberSchema<undefined>;
27
- readonly cacheReadTokens: NumberSchema<undefined>;
28
- readonly totalCost: NumberSchema<undefined>;
29
- }, undefined>;
30
- type DailyUsage = InferOutput<typeof DailyUsageSchema>;
31
- declare const SessionUsageSchema: ObjectSchema<{
32
- readonly sessionId: StringSchema<undefined>;
33
- readonly projectPath: StringSchema<undefined>;
34
- readonly inputTokens: NumberSchema<undefined>;
35
- readonly outputTokens: NumberSchema<undefined>;
36
- readonly cacheCreationTokens: NumberSchema<undefined>;
37
- readonly cacheReadTokens: NumberSchema<undefined>;
38
- readonly totalCost: NumberSchema<undefined>;
39
- readonly lastActivity: StringSchema<undefined>;
40
- readonly versions: ArraySchema<StringSchema<undefined>, undefined>;
41
- }, undefined>;
42
- type SessionUsage = InferOutput<typeof SessionUsageSchema>;
43
- declare const MonthlyUsageSchema: ObjectSchema<{
44
- readonly month: SchemaWithPipe<readonly [StringSchema<undefined>, RegexAction<string, undefined>]>;
45
- readonly inputTokens: NumberSchema<undefined>;
46
- readonly outputTokens: NumberSchema<undefined>;
47
- readonly cacheCreationTokens: NumberSchema<undefined>;
48
- readonly cacheReadTokens: NumberSchema<undefined>;
49
- readonly totalCost: NumberSchema<undefined>;
50
- }, undefined>;
51
- type MonthlyUsage = InferOutput<typeof MonthlyUsageSchema>;
52
- declare const formatDate: (dateStr: string) => string;
53
- declare const calculateCostForEntry: (data: UsageData, mode: CostMode, modelPricing: Record<string, ModelPricing>) => number;
54
- interface DateFilter {
55
- since?: string;
56
- until?: string;
57
- }
58
- interface LoadOptions extends DateFilter {
59
- claudePath?: string;
60
- mode?: CostMode;
61
- order?: SortOrder;
62
- }
63
- declare function loadDailyUsageData(options?: LoadOptions): Promise<DailyUsage[]>;
64
- declare function loadSessionData(options?: LoadOptions): Promise<SessionUsage[]>;
65
- declare function loadMonthlyUsageData(options?: LoadOptions): Promise<MonthlyUsage[]>;
66
- //#endregion
67
- export { DailyUsage, DailyUsageSchema as DailyUsageSchema$1, DateFilter, LoadOptions, MonthlyUsage, MonthlyUsageSchema as MonthlyUsageSchema$1, SessionUsage, SessionUsageSchema as SessionUsageSchema$1, UsageData, UsageDataSchema as UsageDataSchema$1, calculateCostForEntry as calculateCostForEntry$1, formatDate as formatDate$1, getDefaultClaudePath as getDefaultClaudePath$1, loadDailyUsageData as loadDailyUsageData$1, loadMonthlyUsageData as loadMonthlyUsageData$1, loadSessionData as loadSessionData$1 };