Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/auth/device-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/codex-manager/backend-settings-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function formatBackendNumberValue(
return `${Math.round(value)}ms`;
}

export function clampBackendNumber(
function clampBackendNumber(
option: BackendNumberSettingOption,
value: number,
): number {
Expand Down
2 changes: 1 addition & 1 deletion lib/codex-manager/commands/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down
7 changes: 2 additions & 5 deletions lib/codex-manager/forecast-report-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/codex-manager/formatters/quota-formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function quotaCacheEntryToSnapshot(
};
}

export function formatCompactQuotaWindowLabel(
function formatCompactQuotaWindowLabel(
windowMinutes: number | undefined,
): string {
if (!windowMinutes || !Number.isFinite(windowMinutes) || windowMinutes <= 0) {
Expand All @@ -87,7 +87,7 @@ export function formatCompactQuotaWindowLabel(
return `${windowMinutes}m`;
}

export function formatCompactQuotaPart(
function formatCompactQuotaPart(
windowMinutes: number | undefined,
usedPercent: number | undefined,
): string | null {
Expand Down
10 changes: 5 additions & 5 deletions lib/codex-manager/repair-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export interface RepairCommandDeps {
) => boolean;
}

export function printFixUsage(): void {
function printFixUsage(): void {
console.log(
[
"Usage:",
Expand All @@ -152,7 +152,7 @@ export function printFixUsage(): void {
);
}

export function printVerifyFlaggedUsage(): void {
function printVerifyFlaggedUsage(): void {
console.log(
[
"Usage:",
Expand All @@ -170,7 +170,7 @@ export function printVerifyFlaggedUsage(): void {
);
}

export function printDoctorUsage(): void {
function printDoctorUsage(): void {
console.log(
[
"Usage:",
Expand Down Expand Up @@ -235,7 +235,7 @@ export function parseFixArgs(args: string[]): ParsedArgsResult<FixCliOptions> {
return { ok: true, options };
}

export function parseVerifyFlaggedArgs(
function parseVerifyFlaggedArgs(
args: string[],
): ParsedArgsResult<VerifyFlaggedCliOptions> {
const options: VerifyFlaggedCliOptions = {
Expand Down Expand Up @@ -263,7 +263,7 @@ export function parseVerifyFlaggedArgs(
return { ok: true, options };
}

export function parseDoctorArgs(
function parseDoctorArgs(
args: string[],
): ParsedArgsResult<DoctorCliOptions> {
const options: DoctorCliOptions = { json: false, fix: false, dryRun: false };
Expand Down
2 changes: 1 addition & 1 deletion lib/codex-manager/settings-hub/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions lib/codex-manager/settings-hub/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand All @@ -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",
Expand All @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions lib/codex-manager/settings-hub/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -70,7 +70,7 @@ export function applyDashboardDefaultsForKeys(
return next;
}

export function mergeDashboardSettingsForKeys(
function mergeDashboardSettingsForKeys(
base: DashboardDisplaySettings,
selected: DashboardDisplaySettings,
keys: readonly DashboardSettingKey[],
Expand Down
2 changes: 1 addition & 1 deletion lib/codex-manager/settings-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 10 additions & 10 deletions lib/codex-manager/settings-write-queue.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -11,7 +11,7 @@ export const RETRYABLE_SETTINGS_WRITE_CODES = new Set([

const settingsWriteQueues = new Map<string, Promise<void>>();

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);
Expand All @@ -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<string, unknown>;
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<string, unknown>;
return (
Expand All @@ -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" &&
Expand All @@ -62,7 +62,7 @@ export function resolveRetryDelayMs(error: unknown, attempt: number): number {
);
}

export async function enqueueSettingsWrite<T>(
async function enqueueSettingsWrite<T>(
pathKey: string,
task: () => Promise<T>,
): Promise<T> {
Expand Down
2 changes: 0 additions & 2 deletions lib/dashboard-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions lib/fs-retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
Expand Down
30 changes: 0 additions & 30 deletions lib/prompts/codex-host-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
],
};

4 changes: 2 additions & 2 deletions lib/prompts/fetch-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>;
Expand Down
7 changes: 1 addition & 6 deletions lib/rotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ export type {
RoutingMutexMode,
AsyncMutex,
} from "./routing-mutex.js";
export {
createAsyncMutex,
getRoutingMutex,
withRoutingMutex,
} from "./routing-mutex.js";

const log = createLogger("rotation");

Expand Down Expand Up @@ -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,
Expand Down
Loading