mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-05 14:22:12 +00:00
fix(auth): scope km alias mapping to settings profiles
- prevent km continuity mappings from affecting kimi cliproxy executions - apply canonical alias fallback only for settings profile lookups - add regression test for cross-type alias isolation
This commit is contained in:
@@ -65,12 +65,13 @@ function loadLegacyContinuityInheritanceMap(): Record<string, string> {
|
|||||||
|
|
||||||
function resolveMappedAccount(
|
function resolveMappedAccount(
|
||||||
profileName: string,
|
profileName: string,
|
||||||
|
profileType: ProfileType,
|
||||||
inheritFromAccount: Record<string, string>
|
inheritFromAccount: Record<string, string>
|
||||||
): string | undefined {
|
): string | undefined {
|
||||||
const candidates = new Set<string>([
|
const candidates = new Set<string>(getProfileLookupCandidates(profileName));
|
||||||
...getProfileLookupCandidates(profileName),
|
if (profileType === 'settings') {
|
||||||
resolveAliasToCanonical(profileName),
|
candidates.add(resolveAliasToCanonical(profileName));
|
||||||
]);
|
}
|
||||||
|
|
||||||
for (const candidate of candidates) {
|
for (const candidate of candidates) {
|
||||||
const mapped = inheritFromAccount[candidate];
|
const mapped = inheritFromAccount[candidate];
|
||||||
@@ -118,9 +119,13 @@ export async function resolveProfileContinuityInheritance(
|
|||||||
|
|
||||||
const inheritFromAccount = getContinuityInheritanceMap();
|
const inheritFromAccount = getContinuityInheritanceMap();
|
||||||
const sourceAccount =
|
const sourceAccount =
|
||||||
resolveMappedAccount(input.profileName, inheritFromAccount) ??
|
resolveMappedAccount(input.profileName, input.profileType, inheritFromAccount) ??
|
||||||
(!isUnifiedMode()
|
(!isUnifiedMode()
|
||||||
? resolveMappedAccount(input.profileName, loadLegacyContinuityInheritanceMap())
|
? resolveMappedAccount(
|
||||||
|
input.profileName,
|
||||||
|
input.profileType,
|
||||||
|
loadLegacyContinuityInheritanceMap()
|
||||||
|
)
|
||||||
: undefined);
|
: undefined);
|
||||||
if (!sourceAccount) {
|
if (!sourceAccount) {
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -258,6 +258,28 @@ describe('resolveProfileContinuityInheritance', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not apply km settings alias mapping to kimi cliproxy profile', async () => {
|
||||||
|
spyOn(configLoader, 'loadOrCreateUnifiedConfig').mockReturnValue({
|
||||||
|
version: 8,
|
||||||
|
continuity: {
|
||||||
|
inherit_from_account: {
|
||||||
|
km: 'pro',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as ReturnType<typeof configLoader.loadOrCreateUnifiedConfig>);
|
||||||
|
|
||||||
|
const ensureInstanceSpy = spyOn(InstanceManager.prototype, 'ensureInstance');
|
||||||
|
|
||||||
|
const result = await resolveProfileContinuityInheritance({
|
||||||
|
profileName: 'kimi',
|
||||||
|
profileType: 'cliproxy',
|
||||||
|
target: 'claude',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).toEqual({});
|
||||||
|
expect(ensureInstanceSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it('fails open when source account instance initialization throws', async () => {
|
it('fails open when source account instance initialization throws', async () => {
|
||||||
spyOn(configLoader, 'loadOrCreateUnifiedConfig').mockReturnValue({
|
spyOn(configLoader, 'loadOrCreateUnifiedConfig').mockReturnValue({
|
||||||
version: 8,
|
version: 8,
|
||||||
|
|||||||
Reference in New Issue
Block a user