sidekick-agent-hub 0.18.1 → 0.18.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.
- package/README.md +2 -2
- package/dist/sidekick-cli.mjs +518 -82
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ sidekick quota
|
|
|
114
114
|
Provider-aware quota and rate-limit display. The command auto-detects the active provider:
|
|
115
115
|
|
|
116
116
|
- **Claude Code**: Shows Claude Max subscription quota — 5-hour and 7-day windows with color-coded progress bars, projections, and reset countdowns. Includes a peak-hours summary line.
|
|
117
|
-
- **Codex**: Shows rate limits from
|
|
117
|
+
- **Codex**: Shows rate limits from Codex `token_count.rate_limits` events — primary and secondary windows with progress bars and reset countdowns. The default path is local-only: current workspace rollout, recent account-level rollouts, then the active account's cached snapshot. Add `--refresh` to explicitly refresh from Codex's usage API before falling back to local data.
|
|
118
118
|
- **OpenCode**: Prints an informational message (no rate-limit data available).
|
|
119
119
|
|
|
120
120
|
```
|
|
@@ -126,7 +126,7 @@ Subscription Quota
|
|
|
126
126
|
|
|
127
127
|
When quota data is unavailable, `sidekick quota` shows structured auth, rate-limit, network, server, or unexpected-failure messaging instead of a generic raw error. The dashboard Sessions panel also keeps a compact inline quota/rate-limit state visible instead of hiding the section entirely.
|
|
128
128
|
|
|
129
|
-
Use `--json` for machine-readable output. Use `--provider codex` to explicitly check Codex rate limits. Claude Code requires active credentials (read from the system Keychain on macOS, or `~/.claude/.credentials.json` on Linux/Windows). JSON output includes `failureKind`, `httpStatus`, and `retryAfterMs` on unavailable responses.
|
|
129
|
+
Use `--json` for machine-readable output. Use `--provider codex` to explicitly check Codex rate limits, and `--refresh` to opt in to a Codex usage API refresh. Claude Code requires active credentials (read from the system Keychain on macOS, or `~/.claude/.credentials.json` on Linux/Windows). JSON output includes `failureKind`, `httpStatus`, and `retryAfterMs` on unavailable responses.
|
|
130
130
|
|
|
131
131
|
When multi-account is enabled, `sidekick quota` shows the active account email above the quota bars.
|
|
132
132
|
|
package/dist/sidekick-cli.mjs
CHANGED
|
@@ -4865,6 +4865,31 @@ var require_detect = __commonJS({
|
|
|
4865
4865
|
function getCodexHomes() {
|
|
4866
4866
|
return (0, codexProfiles_1.getCodexMonitoringHomes)();
|
|
4867
4867
|
}
|
|
4868
|
+
function hasCodexStateDb(codexHome) {
|
|
4869
|
+
try {
|
|
4870
|
+
return fs9.readdirSync(codexHome).some((entry) => /^state(?:_\d+)?\.sqlite$/.test(entry));
|
|
4871
|
+
} catch {
|
|
4872
|
+
return false;
|
|
4873
|
+
}
|
|
4874
|
+
}
|
|
4875
|
+
function getCodexStateDbMtime(codexHome) {
|
|
4876
|
+
try {
|
|
4877
|
+
let latest = 0;
|
|
4878
|
+
for (const entry of fs9.readdirSync(codexHome)) {
|
|
4879
|
+
if (!/^state(?:_\d+)?\.sqlite$/.test(entry))
|
|
4880
|
+
continue;
|
|
4881
|
+
try {
|
|
4882
|
+
const mtime = fs9.statSync(path8.join(codexHome, entry)).mtime.getTime();
|
|
4883
|
+
if (mtime > latest)
|
|
4884
|
+
latest = mtime;
|
|
4885
|
+
} catch {
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
return latest;
|
|
4889
|
+
} catch {
|
|
4890
|
+
return 0;
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4868
4893
|
function getMostRecentMtime(dir) {
|
|
4869
4894
|
try {
|
|
4870
4895
|
if (!fs9.existsSync(dir))
|
|
@@ -4903,13 +4928,9 @@ var require_detect = __commonJS({
|
|
|
4903
4928
|
function getCodexActivityMtime() {
|
|
4904
4929
|
let latest = 0;
|
|
4905
4930
|
for (const codexHome of getCodexHomes()) {
|
|
4906
|
-
const
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
if (dbMtime > latest)
|
|
4910
|
-
latest = dbMtime;
|
|
4911
|
-
} catch {
|
|
4912
|
-
}
|
|
4931
|
+
const dbMtime = getCodexStateDbMtime(codexHome);
|
|
4932
|
+
if (dbMtime > latest)
|
|
4933
|
+
latest = dbMtime;
|
|
4913
4934
|
const sessionsMtime = getMostRecentMtime(path8.join(codexHome, "sessions"));
|
|
4914
4935
|
if (sessionsMtime > latest)
|
|
4915
4936
|
latest = sessionsMtime;
|
|
@@ -4931,7 +4952,7 @@ var require_detect = __commonJS({
|
|
|
4931
4952
|
const { claudeBase, openCodeDbPath, openCodeStorageDir, codexHomes } = getProviderPaths();
|
|
4932
4953
|
const hasClaude = fs9.existsSync(claudeBase);
|
|
4933
4954
|
const hasOpenCode = fs9.existsSync(openCodeStorageDir) || fs9.existsSync(openCodeDbPath);
|
|
4934
|
-
const hasCodex = codexHomes.some((codexHome) => fs9.existsSync(path8.join(codexHome, "sessions")) ||
|
|
4955
|
+
const hasCodex = codexHomes.some((codexHome) => fs9.existsSync(path8.join(codexHome, "sessions")) || hasCodexStateDb(codexHome));
|
|
4935
4956
|
const available = [];
|
|
4936
4957
|
if (hasClaude)
|
|
4937
4958
|
available.push({ id: "claude-code", mtime: getMostRecentMtime(claudeBase) });
|
|
@@ -4948,7 +4969,7 @@ var require_detect = __commonJS({
|
|
|
4948
4969
|
const { claudeBase, openCodeDbPath, openCodeStorageDir, codexHomes } = getProviderPaths();
|
|
4949
4970
|
const hasClaude = fs9.existsSync(claudeBase);
|
|
4950
4971
|
const hasOpenCode = fs9.existsSync(openCodeStorageDir) || fs9.existsSync(openCodeDbPath);
|
|
4951
|
-
const hasCodex = codexHomes.some((codexHome) => fs9.existsSync(path8.join(codexHome, "sessions")) ||
|
|
4972
|
+
const hasCodex = codexHomes.some((codexHome) => fs9.existsSync(path8.join(codexHome, "sessions")) || hasCodexStateDb(codexHome));
|
|
4952
4973
|
const available = [];
|
|
4953
4974
|
if (hasClaude) {
|
|
4954
4975
|
available.push({ id: "claude-code", mtime: getMostRecentMtime(claudeBase) });
|
|
@@ -8984,7 +9005,7 @@ var require_codexDatabase = __commonJS({
|
|
|
8984
9005
|
dbPath;
|
|
8985
9006
|
sqlite3Available = null;
|
|
8986
9007
|
constructor(codexHome) {
|
|
8987
|
-
this.dbPath = path8.join(codexHome, "state.sqlite");
|
|
9008
|
+
this.dbPath = findLatestStateDatabase(codexHome) ?? path8.join(codexHome, "state.sqlite");
|
|
8988
9009
|
}
|
|
8989
9010
|
isAvailable() {
|
|
8990
9011
|
try {
|
|
@@ -9075,6 +9096,28 @@ var require_codexDatabase = __commonJS({
|
|
|
9075
9096
|
}
|
|
9076
9097
|
};
|
|
9077
9098
|
exports.CodexDatabase = CodexDatabase;
|
|
9099
|
+
function findLatestStateDatabase(codexHome) {
|
|
9100
|
+
try {
|
|
9101
|
+
const entries = fs9.readdirSync(codexHome, { withFileTypes: true });
|
|
9102
|
+
const candidates = [];
|
|
9103
|
+
for (const entry of entries) {
|
|
9104
|
+
if (!entry.isFile() || !/^state(?:_\d+)?\.sqlite$/.test(entry.name))
|
|
9105
|
+
continue;
|
|
9106
|
+
const dbPath = path8.join(codexHome, entry.name);
|
|
9107
|
+
try {
|
|
9108
|
+
const stat = fs9.statSync(dbPath);
|
|
9109
|
+
if (stat.size > 0) {
|
|
9110
|
+
candidates.push({ path: dbPath, mtime: stat.mtime.getTime() });
|
|
9111
|
+
}
|
|
9112
|
+
} catch {
|
|
9113
|
+
}
|
|
9114
|
+
}
|
|
9115
|
+
candidates.sort((a, b) => b.mtime - a.mtime);
|
|
9116
|
+
return candidates[0]?.path ?? null;
|
|
9117
|
+
} catch {
|
|
9118
|
+
return null;
|
|
9119
|
+
}
|
|
9120
|
+
}
|
|
9078
9121
|
function normalizePath(input) {
|
|
9079
9122
|
try {
|
|
9080
9123
|
return fs9.realpathSync(input);
|
|
@@ -11668,15 +11711,15 @@ var require_jsonlWatcher = __commonJS({
|
|
|
11668
11711
|
if (evtType === "token_count") {
|
|
11669
11712
|
const info = payload?.info;
|
|
11670
11713
|
const usage = info?.last_token_usage || info?.total_token_usage;
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11714
|
+
const rl = payload?.rate_limits;
|
|
11715
|
+
const rateLimits = rl ? extractRateLimits(rl) : void 0;
|
|
11716
|
+
if (usage || rateLimits) {
|
|
11674
11717
|
events.push({
|
|
11675
11718
|
providerId: "codex",
|
|
11676
11719
|
type: "system",
|
|
11677
11720
|
timestamp: ts,
|
|
11678
|
-
summary: `Tokens: ${usage.input_tokens ?? 0} in / ${usage.output_tokens ?? 0} out
|
|
11679
|
-
tokens: { input: usage.input_tokens || 0, output: usage.output_tokens || 0 },
|
|
11721
|
+
summary: usage ? `Tokens: ${usage.input_tokens ?? 0} in / ${usage.output_tokens ?? 0} out` : "Rate limits updated",
|
|
11722
|
+
tokens: usage ? { input: usage.input_tokens || 0, output: usage.output_tokens || 0 } : void 0,
|
|
11680
11723
|
rateLimits,
|
|
11681
11724
|
raw
|
|
11682
11725
|
});
|
|
@@ -12056,7 +12099,7 @@ var require_factory = __commonJS({
|
|
|
12056
12099
|
};
|
|
12057
12100
|
}();
|
|
12058
12101
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12059
|
-
exports.createWatcher =
|
|
12102
|
+
exports.createWatcher = createWatcher4;
|
|
12060
12103
|
var os6 = __importStar(__require("os"));
|
|
12061
12104
|
var path8 = __importStar(__require("path"));
|
|
12062
12105
|
var jsonlWatcher_1 = require_jsonlWatcher();
|
|
@@ -12067,7 +12110,7 @@ var require_factory = __commonJS({
|
|
|
12067
12110
|
return path8.join(xdg, "opencode");
|
|
12068
12111
|
return path8.join(os6.homedir(), ".local", "share", "opencode");
|
|
12069
12112
|
}
|
|
12070
|
-
function
|
|
12113
|
+
function createWatcher4(options) {
|
|
12071
12114
|
const { provider, workspacePath, sessionId, callbacks } = options;
|
|
12072
12115
|
const sessions = provider.findAllSessions(workspacePath);
|
|
12073
12116
|
if (sessions.length === 0) {
|
|
@@ -18839,8 +18882,8 @@ var require_quotaSnapshots = __commonJS({
|
|
|
18839
18882
|
};
|
|
18840
18883
|
}();
|
|
18841
18884
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18842
|
-
exports.writeQuotaSnapshot =
|
|
18843
|
-
exports.readQuotaSnapshot =
|
|
18885
|
+
exports.writeQuotaSnapshot = writeQuotaSnapshot;
|
|
18886
|
+
exports.readQuotaSnapshot = readQuotaSnapshot;
|
|
18844
18887
|
var crypto = __importStar(__require("crypto"));
|
|
18845
18888
|
var fs9 = __importStar(__require("fs"));
|
|
18846
18889
|
var path8 = __importStar(__require("path"));
|
|
@@ -18883,7 +18926,7 @@ var require_quotaSnapshots = __commonJS({
|
|
|
18883
18926
|
ensureConfigDir();
|
|
18884
18927
|
atomicWriteJson(getQuotaSnapshotPath(), store);
|
|
18885
18928
|
}
|
|
18886
|
-
function
|
|
18929
|
+
function writeQuotaSnapshot(providerId, accountId, quota) {
|
|
18887
18930
|
const store = readStore();
|
|
18888
18931
|
const snapshot = {
|
|
18889
18932
|
...quota,
|
|
@@ -18905,7 +18948,7 @@ var require_quotaSnapshots = __commonJS({
|
|
|
18905
18948
|
}
|
|
18906
18949
|
writeStore(store);
|
|
18907
18950
|
}
|
|
18908
|
-
function
|
|
18951
|
+
function readQuotaSnapshot(providerId, accountId) {
|
|
18909
18952
|
const store = readStore();
|
|
18910
18953
|
const snapshot = store.snapshots.find((item) => item.providerId === providerId && item.accountId === accountId);
|
|
18911
18954
|
if (!snapshot)
|
|
@@ -18924,24 +18967,413 @@ var require_quotaSnapshots = __commonJS({
|
|
|
18924
18967
|
var require_codexQuota = __commonJS({
|
|
18925
18968
|
"../sidekick-shared/dist/codexQuota.js"(exports) {
|
|
18926
18969
|
"use strict";
|
|
18970
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
18971
|
+
if (k2 === void 0) k2 = k;
|
|
18972
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18973
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18974
|
+
desc = { enumerable: true, get: function() {
|
|
18975
|
+
return m[k];
|
|
18976
|
+
} };
|
|
18977
|
+
}
|
|
18978
|
+
Object.defineProperty(o, k2, desc);
|
|
18979
|
+
} : function(o, m, k, k2) {
|
|
18980
|
+
if (k2 === void 0) k2 = k;
|
|
18981
|
+
o[k2] = m[k];
|
|
18982
|
+
});
|
|
18983
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
|
|
18984
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18985
|
+
} : function(o, v) {
|
|
18986
|
+
o["default"] = v;
|
|
18987
|
+
});
|
|
18988
|
+
var __importStar = exports && exports.__importStar || /* @__PURE__ */ function() {
|
|
18989
|
+
var ownKeys = function(o) {
|
|
18990
|
+
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
18991
|
+
var ar = [];
|
|
18992
|
+
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
18993
|
+
return ar;
|
|
18994
|
+
};
|
|
18995
|
+
return ownKeys(o);
|
|
18996
|
+
};
|
|
18997
|
+
return function(mod) {
|
|
18998
|
+
if (mod && mod.__esModule) return mod;
|
|
18999
|
+
var result = {};
|
|
19000
|
+
if (mod != null) {
|
|
19001
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
19002
|
+
}
|
|
19003
|
+
__setModuleDefault(result, mod);
|
|
19004
|
+
return result;
|
|
19005
|
+
};
|
|
19006
|
+
}();
|
|
18927
19007
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18928
|
-
exports.quotaFromCodexRateLimits =
|
|
18929
|
-
|
|
19008
|
+
exports.quotaFromCodexRateLimits = quotaFromCodexRateLimits2;
|
|
19009
|
+
exports.readLatestCodexQuotaFromRollouts = readLatestCodexQuotaFromRollouts;
|
|
19010
|
+
exports.resolveCodexQuotaFromLocalSources = resolveCodexQuotaFromLocalSources;
|
|
19011
|
+
exports.resolveCodexQuota = resolveCodexQuota2;
|
|
19012
|
+
exports.fetchCodexQuotaFromApi = fetchCodexQuotaFromApi;
|
|
19013
|
+
var fs9 = __importStar(__require("fs"));
|
|
19014
|
+
var path8 = __importStar(__require("path"));
|
|
19015
|
+
var codexProfiles_1 = require_codexProfiles();
|
|
19016
|
+
var quotaSnapshots_1 = require_quotaSnapshots();
|
|
19017
|
+
var codex_1 = require_codex();
|
|
19018
|
+
var DEFAULT_TAIL_BYTES = 2 * 1024 * 1024;
|
|
19019
|
+
var DEFAULT_MAX_SESSION_FILES = 50;
|
|
19020
|
+
var CHATGPT_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
|
|
19021
|
+
function normalizePercent(value) {
|
|
19022
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
19023
|
+
}
|
|
19024
|
+
function timestampToIso(seconds) {
|
|
19025
|
+
if (typeof seconds !== "number" || !Number.isFinite(seconds) || seconds <= 0) {
|
|
19026
|
+
return "";
|
|
19027
|
+
}
|
|
19028
|
+
return new Date(seconds * 1e3).toISOString();
|
|
19029
|
+
}
|
|
19030
|
+
function accountEmail(account) {
|
|
19031
|
+
return account?.email ?? account?.metadata?.email;
|
|
19032
|
+
}
|
|
19033
|
+
function enrichCodexQuota(state, account) {
|
|
19034
|
+
return {
|
|
19035
|
+
...state,
|
|
19036
|
+
runtimeProvider: "codex",
|
|
19037
|
+
providerId: "codex",
|
|
19038
|
+
accountLabel: account?.label,
|
|
19039
|
+
accountDetail: accountEmail(account)
|
|
19040
|
+
};
|
|
19041
|
+
}
|
|
19042
|
+
function unavailableCodexQuota(error, account, meta = {}) {
|
|
19043
|
+
return enrichCodexQuota({
|
|
19044
|
+
fiveHour: { utilization: 0, resetsAt: "" },
|
|
19045
|
+
sevenDay: { utilization: 0, resetsAt: "" },
|
|
19046
|
+
available: false,
|
|
19047
|
+
error,
|
|
19048
|
+
providerId: "codex",
|
|
19049
|
+
fiveHourLabel: "Primary",
|
|
19050
|
+
sevenDayLabel: "Secondary",
|
|
19051
|
+
...meta
|
|
19052
|
+
}, account);
|
|
19053
|
+
}
|
|
19054
|
+
function parseRetryAfterMs(retryAfter) {
|
|
19055
|
+
if (!retryAfter)
|
|
19056
|
+
return void 0;
|
|
19057
|
+
const seconds = Number(retryAfter);
|
|
19058
|
+
if (Number.isFinite(seconds) && seconds >= 0) {
|
|
19059
|
+
return Math.round(seconds * 1e3);
|
|
19060
|
+
}
|
|
19061
|
+
const retryAt = Date.parse(retryAfter);
|
|
19062
|
+
if (Number.isNaN(retryAt))
|
|
19063
|
+
return void 0;
|
|
19064
|
+
return Math.max(retryAt - Date.now(), 0);
|
|
19065
|
+
}
|
|
19066
|
+
function firstString(value) {
|
|
19067
|
+
return typeof value === "string" && value.trim() ? value : void 0;
|
|
19068
|
+
}
|
|
19069
|
+
function normalizeCredits(credits) {
|
|
19070
|
+
if (!credits)
|
|
19071
|
+
return void 0;
|
|
19072
|
+
return {
|
|
19073
|
+
hasCredits: credits.has_credits ?? credits.hasCredits,
|
|
19074
|
+
unlimited: credits.unlimited,
|
|
19075
|
+
balance: credits.balance ?? void 0
|
|
19076
|
+
};
|
|
19077
|
+
}
|
|
19078
|
+
function normalizeRateLimitReachedType(value) {
|
|
19079
|
+
if (typeof value === "string")
|
|
19080
|
+
return value;
|
|
19081
|
+
return firstString(value?.kind);
|
|
19082
|
+
}
|
|
19083
|
+
function normalizeApiWindow(window2) {
|
|
19084
|
+
if (!window2)
|
|
19085
|
+
return void 0;
|
|
19086
|
+
const windowMinutes = typeof window2.window_minutes === "number" || window2.window_minutes === null ? window2.window_minutes : typeof window2.limit_window_seconds === "number" ? Math.round(window2.limit_window_seconds / 60) : void 0;
|
|
19087
|
+
const resetsAt = typeof window2.resets_at === "number" || window2.resets_at === null ? window2.resets_at : window2.reset_at;
|
|
19088
|
+
return {
|
|
19089
|
+
used_percent: normalizePercent(window2.used_percent),
|
|
19090
|
+
window_minutes: windowMinutes,
|
|
19091
|
+
resets_at: resetsAt
|
|
19092
|
+
};
|
|
19093
|
+
}
|
|
19094
|
+
function rateLimitsFromUsagePayload(payload) {
|
|
19095
|
+
if (payload.primary || payload.secondary) {
|
|
19096
|
+
return {
|
|
19097
|
+
limit_id: payload.limit_id ?? "codex",
|
|
19098
|
+
limit_name: payload.limit_name ?? null,
|
|
19099
|
+
primary: payload.primary,
|
|
19100
|
+
secondary: payload.secondary,
|
|
19101
|
+
credits: normalizeCredits(payload.credits),
|
|
19102
|
+
plan_type: payload.plan_type ?? void 0,
|
|
19103
|
+
rate_limit_reached_type: normalizeRateLimitReachedType(payload.rate_limit_reached_type)
|
|
19104
|
+
};
|
|
19105
|
+
}
|
|
19106
|
+
const preferred = payload.rate_limit;
|
|
19107
|
+
return {
|
|
19108
|
+
limit_id: "codex",
|
|
19109
|
+
limit_name: null,
|
|
19110
|
+
primary: normalizeApiWindow(preferred?.primary_window),
|
|
19111
|
+
secondary: normalizeApiWindow(preferred?.secondary_window),
|
|
19112
|
+
credits: normalizeCredits(payload.credits),
|
|
19113
|
+
plan_type: payload.plan_type ?? void 0,
|
|
19114
|
+
rate_limit_reached_type: normalizeRateLimitReachedType(payload.rate_limit_reached_type)
|
|
19115
|
+
};
|
|
19116
|
+
}
|
|
19117
|
+
function quotaFromCodexRateLimits2(rateLimits, source = "session", capturedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
18930
19118
|
const primary = rateLimits?.primary;
|
|
18931
19119
|
const secondary = rateLimits?.secondary;
|
|
18932
19120
|
if (!primary && !secondary)
|
|
18933
19121
|
return null;
|
|
18934
19122
|
return {
|
|
18935
|
-
fiveHour: primary ? { utilization: primary.used_percent, resetsAt:
|
|
18936
|
-
sevenDay: secondary ? { utilization: secondary.used_percent, resetsAt:
|
|
19123
|
+
fiveHour: primary ? { utilization: normalizePercent(primary.used_percent), resetsAt: timestampToIso(primary.resets_at) } : { utilization: 0, resetsAt: "" },
|
|
19124
|
+
sevenDay: secondary ? { utilization: normalizePercent(secondary.used_percent), resetsAt: timestampToIso(secondary.resets_at) } : { utilization: 0, resetsAt: "" },
|
|
18937
19125
|
available: true,
|
|
18938
19126
|
providerId: "codex",
|
|
18939
19127
|
source,
|
|
18940
19128
|
capturedAt,
|
|
18941
19129
|
stale: source === "cache",
|
|
18942
19130
|
fiveHourLabel: "Primary",
|
|
18943
|
-
sevenDayLabel: "Secondary"
|
|
18944
|
-
|
|
19131
|
+
sevenDayLabel: "Secondary",
|
|
19132
|
+
limitId: rateLimits?.limit_id,
|
|
19133
|
+
limitName: rateLimits?.limit_name ?? void 0,
|
|
19134
|
+
credits: rateLimits?.credits,
|
|
19135
|
+
planType: rateLimits?.plan_type,
|
|
19136
|
+
rateLimitReachedType: rateLimits?.rate_limit_reached_type
|
|
19137
|
+
};
|
|
19138
|
+
}
|
|
19139
|
+
function readLatestCodexQuotaFromRollouts(sessionPaths, options = {}) {
|
|
19140
|
+
const maxSessionFiles = options.maxSessionFiles ?? DEFAULT_MAX_SESSION_FILES;
|
|
19141
|
+
const maxTailBytes = options.maxTailBytes ?? DEFAULT_TAIL_BYTES;
|
|
19142
|
+
for (const sessionPath of sessionPaths.slice(0, maxSessionFiles)) {
|
|
19143
|
+
const hit = readLatestQuotaFromRollout(sessionPath, maxTailBytes, options.source ?? "session");
|
|
19144
|
+
if (hit)
|
|
19145
|
+
return hit.quota;
|
|
19146
|
+
}
|
|
19147
|
+
return null;
|
|
19148
|
+
}
|
|
19149
|
+
function resolveCodexQuotaFromLocalSources(options = {}) {
|
|
19150
|
+
const account = options.activeAccount !== void 0 ? options.activeAccount : (0, codexProfiles_1.getActiveCodexAccount)();
|
|
19151
|
+
const readSnapshot = options.readSnapshot ?? quotaSnapshots_1.readQuotaSnapshot;
|
|
19152
|
+
const writeSnapshot = options.writeSnapshot ?? quotaSnapshots_1.writeQuotaSnapshot;
|
|
19153
|
+
const maxTailBytes = options.maxTailBytes ?? DEFAULT_TAIL_BYTES;
|
|
19154
|
+
const maxSessionFiles = options.maxSessionFiles ?? DEFAULT_MAX_SESSION_FILES;
|
|
19155
|
+
let ownProvider = false;
|
|
19156
|
+
const provider = options.provider ?? (() => {
|
|
19157
|
+
ownProvider = true;
|
|
19158
|
+
return new codex_1.CodexProvider();
|
|
19159
|
+
})();
|
|
19160
|
+
try {
|
|
19161
|
+
const workspaceSessions = options.workspacePath ? provider.findAllSessions(options.workspacePath) : [];
|
|
19162
|
+
const workspaceQuota = readLatestCodexQuotaFromRollouts(workspaceSessions, { maxTailBytes, maxSessionFiles });
|
|
19163
|
+
if (workspaceQuota) {
|
|
19164
|
+
if (account)
|
|
19165
|
+
writeSnapshot("codex", account.id, workspaceQuota);
|
|
19166
|
+
return enrichCodexQuota(workspaceQuota, account);
|
|
19167
|
+
}
|
|
19168
|
+
const codexHome = options.codexHome ?? (0, codexProfiles_1.resolveSidekickCodexHome)();
|
|
19169
|
+
const accountSessions = findRolloutFiles(path8.join(codexHome, "sessions"));
|
|
19170
|
+
const accountQuota = readLatestCodexQuotaFromRollouts(accountSessions, { maxTailBytes, maxSessionFiles });
|
|
19171
|
+
if (accountQuota) {
|
|
19172
|
+
if (account)
|
|
19173
|
+
writeSnapshot("codex", account.id, accountQuota);
|
|
19174
|
+
return enrichCodexQuota(accountQuota, account);
|
|
19175
|
+
}
|
|
19176
|
+
const cached = account ? readSnapshot("codex", account.id) : null;
|
|
19177
|
+
if (cached) {
|
|
19178
|
+
return enrichCodexQuota({
|
|
19179
|
+
...cached,
|
|
19180
|
+
providerId: "codex",
|
|
19181
|
+
source: "cache",
|
|
19182
|
+
stale: true,
|
|
19183
|
+
fiveHourLabel: cached.fiveHourLabel ?? "Primary",
|
|
19184
|
+
sevenDayLabel: cached.sevenDayLabel ?? "Secondary"
|
|
19185
|
+
}, account);
|
|
19186
|
+
}
|
|
19187
|
+
} finally {
|
|
19188
|
+
if (ownProvider)
|
|
19189
|
+
provider.dispose();
|
|
19190
|
+
}
|
|
19191
|
+
return null;
|
|
19192
|
+
}
|
|
19193
|
+
async function resolveCodexQuota2(options = {}) {
|
|
19194
|
+
const source = options.source ?? "local";
|
|
19195
|
+
const account = options.activeAccount !== void 0 ? options.activeAccount : (0, codexProfiles_1.getActiveCodexAccount)();
|
|
19196
|
+
const writeSnapshot = options.writeSnapshot ?? quotaSnapshots_1.writeQuotaSnapshot;
|
|
19197
|
+
if (source === "api") {
|
|
19198
|
+
const apiQuota = await fetchCodexQuotaFromApi(options);
|
|
19199
|
+
if (apiQuota.available) {
|
|
19200
|
+
if (account)
|
|
19201
|
+
writeSnapshot("codex", account.id, apiQuota);
|
|
19202
|
+
return enrichCodexQuota(apiQuota, account);
|
|
19203
|
+
}
|
|
19204
|
+
const fallback = resolveCodexQuotaFromLocalSources(options);
|
|
19205
|
+
return fallback ?? enrichCodexQuota(apiQuota, account);
|
|
19206
|
+
}
|
|
19207
|
+
const local = resolveCodexQuotaFromLocalSources(options);
|
|
19208
|
+
if (local)
|
|
19209
|
+
return local;
|
|
19210
|
+
if (source === "auto") {
|
|
19211
|
+
const apiQuota = await fetchCodexQuotaFromApi(options);
|
|
19212
|
+
if (apiQuota.available && account) {
|
|
19213
|
+
writeSnapshot("codex", account.id, apiQuota);
|
|
19214
|
+
}
|
|
19215
|
+
return enrichCodexQuota(apiQuota, account);
|
|
19216
|
+
}
|
|
19217
|
+
return unavailableCodexQuota(account ? `No Codex rate-limit data is available for "${account.label ?? account.id}".` : "No Codex rate-limit data is available.", account, { source: "session" });
|
|
19218
|
+
}
|
|
19219
|
+
async function fetchCodexQuotaFromApi(options = {}) {
|
|
19220
|
+
const capturedAt = options.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
19221
|
+
const accessToken = options.accessToken ?? readCodexAccessToken(options.codexHome ?? (0, codexProfiles_1.resolveSidekickCodexHome)());
|
|
19222
|
+
if (!accessToken) {
|
|
19223
|
+
return {
|
|
19224
|
+
fiveHour: { utilization: 0, resetsAt: "" },
|
|
19225
|
+
sevenDay: { utilization: 0, resetsAt: "" },
|
|
19226
|
+
available: false,
|
|
19227
|
+
error: "Codex API refresh requires a ChatGPT login.",
|
|
19228
|
+
failureKind: "auth",
|
|
19229
|
+
providerId: "codex",
|
|
19230
|
+
source: "api",
|
|
19231
|
+
capturedAt,
|
|
19232
|
+
fiveHourLabel: "Primary",
|
|
19233
|
+
sevenDayLabel: "Secondary"
|
|
19234
|
+
};
|
|
19235
|
+
}
|
|
19236
|
+
try {
|
|
19237
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
19238
|
+
const response = await fetchImpl(options.usageUrl ?? CHATGPT_USAGE_URL, {
|
|
19239
|
+
method: "GET",
|
|
19240
|
+
headers: {
|
|
19241
|
+
Authorization: `Bearer ${accessToken}`,
|
|
19242
|
+
Accept: "application/json"
|
|
19243
|
+
}
|
|
19244
|
+
});
|
|
19245
|
+
if (!response.ok) {
|
|
19246
|
+
return {
|
|
19247
|
+
fiveHour: { utilization: 0, resetsAt: "" },
|
|
19248
|
+
sevenDay: { utilization: 0, resetsAt: "" },
|
|
19249
|
+
available: false,
|
|
19250
|
+
error: `Codex usage API error: ${response.status}`,
|
|
19251
|
+
failureKind: response.status === 401 || response.status === 403 ? "auth" : response.status === 429 ? "rate_limit" : response.status >= 500 && response.status <= 599 ? "server" : "unknown",
|
|
19252
|
+
httpStatus: response.status,
|
|
19253
|
+
retryAfterMs: response.status === 429 ? parseRetryAfterMs(response.headers.get("retry-after")) : void 0,
|
|
19254
|
+
providerId: "codex",
|
|
19255
|
+
source: "api",
|
|
19256
|
+
capturedAt,
|
|
19257
|
+
fiveHourLabel: "Primary",
|
|
19258
|
+
sevenDayLabel: "Secondary"
|
|
19259
|
+
};
|
|
19260
|
+
}
|
|
19261
|
+
const payload = await response.json();
|
|
19262
|
+
const quota = quotaFromCodexRateLimits2(rateLimitsFromUsagePayload(payload), "api", capturedAt);
|
|
19263
|
+
if (!quota) {
|
|
19264
|
+
return {
|
|
19265
|
+
fiveHour: { utilization: 0, resetsAt: "" },
|
|
19266
|
+
sevenDay: { utilization: 0, resetsAt: "" },
|
|
19267
|
+
available: false,
|
|
19268
|
+
error: "Codex usage API returned no rate-limit windows.",
|
|
19269
|
+
failureKind: "unknown",
|
|
19270
|
+
providerId: "codex",
|
|
19271
|
+
source: "api",
|
|
19272
|
+
capturedAt,
|
|
19273
|
+
fiveHourLabel: "Primary",
|
|
19274
|
+
sevenDayLabel: "Secondary"
|
|
19275
|
+
};
|
|
19276
|
+
}
|
|
19277
|
+
return quota;
|
|
19278
|
+
} catch {
|
|
19279
|
+
return {
|
|
19280
|
+
fiveHour: { utilization: 0, resetsAt: "" },
|
|
19281
|
+
sevenDay: { utilization: 0, resetsAt: "" },
|
|
19282
|
+
available: false,
|
|
19283
|
+
error: "Codex usage API network error",
|
|
19284
|
+
failureKind: "network",
|
|
19285
|
+
providerId: "codex",
|
|
19286
|
+
source: "api",
|
|
19287
|
+
capturedAt,
|
|
19288
|
+
fiveHourLabel: "Primary",
|
|
19289
|
+
sevenDayLabel: "Secondary"
|
|
19290
|
+
};
|
|
19291
|
+
}
|
|
19292
|
+
}
|
|
19293
|
+
function readCodexAccessToken(codexHome) {
|
|
19294
|
+
try {
|
|
19295
|
+
const parsed = JSON.parse(fs9.readFileSync(path8.join(codexHome, "auth.json"), "utf8"));
|
|
19296
|
+
if (parsed.OPENAI_API_KEY || parsed.auth_mode === "api_key")
|
|
19297
|
+
return null;
|
|
19298
|
+
return parsed.tokens?.access_token || null;
|
|
19299
|
+
} catch {
|
|
19300
|
+
return null;
|
|
19301
|
+
}
|
|
19302
|
+
}
|
|
19303
|
+
function readLatestQuotaFromRollout(sessionPath, maxTailBytes, source) {
|
|
19304
|
+
let fd = null;
|
|
19305
|
+
try {
|
|
19306
|
+
const stat = fs9.statSync(sessionPath);
|
|
19307
|
+
if (!stat.isFile() || stat.size <= 0)
|
|
19308
|
+
return null;
|
|
19309
|
+
const start = Math.max(0, stat.size - maxTailBytes);
|
|
19310
|
+
const bytesToRead = stat.size - start;
|
|
19311
|
+
const buffer = Buffer.alloc(bytesToRead);
|
|
19312
|
+
fd = fs9.openSync(sessionPath, "r");
|
|
19313
|
+
const bytesRead = fs9.readSync(fd, buffer, 0, bytesToRead, start);
|
|
19314
|
+
fs9.closeSync(fd);
|
|
19315
|
+
fd = null;
|
|
19316
|
+
let text = buffer.toString("utf8", 0, bytesRead);
|
|
19317
|
+
if (start > 0) {
|
|
19318
|
+
const firstNewline = text.indexOf("\n");
|
|
19319
|
+
text = firstNewline >= 0 ? text.slice(firstNewline + 1) : "";
|
|
19320
|
+
}
|
|
19321
|
+
const lines = text.split("\n");
|
|
19322
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
19323
|
+
const line = lines[i].trim();
|
|
19324
|
+
if (!line || !line.includes("rate_limits"))
|
|
19325
|
+
continue;
|
|
19326
|
+
try {
|
|
19327
|
+
const parsed = JSON.parse(line);
|
|
19328
|
+
if (parsed.type !== "event_msg" || parsed.payload?.type !== "token_count")
|
|
19329
|
+
continue;
|
|
19330
|
+
const quota = quotaFromCodexRateLimits2(parsed.payload.rate_limits, source, parsed.timestamp ?? new Date(stat.mtime).toISOString());
|
|
19331
|
+
if (quota)
|
|
19332
|
+
return { quota, filePath: sessionPath };
|
|
19333
|
+
} catch {
|
|
19334
|
+
}
|
|
19335
|
+
}
|
|
19336
|
+
} catch {
|
|
19337
|
+
return null;
|
|
19338
|
+
} finally {
|
|
19339
|
+
if (fd !== null) {
|
|
19340
|
+
try {
|
|
19341
|
+
fs9.closeSync(fd);
|
|
19342
|
+
} catch {
|
|
19343
|
+
}
|
|
19344
|
+
}
|
|
19345
|
+
}
|
|
19346
|
+
return null;
|
|
19347
|
+
}
|
|
19348
|
+
function findRolloutFiles(sessionsDir) {
|
|
19349
|
+
const results = [];
|
|
19350
|
+
function visit(dir) {
|
|
19351
|
+
let entries;
|
|
19352
|
+
try {
|
|
19353
|
+
entries = fs9.readdirSync(dir, { withFileTypes: true });
|
|
19354
|
+
} catch {
|
|
19355
|
+
return;
|
|
19356
|
+
}
|
|
19357
|
+
for (const entry of entries) {
|
|
19358
|
+
const fullPath = path8.join(dir, entry.name);
|
|
19359
|
+
if (entry.isDirectory()) {
|
|
19360
|
+
visit(fullPath);
|
|
19361
|
+
continue;
|
|
19362
|
+
}
|
|
19363
|
+
if (!entry.isFile() || !entry.name.startsWith("rollout-") || !entry.name.endsWith(".jsonl"))
|
|
19364
|
+
continue;
|
|
19365
|
+
try {
|
|
19366
|
+
const stat = fs9.statSync(fullPath);
|
|
19367
|
+
if (stat.size > 0) {
|
|
19368
|
+
results.push({ path: fullPath, mtime: stat.mtime.getTime() });
|
|
19369
|
+
}
|
|
19370
|
+
} catch {
|
|
19371
|
+
}
|
|
19372
|
+
}
|
|
19373
|
+
}
|
|
19374
|
+
visit(sessionsDir);
|
|
19375
|
+
results.sort((a, b) => b.mtime - a.mtime);
|
|
19376
|
+
return results.map((item) => item.path);
|
|
18945
19377
|
}
|
|
18946
19378
|
}
|
|
18947
19379
|
});
|
|
@@ -19029,6 +19461,8 @@ var require_codexQuotaWatcher = __commonJS({
|
|
|
19029
19461
|
readSnapshot;
|
|
19030
19462
|
writeSnapshot;
|
|
19031
19463
|
watchFile;
|
|
19464
|
+
maxTailBytes;
|
|
19465
|
+
maxSessionFiles;
|
|
19032
19466
|
listeners = [];
|
|
19033
19467
|
discoveryTimer;
|
|
19034
19468
|
provider = null;
|
|
@@ -19045,6 +19479,8 @@ var require_codexQuotaWatcher = __commonJS({
|
|
|
19045
19479
|
this.readSnapshot = options.readSnapshot ?? quotaSnapshots_1.readQuotaSnapshot;
|
|
19046
19480
|
this.writeSnapshot = options.writeSnapshot ?? quotaSnapshots_1.writeQuotaSnapshot;
|
|
19047
19481
|
this.watchFile = options.watchFile ?? fs9.watch;
|
|
19482
|
+
this.maxTailBytes = options.maxTailBytes;
|
|
19483
|
+
this.maxSessionFiles = options.maxSessionFiles;
|
|
19048
19484
|
}
|
|
19049
19485
|
start() {
|
|
19050
19486
|
if (this.running)
|
|
@@ -19150,6 +19586,26 @@ var require_codexQuotaWatcher = __commonJS({
|
|
|
19150
19586
|
}
|
|
19151
19587
|
emitCachedOrUnavailable() {
|
|
19152
19588
|
const account = this.getActiveAccount();
|
|
19589
|
+
let localProvider = null;
|
|
19590
|
+
try {
|
|
19591
|
+
localProvider = this.providerFactory();
|
|
19592
|
+
const local = (0, codexQuota_1.resolveCodexQuotaFromLocalSources)({
|
|
19593
|
+
workspacePath: this.workspacePath,
|
|
19594
|
+
activeAccount: account,
|
|
19595
|
+
readSnapshot: this.readSnapshot,
|
|
19596
|
+
writeSnapshot: this.writeSnapshot,
|
|
19597
|
+
provider: localProvider,
|
|
19598
|
+
maxTailBytes: this.maxTailBytes,
|
|
19599
|
+
maxSessionFiles: this.maxSessionFiles
|
|
19600
|
+
});
|
|
19601
|
+
if (local) {
|
|
19602
|
+
this.emitState(local);
|
|
19603
|
+
return;
|
|
19604
|
+
}
|
|
19605
|
+
} catch {
|
|
19606
|
+
} finally {
|
|
19607
|
+
localProvider?.dispose();
|
|
19608
|
+
}
|
|
19153
19609
|
const cached = account ? this.readSnapshot("codex", account.id) : null;
|
|
19154
19610
|
if (cached) {
|
|
19155
19611
|
this.emitState(enrichQuotaState({
|
|
@@ -35961,8 +36417,8 @@ var require_dist = __commonJS({
|
|
|
35961
36417
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35962
36418
|
exports.findActiveClaudeSession = exports.discoverSessionDirectory = exports.getClaudeSessionDirectory = exports.encodeClaudeWorkspacePath = exports.detectSessionActivity = exports.extractTaskInfo = exports.scanSubagentDir = exports.normalizeCodexToolInput = exports.normalizeCodexToolName = exports.extractPatchFilePaths = exports.CodexRolloutParser = exports.parseDbPartData = exports.parseDbMessageData = exports.convertOpenCodeMessage = exports.detectPlanModeFromText = exports.normalizeToolInput = exports.normalizeToolName = exports.TRUNCATION_PATTERNS = exports.JsonlParser = exports.CodexProvider = exports.OpenCodeProvider = exports.ClaudeCodeProvider = exports.getAllDetectedProviders = exports.detectProvider = exports.readClaudeCodePlanFiles = exports.getPlanAnalytics = exports.writePlans = exports.getLatestPlan = exports.readPlans = exports.readLatestHandoff = exports.readHistory = exports.readNotes = exports.readDecisions = exports.readTasks = exports.getProjectSlugRaw = exports.getProjectSlug = exports.encodeWorkspacePath = exports.getGlobalDataPath = exports.getProjectDataPath = exports.getConfigDir = exports.MAX_PLANS_PER_PROJECT = exports.PLAN_SCHEMA_VERSION = exports.createEmptyTokenTotals = exports.HISTORICAL_DATA_SCHEMA_VERSION = exports.STALENESS_THRESHOLDS = exports.IMPORTANCE_DECAY_FACTORS = exports.KNOWLEDGE_NOTE_SCHEMA_VERSION = exports.DECISION_LOG_SCHEMA_VERSION = exports.normalizeTaskStatus = exports.TASK_PERSISTENCE_SCHEMA_VERSION = void 0;
|
|
35963
36419
|
exports.deleteSnapshot = exports.loadSnapshot = exports.saveSnapshot = exports.parseTodoDependencies = exports.EventAggregator = exports.getRandomPhrase = exports.PHRASE_CATEGORIES = exports.ALL_PHRASES = exports.HIGHLIGHT_CSS = exports.clearHighlightCache = exports.highlightEvent = exports.formatSessionJson = exports.formatSessionMarkdown = exports.formatSessionText = exports.classifyNoise = exports.shouldMergeWithPrevious = exports.classifyFollowEvent = exports.classifyMessage = exports.getSoftNoiseReason = exports.isHardNoiseFollowEvent = exports.isHardNoise = exports.formatToolSummary = exports.formatTokenCount = exports.formatDurationMs = exports.createJsonlTail = exports.toFollowEvents = exports.createWatcher = exports.parseChangelog = exports.extractProposedPlanShared = exports.parsePlanMarkdownShared = exports.PlanExtractor = exports.composeContext = exports.FilterEngine = exports.searchSessions = exports.CodexDatabase = exports.OpenCodeDatabase = exports.discoverDebugLogs = exports.collapseDuplicates = exports.filterByLevel = exports.parseDebugLog = exports.scanSubagentTraces = exports.findAllSessionsWithWorktrees = exports.discoverWorktreeSiblings = exports.resolveWorktreeMainRepo = exports.getAllClaudeProjectFolders = exports.decodeEncodedPath = exports.getMostRecentlyActiveSessionDir = exports.findSubdirectorySessionDirs = exports.findSessionsInDirectory = exports.findAllClaudeSessions = void 0;
|
|
35964
|
-
exports.
|
|
35965
|
-
exports.fetchPeakHoursStatus = exports.fetchOpenAIStatus = exports.fetchProviderStatus = exports.permissionModeSchema = exports.sessionEventSchema = exports.sessionMessageSchema = exports.messageUsageSchema = exports.extractToolCalls = exports.extractToolCall = exports.extractTokenUsage = exports.LITELLM_CATALOG_URL = exports.normalizeLiteLlmCatalog = exports.hydratePricingCatalog = exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.getModelPricing = exports.parseModelId = exports.DEFAULT_CONTEXT_WINDOW = exports.getModelContextWindowSize = exports.MultiProviderQuotaService = exports.CodexQuotaWatcher = void 0;
|
|
36420
|
+
exports.fetchCodexQuotaFromApi = exports.writeQuotaSnapshot = exports.readQuotaSnapshot = exports.QuotaPoller = exports.describeQuotaFailure = exports.fetchQuota = exports.removeCodexAccount = exports.switchToCodexAccount = exports.finalizeCodexAccount = exports.prepareCodexAccount = exports.getCodexExecutionEnv = exports.resolveSidekickCodexHome = exports.getActiveCodexAccount = exports.listCodexAccounts = exports.getSystemCodexHome = exports.getCodexMonitoringHomes = exports.getCodexProfileHome = exports.getCodexProfilesDir = exports.getActiveAccountStatus = exports.removeSavedAccountProfile = exports.replaceSavedAccountProfiles = exports.setActiveSavedAccount = exports.upsertSavedAccountProfile = exports.getActiveSavedAccount = exports.listSavedAccountProfiles = exports.writeSavedAccountRegistry = exports.readSavedAccountRegistry = exports.getAccountsDir = exports.isMultiAccountEnabled = exports.getActiveAccount = exports.listAccounts = exports.removeAccount = exports.switchToAccount = exports.addCurrentAccount = exports.readActiveClaudeAccount = exports.writeAccountRegistry = exports.readAccountRegistry = exports.ensureDefaultAccounts = exports.readClaudeMaxAccessTokenSync = exports.readClaudeMaxCredentials = exports.writeActiveCredentials = exports.readActiveCredentials = exports.openInBrowser = exports.parseTranscript = exports.generateHtmlReport = exports.PatternExtractor = exports.HeatmapTracker = exports.FrequencyTracker = exports.getSnapshotPath = exports.isSnapshotValid = void 0;
|
|
36421
|
+
exports.fetchPeakHoursStatus = exports.fetchOpenAIStatus = exports.fetchProviderStatus = exports.permissionModeSchema = exports.sessionEventSchema = exports.sessionMessageSchema = exports.messageUsageSchema = exports.extractToolCalls = exports.extractToolCall = exports.extractTokenUsage = exports.LITELLM_CATALOG_URL = exports.normalizeLiteLlmCatalog = exports.hydratePricingCatalog = exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.getModelPricing = exports.parseModelId = exports.DEFAULT_CONTEXT_WINDOW = exports.getModelContextWindowSize = exports.MultiProviderQuotaService = exports.CodexQuotaWatcher = exports.resolveCodexQuotaFromLocalSources = exports.resolveCodexQuota = exports.readLatestCodexQuotaFromRollouts = exports.quotaFromCodexRateLimits = void 0;
|
|
35966
36422
|
var taskPersistence_1 = require_taskPersistence();
|
|
35967
36423
|
Object.defineProperty(exports, "TASK_PERSISTENCE_SCHEMA_VERSION", { enumerable: true, get: function() {
|
|
35968
36424
|
return taskPersistence_1.TASK_PERSISTENCE_SCHEMA_VERSION;
|
|
@@ -36468,9 +36924,21 @@ var require_dist = __commonJS({
|
|
|
36468
36924
|
return quotaSnapshots_1.writeQuotaSnapshot;
|
|
36469
36925
|
} });
|
|
36470
36926
|
var codexQuota_1 = require_codexQuota();
|
|
36927
|
+
Object.defineProperty(exports, "fetchCodexQuotaFromApi", { enumerable: true, get: function() {
|
|
36928
|
+
return codexQuota_1.fetchCodexQuotaFromApi;
|
|
36929
|
+
} });
|
|
36471
36930
|
Object.defineProperty(exports, "quotaFromCodexRateLimits", { enumerable: true, get: function() {
|
|
36472
36931
|
return codexQuota_1.quotaFromCodexRateLimits;
|
|
36473
36932
|
} });
|
|
36933
|
+
Object.defineProperty(exports, "readLatestCodexQuotaFromRollouts", { enumerable: true, get: function() {
|
|
36934
|
+
return codexQuota_1.readLatestCodexQuotaFromRollouts;
|
|
36935
|
+
} });
|
|
36936
|
+
Object.defineProperty(exports, "resolveCodexQuota", { enumerable: true, get: function() {
|
|
36937
|
+
return codexQuota_1.resolveCodexQuota;
|
|
36938
|
+
} });
|
|
36939
|
+
Object.defineProperty(exports, "resolveCodexQuotaFromLocalSources", { enumerable: true, get: function() {
|
|
36940
|
+
return codexQuota_1.resolveCodexQuotaFromLocalSources;
|
|
36941
|
+
} });
|
|
36474
36942
|
var codexQuotaWatcher_1 = require_codexQuotaWatcher();
|
|
36475
36943
|
Object.defineProperty(exports, "CodexQuotaWatcher", { enumerable: true, get: function() {
|
|
36476
36944
|
return codexQuotaWatcher_1.CodexQuotaWatcher;
|
|
@@ -38803,7 +39271,7 @@ var init_UpdateCheckService = __esm({
|
|
|
38803
39271
|
/** Run the update check (one-shot). */
|
|
38804
39272
|
async check() {
|
|
38805
39273
|
try {
|
|
38806
|
-
const current = "0.18.
|
|
39274
|
+
const current = "0.18.2";
|
|
38807
39275
|
const cached = this.readCache();
|
|
38808
39276
|
let latest;
|
|
38809
39277
|
if (cached && Date.now() - cached.checkedAt < CACHE_TTL_MS) {
|
|
@@ -79420,7 +79888,7 @@ function StatusBar({
|
|
|
79420
79888
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { children: parseBlessedTags(BRAND_INLINE) }),
|
|
79421
79889
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { dimColor: true, children: [
|
|
79422
79890
|
" v",
|
|
79423
|
-
"0.18.
|
|
79891
|
+
"0.18.2"
|
|
79424
79892
|
] }),
|
|
79425
79893
|
updateInfo && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Text, { color: "yellow", children: [
|
|
79426
79894
|
" (v",
|
|
@@ -79810,7 +80278,7 @@ function ChangelogOverlay({ entries, scrollOffset }) {
|
|
|
79810
80278
|
" ",
|
|
79811
80279
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Text, { bold: true, color: "cyan", children: [
|
|
79812
80280
|
"Terminal Dashboard v",
|
|
79813
|
-
"0.18.
|
|
80281
|
+
"0.18.2"
|
|
79814
80282
|
] }),
|
|
79815
80283
|
latestDate ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Text, { color: "gray", children: [
|
|
79816
80284
|
" \u2014 ",
|
|
@@ -80132,7 +80600,7 @@ var init_mouse = __esm({
|
|
|
80132
80600
|
var CHANGELOG_default;
|
|
80133
80601
|
var init_CHANGELOG = __esm({
|
|
80134
80602
|
"CHANGELOG.md"() {
|
|
80135
|
-
CHANGELOG_default = '# Changelog\n\nAll notable changes to the Sidekick Agent Hub CLI will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n## [0.18.1] - 2026-05-08\n\n### Changed\n\n- **Shared dashboard formatting**: terminal dashboard `fmtNum()` and `formatDuration()` now delegate to `formatTokenCount()` and `formatDurationMs()` from `sidekick-shared`, keeping the existing CLI surface (uppercase `K`/`M` suffix, compact `1m5s` style) while removing forked rounding logic\n\n## [0.18.0] - 2026-05-08\n\n### Changed\n\n- **Bundled `sidekick-shared` 0.18.0**: Picks up the new provider-aware quota orchestration surface \u2014 `MultiProviderQuotaService`, `CodexQuotaWatcher`, `getActiveAccountStatus()`, `extractToolCall()`, cost-provenance helpers (`calculateCostWithProvenance`, `mergeCostSources`), and model display helpers (`shortModelName`, `getModelDisplayInfo`, `compareModelIds`, `sortModelIds`). `parseModelId()` also now recognizes legacy Claude IDs such as `claude-3-opus-20240229` and `claude-3-5-sonnet-20241022`\n- **No CLI runtime changes**: This release ships the shared library upgrade for downstream tooling alignment; `sidekick quota`, `sidekick status`, and the live dashboard keep using the existing polling path. Wiring the new orchestrator into the CLI will land in a follow-up release\n\n## [0.17.7] - 2026-04-28\n\n### Fixed\n\n- **Quota snapshot write race**: Updated the bundled `sidekick-shared` snapshot writer so concurrent `sidekick quota` / Codex session updates no longer collide on `quota-snapshots.json.tmp` or throw `ENOENT`. Failed writes now also clean up their partial temp files instead of leaving orphans in `~/.config/sidekick/`\n\n## [0.17.6] - 2026-04-19\n\n### Added\n\n- **`sidekick peak` command**: One-shot check for Claude\'s current peak-hours state \u2014 weekdays 13:00\u201319:00 UTC, when session limits drain faster on Free/Pro/Max/Team subscriptions. Prints a color-coded status block with a countdown to the next transition. Data comes from the public `promoclock.co/api/status` endpoint (third-party, unaffiliated with Anthropic) with a graceful fallback when unreachable. `--json` emits the full raw state\n- **Peak-hours block in `sidekick status`**: When the active provider is `claude-code`, the Claude + OpenAI health blocks are now followed by a **Claude Peak Hours** block (off-peak or in-peak, with countdown). Gated on the provider so OpenCode / Codex users don\'t trigger an unnecessary third-party fetch. `--json` output includes the new `peak` field\n- **Peak-hours summary in `sidekick quota`**: Claude subscription quota output now shows a **Peak** line under the 5-hour / 7-day bars \u2014 green dot off-peak, orange dot during an active peak, with a countdown to the next transition. `--json` output includes the new `peak` field\n\n## [0.17.5] - 2026-04-18\n\n### Added\n\n- **Default account bootstrap at CLI startup**: The CLI now calls `ensureDefaultAccounts()` from `sidekick-shared` at module load and awaits the result inside a Commander `preAction` hook, so the first real subcommand blocks briefly on the bootstrap while `--version` and `--help` stay instant. When a system Claude Code or Codex credential exists and no saved account is active for that provider yet, the CLI registers it as "Default" \u2014 `sidekick quota`, `sidekick account`, and `sidekick stats` now reflect the active account on first run without requiring an explicit `sidekick account --add` first. Idempotent, never overwrites manually saved accounts, and all errors are swallowed so startup is never blocked\n\nThanks to [@B33pBeeps](https://github.com/B33pBeeps) (Juan Fourie) for contributing this feature in [#16](https://github.com/cesarandreslopez/sidekick-agent-hub/pull/16).\n\n## [0.17.4] - 2026-04-17\n\n### Changed\n\n- **Pricing hydration import migrated to `sidekick-shared/node`**: `cli.ts` now imports `hydratePricingCatalog` from the new Node-only subpath and keeps `detectProvider` on the package root. Runtime behavior is unchanged; the split makes the CLI\'s import surface self-documenting (hydration is explicitly a Node API) and aligns the CLI with the shared library\'s new versioned public API contract\n\n## [0.17.3] - 2026-04-17\n\n### Changed\n\n- **Version sync with the VS Code extension**: Republished to keep CLI, extension, and shared-library versions aligned after a cosmetic changelog fix in 0.17.3. No CLI code changes \u2014 functionally identical to 0.17.2\n\n## [0.17.2] - 2026-04-17\n\n### Added\n\n- **LiteLLM pricing hydration on startup**: The CLI now fetches the LiteLLM pricing catalog on startup and caches to `~/.config/sidekick/pricing-catalog.json` with a 24-hour TTL, 3s timeout, and stale-cache fallback \u2014 new model prices are picked up without a CLI upgrade\n- **Expanded pricing coverage**: GPT-4o, GPT-4.1, GPT-5.x, o1, o3, and o3-mini families are now priced alongside the existing Claude entries\n- **Real-dollar Codex / Claude Code costs**: `EventAggregator` computes cost from the pricing table when the session provider doesn\'t report one, so `sidekick` live dashboards now show actual dollars for Codex and Claude Code sessions\n- **`stats` footer lists unpriced models**: `sidekick stats` prints any models encountered with no pricing entry so missing coverage is visible\n\n### Fixed\n\n- **Context-gauge % wrong for Opus 4.7 (1M) and other new models**: The dashboard\'s context gauge was dividing by 200K for Claude Opus 4.7 (native 1M), inflating the displayed %. The shared model \u2192 context-window map now includes Opus/Sonnet 4.7 (1M), GPT-5.4 (1.05M), GPT-5.3-Codex (400K), and GPT-5.3-Codex-Spark (128K). Claude Code\'s `[1m]` suffix is now also honored as an explicit 1M marker\n- **Silent Sonnet-priced fallback for unknown models**: Codex, GPT-5.x, and o-series rows were being rendered at Sonnet rates. Unknown-model rows now render as `\u2014` in yellow instead of inventing a dollar figure\n\n### Changed\n\n- **`historical-data.json` schema v2**: reads `priced` flag and `unpricedModelIds` from records written by the latest VS Code extension; v1 records still read correctly\n\n## [0.17.1] - 2026-04-13\n\n### Fixed\n\n- **Codex multi-home session discovery**: Provider detection now scans all candidate Codex home directories, fixing missed sessions when the managed profile home is empty but the system `~/.codex/` has activity\n\n## [0.17.0] - 2026-04-13\n\n### Added\n\n- **Multi-provider account management**: `sidekick account` now supports `--provider codex` for Codex profile management alongside Claude Code accounts\n- **Codex account lifecycle**: `--add` prepares a profile and spawns `codex login`; `--switch-to` and `--remove` accept email, label, or profile ID\n- **Quota snapshot fallback**: `sidekick quota` for Codex shows cached rate-limit snapshots when no active session exists, with "cached from" timestamp\n\n### Fixed\n\n- **Email normalization**: Claude account lookup normalizes email case for reliable matching\n\n## [0.16.1] - 2026-03-27\n\n### Fixed\n\n- **Dashboard provider status scoping**: The TUI now shows degraded-service notices only for the monitored provider \u2014 Claude for Claude Code sessions, OpenAI for Codex sessions, and no status banner for OpenCode\n\n## [0.16.0] - 2026-03-23\n\n### Changed\n\n- **Consistent cost formatting**: All cost displays (`stats`, `context`, Sessions panel, narrative prompt) now use shared `formatCost()` with intelligent decimal precision (4 places for < $0.01, 2 otherwise)\n- **QuotaService**: Rewritten to wrap shared `QuotaPoller` with exponential backoff instead of manual polling loop\n- **modelContext**: Now re-exports `getModelInfo` from shared library alongside `getContextWindowSize`\n\n## [0.15.2] - 2026-03-18\n\n### Fixed\n\n- **CLI help descriptions**: Updated `quota` and `status` command descriptions to reflect provider-aware behavior\n- **`sidekick quota --provider`**: Added local `--provider` option so `sidekick quota --provider codex` works naturally\n\n## [0.15.0] - 2026-03-18\n\n### Added\n\n- **OpenAI status page monitoring**: CLI dashboard now shows OpenAI API status alongside Claude API status\n- **Codex rate limits in dashboard**: Sessions panel displays Codex rate-limit data with "Rate Limits" header instead of "Quota"\n- **Provider-aware `sidekick quota` command**: Detects active provider and shows Codex rate limits, Claude subscription quota, or an informational message for OpenCode\n\n### Fixed\n\n- **QuotaService polling for Codex**: Dashboard no longer starts Claude OAuth quota polling when the active provider is Codex\n\n## [0.14.2] - 2026-03-16\n\n### Fixed\n\n- **Quota polling interval**: Reduced quota refresh from every 30 seconds to every 5 minutes to avoid unnecessary API calls\n- **SessionsPanel `detailWidth()` call**: Removed unused parameter from `detailWidth()` in the Sessions panel quota rendering\n\n## [0.14.1] - 2026-03-14\n\n### Fixed\n\n- **Per-model context window sizes**: Dashboard context gauge now shows correct utilization for Claude Opus 4.6 (1M context) and other models with non-200K windows\n\n### Changed\n\n- **Shared model context lookup**: CLI dashboard now uses the centralized `getModelContextWindowSize()` from `sidekick-shared` instead of a local duplicate map\n\n## [0.14.0] - 2026-03-12\n\n### Added\n\n- **`sidekick account` Command**: Manage Claude Code accounts from the terminal \u2014 list saved accounts, add the current account with an optional label, switch to the next or a specific account, and remove accounts. Supports `--json` output for scripting\n- **Quota Account Label**: `sidekick quota` now shows the active account email and label above the quota bars when multi-account is enabled\n- **macOS Keychain Support**: `sidekick account` and `sidekick quota` now read and write credentials via the system Keychain on macOS, fixing account switching and quota checks on Mac\n\n## [0.13.8] - 2026-03-12\n\n### Changed\n\n- **Structured quota failure output**: `sidekick quota` now renders consistent auth, rate-limit, server, network, and unexpected-failure copy from shared quota failure descriptors while preserving `--json` machine-readable output\n- **Dashboard unavailable quota rendering**: The Sessions panel now shows Claude Code quota failures inline instead of hiding the quota section whenever subscription data is unavailable\n- **Quota transition toasts**: The Ink dashboard now fires low-noise toast notifications only when Claude Code quota failure state changes, avoiding repeated alerts every polling interval\n\n## [0.13.7] - 2026-03-11\n\n### Changed\n\n- **npm README sync**: Updated the published CLI package README to reflect current OpenCode monitoring behavior, platform-specific data directories, and the `sqlite3` runtime requirement\n- **README badge cleanup**: Removed the Ask DeepWiki badge from the published CLI package README; the repo root README still keeps it\n\n## [0.13.6] - 2026-03-11\n\n### Changed\n\n- **Refreshed CLI Dashboard Wordmark**: Updated the dashboard wordmark/header styling for a cleaner splash and dashboard identity\n\n### Fixed\n\n- **OpenCode dashboard startup**: OpenCode DB-backed session discovery now resolves projects by worktree, sandboxes, and session directory instead of quietly behaving like no session exists\n- **OpenCode runtime notices**: The CLI now prints an OpenCode-only actionable notice when `opencode.db` exists but `sqlite3` is missing, blocked, or otherwise unusable in the current shell environment\n\n## [0.13.5] - 2026-03-10\n\n### Added\n\n- **`sidekick status` Command**: One-shot Claude API status check with color-coded text output and `--json` mode\n- **Dashboard Status Banner**: Status bar shows a colored `\u25CF API minor/major/critical` indicator when Claude is degraded; Sessions panel Summary tab shows an "API Status" section with affected components and active incident details. Polls every 60s\n\n## [0.13.4] - 2026-03-08\n\n### Fixed\n\n- **Onboarding Phrase Spam**: Splash screen and detail pane motivational phrases memoized \u2014 no longer flicker every render tick (fixes [#13](https://github.com/cesarandreslopez/sidekick-agent-hub/issues/13))\n\n### Changed\n\n- **Simplified Logo**: Replaced 6-line ASCII robot art with compact text header in splash, help, and changelog overlays\n- **Removed Dead Code**: Removed unused `getSplashContent()` and `HELP_HEADER` exports from branding module\n\n## [0.13.3] - 2026-03-04\n\n_No CLI-specific changes in this release._\n\n## [0.13.2] - 2026-03-04\n\n_No CLI-specific changes in this release._\n\n## [0.13.1] - 2026-03-04\n\n### Added\n\n- **`sidekick quota` Command**: One-shot subscription quota check showing 5-hour and 7-day utilization with color-coded progress bars and reset countdowns \u2014 supports `--json` for machine-readable output\n- **Quota Projections**: Elapsed-time projections shown in `sidekick quota` output and TUI dashboard quota section \u2014 displays projected end-of-window utilization next to current value (e.g., `40% \u2192 100%`), included in `--json` output as `projectedFiveHour` / `projectedSevenDay`\n\n## [0.13.0] - 2026-03-03\n\n_No CLI-specific changes in this release._\n\n## [0.12.10] - 2026-03-01\n\n### Added\n\n- **Events Panel** (key 7): Scrollable live event stream with colored type badges (`[USR]`, `[AST]`, `[TOOL]`, `[RES]`), timestamps, and keyword-highlighted summaries; detail tabs for full event JSON and surrounding context\n- **Charts Panel** (key 8): Tool frequency horizontal bars, event type distribution, 60-minute activity heatmap using `\u2591\u2592\u2593\u2588` intensity characters, and pattern analysis with frequency bars and template text\n- **Multi-Mode Filter**: `/` filter overlay now supports four modes \u2014 substring, fuzzy, regex, and date range \u2014 Tab cycles modes, regex mode shows red validation errors\n- **Search Term Highlighting**: Active filter terms highlighted in blue within side list items\n- **Timeline Keyword Coloring**: Event summaries in the Sessions panel Timeline tab now use semantic keyword coloring \u2014 errors red, success green, tool names cyan, file paths magenta\n\n### Removed\n\n- **Search Panel**: Removed redundant Search panel (previously key 7) \u2014 the `/` filter with multi-mode support serves the same purpose\n\n## [0.12.9] - 2026-02-28\n\n### Added\n\n- **Standalone Data Commands**: `sidekick tasks`, `sidekick decisions`, `sidekick notes`, `sidekick stats`, `sidekick handoff` for accessing project data without launching the TUI\n- **`sidekick search <query>`**: Cross-session full-text search from the terminal\n- **`sidekick context`**: Composite output of tasks, decisions, notes, and handoff for piping into other tools\n- **`--list` flag on `sidekick dump`**: Discover available session IDs before requiring `--session <id>`\n- **Search Panel**: Search panel (panel 7) wired into the TUI dashboard\n\n### Changed\n\n- **`taskMerger` utility**: Duplicate `mergeTasks` logic extracted into shared `taskMerger` utility\n- **Model constants**: Hardcoded model IDs extracted to named constants\n\n### Fixed\n\n- **`convention` icon**: Notes panel icon replaced with valid `tip` type\n- **Linux clipboard**: Now supports Wayland (`wl-copy`) and `xsel` fallbacks, with error messages instead of silent failure\n- **`provider.dispose()`**: Added to `dump` and `report` commands (prevents SQLite connection leaks)\n\n## [0.12.8] - 2026-02-28\n\n### Changed\n\n- **Dashboard UI/UX Polish**: Visual overhaul for better hierarchy, consistency, and readability\n - Splash screen and help overlay now display the robot ASCII logo\n - Toast notifications show severity icons (\u2718 error, \u26A0 warning, \u25CF info) with inner padding\n - Focused pane uses double-border for clear focus indication\n - Section dividers (`\u2500\u2500 Title \u2500\u2500\u2500\u2500`) replace bare bold headers in summary, agents, and context attribution\n - Tab bar: active tab underlined in magenta, inactive tabs dimmed, bracket syntax removed\n - Status bar: segmented layout with `\u2502` separators; keys bold, labels dim\n - Summary metrics condensed: elapsed/events/compactions on one line, tokens on one line with cache rate and cost\n - Sparklines display peak metadata annotations\n - Progress bars use blessed color tags for consistent coloring\n - Help overlay uses dot-leader alignment for all keybinding rows\n - Empty state hints per panel (e.g. "Tasks appear as your agent works.")\n - Session picker groups sessions by provider with section headers when multiple providers are present\n\n## [0.12.7] - 2026-02-27\n\n### Added\n\n- **HTML Session Report**: `sidekick report` command generates a self-contained HTML report and opens it in the default browser\n - Options: `--session`, `--output`, `--theme` (dark/light), `--no-open`, `--no-thinking`\n - TUI Dashboard: press `r` to generate and open an HTML report for the current session\n\n## [0.12.6] - 2026-02-26\n\n### Added\n\n- **Session Dump Command**: `sidekick dump` exports session data in text, markdown, or JSON format with `--format`, `--width`, and `--expand` options\n- **Plans Panel Re-enabled**: Plans panel restored in CLI dashboard with plan file discovery from `~/.claude/plans/`\n- **Enhanced Status Bar**: Session info display improved with richer metadata\n\n### Fixed\n\n- **Old snapshot format migration**: Restoring pre-0.12.3 session snapshots no longer shows empty timeline entries\n\n### Changed\n\n- **Phrase library moved to shared**: CLI-specific phrase formatting kept local, all phrase content now from `sidekick-shared`\n\n## [0.12.5] - 2026-02-24\n\n### Fixed\n\n- **Update check too slow to notice new versions**: Reduced npm registry cache TTL from 24 hours to 4 hours so upgrade notices appear sooner after a new release\n\n## [0.12.4] - 2026-02-24\n\n### Fixed\n\n- **Session crash on upgrade**: Fixed `d.timestamp.getTime is not a function` error when restoring tool call data from session snapshots \u2014 `Date` objects were serialized to strings by JSON but not rehydrated on restore, causing the session monitor to crash on first run after upgrading from 0.12.2 to 0.12.3\n\n## [0.12.3] - 2026-02-24\n\n### Added\n\n- **Latest-node indicator**: The most recently added node in tree and boxed mind map views is now marked with a yellow indicator\n- **Plan analytics in mind map**: Tree and boxed views now display plan progress and per-step metrics\n - Tree view: plan header shows completion stats; steps show complexity, duration, tokens, tool calls, and errors in metadata brackets\n - Box view: progress bar with completion percentage; steps show right-aligned metrics; subtitle shows step count and total duration\n- **Cross-provider plan extraction**: Shared `PlanExtractor` now handles Claude Code (EnterPlanMode/ExitPlanMode) and OpenCode (`<proposed_plan>` XML) plans \u2014 previously only Codex plans were shown\n- **Enriched plan data model**: Plan steps include duration, token count, tool call count, and error messages\n- **Phase-grouped plan display**: When a plan has phase structure, tree and boxed views group steps under phase headers with context lines from the original plan markdown\n- **Node type filter**: Press `f` on the Mind Map tab to cycle through node type filters (file, tool, task, subagent, command, plan, knowledge-note) \u2014 non-matching sections render dimmed in grey\n\n### Fixed\n\n- **Kanban board regression**: Subagent and plan-step tasks now correctly appear in the kanban board\n\n### Changed\n\n- **Plans panel temporarily disabled**: The Plans panel in the CLI dashboard is disabled until plan-mode event capture is reliably working end-to-end. Plan nodes in the mind map remain active.\n- `DashboardState` now delegates to shared `EventAggregator` instead of maintaining its own aggregation logic\n\n## [0.12.2] - 2026-02-23\n\n### Added\n\n- **Update notifications**: The dashboard now checks the npm registry for newer versions on startup and shows a yellow banner in the status bar when an update is available (e.g., `v0.13.0 available \u2014 npm i -g sidekick-agent-hub`). Results are cached for 24 hours to avoid repeated network requests.\n\n## [0.12.1] - 2026-02-23\n\n### Fixed\n\n- **VS Code integration**: Fixed exit code 127 when the extension launches the CLI dashboard on systems using nvm or volta (node binary not found when shell init is bypassed)\n\n## [0.12.0] - 2026-02-22\n\n### Added\n\n- **"Open CLI Dashboard" VS Code Integration**: New VS Code command `Sidekick: Open CLI Dashboard` launches the TUI dashboard in an integrated terminal\n - Install the CLI with `npm install -g sidekick-agent-hub`\n\n## [0.11.0] - 2026-02-19\n\n### Added\n\n- **Initial Release**: Full-screen TUI dashboard for monitoring agent sessions from the terminal\n - Ink-based terminal UI with panels for sessions, tasks, kanban, mind map, notes, decisions, search, files, and git diff\n - Multi-provider support: auto-detects Claude Code, OpenCode, and Codex sessions\n - Reads from `~/.config/sidekick/` \u2014 the same data files the VS Code extension writes\n - Usage: `sidekick dashboard [--project <path>] [--provider <id>]`\n';
|
|
80603
|
+
CHANGELOG_default = '# Changelog\n\nAll notable changes to the Sidekick Agent Hub CLI will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n## [0.18.2] - 2026-05-19\n\n### Added\n\n- **`sidekick quota --refresh`**: New flag on the `quota` command that, for Codex, explicitly refreshes from the ChatGPT usage API before falling back to local rollout data and cached snapshots. Without the flag, the Codex quota path stays fully local and makes no upstream network call\n\n### Changed\n\n- **Codex quota is local-only by default**: `sidekick quota --provider codex` now delegates to the new `resolveCodexQuota` orchestrator in `sidekick-shared`. It checks the current workspace\'s most recent rollout, then recent account-level rollouts under `CODEX_HOME/sessions`, then the active account\'s cached snapshot \u2014 no upstream network call unless `--refresh` is passed. Failure output continues to include structured `failureKind` / `httpStatus` / `retryAfterMs` fields under `--json`\n- **Bundled `sidekick-shared` 0.18.2**: Picks up the new Codex quota orchestrator (`resolveCodexQuota`, `resolveCodexQuotaFromLocalSources`, `readLatestCodexQuotaFromRollouts`, `fetchCodexQuotaFromApi`), the relaxed `CodexRateLimits` shape (nullable `resets_at` / `window_minutes`), the rate-limit-only `token_count` event emission in `JsonlSessionWatcher`, and `state_N.sqlite` discovery in `CodexDatabase` + provider auto-detect\n\n## [0.18.1] - 2026-05-08\n\n### Changed\n\n- **Shared dashboard formatting**: terminal dashboard `fmtNum()` and `formatDuration()` now delegate to `formatTokenCount()` and `formatDurationMs()` from `sidekick-shared`, keeping the existing CLI surface (uppercase `K`/`M` suffix, compact `1m5s` style) while removing forked rounding logic\n\n## [0.18.0] - 2026-05-08\n\n### Changed\n\n- **Bundled `sidekick-shared` 0.18.0**: Picks up the new provider-aware quota orchestration surface \u2014 `MultiProviderQuotaService`, `CodexQuotaWatcher`, `getActiveAccountStatus()`, `extractToolCall()`, cost-provenance helpers (`calculateCostWithProvenance`, `mergeCostSources`), and model display helpers (`shortModelName`, `getModelDisplayInfo`, `compareModelIds`, `sortModelIds`). `parseModelId()` also now recognizes legacy Claude IDs such as `claude-3-opus-20240229` and `claude-3-5-sonnet-20241022`\n- **No CLI runtime changes**: This release ships the shared library upgrade for downstream tooling alignment; `sidekick quota`, `sidekick status`, and the live dashboard keep using the existing polling path. Wiring the new orchestrator into the CLI will land in a follow-up release\n\n## [0.17.7] - 2026-04-28\n\n### Fixed\n\n- **Quota snapshot write race**: Updated the bundled `sidekick-shared` snapshot writer so concurrent `sidekick quota` / Codex session updates no longer collide on `quota-snapshots.json.tmp` or throw `ENOENT`. Failed writes now also clean up their partial temp files instead of leaving orphans in `~/.config/sidekick/`\n\n## [0.17.6] - 2026-04-19\n\n### Added\n\n- **`sidekick peak` command**: One-shot check for Claude\'s current peak-hours state \u2014 weekdays 13:00\u201319:00 UTC, when session limits drain faster on Free/Pro/Max/Team subscriptions. Prints a color-coded status block with a countdown to the next transition. Data comes from the public `promoclock.co/api/status` endpoint (third-party, unaffiliated with Anthropic) with a graceful fallback when unreachable. `--json` emits the full raw state\n- **Peak-hours block in `sidekick status`**: When the active provider is `claude-code`, the Claude + OpenAI health blocks are now followed by a **Claude Peak Hours** block (off-peak or in-peak, with countdown). Gated on the provider so OpenCode / Codex users don\'t trigger an unnecessary third-party fetch. `--json` output includes the new `peak` field\n- **Peak-hours summary in `sidekick quota`**: Claude subscription quota output now shows a **Peak** line under the 5-hour / 7-day bars \u2014 green dot off-peak, orange dot during an active peak, with a countdown to the next transition. `--json` output includes the new `peak` field\n\n## [0.17.5] - 2026-04-18\n\n### Added\n\n- **Default account bootstrap at CLI startup**: The CLI now calls `ensureDefaultAccounts()` from `sidekick-shared` at module load and awaits the result inside a Commander `preAction` hook, so the first real subcommand blocks briefly on the bootstrap while `--version` and `--help` stay instant. When a system Claude Code or Codex credential exists and no saved account is active for that provider yet, the CLI registers it as "Default" \u2014 `sidekick quota`, `sidekick account`, and `sidekick stats` now reflect the active account on first run without requiring an explicit `sidekick account --add` first. Idempotent, never overwrites manually saved accounts, and all errors are swallowed so startup is never blocked\n\nThanks to [@B33pBeeps](https://github.com/B33pBeeps) (Juan Fourie) for contributing this feature in [#16](https://github.com/cesarandreslopez/sidekick-agent-hub/pull/16).\n\n## [0.17.4] - 2026-04-17\n\n### Changed\n\n- **Pricing hydration import migrated to `sidekick-shared/node`**: `cli.ts` now imports `hydratePricingCatalog` from the new Node-only subpath and keeps `detectProvider` on the package root. Runtime behavior is unchanged; the split makes the CLI\'s import surface self-documenting (hydration is explicitly a Node API) and aligns the CLI with the shared library\'s new versioned public API contract\n\n## [0.17.3] - 2026-04-17\n\n### Changed\n\n- **Version sync with the VS Code extension**: Republished to keep CLI, extension, and shared-library versions aligned after a cosmetic changelog fix in 0.17.3. No CLI code changes \u2014 functionally identical to 0.17.2\n\n## [0.17.2] - 2026-04-17\n\n### Added\n\n- **LiteLLM pricing hydration on startup**: The CLI now fetches the LiteLLM pricing catalog on startup and caches to `~/.config/sidekick/pricing-catalog.json` with a 24-hour TTL, 3s timeout, and stale-cache fallback \u2014 new model prices are picked up without a CLI upgrade\n- **Expanded pricing coverage**: GPT-4o, GPT-4.1, GPT-5.x, o1, o3, and o3-mini families are now priced alongside the existing Claude entries\n- **Real-dollar Codex / Claude Code costs**: `EventAggregator` computes cost from the pricing table when the session provider doesn\'t report one, so `sidekick` live dashboards now show actual dollars for Codex and Claude Code sessions\n- **`stats` footer lists unpriced models**: `sidekick stats` prints any models encountered with no pricing entry so missing coverage is visible\n\n### Fixed\n\n- **Context-gauge % wrong for Opus 4.7 (1M) and other new models**: The dashboard\'s context gauge was dividing by 200K for Claude Opus 4.7 (native 1M), inflating the displayed %. The shared model \u2192 context-window map now includes Opus/Sonnet 4.7 (1M), GPT-5.4 (1.05M), GPT-5.3-Codex (400K), and GPT-5.3-Codex-Spark (128K). Claude Code\'s `[1m]` suffix is now also honored as an explicit 1M marker\n- **Silent Sonnet-priced fallback for unknown models**: Codex, GPT-5.x, and o-series rows were being rendered at Sonnet rates. Unknown-model rows now render as `\u2014` in yellow instead of inventing a dollar figure\n\n### Changed\n\n- **`historical-data.json` schema v2**: reads `priced` flag and `unpricedModelIds` from records written by the latest VS Code extension; v1 records still read correctly\n\n## [0.17.1] - 2026-04-13\n\n### Fixed\n\n- **Codex multi-home session discovery**: Provider detection now scans all candidate Codex home directories, fixing missed sessions when the managed profile home is empty but the system `~/.codex/` has activity\n\n## [0.17.0] - 2026-04-13\n\n### Added\n\n- **Multi-provider account management**: `sidekick account` now supports `--provider codex` for Codex profile management alongside Claude Code accounts\n- **Codex account lifecycle**: `--add` prepares a profile and spawns `codex login`; `--switch-to` and `--remove` accept email, label, or profile ID\n- **Quota snapshot fallback**: `sidekick quota` for Codex shows cached rate-limit snapshots when no active session exists, with "cached from" timestamp\n\n### Fixed\n\n- **Email normalization**: Claude account lookup normalizes email case for reliable matching\n\n## [0.16.1] - 2026-03-27\n\n### Fixed\n\n- **Dashboard provider status scoping**: The TUI now shows degraded-service notices only for the monitored provider \u2014 Claude for Claude Code sessions, OpenAI for Codex sessions, and no status banner for OpenCode\n\n## [0.16.0] - 2026-03-23\n\n### Changed\n\n- **Consistent cost formatting**: All cost displays (`stats`, `context`, Sessions panel, narrative prompt) now use shared `formatCost()` with intelligent decimal precision (4 places for < $0.01, 2 otherwise)\n- **QuotaService**: Rewritten to wrap shared `QuotaPoller` with exponential backoff instead of manual polling loop\n- **modelContext**: Now re-exports `getModelInfo` from shared library alongside `getContextWindowSize`\n\n## [0.15.2] - 2026-03-18\n\n### Fixed\n\n- **CLI help descriptions**: Updated `quota` and `status` command descriptions to reflect provider-aware behavior\n- **`sidekick quota --provider`**: Added local `--provider` option so `sidekick quota --provider codex` works naturally\n\n## [0.15.0] - 2026-03-18\n\n### Added\n\n- **OpenAI status page monitoring**: CLI dashboard now shows OpenAI API status alongside Claude API status\n- **Codex rate limits in dashboard**: Sessions panel displays Codex rate-limit data with "Rate Limits" header instead of "Quota"\n- **Provider-aware `sidekick quota` command**: Detects active provider and shows Codex rate limits, Claude subscription quota, or an informational message for OpenCode\n\n### Fixed\n\n- **QuotaService polling for Codex**: Dashboard no longer starts Claude OAuth quota polling when the active provider is Codex\n\n## [0.14.2] - 2026-03-16\n\n### Fixed\n\n- **Quota polling interval**: Reduced quota refresh from every 30 seconds to every 5 minutes to avoid unnecessary API calls\n- **SessionsPanel `detailWidth()` call**: Removed unused parameter from `detailWidth()` in the Sessions panel quota rendering\n\n## [0.14.1] - 2026-03-14\n\n### Fixed\n\n- **Per-model context window sizes**: Dashboard context gauge now shows correct utilization for Claude Opus 4.6 (1M context) and other models with non-200K windows\n\n### Changed\n\n- **Shared model context lookup**: CLI dashboard now uses the centralized `getModelContextWindowSize()` from `sidekick-shared` instead of a local duplicate map\n\n## [0.14.0] - 2026-03-12\n\n### Added\n\n- **`sidekick account` Command**: Manage Claude Code accounts from the terminal \u2014 list saved accounts, add the current account with an optional label, switch to the next or a specific account, and remove accounts. Supports `--json` output for scripting\n- **Quota Account Label**: `sidekick quota` now shows the active account email and label above the quota bars when multi-account is enabled\n- **macOS Keychain Support**: `sidekick account` and `sidekick quota` now read and write credentials via the system Keychain on macOS, fixing account switching and quota checks on Mac\n\n## [0.13.8] - 2026-03-12\n\n### Changed\n\n- **Structured quota failure output**: `sidekick quota` now renders consistent auth, rate-limit, server, network, and unexpected-failure copy from shared quota failure descriptors while preserving `--json` machine-readable output\n- **Dashboard unavailable quota rendering**: The Sessions panel now shows Claude Code quota failures inline instead of hiding the quota section whenever subscription data is unavailable\n- **Quota transition toasts**: The Ink dashboard now fires low-noise toast notifications only when Claude Code quota failure state changes, avoiding repeated alerts every polling interval\n\n## [0.13.7] - 2026-03-11\n\n### Changed\n\n- **npm README sync**: Updated the published CLI package README to reflect current OpenCode monitoring behavior, platform-specific data directories, and the `sqlite3` runtime requirement\n- **README badge cleanup**: Removed the Ask DeepWiki badge from the published CLI package README; the repo root README still keeps it\n\n## [0.13.6] - 2026-03-11\n\n### Changed\n\n- **Refreshed CLI Dashboard Wordmark**: Updated the dashboard wordmark/header styling for a cleaner splash and dashboard identity\n\n### Fixed\n\n- **OpenCode dashboard startup**: OpenCode DB-backed session discovery now resolves projects by worktree, sandboxes, and session directory instead of quietly behaving like no session exists\n- **OpenCode runtime notices**: The CLI now prints an OpenCode-only actionable notice when `opencode.db` exists but `sqlite3` is missing, blocked, or otherwise unusable in the current shell environment\n\n## [0.13.5] - 2026-03-10\n\n### Added\n\n- **`sidekick status` Command**: One-shot Claude API status check with color-coded text output and `--json` mode\n- **Dashboard Status Banner**: Status bar shows a colored `\u25CF API minor/major/critical` indicator when Claude is degraded; Sessions panel Summary tab shows an "API Status" section with affected components and active incident details. Polls every 60s\n\n## [0.13.4] - 2026-03-08\n\n### Fixed\n\n- **Onboarding Phrase Spam**: Splash screen and detail pane motivational phrases memoized \u2014 no longer flicker every render tick (fixes [#13](https://github.com/cesarandreslopez/sidekick-agent-hub/issues/13))\n\n### Changed\n\n- **Simplified Logo**: Replaced 6-line ASCII robot art with compact text header in splash, help, and changelog overlays\n- **Removed Dead Code**: Removed unused `getSplashContent()` and `HELP_HEADER` exports from branding module\n\n## [0.13.3] - 2026-03-04\n\n_No CLI-specific changes in this release._\n\n## [0.13.2] - 2026-03-04\n\n_No CLI-specific changes in this release._\n\n## [0.13.1] - 2026-03-04\n\n### Added\n\n- **`sidekick quota` Command**: One-shot subscription quota check showing 5-hour and 7-day utilization with color-coded progress bars and reset countdowns \u2014 supports `--json` for machine-readable output\n- **Quota Projections**: Elapsed-time projections shown in `sidekick quota` output and TUI dashboard quota section \u2014 displays projected end-of-window utilization next to current value (e.g., `40% \u2192 100%`), included in `--json` output as `projectedFiveHour` / `projectedSevenDay`\n\n## [0.13.0] - 2026-03-03\n\n_No CLI-specific changes in this release._\n\n## [0.12.10] - 2026-03-01\n\n### Added\n\n- **Events Panel** (key 7): Scrollable live event stream with colored type badges (`[USR]`, `[AST]`, `[TOOL]`, `[RES]`), timestamps, and keyword-highlighted summaries; detail tabs for full event JSON and surrounding context\n- **Charts Panel** (key 8): Tool frequency horizontal bars, event type distribution, 60-minute activity heatmap using `\u2591\u2592\u2593\u2588` intensity characters, and pattern analysis with frequency bars and template text\n- **Multi-Mode Filter**: `/` filter overlay now supports four modes \u2014 substring, fuzzy, regex, and date range \u2014 Tab cycles modes, regex mode shows red validation errors\n- **Search Term Highlighting**: Active filter terms highlighted in blue within side list items\n- **Timeline Keyword Coloring**: Event summaries in the Sessions panel Timeline tab now use semantic keyword coloring \u2014 errors red, success green, tool names cyan, file paths magenta\n\n### Removed\n\n- **Search Panel**: Removed redundant Search panel (previously key 7) \u2014 the `/` filter with multi-mode support serves the same purpose\n\n## [0.12.9] - 2026-02-28\n\n### Added\n\n- **Standalone Data Commands**: `sidekick tasks`, `sidekick decisions`, `sidekick notes`, `sidekick stats`, `sidekick handoff` for accessing project data without launching the TUI\n- **`sidekick search <query>`**: Cross-session full-text search from the terminal\n- **`sidekick context`**: Composite output of tasks, decisions, notes, and handoff for piping into other tools\n- **`--list` flag on `sidekick dump`**: Discover available session IDs before requiring `--session <id>`\n- **Search Panel**: Search panel (panel 7) wired into the TUI dashboard\n\n### Changed\n\n- **`taskMerger` utility**: Duplicate `mergeTasks` logic extracted into shared `taskMerger` utility\n- **Model constants**: Hardcoded model IDs extracted to named constants\n\n### Fixed\n\n- **`convention` icon**: Notes panel icon replaced with valid `tip` type\n- **Linux clipboard**: Now supports Wayland (`wl-copy`) and `xsel` fallbacks, with error messages instead of silent failure\n- **`provider.dispose()`**: Added to `dump` and `report` commands (prevents SQLite connection leaks)\n\n## [0.12.8] - 2026-02-28\n\n### Changed\n\n- **Dashboard UI/UX Polish**: Visual overhaul for better hierarchy, consistency, and readability\n - Splash screen and help overlay now display the robot ASCII logo\n - Toast notifications show severity icons (\u2718 error, \u26A0 warning, \u25CF info) with inner padding\n - Focused pane uses double-border for clear focus indication\n - Section dividers (`\u2500\u2500 Title \u2500\u2500\u2500\u2500`) replace bare bold headers in summary, agents, and context attribution\n - Tab bar: active tab underlined in magenta, inactive tabs dimmed, bracket syntax removed\n - Status bar: segmented layout with `\u2502` separators; keys bold, labels dim\n - Summary metrics condensed: elapsed/events/compactions on one line, tokens on one line with cache rate and cost\n - Sparklines display peak metadata annotations\n - Progress bars use blessed color tags for consistent coloring\n - Help overlay uses dot-leader alignment for all keybinding rows\n - Empty state hints per panel (e.g. "Tasks appear as your agent works.")\n - Session picker groups sessions by provider with section headers when multiple providers are present\n\n## [0.12.7] - 2026-02-27\n\n### Added\n\n- **HTML Session Report**: `sidekick report` command generates a self-contained HTML report and opens it in the default browser\n - Options: `--session`, `--output`, `--theme` (dark/light), `--no-open`, `--no-thinking`\n - TUI Dashboard: press `r` to generate and open an HTML report for the current session\n\n## [0.12.6] - 2026-02-26\n\n### Added\n\n- **Session Dump Command**: `sidekick dump` exports session data in text, markdown, or JSON format with `--format`, `--width`, and `--expand` options\n- **Plans Panel Re-enabled**: Plans panel restored in CLI dashboard with plan file discovery from `~/.claude/plans/`\n- **Enhanced Status Bar**: Session info display improved with richer metadata\n\n### Fixed\n\n- **Old snapshot format migration**: Restoring pre-0.12.3 session snapshots no longer shows empty timeline entries\n\n### Changed\n\n- **Phrase library moved to shared**: CLI-specific phrase formatting kept local, all phrase content now from `sidekick-shared`\n\n## [0.12.5] - 2026-02-24\n\n### Fixed\n\n- **Update check too slow to notice new versions**: Reduced npm registry cache TTL from 24 hours to 4 hours so upgrade notices appear sooner after a new release\n\n## [0.12.4] - 2026-02-24\n\n### Fixed\n\n- **Session crash on upgrade**: Fixed `d.timestamp.getTime is not a function` error when restoring tool call data from session snapshots \u2014 `Date` objects were serialized to strings by JSON but not rehydrated on restore, causing the session monitor to crash on first run after upgrading from 0.12.2 to 0.12.3\n\n## [0.12.3] - 2026-02-24\n\n### Added\n\n- **Latest-node indicator**: The most recently added node in tree and boxed mind map views is now marked with a yellow indicator\n- **Plan analytics in mind map**: Tree and boxed views now display plan progress and per-step metrics\n - Tree view: plan header shows completion stats; steps show complexity, duration, tokens, tool calls, and errors in metadata brackets\n - Box view: progress bar with completion percentage; steps show right-aligned metrics; subtitle shows step count and total duration\n- **Cross-provider plan extraction**: Shared `PlanExtractor` now handles Claude Code (EnterPlanMode/ExitPlanMode) and OpenCode (`<proposed_plan>` XML) plans \u2014 previously only Codex plans were shown\n- **Enriched plan data model**: Plan steps include duration, token count, tool call count, and error messages\n- **Phase-grouped plan display**: When a plan has phase structure, tree and boxed views group steps under phase headers with context lines from the original plan markdown\n- **Node type filter**: Press `f` on the Mind Map tab to cycle through node type filters (file, tool, task, subagent, command, plan, knowledge-note) \u2014 non-matching sections render dimmed in grey\n\n### Fixed\n\n- **Kanban board regression**: Subagent and plan-step tasks now correctly appear in the kanban board\n\n### Changed\n\n- **Plans panel temporarily disabled**: The Plans panel in the CLI dashboard is disabled until plan-mode event capture is reliably working end-to-end. Plan nodes in the mind map remain active.\n- `DashboardState` now delegates to shared `EventAggregator` instead of maintaining its own aggregation logic\n\n## [0.12.2] - 2026-02-23\n\n### Added\n\n- **Update notifications**: The dashboard now checks the npm registry for newer versions on startup and shows a yellow banner in the status bar when an update is available (e.g., `v0.13.0 available \u2014 npm i -g sidekick-agent-hub`). Results are cached for 24 hours to avoid repeated network requests.\n\n## [0.12.1] - 2026-02-23\n\n### Fixed\n\n- **VS Code integration**: Fixed exit code 127 when the extension launches the CLI dashboard on systems using nvm or volta (node binary not found when shell init is bypassed)\n\n## [0.12.0] - 2026-02-22\n\n### Added\n\n- **"Open CLI Dashboard" VS Code Integration**: New VS Code command `Sidekick: Open CLI Dashboard` launches the TUI dashboard in an integrated terminal\n - Install the CLI with `npm install -g sidekick-agent-hub`\n\n## [0.11.0] - 2026-02-19\n\n### Added\n\n- **Initial Release**: Full-screen TUI dashboard for monitoring agent sessions from the terminal\n - Ink-based terminal UI with panels for sessions, tasks, kanban, mind map, notes, decisions, search, files, and git diff\n - Multi-provider support: auto-detects Claude Code, OpenCode, and Codex sessions\n - Reads from `~/.config/sidekick/` \u2014 the same data files the VS Code extension writes\n - Usage: `sidekick dashboard [--project <path>] [--provider <id>]`\n';
|
|
80136
80604
|
}
|
|
80137
80605
|
});
|
|
80138
80606
|
|
|
@@ -82316,7 +82784,7 @@ async function quotaAction(_opts, cmd) {
|
|
|
82316
82784
|
return;
|
|
82317
82785
|
}
|
|
82318
82786
|
if (provider.id === "codex") {
|
|
82319
|
-
await codexQuotaAction(provider, globalOpts, jsonOutput);
|
|
82787
|
+
await codexQuotaAction(provider, globalOpts, localOpts, jsonOutput);
|
|
82320
82788
|
return;
|
|
82321
82789
|
}
|
|
82322
82790
|
provider.dispose();
|
|
@@ -82387,57 +82855,25 @@ function printPeakHoursSummary(peak) {
|
|
|
82387
82855
|
process.stdout.write(` ${source_default.dim("Peak")} ${line}
|
|
82388
82856
|
`);
|
|
82389
82857
|
}
|
|
82390
|
-
async function codexQuotaAction(provider, globalOpts, jsonOutput) {
|
|
82858
|
+
async function codexQuotaAction(provider, globalOpts, localOpts, jsonOutput) {
|
|
82391
82859
|
const workspacePath = globalOpts.project || process.cwd();
|
|
82392
82860
|
const activeAccount = (0, import_sidekick_shared29.getActiveCodexAccount)();
|
|
82393
|
-
let quota
|
|
82394
|
-
|
|
82395
|
-
|
|
82396
|
-
|
|
82397
|
-
|
|
82398
|
-
|
|
82399
|
-
|
|
82400
|
-
|
|
82401
|
-
|
|
82402
|
-
|
|
82403
|
-
if (event.rateLimits) {
|
|
82404
|
-
captured.rl = event.rateLimits;
|
|
82405
|
-
}
|
|
82406
|
-
},
|
|
82407
|
-
onError: () => {
|
|
82408
|
-
}
|
|
82409
|
-
}
|
|
82410
|
-
});
|
|
82411
|
-
result.watcher.start(true);
|
|
82412
|
-
result.watcher.stop();
|
|
82413
|
-
} catch {
|
|
82414
|
-
}
|
|
82415
|
-
const liveQuota = captured.rl ? (0, import_sidekick_shared29.quotaFromCodexRateLimits)({
|
|
82416
|
-
primary: captured.rl.primary ? {
|
|
82417
|
-
used_percent: captured.rl.primary.usedPercent,
|
|
82418
|
-
window_minutes: captured.rl.primary.windowMinutes,
|
|
82419
|
-
resets_at: captured.rl.primary.resetsAt
|
|
82420
|
-
} : void 0,
|
|
82421
|
-
secondary: captured.rl.secondary ? {
|
|
82422
|
-
used_percent: captured.rl.secondary.usedPercent,
|
|
82423
|
-
window_minutes: captured.rl.secondary.windowMinutes,
|
|
82424
|
-
resets_at: captured.rl.secondary.resetsAt
|
|
82425
|
-
} : void 0
|
|
82426
|
-
}, "session") : null;
|
|
82427
|
-
if (liveQuota) {
|
|
82428
|
-
quota = liveQuota;
|
|
82429
|
-
if (activeAccount) {
|
|
82430
|
-
(0, import_sidekick_shared29.writeQuotaSnapshot)("codex", activeAccount.id, liveQuota);
|
|
82431
|
-
}
|
|
82432
|
-
}
|
|
82861
|
+
let quota;
|
|
82862
|
+
try {
|
|
82863
|
+
quota = await (0, import_sidekick_shared29.resolveCodexQuota)({
|
|
82864
|
+
workspacePath,
|
|
82865
|
+
provider,
|
|
82866
|
+
activeAccount,
|
|
82867
|
+
source: localOpts.refresh ? "api" : "local"
|
|
82868
|
+
});
|
|
82869
|
+
} finally {
|
|
82870
|
+
provider.dispose();
|
|
82433
82871
|
}
|
|
82434
|
-
|
|
82435
|
-
if (!quota) {
|
|
82436
|
-
const msg = activeAccount ? `No active Codex session and no cached rate-limit snapshot is available for "${activeAccount.label ?? activeAccount.id}".` : "No active Codex session and no saved Codex account snapshot is available.";
|
|
82872
|
+
if (!quota.available) {
|
|
82437
82873
|
if (jsonOutput) {
|
|
82438
|
-
process.stdout.write(JSON.stringify(
|
|
82874
|
+
process.stdout.write(JSON.stringify(quota, null, 2) + "\n");
|
|
82439
82875
|
} else {
|
|
82440
|
-
process.stderr.write(source_default.yellow(
|
|
82876
|
+
process.stderr.write(source_default.yellow(quota.error ?? "Codex rate-limit data is unavailable.") + "\n");
|
|
82441
82877
|
}
|
|
82442
82878
|
return;
|
|
82443
82879
|
}
|
|
@@ -82989,7 +83425,7 @@ var init_cli = __esm({
|
|
|
82989
83425
|
defaultAccountsReady = (0, import_sidekick_shared34.ensureDefaultAccounts)().catch(() => {
|
|
82990
83426
|
});
|
|
82991
83427
|
program2 = new Command();
|
|
82992
|
-
program2.name("sidekick").description("Query Sidekick project intelligence from the command line").version("0.18.
|
|
83428
|
+
program2.name("sidekick").description("Query Sidekick project intelligence from the command line").version("0.18.2").option("--json", "Output as JSON").option("--project <path>", "Override project path (default: cwd)").option("--provider <id>", "Provider: claude-code, opencode, codex, auto (default: auto)");
|
|
82993
83429
|
program2.hook("preAction", async () => {
|
|
82994
83430
|
await defaultAccountsReady;
|
|
82995
83431
|
});
|
|
@@ -83039,7 +83475,7 @@ var init_cli = __esm({
|
|
|
83039
83475
|
return statsAction2(_opts, cmd);
|
|
83040
83476
|
});
|
|
83041
83477
|
program2.addCommand(statsCmd);
|
|
83042
|
-
quotaCmd = new Command("quota").description("Show quota or rate-limit utilization (auto-detects provider)").option("--provider <id>", "Provider: claude-code, codex, auto (default: auto)").action(async (_opts, cmd) => {
|
|
83478
|
+
quotaCmd = new Command("quota").description("Show quota or rate-limit utilization (auto-detects provider)").option("--provider <id>", "Provider: claude-code, codex, auto (default: auto)").option("--refresh", "For Codex, explicitly refresh from the Codex usage API before falling back to local data").action(async (_opts, cmd) => {
|
|
83043
83479
|
const { quotaAction: quotaAction2 } = await Promise.resolve().then(() => (init_quota(), quota_exports));
|
|
83044
83480
|
return quotaAction2(_opts, cmd);
|
|
83045
83481
|
});
|