π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(hetero): discover DeepSeek Harness models over ACP (#22542)
AleFlyXffa37176602c
diff --git a/apps/server/src/routers/lambda/device/agents.ts b/apps/server/src/routers/lambda/device/agents.tsindex 64922ac7a5e..dd721c5ff8b 100644--- a/apps/server/src/routers/lambda/device/agents.ts+++ b/apps/server/src/routers/lambda/device/agents.ts@@ -140,6 +140,7 @@ export const agentsRouter = router({'codex','copilot','cursor',+ 'deepseek-harness','droid','devin','grok-build',diff --git a/apps/server/src/services/aiAgent/pipeline/heteroDispatch/prepare.ts b/apps/server/src/services/aiAgent/pipeline/heteroDispatch/prepare.tsindex 193725b4ccc..a931353b07d 100644--- a/apps/server/src/services/aiAgent/pipeline/heteroDispatch/prepare.ts+++ b/apps/server/src/services/aiAgent/pipeline/heteroDispatch/prepare.ts@@ -4,6 +4,7 @@ import {appendAttachedFilesToPrompt,collectHeteroAttachedFiles,isLocalHeterogeneousType,+ isLocalRuntimeHeterogeneousType,resolveDispatchedClaudeCodeEntrypoint,} from '@lobechat/heterogeneous-agents';import {@@ -318,16 +319,20 @@ export const prepareHeteroRun = async (runAttachments.imageList && runAttachments.imageList.length > 0? runAttachments.imageList.map((image) => ({ id: image.id, url: image.url })): undefined;- const heteroExecArgs = isLocalHeterogeneousType(heteroType)- ? buildHeteroExecArgs(- heterogeneousProvider?.type === heteroType- ? applyTopicModelToHeterogeneousProvider(- heterogeneousProvider,- pinnedHeterogeneousTopicModel,- )- : { type: heteroType },- )- : undefined;+ // Protocol runtimes (DeepSeek Harness) also launch through `lh hetero exec`+ // and need the selector flags (e.g. `--model <tuple>`) built for it, even+ // though they are not local-CLI descriptor agents.+ const heteroExecArgs =+ isLocalHeterogeneousType(heteroType) || isLocalRuntimeHeterogeneousType(heteroType)+ ? buildHeteroExecArgs(+ heterogeneousProvider?.type === heteroType+ ? applyTopicModelToHeterogeneousProvider(+ heterogeneousProvider,+ pinnedHeterogeneousTopicModel,+ )+ : { type: heteroType },+ )+ : undefined;const heteroParams = {agentType: heteroType,diff --git a/apps/server/src/services/deviceGateway/agents.ts b/apps/server/src/services/deviceGateway/agents.tsindex 398dfc694dd..42e66ecf579 100644--- a/apps/server/src/services/deviceGateway/agents.ts+++ b/apps/server/src/services/deviceGateway/agents.ts@@ -101,6 +101,7 @@ export async function listHeterogeneousAgentModels(| 'copilot'| 'cursor'| 'devin'+ | 'deepseek-harness'| 'droid'| 'grok-build'| 'kimi-code'diff --git a/packages/heterogeneous-agents/src/labels.test.ts b/packages/heterogeneous-agents/src/labels.test.tsnew file mode 100644index 00000000000..233ad407a5d--- /dev/null+++ b/packages/heterogeneous-agents/src/labels.test.ts@@ -0,0 +1,10 @@+import { describe, expect, it } from 'vitest';++import { getHeterogeneousTypeLabel, HETEROGENEOUS_TYPE_LABELS } from './labels';++describe('heterogeneous type labels', () => {+ it('labels protocol runtimes instead of falling back to the type slug', () => {+ expect(HETEROGENEOUS_TYPE_LABELS['deepseek-harness']).toBe('DeepSeek Harness');+ expect(getHeterogeneousTypeLabel('deepseek-harness')).toBe('DeepSeek Harness');+ });+});diff --git a/packages/heterogeneous-agents/src/labels.ts b/packages/heterogeneous-agents/src/labels.tsindex b0a1d59bc66..24d3807fdc3 100644--- a/packages/heterogeneous-agents/src/labels.ts+++ b/packages/heterogeneous-agents/src/labels.ts@@ -1,16 +1,22 @@-import { HETEROGENEOUS_AGENT_CONFIGS, REMOTE_HETEROGENEOUS_AGENT_CONFIGS } from './config';+import {+ HETEROGENEOUS_AGENT_CONFIGS,+ LOCAL_RUNTIME_HETEROGENEOUS_AGENT_CONFIGS,+ REMOTE_HETEROGENEOUS_AGENT_CONFIGS,+} from './config';/**- * Display-name mapping for all heterogeneous agent types (local CLI + remote platform).+ * Display-name mapping for all heterogeneous agent types (local CLI, local+ * runtime, remote platform).** Keys mirror the registry keys in `registry.ts` (adapter type). UI layers* use this to render user-facing names (e.g. "Claude Code is running")* without knowing adapter-specific branding.- * Add new types to HETEROGENEOUS_AGENT_CONFIGS or REMOTE_HETEROGENEOUS_AGENT_CONFIGS- * in config.ts to automatically include them here.+ * Add new types to HETEROGENEOUS_AGENT_CONFIGS, LOCAL_RUNTIME_HETEROGENEOUS_AGENT_CONFIGS+ * or REMOTE_HETEROGENEOUS_AGENT_CONFIGS in config.ts to automatically include them here.*/export const HETEROGENEOUS_TYPE_LABELS: Record<string, string> = Object.fromEntries([...HETEROGENEOUS_AGENT_CONFIGS.map((config) => [config.type, config.title]),+ ...LOCAL_RUNTIME_HETEROGENEOUS_AGENT_CONFIGS.map((config) => [config.type, config.title]),...REMOTE_HETEROGENEOUS_AGENT_CONFIGS.map((config) => [config.type, config.title]),]);diff --git a/packages/heterogeneous-agents/src/models/listHeterogeneousAgentModels.test.ts b/packages/heterogeneous-agents/src/models/listHeterogeneousAgentModels.test.tsindex d50c52118bd..1a3ee8ddc0d 100644--- a/packages/heterogeneous-agents/src/models/listHeterogeneousAgentModels.test.ts+++ b/packages/heterogeneous-agents/src/models/listHeterogeneousAgentModels.test.ts@@ -4,9 +4,17 @@ import path from 'node:path';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-const { listCodexModelsMock, listDroidAcpModelsMock, listTraeAcpModelsMock } = vi.hoisted(() => ({+const {+ detectDshCommandMock,+ listCodexModelsMock,+ listDroidAcpModelsMock,+ listDshAcpModelsMock,+ listTraeAcpModelsMock,+} = vi.hoisted(() => ({+ detectDshCommandMock: vi.fn(),listCodexModelsMock: vi.fn(),listDroidAcpModelsMock: vi.fn(),+ listDshAcpModelsMock: vi.fn(),listTraeAcpModelsMock: vi.fn(),}));@@ -28,6 +36,12 @@ vi.mock('../spawn/droidAcpSession', () => ({listDroidAcpModels: listDroidAcpModelsMock,}));+vi.mock('../spawn/dshAcpSession', () => ({+ DSH_COMMAND: 'dsh',+ detectDshCommand: detectDshCommandMock,+ listDshAcpModels: listDshAcpModelsMock,+}));+vi.mock('./codex', () => ({ listCodexModels: listCodexModelsMock }));// Catalog parsing uses a mocked process; directory failures exercise the real spawn separately.@@ -56,8 +70,10 @@ const importModule = () => import('./listHeterogeneousAgentModels');describe('heterogeneous agent model discovery', () => {beforeEach(() => {execFileMock.mockReset();+ detectDshCommandMock.mockReset();listCodexModelsMock.mockReset();listDroidAcpModelsMock.mockReset();+ listDshAcpModelsMock.mockReset();listTraeAcpModelsMock.mockReset();});@@ -65,6 +81,53 @@ describe('heterogeneous agent model discovery', () => {vi.resetModules();});+ it('queries DeepSeek Harness through ACP instead of --list-models', async () => {+ const models = [{ id: '["gateway","model"]', modelId: 'model', providerId: 'gateway' }];+ listDshAcpModelsMock.mockResolvedValue(models);+ const { listHeterogeneousAgentModels } = await importModule();++ await expect(+ listHeterogeneousAgentModels({+ args: ['--config', '/config'],+ command: '/custom/dsh',+ cwd: '/repo',+ env: { DSH_TEST: 'value' },+ type: 'deepseek-harness',+ }),+ ).resolves.toMatchObject({ models, status: 'success' });++ expect(listDshAcpModelsMock).toHaveBeenCalledWith(+ expect.objectContaining({+ args: ['--config', '/config'],+ commandPath: '/custom/dsh',+ cwd: '/repo',+ env: expect.objectContaining({ DSH_TEST: 'value' }),+ }),+ );+ expect(detectDshCommandMock).not.toHaveBeenCalled();+ expect(execFileMock).not.toHaveBeenCalled();+ });++ it('resolves the default dsh executable before ACP discovery', async () => {+ listDshAcpModelsMock.mockResolvedValue([]);+ detectDshCommandMock.mockResolvedValue({+ available: true,+ path: '/opt/dsh/bin/dsh',+ resolvedPathEnv: '/opt/dsh/bin',+ });+ const { listHeterogeneousAgentModels } = await importModule();++ await listHeterogeneousAgentModels({+ cwd: '/repo',+ env: { PATH: '/usr/bin' },+ type: 'deepseek-harness',+ });++ expect(listDshAcpModelsMock).toHaveBeenCalledWith(+ expect.objectContaining({ commandPath: '/opt/dsh/bin/dsh' }),+ );+ });+it('loads Pi provider extensions with the same discovery policy as the configured run', async () => {resolveExecFile('custom fixture-model 4K 512 no no');const { listHeterogeneousAgentModels } = await importModule();diff --git a/packages/heterogeneous-agents/src/models/listHeterogeneousAgentModels.ts b/packages/heterogeneous-agents/src/models/listHeterogeneousAgentModels.tsindex 34107b768ac..4dd650b35ae 100644--- a/packages/heterogeneous-agents/src/models/listHeterogeneousAgentModels.ts+++ b/packages/heterogeneous-agents/src/models/listHeterogeneousAgentModels.ts@@ -15,6 +15,8 @@ import { AcpRpcResponseError } from '../spawn/acpStdioClient';import { resolveCliSpawnPlan } from '../spawn/cliSpawn';import { listCopilotAcpModels } from '../spawn/copilotAcpSession';import { listDroidAcpModels } from '../spawn/droidAcpSession';+import { detectDshCommand, DSH_COMMAND, listDshAcpModels } from '../spawn/dshAcpSession';+import type { ResolvedHeteroCommand } from '../spawn/resolveCliCommand';import { resolveHeteroSpawnCommand } from '../spawn/resolveCliCommand';import { listTraeAcpModels } from '../spawn/traeAcpSession';import { resolveHeteroSpawnCwd } from '../spawn/workingDirectory';@@ -317,6 +319,31 @@ const getCatalogErrorMessage = (return `${name} model discovery failed`;};+/**+ * Resolve the runtime to launch for catalog discovery. DeepSeek Harness is a+ * protocol runtime with no local-CLI descriptor, so it is not covered by+ * {@link resolveHeteroSpawnCommand}; its own detector validates the version and+ * resolves the executable the same way.+ */+const resolveCatalogCommand = async (+ params: ListHeterogeneousAgentModelsParams,+ env: NodeJS.ProcessEnv | Record<string, string>,+): Promise<ResolvedHeteroCommand> => {+ if (params.type !== 'deepseek-harness') {+ return resolveHeteroSpawnCommand(params.type, params.command);+ }++ const requested = params.command?.trim();+ if (requested && requested !== DSH_COMMAND) return { command: requested };++ const detected = await detectDshCommand(DSH_COMMAND, env as NodeJS.ProcessEnv).catch(+ () => undefined,+ );+ return detected?.available && detected.path+ ? { command: detected.path, pathEnv: detected.resolvedPathEnv }+ : { command: DSH_COMMAND };+};+/*** Query the model catalog from the same host that will execute the agent.*@@ -329,8 +356,8 @@ export const listHeterogeneousAgentModels = async (params: ListHeterogeneousAgentModelsParams,): Promise<HeterogeneousAgentModelCatalog> => {const updatedAt = Date.now();- const resolved = await resolveHeteroSpawnCommand(params.type, params.command);const callerEnv = params.env ?? process.env;+ const resolved = await resolveCatalogCommand(params, callerEnv);const mergedPath = [...new Set([callerEnv.PATH, resolved.pathEnv].filter(Boolean).join(path.delimiter).split(path.delimiter),@@ -359,6 +386,19 @@ export const listHeterogeneousAgentModels = async (// Keep valid project directories so project-specific provider configuration still applies.const cwd = resolveHeteroSpawnCwd(params.cwd ?? process.cwd());+ if (params.type === 'deepseek-harness') {+ const models = await listDshAcpModels({+ args: params.args,+ commandPath: resolved.command,+ cwd: cwd ?? process.cwd(),+ env: env as NodeJS.ProcessEnv,+ // Keep the interactive catalog budget instead of the runtime's 60s turn+ // budget: a cold boot should surface a retryable timeout, not a hang.+ timeoutMs: MODEL_CATALOG_TIMEOUT_MS,+ });+ return { models, status: 'success', updatedAt };+ }+if (params.type === 'copilot') {const models = await listCopilotAcpModels({args: params.args,diff --git a/packages/heterogeneous-agents/src/spawn/dshAcpSession.e2e.test.ts b/packages/heterogeneous-agents/src/spawn/dshAcpSession.e2e.test.tsindex e7c78c64754..7ff08396461 100644--- a/packages/heterogeneous-agents/src/spawn/dshAcpSession.e2e.test.ts+++ b/packages/heterogeneous-agents/src/spawn/dshAcpSession.e2e.test.ts@@ -5,7 +5,7 @@ import path from 'node:path';import type { AgentStreamEvent } from '@lobechat/agent-gateway-client';import { describe, expect, it } from 'vitest';-import { spawnDshAcpSession } from './dshAcpSession';+import { listDshAcpModels, spawnDshAcpSession } from './dshAcpSession';/*** End-to-end against a REAL DeepSeek Harness runtime β real model calls and@@ -80,3 +80,31 @@ describe.runIf(runnable)('spawnDshAcpSession β live harness', () => {expect(await readFile(path.join(cwd, 'proof.txt'), 'utf8')).toContain('dsh-e2e-proof');}, 240_000);});++/**+ * Live catalog discovery against a real CLI. Self-skips unless `DSH_BIN`+ * points at a DeepSeek Harness install β no API key needed. Run it after a+ * harness upgrade to catch ACP catalog-shape drift:+ *+ * DSH_BIN="$(command -v dsh)" DSH_HOME=/tmp/dsh-e2e bunx vitest run \+ * src/spawn/dshAcpSession.e2e.test.ts -t "enumerates the configured model catalog"+ */+describe.skipIf(!process.env.DSH_BIN)('listDshAcpModels β live harness', () => {+ it('enumerates the configured model catalog over ACP', async () => {+ const cwd = await mkdtemp(path.join(tmpdir(), 'dsh-e2e-'));++ const models = await listDshAcpModels({+ commandPath: process.env.DSH_BIN!,+ cwd,+ env: process.env,+ timeoutMs: 60_000,+ });++ expect(models.length).toBeGreaterThan(0);+ for (const model of models) {+ expect(model.id).toBeTruthy();+ expect(model.modelId).toBeTruthy();+ expect(model.providerId).toBeTruthy();+ }+ }, 90_000);+});diff --git a/packages/heterogeneous-agents/src/spawn/dshAcpSession.test.ts b/packages/heterogeneous-agents/src/spawn/dshAcpSession.test.tsindex 988d430eb5f..617f3a41dbb 100644--- a/packages/heterogeneous-agents/src/spawn/dshAcpSession.test.ts+++ b/packages/heterogeneous-agents/src/spawn/dshAcpSession.test.ts@@ -6,7 +6,7 @@ import { fileURLToPath } from 'node:url';import type { AgentStreamEvent } from '@lobechat/agent-gateway-client';import { describe, expect, it, vi } from 'vitest';-import { DSH_ACP_PROFILE_ARGS, spawnDshAcpSession } from './dshAcpSession';+import { DSH_ACP_PROFILE_ARGS, listDshAcpModels, spawnDshAcpSession } from './dshAcpSession';const FIXTURES = path.join(path.dirname(fileURLToPath(import.meta.url)), '__fixtures__/dshAcp');@@ -60,6 +60,8 @@ process.stdin.on('data', (chunk) => {send({ id, result: { configOptions: config } });} else if (method === 'session/set_config_option') {send({ id, result: { configOptions: config } });+ } else if (method === 'session/close') {+ send({ id, result: {} });} else if (method === 'session/prompt') {if (process.env.FAKE_HANG) { pendingPrompt = id; continue; }const recorded = fs.readFileSync(process.env.FAKE_FIXTURE, 'utf8').trim().split('\\n');@@ -212,6 +214,87 @@ describe('spawnDshAcpSession', () => {expect(await methodsOf(logPath)).toEqual(['initialize']);});+ it('selects the exact persisted tuple when providers offer the same model name', async () => {+ const value = '["gateway","deepseek-v4-pro"]';+ const config = structuredClone(MODEL_CONFIG);+ config[0].options.push({+ group: 'gateway',+ name: 'Gateway',+ options: [{ name: 'DeepSeek-V4-Pro', value }],+ });+ const { handle, logPath } = await start({+ env: { FAKE_CONFIG: JSON.stringify(config) },+ model: value,+ });++ await collect(handle);++ const setConfig = (await requestsOf(logPath)).find(+ ({ frame }) => frame.method === 'session/set_config_option',+ );+ expect(setConfig?.frame.params.value).toBe(value);+ });++ it('discovers grouped models over ACP without prompting, preserving tuple IDs', async () => {+ const { dir, logPath } = await start({});++ const models = await listDshAcpModels({+ commandPath: path.join(dir, 'dsh'),+ cwd: dir,+ env: { ...process.env, FAKE_CONFIG: JSON.stringify(MODEL_CONFIG), FAKE_LOG: logPath },+ });++ expect(models).toEqual([+ {+ id: '["deepseek-official","deepseek-v4-flash"]',+ label: 'deepseek-v4-flash',+ modelId: 'deepseek-v4-flash',+ providerId: 'deepseek-official',+ },+ {+ id: '["deepseek-official","deepseek-v4-pro"]',+ label: 'DeepSeek-V4-Pro',+ modelId: 'deepseek-v4-pro',+ providerId: 'deepseek-official',+ },+ ]);+ expect(await methodsOf(logPath)).toEqual(['initialize', 'session/new', 'session/close']);+ });++ it('dedupes repeated choice values from the runtime catalog', async () => {+ const { dir, logPath } = await start({});+ const duplicateConfig = [+ {+ ...MODEL_CONFIG[0],+ options: [+ {+ group: 'deepseek-official',+ name: 'DeepSeek',+ options: [+ { name: 'deepseek-v4-flash', value: '["deepseek-official","deepseek-v4-flash"]' },+ {+ name: 'deepseek-v4-flash (dup)',+ value: '["deepseek-official","deepseek-v4-flash"]',+ },+ { name: 'DeepSeek-V4-Pro', value: '["deepseek-official","deepseek-v4-pro"]' },+ ],+ },+ ],+ },+ ];++ const models = await listDshAcpModels({+ commandPath: path.join(dir, 'dsh'),+ cwd: dir,+ env: { ...process.env, FAKE_CONFIG: JSON.stringify(duplicateConfig), FAKE_LOG: logPath },+ });++ expect(models.map(({ id }) => id)).toEqual([+ '["deepseek-official","deepseek-v4-flash"]',+ '["deepseek-official","deepseek-v4-pro"]',+ ]);+ });+it('switches to a requested model the runtime offers', async () => {const { handle, logPath } = await start({ model: 'deepseek-v4-pro' });diff --git a/packages/heterogeneous-agents/src/spawn/dshAcpSession.ts b/packages/heterogeneous-agents/src/spawn/dshAcpSession.tsindex 5bcc69bfdc0..5e3ef0589e0 100644--- a/packages/heterogeneous-agents/src/spawn/dshAcpSession.ts+++ b/packages/heterogeneous-agents/src/spawn/dshAcpSession.ts@@ -1,4 +1,6 @@import type { AgentStreamEvent } from '@lobechat/agent-gateway-client';+import type { HeterogeneousAgentModel } from '@lobechat/types';+import { parseModelTuple } from '@lobechat/types';import { isRecord } from '@lobechat/utils/object';import type { AcpAgentSessionOptions } from './acpAgentSession';@@ -79,7 +81,7 @@ const DISPOSE_GRACE_MS = 5000;const DSH_MODEL_CONFIG_ID = 'model';interface DshInitializeResult {- agentCapabilities?: { sessionCapabilities?: { resume?: unknown } };+ agentCapabilities?: { sessionCapabilities?: { close?: unknown; resume?: unknown } };protocolVersion?: number | string;}@@ -96,8 +98,9 @@ interface DshSessionResult {export interface DshAcpSessionOptions extends AcpAgentSessionOptions {/**- * Model to select, by name (`deepseek-v4-pro`). A name the runtime does not- * offer keeps the harness's own default rather than failing the turn.+ * Model to select, by ACP tuple value (`["provider","model"]`) or legacy+ * name (`deepseek-v4-pro`). A model the runtime does not offer keeps the+ * harness's own default rather than failing the turn.*/model?: string;prompt: string;@@ -131,16 +134,8 @@ const modelChoices = (configOptions: DshConfigOption[] | undefined) => {};/** The model name inside a `[provider, model]` choice value. */-const modelOf = (value: string | undefined): string | undefined => {- if (!value) return;- try {- const parsed = JSON.parse(value);- if (Array.isArray(parsed) && typeof parsed[1] === 'string') return parsed[1];- } catch {- // Not the encoded pair; treat the raw value as the model name.- }- return value;-};+const modelOf = (value: string | undefined): string | undefined =>+ value ? (parseModelTuple(value)?.modelId ?? value) : undefined;/** DeepSeek Harness's ACP lifecycle on the shared session base. */export class DshAcpSession extends AcpAgentSession<DshInitializeResult, DshAcpSessionOptions> {@@ -160,6 +155,50 @@ export class DshAcpSession extends AcpAgentSession<DshInitializeResult, DshAcpSereturn this.acpSessionId;}+ /**+ * Enumerate the configured providers through ACP without sending a prompt.+ * The harness advertises its model selector on `session/new`; the same+ * lifecycle a real turn uses, so discovery sees exactly what a turn can pick.+ */+ async discoverModels(): Promise<HeterogeneousAgentModel[]> {+ try {+ const initialized = await this.initializeConnection();+ const result = await this.client.request<DshSessionResult>('session/new', {+ cwd: this.options.cwd,+ mcpServers: [],+ });+ if (!result?.sessionId) throw new Error('DeepSeek Harness ACP returned no session id');+ if (!result.configOptions?.some(({ id }) => id === DSH_MODEL_CONFIG_ID)) {+ throw new Error('DeepSeek Harness ACP did not expose a model configuration option');+ }++ const seen = new Set<string>();+ const models = modelChoices(result.configOptions).choices.flatMap(({ name, value }) => {+ // The value is an opaque selection id; the `[provider, model]` pair is+ // only a convention, and an unrecognized encoding must still be usable.+ if (seen.has(value)) return [];+ seen.add(value);++ const tuple = parseModelTuple(value);+ return [+ {+ id: value,+ ...(name ? { label: name } : {}),+ modelId: tuple?.modelId ?? value,+ providerId: tuple?.providerId ?? 'deepseek-harness',+ },+ ];+ });++ if (initialized?.agentCapabilities?.sessionCapabilities?.close) {+ await this.client.request('session/close', { sessionId: result.sessionId });+ }+ return models;+ } finally {+ this.client.close();+ }+ }+protected buildInitializeParams(): unknown {return {clientCapabilities: { fs: {}, terminal: false },@@ -253,8 +292,12 @@ export class DshAcpSession extends AcpAgentSession<DshInitializeResult, DshAcpSe): Promise<string | undefined> {const { choices, current } = modelChoices(configOptions);const wanted = this.options.model?.trim();+ // An exact tuple wins: two providers may expose the same model name, and+ // the picker's persisted id is the tuple, so name matching is only a+ // fallback for selections created before the tuple was persisted.const choice = wanted- ? choices.find(({ name, value }) => name === wanted || modelOf(value) === wanted)+ ? (choices.find(({ value }) => value === wanted) ??+ choices.find(({ name, value }) => name === wanted || modelOf(value) === wanted)): undefined;if (!choice || choice.value === current) return modelOf(current);@@ -380,3 +423,33 @@ export const spawnDshAcpSession = (options: SpawnDshAcpSessionOptions): DshAcpSe},};};++export interface ListDshAcpModelsOptions {+ args?: string[];+ clientVersion?: string;+ commandPath: string;+ cwd: string;+ env: NodeJS.ProcessEnv;+ timeoutMs?: number;+}++/** Discover the runtime's grouped model catalog over the `acp` profile. */+export const listDshAcpModels = async (+ options: ListDshAcpModelsOptions,+): Promise<HeterogeneousAgentModel[]> =>+ new DshAcpSession({+ args: options.args ?? [],+ clientVersion: options.clientVersion ?? '1.0.0',+ commandPath: options.commandPath,+ cwd: options.cwd,+ env: options.env,+ onEvents: () => {},+ onRawMessage: () => {},+ onRuntimeStatus: () => {},+ onSessionId: () => {},+ onStderr: () => {},+ operationId: 'dsh-model-discovery',+ prompt: '',+ requestTimeoutMs: options.timeoutMs,+ sessionId: 'dsh-model-discovery',+ }).discoverModels();diff --git a/packages/types/src/agent/heteroSelectorCapabilities.test.ts b/packages/types/src/agent/heteroSelectorCapabilities.test.tsindex bfdf16c69a4..35334952580 100644--- a/packages/types/src/agent/heteroSelectorCapabilities.test.ts+++ b/packages/types/src/agent/heteroSelectorCapabilities.test.ts@@ -4,13 +4,28 @@ import type { HeterogeneousProviderConfig } from './agencyConfig';import { buildHeteroSpawnArgs } from './agencyConfig';import {applyHeteroSelection,+ buildHeteroExecArgs,getHeteroSelectorCapability,HETEROGENEOUS_AGENT_DEFAULT_SELECTION,isCodexServerDefaultCustomModel,isHeteroSelectorAvailable,+ parseModelTuple,} from './heteroSelectorCapabilities';describe('selector availability', () => {+ it('offers an ACP model selector for DeepSeek Harness and preserves tuple selections', () => {+ const value = '["gateway","deepseek-v4-pro"]';+ const capability = getHeteroSelectorCapability('deepseek-harness');++ expect(isHeteroSelectorAvailable('deepseek-harness')).toBe(true);+ expect(capability?.model?.source).toBe('catalog');+ expect(capability?.model?.encodings).toEqual([]);+ expect(capability?.model?.resolve({ model: value })).toBe(value);+ expect(applyHeteroSelection({ type: 'deepseek-harness' }, { model: value })).toMatchObject({+ model: value,+ });+ });+it('derives the selectable provider set from any registered dimension', () => {expect(isHeteroSelectorAvailable('amp')).toBe(true);expect(isHeteroSelectorAvailable('claude-code')).toBe(true);@@ -291,3 +306,39 @@ describe('applyHeteroSelection', () => {expect(buildHeteroSpawnArgs(patched)).toEqual(['--model', 'opus']);});});++describe('DeepSeek Harness exec args', () => {+ it('forwards the persisted tuple to lh hetero exec without native spawn args', () => {+ const provider: HeterogeneousProviderConfig = {+ args: ['--config', '/tmp/dsh.yml'],+ model: '["deepseek-account","deepseek-flash"]',+ type: 'deepseek-harness',+ };++ // The runtime selects the model through ACP, so the desktop spawn keeps the+ // user's own args and passes the tuple as `initialModel` instead.+ expect(buildHeteroSpawnArgs(provider)).toEqual(['--config', '/tmp/dsh.yml']);+ expect(buildHeteroExecArgs(provider)).toEqual([+ '--agent-arg=--config',+ '--agent-arg=/tmp/dsh.yml',+ '--model',+ '["deepseek-account","deepseek-flash"]',+ ]);+ });+});++describe('parseModelTuple', () => {+ it('decodes the provider and model halves', () => {+ expect(parseModelTuple('["deepseek-account","deepseek-v4-pro"]')).toEqual({+ modelId: 'deepseek-v4-pro',+ providerId: 'deepseek-account',+ });+ });++ it('returns undefined for opaque and malformed values', () => {+ expect(parseModelTuple('deepseek-v4-pro')).toBeUndefined();+ expect(parseModelTuple('["deepseek-account"]')).toBeUndefined();+ expect(parseModelTuple('["deepseek-account",42]')).toBeUndefined();+ expect(parseModelTuple('[not json')).toBeUndefined();+ });+});diff --git a/packages/types/src/agent/heteroSelectorCapabilities.ts b/packages/types/src/agent/heteroSelectorCapabilities.tsindex 63e3f6f5a7f..3500cc688e3 100644--- a/packages/types/src/agent/heteroSelectorCapabilities.ts+++ b/packages/types/src/agent/heteroSelectorCapabilities.ts@@ -8,7 +8,11 @@ import {stripCliConfigKey,stripCliFlags,} from './heteroCliArgs';-import type { HeterogeneousAgentType, LocalHeterogeneousAgentType } from './heterogeneousAgent';+import type {+ HeterogeneousAgentType,+ LocalHeterogeneousAgentType,+ LocalRuntimeHeterogeneousAgentType,+} from './heterogeneousAgent';/*** Selector value that means "do not override the underlying CLI".@@ -299,6 +303,34 @@ const resolvePersistedModel = (source: HeteroSelectionSource | null | undefined): HETEROGENEOUS_AGENT_DEFAULT_SELECTION;};+export interface ParsedModelTuple {+ modelId: string;+ providerId: string;+}++/**+ * Decode a persisted `[provider, model]` selection value. Catalog providers use+ * this encoding when two providers can offer the same model name; opaque values+ * return undefined so callers can keep the raw value.+ */+export const parseModelTuple = (value: string): ParsedModelTuple | undefined => {+ if (!value.startsWith('[')) return;++ try {+ const parsed: unknown = JSON.parse(value);+ if (+ Array.isArray(parsed) &&+ parsed.length === 2 &&+ typeof parsed[0] === 'string' &&+ typeof parsed[1] === 'string'+ ) {+ return { modelId: parsed[1], providerId: parsed[0] };+ }+ } catch {+ // Not the encoded pair; callers fall back to the raw value.+ }+};+export type HeteroCliEncoding ={ flags: readonly string[]; kind: 'flag' } | { key: string; kind: 'config' };@@ -426,6 +458,9 @@ export const HETERO_SELECTOR_CAPABILITIES = {source: 'catalog',},},+ 'deepseek-harness': {+ model: { encodings: [], resolve: resolvePersistedModel, source: 'catalog' },+ },'droid': {model: { encodings: [], resolve: resolvePersistedModel, source: 'catalog' },},@@ -473,12 +508,17 @@ export const HETERO_SELECTOR_CAPABILITIES = {'trae': {model: { encodings: [], resolve: resolvePersistedModel, source: 'catalog' },},-} satisfies Record<LocalHeterogeneousAgentType, HeteroSelectorCapability>;+} satisfies Record<+ LocalHeterogeneousAgentType | LocalRuntimeHeterogeneousAgentType,+ HeteroSelectorCapability+>;export const getHeteroSelectorCapability = (type: string | undefined,): HeteroSelectorCapability | undefined =>- HETERO_SELECTOR_CAPABILITIES[type as LocalHeterogeneousAgentType];+ HETERO_SELECTOR_CAPABILITIES[+ type as LocalHeterogeneousAgentType | LocalRuntimeHeterogeneousAgentType+ ];export const isHeteroSelectorAvailable = (type: string | undefined): boolean =>Object.keys(getHeteroSelectorCapability(type) ?? {}).length > 0;@@ -831,7 +871,8 @@ export const buildHeteroExecArgs = (provider.type !== 'opencode' &&provider.type !== 'pi' &&provider.type !== 'qoder' &&- provider.type !== 'trae'+ provider.type !== 'trae' &&+ provider.type !== 'deepseek-harness') {return provider.args;}@@ -981,7 +1022,11 @@ export const buildHeteroExecArgs = (}}- if (provider.type === 'droid' || provider.type === 'trae') {+ if (+ provider.type === 'droid' ||+ provider.type === 'trae' ||+ provider.type === 'deepseek-harness'+ ) {const model = provider.model?.trim();if (model && model !== HETEROGENEOUS_AGENT_DEFAULT_SELECTION) {selectorArgs.push('--model', model);diff --git a/src/features/ChatInput/ControlBar/HeteroModel/ModelCatalogSelector.tsx b/src/features/ChatInput/ControlBar/HeteroModel/ModelCatalogSelector.tsxindex a1cbb0487a6..b73f3c53bb2 100644--- a/src/features/ChatInput/ControlBar/HeteroModel/ModelCatalogSelector.tsx+++ b/src/features/ChatInput/ControlBar/HeteroModel/ModelCatalogSelector.tsx@@ -42,6 +42,7 @@ import { memo, useCallback, useState } from 'react';import { useTranslation } from 'react-i18next';import { useMenuContentLifecycle } from '../useMenuContentLifecycle';+import { getModelLabel, getModelOptionDescription } from './labels';import { useModelCatalogView } from './useModelCatalogView';import { useTargetModelCatalog } from './useTargetModelCatalog';@@ -170,6 +171,14 @@ export const ModelCatalogSelector = memo<ModelCatalogSelectorProps>(search,});+ // The persisted id can be an opaque tuple (DeepSeek Harness). Show the+ // catalog label when it is loaded, otherwise derive a readable name.+ const triggerModelLabel =+ currentModel === HETEROGENEOUS_AGENT_DEFAULT_SELECTION+ ? t('heteroAgent.modelSelector.default')+ : (data?.models.find((item) => item.id === currentModel)?.label ??+ getModelLabel(currentModel, t('heteroAgent.modelSelector.default')));+const handleOpenChangeComplete = useCallback((nextOpen: boolean) => {completeOpenChange(nextOpen);@@ -183,17 +192,10 @@ export const ModelCatalogSelector = memo<ModelCatalogSelectorProps>({...stylex.props(styles.trigger, disabled && styles.triggerDisabled)}aria-label={t('heteroAgent.cliModel.ariaLabel', {name: agentName,- model:- currentModel === HETEROGENEOUS_AGENT_DEFAULT_SELECTION- ? t('heteroAgent.modelSelector.default')- : currentModel,+ model: triggerModelLabel,})}>- <span {...stylex.props(styles.triggerLabel)}>- {currentModel === HETEROGENEOUS_AGENT_DEFAULT_SELECTION- ? t('heteroAgent.modelSelector.default')- : currentModel}- </span>+ <span {...stylex.props(styles.triggerLabel)}>{triggerModelLabel}</span><Icon icon={ChevronDownIcon} size={12} /></div>);@@ -299,7 +301,7 @@ export const ModelCatalogSelector = memo<ModelCatalogSelectorProps>(<DropdownMenuItemDescclassName={isStale ? stylex.props(styles.stale).className : undefined}>- {item.id}+ {getModelOptionDescription(item.id)}{isStale ? ` Β· ${t('heteroAgent.cliModel.stale')}` : ''}</DropdownMenuItemDesc></DropdownMenuItemLabelGroup>diff --git a/src/features/ChatInput/ControlBar/HeteroModel/labels.test.ts b/src/features/ChatInput/ControlBar/HeteroModel/labels.test.tsnew file mode 100644index 00000000000..8d68158739e--- /dev/null+++ b/src/features/ChatInput/ControlBar/HeteroModel/labels.test.ts@@ -0,0 +1,37 @@+import { describe, expect, it } from 'vitest';++import { getModelLabel, getModelOptionDescription } from './labels';++describe('getModelLabel', () => {+ it('shows the model half of a persisted provider/model tuple', () => {+ expect(getModelLabel('["deepseek-official","deepseek-v4-flash"]', 'Default')).toBe(+ 'deepseek-v4-flash',+ );+ expect(getModelLabel('["gateway","deepseek-v4-pro"]', 'Default')).toBe('deepseek-v4-pro');+ });++ it('keeps plain ids and the default sentinel unchanged', () => {+ expect(getModelLabel('default', 'Default')).toBe('Default');+ expect(getModelLabel('some-plain-model', 'Default')).toBe('some-plain-model');+ expect(getModelLabel('gpt-5.5', 'Default')).toBe('GPT-5.5');+ expect(getModelLabel('claude-opus-4-1', 'Default')).toBe('Opus 4.1');+ });++ it('falls back to the raw value when the tuple is malformed', () => {+ expect(getModelLabel('["only-one-element"]', 'Default')).toBe('["only-one-element"]');+ expect(getModelLabel('[not json', 'Default')).toBe('[not json');+ });+});++describe('getModelOptionDescription', () => {+ it('renders a provider/model tuple as provider/model', () => {+ expect(getModelOptionDescription('["deepseek-official","deepseek-v4-flash"]')).toBe(+ 'deepseek-official/deepseek-v4-flash',+ );+ });++ it('leaves plain ids and malformed tuples untouched', () => {+ expect(getModelOptionDescription('deepseek-v4-flash')).toBe('deepseek-v4-flash');+ expect(getModelOptionDescription('["only-one-element"]')).toBe('["only-one-element"]');+ });+});diff --git a/src/features/ChatInput/ControlBar/HeteroModel/labels.ts b/src/features/ChatInput/ControlBar/HeteroModel/labels.tsindex 6ed16ff04e5..cfb3e826af4 100644--- a/src/features/ChatInput/ControlBar/HeteroModel/labels.ts+++ b/src/features/ChatInput/ControlBar/HeteroModel/labels.ts@@ -1,5 +1,5 @@import type { HeterogeneousAgentMode, HeterogeneousReasoningEffort } from '@lobechat/types';-import { HETEROGENEOUS_AGENT_DEFAULT_SELECTION } from '@lobechat/types';+import { HETEROGENEOUS_AGENT_DEFAULT_SELECTION, parseModelTuple } from '@lobechat/types';import { MODEL_LABELS } from './modelOptions';@@ -41,12 +41,25 @@ export const getEffortLabelKeys = (export const getModeLabelKey = (mode: HeterogeneousAgentMode) => MODE_LABEL_KEYS[mode];+/**+ * Menu description for a catalog option. Synthetic ids (deepseek-harness's+ * `[provider, model]` tuples) read better as `provider/model`; plain ids stay+ * untouched so other catalog providers keep their current copy.+ */+export const getModelOptionDescription = (model: string): string => {+ const tuple = parseModelTuple(model);+ return tuple ? `${tuple.providerId}/${tuple.modelId}` : model;+};+export const getModelLabel = (model: string, defaultLabel: string) => {if (model === HETEROGENEOUS_AGENT_DEFAULT_SELECTION) return defaultLabel;const aliasLabel = MODEL_LABELS[model];if (aliasLabel) return aliasLabel;+ const tuple = parseModelTuple(model);+ if (tuple) return tuple.modelId;+const match = /^claude-(opus|sonnet|haiku)-(\d+)-(\d+)/.exec(model);if (!match) return model;diff --git a/src/features/ChatInput/ControlBar/HeteroModel/selectorView.test.ts b/src/features/ChatInput/ControlBar/HeteroModel/selectorView.test.tsindex d362f3a6f05..4a7e1d4ec19 100644--- a/src/features/ChatInput/ControlBar/HeteroModel/selectorView.test.ts+++ b/src/features/ChatInput/ControlBar/HeteroModel/selectorView.test.ts@@ -57,6 +57,7 @@ describe('resolveSelectorShape', () => {});it('gives catalog-only providers the bare picker', () => {+ expect(resolveSelectorShape({ type: 'deepseek-harness' }, true).kind).toBe('catalog');expect(resolveSelectorShape({ type: 'kimi-code' }, true).kind).toBe('catalog');expect(resolveSelectorShape({ type: 'opencode' }, true).kind).toBe('catalog');expect(resolveSelectorShape({ type: 'pi' }, true).kind).toBe('catalog');