fix: restore discord username lookup and align minimax test (#3131) (thanks @bonald)

This commit is contained in:
Ayaan Zaidi 2026-01-28 11:01:03 +05:30
parent a3ff7daf70
commit a81c1daca7
3 changed files with 23 additions and 6 deletions

View File

@ -71,6 +71,8 @@ Status: beta.
- **BREAKING:** Gateway auth mode "none" is removed; gateway now requires token/password (Tailscale Serve identity still allowed). - **BREAKING:** Gateway auth mode "none" is removed; gateway now requires token/password (Tailscale Serve identity still allowed).
### Fixes ### Fixes
- Discord: restore username directory lookup in target resolution. (#3131) Thanks @bonald.
- Agents: align MiniMax base URL test expectation with default provider config. (#3131) Thanks @bonald.
- Agents: prevent retries on oversized image errors and surface size limits. (#2871) Thanks @Suksham-sharma. - Agents: prevent retries on oversized image errors and surface size limits. (#2871) Thanks @Suksham-sharma.
- Agents: inherit provider baseUrl/api for inline models. (#2740) Thanks @lploc94. - Agents: inherit provider baseUrl/api for inline models. (#2740) Thanks @lploc94.
- Memory Search: keep auto provider model defaults and only include remote when configured. (#2576) Thanks @papago2355. - Memory Search: keep auto provider model defaults and only include remote when configured. (#2576) Thanks @papago2355.

View File

@ -136,7 +136,7 @@ describe("models-config", () => {
} }
>; >;
}; };
expect(parsed.providers.minimax?.baseUrl).toBe("https://api.minimax.io/anthropic"); expect(parsed.providers.minimax?.baseUrl).toBe("https://api.minimax.chat/v1");
expect(parsed.providers.minimax?.apiKey).toBe("MINIMAX_API_KEY"); expect(parsed.providers.minimax?.apiKey).toBe("MINIMAX_API_KEY");
const ids = parsed.providers.minimax?.models?.map((model) => model.id); const ids = parsed.providers.minimax?.models?.map((model) => model.id);
expect(ids).toContain("MiniMax-M2.1"); expect(ids).toContain("MiniMax-M2.1");

View File

@ -80,13 +80,15 @@ export async function resolveDiscordTarget(
const trimmed = raw.trim(); const trimmed = raw.trim();
if (!trimmed) return undefined; if (!trimmed) return undefined;
const shouldLookup = isExplicitUserLookup(trimmed, options); const parseOptions: DiscordTargetParseOptions = {};
const directParse = safeParseDiscordTarget(trimmed, options); const likelyUsername = isLikelyUsername(trimmed);
if (directParse && directParse.kind !== "channel") { const shouldLookup = isExplicitUserLookup(trimmed, parseOptions) || likelyUsername;
const directParse = safeParseDiscordTarget(trimmed, parseOptions);
if (directParse && directParse.kind !== "channel" && !likelyUsername) {
return directParse; return directParse;
} }
if (!shouldLookup) { if (!shouldLookup) {
return directParse ?? parseDiscordTarget(trimmed, options); return directParse ?? parseDiscordTarget(trimmed, parseOptions);
} }
// Try to resolve as a username via directory lookup // Try to resolve as a username via directory lookup
@ -109,7 +111,7 @@ export async function resolveDiscordTarget(
} }
// Fallback to original parsing (for channels, etc.) // Fallback to original parsing (for channels, etc.)
return parseDiscordTarget(trimmed, options); return parseDiscordTarget(trimmed, parseOptions);
} }
function safeParseDiscordTarget( function safeParseDiscordTarget(
@ -138,3 +140,16 @@ function isExplicitUserLookup(input: string, options: DiscordTargetParseOptions)
} }
return false; return false;
} }
/**
* Check if a string looks like a Discord username (not a mention, prefix, or ID).
* Usernames typically don't start with special characters except underscore.
*/
function isLikelyUsername(input: string): boolean {
// Skip if it's already a known format
if (/^(user:|channel:|discord:|@|<@!?)|[\d]+$/.test(input)) {
return false;
}
// Likely a username if it doesn't match known patterns
return true;
}