@praeviso/code-env-switch 0.1.5 → 0.1.6
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/README.md +40 -0
- package/README_zh.md +40 -0
- package/bin/cli/args.js +13 -0
- package/bin/cli/help.js +5 -0
- package/bin/cli/index.js +2 -1
- package/bin/commands/index.js +3 -1
- package/bin/commands/usage.js +41 -0
- package/bin/index.js +7 -0
- package/bin/statusline/debug.js +1 -0
- package/bin/statusline/usage/codex.js +29 -20
- package/bin/usage/index.js +261 -19
- package/package.json +1 -1
- package/src/cli/args.ts +14 -0
- package/src/cli/help.ts +5 -0
- package/src/cli/index.ts +7 -1
- package/src/commands/index.ts +1 -0
- package/src/commands/usage.ts +53 -0
- package/src/index.ts +11 -0
- package/src/statusline/debug.ts +1 -1
- package/src/statusline/usage/codex.ts +26 -31
- package/src/types.ts +4 -0
- package/src/usage/index.ts +268 -17
package/README.md
CHANGED
|
@@ -80,6 +80,46 @@ codenv remove codex primary
|
|
|
80
80
|
`codenv list` (or `codenv ls`) prints a table with `PROFILE`, `TYPE`, and `NOTE`. Default profiles are labeled in the `NOTE` column, and the active profile is shown in green.
|
|
81
81
|
If `profile.name` is set, it is shown in `PROFILE`. Otherwise the profile key is shown (with legacy `type-` prefixes stripped when possible).
|
|
82
82
|
|
|
83
|
+
### Reset usage history
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
codenv usage-reset
|
|
87
|
+
# skip confirmation
|
|
88
|
+
codenv usage-reset --yes
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
This deletes usage history files (`usage.jsonl`, usage state, `profile-log.jsonl`, `statusline-debug.jsonl`) plus any backup variants in the config directory.
|
|
92
|
+
|
|
93
|
+
### Usage tracking
|
|
94
|
+
|
|
95
|
+
Usage stats are derived from two sources (statusline input + session logs) and appended to `usage.jsonl`.
|
|
96
|
+
|
|
97
|
+
- Files and paths
|
|
98
|
+
- `usage.jsonl`: JSONL records with `ts`, `type`, `profileKey`/`profileName`, `model`, `sessionId`, and token breakdowns.
|
|
99
|
+
- `usage.jsonl.state.json`: per-session totals + per-session-file metadata (mtime/size) used to compute deltas and avoid double counting.
|
|
100
|
+
- `profile-log.jsonl`: profile usage + session binding log (`use` and `session` events).
|
|
101
|
+
- `statusline-debug.jsonl`: optional debug capture when `CODE_ENV_STATUSLINE_DEBUG` is enabled.
|
|
102
|
+
- Paths can be overridden via `usagePath`, `usageStatePath`, `profileLogPath`, `codexSessionsPath`, `claudeSessionsPath`.
|
|
103
|
+
- Session binding (profile -> session)
|
|
104
|
+
- `codenv init` installs a shell wrapper so `codex`/`claude` run via `codenv launch`.
|
|
105
|
+
- `codenv launch` logs profile usage and then finds the latest unbound session file (prefers matching `cwd`, within a small grace window) and records the binding in `profile-log.jsonl`.
|
|
106
|
+
- Sync uses these bindings to attribute session usage to a profile.
|
|
107
|
+
- Statusline sync (`codenv statusline --sync-usage`)
|
|
108
|
+
- Requires `sessionId`, model, and a profile (`profileKey` or `profileName`) to write usage.
|
|
109
|
+
- Reads stdin JSON for totals and computes a delta against the last stored totals in the state file.
|
|
110
|
+
- If totals decrease (session reset), the current totals are treated as fresh usage; otherwise negative sub-deltas are clamped to zero.
|
|
111
|
+
- If the token breakdown exceeds the reported total, the breakdown sum wins.
|
|
112
|
+
- Appends a delta record to `usage.jsonl` and updates the per-session totals in the state file.
|
|
113
|
+
- Session log sync (`--sync-usage` and `codenv list`)
|
|
114
|
+
- Scans Codex sessions under `CODEX_HOME/sessions` (or `~/.codex/sessions`) and Claude sessions under `CLAUDE_HOME/projects` (or `~/.claude/projects`).
|
|
115
|
+
- Codex: parses `event_msg` token_count records and uses max totals; cached input is recorded as cache read and subtracted from input when possible.
|
|
116
|
+
- Claude: sums `message.usage` input/output/cache tokens across the file.
|
|
117
|
+
- Deltas are computed against prior file metadata and per-session maxima in the state file; files without a resolved binding are skipped.
|
|
118
|
+
- Daily totals
|
|
119
|
+
- "Today" is computed in local time between 00:00 and the next 00:00.
|
|
120
|
+
- Cost calculation
|
|
121
|
+
- Uses pricing from the profile (or `pricing.models`, plus defaults) and requires token splits; if splits are missing, cost is omitted.
|
|
122
|
+
|
|
83
123
|
### Add / update a profile
|
|
84
124
|
|
|
85
125
|
```bash
|
package/README_zh.md
CHANGED
|
@@ -80,6 +80,46 @@ codenv remove codex primary
|
|
|
80
80
|
`codenv list`(或 `codenv ls`)会输出 `PROFILE` / `TYPE` / `NOTE` 的表格。默认项会标注在 `NOTE` 列,当前激活的配置会用绿色显示。
|
|
81
81
|
如果设置了 `profile.name`,`PROFILE` 列会显示该名称;否则显示 profile 的 key(会尽量去掉旧的 `type-` 前缀)。
|
|
82
82
|
|
|
83
|
+
### 清理用量历史
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
codenv usage-reset
|
|
87
|
+
# 跳过确认
|
|
88
|
+
codenv usage-reset --yes
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
该命令会删除用量历史文件(`usage.jsonl`、用量 state、`profile-log.jsonl`、`statusline-debug.jsonl`)以及配置目录中的相关备份文件。
|
|
92
|
+
|
|
93
|
+
### 用量统计逻辑
|
|
94
|
+
|
|
95
|
+
用量来自两条路径(状态栏输入同步 + 会话日志解析),最终追加到 `usage.jsonl`。
|
|
96
|
+
|
|
97
|
+
- 文件与路径
|
|
98
|
+
- `usage.jsonl`:JSONL 记录,包含 `ts`/`type`/`profileKey`/`profileName`/`model`/`sessionId` 和 token 拆分字段。
|
|
99
|
+
- `usage.jsonl.state.json`:保存每个 session 的累计 totals + session 文件的 mtime/size,用于计算增量并避免重复统计。
|
|
100
|
+
- `profile-log.jsonl`:profile 使用与 session 绑定日志(`use`/`session`)。
|
|
101
|
+
- `statusline-debug.jsonl`:当 `CODE_ENV_STATUSLINE_DEBUG` 开启时写入的调试信息。
|
|
102
|
+
- 可通过 `usagePath`/`usageStatePath`/`profileLogPath`/`codexSessionsPath`/`claudeSessionsPath` 覆盖默认路径。
|
|
103
|
+
- 会话绑定(profile -> session)
|
|
104
|
+
- `codenv init` 安装 shell 包装函数,使 `codex`/`claude` 实际走 `codenv launch`。
|
|
105
|
+
- `codenv launch` 记录 profile 使用,并在启动后短时间内(默认约 5 秒、每秒轮询)找到最新未绑定的 session 文件(优先 `cwd` 匹配),写入 `profile-log.jsonl`。
|
|
106
|
+
- 后续同步会用该绑定将 session 归因到对应 profile。
|
|
107
|
+
- 状态栏同步(`codenv statusline --sync-usage`)
|
|
108
|
+
- 需要 `sessionId`、model,以及 profile(`profileKey` 或 `profileName`)才会写入用量。
|
|
109
|
+
- 从 stdin JSON 读取 totals,与 state 中的上次 totals 做差得到增量。
|
|
110
|
+
- 如果 totals 回退(session reset),直接把当前 totals 当作新增;否则对负数子项做 0 处理。
|
|
111
|
+
- 当拆分合计大于 total 时,以拆分合计为准。
|
|
112
|
+
- 把增量写入 `usage.jsonl`,并更新 state 中的 session totals。
|
|
113
|
+
- 会话日志同步(`--sync-usage` 与 `codenv list`)
|
|
114
|
+
- 扫描 Codex 的 `CODEX_HOME/sessions`(或 `~/.codex/sessions`)与 Claude 的 `CLAUDE_HOME/projects`(或 `~/.claude/projects`)。
|
|
115
|
+
- Codex:读取 `event_msg` 的 token_count 记录,取累计最大值;cached input 计为 cache read,并在可判断时从 input 中扣除。
|
|
116
|
+
- Claude:汇总 `message.usage` 中的 input/output/cache tokens。
|
|
117
|
+
- 与 state 中的文件元数据和 session 最大值做差,生成增量并写入 `usage.jsonl`;无法解析到绑定的文件会被跳过。
|
|
118
|
+
- 今日统计
|
|
119
|
+
- “今日”按本地时区 00:00 到次日 00:00 计算。
|
|
120
|
+
- 费用换算
|
|
121
|
+
- 使用 profile 定价或 `pricing.models`(含默认值)换算,依赖 input/output/cache 拆分;缺少拆分则不显示金额。
|
|
122
|
+
|
|
83
123
|
### 添加 / 更新 profile
|
|
84
124
|
|
|
85
125
|
```bash
|
package/bin/cli/args.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseArgs = parseArgs;
|
|
4
4
|
exports.parseInitArgs = parseInitArgs;
|
|
5
5
|
exports.parseAddArgs = parseAddArgs;
|
|
6
|
+
exports.parseUsageResetArgs = parseUsageResetArgs;
|
|
6
7
|
exports.parseStatuslineArgs = parseStatuslineArgs;
|
|
7
8
|
const type_1 = require("../profile/type");
|
|
8
9
|
function parseArgs(argv) {
|
|
@@ -150,6 +151,18 @@ function parseAddArgs(args) {
|
|
|
150
151
|
}
|
|
151
152
|
return result;
|
|
152
153
|
}
|
|
154
|
+
function parseUsageResetArgs(args) {
|
|
155
|
+
const result = { yes: false };
|
|
156
|
+
for (let i = 0; i < args.length; i++) {
|
|
157
|
+
const arg = args[i];
|
|
158
|
+
if (arg === "-y" || arg === "--yes") {
|
|
159
|
+
result.yes = true;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
throw new Error(`Unknown usage-reset argument: ${arg}`);
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
153
166
|
function parseNumberFlag(value, flag) {
|
|
154
167
|
if (value === null || value === undefined || value === "") {
|
|
155
168
|
throw new Error(`Missing value for ${flag}.`);
|
package/bin/cli/help.js
CHANGED
|
@@ -29,6 +29,7 @@ Usage:
|
|
|
29
29
|
codenv launch <codex|claude> [--] [args...]
|
|
30
30
|
codenv init
|
|
31
31
|
codenv statusline [options]
|
|
32
|
+
codenv usage-reset [--yes]
|
|
32
33
|
|
|
33
34
|
Options:
|
|
34
35
|
-c, --config <path> Path to config JSON
|
|
@@ -59,6 +60,9 @@ Statusline options:
|
|
|
59
60
|
--usage-output <n> Set output token usage
|
|
60
61
|
--sync-usage Sync usage from sessions before reading
|
|
61
62
|
|
|
63
|
+
Usage reset options:
|
|
64
|
+
-y, --yes Skip confirmation prompt
|
|
65
|
+
|
|
62
66
|
Examples:
|
|
63
67
|
codenv init
|
|
64
68
|
codenv use codex primary
|
|
@@ -69,6 +73,7 @@ Examples:
|
|
|
69
73
|
codenv remove --all
|
|
70
74
|
codenv launch codex -- --help
|
|
71
75
|
codenv statusline --format json
|
|
76
|
+
codenv usage-reset --yes
|
|
72
77
|
CODE_ENV_CONFIG=~/.config/code-env/config.json codenv use claude default
|
|
73
78
|
codenv add --type codex primary OPENAI_BASE_URL=https://api.example.com/v1 OPENAI_API_KEY=YOUR_API_KEY
|
|
74
79
|
codenv add
|
package/bin/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printHelp = exports.parseStatuslineArgs = exports.parseAddArgs = exports.parseInitArgs = exports.parseArgs = void 0;
|
|
3
|
+
exports.printHelp = exports.parseStatuslineArgs = exports.parseUsageResetArgs = exports.parseAddArgs = exports.parseInitArgs = exports.parseArgs = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* CLI module exports
|
|
6
6
|
*/
|
|
@@ -8,6 +8,7 @@ var args_1 = require("./args");
|
|
|
8
8
|
Object.defineProperty(exports, "parseArgs", { enumerable: true, get: function () { return args_1.parseArgs; } });
|
|
9
9
|
Object.defineProperty(exports, "parseInitArgs", { enumerable: true, get: function () { return args_1.parseInitArgs; } });
|
|
10
10
|
Object.defineProperty(exports, "parseAddArgs", { enumerable: true, get: function () { return args_1.parseAddArgs; } });
|
|
11
|
+
Object.defineProperty(exports, "parseUsageResetArgs", { enumerable: true, get: function () { return args_1.parseUsageResetArgs; } });
|
|
11
12
|
Object.defineProperty(exports, "parseStatuslineArgs", { enumerable: true, get: function () { return args_1.parseStatuslineArgs; } });
|
|
12
13
|
var help_1 = require("./help");
|
|
13
14
|
Object.defineProperty(exports, "printHelp", { enumerable: true, get: function () { return help_1.printHelp; } });
|
package/bin/commands/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printStatusline = exports.runLaunch = exports.printUnset = exports.printShow = exports.addConfig = exports.printList = exports.printUse = exports.buildUseLines = void 0;
|
|
3
|
+
exports.runUsageReset = exports.printStatusline = exports.runLaunch = exports.printUnset = exports.printShow = exports.addConfig = exports.printList = exports.printUse = exports.buildUseLines = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Commands module exports
|
|
6
6
|
*/
|
|
@@ -19,3 +19,5 @@ var launch_1 = require("./launch");
|
|
|
19
19
|
Object.defineProperty(exports, "runLaunch", { enumerable: true, get: function () { return launch_1.runLaunch; } });
|
|
20
20
|
var statusline_1 = require("./statusline");
|
|
21
21
|
Object.defineProperty(exports, "printStatusline", { enumerable: true, get: function () { return statusline_1.printStatusline; } });
|
|
22
|
+
var usage_1 = require("./usage");
|
|
23
|
+
Object.defineProperty(exports, "runUsageReset", { enumerable: true, get: function () { return usage_1.runUsageReset; } });
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runUsageReset = runUsageReset;
|
|
4
|
+
const usage_1 = require("../usage");
|
|
5
|
+
const ui_1 = require("../ui");
|
|
6
|
+
async function runUsageReset(config, configPath, args) {
|
|
7
|
+
if (!args.yes) {
|
|
8
|
+
const rl = (0, ui_1.createReadline)();
|
|
9
|
+
try {
|
|
10
|
+
const confirmed = await (0, ui_1.askConfirm)(rl, "Clear all usage history files? This cannot be undone. (y/N): ");
|
|
11
|
+
if (!confirmed)
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
finally {
|
|
15
|
+
rl.close();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const result = (0, usage_1.clearUsageHistory)(config, configPath);
|
|
19
|
+
const removed = result.removed.sort();
|
|
20
|
+
const missing = result.missing.sort();
|
|
21
|
+
const failed = result.failed.sort((a, b) => a.path.localeCompare(b.path));
|
|
22
|
+
if (removed.length === 0 && failed.length === 0) {
|
|
23
|
+
console.log("No usage files found.");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (removed.length > 0) {
|
|
27
|
+
console.log(`Removed ${removed.length} file(s):`);
|
|
28
|
+
for (const filePath of removed) {
|
|
29
|
+
console.log(`- ${filePath}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (missing.length > 0) {
|
|
33
|
+
console.log(`Skipped ${missing.length} missing file(s).`);
|
|
34
|
+
}
|
|
35
|
+
if (failed.length > 0) {
|
|
36
|
+
for (const failure of failed) {
|
|
37
|
+
console.error(`Failed to remove ${failure.path}: ${failure.error}`);
|
|
38
|
+
}
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
package/bin/index.js
CHANGED
|
@@ -111,6 +111,13 @@ async function main() {
|
|
|
111
111
|
(0, commands_1.printStatusline)(config, configPath, statuslineArgs);
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
|
+
if (cmd === "usage-reset" || cmd === "reset-usage") {
|
|
115
|
+
const resetArgs = (0, cli_1.parseUsageResetArgs)(args.slice(1));
|
|
116
|
+
const configPath = process.env.CODE_ENV_CONFIG_PATH || (0, config_1.findConfigPath)(parsed.configPath);
|
|
117
|
+
const config = (0, config_1.readConfigIfExists)(configPath);
|
|
118
|
+
await (0, commands_1.runUsageReset)(config, configPath, resetArgs);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
114
121
|
const configPath = (0, config_1.findConfigPath)(parsed.configPath);
|
|
115
122
|
const config = (0, config_1.readConfig)(configPath);
|
|
116
123
|
if (cmd === "default") {
|
package/bin/statusline/debug.js
CHANGED
|
@@ -7,19 +7,33 @@ function resolveOutputTokens(record) {
|
|
|
7
7
|
var _a, _b;
|
|
8
8
|
const outputTokens = (_a = (0, utils_1.firstNumber)(record.outputTokens, record.output, record.output_tokens)) !== null && _a !== void 0 ? _a : null;
|
|
9
9
|
const reasoningTokens = (_b = (0, utils_1.firstNumber)(record.reasoning_output_tokens, record.reasoningOutputTokens, record.reasoning_output)) !== null && _b !== void 0 ? _b : null;
|
|
10
|
-
if (outputTokens
|
|
11
|
-
return null;
|
|
12
|
-
if (reasoningTokens === null)
|
|
10
|
+
if (outputTokens !== null)
|
|
13
11
|
return outputTokens;
|
|
14
|
-
|
|
12
|
+
if (reasoningTokens !== null)
|
|
13
|
+
return reasoningTokens;
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
function splitInputTokens(record) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const rawInput = (_a = (0, utils_1.firstNumber)(record.inputTokens, record.input, record.input_tokens)) !== null && _a !== void 0 ? _a : null;
|
|
19
|
+
const cacheRead = (_b = (0, utils_1.firstNumber)(record.cached_input_tokens, record.cachedInputTokens, record.cache_read_input_tokens, record.cacheReadInputTokens, record.cache_read, record.cacheRead)) !== null && _b !== void 0 ? _b : null;
|
|
20
|
+
if (rawInput === null) {
|
|
21
|
+
return { inputTokens: null, cacheReadTokens: cacheRead };
|
|
22
|
+
}
|
|
23
|
+
if (cacheRead === null) {
|
|
24
|
+
return { inputTokens: rawInput, cacheReadTokens: null };
|
|
25
|
+
}
|
|
26
|
+
const nonCachedInput = Math.max(0, rawInput - cacheRead);
|
|
27
|
+
return { inputTokens: nonCachedInput, cacheReadTokens: cacheRead };
|
|
15
28
|
}
|
|
16
29
|
function parseCodexUsageTotalsRecord(record) {
|
|
17
|
-
var _a, _b
|
|
18
|
-
const
|
|
30
|
+
var _a, _b;
|
|
31
|
+
const split = splitInputTokens(record);
|
|
32
|
+
const inputTokens = split.inputTokens;
|
|
19
33
|
const outputTokens = resolveOutputTokens(record);
|
|
20
|
-
const cacheRead =
|
|
21
|
-
const cacheWrite = (
|
|
22
|
-
const totalTokens = (
|
|
34
|
+
const cacheRead = split.cacheReadTokens;
|
|
35
|
+
const cacheWrite = (_a = (0, utils_1.firstNumber)(record.cache_creation_input_tokens, record.cacheCreationInputTokens, record.cache_write_input_tokens, record.cacheWriteInputTokens, record.cache_write, record.cacheWrite)) !== null && _a !== void 0 ? _a : null;
|
|
36
|
+
const totalTokens = (_b = (0, utils_1.firstNumber)(record.totalTokens, record.total, record.total_tokens)) !== null && _b !== void 0 ? _b : null;
|
|
23
37
|
let computedTotal = null;
|
|
24
38
|
if (inputTokens !== null ||
|
|
25
39
|
outputTokens !== null ||
|
|
@@ -48,13 +62,14 @@ function parseCodexUsageTotalsRecord(record) {
|
|
|
48
62
|
};
|
|
49
63
|
}
|
|
50
64
|
function parseCodexInputUsageRecord(record) {
|
|
51
|
-
var _a, _b, _c, _d
|
|
65
|
+
var _a, _b, _c, _d;
|
|
52
66
|
const todayTokens = (_a = (0, utils_1.firstNumber)(record.todayTokens, record.today, record.today_tokens, record.daily, record.daily_tokens)) !== null && _a !== void 0 ? _a : null;
|
|
53
67
|
const totalTokens = (_b = (0, utils_1.firstNumber)(record.totalTokens, record.total, record.total_tokens)) !== null && _b !== void 0 ? _b : null;
|
|
54
|
-
const
|
|
68
|
+
const split = splitInputTokens(record);
|
|
69
|
+
const inputTokens = split.inputTokens;
|
|
55
70
|
const outputTokens = resolveOutputTokens(record);
|
|
56
|
-
const cacheRead =
|
|
57
|
-
const cacheWrite = (
|
|
71
|
+
const cacheRead = split.cacheReadTokens;
|
|
72
|
+
const cacheWrite = (_c = (0, utils_1.firstNumber)(record.cache_creation_input_tokens, record.cacheCreationInputTokens, record.cache_write_input_tokens, record.cacheWriteInputTokens, record.cache_write, record.cacheWrite)) !== null && _c !== void 0 ? _c : null;
|
|
58
73
|
if (todayTokens === null &&
|
|
59
74
|
totalTokens === null &&
|
|
60
75
|
inputTokens === null &&
|
|
@@ -71,7 +86,7 @@ function parseCodexInputUsageRecord(record) {
|
|
|
71
86
|
(cacheWrite || 0)
|
|
72
87
|
: null;
|
|
73
88
|
const resolvedTodayTokens = hasCacheTokens
|
|
74
|
-
? (
|
|
89
|
+
? (_d = todayTokens !== null && todayTokens !== void 0 ? todayTokens : totalTokens) !== null && _d !== void 0 ? _d : computedTotal
|
|
75
90
|
: todayTokens;
|
|
76
91
|
return {
|
|
77
92
|
todayTokens: resolvedTodayTokens,
|
|
@@ -110,12 +125,6 @@ function getCodexUsageTotalsFromInput(input) {
|
|
|
110
125
|
if (parsed)
|
|
111
126
|
return parsed;
|
|
112
127
|
}
|
|
113
|
-
const lastUsage = resolveNestedRecord(tokenUsage, "last_token_usage", "lastTokenUsage");
|
|
114
|
-
if (lastUsage) {
|
|
115
|
-
const parsed = parseCodexUsageTotalsRecord(lastUsage);
|
|
116
|
-
if (parsed)
|
|
117
|
-
return parsed;
|
|
118
|
-
}
|
|
119
128
|
const parsed = parseCodexUsageTotalsRecord(tokenUsage);
|
|
120
129
|
if (parsed)
|
|
121
130
|
return parsed;
|