All files / lib/os/neurals/orchestrator dialog.orchestrator.ts

0% Statements 0/43
0% Branches 0/1
0% Functions 0/1
0% Lines 0/43

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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58                                                                                                                   
import { parseIntent } from './dialog.types';
import { enqueue, flush } from './toolcalls.queue';
 
export async function handleTranscript(
  text: string,
  ctx: {
    lastInsight?: any;
    pin?: (i: any) => void;
    openSummary?: () => void;
    closeSummary?: () => void;
    exportFns?: {
      logsCSV: () => void;
      logsJSON: () => void;
      pinsCSV: () => void;
      pinsPDF: () => void;
    };
    snapshotFns?: { start: () => void; stop: () => void };
  }
) {
  const intent = parseIntent(text);
  if (!intent) return { reply: 'Say: help' };
 
  switch (intent.kind) {
    case 'PIN':
      enqueue({ type: 'PIN_INSIGHT', payload: { insight: ctx.lastInsight } });
      break;
    case 'OPEN_SUMMARY':
      ctx.openSummary?.();
      break;
    case 'CLOSE_SUMMARY':
      ctx.closeSummary?.();
      break;
    case 'EXPORT_LOGS_CSV':
      ctx.exportFns?.logsCSV();
      break;
    case 'EXPORT_LOGS_JSON':
      ctx.exportFns?.logsJSON();
      break;
    case 'EXPORT_CSV':
      ctx.exportFns?.pinsCSV();
      break;
    case 'EXPORT_PDF':
      ctx.exportFns?.pinsPDF();
      break;
    case 'AUTO_START':
      ctx.snapshotFns?.start();
      break;
    case 'AUTO_STOP':
      ctx.snapshotFns?.stop();
      break;
    case 'HELP':
    default:
      break;
  }
  await flush(ctx);
  return { reply: intent.reply || 'Done.' };
}