MCPcopy Create free account
hub / github.com/apache/maka / submitCompactToTranscript

Function submitCompactToTranscript

packages/cli/src/pi-transcript.ts:478–509  ·  view source on GitHub ↗
(input: {
  state: MakaPiTranscriptState;
  driver: Pick<MakaSessionDriver, 'compactSession'>;
  onChange?: () => void;
})

Source from the content-addressed store, hash-verified

476}
477
478export async function submitCompactToTranscript(input: {
479 state: MakaPiTranscriptState;
480 driver: Pick<MakaSessionDriver, 'compactSession'>;
481 onChange?: () => void;
482}): Promise<void> {
483 let completed = false;
484 let sawCompactionNotice = false;
485 try {
486 for await (const event of input.driver.compactSession()) {
487 if (event.type === 'token_usage' && contextBudgetOutcomeNotice(event.contextBudget))
488 sawCompactionNotice = true;
489 if (event.type === 'complete' && event.stopReason === 'end_turn') completed = true;
490 applyMakaSessionEventToTranscript(input.state, event);
491 input.onChange?.();
492 }
493 if (completed && !sawCompactionNotice) {
494 input.state.entries.push({
495 kind: 'notice',
496 level: 'info',
497 text: 'Nothing to compact.',
498 });
499 input.onChange?.();
500 }
501 } catch (error) {
502 input.state.entries.push({
503 kind: 'notice',
504 level: 'error',
505 text: error instanceof Error ? error.message : String(error),
506 });
507 input.onChange?.();
508 }
509}
510
511export function applyMakaSessionEventToTranscript(
512 state: MakaPiTranscriptState,

Callers 1

compactSessionFunction · 0.85

Calls 5

onChangeMethod · 0.80
compactSessionMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected