codex-multi-auth 2.3.0-beta.2 → 2.3.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/.codex-plugin/plugin.json +2 -1
- package/README.md +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/lib/account-policy.d.ts.map +1 -1
- package/dist/lib/account-policy.js +2 -1
- package/dist/lib/accounts/rate-limits.d.ts +8 -0
- package/dist/lib/accounts/rate-limits.d.ts.map +1 -1
- package/dist/lib/accounts/rate-limits.js +13 -0
- package/dist/lib/accounts.d.ts +19 -1
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +31 -2
- package/dist/lib/audit.d.ts +0 -9
- package/dist/lib/audit.d.ts.map +1 -1
- package/dist/lib/auth/device-auth.d.ts +1 -6
- package/dist/lib/auth/device-auth.d.ts.map +1 -1
- package/dist/lib/auth/device-auth.js +5 -5
- package/dist/lib/budget-guard.d.ts.map +1 -1
- package/dist/lib/budget-guard.js +2 -1
- package/dist/lib/codex-cli/writer.d.ts.map +1 -1
- package/dist/lib/codex-cli/writer.js +2 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts.map +1 -1
- package/dist/lib/codex-manager/backend-settings-helpers.js +1 -1
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts +0 -19
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/report.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/report.js +2 -1
- package/dist/lib/codex-manager/commands/uninstall.d.ts +2 -2
- package/dist/lib/codex-manager/commands/uninstall.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/uninstall.js +1 -1
- package/dist/lib/codex-manager/commands/usage.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/usage.js +2 -1
- package/dist/lib/codex-manager/commands/verify.d.ts +2 -2
- package/dist/lib/codex-manager/commands/verify.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/why-selected.d.ts +1 -22
- package/dist/lib/codex-manager/commands/why-selected.d.ts.map +1 -1
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts +0 -14
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +2 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts.map +1 -1
- package/dist/lib/codex-manager/forecast-report-shared.d.ts +2 -2
- package/dist/lib/codex-manager/forecast-report-shared.d.ts.map +1 -1
- package/dist/lib/codex-manager/forecast-report-shared.js +2 -2
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +0 -2
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -1
- package/dist/lib/codex-manager/formatters/quota-formatters.js +2 -2
- package/dist/lib/codex-manager/help.d.ts +2 -1
- package/dist/lib/codex-manager/help.d.ts.map +1 -1
- package/dist/lib/codex-manager/repair-commands.d.ts +0 -15
- package/dist/lib/codex-manager/repair-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/repair-commands.js +5 -5
- package/dist/lib/codex-manager/settings-hub/backend.d.ts +0 -5
- package/dist/lib/codex-manager/settings-hub/backend.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-hub/backend.js +1 -1
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts +1 -14
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-hub/dashboard.js +8 -8
- package/dist/lib/codex-manager/settings-write-queue.d.ts +0 -10
- package/dist/lib/codex-manager/settings-write-queue.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-write-queue.js +10 -10
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts +2 -17
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/theme-settings-panel.d.ts +0 -13
- package/dist/lib/codex-manager/theme-settings-panel.d.ts.map +1 -1
- package/dist/lib/config.d.ts +0 -13
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +22 -19
- package/dist/lib/dashboard-settings.d.ts +3 -3
- package/dist/lib/dashboard-settings.d.ts.map +1 -1
- package/dist/lib/dashboard-settings.js +0 -1
- package/dist/lib/errors.d.ts +0 -1
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/forecast.d.ts +4 -3
- package/dist/lib/forecast.d.ts.map +1 -1
- package/dist/lib/fs-retry.d.ts +0 -3
- package/dist/lib/fs-retry.d.ts.map +1 -1
- package/dist/lib/fs-retry.js +3 -3
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/local-client-tokens.d.ts.map +1 -1
- package/dist/lib/local-client-tokens.js +2 -1
- package/dist/lib/oc-chatgpt-import-adapter.d.ts +1 -1
- package/dist/lib/oc-chatgpt-import-adapter.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-orchestrator.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-orchestrator.js +2 -1
- package/dist/lib/oc-chatgpt-target-detection.d.ts +1 -1
- package/dist/lib/oc-chatgpt-target-detection.d.ts.map +1 -1
- package/dist/lib/prompts/codex-host-bridge.d.ts +0 -8
- package/dist/lib/prompts/codex-host-bridge.d.ts.map +1 -1
- package/dist/lib/prompts/codex-host-bridge.js +0 -20
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +2 -1
- package/dist/lib/prompts/fetch-utils.d.ts +0 -2
- package/dist/lib/prompts/fetch-utils.d.ts.map +1 -1
- package/dist/lib/prompts/fetch-utils.js +2 -2
- package/dist/lib/prompts/host-codex-prompt.d.ts.map +1 -1
- package/dist/lib/prompts/host-codex-prompt.js +2 -1
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +2 -1
- package/dist/lib/recovery/storage.d.ts.map +1 -1
- package/dist/lib/recovery/storage.js +5 -3
- package/dist/lib/recovery/types.d.ts +4 -12
- package/dist/lib/recovery/types.d.ts.map +1 -1
- package/dist/lib/recovery.d.ts +2 -2
- package/dist/lib/recovery.d.ts.map +1 -1
- package/dist/lib/request/response-compaction.d.ts +2 -1
- package/dist/lib/request/response-compaction.d.ts.map +1 -1
- package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -1
- package/dist/lib/request/stream-failover-runtime.js +30 -1
- package/dist/lib/rotation.d.ts +1 -3
- package/dist/lib/rotation.d.ts.map +1 -1
- package/dist/lib/rotation.js +1 -2
- package/dist/lib/routing-profiles.d.ts.map +1 -1
- package/dist/lib/routing-profiles.js +2 -1
- package/dist/lib/runtime/config-toml.d.ts +0 -6
- package/dist/lib/runtime/config-toml.d.ts.map +1 -1
- package/dist/lib/runtime/config-toml.js +6 -6
- package/dist/lib/runtime/event-handler.d.ts +0 -31
- package/dist/lib/runtime/event-handler.d.ts.map +1 -1
- package/dist/lib/runtime/event-handler.js +0 -22
- package/dist/lib/runtime/first-run.d.ts +3 -5
- package/dist/lib/runtime/first-run.d.ts.map +1 -1
- package/dist/lib/runtime/first-run.js +2 -2
- package/dist/lib/runtime/quota-headers.d.ts +1 -6
- package/dist/lib/runtime/quota-headers.d.ts.map +1 -1
- package/dist/lib/runtime/quota-headers.js +5 -5
- package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -1
- package/dist/lib/runtime/rotation-proxy-state.js +24 -0
- package/dist/lib/runtime/runtime-current-account.d.ts +3 -3
- package/dist/lib/runtime/runtime-current-account.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-current-account.js +1 -1
- package/dist/lib/runtime/runtime-observability.d.ts +2 -2
- package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-observability.js +0 -4
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +20 -6
- package/dist/lib/schemas.d.ts +3 -91
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +8 -8
- package/dist/lib/storage/file-paths.d.ts +2 -2
- package/dist/lib/storage/file-paths.d.ts.map +1 -1
- package/dist/lib/storage/file-paths.js +2 -2
- package/dist/lib/storage/flagged-storage-io.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage-io.js +2 -2
- package/dist/lib/storage/import-export.d.ts.map +1 -1
- package/dist/lib/storage/import-export.js +2 -2
- package/dist/lib/storage/migrations.d.ts +2 -1
- package/dist/lib/storage/migrations.d.ts.map +1 -1
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +30 -23
- package/dist/lib/temp-path.d.ts +26 -0
- package/dist/lib/temp-path.d.ts.map +1 -0
- package/dist/lib/temp-path.js +30 -0
- package/dist/lib/ui/theme.d.ts +3 -2
- package/dist/lib/ui/theme.d.ts.map +1 -1
- package/dist/lib/unified-settings.d.ts.map +1 -1
- package/dist/lib/unified-settings.js +2 -1
- package/dist/lib/update-notice.d.ts.map +1 -1
- package/dist/lib/update-notice.js +2 -1
- package/package.json +1 -2
package/dist/lib/config.js
CHANGED
|
@@ -4,9 +4,11 @@ import { dirname, join } from "node:path";
|
|
|
4
4
|
import { parseBooleanEnv } from "./env-parsing.js";
|
|
5
5
|
import { withRetry, withRetrySync } from "./fs-retry.js";
|
|
6
6
|
import { logWarn } from "./logger.js";
|
|
7
|
+
import { StorageError } from "./errors.js";
|
|
7
8
|
import { getCodexHomeDir, getCodexMultiAuthDir, getLegacyCodexDir, } from "./runtime-paths.js";
|
|
8
9
|
import { getValidationErrors, PluginConfigSchema } from "./schemas.js";
|
|
9
10
|
import { getUnifiedSettingsPath, loadUnifiedPluginConfigSync, saveUnifiedPluginConfig, } from "./unified-settings.js";
|
|
11
|
+
import { tempPathFor } from "./temp-path.js";
|
|
10
12
|
const CONFIG_DIR = getCodexMultiAuthDir();
|
|
11
13
|
const CONFIG_PATH = join(CONFIG_DIR, "config.json");
|
|
12
14
|
const CODEX_HOME_DIR = getCodexHomeDir();
|
|
@@ -347,7 +349,7 @@ async function getConfigFileMtimeMs(filePath) {
|
|
|
347
349
|
});
|
|
348
350
|
}
|
|
349
351
|
async function writeJsonFileAtomicWithRetry(filePath, payload, options) {
|
|
350
|
-
const tempPath =
|
|
352
|
+
const tempPath = tempPathFor(filePath);
|
|
351
353
|
await fs.mkdir(dirname(filePath), { recursive: true });
|
|
352
354
|
await fs.writeFile(tempPath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
353
355
|
let renamed = false;
|
|
@@ -692,6 +694,14 @@ function sanitizePluginConfigForSave(config) {
|
|
|
692
694
|
* @param configPatch - Partial PluginConfig containing changes to persist; undefined fields are ignored.
|
|
693
695
|
* @returns void
|
|
694
696
|
*/
|
|
697
|
+
/**
|
|
698
|
+
* Typed abort for a config save that found the existing file unreadable
|
|
699
|
+
* (audit §4.3): same message as the historical bare Error, but callers can
|
|
700
|
+
* now branch on `instanceof StorageError` / the path field instead of text.
|
|
701
|
+
*/
|
|
702
|
+
function unreadableConfigSaveError(configPath, errorMessage) {
|
|
703
|
+
return new StorageError(`Aborting config save because ${configPath} is unreadable.`, "UNREADABLE", configPath, "Fix or remove the unreadable config file, then retry the save.", new Error(errorMessage));
|
|
704
|
+
}
|
|
695
705
|
export async function savePluginConfig(configPatch) {
|
|
696
706
|
const { sanitized: sanitizedPatch, droppedKeys } = sanitizePluginConfigForSave(configPatch);
|
|
697
707
|
if (droppedKeys.length > 0) {
|
|
@@ -707,11 +717,14 @@ export async function savePluginConfig(configPatch) {
|
|
|
707
717
|
// writer. Mirrors the unified-settings save path (writeSettingsRecordAsync
|
|
708
718
|
// CAS).
|
|
709
719
|
await withConfigFileLock(envPath, async () => {
|
|
710
|
-
|
|
720
|
+
// CAS retry: ESTALE means the file's mtime moved between our stat and
|
|
721
|
+
// the write, so each attempt re-stats, re-reads, and re-merges against
|
|
722
|
+
// the latest on-disk state before writing again.
|
|
723
|
+
await withRetry(async () => {
|
|
711
724
|
const expectedMtimeMs = await getConfigFileMtimeMs(envPath);
|
|
712
725
|
const envConfigState = await readConfigRecordForSave(envPath);
|
|
713
726
|
if (envConfigState.status === "unreadable") {
|
|
714
|
-
throw
|
|
727
|
+
throw unreadableConfigSaveError(envPath, envConfigState.errorMessage);
|
|
715
728
|
}
|
|
716
729
|
const existingConfig = envConfigState.status === "ok"
|
|
717
730
|
? sanitizeStoredPluginConfigRecord(envConfigState.record)
|
|
@@ -720,20 +733,10 @@ export async function savePluginConfig(configPatch) {
|
|
|
720
733
|
...(existingConfig ?? {}),
|
|
721
734
|
...sanitizedPatch,
|
|
722
735
|
};
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
catch (error) {
|
|
730
|
-
if (error.code !== "ESTALE" ||
|
|
731
|
-
attempt >= 2) {
|
|
732
|
-
throw error;
|
|
733
|
-
}
|
|
734
|
-
// Loop: re-stat, re-read, re-merge against the latest on-disk state.
|
|
735
|
-
}
|
|
736
|
-
}
|
|
736
|
+
await writeJsonFileAtomicWithRetry(envPath, merged, {
|
|
737
|
+
expectedMtimeMs,
|
|
738
|
+
});
|
|
739
|
+
}, { maxAttempts: 3, backoffMs: 0, retryableCodes: ["ESTALE"] });
|
|
737
740
|
});
|
|
738
741
|
});
|
|
739
742
|
return;
|
|
@@ -742,7 +745,7 @@ export async function savePluginConfig(configPatch) {
|
|
|
742
745
|
await withConfigSaveLock(unifiedPath, async () => {
|
|
743
746
|
const unifiedConfigState = await readConfigRecordForSave(unifiedPath);
|
|
744
747
|
if (unifiedConfigState.status === "unreadable") {
|
|
745
|
-
throw
|
|
748
|
+
throw unreadableConfigSaveError(unifiedPath, unifiedConfigState.errorMessage);
|
|
746
749
|
}
|
|
747
750
|
const unifiedConfigRecord = unifiedConfigState.status === "ok"
|
|
748
751
|
? unifiedConfigState.record.pluginConfig
|
|
@@ -753,7 +756,7 @@ export async function savePluginConfig(configPatch) {
|
|
|
753
756
|
? await readConfigRecordForSave(legacyPath)
|
|
754
757
|
: null;
|
|
755
758
|
if (legacyConfigState?.status === "unreadable") {
|
|
756
|
-
throw
|
|
759
|
+
throw unreadableConfigSaveError(legacyPath, legacyConfigState.errorMessage);
|
|
757
760
|
}
|
|
758
761
|
const legacyConfig = legacyConfigState?.status === "ok"
|
|
759
762
|
? sanitizeStoredPluginConfigRecord(legacyConfigState.record)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type DashboardThemePreset = "green" | "blue";
|
|
2
2
|
export type DashboardAccentColor = "green" | "cyan" | "blue" | "yellow";
|
|
3
3
|
export type DashboardAccountSortMode = "manual" | "ready-first";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type DashboardLayoutMode = "compact-details" | "expanded-rows";
|
|
5
|
+
type DashboardFocusStyle = "row-invert";
|
|
6
6
|
export interface DashboardDisplaySettings {
|
|
7
7
|
showPerAccountRows: boolean;
|
|
8
8
|
showQuotaDetails: boolean;
|
|
@@ -32,7 +32,6 @@ export interface DashboardDisplaySettings {
|
|
|
32
32
|
menuStatuslineFields?: DashboardStatuslineField[];
|
|
33
33
|
}
|
|
34
34
|
export type DashboardStatuslineField = "last-used" | "limits" | "status";
|
|
35
|
-
export declare const DASHBOARD_DISPLAY_SETTINGS_VERSION: 1;
|
|
36
35
|
export declare const DEFAULT_DASHBOARD_DISPLAY_SETTINGS: DashboardDisplaySettings;
|
|
37
36
|
/**
|
|
38
37
|
* Filesystem path to the unified dashboard settings file.
|
|
@@ -87,4 +86,5 @@ export declare function loadDashboardDisplaySettings(): Promise<DashboardDisplay
|
|
|
87
86
|
* @param settings - The dashboard display settings to normalize and save
|
|
88
87
|
*/
|
|
89
88
|
export declare function saveDashboardDisplaySettings(settings: DashboardDisplaySettings): Promise<void>;
|
|
89
|
+
export {};
|
|
90
90
|
//# sourceMappingURL=dashboard-settings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-settings.d.ts","sourceRoot":"","sources":["../../lib/dashboard-settings.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,MAAM,CAAC;AACpD,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AACxE,MAAM,MAAM,wBAAwB,GAAG,QAAQ,GAAG,aAAa,CAAC;AAChE,
|
|
1
|
+
{"version":3,"file":"dashboard-settings.d.ts","sourceRoot":"","sources":["../../lib/dashboard-settings.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,MAAM,CAAC;AACpD,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AACxE,MAAM,MAAM,wBAAwB,GAAG,QAAQ,GAAG,aAAa,CAAC;AAChE,KAAK,mBAAmB,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAC/D,KAAK,mBAAmB,GAAG,YAAY,CAAC;AAExC,MAAM,WAAW,wBAAwB;IACxC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,wBAAwB,CAAC;IACxC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,oBAAoB,CAAC,EAAE,wBAAwB,EAAE,CAAC;CAClD;AAED,MAAM,MAAM,wBAAwB,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEzE,eAAO,MAAM,kCAAkC,EAAE,wBA2BhD,CAAC;AA4LF;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAEjD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iCAAiC,CAChD,KAAK,EAAE,OAAO,GACZ,wBAAwB,CAoG1B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,wBAAwB,CAAC,CA+BtF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,4BAA4B,CACjD,QAAQ,EAAE,wBAAwB,GAChC,OAAO,CAAC,IAAI,CAAC,CAGf"}
|
|
@@ -4,7 +4,6 @@ import { getCodexMultiAuthDir } from "./runtime-paths.js";
|
|
|
4
4
|
import { logWarn } from "./logger.js";
|
|
5
5
|
import { sleep } from "./utils.js";
|
|
6
6
|
import { getUnifiedSettingsPath, loadUnifiedDashboardSettings, saveUnifiedDashboardSettings, } from "./unified-settings.js";
|
|
7
|
-
export const DASHBOARD_DISPLAY_SETTINGS_VERSION = 1;
|
|
8
7
|
export const DEFAULT_DASHBOARD_DISPLAY_SETTINGS = {
|
|
9
8
|
showPerAccountRows: true,
|
|
10
9
|
showQuotaDetails: true,
|
package/dist/lib/errors.d.ts
CHANGED
package/dist/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../lib/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;CAQZ,CAAC;AAEX
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../lib/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;CAQZ,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;GAGG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACpC,SAAkB,IAAI,EAAE,MAAM,CAAgB;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAE/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB;CAUxD;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC9D,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,UAAU;IAC5C,SAAkB,IAAI,mBAAmB;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAE9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SAAQ,UAAU;IAClD,SAAkB,IAAI,yBAAyB;IAC/C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;gBAEhB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0B;CAKjE;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAC3C,SAAkB,IAAI,kBAAkB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAGrB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,KAAK;CAMd;AAED;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,UAAU;IACpD,SAAkB,IAAI,2BAA2B;gBAErC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB;CAGxD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAMtF"}
|
package/dist/lib/forecast.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import type { CodexQuotaSnapshot } from "./quota-probe.js";
|
|
|
2
2
|
import type { QuotaCacheData } from "./quota-cache.js";
|
|
3
3
|
import type { AccountMetadataV3 } from "./storage.js";
|
|
4
4
|
import type { TokenFailure } from "./types.js";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type ForecastAvailability = "ready" | "delayed" | "unavailable";
|
|
6
|
+
type ForecastRiskLevel = "low" | "medium" | "high";
|
|
7
7
|
export interface ForecastAccountInput {
|
|
8
8
|
index: number;
|
|
9
9
|
account: AccountMetadataV3;
|
|
@@ -37,7 +37,7 @@ export interface ForecastRecommendation {
|
|
|
37
37
|
recommendedIndex: number | null;
|
|
38
38
|
reason: string;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
interface ForecastExplanationAccount {
|
|
41
41
|
index: number;
|
|
42
42
|
label: string;
|
|
43
43
|
isCurrent: boolean;
|
|
@@ -66,4 +66,5 @@ export declare function evaluateForecastAccounts(inputs: ForecastAccountInput[])
|
|
|
66
66
|
export declare function recommendForecastAccount(results: ForecastAccountResult[]): ForecastRecommendation;
|
|
67
67
|
export declare function summarizeForecast(results: ForecastAccountResult[]): ForecastSummary;
|
|
68
68
|
export declare function buildForecastExplanation(results: ForecastAccountResult[], recommendation: ForecastRecommendation): ForecastExplanation;
|
|
69
|
+
export {};
|
|
69
70
|
//# sourceMappingURL=forecast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forecast.d.ts","sourceRoot":"","sources":["../../lib/forecast.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,
|
|
1
|
+
{"version":3,"file":"forecast.d.ts","sourceRoot":"","sources":["../../lib/forecast.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,KAAK,oBAAoB,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,CAAC;AAChE,KAAK,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEnD,MAAM,WAAW,oBAAoB;IACpC,KAAK,EAAE,MAAM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7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IACnC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,UAAU,EAAE,0BAA0B,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACjB;AA0ED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAUnE;AAWD,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,oBAAoB,GACzB,qBAAqB,CA+LvB;AAED,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,oBAAoB,EAAE,GAC5B,qBAAqB,EAAE,CAEzB;AAkCD,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,qBAAqB,EAAE,GAC9B,sBAAsB,CAuDxB;AAED,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,qBAAqB,EAAE,GAC9B,eAAe,CAWjB;AAED,wBAAgB,wBAAwB,CACvC,OAAO,EAAE,qBAAqB,EAAE,EAChC,cAAc,EAAE,sBAAsB,GACpC,mBAAmB,CAgBrB"}
|
package/dist/lib/fs-retry.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export declare const FILE_RETRY_CODES: Set<string>;
|
|
2
|
-
export declare const FILE_RETRY_MAX_ATTEMPTS = 6;
|
|
3
|
-
export declare const FILE_RETRY_BASE_DELAY_MS = 25;
|
|
4
|
-
export declare const FILE_RETRY_JITTER_MS = 20;
|
|
5
2
|
export declare function shouldRetryFileOperation(error: unknown): boolean;
|
|
6
3
|
/**
|
|
7
4
|
* Options for {@link withRetry} / {@link withRetrySync}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs-retry.d.ts","sourceRoot":"","sources":["../../lib/fs-retry.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,aAM3B,CAAC;
|
|
1
|
+
{"version":3,"file":"fs-retry.d.ts","sourceRoot":"","sources":["../../lib/fs-retry.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,aAM3B,CAAC;AASH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOhE;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC5B,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IAClD;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,MAAM,EAAE,CAAC;IACzD,sEAAsE;IACtE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAgCD;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAChC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAC/B,OAAO,EAAE,YAAY,GACnB,OAAO,CAAC,CAAC,CAAC,CAkBZ;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,YAAY,GAAG,CAAC,CAqB7E;AAED,wBAAgB,sBAAsB,CAAC,CAAC,EACvC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACzB,OAAO,CAAC,CAAC,CAAC,CAOZ"}
|
package/dist/lib/fs-retry.js
CHANGED
|
@@ -5,9 +5,9 @@ export const FILE_RETRY_CODES = new Set([
|
|
|
5
5
|
"ENOTEMPTY",
|
|
6
6
|
"EACCES",
|
|
7
7
|
]);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const FILE_RETRY_MAX_ATTEMPTS = 6;
|
|
9
|
+
const FILE_RETRY_BASE_DELAY_MS = 25;
|
|
10
|
+
const FILE_RETRY_JITTER_MS = 20;
|
|
11
11
|
function sleep(ms) {
|
|
12
12
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
13
13
|
}
|
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAClB,0BAA0B,EAC1B,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,EAC7B,iCAAiC,IAAI,2CAA2C,EAChF,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,iCAAiC,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6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AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC"}
|
package/dist/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-client-tokens.d.ts","sourceRoot":"","sources":["../../lib/local-client-tokens.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"local-client-tokens.d.ts","sourceRoot":"","sources":["../../lib/local-client-tokens.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACrC,OAAO,EAAE,CAAC,CAAC;IACX,MAAM,EAAE,sBAAsB,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,uBAAuB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,sBAAsB,CAAC;CAC/B;AAqHD,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AAED,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAahF;AAgDD,wBAAsB,yBAAyB,CAC9C,KAAK,EAAE,qBAAqB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAgB,4BAA4B,CAAC,KAAK,GAAE;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACR,GAAG,uBAAuB,CAY/B;AAED,wBAAsB,mBAAmB,CAAC,KAAK,GAAE;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACR,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAQxC;AAED,wBAAsB,sBAAsB,CAAC,KAAK,EAAE;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACb,GAAG,OAAO,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAe1C;AAED,wBAAsB,sBAAsB,CAC3C,EAAE,EAAE,MAAM,EACV,GAAG,SAAa,GACd,OAAO,CAAC,OAAO,CAAC,CASlB;AAED,wBAAsB,4BAA4B,CACjD,mBAAmB,EAAE,MAAM,GAAG,IAAI,EAClC,GAAG,SAAa,GACd,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAwBxC;AAED,wBAAgB,uCAAuC,IAAI,IAAI,CAE9D"}
|
|
@@ -4,6 +4,7 @@ import { basename, join } from "node:path";
|
|
|
4
4
|
import { logWarn } from "./logger.js";
|
|
5
5
|
import { getCodexMultiAuthDir } from "./runtime-paths.js";
|
|
6
6
|
import { isRecord, sleep } from "./utils.js";
|
|
7
|
+
import { tempPathFor } from "./temp-path.js";
|
|
7
8
|
const TOKEN_FILE_NAME = "local-client-tokens.json";
|
|
8
9
|
const TOKEN_PREFIX = "cma_local";
|
|
9
10
|
// Debounce window for persisting a record's lastUsedAt. Bearer verification is
|
|
@@ -138,7 +139,7 @@ async function writeStoreToDisk(store) {
|
|
|
138
139
|
// Best-effort hardening only.
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
|
-
const tempPath =
|
|
142
|
+
const tempPath = tempPathFor(path);
|
|
142
143
|
let moved = false;
|
|
143
144
|
try {
|
|
144
145
|
await fs.writeFile(tempPath, `${JSON.stringify(payload, null, 2)}\n`, {
|
|
@@ -7,7 +7,7 @@ export type OcChatgptPreviewPayload = {
|
|
|
7
7
|
activeIndexByFamily?: AccountStorageV3["activeIndexByFamily"];
|
|
8
8
|
accounts: OcChatgptAccountRef[];
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type OcChatgptAccountRef = {
|
|
11
11
|
accountId?: string;
|
|
12
12
|
email?: string;
|
|
13
13
|
refreshTokenLast4: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oc-chatgpt-import-adapter.d.ts","sourceRoot":"","sources":["../../lib/oc-chatgpt-import-adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,gBAAgB,EAIrB,MAAM,cAAc,CAAC;AAEtB,KAAK,aAAa,GAAG,WAAW,GAAG,OAAO,GAAG,cAAc,CAAC;AAE5D,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEtD,MAAM,MAAM,uBAAuB,GAAG;IACrC,OAAO,EAAE,CAAC,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IAC9D,QAAQ,EAAE,mBAAmB,EAAE,CAAC;CAChC,CAAC;AAEF,
|
|
1
|
+
{"version":3,"file":"oc-chatgpt-import-adapter.d.ts","sourceRoot":"","sources":["../../lib/oc-chatgpt-import-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AI,CAAC;IAChC,WAAW,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACrC,GAAG,qBAAqB,CA2ExB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oc-chatgpt-orchestrator.d.ts","sourceRoot":"","sources":["../../lib/oc-chatgpt-orchestrator.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,2BAA2B,EAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,8BAA8B,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAE9B,KAAK,mBAAmB,EACxB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,KAAK,gBAAgB,EACrB,iBAAiB,EAEjB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"oc-chatgpt-orchestrator.d.ts","sourceRoot":"","sources":["../../lib/oc-chatgpt-orchestrator.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,2BAA2B,EAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,8BAA8B,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAE9B,KAAK,mBAAmB,EACxB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,KAAK,gBAAgB,EACrB,iBAAiB,EAEjB,MAAM,cAAc,CAAC;AAGtB,KAAK,gBAAgB,GAAG;IACvB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,SAAS,EAAE,wBAAwB,CAAC;CACpC,CAAC;AAEF,KAAK,WAAW,GAAG;IAClB,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,mBAAmB,CAAC;CAC/B,CAAC;AAEF,KAAK,gBAAgB,GAAG,gBAAgB,GAAG,WAAW,CAAC;AAEvD,KAAK,sBAAsB,GAAG;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,yBAAyB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AAE,2BAA2B,GAClC,OAAO,CAAC,0BAA0B,CAAC,CAYrC"}
|
|
@@ -4,6 +4,7 @@ import { withFileOperationRetry } from "./fs-retry.js";
|
|
|
4
4
|
import { previewOcChatgptImportMerge, } from "./oc-chatgpt-import-adapter.js";
|
|
5
5
|
import { detectOcChatgptMultiAuthTarget, } from "./oc-chatgpt-target-detection.js";
|
|
6
6
|
import { exportNamedBackup, normalizeAccountStorage, } from "./storage.js";
|
|
7
|
+
import { tempPathFor } from "./temp-path.js";
|
|
7
8
|
function mapDetectionToBlocked(detection) {
|
|
8
9
|
if (detection.kind === "ambiguous") {
|
|
9
10
|
return { kind: "blocked-ambiguous", detection };
|
|
@@ -84,7 +85,7 @@ async function persistMergedDefault(target, merged) {
|
|
|
84
85
|
if (process.platform !== "win32") {
|
|
85
86
|
await fs.chmod(dir, 0o700).catch(() => undefined);
|
|
86
87
|
}
|
|
87
|
-
const tempPath =
|
|
88
|
+
const tempPath = tempPathFor(path);
|
|
88
89
|
const content = `${JSON.stringify(merged, null, 2)}\n`;
|
|
89
90
|
try {
|
|
90
91
|
await fs.writeFile(tempPath, content, { encoding: "utf-8", mode: 0o600 });
|
|
@@ -27,7 +27,7 @@ export type OcChatgptTargetNone = {
|
|
|
27
27
|
reason: string;
|
|
28
28
|
tried: Array<Pick<OcChatgptTargetCandidate, "scope" | "root" | "accountPath" | "backupRoot" | "source">>;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
type OcChatgptTargetFound = {
|
|
31
31
|
kind: "target";
|
|
32
32
|
descriptor: OcChatgptTargetDescriptor;
|
|
33
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oc-chatgpt-target-detection.d.ts","sourceRoot":"","sources":["../../lib/oc-chatgpt-target-detection.ts"],"names":[],"mappings":"AAcA,KAAK,oBAAoB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEjD,KAAK,qBAAqB,GAAG,UAAU,GAAG,gBAAgB,GAAG,SAAS,CA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YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GAAG,8BAA8B,CA4JjC"}
|
|
@@ -8,12 +8,4 @@
|
|
|
8
8
|
* Token Count: ~450 tokens (~90% reduction vs full host prompt)
|
|
9
9
|
*/
|
|
10
10
|
export declare const CODEX_HOST_BRIDGE = "# Codex Host Bridge\n\nYou are running Codex through a host terminal coding runtime. The host provides specific tools to help you work efficiently.\n\n## CRITICAL: Tool Usage\n\n<critical_rule priority=\"0\">\napply_patch/applyPatch are Codex names, but host tool names vary by version.\n- Inspect the actual tool list before editing.\n- If `edit` exists: use `edit` for precise in-place string replacements and hashline edits.\n- If `edit` is absent and `apply_patch` exists: use `apply_patch` for those precise/hashline edits in this plugin.\n- For diff-style or multi-line structural edits: use `patch` if available, otherwise use `apply_patch`.\n- In this plugin, `edit` / `apply_patch` also support hashline refs (`lineRef`, `endLineRef`, `operation`, `content`)\n</critical_rule>\n\n<critical_rule priority=\"0\">\nUPDATE_PLAN DOES NOT EXIST -> USE \"todowrite\" INSTEAD\n- NEVER use: update_plan, updatePlan, read_plan, readPlan\n- ALWAYS use: todowrite for task/plan updates, todoread to read plans\n- Before plan operations: Verify you're using \"todowrite\", NOT \"update_plan\"\n</critical_rule>\n\n## Available Host Tools\n\n**File Operations:**\n- `write` - Create new files\n - Overwriting existing files requires a prior Read in this session; default to ASCII unless the file already uses Unicode.\n- `edit` - Modify existing files with string replacement (version-dependent)\n - Requires a prior Read in this session; preserve exact indentation; ensure `oldString` uniquely matches or use `replaceAll`; edit fails if ambiguous or missing.\n - Never pass unresolved template placeholders in `oldString` (e.g. `${TARGET_SNIPPET}`); `oldString` must be literal text copied from the current file.\n - For complex multi-line changes: break into multiple sequential edit calls, each with unique oldString context.\n- `apply_patch` - May be the edit/patch tool name in newer host builds (version-dependent)\n - In this plugin, `apply_patch` also accepts hashline edit args (`path`, `lineRef`, `endLineRef`, `operation`, `content`) when `edit` is not available.\n- `hashline_read` - Read file with hashline refs (`L<line>#<hash>`) for deterministic edits\n- `patch` - Apply diff-style patches for multi-line updates (version-dependent)\n- `read` - Read file contents\n\nNote: Tool naming is version-dependent. If `edit` is unavailable but `apply_patch` exists, use `apply_patch`.\n\nWhen available, prefer hashline workflow for reliability:\n1. Call `hashline_read` for target file and capture refs.\n2. Call `edit` or `apply_patch` with `lineRef` (and optional `endLineRef`) plus `operation` and `content`.\n3. Use legacy `oldString` / `newString` only when hashline refs are unavailable, and only with literal file text (no template placeholders).\n\n**Search/Discovery:**\n- `grep` - Search file contents (tool, not bash grep); use `include` to filter patterns; set `path` only when not searching workspace root; for cross-file match counts use bash with `rg`.\n- `glob` - Find files by pattern; defaults to workspace cwd unless `path` is set.\n- `list` - List directories (requires absolute paths)\n\n**Execution:**\n- `bash` - Run shell commands\n - No workdir parameter; do not include it in tool calls.\n - Always include a short description for the command.\n - Do not use cd; use absolute paths in commands.\n - Quote paths containing spaces with double quotes.\n - Chain multiple commands with ';' or '&&'; avoid newlines.\n - Use Grep/Glob tools for searches; only use bash with `rg` when you need counts or advanced features.\n - Do not use `ls`/`cat` in bash; use `list`/`read` tools instead.\n - For deletions (rm), verify by listing parent dir with `list`.\n\n**Network:**\n- `webfetch` - Fetch web content\n - Use fully-formed URLs (http/https; http auto-upgrades to https).\n - Always set `format` to one of: text | markdown | html; prefer markdown unless otherwise required.\n - Read-only; short cache window.\n\n**Task Management:**\n- `todowrite` - Manage tasks/plans (REPLACES update_plan)\n- `todoread` - Read current plan\n\n## Substitution Rules\n\nBase instruction says: You MUST use instead:\napply_patch -> patch (preferred if available), otherwise edit/apply_patch based on actual tool list\nupdate_plan -> todowrite\nread_plan -> todoread\n\n**Path Usage:** Use per-tool conventions to avoid conflicts:\n- Tool calls: `read`, `edit`, `write`, `list` require absolute paths.\n- Searches: `grep`/`glob` default to the workspace cwd; prefer relative include patterns; set `path` only when a different root is needed.\n- Presentation: In assistant messages, show workspace-relative paths; use absolute paths only inside tool calls.\n- Tool schema overrides general path preferences-do not convert required absolute paths to relative.\n\n## Verification Checklist\n\nBefore file/plan modifications:\n1. Am I using the actual available edit tool name (`edit`, `patch`, or `apply_patch`)?\n2. Am I using \"todowrite\" NOT \"update_plan\"?\n3. Is this tool in the approved list above?\n4. Am I following each tool's path requirements?\n\nIf ANY answer is NO -> STOP and correct before proceeding.\n\n## Host Working Style\n\n**Communication:**\n- Send brief preambles (8-12 words) before tool calls, building on prior context\n- Provide progress updates during longer tasks\n\n**Execution:**\n- Keep working autonomously until query is fully resolved before yielding\n- Don't return to user with partial solutions\n\n**Code Approach:**\n- New projects: Be ambitious and creative\n- Existing codebases: Surgical precision - modify only what's requested unless explicitly instructed to do otherwise\n\n**Testing:**\n- If tests exist: Start specific to your changes, then broader validation\n\n## Advanced Tools\n\n**Task Tool (Sub-Agents):**\n- Use the Task tool (functions.task) to launch sub-agents\n- Check the Task tool description for current agent types and their capabilities\n- Useful for complex analysis, specialized workflows, or tasks requiring isolated context\n- The agent list is dynamically generated - refer to tool schema for available agents\n\n**Parallelization:**\n- When multiple independent tool calls are needed, use multi_tool_use.parallel to run them concurrently.\n- Reserve sequential calls for ordered or data-dependent steps.\n\n**MCP Tools:**\n- Model Context Protocol servers provide additional capabilities\n- MCP tools are prefixed: `mcp__<server-name>__<tool-name>`\n- Check your available tools for MCP integrations\n- Use when the tool's functionality matches your task needs\n\n## What Remains from Codex\n \nSandbox policies, approval mechanisms, final answer formatting, git commit protocols, and file reference formats all follow Codex instructions. In approval policy \"never\", never request escalations.\n\n## Approvals & Safety\n- Assume workspace-write filesystem, network enabled, approval on-failure unless explicitly stated otherwise.\n- When a command fails due to sandboxing or permissions, retry with escalated permissions if allowed by policy, including a one-line justification.\n- Treat destructive commands (e.g., `rm`, `git reset --hard`) as requiring explicit user request or approval.\n- Never run `git reset --hard`, `git checkout --`, or force deletes unless the user explicitly asked for that exact action.\n- `request_user_input` is Plan-mode only; do not call it in Default mode.\n- When uncertain, prefer non-destructive verification first (e.g., confirm file existence with `list`, then delete with `bash`).";
|
|
11
|
-
export interface CodexHostBridgeMeta {
|
|
12
|
-
estimatedTokens: number;
|
|
13
|
-
reductionVsCurrent: string;
|
|
14
|
-
reductionVsToolRemap: string;
|
|
15
|
-
protects: string[];
|
|
16
|
-
omits: string[];
|
|
17
|
-
}
|
|
18
|
-
export declare const CODEX_HOST_BRIDGE_META: CodexHostBridgeMeta;
|
|
19
11
|
//# sourceMappingURL=codex-host-bridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-host-bridge.d.ts","sourceRoot":"","sources":["../../../lib/prompts/codex-host-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,iBAAiB,y5OA0IuG,CAAC
|
|
1
|
+
{"version":3,"file":"codex-host-bridge.d.ts","sourceRoot":"","sources":["../../../lib/prompts/codex-host-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,iBAAiB,y5OA0IuG,CAAC"}
|
|
@@ -146,23 +146,3 @@ Sandbox policies, approval mechanisms, final answer formatting, git commit proto
|
|
|
146
146
|
- Never run \`git reset --hard\`, \`git checkout --\`, or force deletes unless the user explicitly asked for that exact action.
|
|
147
147
|
- \`request_user_input\` is Plan-mode only; do not call it in Default mode.
|
|
148
148
|
- When uncertain, prefer non-destructive verification first (e.g., confirm file existence with \`list\`, then delete with \`bash\`).`;
|
|
149
|
-
export const CODEX_HOST_BRIDGE_META = {
|
|
150
|
-
estimatedTokens: 550,
|
|
151
|
-
reductionVsCurrent: "88%",
|
|
152
|
-
reductionVsToolRemap: "10%",
|
|
153
|
-
protects: [
|
|
154
|
-
"Tool name confusion (update_plan)",
|
|
155
|
-
"Missing tool awareness",
|
|
156
|
-
"Task tool / sub-agent awareness",
|
|
157
|
-
"MCP tool awareness",
|
|
158
|
-
"Premature yielding to user",
|
|
159
|
-
"Over-modification of existing code",
|
|
160
|
-
"Environment confusion",
|
|
161
|
-
],
|
|
162
|
-
omits: [
|
|
163
|
-
"Sandbox details (in Codex)",
|
|
164
|
-
"Formatting rules (in Codex)",
|
|
165
|
-
"Tool schemas (in tool JSONs)",
|
|
166
|
-
"Git protocols (in Codex)",
|
|
167
|
-
],
|
|
168
|
-
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../lib/prompts/codex.ts"],"names":[],"mappings":"AAOA,OAAO,EAAkC,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../lib/prompts/codex.ts"],"names":[],"mappings":"AAOA,OAAO,EAAkC,KAAK,WAAW,EAAE,MAAM,iCAAiC,CAAC;AA4EnG;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAI7C;AAcD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAyBnE;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,GAAG,WAAW,CAEnE;AA4ED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACzC,eAAe,SAAgB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAkHjB;AA6GD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,IAAI,CAiBpE;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,ozGA+EV,CAAC"}
|
|
@@ -7,6 +7,7 @@ import { getCodexCacheDir } from "../runtime-paths.js";
|
|
|
7
7
|
import { DEFAULT_MODEL, getModelProfile } from "../request/helpers/model-map.js";
|
|
8
8
|
import { fetchWithTimeout, readBodyTextGuarded, withBodyTimeout } from "./fetch-utils.js";
|
|
9
9
|
import { withFileOperationRetry } from "../fs-retry.js";
|
|
10
|
+
import { tempFileNonce } from "../temp-path.js";
|
|
10
11
|
/** SHA-256 of cache content for integrity verification (prompts-03). */
|
|
11
12
|
function sha256(content) {
|
|
12
13
|
return createHash("sha256").update(content, "utf8").digest("hex");
|
|
@@ -29,7 +30,7 @@ function sha256(content) {
|
|
|
29
30
|
*/
|
|
30
31
|
async function writeCacheAtomically(cacheFile, cacheMetaFile, content, meta) {
|
|
31
32
|
await withFileOperationRetry(() => fs.mkdir(CACHE_DIR, { recursive: true }));
|
|
32
|
-
const nonce =
|
|
33
|
+
const nonce = tempFileNonce();
|
|
33
34
|
const contentTmp = `${cacheFile}.${nonce}.tmp`;
|
|
34
35
|
const metaTmp = `${cacheMetaFile}.${nonce}.tmp`;
|
|
35
36
|
try {
|
|
@@ -13,9 +13,7 @@
|
|
|
13
13
|
* - a User-Agent (api.github.com rejects requests without one) plus a sensible
|
|
14
14
|
* Accept, applied to every request (prompts-08)
|
|
15
15
|
*/
|
|
16
|
-
export declare const PROMPT_FETCH_TIMEOUT_MS = 10000;
|
|
17
16
|
export declare const PROMPT_FETCH_MAX_BYTES = 1000000;
|
|
18
|
-
export declare const PROMPT_FETCH_USER_AGENT = "codex-multi-auth";
|
|
19
17
|
export interface PromptFetchOptions {
|
|
20
18
|
headers?: Record<string, string>;
|
|
21
19
|
timeoutMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-utils.d.ts","sourceRoot":"","sources":["../../../lib/prompts/fetch-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"fetch-utils.d.ts","sourceRoot":"","sources":["../../../lib/prompts/fetch-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,eAAO,MAAM,sBAAsB,UAAY,CAAC;AAGhD,MAAM,WAAW,kBAAkB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACpC,IAAI,UAAQ,GACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACrC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,kBAAuB,EAChC,SAAS,GAAE,OAAO,KAAa,GAC7B,OAAO,CAAC,QAAQ,CAAC,CAYnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,eAAe,CAAC,CAAC,EACtC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,EAChC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,SAAS,GAAE,MAAgC,GACzC,OAAO,CAAC,CAAC,CAAC,CAqBZ;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CACxC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,GAAE,MAA+B,EACzC,SAAS,GAAE,MAAgC,GACzC,OAAO,CAAC,MAAM,CAAC,CA2DjB"}
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
* - a User-Agent (api.github.com rejects requests without one) plus a sensible
|
|
14
14
|
* Accept, applied to every request (prompts-08)
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
const PROMPT_FETCH_TIMEOUT_MS = 10_000;
|
|
17
17
|
export const PROMPT_FETCH_MAX_BYTES = 1_000_000; // 1 MB ceiling for a prompt body
|
|
18
|
-
|
|
18
|
+
const PROMPT_FETCH_USER_AGENT = "codex-multi-auth";
|
|
19
19
|
/**
|
|
20
20
|
* Merge caller headers with the mandatory User-Agent / Accept defaults.
|
|
21
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-codex-prompt.d.ts","sourceRoot":"","sources":["../../../lib/prompts/host-codex-prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"host-codex-prompt.d.ts","sourceRoot":"","sources":["../../../lib/prompts/host-codex-prompt.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2VH;;;;;;GAMG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CA+B1D;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,SAAK,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAO9E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAI7C"}
|
|
@@ -10,6 +10,7 @@ import { logDebug } from "../logger.js";
|
|
|
10
10
|
import { getCodexCacheDir } from "../runtime-paths.js";
|
|
11
11
|
import { sleep } from "../utils.js";
|
|
12
12
|
import { fetchWithTimeout, readBodyTextGuarded } from "./fetch-utils.js";
|
|
13
|
+
import { tempFileNonce } from "../temp-path.js";
|
|
13
14
|
const DEFAULT_HOST_CODEX_PROMPT_URLS = [
|
|
14
15
|
// Canonical upstream is sst/opencode. The previous list pointed at a rebrand
|
|
15
16
|
// artifact (`anomalyco/Codex`, `sst/Codex`, `packages/Codex/...`) that 404s, so
|
|
@@ -132,7 +133,7 @@ async function removeFileQuietly(path) {
|
|
|
132
133
|
}
|
|
133
134
|
async function writeCacheFilesAtomically(content, meta) {
|
|
134
135
|
await mkdir(CACHE_DIR, { recursive: true });
|
|
135
|
-
const nonce =
|
|
136
|
+
const nonce = tempFileNonce();
|
|
136
137
|
const contentTmp = `${CACHE_FILE}.${nonce}.tmp`;
|
|
137
138
|
const metaTmp = `${CACHE_META_FILE}.${nonce}.tmp`;
|
|
138
139
|
const metaJson = JSON.stringify(meta, null, 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-cache.d.ts","sourceRoot":"","sources":["../../lib/quota-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota-cache.d.ts","sourceRoot":"","sources":["../../lib/quota-cache.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,gBAAgB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,SAAS,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CACzC;AAsGD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,cAAc,CAAC,CA4B9D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CA4DxE"}
|
package/dist/lib/quota-cache.js
CHANGED
|
@@ -3,6 +3,7 @@ import { basename, join } from "node:path";
|
|
|
3
3
|
import { withRetry } from "./fs-retry.js";
|
|
4
4
|
import { logWarn } from "./logger.js";
|
|
5
5
|
import { getCodexMultiAuthDir } from "./runtime-paths.js";
|
|
6
|
+
import { tempPathFor } from "./temp-path.js";
|
|
6
7
|
import { isRecord } from "./utils.js";
|
|
7
8
|
const QUOTA_CACHE_PATH = join(getCodexMultiAuthDir(), "quota-cache.json");
|
|
8
9
|
const QUOTA_CACHE_LABEL = basename(QUOTA_CACHE_PATH);
|
|
@@ -192,7 +193,7 @@ export async function saveQuotaCache(data) {
|
|
|
192
193
|
// Best-effort hardening only.
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
|
-
const tempPath =
|
|
196
|
+
const tempPath = tempPathFor(QUOTA_CACHE_PATH);
|
|
196
197
|
await fs.writeFile(tempPath, `${JSON.stringify(payload, null, 2)}\n`, {
|
|
197
198
|
encoding: "utf8",
|
|
198
199
|
mode: 0o600,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../lib/recovery/storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../lib/recovery/storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqBH,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AA4EhF,mFAAmF;AACnF,wBAAgB,0BAA0B,IAAI;IAC7C,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC3B,CAEA;AAED,kDAAkD;AAClD,wBAAgB,8BAA8B,IAAI,IAAI,CAGrD;AAuJD,wBAAgB,cAAc,IAAI,MAAM,CAIvC;AAUD;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAK/C;AAMD,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAsBvD;AAMD,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,EAAE,CA0CnE;AAMD,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CAiCzD;AAMD,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAkBpD;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAG5D;AAMD,wBAAgB,cAAc,CAC7B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACV,OAAO,CA8BT;AAMD,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAe1E;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAoBxE;AAED,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAwB1E;AAED,wBAAgB,mBAAmB,CAClC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GACf,OAAO,CAkCT;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAkC7D;AAMD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAW7D;AAED,wBAAgB,uBAAuB,CACtC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAkBf;AAED,wBAAgB,iCAAiC,CAChD,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GACjB,MAAM,GAAG,IAAI,CAsBf;AAED,wBAAgB,qBAAqB,CACpC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACrB,OAAO,CAgCT;AAED,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAkB1E"}
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Based on Codex-antigravity-auth recovery module.
|
|
5
5
|
*/
|
|
6
|
+
import { randomBytes } from "node:crypto";
|
|
6
7
|
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
7
8
|
import { join } from "node:path";
|
|
8
9
|
import { withRetrySync } from "../fs-retry.js";
|
|
9
10
|
import { MESSAGE_STORAGE, PART_STORAGE, THINKING_TYPES, META_TYPES, } from "./constants.js";
|
|
10
11
|
import { createLogger } from "../logger.js";
|
|
12
|
+
import { tempFileNonce } from "../temp-path.js";
|
|
11
13
|
const recoveryLog = createLogger("recovery-storage");
|
|
12
14
|
/**
|
|
13
15
|
* recovery-10: corrupt session files were silently skipped (`continue`) with no
|
|
@@ -176,7 +178,7 @@ function renameSyncWithRetry(source, target) {
|
|
|
176
178
|
* do not silently drop the payload. See AUDIT-M01 HIGH-2.
|
|
177
179
|
*/
|
|
178
180
|
function atomicWriteFileSync(path, data, options = {}) {
|
|
179
|
-
const tempSuffix = `.tmp.${
|
|
181
|
+
const tempSuffix = `.tmp.${tempFileNonce()}`;
|
|
180
182
|
const tempPath = `${path}${tempSuffix}`;
|
|
181
183
|
try {
|
|
182
184
|
writeFileSync(tempPath, data, { mode: options.mode ?? 0o600 });
|
|
@@ -225,7 +227,7 @@ function safeUnlinkWithRetry(filePath, maxAttempts = 4) {
|
|
|
225
227
|
// =============================================================================
|
|
226
228
|
export function generatePartId() {
|
|
227
229
|
const timestamp = Date.now().toString(16);
|
|
228
|
-
const random =
|
|
230
|
+
const random = randomBytes(4).toString("hex");
|
|
229
231
|
return `prt_${timestamp}${random}`;
|
|
230
232
|
}
|
|
231
233
|
/**
|
|
@@ -250,7 +252,7 @@ let thinkingPartCounter = 0;
|
|
|
250
252
|
export function generateThinkingPartId() {
|
|
251
253
|
const timestamp = Date.now().toString(16);
|
|
252
254
|
const counter = (thinkingPartCounter++).toString(36);
|
|
253
|
-
const random =
|
|
255
|
+
const random = randomBytes(3).toString("hex");
|
|
254
256
|
return `prt_0000000000_thinking_${timestamp}_${counter}_${random}`;
|
|
255
257
|
}
|
|
256
258
|
// =============================================================================
|