MCPcopy
hub / github.com/coder/mux / finalizeReportedChildTaskForTest

Function finalizeReportedChildTaskForTest

src/node/services/taskService.test.ts:11637–11702  ·  view source on GitHub ↗
(params: {
    historyService: HistoryService;
    partialService: ReturnType<typeof createTaskServiceHarness>["partialService"];
    taskService: TaskService;
    childId: string;
    reportMarkdown: string;
    title: string;
    prompt?: string;
  })

Source from the content-addressed store, hash-verified

11635 }
11636
11637 async function finalizeReportedChildTaskForTest(params: {
11638 historyService: HistoryService;
11639 partialService: ReturnType<typeof createTaskServiceHarness>["partialService"];
11640 taskService: TaskService;
11641 childId: string;
11642 reportMarkdown: string;
11643 title: string;
11644 prompt?: string;
11645 }): Promise<void> {
11646 const childPrompt = createMuxMessage(
11647 `user-${params.childId}-prompt`,
11648 "user",
11649 params.prompt ?? "compare options",
11650 {
11651 timestamp: Date.now(),
11652 }
11653 );
11654 expect((await params.historyService.appendToHistory(params.childId, childPrompt)).success).toBe(
11655 true
11656 );
11657
11658 const childAssistantPlaceholder = createMuxMessage(
11659 `assistant-${params.childId}-partial`,
11660 "assistant",
11661 "",
11662 { timestamp: Date.now() }
11663 );
11664 expect(
11665 (await params.historyService.appendToHistory(params.childId, childAssistantPlaceholder))
11666 .success
11667 ).toBe(true);
11668
11669 const childHistorySequence = childAssistantPlaceholder.metadata?.historySequence;
11670 if (typeof childHistorySequence !== "number") {
11671 throw new Error("Expected child historySequence to be a number");
11672 }
11673
11674 const childPartial = createMuxMessage(
11675 `assistant-${params.childId}-partial`,
11676 "assistant",
11677 "",
11678 { timestamp: Date.now(), historySequence: childHistorySequence },
11679 [
11680 {
11681 type: "dynamic-tool",
11682 toolCallId: `agent-report-${params.childId}`,
11683 toolName: "agent_report",
11684 input: { reportMarkdown: params.reportMarkdown, title: params.title },
11685 state: "output-available",
11686 output: { success: true },
11687 },
11688 ]
11689 );
11690 expect((await params.partialService.writePartial(params.childId, childPartial)).success).toBe(
11691 true
11692 );
11693 expect((await params.partialService.commitPartial(params.childId)).success).toBe(true);
11694

Callers 1

Calls 5

createMuxMessageFunction · 0.90
appendToHistoryMethod · 0.80
writePartialMethod · 0.80
commitPartialMethod · 0.80

Tested by

no test coverage detected