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>;
|
healthInterval: ReturnType<typeof setInterval>;
|
||||||
dedupeCleanup: ReturnType<typeof setInterval>;
|
dedupeCleanup: ReturnType<typeof setInterval>;
|
||||||
agentUnsub: (() => void) | null;
|
agentUnsub: (() => void) | null;
|
||||||
|
execUnsub: (() => void) | null;
|
||||||
heartbeatUnsub: (() => void) | null;
|
heartbeatUnsub: (() => void) | null;
|
||||||
chatRunState: { clear: () => void };
|
chatRunState: { clear: () => void };
|
||||||
clients: Set<{ socket: { close: (code: number, reason: string) => void } }>;
|
clients: Set<{ socket: { close: (code: number, reason: string) => void } }>;
|
||||||
@ -88,6 +89,13 @@ export function createGatewayCloseHandler(params: {
|
|||||||
/* ignore */
|
/* ignore */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (params.execUnsub) {
|
||||||
|
try {
|
||||||
|
params.execUnsub();
|
||||||
|
} catch {
|
||||||
|
/* ignore */
|
||||||
|
}
|
||||||
|
}
|
||||||
if (params.heartbeatUnsub) {
|
if (params.heartbeatUnsub) {
|
||||||
try {
|
try {
|
||||||
params.heartbeatUnsub();
|
params.heartbeatUnsub();
|
||||||
|
|||||||
@ -108,4 +108,7 @@ export const GATEWAY_EVENTS = [
|
|||||||
"voicewake.changed",
|
"voicewake.changed",
|
||||||
"exec.approval.requested",
|
"exec.approval.requested",
|
||||||
"exec.approval.resolved",
|
"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 { logAcceptedEnvOption } from "../infra/env.js";
|
||||||
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
||||||
import { clearAgentRunContext, onAgentEvent } from "../infra/agent-events.js";
|
import { clearAgentRunContext, onAgentEvent } from "../infra/agent-events.js";
|
||||||
|
import { onExecEvent } from "../infra/exec-events.js";
|
||||||
import { onHeartbeatEvent } from "../infra/heartbeat-events.js";
|
import { onHeartbeatEvent } from "../infra/heartbeat-events.js";
|
||||||
import { startHeartbeatRunner } from "../infra/heartbeat-runner.js";
|
import { startHeartbeatRunner } from "../infra/heartbeat-runner.js";
|
||||||
import { getMachineDisplayName } from "../infra/machine-name.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) => {
|
const heartbeatUnsub = onHeartbeatEvent((evt) => {
|
||||||
broadcast("heartbeat", evt, { dropIfSlow: true });
|
broadcast("heartbeat", evt, { dropIfSlow: true });
|
||||||
});
|
});
|
||||||
@ -559,6 +564,7 @@ export async function startGatewayServer(
|
|||||||
healthInterval,
|
healthInterval,
|
||||||
dedupeCleanup,
|
dedupeCleanup,
|
||||||
agentUnsub,
|
agentUnsub,
|
||||||
|
execUnsub,
|
||||||
heartbeatUnsub,
|
heartbeatUnsub,
|
||||||
chatRunState,
|
chatRunState,
|
||||||
clients,
|
clients,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user