π€― 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(desktop): route gateway agent runs through lh hetero exec (#15132)
Arvin Xu0fa2e2349c22
diff --git a/apps/desktop/src/main/controllers/GatewayConnectionCtr.ts b/apps/desktop/src/main/controllers/GatewayConnectionCtr.tsindex d9382201a18..f0613cb1043 100644--- a/apps/desktop/src/main/controllers/GatewayConnectionCtr.ts+++ b/apps/desktop/src/main/controllers/GatewayConnectionCtr.ts@@ -172,36 +172,25 @@ export default class GatewayConnectionCtr extends ControllerModule {request: AgentRunRequestMessage,): Promise<{ reason?: string; status: 'accepted' | 'rejected' }> {try {- const ctr = this.heterogeneousAgentCtr;-- // Map agentType to binary name.- // claude-code β `claude` CLI; all other platforms use their type name as the binary.- const command = request.agentType === 'claude-code' ? 'claude' : request.agentType;+ const serverUrl = await this.remoteServerConfigCtr.getRemoteServerUrl();+ if (!serverUrl) {+ return { reason: 'Remote server URL not configured', status: 'rejected' };+ }- // Create a session for the hetero agent.- const { sessionId } = await ctr.startSession({+ // Fire-and-forget: lh hetero exec handles spawn -> adapt ->+ // BatchIngester -> heteroIngest/heteroFinish -> server -> Gateway -> clients.+ // Same command as spawnHeteroSandbox() on the server side.+ this.heterogeneousAgentCtr.spawnLhHeteroExec({agentType: request.agentType,- args: [],- command,cwd: request.cwd,- // Inject LOBEHUB_JWT so the CLI authenticates against heteroIngest.- env: { LOBEHUB_JWT: request.jwt },+ jwt: request.jwt,+ operationId: request.operationId,+ prompt: request.prompt,resumeSessionId: request.resumeSessionId,+ serverUrl,+ topicId: request.topicId,});- // Fire-and-forget: sendPrompt runs the CLI until completion.- ctr- .sendPrompt({- operationId: request.operationId,- prompt: request.prompt,- sessionId,- })- .catch((err: Error) => {- // Errors are surfaced via heteroFinish on the server side.- // Log locally for desktop debugging only.- console.error('[GatewayConnectionCtr] agent run failed:', err.message);- });-return { status: 'accepted' };} catch (err) {const reason = err instanceof Error ? err.message : String(err);diff --git a/apps/desktop/src/main/controllers/HeterogeneousAgentCtr.ts b/apps/desktop/src/main/controllers/HeterogeneousAgentCtr.tsindex 6b6cf540af8..f0282ebc1b5 100644--- a/apps/desktop/src/main/controllers/HeterogeneousAgentCtr.ts+++ b/apps/desktop/src/main/controllers/HeterogeneousAgentCtr.ts@@ -1251,4 +1251,69 @@ export default class HeterogeneousAgentCtr extends ControllerModule {process.on('SIGTERM', onSignal);process.on('SIGINT', onSignal);}++ /**+ * Spawn `lh hetero exec` for gateway-driven agent runs.+ * The `lh` CLI handles everything downstream β no local+ * AgentStreamPipeline or IPC broadcast needed. Mirrors+ * `spawnHeteroSandbox()` on the server side.+ */+ spawnLhHeteroExec(params: {+ agentType: string;+ cwd?: string;+ jwt: string;+ operationId: string;+ prompt: string;+ resumeSessionId?: string;+ serverUrl: string;+ topicId: string;+ }): void {+ const { agentType, cwd, jwt, operationId, prompt, resumeSessionId, serverUrl, topicId } =+ params;+ const workDir = cwd ?? process.cwd();++ const args = [+ 'hetero',+ 'exec',+ '--type',+ agentType,+ '--operation-id',+ operationId,+ '--topic',+ topicId,+ '--render',+ 'none',+ '--input-json',+ '-',+ '--cwd',+ workDir,+ ...(resumeSessionId ? ['--resume', resumeSessionId] : []),+ ];++ const env = {+ ...process.env,+ ...buildProxyEnv(this.app.storeManager.get('networkProxy')),+ LOBEHUB_JWT: jwt,+ LOBEHUB_SERVER: serverUrl,+ };++ logger.info('spawnLhHeteroExec: type=%s op=%s topic=%s', agentType, operationId, topicId);++ const child = spawn('lh', args, {+ cwd: workDir,+ env,+ stdio: ['pipe', 'inherit', 'inherit'],+ });++ child.stdin.write(JSON.stringify(prompt));+ child.stdin.end();++ child.on('error', (err) => {+ logger.error('spawnLhHeteroExec: spawn failed β %s', err.message);+ });++ child.on('exit', (code, signal) => {+ logger.info('spawnLhHeteroExec: exited β op=%s code=%s signal=%s', operationId, code, signal);+ });+ }}