diff --git a/lib/auth/device-auth.ts b/lib/auth/device-auth.ts index 5ba8a77a..be257d56 100644 --- a/lib/auth/device-auth.ts +++ b/lib/auth/device-auth.ts @@ -5,12 +5,12 @@ import { sanitizeOAuthResponseBodyForLog, } from "./auth.js"; -export const DEVICE_AUTH_BASE_URL = "https://auth.openai.com"; -export const DEVICE_AUTH_API_BASE_URL = `${DEVICE_AUTH_BASE_URL}/api/accounts`; +const DEVICE_AUTH_BASE_URL = "https://auth.openai.com"; +const DEVICE_AUTH_API_BASE_URL = `${DEVICE_AUTH_BASE_URL}/api/accounts`; export const DEVICE_AUTH_VERIFICATION_URL = `${DEVICE_AUTH_BASE_URL}/codex/device`; export const DEVICE_AUTH_REDIRECT_URI = `${DEVICE_AUTH_BASE_URL}/deviceauth/callback`; -export const DEVICE_AUTH_TIMEOUT_MS = 15 * 60 * 1000; -export const DEVICE_AUTH_DEFAULT_INTERVAL_MS = 5_000; +const DEVICE_AUTH_TIMEOUT_MS = 15 * 60 * 1000; +const DEVICE_AUTH_DEFAULT_INTERVAL_MS = 5_000; const DEVICE_AUTH_ABORTED_MESSAGE = "aborted"; const DEVICE_AUTH_TRANSIENT_PENDING_STATUSES = new Set([ 408, @@ -407,7 +407,7 @@ export async function requestDeviceAuthorization( } } -export function printDeviceAuthorizationPrompt( +function printDeviceAuthorizationPrompt( deviceCode: DeviceAuthCode, log: (message: string) => void = console.log, timeoutMs = DEVICE_AUTH_TIMEOUT_MS, diff --git a/lib/codex-manager/backend-settings-helpers.ts b/lib/codex-manager/backend-settings-helpers.ts index 49ce5e71..6385cab2 100644 --- a/lib/codex-manager/backend-settings-helpers.ts +++ b/lib/codex-manager/backend-settings-helpers.ts @@ -61,7 +61,7 @@ export function formatBackendNumberValue( return `${Math.round(value)}ms`; } -export function clampBackendNumber( +function clampBackendNumber( option: BackendNumberSettingOption, value: number, ): number { diff --git a/lib/codex-manager/commands/uninstall.ts b/lib/codex-manager/commands/uninstall.ts index ebd746f5..b1497f3d 100644 --- a/lib/codex-manager/commands/uninstall.ts +++ b/lib/codex-manager/commands/uninstall.ts @@ -51,7 +51,7 @@ export type ParsedUninstallArgs = | { ok: false; reason: "help" } | { ok: false; reason: "error"; message: string }; -export function printUninstallUsage(): void { +function printUninstallUsage(): void { console.log( [ "Usage:", diff --git a/lib/codex-manager/forecast-report-shared.ts b/lib/codex-manager/forecast-report-shared.ts index 5e635019..3ef0e649 100644 --- a/lib/codex-manager/forecast-report-shared.ts +++ b/lib/codex-manager/forecast-report-shared.ts @@ -5,16 +5,13 @@ import { type AccountMetadataV3, type AccountStorageV3, } from "../storage.js"; -import { - isRetryableStorageWriteError, - saveAccountsWithRetry, -} from "../storage/save-retry.js"; +import { saveAccountsWithRetry } from "../storage/save-retry.js"; import type { TokenFailure } from "../types.js"; // Moved to lib/storage/save-retry.ts so lib/accounts.ts can use the retry // helper without importing this codex-manager module; re-exported here to // preserve the historical import surface. -export { isRetryableStorageWriteError, saveAccountsWithRetry }; +export { saveAccountsWithRetry }; export type AccountIdentityMatch = Pick< AccountMetadataV3, diff --git a/lib/codex-manager/formatters/quota-formatters.ts b/lib/codex-manager/formatters/quota-formatters.ts index 755a95ef..5899dff2 100644 --- a/lib/codex-manager/formatters/quota-formatters.ts +++ b/lib/codex-manager/formatters/quota-formatters.ts @@ -76,7 +76,7 @@ export function quotaCacheEntryToSnapshot( }; } -export function formatCompactQuotaWindowLabel( +function formatCompactQuotaWindowLabel( windowMinutes: number | undefined, ): string { if (!windowMinutes || !Number.isFinite(windowMinutes) || windowMinutes <= 0) { @@ -87,7 +87,7 @@ export function formatCompactQuotaWindowLabel( return `${windowMinutes}m`; } -export function formatCompactQuotaPart( +function formatCompactQuotaPart( windowMinutes: number | undefined, usedPercent: number | undefined, ): string | null { diff --git a/lib/codex-manager/repair-commands.ts b/lib/codex-manager/repair-commands.ts index 4cdeb3cc..3dfe62bb 100644 --- a/lib/codex-manager/repair-commands.ts +++ b/lib/codex-manager/repair-commands.ts @@ -132,7 +132,7 @@ export interface RepairCommandDeps { ) => boolean; } -export function printFixUsage(): void { +function printFixUsage(): void { console.log( [ "Usage:", @@ -152,7 +152,7 @@ export function printFixUsage(): void { ); } -export function printVerifyFlaggedUsage(): void { +function printVerifyFlaggedUsage(): void { console.log( [ "Usage:", @@ -170,7 +170,7 @@ export function printVerifyFlaggedUsage(): void { ); } -export function printDoctorUsage(): void { +function printDoctorUsage(): void { console.log( [ "Usage:", @@ -235,7 +235,7 @@ export function parseFixArgs(args: string[]): ParsedArgsResult { return { ok: true, options }; } -export function parseVerifyFlaggedArgs( +function parseVerifyFlaggedArgs( args: string[], ): ParsedArgsResult { const options: VerifyFlaggedCliOptions = { @@ -263,7 +263,7 @@ export function parseVerifyFlaggedArgs( return { ok: true, options }; } -export function parseDoctorArgs( +function parseDoctorArgs( args: string[], ): ParsedArgsResult { const options: DoctorCliOptions = { json: false, fix: false, dryRun: false }; diff --git a/lib/codex-manager/settings-hub/backend.ts b/lib/codex-manager/settings-hub/backend.ts index c7cb3639..aaab0835 100644 --- a/lib/codex-manager/settings-hub/backend.ts +++ b/lib/codex-manager/settings-hub/backend.ts @@ -37,7 +37,7 @@ import { } from "./shared.js"; /* c8 ignore start - interactive prompt flows are covered by integration tests */ -export async function promptBackendCategorySettings( +async function promptBackendCategorySettings( initial: PluginConfig, category: BackendCategoryOption, initialFocus: BackendSettingFocusKey, diff --git a/lib/codex-manager/settings-hub/dashboard.ts b/lib/codex-manager/settings-hub/dashboard.ts index 9406c1af..e894386b 100644 --- a/lib/codex-manager/settings-hub/dashboard.ts +++ b/lib/codex-manager/settings-hub/dashboard.ts @@ -42,7 +42,7 @@ import { resolveMenuLayoutMode, } from "./shared.js"; -export const DASHBOARD_DISPLAY_OPTIONS: DashboardDisplaySettingOption[] = [ +const DASHBOARD_DISPLAY_OPTIONS: DashboardDisplaySettingOption[] = [ { key: "menuShowStatusBadge", label: "Show Status Badges", @@ -95,7 +95,7 @@ export const DASHBOARD_DISPLAY_OPTIONS: DashboardDisplaySettingOption[] = [ }, ]; -export const STATUSLINE_FIELD_OPTIONS: Array<{ +const STATUSLINE_FIELD_OPTIONS: Array<{ key: DashboardStatuslineField; label: string; description: string; @@ -117,21 +117,21 @@ export const STATUSLINE_FIELD_OPTIONS: Array<{ }, ]; -export const AUTO_RETURN_OPTIONS_MS = [1_000, 2_000, 4_000] as const; -export const MENU_QUOTA_TTL_OPTIONS_MS = [ +const AUTO_RETURN_OPTIONS_MS = [1_000, 2_000, 4_000] as const; +const MENU_QUOTA_TTL_OPTIONS_MS = [ 60_000, 5 * 60_000, 10 * 60_000, ] as const; -export const THEME_PRESET_OPTIONS: DashboardThemePreset[] = ["green", "blue"]; -export const ACCENT_COLOR_OPTIONS: DashboardAccentColor[] = [ +const THEME_PRESET_OPTIONS: DashboardThemePreset[] = ["green", "blue"]; +const ACCENT_COLOR_OPTIONS: DashboardAccentColor[] = [ "green", "cyan", "blue", "yellow", ]; -export const ACCOUNT_LIST_PANEL_KEYS = [ +const ACCOUNT_LIST_PANEL_KEYS = [ "menuShowStatusBadge", "menuShowCurrentBadge", "menuShowLastUsed", @@ -147,7 +147,7 @@ export const ACCOUNT_LIST_PANEL_KEYS = [ "menuLayoutMode", ] as const satisfies readonly DashboardSettingKey[]; -export const STATUSLINE_PANEL_KEYS = [ +const STATUSLINE_PANEL_KEYS = [ "menuStatuslineFields", ] as const satisfies readonly DashboardSettingKey[]; export const BEHAVIOR_PANEL_KEYS = [ diff --git a/lib/codex-manager/settings-hub/shared.ts b/lib/codex-manager/settings-hub/shared.ts index be23e567..b93d6b6d 100644 --- a/lib/codex-manager/settings-hub/shared.ts +++ b/lib/codex-manager/settings-hub/shared.ts @@ -47,7 +47,7 @@ export function isTtyInteractive(): boolean { return Boolean(input.isTTY && output.isTTY); } -export function copyDashboardSettingValue( +function copyDashboardSettingValue( target: DashboardDisplaySettings, source: DashboardDisplaySettings, key: DashboardSettingKey, @@ -70,7 +70,7 @@ export function applyDashboardDefaultsForKeys( return next; } -export function mergeDashboardSettingsForKeys( +function mergeDashboardSettingsForKeys( base: DashboardDisplaySettings, selected: DashboardDisplaySettings, keys: readonly DashboardSettingKey[], diff --git a/lib/codex-manager/settings-preview.ts b/lib/codex-manager/settings-preview.ts index 308bc573..cdcdd085 100644 --- a/lib/codex-manager/settings-preview.ts +++ b/lib/codex-manager/settings-preview.ts @@ -6,7 +6,7 @@ import type { import { ANSI } from "../ui/ansi.js"; import type { UiRuntimeOptions } from "../ui/runtime.js"; -export const DEFAULT_STATUSLINE_FIELDS: DashboardStatuslineField[] = [ +const DEFAULT_STATUSLINE_FIELDS: DashboardStatuslineField[] = [ "last-used", "limits", "status", diff --git a/lib/codex-manager/settings-write-queue.ts b/lib/codex-manager/settings-write-queue.ts index 26cb5348..8b81df95 100644 --- a/lib/codex-manager/settings-write-queue.ts +++ b/lib/codex-manager/settings-write-queue.ts @@ -1,7 +1,7 @@ -export const SETTINGS_WRITE_MAX_ATTEMPTS = 4; -export const SETTINGS_WRITE_BASE_DELAY_MS = 50; -export const SETTINGS_WRITE_MAX_DELAY_MS = 30_000; -export const RETRYABLE_SETTINGS_WRITE_CODES = new Set([ +const SETTINGS_WRITE_MAX_ATTEMPTS = 4; +const SETTINGS_WRITE_BASE_DELAY_MS = 50; +const SETTINGS_WRITE_MAX_DELAY_MS = 30_000; +const RETRYABLE_SETTINGS_WRITE_CODES = new Set([ "EBUSY", "EPERM", "EAGAIN", @@ -11,7 +11,7 @@ export const RETRYABLE_SETTINGS_WRITE_CODES = new Set([ const settingsWriteQueues = new Map>(); -export function readErrorNumber(value: unknown): number | undefined { +function readErrorNumber(value: unknown): number | undefined { if (typeof value === "number" && Number.isFinite(value)) return value; if (typeof value === "string" && value.trim().length > 0) { const parsed = Number.parseInt(value, 10); @@ -20,13 +20,13 @@ export function readErrorNumber(value: unknown): number | undefined { return undefined; } -export function getErrorStatusCode(error: unknown): number | undefined { +function getErrorStatusCode(error: unknown): number | undefined { if (!error || typeof error !== "object") return undefined; const record = error as Record; return readErrorNumber(record.status) ?? readErrorNumber(record.statusCode); } -export function getRetryAfterMs(error: unknown): number | undefined { +function getRetryAfterMs(error: unknown): number | undefined { if (!error || typeof error !== "object") return undefined; const record = error as Record; return ( @@ -37,14 +37,14 @@ export function getRetryAfterMs(error: unknown): number | undefined { ); } -export function isRetryableSettingsWriteError(error: unknown): boolean { +function isRetryableSettingsWriteError(error: unknown): boolean { const statusCode = getErrorStatusCode(error); if (statusCode === 429) return true; const code = (error as NodeJS.ErrnoException | undefined)?.code; return typeof code === "string" && RETRYABLE_SETTINGS_WRITE_CODES.has(code); } -export function resolveRetryDelayMs(error: unknown, attempt: number): number { +function resolveRetryDelayMs(error: unknown, attempt: number): number { const retryAfterMs = getRetryAfterMs(error); if ( typeof retryAfterMs === "number" && @@ -62,7 +62,7 @@ export function resolveRetryDelayMs(error: unknown, attempt: number): number { ); } -export async function enqueueSettingsWrite( +async function enqueueSettingsWrite( pathKey: string, task: () => Promise, ): Promise { diff --git a/lib/dashboard-settings.ts b/lib/dashboard-settings.ts index d4dbdb1a..32841501 100644 --- a/lib/dashboard-settings.ts +++ b/lib/dashboard-settings.ts @@ -46,8 +46,6 @@ export interface DashboardDisplaySettings { export type DashboardStatuslineField = "last-used" | "limits" | "status"; -export const DASHBOARD_DISPLAY_SETTINGS_VERSION = 1 as const; - export const DEFAULT_DASHBOARD_DISPLAY_SETTINGS: DashboardDisplaySettings = { showPerAccountRows: true, showQuotaDetails: true, diff --git a/lib/fs-retry.ts b/lib/fs-retry.ts index 5856be5a..79940ffb 100644 --- a/lib/fs-retry.ts +++ b/lib/fs-retry.ts @@ -5,9 +5,9 @@ export const FILE_RETRY_CODES = new Set([ "ENOTEMPTY", "EACCES", ]); -export const FILE_RETRY_MAX_ATTEMPTS = 6; -export const FILE_RETRY_BASE_DELAY_MS = 25; -export const FILE_RETRY_JITTER_MS = 20; +const FILE_RETRY_MAX_ATTEMPTS = 6; +const FILE_RETRY_BASE_DELAY_MS = 25; +const FILE_RETRY_JITTER_MS = 20; function sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); diff --git a/lib/prompts/codex-host-bridge.ts b/lib/prompts/codex-host-bridge.ts index 19556893..8c829722 100644 --- a/lib/prompts/codex-host-bridge.ts +++ b/lib/prompts/codex-host-bridge.ts @@ -147,33 +147,3 @@ Sandbox policies, approval mechanisms, final answer formatting, git commit proto - Never run \`git reset --hard\`, \`git checkout --\`, or force deletes unless the user explicitly asked for that exact action. - \`request_user_input\` is Plan-mode only; do not call it in Default mode. - When uncertain, prefer non-destructive verification first (e.g., confirm file existence with \`list\`, then delete with \`bash\`).`; - -export interface CodexHostBridgeMeta { - estimatedTokens: number; - reductionVsCurrent: string; - reductionVsToolRemap: string; - protects: string[]; - omits: string[]; -} - -export const CODEX_HOST_BRIDGE_META: CodexHostBridgeMeta = { - estimatedTokens: 550, - reductionVsCurrent: "88%", - reductionVsToolRemap: "10%", - protects: [ - "Tool name confusion (update_plan)", - "Missing tool awareness", - "Task tool / sub-agent awareness", - "MCP tool awareness", - "Premature yielding to user", - "Over-modification of existing code", - "Environment confusion", - ], - omits: [ - "Sandbox details (in Codex)", - "Formatting rules (in Codex)", - "Tool schemas (in tool JSONs)", - "Git protocols (in Codex)", - ], -}; - diff --git a/lib/prompts/fetch-utils.ts b/lib/prompts/fetch-utils.ts index 993cb2d8..9184898b 100644 --- a/lib/prompts/fetch-utils.ts +++ b/lib/prompts/fetch-utils.ts @@ -14,9 +14,9 @@ * Accept, applied to every request (prompts-08) */ -export const PROMPT_FETCH_TIMEOUT_MS = 10_000; +const PROMPT_FETCH_TIMEOUT_MS = 10_000; export const PROMPT_FETCH_MAX_BYTES = 1_000_000; // 1 MB ceiling for a prompt body -export const PROMPT_FETCH_USER_AGENT = "codex-multi-auth"; +const PROMPT_FETCH_USER_AGENT = "codex-multi-auth"; export interface PromptFetchOptions { headers?: Record; diff --git a/lib/rotation.ts b/lib/rotation.ts index 50aae032..4308d35b 100644 --- a/lib/rotation.ts +++ b/lib/rotation.ts @@ -17,11 +17,6 @@ export type { RoutingMutexMode, AsyncMutex, } from "./routing-mutex.js"; -export { - createAsyncMutex, - getRoutingMutex, - withRoutingMutex, -} from "./routing-mutex.js"; const log = createLogger("rotation"); @@ -389,7 +384,7 @@ export interface HybridSelectionConfig { freshnessWeight: number; } -export const DEFAULT_HYBRID_SELECTION_CONFIG: HybridSelectionConfig = { +const DEFAULT_HYBRID_SELECTION_CONFIG: HybridSelectionConfig = { healthWeight: 2, tokenWeight: 5, freshnessWeight: 2.0, diff --git a/lib/runtime/config-toml.ts b/lib/runtime/config-toml.ts index 5390b584..5e88652b 100644 --- a/lib/runtime/config-toml.ts +++ b/lib/runtime/config-toml.ts @@ -23,12 +23,12 @@ export function tomlStringLiteral(value: string): string { })}"`; } -export function readTomlTableName(line: string): string | null { +function readTomlTableName(line: string): string | null { const match = /^\s*\[{1,2}\s*([^\]]+?)\s*\]{1,2}\s*$/.exec(line); return match?.[1]?.trim() ?? null; } -export function removeRuntimeRotationProviderBlock(rawConfig: string): string { +function removeRuntimeRotationProviderBlock(rawConfig: string): string { const lines = rawConfig.split(/\r?\n/); const output: string[] = []; let skipping = false; @@ -50,7 +50,7 @@ export function removeRuntimeRotationProviderBlock(rawConfig: string): string { return output.join(rawConfig.includes("\r\n") ? "\r\n" : "\n"); } -export function rewriteTopLevelModelProvider(rawConfig: string): string { +function rewriteTopLevelModelProvider(rawConfig: string): string { const lineEnding = rawConfig.includes("\r\n") ? "\r\n" : "\n"; const lines = rawConfig.length > 0 ? rawConfig.split(/\r?\n/) : []; const rewrittenLine = `model_provider = ${tomlStringLiteral(RUNTIME_ROTATION_PROXY_PROVIDER_ID)}`; @@ -75,7 +75,7 @@ export function rewriteTopLevelModelProvider(rawConfig: string): string { return output.join(lineEnding); } -export function enableTopLevelResponseStorage(rawConfig: string): string { +function enableTopLevelResponseStorage(rawConfig: string): string { const lineEnding = rawConfig.includes("\r\n") ? "\r\n" : "\n"; const lines = rawConfig.length > 0 ? rawConfig.split(/\r?\n/) : []; const output: string[] = []; @@ -206,11 +206,11 @@ export function restoreTopLevelResponseStorage( return output.join(lineEnding); } -export function ensureTomlTrailingNewline(value: string): string { +function ensureTomlTrailingNewline(value: string): string { return value.replace(/[\r\n]*$/, "\n"); } -export function createRuntimeRotationProviderBlock( +function createRuntimeRotationProviderBlock( baseUrl: string, clientApiKey = "", ): string[] { diff --git a/lib/runtime/event-handler.ts b/lib/runtime/event-handler.ts index c81ac6a5..d54b5b87 100644 --- a/lib/runtime/event-handler.ts +++ b/lib/runtime/event-handler.ts @@ -2,62 +2,6 @@ import type { ModelFamily } from "../prompts/codex.js"; import type { AccountStorageV3 } from "../storage.js"; import { handleAccountSelectEvent } from "./account-select-event.js"; -export function createRuntimeEventHandler< - TLoadedStorage, - TSavedStorage, - TModelFamily extends string, - TManager, ->(deps: { - handleAccountSelectEvent: (input: { - event: { type: string; properties?: unknown }; - providerId: string; - loadAccounts: () => Promise; - saveAccounts: (storage: TSavedStorage) => Promise; - modelFamilies: readonly TModelFamily[]; - cachedAccountManager: TManager; - reloadAccountManagerFromDisk: () => Promise; - setLastCodexCliActiveSyncIndex: (index: number) => void; - showToast: ( - message: string, - variant?: "info" | "success" | "warning" | "error", - ) => Promise; - }) => Promise; - providerId: string; - loadAccounts: () => Promise; - saveAccounts: (storage: TSavedStorage) => Promise; - modelFamilies: readonly TModelFamily[]; - getCachedAccountManager: () => TManager; - reloadAccountManagerFromDisk: () => Promise; - setLastCodexCliActiveSyncIndex: (index: number) => void; - showToast: ( - message: string, - variant?: "info" | "success" | "warning" | "error", - ) => Promise; - logDebug: (message: string) => void; - pluginName: string; -}) { - return async (input: { event: { type: string; properties?: unknown } }) => { - try { - const handled = await deps.handleAccountSelectEvent({ - event: input.event, - providerId: deps.providerId, - loadAccounts: deps.loadAccounts, - saveAccounts: deps.saveAccounts, - modelFamilies: deps.modelFamilies, - cachedAccountManager: deps.getCachedAccountManager(), - reloadAccountManagerFromDisk: deps.reloadAccountManagerFromDisk, - setLastCodexCliActiveSyncIndex: deps.setLastCodexCliActiveSyncIndex, - showToast: deps.showToast, - }); - if (handled) return; - } catch (error) { - deps.logDebug( - `[${deps.pluginName}] Event handler error: ${error instanceof Error ? error.message : String(error)}`, - ); - } - }; -} - export async function handleRuntimeEvent(params: { input: { event: { type: string; properties?: unknown } }; providerId: string; diff --git a/lib/runtime/first-run.ts b/lib/runtime/first-run.ts index 235ddb47..eb3285b4 100644 --- a/lib/runtime/first-run.ts +++ b/lib/runtime/first-run.ts @@ -73,7 +73,7 @@ export interface FirstRunSetupDeps { now?: () => number; } -export function readOptionalBoolean(value: string | undefined): boolean | null { +function readOptionalBoolean(value: string | undefined): boolean | null { if (value === undefined || value.trim().length === 0) return null; const normalized = value.trim().toLowerCase(); if (TRUE_VALUES.has(normalized)) return true; @@ -233,7 +233,7 @@ export function isInstalledPackageContext( return true; } -export function getFirstRunMarkerPath(): string { +function getFirstRunMarkerPath(): string { return join(getCodexMultiAuthDir(), FIRST_RUN_MARKER_FILE); } diff --git a/lib/runtime/quota-headers.ts b/lib/runtime/quota-headers.ts index 395b3ce4..5724f078 100644 --- a/lib/runtime/quota-headers.ts +++ b/lib/runtime/quota-headers.ts @@ -4,7 +4,7 @@ export type { CodexQuotaSnapshot, CodexQuotaWindow } from "../quota-probe.js"; export type ParsedCodexQuotaSnapshot = Omit; -export function parseFiniteNumberHeader( +function parseFiniteNumberHeader( headers: Headers, name: string, ): number | undefined { @@ -14,7 +14,7 @@ export function parseFiniteNumberHeader( return Number.isFinite(parsed) ? parsed : undefined; } -export function parseFiniteIntHeader( +function parseFiniteIntHeader( headers: Headers, name: string, ): number | undefined { @@ -55,7 +55,7 @@ export function parseResetAtMs( return Number.isFinite(parsedDate) ? parsedDate : undefined; } -export function hasCodexQuotaHeaders(headers: Headers): boolean { +function hasCodexQuotaHeaders(headers: Headers): boolean { const keys = [ "x-codex-primary-used-percent", "x-codex-primary-window-minutes", @@ -108,7 +108,7 @@ export function parseCodexQuotaSnapshot( return { status, planType, activeLimit, primary, secondary }; } -export function formatQuotaWindowLabel( +function formatQuotaWindowLabel( windowMinutes: number | undefined, ): string { if (!windowMinutes || !Number.isFinite(windowMinutes) || windowMinutes <= 0) { @@ -119,7 +119,7 @@ export function formatQuotaWindowLabel( return `${windowMinutes}m`; } -export function formatResetAt( +function formatResetAt( resetAtMs: number | undefined, ): string | undefined { if (!resetAtMs || !Number.isFinite(resetAtMs) || resetAtMs <= 0) diff --git a/lib/runtime/runtime-current-account.ts b/lib/runtime/runtime-current-account.ts index ee338549..0b007461 100644 --- a/lib/runtime/runtime-current-account.ts +++ b/lib/runtime/runtime-current-account.ts @@ -48,7 +48,7 @@ export interface RuntimeCurrentAccountSources { appHelperStatus?: RuntimeAccountSignal | null; } -export const RUNTIME_CURRENT_ACCOUNT_MAX_AGE_MS = 24 * 60 * 60 * 1000; +const RUNTIME_CURRENT_ACCOUNT_MAX_AGE_MS = 24 * 60 * 60 * 1000; const APP_RUNTIME_HELPER_KIND = "codex-app-runtime-rotation-helper"; const MAX_STATUS_FILE_BYTES = 1024 * 1024; // 1 MB sanity cap diff --git a/lib/runtime/runtime-observability.ts b/lib/runtime/runtime-observability.ts index 7dda5dd4..e5458ced 100644 --- a/lib/runtime/runtime-observability.ts +++ b/lib/runtime/runtime-observability.ts @@ -344,7 +344,3 @@ export async function loadPersistedRuntimeObservabilitySnapshot(): Promise; /** * Source of the accountId used for ChatGPT requests. */ -export const AccountIdSourceSchema = z.enum([ +const AccountIdSourceSchema = z.enum([ "token", "id_token", "org", @@ -102,7 +102,7 @@ export type AccountIdSourceFromSchema = z.infer; /** * Cooldown reason for temporary account suspension. */ -export const CooldownReasonSchema = z.enum([ +const CooldownReasonSchema = z.enum([ "auth-failure", "network-error", "server-error", @@ -114,7 +114,7 @@ export type CooldownReasonFromSchema = z.infer; /** * Last switch reason for account rotation tracking. */ -export const SwitchReasonSchema = z.enum([ +const SwitchReasonSchema = z.enum([ "rate-limit", "initial", "rotation", @@ -142,7 +142,7 @@ export type PersistedSwitchReason = z.infer; /** * Rate limit state - maps model family to reset timestamp. */ -export const RateLimitStateV3Schema = z.record( +const RateLimitStateV3Schema = z.record( z.string(), z.number().optional(), ); @@ -155,7 +155,7 @@ export type RateLimitStateV3FromSchema = z.infer; * business/team workspace), each a distinct quota pool keyed by its org_id * (`id`). Mirrors the `Workspace` TS interface in `lib/accounts.ts`. See #491. */ -export const WorkspaceSchema = z.object({ +const WorkspaceSchema = z.object({ id: z.string(), name: z.string().optional(), enabled: z.boolean(), @@ -201,7 +201,7 @@ const modelFamilyEntries = MODEL_FAMILIES.map((family) => [ family, z.number().optional(), ]); -export const ActiveIndexByFamilySchema = z +const ActiveIndexByFamilySchema = z .object( Object.fromEntries(modelFamilyEntries) as Record< ModelFamily, @@ -231,7 +231,7 @@ export type AccountStorageV3FromSchema = z.infer; /** * Legacy V1 account metadata for migration support. */ -export const AccountMetadataV1Schema = z.object({ +const AccountMetadataV1Schema = z.object({ accountId: z.string().optional(), accountIdSource: AccountIdSourceSchema.optional(), accountLabel: z.string().optional(), @@ -334,7 +334,7 @@ export type AccountsJournalEntryFromSchema = z.infer< /** * Token failure reason codes. */ -export const TokenFailureReasonSchema = z.enum([ +const TokenFailureReasonSchema = z.enum([ "http_error", "invalid_response", "network_error", diff --git a/lib/storage/file-paths.ts b/lib/storage/file-paths.ts index 393a2cf3..0a210286 100644 --- a/lib/storage/file-paths.ts +++ b/lib/storage/file-paths.ts @@ -3,7 +3,6 @@ import { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, - getAccountsBackupPathAtIndex, getAccountsBackupRecoveryCandidates as getBackupRecoveryCandidates, getAccountsWalPath, getIntentionalResetMarkerPath, @@ -16,7 +15,6 @@ export { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, - getAccountsBackupPathAtIndex, getAccountsWalPath, getIntentionalResetMarkerPath, RESET_MARKER_SUFFIX, diff --git a/lib/storage/save-retry.ts b/lib/storage/save-retry.ts index 43a7291f..242c7925 100644 --- a/lib/storage/save-retry.ts +++ b/lib/storage/save-retry.ts @@ -10,7 +10,7 @@ import type { AccountStorageV3 } from "./public-types.js"; const RETRYABLE_STORAGE_WRITE_CODES = new Set(["EBUSY", "EPERM"]); -export function isRetryableStorageWriteError(error: unknown): boolean { +function isRetryableStorageWriteError(error: unknown): boolean { const code = (error as NodeJS.ErrnoException | undefined)?.code; return typeof code === "string" && RETRYABLE_STORAGE_WRITE_CODES.has(code); } diff --git a/scripts/bench-format/hashline-v2.mjs b/scripts/bench-format/hashline-v2.mjs index 05cbc5e8..c598f001 100644 --- a/scripts/bench-format/hashline-v2.mjs +++ b/scripts/bench-format/hashline-v2.mjs @@ -11,7 +11,7 @@ function normalizeLineForHash(line) { return value.replace(/\s+/g, ""); } -export function computeHashlineV2Hash(line) { +function computeHashlineV2Hash(line) { const normalized = normalizeLineForHash(line); const digest = createHash("sha1").update(normalized, "utf8").digest(); const raw = (digest.readUInt32BE(0) % 46656).toString(36); diff --git a/scripts/bench-format/models.mjs b/scripts/bench-format/models.mjs index af63e5ef..d8265cc1 100644 --- a/scripts/bench-format/models.mjs +++ b/scripts/bench-format/models.mjs @@ -10,16 +10,16 @@ const FALLBACK_OPENAI_CODEX_STABLE = [ const OPENAI_CODEX_PREFIXES = ["openai/", "openai-multi/"]; -export function isOpenAiCodexProviderPrefix(modelId) { +function isOpenAiCodexProviderPrefix(modelId) { return OPENAI_CODEX_PREFIXES.some((prefix) => modelId.startsWith(prefix)); } -export function codexTail(modelId) { +function codexTail(modelId) { const slash = modelId.indexOf("/"); return slash >= 0 ? modelId.slice(slash + 1) : modelId; } -export function canonicalCodexModelId(modelId) { +function canonicalCodexModelId(modelId) { return `openai/${codexTail(modelId)}`; } @@ -32,7 +32,7 @@ export function aliasCandidatesForCodexModel(modelId) { return [...new Set([tail, modelId, ...candidates])]; } -export function isStableOpenAiCodexModel(modelId) { +function isStableOpenAiCodexModel(modelId) { if (!isOpenAiCodexProviderPrefix(modelId)) { return false; } diff --git a/scripts/bench-format/stats.mjs b/scripts/bench-format/stats.mjs index f25c702d..9cfd36f4 100644 --- a/scripts/bench-format/stats.mjs +++ b/scripts/bench-format/stats.mjs @@ -1,4 +1,4 @@ -export function percentile(values, p) { +function percentile(values, p) { if (!Array.isArray(values) || values.length === 0) { return null; } diff --git a/test/property/helpers.ts b/test/property/helpers.ts index 0a2170b7..565803f6 100644 --- a/test/property/helpers.ts +++ b/test/property/helpers.ts @@ -4,7 +4,7 @@ export const arbAccountIndex = fc.integer({ min: 0, max: 19 }); export const arbHealthScore = fc.integer({ min: 0, max: 100 }); -export const arbTimestamp = fc.integer({ min: 0, max: Date.now() + 86400000 }); +const arbTimestamp = fc.integer({ min: 0, max: Date.now() + 86400000 }); export const arbQuotaKey = fc.oneof( fc.constant(undefined), @@ -18,32 +18,6 @@ export const arbQuotaKey = fc.oneof( ) ); -export const arbTokenBucketState = fc.record({ - tokens: fc.integer({ min: 0, max: 50 }), - lastRefill: arbTimestamp, - maxTokens: fc.integer({ min: 10, max: 100 }), - refillRate: fc.integer({ min: 1, max: 10 }), -}); - -export const arbHealthEntry = fc.record({ - score: arbHealthScore, - lastUpdated: arbTimestamp, - consecutiveFailures: fc.integer({ min: 0, max: 10 }), -}); - -export const arbAccountId = fc.uuid(); - -export const arbEmail = fc.emailAddress(); - -export const arbReasoningEffort = fc.constantFrom( - "none", - "minimal", - "low", - "medium", - "high", - "xhigh" -); - export const arbModel = fc.constantFrom( "gpt-5.5", "gpt-5.4", @@ -58,7 +32,7 @@ export const arbModel = fc.constantFrom( export const arbMessageRole = fc.constantFrom("user", "assistant", "system"); -export const arbMessageContent = fc.oneof( +const arbMessageContent = fc.oneof( fc.string({ minLength: 0, maxLength: 1000 }), fc.array( fc.record({ @@ -69,46 +43,9 @@ export const arbMessageContent = fc.oneof( ) ); -export const arbInputItem = fc.record({ +const arbInputItem = fc.record({ id: fc.option(fc.uuid(), { nil: undefined }), type: fc.constant("message"), role: arbMessageRole, content: arbMessageContent, }); - -export const arbRequestBody = fc.record({ - model: arbModel, - store: fc.option(fc.boolean(), { nil: undefined }), - stream: fc.option(fc.boolean(), { nil: undefined }), - instructions: fc.option(fc.string({ minLength: 0, maxLength: 500 }), { - nil: undefined, - }), - input: fc.array(arbInputItem, { minLength: 0, maxLength: 10 }), -}); - -export const arbPositiveInteger = fc.integer({ min: 1, max: 1000000 }); - -export const arbNonNegativeInteger = fc.integer({ min: 0, max: 1000000 }); - -export function arbArrayOfN(arb: fc.Arbitrary, n: number): fc.Arbitrary { - return fc.array(arb, { minLength: n, maxLength: n }); -} - -export const arbHttpStatusCode = fc.oneof( - fc.constantFrom(200, 201, 204), - fc.constantFrom(400, 401, 403, 404, 422, 429), - fc.constantFrom(500, 502, 503, 504) -); - -export const arbRateLimitHeaders = fc.record({ - "x-ratelimit-limit-requests": fc.option(fc.nat({ max: 1000 }).map(String), { - nil: undefined, - }), - "x-ratelimit-remaining-requests": fc.option(fc.nat({ max: 1000 }).map(String), { - nil: undefined, - }), - "x-ratelimit-reset-requests": fc.option( - fc.integer({ min: 1, max: 3600 }).map((s) => `${s}s`), - { nil: undefined } - ), -});