fix(cli): stamp and reap orphan HAPI MCP bridge helpers (#2004)

* fix(cli): stamp and reap orphan HAPI MCP bridge helpers

MCP stdio bridges survive agent-root death (OOM / partial kills) and
were invisible to #1911 argv orphan reap. Stamp --hapi-session-id on
bridge spawn and match mcp --url helpers in orphanReap.

Fixes #2003

Co-authored-by: Cursor <cursoragent@cursor.com>

* fix(cli): use ApiSessionClient.sessionId for MCP bridge stamp

bootstrapSession returns ApiSessionClient directly; session.client was a
typecheck failure that broke CI typecheck:cli on #2004.

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore: retrigger Codex PR review after 503 infra failure

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
HeavyGee
2026-10-12 21:58:57 +01:00
committed by GitHub
co-authored by Cursor
parent eca9e99331
commit c3e33835c3
7 changed files with 93 additions and 12 deletions
+12 -2
View File
@@ -71,7 +71,9 @@ describe('buildHapiMcpBridge skill lookup config', () => {
'--url',
'http://127.0.0.1:43006/',
'--tools',
'change_title,display_image,display_video,display_media,list_peers,ping_peer,inspect_peer,skill_lookup'
'change_title,display_image,display_video,display_media,list_peers,ping_peer,inspect_peer,skill_lookup',
'--hapi-session-id',
'hub-session-1',
])
expect(bridge.mcpServers.hapi.tools).toEqual({
change_title: { approval_mode: 'approve' },
@@ -86,7 +88,15 @@ describe('buildHapiMcpBridge skill lookup config', () => {
it('does not expose skill_lookup for native-skill bridge callers', async () => {
const bridge = await buildHapiMcpBridge(createClient())
expect(harness.cliArgs.at(-1)).toBe('change_title,display_image,display_video,display_media,list_peers,ping_peer,inspect_peer')
expect(harness.cliArgs).toEqual([
'mcp',
'--url',
'http://127.0.0.1:43006/',
'--tools',
'change_title,display_image,display_video,display_media,list_peers,ping_peer,inspect_peer',
'--hapi-session-id',
'hub-session-1',
])
expect(bridge.mcpServers.hapi.tools).toEqual({
change_title: { approval_mode: 'approve' },
display_image: { approval_mode: 'prompt' },
+5 -1
View File
@@ -84,12 +84,16 @@ export async function buildHapiMcpBridge(
enableChangeTitle: options.enableChangeTitle,
skillLookup: options.skillLookup
});
// Stamp the hub row id so orphanReap can find MCP helpers after the agent
// root dies without a full tree kill (#2003 / #1911 follow-up).
const bridgeCommand = getHappyCliCommand([
'mcp',
'--url',
happyServer.url,
'--tools',
happyServer.toolNames.join(',')
happyServer.toolNames.join(','),
'--hapi-session-id',
client.sessionId,
]);
const tools: Record<string, McpServerToolConfig> = {
display_image: {