Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 7x 7x 7x 8x 8x 19x 1x 1x 18x 18x | import { Injectable, Logger } from '@nestjs/common';
import { PostExecutionHook } from './post-execution-hook.interface';
import { PlanExecutionContext } from '../llm-orchestration.interfaces';
import { SessionInput } from '../../core-entities';
import { EventsGateway } from '../../events/events.gateway';
@Injectable()
export class FrontendNotificationHook implements PostExecutionHook {
private readonly logger = new Logger(FrontendNotificationHook.name);
constructor(private readonly eventsGateway: EventsGateway) {}
async run(
sessionInput: SessionInput,
context: PlanExecutionContext,
): Promise<void> {
// If another hook has already initiated a follow-up action (like starting a
// new AI turn), we should not notify the frontend that a plan is ready.
if (context.flags.follow_up_initiated) {
this.logger.log(
'Skipping frontend notification because a follow-up action was initiated.',
);
return;
}
this.logger.log('Notifying frontend that plan is ready for review.');
this.eventsGateway.sendToAll('plan-ready', {
sessionId: sessionInput.session_id,
sessionInputId: sessionInput.id,
});
}
}
|