fix: stabilize sub2api codex pool operations

This commit is contained in:
Codex
2026-07-01 15:52:22 +00:00
parent 8f54b591d7
commit 113b6809d1
16 changed files with 509 additions and 59 deletions
@@ -21,7 +21,7 @@ import {
import { parseEnvFile, readTextFile, redactRepoPath, requiredEnvValue } from "../secrets";
import { runSshCommandCapture, type SshCaptureResult } from "../ssh";
import type { CodexPoolConfig, CodexPoolManualAccountGroupBinding, CodexPoolManualAccountProxyBinding, CodexPoolManualBindingSource, CodexPoolRuntimeTarget, CodexProfile } from "./types";
import type { CodexPoolConfig, CodexPoolManualAccountGroupBinding, CodexPoolManualAccountProtection, CodexPoolManualAccountProxyBinding, CodexPoolManualBindingSource, CodexPoolRuntimeTarget, CodexProfile } from "./types";
import { desiredAccountCapacityTotal } from "./accounts";
import { readCodexPoolConfig } from "./config";
import { codexConsumerBaseUrl } from "./local-codex";
@@ -47,6 +47,7 @@ export function poolTarget(pool = readCodexPoolConfig(), target = codexPoolRunti
source: `${sub2apiConfigPath}.targets[${target.id}].codexPool.sentinelImageBuild`,
baseImageCachePolicy: target.sentinelImageBuild.baseImageCachePolicy,
noProxy: target.sentinelImageBuild.noProxy,
proxyEnvPath: target.sentinelImageBuild.proxyEnvPath,
},
minOwnerConcurrency: pool.minOwnerConcurrency,
minOwnerConcurrencySource: pool.minOwnerConcurrencySource,
@@ -88,14 +89,26 @@ export function sentinelProfileSecrets(profiles: CodexProfile[]): CodexPoolSenti
}
export function resolvedManualAccountProtections(pool: CodexPoolConfig, target: CodexPoolRuntimeTarget): Record<string, unknown>[] {
return pool.manualAccounts.protected.map((account) => ({
return protectedManualAccountsForTarget(pool, target).map((account) => ({
accountName: account.accountName,
reason: account.reason,
targetIds: account.targetIds,
proxyBinding: resolveManualProxyBinding(account.proxyBinding, pool, target),
groupBinding: resolveManualGroupBinding(account.groupBinding, pool),
}));
}
export function protectedManualAccountsForTarget(pool: CodexPoolConfig, target: CodexPoolRuntimeTarget): CodexPoolManualAccountProtection[] {
return pool.manualAccounts.protected.filter((account) => (
account.targetIds === null
|| account.targetIds.some((id) => id.toLowerCase() === target.id.toLowerCase())
));
}
export function protectedManualAccountNamesForTarget(pool: CodexPoolConfig, target: CodexPoolRuntimeTarget): string[] {
return protectedManualAccountsForTarget(pool, target).map((account) => account.accountName);
}
export function resolveManualProxyBinding(binding: CodexPoolManualAccountProxyBinding | null, pool: CodexPoolConfig, target: CodexPoolRuntimeTarget): Record<string, unknown> | null {
if (binding === null) return null;
const source = manualBindingSource(pool, binding.source);