fix: support PK01 Codex pool sync

This commit is contained in:
Codex
2026-07-02 02:43:01 +00:00
parent 18b6b93390
commit 3a8681f458
11 changed files with 258 additions and 48 deletions
@@ -59,7 +59,9 @@ export function codexPoolPlan(options?: DisclosureOptions): Record<string, unkno
decision: {
accountType: "openai/apikey",
grouping: `All discovered Codex profiles are bound to one Sub2API group named ${pool.groupName}.`,
unifiedApiKey: `The client-facing API_KEY is controlled by k3s Secret ${runtimeTarget.namespace}/${pool.apiKeySecretName}.${pool.apiKeySecretKey}.`,
unifiedApiKey: runtimeTarget.runtimeMode === "host-docker"
? `The client-facing API_KEY is controlled by host-Docker env source ${runtimeTarget.hostDockerEnvPath}.${pool.apiKeySecretKey}.`
: `The client-facing API_KEY is controlled by k3s Secret ${runtimeTarget.namespace}/${pool.apiKeySecretName}.${pool.apiKeySecretKey}.`,
sentinel: pool.sentinel.monitor.enabled
? `Account sentinel is enabled as k8s CronJob ${runtimeTarget.namespace}/${pool.sentinel.cronJobName}; actions.enabled=${pool.sentinel.actions.enabled}.`
: "Account sentinel monitoring is disabled by YAML.",
@@ -73,13 +75,7 @@ export function codexPoolPlan(options?: DisclosureOptions): Record<string, unkno
: `${pool.manualAccounts.protected.length} manual Sub2API account(s) are protected from UniDesk-managed credentials, prune, sentinel probe, and sentinel freeze paths; only explicitly declared proxy/group bindings are reconciled.`,
},
next: ok
? runtimeTarget.runtimeMode === "host-docker"
? {
expose: `bun scripts/cli.ts platform-infra sub2api codex-pool expose${targetFlag(runtimeTarget)} --confirm`,
validate: `bun scripts/cli.ts platform-infra sub2api validate${targetFlag(runtimeTarget)}`,
note: "PK01 host-Docker target does not run the k3s codex-pool sync path.",
}
: { sync: `bun scripts/cli.ts platform-infra sub2api codex-pool sync${targetFlag(runtimeTarget)} --confirm` }
? { sync: `bun scripts/cli.ts platform-infra sub2api codex-pool sync${targetFlag(runtimeTarget)} --confirm` }
: { fix: "Ensure every discovered config.toml profile has a base_url and either auth.json OPENAI_API_KEY or the configured env_key present in this shell." },
};
}
@@ -89,24 +85,6 @@ export async function codexPoolSync(config: UniDeskConfig, options: SyncOptions)
const runtimeTarget = codexPoolRuntimeTarget(options.targetId);
const profiles = collectCodexProfiles();
const planOk = profiles.length > 0 && profiles.every((profile) => profile.ok);
if (runtimeTarget.runtimeMode === "host-docker" && options.confirm) {
return {
ok: false,
action: "platform-infra-sub2api-codex-pool-sync",
mode: "blocked-host-docker-sync-unsupported",
target: poolTarget(pool, runtimeTarget),
reason: "PK01 host-Docker target does not run the k3s codex-pool sync path; Sub2API runtime is controlled by platform-infra sub2api apply/validate.",
local: {
profileCount: profiles.length,
invalidProfiles: profiles.filter((profile) => !profile.ok).map(compactProfile),
valuesPrinted: false,
},
next: {
expose: `bun scripts/cli.ts platform-infra sub2api codex-pool expose${targetFlag(runtimeTarget)} --confirm`,
validate: `bun scripts/cli.ts platform-infra sub2api validate${targetFlag(runtimeTarget)}`,
},
};
}
if (!options.confirm || !planOk) {
const plan = {
...codexPoolPlan(options),