feat: expand DeepSeek Harness compatibility

This commit is contained in:
lofyer
2026-08-14 12:38:01 +08:00
parent 36e05d45fa
commit 45aeecb6dd
32 changed files with 554 additions and 193 deletions
@@ -0,0 +1,50 @@
type DeepSeekHarnessModelProfile = {
baseUrl: string
protocol: string
authentication: string
}
function isLoopbackHostname(hostname: string): boolean {
const normalized = hostname
.toLowerCase()
.replace(/^\[|\]$/gu, '')
return (
normalized === 'localhost' ||
normalized === '127.0.0.1' ||
normalized === '::1'
)
}
export function isDeepSeekHarnessCompatibleBaseUrl(
value: string
): boolean {
try {
const url = new URL(value)
if (
!url.hostname ||
url.username ||
url.password ||
url.search ||
url.hash
) {
return false
}
return (
url.protocol === 'https:' ||
(url.protocol === 'http:' &&
isLoopbackHostname(url.hostname))
)
} catch {
return false
}
}
export function isDeepSeekHarnessModelProfile(
profile: DeepSeekHarnessModelProfile
): boolean {
return (
profile.protocol === 'openai-chat-completions' &&
profile.authentication === 'api-key' &&
isDeepSeekHarnessCompatibleBaseUrl(profile.baseUrl)
)
}