oc-codex-multi-auth 6.14.4 → 6.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/codex-usage.d.ts +13 -1
- package/dist/lib/codex-usage.d.ts.map +1 -1
- package/dist/lib/codex-usage.js +27 -8
- package/dist/lib/codex-usage.js.map +1 -1
- package/dist/lib/config.d.ts +8 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +28 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/desktop-notifications.d.ts +14 -0
- package/dist/lib/desktop-notifications.d.ts.map +1 -0
- package/dist/lib/desktop-notifications.js +59 -0
- package/dist/lib/desktop-notifications.js.map +1 -0
- package/dist/lib/quota-notification-state.d.ts +25 -0
- package/dist/lib/quota-notification-state.d.ts.map +1 -0
- package/dist/lib/quota-notification-state.js +94 -0
- package/dist/lib/quota-notification-state.js.map +1 -0
- package/dist/lib/quota-notifications.d.ts +64 -0
- package/dist/lib/quota-notifications.d.ts.map +1 -0
- package/dist/lib/quota-notifications.js +371 -0
- package/dist/lib/quota-notifications.js.map +1 -0
- package/dist/lib/schemas.d.ts +6 -0
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +6 -0
- package/dist/lib/schemas.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -293,6 +293,52 @@ Primary config files:
|
|
|
293
293
|
- `~/.config/opencode/tui.json`
|
|
294
294
|
- `~/.opencode/openai-codex-auth-config.json`
|
|
295
295
|
|
|
296
|
+
### Desktop quota notifications
|
|
297
|
+
|
|
298
|
+
Quota notifications are an optional macOS-only feature. While the plugin is
|
|
299
|
+
running, it checks all enabled accounts and alerts through Notification Center
|
|
300
|
+
when the best remaining 5-hour or weekly pool quota crosses 25%, 10%, or 0%.
|
|
301
|
+
The feature is disabled by default.
|
|
302
|
+
|
|
303
|
+
Each line reports the enabled account with the most headroom in that window,
|
|
304
|
+
together with that same account's reset time, so the pair always describes a
|
|
305
|
+
quota that one account actually has. Windows a plan has switched off are
|
|
306
|
+
skipped rather than counted as full. Account identities are omitted for
|
|
307
|
+
readability and lock-screen privacy:
|
|
308
|
+
|
|
309
|
+
```text
|
|
310
|
+
5h: 10% | resets 22:30
|
|
311
|
+
Weekly: 72% | resets 22:30 on Aug 30
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
```json
|
|
315
|
+
{
|
|
316
|
+
"quotaNotifications": {
|
|
317
|
+
"enabled": true,
|
|
318
|
+
"intervalMs": 1800000,
|
|
319
|
+
"notifyEveryCheck": false,
|
|
320
|
+
"thresholds": [25, 10, 0]
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
Add the object above to `~/.opencode/openai-codex-auth-config.json`, or set
|
|
326
|
+
`CODEX_AUTH_QUOTA_NOTIFICATIONS=1`, then quit and restart OpenCode. The minimum
|
|
327
|
+
interval is 30 seconds. If macOS blocks the alert, allow notifications for
|
|
328
|
+
the process shown in **System Settings > Notifications**. The setting is
|
|
329
|
+
ignored on Windows and Linux.
|
|
330
|
+
|
|
331
|
+
Set `"notifyEveryCheck": true` to show the aggregate quota notification after
|
|
332
|
+
every successful poll interval instead of only when a configured threshold is
|
|
333
|
+
crossed. Set `"thresholds": []` to turn threshold alerts off entirely; pair it
|
|
334
|
+
with `"notifyEveryCheck": true` or the monitor has nothing to deliver and stops
|
|
335
|
+
polling.
|
|
336
|
+
|
|
337
|
+
Delivery state lives beside the accounts file the alerts are computed from, so
|
|
338
|
+
OpenCode processes working in the same account scope show only one alert per
|
|
339
|
+
interval. With the default `perProjectAccounts`, that scope is one project:
|
|
340
|
+
two projects have separate account pools and therefore alert independently.
|
|
341
|
+
|
|
296
342
|
### Route models to preferred accounts
|
|
297
343
|
|
|
298
344
|
Use `modelAccountPools` to assign one or more preferred ChatGPT accounts or Business seats to a
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAuU/D;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,iBAAiB,EAAE,MAq9H/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAoB,CAAC;AAElD,eAAe,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ import { promptAddAnotherAccount, promptLoginMode } from "./lib/cli.js";
|
|
|
36
36
|
import { getCodexMode, getRequestTransformMode, getFastSession, getFastSessionStrategy, getFastSessionMaxInputItems, getRetryProfile, getRetryBudgetOverrides, getRateLimitToastDebounceMs, getRetryAllAccountsMaxRetries, getRetryAllAccountsMaxWaitMs, getRetryAllAccountsRateLimited, getFallbackToGpt52OnUnsupportedGpt53, getUnsupportedCodexPolicy, getUnsupportedCodexFallbackChain, getTokenRefreshSkewMs, getSessionRecovery, getAutoResume, getAutoUpdate, getToastDurationMs, getAccountToastsEnabled, getPerProjectAccounts, getEmptyResponseMaxRetries, getEmptyResponseRetryDelayMs, getPidOffsetEnabled, getRotationStrategy, getModelAccountPool, getModelAccountPoolMode, getFetchTimeoutMs, getStreamStallTimeoutMs, getCodexTuiV2, getCodexTuiColorProfile, getCodexTuiGlyphMode, getBeginnerSafeMode, getCodexTuiMaskEmail, loadPluginConfig, } from "./lib/config.js";
|
|
37
37
|
import { AUTH_LABELS, CODEX_BASE_URL, DUMMY_API_KEY, LOG_STAGES, PLUGIN_NAME, PROVIDER_ID, ACCOUNT_LIMITS, } from "./lib/constants.js";
|
|
38
38
|
import { initLogger, logRequest, logDebug, logInfo, logWarn, logError, setCorrelationId, clearCorrelationId, } from "./lib/logger.js";
|
|
39
|
+
import { createQuotaMonitor } from "./lib/quota-notifications.js";
|
|
39
40
|
import { checkAndNotify } from "./lib/auto-update-checker.js";
|
|
40
41
|
import { handleContextOverflow } from "./lib/context-overflow.js";
|
|
41
42
|
import { AccountManager, extractAccountEmail, extractAccountId, formatAccountLabel, formatWaitTime, sanitizeEmail, shouldUpdateAccountIdFromToken, resolveRequestAccountId, parseRateLimitReason, lookupCodexCliTokensByEmail, } from "./lib/accounts.js";
|
|
@@ -1128,10 +1129,22 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
1128
1129
|
});
|
|
1129
1130
|
}
|
|
1130
1131
|
};
|
|
1132
|
+
// Created here, after `invalidateAccountManagerCache`, because the
|
|
1133
|
+
// monitor refreshes access tokens unattended. A refresh rotates the
|
|
1134
|
+
// single-use refresh token durably on disk, so the cached
|
|
1135
|
+
// AccountManager holding the old one must be dropped or its debounced
|
|
1136
|
+
// save clobbers the rotation (see `reloadCachedAccountManager` above).
|
|
1137
|
+
const quotaMonitor = createQuotaMonitor({
|
|
1138
|
+
onCredentialsPersisted: invalidateAccountManagerCache,
|
|
1139
|
+
});
|
|
1131
1140
|
// Event handler for session recovery and account selection
|
|
1132
1141
|
const eventHandler = async (input) => {
|
|
1133
1142
|
try {
|
|
1134
1143
|
const { event } = input;
|
|
1144
|
+
if (event.type === "server.instance.disposed") {
|
|
1145
|
+
quotaMonitor.dispose();
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1135
1148
|
// Handle TUI account selection events
|
|
1136
1149
|
// Accepts generic selection events with an index property
|
|
1137
1150
|
if (event.type === "account.select" ||
|
|
@@ -1238,6 +1251,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
1238
1251
|
const startupPerProjectAccounts = getPerProjectAccounts(startupPluginConfig);
|
|
1239
1252
|
setStoragePath(startupPerProjectAccounts ? process.cwd() : null);
|
|
1240
1253
|
await backfillHostOpenAIAuthFromPool();
|
|
1254
|
+
quotaMonitor.start();
|
|
1241
1255
|
return {
|
|
1242
1256
|
event: eventHandler,
|
|
1243
1257
|
auth: {
|