feat(exec-events): bead-6 - broadcast exec events
This commit is contained in:
parent
ecfa976280
commit
17f0799835
@ -21,6 +21,7 @@ export function createGatewayCloseHandler(params: {
|
||||
healthInterval: ReturnType<typeof setInterval>;
|
||||
dedupeCleanup: ReturnType<typeof setInterval>;
|
||||
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();
|
||||
|
||||
@ -108,4 +108,7 @@ export const GATEWAY_EVENTS = [
|
||||
"voicewake.changed",
|
||||
"exec.approval.requested",
|
||||
"exec.approval.resolved",
|
||||
"exec.started",
|
||||
"exec.output",
|
||||
"exec.completed",
|
||||
];
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user