mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-07 06:52:28 +00:00
refactor: unify MCP bridge setup and system prompt delivery
Extract duplicate MCP bridge initialization code from codexLocalLauncher and codexRemoteLauncher into a new buildHapiMcpBridge utility. This ensures both modes use identical server setup logic and provides a single source of truth for MCP configuration. Update codexStartConfig to deliver system prompt via developer_instructions instead of appending to the user message. This ensures consistent behavior between local and remote modes and properly separates system guidance from user intent.
This commit is contained in:
@@ -5,8 +5,7 @@ import { Future } from '@/utils/future';
|
||||
import { createCodexSessionScanner } from './utils/codexSessionScanner';
|
||||
import { convertCodexEvent } from './utils/codexEventConverter';
|
||||
import { getLocalLaunchExitReason } from '@/agent/localLaunchPolicy';
|
||||
import { startHappyServer } from '@/claude/utils/startHappyServer';
|
||||
import { getHappyCliCommand } from '@/utils/spawnHappyCLI';
|
||||
import { buildHapiMcpBridge } from './utils/buildHapiMcpBridge';
|
||||
|
||||
export async function codexLocalLauncher(session: CodexSession): Promise<'switch' | 'exit'> {
|
||||
let exitReason: 'switch' | 'exit' | null = null;
|
||||
@@ -14,14 +13,7 @@ export async function codexLocalLauncher(session: CodexSession): Promise<'switch
|
||||
const exitFuture = new Future<void>();
|
||||
|
||||
// Start hapi server for MCP bridge (same as remote mode)
|
||||
const happyServer = await startHappyServer(session.client);
|
||||
const bridgeCommand = getHappyCliCommand(['mcp', '--url', happyServer.url]);
|
||||
const mcpServers = {
|
||||
hapi: {
|
||||
command: bridgeCommand.command,
|
||||
args: bridgeCommand.args
|
||||
}
|
||||
};
|
||||
const { server: happyServer, mcpServers } = await buildHapiMcpBridge(session.client);
|
||||
logger.debug(`[codex-local]: Started hapi MCP bridge server at ${happyServer.url}`);
|
||||
|
||||
const handleSessionMatchFailed = (message: string) => {
|
||||
|
||||
Reference in New Issue
Block a user