axusage 2.0.0 → 2.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.
@@ -1,4 +1,4 @@
1
- import { extractRawCredentials, getAccessToken } from "axauth";
1
+ import { getAgentAccessToken } from "axauth";
2
2
  import { ApiError } from "../types/domain.js";
3
3
  import { ChatGPTUsageResponse as ChatGPTUsageResponseSchema } from "../types/chatgpt.js";
4
4
  import { toServiceUsageData } from "./parse-chatgpt-usage.js";
@@ -12,24 +12,11 @@ const API_URL = "https://chatgpt.com/backend-api/wham/usage";
12
12
  export const chatGPTAdapter = {
13
13
  name: "ChatGPT",
14
14
  async fetchUsage() {
15
- const credentials = extractRawCredentials("codex");
16
- if (!credentials) {
17
- return {
18
- ok: false,
19
- error: new ApiError("No Codex credentials found. Run 'codex' to authenticate."),
20
- };
21
- }
22
- if (credentials.type !== "oauth") {
23
- return {
24
- ok: false,
25
- error: new ApiError("ChatGPT usage API requires OAuth authentication. API key authentication is not supported for usage data."),
26
- };
27
- }
28
- const accessToken = getAccessToken(credentials);
15
+ const accessToken = await getAgentAccessToken("codex");
29
16
  if (!accessToken) {
30
17
  return {
31
18
  ok: false,
32
- error: new ApiError("Invalid OAuth credentials: missing access token."),
19
+ error: new ApiError("No Codex credentials found. Run 'codex' to authenticate."),
33
20
  };
34
21
  }
35
22
  try {
@@ -1,4 +1,4 @@
1
- import { extractRawCredentials, getAccessToken } from "axauth";
1
+ import { getAgentAccessToken } from "axauth";
2
2
  import { z } from "zod";
3
3
  import { ApiError } from "../types/domain.js";
4
4
  import { UsageResponse as UsageResponseSchema } from "../types/usage.js";
@@ -43,24 +43,11 @@ async function fetchPlanType(accessToken) {
43
43
  export const claudeAdapter = {
44
44
  name: "Claude",
45
45
  async fetchUsage() {
46
- const credentials = extractRawCredentials("claude");
47
- if (!credentials) {
48
- return {
49
- ok: false,
50
- error: new ApiError("No Claude Code credentials found. Ensure Claude Code is installed and authenticated."),
51
- };
52
- }
53
- if (credentials.type !== "oauth") {
54
- return {
55
- ok: false,
56
- error: new ApiError("Claude Code usage API requires OAuth authentication. API key authentication is not supported for usage data."),
57
- };
58
- }
59
- const accessToken = getAccessToken(credentials);
46
+ const accessToken = await getAgentAccessToken("claude");
60
47
  if (!accessToken) {
61
48
  return {
62
49
  ok: false,
63
- error: new ApiError("Invalid OAuth credentials: missing access token."),
50
+ error: new ApiError("No Claude credentials found. Run 'claude' to authenticate."),
64
51
  };
65
52
  }
66
53
  try {
@@ -11,7 +11,7 @@ import { toServiceUsageData } from "./parse-gemini-usage.js";
11
11
  export const geminiAdapter = {
12
12
  name: "Gemini",
13
13
  async fetchUsage() {
14
- const accessToken = getAgentAccessToken("gemini");
14
+ const accessToken = await getAgentAccessToken("gemini");
15
15
  if (!accessToken) {
16
16
  return {
17
17
  ok: false,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "axusage",
3
3
  "author": "Łukasz Jerciński",
4
4
  "license": "MIT",
5
- "version": "2.0.0",
5
+ "version": "2.1.0",
6
6
  "description": "Monitor API usage across Claude, ChatGPT, GitHub Copilot, and Gemini from a single CLI",
7
7
  "repository": {
8
8
  "type": "git",
@@ -18,6 +18,24 @@
18
18
  "README.md",
19
19
  "LICENSE"
20
20
  ],
21
+ "scripts": {
22
+ "postinstall": "playwright install chromium",
23
+ "prepare": "git config core.hooksPath .githooks",
24
+ "prepublishOnly": "pnpm run rebuild",
25
+ "build": "tsc -p tsconfig.app.json",
26
+ "clean": "rm -rf dist *.tsbuildinfo",
27
+ "format": "prettier --write .",
28
+ "format:check": "prettier --check .",
29
+ "fta": "fta-check",
30
+ "knip": "knip",
31
+ "lint": "eslint",
32
+ "rebuild": "pnpm run clean && pnpm run build",
33
+ "start": "pnpm run rebuild && node bin/axusage",
34
+ "test": "vitest run",
35
+ "test:coverage": "vitest run --coverage",
36
+ "test:watch": "vitest",
37
+ "typecheck": "tsc -b --noEmit"
38
+ },
21
39
  "keywords": [
22
40
  "ai",
23
41
  "usage",
@@ -30,12 +48,13 @@
30
48
  "llm",
31
49
  "monitoring"
32
50
  ],
51
+ "packageManager": "pnpm@10.25.0",
33
52
  "engines": {
34
53
  "node": ">=22.14.0"
35
54
  },
36
55
  "dependencies": {
37
56
  "@commander-js/extra-typings": "^14.0.0",
38
- "axauth": "^1.0.0",
57
+ "axauth": "^1.5.0",
39
58
  "chalk": "^5.6.2",
40
59
  "commander": "^14.0.2",
41
60
  "env-paths": "^3.0.0",
@@ -63,21 +82,5 @@
63
82
  "typescript": "^5.9.3",
64
83
  "typescript-eslint": "^8.49.0",
65
84
  "vitest": "^4.0.15"
66
- },
67
- "scripts": {
68
- "postinstall": "playwright install chromium",
69
- "build": "tsc -p tsconfig.app.json",
70
- "clean": "rm -rf dist *.tsbuildinfo",
71
- "format": "prettier --write .",
72
- "format:check": "prettier --check .",
73
- "fta": "fta-check",
74
- "knip": "knip",
75
- "lint": "eslint",
76
- "rebuild": "pnpm run clean && pnpm run build",
77
- "start": "pnpm run rebuild && node bin/axusage",
78
- "test": "vitest run",
79
- "test:coverage": "vitest run --coverage",
80
- "test:watch": "vitest",
81
- "typecheck": "tsc -b --noEmit"
82
85
  }
83
- }
86
+ }