export type ExternalCliResolvedProfile = {
profileId: string;
credential: OAuthCredential;
};
type ExternalCliSyncProvider = {
profileId: string;
provider: string;
readCredentials: () => OAuthCredential | null; // bootstrapOnly providers adopt the external CLI credential only to // seed an empty slot; once a local OAuth credential exists for the // profile, the local refresh token is treated as canonical and the // CLI state must not replace or shadow it. Codex requires this to // avoid clobbering a locally refreshed token with stale CLI state.
bootstrapOnly?: boolean;
};
export function readExternalCliBootstrapCredential(params: {
profileId: string;
credential: OAuthCredential;
}): OAuthCredential | null { const provider = resolveExternalCliSyncProvider(params); if (!provider) { returnnull;
} // bootstrapOnly providers must not replace an existing local credential // during runtime refresh. The oauth-manager only calls this hook when a // local credential is already present, so returning null here keeps the // locally stored refresh token canonical. if (provider.bootstrapOnly) { returnnull;
} return provider.readCredentials();
}
export function resolveExternalCliAuthProfiles(
store: AuthProfileStore,
): ExternalCliResolvedProfile[] { const profiles: ExternalCliResolvedProfile[] = []; const now = Date.now(); for (const providerConfig of EXTERNAL_CLI_SYNC_PROVIDERS) { const creds = providerConfig.readCredentials(); if (!creds) { continue;
} const existing = store.profiles[providerConfig.profileId]; const existingOAuth =
existing?.type === "oauth" && existing.provider === providerConfig.provider
? existing
: undefined; if (existing && !existingOAuth) {
log.debug("kept explicit local auth over external cli bootstrap", {
profileId: providerConfig.profileId,
provider: providerConfig.provider,
localType: existing.type,
localProvider: existing.provider,
}); continue;
} if (providerConfig.bootstrapOnly && existingOAuth) {
log.debug("kept local oauth over external cli bootstrap-only provider", {
profileId: providerConfig.profileId,
provider: providerConfig.provider,
}); continue;
} if (existingOAuth && !isSafeToUseExternalCliCredential(existingOAuth, creds)) {
log.warn("refused external cli oauth bootstrap: identity mismatch", {
profileId: providerConfig.profileId,
provider: providerConfig.provider,
}); continue;
} if (
existingOAuth &&
!isSafeToAdoptBootstrapOAuthIdentity(existingOAuth, creds) &&
!areOAuthCredentialsEquivalent(existingOAuth, creds)
) {
log.warn("refused external cli oauth bootstrap: identity mismatch or missing binding", {
profileId: providerConfig.profileId,
provider: providerConfig.provider,
}); continue;
} if (
!shouldBootstrapFromExternalCliCredential({
existing: existingOAuth,
imported: creds,
now,
})
) { if (existingOAuth) {
log.debug("kept usable local oauth over external cli bootstrap", {
profileId: providerConfig.profileId,
provider: providerConfig.provider,
localExpires: existingOAuth.expires,
externalExpires: creds.expires,
});
} continue;
}
log.debug("used external cli oauth bootstrap because local oauth was missing or unusable", {
profileId: providerConfig.profileId,
provider: providerConfig.provider,
localExpires: existingOAuth?.expires,
externalExpires: creds.expires,
});
profiles.push({
profileId: providerConfig.profileId,
credential: creds,
});
} return profiles;
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet am 2026-06-06)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.