feat: add DeepSeek Harness runtime

This commit is contained in:
lofyer
2026-08-14 10:04:34 +08:00
parent fca9888f83
commit 8286e120a1
69 changed files with 13660 additions and 351 deletions
+47 -1
View File
@@ -23,6 +23,12 @@ export const agentRuntimeSelectionSchema = z.discriminatedUnion(
provider: z.literal('continue'),
profileId: runtimeSelectionProfileIdSchema.optional()
})
.strict(),
z
.object({
provider: z.literal('deepseek-harness'),
profileId: runtimeSelectionProfileIdSchema.optional()
})
.strict()
]
)
@@ -34,6 +40,7 @@ export type AgentRuntimeSelection = z.infer<
export type RuntimeSelectionRepairSettings = {
modelProfiles: ReadonlyArray<{
id: string
baseUrl?: string
protocol?: string
authentication?: 'api-key' | 'none'
apiKeyConfigured?: boolean
@@ -45,6 +52,9 @@ export type RuntimeSelectionRepairSettings = {
continueModelSource:
| { kind: 'platform' }
| { kind: 'profile'; profileId: string }
deepseekHarnessModelSource?:
| { kind: 'platform' }
| { kind: 'profile'; profileId: string }
}
type ChannelModelProfile = RuntimeSelectionRepairSettings['modelProfiles'][number]
@@ -61,6 +71,25 @@ export function isChannelModelProfileUsable(
)
}
function isDeepSeekHarnessRepairProfileUsable(
profile: ChannelModelProfile
): boolean {
if (
profile.protocol !== 'openai-chat-completions' ||
profile.authentication !== 'api-key' ||
profile.apiKeyConfigured === false ||
!profile.baseUrl
) {
return false
}
try {
return new URL(profile.baseUrl).hostname.toLowerCase() ===
'api.deepseek.com'
} catch {
return false
}
}
export function repairChannelRuntimeSelection(
selection: AgentRuntimeSelection,
settings: RuntimeSelectionRepairSettings
@@ -86,6 +115,21 @@ export function repairChannelRuntimeSelection(
) {
return { provider: selection.provider }
}
if (selection.provider === 'deepseek-harness') {
const repaired = repairAgentRuntimeSelection(selection, settings)
if (
repaired.provider === 'deepseek-harness' &&
repaired.profileId
) {
const profile = settings.modelProfiles.find(
(candidate) => candidate.id === repaired.profileId
)
if (profile && isDeepSeekHarnessRepairProfileUsable(profile)) {
return repaired
}
}
return { provider: 'deepseek-harness' }
}
const repaired = repairAgentRuntimeSelection(selection, settings)
if (repaired.provider !== 'model') {
return repaired
@@ -120,7 +164,9 @@ export function repairAgentRuntimeSelection(
const source =
selection.provider === 'opencode'
? settings.opencodeModelSource
: settings.continueModelSource
: selection.provider === 'continue'
? settings.continueModelSource
: settings.deepseekHarnessModelSource ?? { kind: 'platform' }
return {
provider: selection.provider,
...(source.kind === 'profile'