@revenium/claude-code-metering 0.1.0

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 (64) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/LICENSE +21 -0
  3. package/README.md +274 -0
  4. package/dist/cli/commands/backfill.d.ts +11 -0
  5. package/dist/cli/commands/backfill.d.ts.map +1 -0
  6. package/dist/cli/commands/backfill.js +390 -0
  7. package/dist/cli/commands/backfill.js.map +1 -0
  8. package/dist/cli/commands/setup.d.ts +13 -0
  9. package/dist/cli/commands/setup.d.ts.map +1 -0
  10. package/dist/cli/commands/setup.js +177 -0
  11. package/dist/cli/commands/setup.js.map +1 -0
  12. package/dist/cli/commands/status.d.ts +5 -0
  13. package/dist/cli/commands/status.d.ts.map +1 -0
  14. package/dist/cli/commands/status.js +95 -0
  15. package/dist/cli/commands/status.js.map +1 -0
  16. package/dist/cli/commands/test.d.ts +9 -0
  17. package/dist/cli/commands/test.d.ts.map +1 -0
  18. package/dist/cli/commands/test.js +67 -0
  19. package/dist/cli/commands/test.js.map +1 -0
  20. package/dist/cli/index.d.ts +3 -0
  21. package/dist/cli/index.d.ts.map +1 -0
  22. package/dist/cli/index.js +65 -0
  23. package/dist/cli/index.js.map +1 -0
  24. package/dist/core/api/client.d.ts +28 -0
  25. package/dist/core/api/client.d.ts.map +1 -0
  26. package/dist/core/api/client.js +127 -0
  27. package/dist/core/api/client.js.map +1 -0
  28. package/dist/core/config/loader.d.ts +35 -0
  29. package/dist/core/config/loader.d.ts.map +1 -0
  30. package/dist/core/config/loader.js +162 -0
  31. package/dist/core/config/loader.js.map +1 -0
  32. package/dist/core/config/validator.d.ts +19 -0
  33. package/dist/core/config/validator.d.ts.map +1 -0
  34. package/dist/core/config/validator.js +101 -0
  35. package/dist/core/config/validator.js.map +1 -0
  36. package/dist/core/config/writer.d.ts +11 -0
  37. package/dist/core/config/writer.d.ts.map +1 -0
  38. package/dist/core/config/writer.js +145 -0
  39. package/dist/core/config/writer.js.map +1 -0
  40. package/dist/core/shell/detector.d.ts +14 -0
  41. package/dist/core/shell/detector.d.ts.map +1 -0
  42. package/dist/core/shell/detector.js +69 -0
  43. package/dist/core/shell/detector.js.map +1 -0
  44. package/dist/core/shell/profile-updater.d.ts +11 -0
  45. package/dist/core/shell/profile-updater.d.ts.map +1 -0
  46. package/dist/core/shell/profile-updater.js +101 -0
  47. package/dist/core/shell/profile-updater.js.map +1 -0
  48. package/dist/index.d.ts +9 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +26 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/types/index.d.ts +96 -0
  53. package/dist/types/index.d.ts.map +1 -0
  54. package/dist/types/index.js +3 -0
  55. package/dist/types/index.js.map +1 -0
  56. package/dist/utils/constants.d.ts +68 -0
  57. package/dist/utils/constants.d.ts.map +1 -0
  58. package/dist/utils/constants.js +73 -0
  59. package/dist/utils/constants.js.map +1 -0
  60. package/dist/utils/masking.d.ts +14 -0
  61. package/dist/utils/masking.d.ts.map +1 -0
  62. package/dist/utils/masking.js +33 -0
  63. package/dist/utils/masking.js.map +1 -0
  64. package/package.json +61 -0
@@ -0,0 +1,96 @@
1
+ import type { SubscriptionTier } from '../utils/constants.js';
2
+ /**
3
+ * Configuration stored in ~/.claude/revenium.env
4
+ */
5
+ export interface ReveniumConfig {
6
+ apiKey: string;
7
+ endpoint: string;
8
+ email?: string;
9
+ subscriptionTier?: SubscriptionTier;
10
+ /** Optional override for the cost multiplier (overrides tier default) */
11
+ costMultiplierOverride?: number;
12
+ /** Optional organization ID for attributing costs to a specific customer/company */
13
+ organizationId?: string;
14
+ /** Optional product ID for attributing costs to a specific product/project */
15
+ productId?: string;
16
+ }
17
+ /**
18
+ * Result of configuration validation
19
+ */
20
+ export interface ValidationResult {
21
+ valid: boolean;
22
+ errors: string[];
23
+ }
24
+ /**
25
+ * Result of endpoint health check
26
+ */
27
+ export interface HealthCheckResult {
28
+ healthy: boolean;
29
+ statusCode?: number;
30
+ message: string;
31
+ latencyMs?: number;
32
+ }
33
+ /**
34
+ * Shell types supported for profile updates
35
+ */
36
+ export type ShellType = 'bash' | 'zsh' | 'fish' | 'unknown';
37
+ /**
38
+ * Result of shell profile update
39
+ */
40
+ export interface ShellUpdateResult {
41
+ success: boolean;
42
+ shellType: ShellType;
43
+ profilePath?: string;
44
+ message: string;
45
+ }
46
+ /**
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
50
+ */
51
+ export interface OTLPMetricsPayload {
52
+ resourceMetrics: Array<{
53
+ resource?: {
54
+ attributes?: Array<{
55
+ key: string;
56
+ value: OTLPValue;
57
+ }>;
58
+ };
59
+ scopeMetrics: Array<{
60
+ metrics: Array<{
61
+ 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
+ };
74
+ }>;
75
+ }>;
76
+ }>;
77
+ }
78
+ /**
79
+ * OTLP any value type
80
+ */
81
+ export interface OTLPValue {
82
+ stringValue?: string;
83
+ intValue?: number;
84
+ doubleValue?: number;
85
+ boolValue?: boolean;
86
+ }
87
+ /**
88
+ * Response from OTEL metrics endpoint
89
+ */
90
+ export interface OTLPResponse {
91
+ id: string;
92
+ resourceType: string;
93
+ processedMetrics: number;
94
+ created: string;
95
+ }
96
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,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AG,EAAE,MAAM,CAAC;4BACZ,KAAK,EAAE,SAAS,CAAC;yBAClB,CAAC,CAAC;wBACH,YAAY,CAAC,EAAE,MAAM,CAAC;wBACtB,KAAK,CAAC,EAAE,MAAM,CAAC;wBACf,QAAQ,CAAC,EAAE,MAAM,CAAC;qBACnB,CAAC,CAAC;iBACJ,CAAC;aACH,CAAC,CAAC;SACJ,CAAC,CAAC;KACJ,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,WAAW,CAAC,EAAE,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,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Constants for the Revenium Claude Code Metering CLI
3
+ */
4
+ /** Default Revenium API base URL */
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";
8
+ /** API key prefix required for valid Revenium API keys */
9
+ export declare const API_KEY_PREFIX = "hak_";
10
+ /** Directory for Claude Code configuration */
11
+ export declare const CLAUDE_CONFIG_DIR = ".claude";
12
+ /** Filename for Revenium environment configuration */
13
+ export declare const REVENIUM_ENV_FILE = "revenium.env";
14
+ /** File permissions for config file (owner read/write only) */
15
+ export declare const CONFIG_FILE_MODE = 384;
16
+ /** Available subscription tiers with their cost multipliers
17
+ *
18
+ * Cost multipliers represent the effective discount vs API pricing.
19
+ * Values are estimates based on fully consuming monthly token allotments.
20
+ *
21
+ * Calculation basis: Max 20x tier ($200 for 20X tokens = $2,500 API equivalent)
22
+ * establishes $125 per X tokens at API rates. Other tiers calculated proportionally.
23
+ *
24
+ * For detailed explanation and manual override instructions, see README.md
25
+ */
26
+ export declare const SUBSCRIPTION_TIER_CONFIG: {
27
+ readonly pro: {
28
+ readonly name: "Pro (~$20 USD/month or local equivalent)";
29
+ readonly multiplier: 0.16;
30
+ };
31
+ readonly max_5x: {
32
+ readonly name: "Max 5x (~$100 USD/month or local equivalent)";
33
+ readonly multiplier: 0.16;
34
+ };
35
+ readonly max_20x: {
36
+ readonly name: "Max 20x (~$200 USD/month or local equivalent)";
37
+ readonly multiplier: 0.08;
38
+ };
39
+ readonly team_premium: {
40
+ readonly name: "Team Premium (~$150 USD/seat or local equivalent)";
41
+ readonly multiplier: 0.24;
42
+ };
43
+ readonly enterprise: {
44
+ readonly name: "Enterprise (custom)";
45
+ readonly multiplier: 0.05;
46
+ };
47
+ readonly api: {
48
+ readonly name: "API (no subscription)";
49
+ readonly multiplier: 1;
50
+ };
51
+ };
52
+ export declare const SUBSCRIPTION_TIERS: ReadonlyArray<keyof typeof SUBSCRIPTION_TIER_CONFIG>;
53
+ export type SubscriptionTier = keyof typeof SUBSCRIPTION_TIER_CONFIG;
54
+ /** Get the cost multiplier for a given tier */
55
+ export declare function getCostMultiplier(tier: SubscriptionTier): number;
56
+ /** Environment variable names */
57
+ export declare const ENV_VARS: {
58
+ readonly TELEMETRY_ENABLED: "CLAUDE_CODE_ENABLE_TELEMETRY";
59
+ readonly OTLP_ENDPOINT: "OTEL_EXPORTER_OTLP_ENDPOINT";
60
+ readonly OTLP_HEADERS: "OTEL_EXPORTER_OTLP_HEADERS";
61
+ readonly OTLP_PROTOCOL: "OTEL_EXPORTER_OTLP_PROTOCOL";
62
+ readonly SUBSCRIBER_EMAIL: "REVENIUM_SUBSCRIBER_EMAIL";
63
+ readonly SUBSCRIPTION: "CLAUDE_CODE_SUBSCRIPTION";
64
+ readonly COST_MULTIPLIER: "CLAUDE_CODE_COST_MULTIPLIER";
65
+ readonly ORGANIZATION_ID: "REVENIUM_ORGANIZATION_ID";
66
+ readonly PRODUCT_ID: "REVENIUM_PRODUCT_ID";
67
+ };
68
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ /**
3
+ * Constants for the Revenium Claude Code Metering CLI
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
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
+ exports.getCostMultiplier = getCostMultiplier;
8
+ /** Default Revenium API base URL */
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';
12
+ /** API key prefix required for valid Revenium API keys */
13
+ exports.API_KEY_PREFIX = 'hak_';
14
+ /** Directory for Claude Code configuration */
15
+ exports.CLAUDE_CONFIG_DIR = '.claude';
16
+ /** Filename for Revenium environment configuration */
17
+ exports.REVENIUM_ENV_FILE = 'revenium.env';
18
+ /** File permissions for config file (owner read/write only) */
19
+ exports.CONFIG_FILE_MODE = 0o600;
20
+ /** Available subscription tiers with their cost multipliers
21
+ *
22
+ * Cost multipliers represent the effective discount vs API pricing.
23
+ * Values are estimates based on fully consuming monthly token allotments.
24
+ *
25
+ * Calculation basis: Max 20x tier ($200 for 20X tokens = $2,500 API equivalent)
26
+ * establishes $125 per X tokens at API rates. Other tiers calculated proportionally.
27
+ *
28
+ * For detailed explanation and manual override instructions, see README.md
29
+ */
30
+ exports.SUBSCRIPTION_TIER_CONFIG = {
31
+ pro: {
32
+ name: 'Pro (~$20 USD/month or local equivalent)',
33
+ multiplier: 0.16, // $20 / $125 API equivalent = 16%
34
+ },
35
+ max_5x: {
36
+ name: 'Max 5x (~$100 USD/month or local equivalent)',
37
+ multiplier: 0.16, // $100 / $625 API equivalent = 16%
38
+ },
39
+ max_20x: {
40
+ name: 'Max 20x (~$200 USD/month or local equivalent)',
41
+ multiplier: 0.08, // $200 / $2,500 API equivalent = 8% (baseline from real data)
42
+ },
43
+ team_premium: {
44
+ name: 'Team Premium (~$150 USD/seat or local equivalent)',
45
+ multiplier: 0.24, // $150 / $625 API equivalent = 24%
46
+ },
47
+ enterprise: {
48
+ name: 'Enterprise (custom)',
49
+ multiplier: 0.05, // Custom pricing with best discounts
50
+ },
51
+ api: {
52
+ name: 'API (no subscription)',
53
+ multiplier: 1.0, // Full API pricing
54
+ },
55
+ };
56
+ exports.SUBSCRIPTION_TIERS = Object.keys(exports.SUBSCRIPTION_TIER_CONFIG);
57
+ /** Get the cost multiplier for a given tier */
58
+ function getCostMultiplier(tier) {
59
+ return exports.SUBSCRIPTION_TIER_CONFIG[tier].multiplier;
60
+ }
61
+ /** Environment variable names */
62
+ exports.ENV_VARS = {
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
+ };
73
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +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,iBAAi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masks an API key, showing only the prefix and last 4 characters.
6
+ * Example: "hak_tenant_abc123xyz" -> "hak_***xyz"
7
+ */
8
+ export declare function maskApiKey(apiKey: string): string;
9
+ /**
10
+ * Masks an email address, showing only the first character and domain.
11
+ * Example: "dev@company.com" -> "d***@company.com"
12
+ */
13
+ export declare function maskEmail(email: string): string;
14
+ //# sourceMappingURL=masking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"masking.d.ts","sourceRoot":"","sources":["../../src/utils/masking.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQjD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAS/C"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * Utility functions for masking sensitive data in terminal output
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.maskApiKey = maskApiKey;
7
+ exports.maskEmail = maskEmail;
8
+ /**
9
+ * Masks an API key, showing only the prefix and last 4 characters.
10
+ * Example: "hak_tenant_abc123xyz" -> "hak_***xyz"
11
+ */
12
+ function maskApiKey(apiKey) {
13
+ if (!apiKey || apiKey.length < 8) {
14
+ return '***';
15
+ }
16
+ const prefix = apiKey.substring(0, 4); // "hak_"
17
+ const lastFour = apiKey.substring(apiKey.length - 4);
18
+ return `${prefix}***${lastFour}`;
19
+ }
20
+ /**
21
+ * Masks an email address, showing only the first character and domain.
22
+ * Example: "dev@company.com" -> "d***@company.com"
23
+ */
24
+ function maskEmail(email) {
25
+ const atIndex = email.indexOf('@');
26
+ if (atIndex <= 0) {
27
+ return '***';
28
+ }
29
+ const firstChar = email.charAt(0);
30
+ const domain = email.substring(atIndex);
31
+ return `${firstChar}***${domain}`;
32
+ }
33
+ //# sourceMappingURL=masking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"masking.js","sourceRoot":"","sources":["../../src/utils/masking.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAMH,gCAQC;AAMD,8BASC;AA3BD;;;GAGG;AACH,SAAgB,UAAU,CAAC,MAAc;IACvC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;IAChD,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrD,OAAO,GAAG,MAAM,MAAM,QAAQ,EAAE,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,KAAa;IACrC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACxC,OAAO,GAAG,SAAS,MAAM,MAAM,EAAE,CAAC;AACpC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@revenium/claude-code-metering",
3
+ "version": "0.1.0",
4
+ "description": "CLI tool to configure Claude Code telemetry export to Revenium",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "revenium-metering": "dist/cli/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsc --watch",
13
+ "cli": "node dist/cli/index.js",
14
+ "test": "vitest run",
15
+ "test:watch": "vitest",
16
+ "lint": "eslint src --ext .ts",
17
+ "format": "prettier --write \"src/**/*.ts\"",
18
+ "prepublishOnly": "npm run build"
19
+ },
20
+ "keywords": [
21
+ "revenium",
22
+ "claude-code",
23
+ "metering",
24
+ "telemetry",
25
+ "opentelemetry",
26
+ "otlp"
27
+ ],
28
+ "author": "Revenium",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/revenium/revenium-claude-code-sdk.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/revenium/revenium-claude-code-sdk/issues"
36
+ },
37
+ "homepage": "https://github.com/revenium/revenium-claude-code-sdk#readme",
38
+ "files": [
39
+ "dist",
40
+ "README.md",
41
+ "LICENSE",
42
+ "CHANGELOG.md"
43
+ ],
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ },
47
+ "dependencies": {
48
+ "chalk": "^5.3.0",
49
+ "commander": "^12.1.0",
50
+ "inquirer": "^9.3.7",
51
+ "ora": "^8.1.1"
52
+ },
53
+ "devDependencies": {
54
+ "@types/inquirer": "^9.0.7",
55
+ "@types/node": "^20.17.12",
56
+ "eslint": "^8.57.1",
57
+ "prettier": "^3.4.2",
58
+ "typescript": "^5.7.2",
59
+ "vitest": "^2.1.8"
60
+ }
61
+ }