@revenium/claude-code-metering 0.1.0 → 0.1.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/CHANGELOG.md +22 -28
- package/README.md +321 -139
- package/dist/cli/commands/backfill.d.ts +98 -1
- package/dist/cli/commands/backfill.d.ts.map +1 -1
- package/dist/cli/commands/backfill.js +356 -146
- package/dist/cli/commands/backfill.js.map +1 -1
- package/dist/cli/commands/setup.d.ts +2 -0
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +55 -49
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +2 -11
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/test.d.ts.map +1 -1
- package/dist/cli/commands/test.js +23 -22
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +44 -30
- package/dist/cli/index.js.map +1 -1
- package/dist/core/api/client.d.ts +7 -6
- package/dist/core/api/client.d.ts.map +1 -1
- package/dist/core/api/client.js +52 -47
- package/dist/core/api/client.js.map +1 -1
- package/dist/core/config/loader.d.ts +5 -13
- package/dist/core/config/loader.d.ts.map +1 -1
- package/dist/core/config/loader.js +67 -46
- package/dist/core/config/loader.js.map +1 -1
- package/dist/core/config/validator.d.ts +5 -1
- package/dist/core/config/validator.d.ts.map +1 -1
- package/dist/core/config/validator.js +37 -22
- package/dist/core/config/validator.js.map +1 -1
- package/dist/core/config/writer.d.ts +1 -1
- package/dist/core/config/writer.d.ts.map +1 -1
- package/dist/core/config/writer.js +76 -72
- package/dist/core/config/writer.js.map +1 -1
- package/dist/core/shell/detector.d.ts +8 -1
- package/dist/core/shell/detector.d.ts.map +1 -1
- package/dist/core/shell/detector.js +38 -24
- package/dist/core/shell/detector.js.map +1 -1
- package/dist/core/shell/profile-updater.d.ts +1 -1
- package/dist/core/shell/profile-updater.d.ts.map +1 -1
- package/dist/core/shell/profile-updater.js +40 -27
- package/dist/core/shell/profile-updater.js.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +18 -23
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +21 -21
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/hashing.d.ts +18 -0
- package/dist/utils/hashing.d.ts.map +1 -0
- package/dist/utils/hashing.js +27 -0
- package/dist/utils/hashing.js.map +1 -0
- package/package.json +6 -3
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SubscriptionTier } from
|
|
1
|
+
import type { SubscriptionTier } from "../utils/constants.js";
|
|
2
2
|
/**
|
|
3
3
|
* Configuration stored in ~/.claude/revenium.env
|
|
4
4
|
*/
|
|
@@ -33,7 +33,7 @@ export interface HealthCheckResult {
|
|
|
33
33
|
/**
|
|
34
34
|
* Shell types supported for profile updates
|
|
35
35
|
*/
|
|
36
|
-
export type ShellType =
|
|
36
|
+
export type ShellType = "bash" | "zsh" | "fish" | "unknown";
|
|
37
37
|
/**
|
|
38
38
|
* Result of shell profile update
|
|
39
39
|
*/
|
|
@@ -44,33 +44,28 @@ export interface ShellUpdateResult {
|
|
|
44
44
|
message: string;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
* Uses OTEL metrics format with sum datapoints for token counts
|
|
49
|
-
* Sent to: POST /meter/v2/otel/v1/metrics
|
|
47
|
+
* OTLP log payload structure (matching backend expectations)
|
|
50
48
|
*/
|
|
51
|
-
export interface
|
|
52
|
-
|
|
49
|
+
export interface OTLPLogsPayload {
|
|
50
|
+
resourceLogs: Array<{
|
|
53
51
|
resource?: {
|
|
54
52
|
attributes?: Array<{
|
|
55
53
|
key: string;
|
|
56
54
|
value: OTLPValue;
|
|
57
55
|
}>;
|
|
58
56
|
};
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
scopeLogs: Array<{
|
|
58
|
+
scope?: {
|
|
61
59
|
name: string;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
asDouble?: number;
|
|
72
|
-
}>;
|
|
73
|
-
};
|
|
60
|
+
version: string;
|
|
61
|
+
};
|
|
62
|
+
logRecords: Array<{
|
|
63
|
+
timeUnixNano?: string;
|
|
64
|
+
body: OTLPValue;
|
|
65
|
+
attributes: Array<{
|
|
66
|
+
key: string;
|
|
67
|
+
value: OTLPValue;
|
|
68
|
+
}>;
|
|
74
69
|
}>;
|
|
75
70
|
}>;
|
|
76
71
|
}>;
|
|
@@ -85,12 +80,12 @@ export interface OTLPValue {
|
|
|
85
80
|
boolValue?: boolean;
|
|
86
81
|
}
|
|
87
82
|
/**
|
|
88
|
-
* Response from
|
|
83
|
+
* Response from OTLP endpoint
|
|
89
84
|
*/
|
|
90
85
|
export interface OTLPResponse {
|
|
91
86
|
id: string;
|
|
92
87
|
resourceType: string;
|
|
93
|
-
|
|
88
|
+
processedEvents: number;
|
|
94
89
|
created: string;
|
|
95
90
|
}
|
|
96
91
|
//# 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,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,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AAE,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
|
|
7
|
-
export declare const OTLP_PATH = "/meter/v2/
|
|
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,
|
|
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,EAE1B,aAAa,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAE1D,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"}
|
package/dist/utils/constants.js
CHANGED
|
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ENV_VARS = exports.SUBSCRIPTION_TIERS = exports.SUBSCRIPTION_TIER_CONFIG = exports.CONFIG_FILE_MODE = exports.REVENIUM_ENV_FILE = exports.CLAUDE_CONFIG_DIR = exports.API_KEY_PREFIX = exports.OTLP_PATH = exports.DEFAULT_REVENIUM_URL = void 0;
|
|
7
7
|
exports.getCostMultiplier = getCostMultiplier;
|
|
8
8
|
/** Default Revenium API base URL */
|
|
9
|
-
exports.DEFAULT_REVENIUM_URL =
|
|
10
|
-
/** Path appended to base URL for
|
|
11
|
-
exports.OTLP_PATH =
|
|
9
|
+
exports.DEFAULT_REVENIUM_URL = "https://api.revenium.ai";
|
|
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
|
-
exports.API_KEY_PREFIX =
|
|
13
|
+
exports.API_KEY_PREFIX = "hak_";
|
|
14
14
|
/** Directory for Claude Code configuration */
|
|
15
|
-
exports.CLAUDE_CONFIG_DIR =
|
|
15
|
+
exports.CLAUDE_CONFIG_DIR = ".claude";
|
|
16
16
|
/** Filename for Revenium environment configuration */
|
|
17
|
-
exports.REVENIUM_ENV_FILE =
|
|
17
|
+
exports.REVENIUM_ENV_FILE = "revenium.env";
|
|
18
18
|
/** File permissions for config file (owner read/write only) */
|
|
19
19
|
exports.CONFIG_FILE_MODE = 0o600;
|
|
20
20
|
/** Available subscription tiers with their cost multipliers
|
|
@@ -29,27 +29,27 @@ exports.CONFIG_FILE_MODE = 0o600;
|
|
|
29
29
|
*/
|
|
30
30
|
exports.SUBSCRIPTION_TIER_CONFIG = {
|
|
31
31
|
pro: {
|
|
32
|
-
name:
|
|
32
|
+
name: "Pro (~$20 USD/month or local equivalent)",
|
|
33
33
|
multiplier: 0.16, // $20 / $125 API equivalent = 16%
|
|
34
34
|
},
|
|
35
35
|
max_5x: {
|
|
36
|
-
name:
|
|
36
|
+
name: "Max 5x (~$100 USD/month or local equivalent)",
|
|
37
37
|
multiplier: 0.16, // $100 / $625 API equivalent = 16%
|
|
38
38
|
},
|
|
39
39
|
max_20x: {
|
|
40
|
-
name:
|
|
40
|
+
name: "Max 20x (~$200 USD/month or local equivalent)",
|
|
41
41
|
multiplier: 0.08, // $200 / $2,500 API equivalent = 8% (baseline from real data)
|
|
42
42
|
},
|
|
43
43
|
team_premium: {
|
|
44
|
-
name:
|
|
44
|
+
name: "Team Premium (~$150 USD/seat or local equivalent)",
|
|
45
45
|
multiplier: 0.24, // $150 / $625 API equivalent = 24%
|
|
46
46
|
},
|
|
47
47
|
enterprise: {
|
|
48
|
-
name:
|
|
48
|
+
name: "Enterprise (custom)",
|
|
49
49
|
multiplier: 0.05, // Custom pricing with best discounts
|
|
50
50
|
},
|
|
51
51
|
api: {
|
|
52
|
-
name:
|
|
52
|
+
name: "API (no subscription)",
|
|
53
53
|
multiplier: 1.0, // Full API pricing
|
|
54
54
|
},
|
|
55
55
|
};
|
|
@@ -60,14 +60,14 @@ function getCostMultiplier(tier) {
|
|
|
60
60
|
}
|
|
61
61
|
/** Environment variable names */
|
|
62
62
|
exports.ENV_VARS = {
|
|
63
|
-
TELEMETRY_ENABLED:
|
|
64
|
-
OTLP_ENDPOINT:
|
|
65
|
-
OTLP_HEADERS:
|
|
66
|
-
OTLP_PROTOCOL:
|
|
67
|
-
SUBSCRIBER_EMAIL:
|
|
68
|
-
SUBSCRIPTION:
|
|
69
|
-
COST_MULTIPLIER:
|
|
70
|
-
ORGANIZATION_ID:
|
|
71
|
-
PRODUCT_ID:
|
|
63
|
+
TELEMETRY_ENABLED: "CLAUDE_CODE_ENABLE_TELEMETRY",
|
|
64
|
+
OTLP_ENDPOINT: "OTEL_EXPORTER_OTLP_ENDPOINT",
|
|
65
|
+
OTLP_HEADERS: "OTEL_EXPORTER_OTLP_HEADERS",
|
|
66
|
+
OTLP_PROTOCOL: "OTEL_EXPORTER_OTLP_PROTOCOL",
|
|
67
|
+
SUBSCRIBER_EMAIL: "REVENIUM_SUBSCRIBER_EMAIL",
|
|
68
|
+
SUBSCRIPTION: "CLAUDE_CODE_SUBSCRIPTION",
|
|
69
|
+
COST_MULTIPLIER: "CLAUDE_CODE_COST_MULTIPLIER",
|
|
70
|
+
ORGANIZATION_ID: "REVENIUM_ORGANIZATION_ID",
|
|
71
|
+
PRODUCT_ID: "REVENIUM_PRODUCT_ID",
|
|
72
72
|
};
|
|
73
73
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAgEH,8CAEC;AAhED,oCAAoC;AACvB,QAAA,oBAAoB,GAAG,yBAAyB,CAAC;AAE9D,kDAAkD;AACrC,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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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.
|
|
3
|
+
"version": "0.1.1",
|
|
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": ">=
|
|
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": "^
|
|
62
|
+
"vitest": "^4.0.17"
|
|
60
63
|
}
|
|
61
64
|
}
|