diff --git a/src/gateway/server-close.ts b/src/gateway/server-close.ts index da9f5a39e..9016aa343 100644 --- a/src/gateway/server-close.ts +++ b/src/gateway/server-close.ts @@ -21,6 +21,7 @@ export function createGatewayCloseHandler(params: { healthInterval: ReturnType; dedupeCleanup: ReturnType; agentUnsub: (() => void) | null; + execUnsub: (() => void) | null; heartbeatUnsub: (() => void) | null; chatRunState: { clear: () => void }; clients: Set<{ socket: { close: (code: number, reason: string) => void } }>; @@ -88,6 +89,13 @@ export function createGatewayCloseHandler(params: { /* ignore */ } } + if (params.execUnsub) { + try { + params.execUnsub(); + } catch { + /* ignore */ + } + } if (params.heartbeatUnsub) { try { params.heartbeatUnsub(); diff --git a/src/gateway/server-methods-list.ts b/src/gateway/server-methods-list.ts index 098384d44..6a9740b52 100644 --- a/src/gateway/server-methods-list.ts +++ b/src/gateway/server-methods-list.ts @@ -108,4 +108,7 @@ export const GATEWAY_EVENTS = [ "voicewake.changed", "exec.approval.requested", "exec.approval.resolved", + "exec.started", + "exec.output", + "exec.completed", ]; diff --git a/src/gateway/server.impl.ts b/src/gateway/server.impl.ts index f641c4076..fbc681a43 100644 --- a/src/gateway/server.impl.ts +++ b/src/gateway/server.impl.ts @@ -17,6 +17,7 @@ import { isDiagnosticsEnabled } from "../infra/diagnostic-events.js"; import { logAcceptedEnvOption } from "../infra/env.js"; import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js"; import { clearAgentRunContext, onAgentEvent } from "../infra/agent-events.js"; +import { onExecEvent } from "../infra/exec-events.js"; import { onHeartbeatEvent } from "../infra/heartbeat-events.js"; import { startHeartbeatRunner } from "../infra/heartbeat-runner.js"; import { getMachineDisplayName } from "../infra/machine-name.js"; @@ -402,6 +403,10 @@ export async function startGatewayServer( }), ); + const execUnsub = onExecEvent((evt) => { + broadcast(evt.event, evt, { dropIfSlow: true }); + }); + const heartbeatUnsub = onHeartbeatEvent((evt) => { broadcast("heartbeat", evt, { dropIfSlow: true }); }); @@ -559,6 +564,7 @@ export async function startGatewayServer( healthInterval, dedupeCleanup, agentUnsub, + execUnsub, heartbeatUnsub, chatRunState, clients,