@revenium/claude-code-metering 0.1.0 → 0.1.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 (59) hide show
  1. package/CHANGELOG.md +22 -28
  2. package/README.md +323 -139
  3. package/dist/cli/commands/backfill.d.ts +106 -1
  4. package/dist/cli/commands/backfill.d.ts.map +1 -1
  5. package/dist/cli/commands/backfill.js +359 -146
  6. package/dist/cli/commands/backfill.js.map +1 -1
  7. package/dist/cli/commands/setup.d.ts +2 -0
  8. package/dist/cli/commands/setup.d.ts.map +1 -1
  9. package/dist/cli/commands/setup.js +55 -49
  10. package/dist/cli/commands/setup.js.map +1 -1
  11. package/dist/cli/commands/status.d.ts.map +1 -1
  12. package/dist/cli/commands/status.js +23 -30
  13. package/dist/cli/commands/status.js.map +1 -1
  14. package/dist/cli/commands/test.d.ts.map +1 -1
  15. package/dist/cli/commands/test.js +4 -3
  16. package/dist/cli/commands/test.js.map +1 -1
  17. package/dist/cli/index.d.ts +2 -1
  18. package/dist/cli/index.d.ts.map +1 -1
  19. package/dist/cli/index.js +44 -30
  20. package/dist/cli/index.js.map +1 -1
  21. package/dist/core/api/client.d.ts +17 -8
  22. package/dist/core/api/client.d.ts.map +1 -1
  23. package/dist/core/api/client.js +58 -49
  24. package/dist/core/api/client.js.map +1 -1
  25. package/dist/core/config/loader.d.ts +5 -13
  26. package/dist/core/config/loader.d.ts.map +1 -1
  27. package/dist/core/config/loader.js +70 -46
  28. package/dist/core/config/loader.js.map +1 -1
  29. package/dist/core/config/validator.d.ts +5 -1
  30. package/dist/core/config/validator.d.ts.map +1 -1
  31. package/dist/core/config/validator.js +37 -22
  32. package/dist/core/config/validator.js.map +1 -1
  33. package/dist/core/config/writer.d.ts +1 -1
  34. package/dist/core/config/writer.d.ts.map +1 -1
  35. package/dist/core/config/writer.js +82 -74
  36. package/dist/core/config/writer.js.map +1 -1
  37. package/dist/core/shell/detector.d.ts +8 -1
  38. package/dist/core/shell/detector.d.ts.map +1 -1
  39. package/dist/core/shell/detector.js +38 -24
  40. package/dist/core/shell/detector.js.map +1 -1
  41. package/dist/core/shell/profile-updater.d.ts +1 -1
  42. package/dist/core/shell/profile-updater.d.ts.map +1 -1
  43. package/dist/core/shell/profile-updater.js +40 -27
  44. package/dist/core/shell/profile-updater.js.map +1 -1
  45. package/dist/index.d.ts +1 -0
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +1 -0
  48. package/dist/index.js.map +1 -1
  49. package/dist/types/index.d.ts +30 -25
  50. package/dist/types/index.d.ts.map +1 -1
  51. package/dist/utils/constants.d.ts +2 -2
  52. package/dist/utils/constants.d.ts.map +1 -1
  53. package/dist/utils/constants.js +2 -2
  54. package/dist/utils/constants.js.map +1 -1
  55. package/dist/utils/hashing.d.ts +18 -0
  56. package/dist/utils/hashing.d.ts.map +1 -0
  57. package/dist/utils/hashing.js +27 -0
  58. package/dist/utils/hashing.js.map +1 -0
  59. package/package.json +6 -3
@@ -7,8 +7,8 @@ const node_fs_1 = require("node:fs");
7
7
  const detector_js_1 = require("./detector.js");
8
8
  const writer_js_1 = require("../config/writer.js");
9
9
  /** Marker comment to identify our configuration block */
10
- const CONFIG_MARKER_START = '# >>> revenium-claude-code-metering >>>';
11
- const CONFIG_MARKER_END = '# <<< revenium-claude-code-metering <<<';
10
+ const CONFIG_MARKER_START = "# >>> revenium-claude-code-metering >>>";
11
+ const CONFIG_MARKER_END = "# <<< revenium-claude-code-metering <<<";
12
12
  /**
13
13
  * Checks if the shell profile already has the Revenium source command.
14
14
  */
@@ -16,7 +16,7 @@ async function hasReveniumConfig(profilePath) {
16
16
  if (!(0, node_fs_1.existsSync)(profilePath)) {
17
17
  return false;
18
18
  }
19
- const content = await (0, promises_1.readFile)(profilePath, 'utf-8');
19
+ const content = await (0, promises_1.readFile)(profilePath, "utf-8");
20
20
  return content.includes(CONFIG_MARKER_START);
21
21
  }
22
22
  /**
@@ -36,8 +36,10 @@ function removeExistingConfig(content) {
36
36
  return content;
37
37
  }
38
38
  const before = content.substring(0, startIndex).trimEnd();
39
- const after = content.substring(endIndex + CONFIG_MARKER_END.length).trimStart();
40
- return before + (after ? '\n' + after : '');
39
+ const after = content
40
+ .substring(endIndex + CONFIG_MARKER_END.length)
41
+ .trimStart();
42
+ return before + (after ? "\n" + after : "");
41
43
  }
42
44
  /**
43
45
  * Updates the shell profile to source the Revenium configuration file.
@@ -45,11 +47,11 @@ function removeExistingConfig(content) {
45
47
  */
46
48
  async function updateShellProfile() {
47
49
  const shellType = (0, detector_js_1.detectShell)();
48
- if (shellType === 'unknown') {
50
+ if (shellType === "unknown") {
49
51
  return {
50
52
  success: false,
51
53
  shellType,
52
- message: 'Could not detect shell type. Please manually add the source command to your shell profile.',
54
+ message: "Could not detect shell type. Please manually add the source command to your shell profile.",
53
55
  };
54
56
  }
55
57
  const profilePath = (0, detector_js_1.getProfilePath)(shellType);
@@ -61,33 +63,44 @@ async function updateShellProfile() {
61
63
  };
62
64
  }
63
65
  const configPath = (0, writer_js_1.getConfigFilePath)();
64
- // Check if already configured
65
- if (await hasReveniumConfig(profilePath)) {
66
- // Remove existing and re-add (in case config path changed)
67
- let content = await (0, promises_1.readFile)(profilePath, 'utf-8');
68
- content = removeExistingConfig(content);
66
+ try {
67
+ // Check if already configured
68
+ if (await hasReveniumConfig(profilePath)) {
69
+ // Remove existing and re-add (in case config path changed)
70
+ let content = await (0, promises_1.readFile)(profilePath, "utf-8");
71
+ content = removeExistingConfig(content);
72
+ const configBlock = generateConfigBlock(shellType, configPath);
73
+ await (0, promises_1.writeFile)(profilePath, content + configBlock, "utf-8");
74
+ return {
75
+ success: true,
76
+ shellType,
77
+ profilePath,
78
+ message: `Updated existing configuration in ${profilePath}`,
79
+ };
80
+ }
81
+ // Add new configuration
82
+ let content = "";
83
+ if ((0, node_fs_1.existsSync)(profilePath)) {
84
+ content = await (0, promises_1.readFile)(profilePath, "utf-8");
85
+ }
69
86
  const configBlock = generateConfigBlock(shellType, configPath);
70
- await (0, promises_1.writeFile)(profilePath, content + configBlock, 'utf-8');
87
+ await (0, promises_1.writeFile)(profilePath, content + configBlock, "utf-8");
71
88
  return {
72
89
  success: true,
73
90
  shellType,
74
91
  profilePath,
75
- message: `Updated existing configuration in ${profilePath}`,
92
+ message: `Added configuration to ${profilePath}`,
76
93
  };
77
94
  }
78
- // Add new configuration
79
- let content = '';
80
- if ((0, node_fs_1.existsSync)(profilePath)) {
81
- content = await (0, promises_1.readFile)(profilePath, 'utf-8');
95
+ catch (error) {
96
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
97
+ return {
98
+ success: false,
99
+ shellType,
100
+ profilePath,
101
+ message: `Failed to update shell profile: ${errorMessage}`,
102
+ };
82
103
  }
83
- const configBlock = generateConfigBlock(shellType, configPath);
84
- await (0, promises_1.writeFile)(profilePath, content + configBlock, 'utf-8');
85
- return {
86
- success: true,
87
- shellType,
88
- profilePath,
89
- message: `Added configuration to ${profilePath}`,
90
- };
91
104
  }
92
105
  /**
93
106
  * Gets instructions for manual shell profile configuration.
@@ -96,6 +109,6 @@ function getManualInstructions(shellType) {
96
109
  const configPath = (0, writer_js_1.getConfigFilePath)();
97
110
  const sourceCmd = (0, detector_js_1.getSourceCommand)(shellType, configPath);
98
111
  const profilePath = (0, detector_js_1.getProfilePath)(shellType);
99
- return `Add the following to ${profilePath || 'your shell profile'}:\n\n${sourceCmd}`;
112
+ return `Add the following to ${profilePath || "your shell profile"}:\n\n${sourceCmd}`;
100
113
  }
101
114
  //# sourceMappingURL=profile-updater.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"profile-updater.js","sourceRoot":"","sources":["../../../src/core/shell/profile-updater.ts"],"names":[],"mappings":";;AAmDA,gDAuDC;AAKD,sDAMC;AArHD,+CAAuD;AACvD,qCAAqC;AAErC,+CAA8E;AAC9E,mDAAwD;AAExD,yDAAyD;AACzD,MAAM,mBAAmB,GAAG,yCAAyC,CAAC;AACtE,MAAM,iBAAiB,GAAG,yCAAyC,CA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,GAAG,IAAA,8BAAgB,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,IAAA,4BAAc,EAAC,SAAS,CAAC,CAAC;IAE9C,OAAO,wBAAwB,WAAW,IAAI,oBAAoB,QAAQ,SAAS,EAAE,CAAC;AACxF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './types/index.js';
2
2
  export * from './utils/constants.js';
3
+ export * from './utils/hashing.js';
3
4
  export * from './utils/masking.js';
4
5
  export * from './core/config/loader.js';
5
6
  export * from './core/config/writer.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // Re-export types and utilities for programmatic use
18
18
  __exportStar(require("./types/index.js"), exports);
19
19
  __exportStar(require("./utils/constants.js"), exports);
20
+ __exportStar(require("./utils/hashing.js"), exports);
20
21
  __exportStar(require("./utils/masking.js"), exports);
21
22
  __exportStar(require("./core/config/loader.js"), exports);
22
23
  __exportStar(require("./core/config/writer.js"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,mDAAiC;AACjC,uDAAqC;AACrC,qDAAmC;AACnC,0DAAwC;AACxC,0DAAwC;AACxC,6DAA2C;AAC3C,uDAAqC;AACrC,2DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAqD;AACrD,mDAAiC;AACjC,uDAAqC;AACrC,qDAAmC;AACnC,qDAAmC;AACnC,0DAAwC;AACxC,0DAAwC;AACxC,6DAA2C;AAC3C,uDAAqC;AACrC,2DAAyC"}
@@ -1,4 +1,4 @@
1
- import type { SubscriptionTier } from '../utils/constants.js';
1
+ import type { SubscriptionTier } from "../utils/constants.js";
2
2
  /**
3
3
  * Configuration stored in ~/.claude/revenium.env
4
4
  */
@@ -9,9 +9,19 @@ export interface ReveniumConfig {
9
9
  subscriptionTier?: SubscriptionTier;
10
10
  /** Optional override for the cost multiplier (overrides tier default) */
11
11
  costMultiplierOverride?: number;
12
- /** Optional organization ID for attributing costs to a specific customer/company */
12
+ /** Optional organization name for attributing costs to a specific customer/company */
13
+ organizationName?: string;
14
+ /**
15
+ * @deprecated Use organizationName instead. This field will be removed in a future version.
16
+ * Organization or company identifier
17
+ */
13
18
  organizationId?: string;
14
- /** Optional product ID for attributing costs to a specific product/project */
19
+ /** Optional product name for attributing costs to a specific product/project */
20
+ productName?: string;
21
+ /**
22
+ * @deprecated Use productName instead. This field will be removed in a future version.
23
+ * Product or application identifier
24
+ */
15
25
  productId?: string;
16
26
  }
17
27
  /**
@@ -33,7 +43,7 @@ export interface HealthCheckResult {
33
43
  /**
34
44
  * Shell types supported for profile updates
35
45
  */
36
- export type ShellType = 'bash' | 'zsh' | 'fish' | 'unknown';
46
+ export type ShellType = "bash" | "zsh" | "fish" | "unknown";
37
47
  /**
38
48
  * Result of shell profile update
39
49
  */
@@ -44,33 +54,28 @@ export interface ShellUpdateResult {
44
54
  message: string;
45
55
  }
46
56
  /**
47
- * OTEL metrics payload structure (matching backend expectations)
48
- * Uses OTEL metrics format with sum datapoints for token counts
49
- * Sent to: POST /meter/v2/otel/v1/metrics
57
+ * OTLP log payload structure (matching backend expectations)
50
58
  */
51
- export interface OTLPMetricsPayload {
52
- resourceMetrics: Array<{
59
+ export interface OTLPLogsPayload {
60
+ resourceLogs: Array<{
53
61
  resource?: {
54
62
  attributes?: Array<{
55
63
  key: string;
56
64
  value: OTLPValue;
57
65
  }>;
58
66
  };
59
- scopeMetrics: Array<{
60
- metrics: Array<{
67
+ scopeLogs: Array<{
68
+ scope?: {
61
69
  name: string;
62
- unit?: string;
63
- sum: {
64
- dataPoints: Array<{
65
- attributes?: Array<{
66
- key: string;
67
- value: OTLPValue;
68
- }>;
69
- timeUnixNano?: string;
70
- asInt?: number;
71
- asDouble?: number;
72
- }>;
73
- };
70
+ version: string;
71
+ };
72
+ logRecords: Array<{
73
+ timeUnixNano?: string;
74
+ body: OTLPValue;
75
+ attributes: Array<{
76
+ key: string;
77
+ value: OTLPValue;
78
+ }>;
74
79
  }>;
75
80
  }>;
76
81
  }>;
@@ -85,12 +90,12 @@ export interface OTLPValue {
85
90
  boolValue?: boolean;
86
91
  }
87
92
  /**
88
- * Response from OTEL metrics endpoint
93
+ * Response from OTLP endpoint
89
94
  */
90
95
  export interface OTLPResponse {
91
96
  id: string;
92
97
  resourceType: string;
93
- processedMetrics: number;
98
+ processedEvents: number;
94
99
  created: string;
95
100
  }
96
101
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,cAA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AE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -3,8 +3,8 @@
3
3
  */
4
4
  /** Default Revenium API base URL */
5
5
  export declare const DEFAULT_REVENIUM_URL = "https://api.revenium.ai";
6
- /** Path appended to base URL for OTEL metrics endpoint */
7
- export declare const OTLP_PATH = "/meter/v2/otel";
6
+ /** Path appended to base URL for OTLP endpoint */
7
+ export declare const OTLP_PATH = "/meter/v2/otlp";
8
8
  /** API key prefix required for valid Revenium API keys */
9
9
  export declare const API_KEY_PREFIX = "hak_";
10
10
  /** Directory for Claude Code configuration */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oCAAoC;AACpC,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAE9D,0DAA0D;AAC1D,eAAO,MAAM,SAAS,mBAAmB,CAAC;AAE1C,0DAA0D;AAC1D,eAAO,MAAM,cAAc,SAAS,CAAC;AAErC,8CAA8C;AAC9C,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,MAAQ,CAAC;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;CAyB3B,CAAC;AAEX,eAAO,MAAM,kBAAkB,EAA4C,aAAa,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAEhI,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,wBAAwB,CAAC;AAErE,+CAA+C;AAC/C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAEhE;AAED,iCAAiC;AACjC,eAAO,MAAM,QAAQ;;;;;;;;;;CAUX,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oCAAoC;AACpC,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAE9D,kDAAkD;AAClD,eAAO,MAAM,SAAS,mBAAmB,CAAC;AAE1C,0DAA0D;AAC1D,eAAO,MAAM,cAAc,SAAS,CAAC;AAErC,8CAA8C;AAC9C,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,MAAQ,CAAC;AAEtC;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;CAyB3B,CAAC;AAEX,eAAO,MAAM,kBAAkB,EAA4C,aAAa,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAEhI,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,wBAAwB,CAAC;AAErE,+CAA+C;AAC/C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAEhE;AAED,iCAAiC;AACjC,eAAO,MAAM,QAAQ;;;;;;;;;;CAUX,CAAC"}
@@ -7,8 +7,8 @@ exports.ENV_VARS = exports.SUBSCRIPTION_TIERS = exports.SUBSCRIPTION_TIER_CONFIG
7
7
  exports.getCostMultiplier = getCostMultiplier;
8
8
  /** Default Revenium API base URL */
9
9
  exports.DEFAULT_REVENIUM_URL = 'https://api.revenium.ai';
10
- /** Path appended to base URL for OTEL metrics endpoint */
11
- exports.OTLP_PATH = '/meter/v2/otel';
10
+ /** Path appended to base URL for OTLP endpoint */
11
+ exports.OTLP_PATH = '/meter/v2/otlp';
12
12
  /** API key prefix required for valid Revenium API keys */
13
13
  exports.API_KEY_PREFIX = 'hak_';
14
14
  /** Directory for Claude Code configuration */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA8DH,8CAEC;AA9DD,oCAAoC;AACvB,QAAA,oBAAoB,GAAG,yBAAyB,CAAC;AAE9D,0DAA0D;AAC7C,QAAA,SAAS,GAAG,gBAAgB,CAAC;AAE1C,0DAA0D;AAC7C,QAAA,cAAc,GAAG,MAAM,CAAC;AAErC,8CAA8C;AACjC,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAE3C,sDAAsD;AACzC,QAAA,iBAAiB,GAAG,cAAc,CAAC;AAEhD,+DAA+D;AAClD,QAAA,gBAAgB,GAAG,KAAK,CAAC;AAEtC;;;;;;;;;GASG;AACU,QAAA,wBAAwB,GAAG;IACtC,GAAG,EAAE;QACH,IAAI,EAAE,0CAA0C;QAChD,UAAU,EAAE,IAAI,EAAE,kCAAkC;KACrD;IACD,MAAM,EAAE;QACN,IAAI,EAAE,8CAA8C;QACpD,UAAU,EAAE,IAAI,EAAE,mCAAmC;KACtD;IACD,OAAO,EAAE;QACP,IAAI,EAAE,+CAA+C;QACrD,UAAU,EAAE,IAAI,EAAE,8DAA8D;KACjF;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,mDAAmD;QACzD,UAAU,EAAE,IAAI,EAAE,mCAAmC;KACtD;IACD,UAAU,EAAE;QACV,IAAI,EAAE,qBAAqB;QAC3B,UAAU,EAAE,IAAI,EAAE,qCAAqC;KACxD;IACD,GAAG,EAAE;QACH,IAAI,EAAE,uBAAuB;QAC7B,UAAU,EAAE,GAAG,EAAE,mBAAmB;KACrC;CACO,CAAC;AAEE,QAAA,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,gCAAwB,CA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,EAAE,mCAAmC;KACtD;IACD,UAAU,EAAE;QACV,IAAI,EAAE,qBAAqB;QAC3B,UAAU,EAAE,IAAI,EAAE,qCAAqC;KACxD;IACD,GAAG,EAAE;QACH,IAAI,EAAE,uBAAuB;QAC7B,UAAU,EAAE,GAAG,EAAE,mBAAmB;KACrC;CACO,CAAC;AAEE,QAAA,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAAC,gCAAwB,CAAyD,CAAC;AAIhI,+CAA+C;AAC/C,SAAgB,iBAAiB,CAAC,IAAsB;IACtD,OAAO,gCAAwB,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;AACnD,CAAC;AAED,iCAAiC;AACpB,QAAA,QAAQ,GAAG;IACtB,iBAAiB,EAAE,8BAA8B;IACjD,aAAa,EAAE,6BAA6B;IAC5C,YAAY,EAAE,4BAA4B;IAC1C,aAAa,EAAE,6BAA6B;IAC5C,gBAAgB,EAAE,2BAA2B;IAC7C,YAAY,EAAE,0BAA0B;IACxC,eAAe,EAAE,6BAA6B;IAC9C,eAAe,EAAE,0BAA0B;IAC3C,UAAU,EAAE,qBAAqB;CACzB,CAAC"}
@@ -0,0 +1,18 @@
1
+ export interface TransactionIdComponents {
2
+ sessionId: string;
3
+ timestamp: string;
4
+ model: string;
5
+ inputTokens: number;
6
+ outputTokens: number;
7
+ cacheReadTokens: number;
8
+ cacheCreationTokens: number;
9
+ }
10
+ /**
11
+ * Generates a deterministic transaction ID from record components.
12
+ * Uses SHA-256 hash truncated to 32 hex characters.
13
+ *
14
+ * IMPORTANT: This formula must match ClaudeCodeMapper.kt in the backend.
15
+ * Format: sessionId|timestamp|model|input|output|cacheRead|cacheCreation
16
+ */
17
+ export declare function generateTransactionId(components: TransactionIdComponents): string;
18
+ //# sourceMappingURL=hashing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashing.d.ts","sourceRoot":"","sources":["../../src/utils/hashing.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,uBAAuB,GAAG,MAAM,CAejF"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateTransactionId = generateTransactionId;
4
+ const node_crypto_1 = require("node:crypto");
5
+ /**
6
+ * Generates a deterministic transaction ID from record components.
7
+ * Uses SHA-256 hash truncated to 32 hex characters.
8
+ *
9
+ * IMPORTANT: This formula must match ClaudeCodeMapper.kt in the backend.
10
+ * Format: sessionId|timestamp|model|input|output|cacheRead|cacheCreation
11
+ */
12
+ function generateTransactionId(components) {
13
+ const input = [
14
+ components.sessionId,
15
+ components.timestamp,
16
+ components.model,
17
+ components.inputTokens,
18
+ components.outputTokens,
19
+ components.cacheReadTokens,
20
+ components.cacheCreationTokens,
21
+ ].join('|');
22
+ return (0, node_crypto_1.createHash)('sha256')
23
+ .update(input)
24
+ .digest('hex')
25
+ .substring(0, 32);
26
+ }
27
+ //# sourceMappingURL=hashing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashing.js","sourceRoot":"","sources":["../../src/utils/hashing.ts"],"names":[],"mappings":";;AAmBA,sDAeC;AAlCD,6CAAyC;AAYzC;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,UAAmC;IACvE,MAAM,KAAK,GAAG;QACZ,UAAU,CAAC,SAAS;QACpB,UAAU,CAAC,SAAS;QACpB,UAAU,CAAC,KAAK;QAChB,UAAU,CAAC,WAAW;QACtB,UAAU,CAAC,YAAY;QACvB,UAAU,CAAC,eAAe;QAC1B,UAAU,CAAC,mBAAmB;KAC/B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEZ,OAAO,IAAA,wBAAU,EAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,KAAK,CAAC;SACb,MAAM,CAAC,KAAK,CAAC;SACb,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACtB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenium/claude-code-metering",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "CLI tool to configure Claude Code telemetry export to Revenium",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -42,7 +42,7 @@
42
42
  "CHANGELOG.md"
43
43
  ],
44
44
  "engines": {
45
- "node": ">=18.0.0"
45
+ "node": ">=20.0.0"
46
46
  },
47
47
  "dependencies": {
48
48
  "chalk": "^5.3.0",
@@ -53,9 +53,12 @@
53
53
  "devDependencies": {
54
54
  "@types/inquirer": "^9.0.7",
55
55
  "@types/node": "^20.17.12",
56
+ "@typescript-eslint/eslint-plugin": "^8.53.0",
57
+ "@typescript-eslint/parser": "^8.53.0",
58
+ "@vitest/coverage-v8": "^4.0.17",
56
59
  "eslint": "^8.57.1",
57
60
  "prettier": "^3.4.2",
58
61
  "typescript": "^5.7.2",
59
- "vitest": "^2.1.8"
62
+ "vitest": "^4.0.17"
60
63
  }
61
64
  }