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

Function finalizeChildReport

src/node/services/taskService.test.ts:12251–12302  ·  view source on GitHub ↗
(
      childId: string,
      reportMarkdown: string,
      title: string
    )

Source from the content-addressed store, hash-verified

12249 expect((await partialService.writePartial(parentId, parentPartial)).success).toBe(true);
12250
12251 async function finalizeChildReport(
12252 childId: string,
12253 reportMarkdown: string,
12254 title: string
12255 ): Promise<void> {
12256 const childPrompt = createMuxMessage(`user-${childId}-prompt`, "user", "compare options", {
12257 timestamp: Date.now(),
12258 });
12259 expect((await historyService.appendToHistory(childId, childPrompt)).success).toBe(true);
12260
12261 const childAssistantPlaceholder = createMuxMessage(
12262 `assistant-${childId}-partial`,
12263 "assistant",
12264 "",
12265 { timestamp: Date.now() }
12266 );
12267 expect(
12268 (await historyService.appendToHistory(childId, childAssistantPlaceholder)).success
12269 ).toBe(true);
12270
12271 const childHistorySequence = childAssistantPlaceholder.metadata?.historySequence;
12272 if (typeof childHistorySequence !== "number") {
12273 throw new Error("Expected child historySequence to be a number");
12274 }
12275
12276 const childPartial = createMuxMessage(
12277 `assistant-${childId}-partial`,
12278 "assistant",
12279 "",
12280 { timestamp: Date.now(), historySequence: childHistorySequence },
12281 [
12282 {
12283 type: "dynamic-tool",
12284 toolCallId: `agent-report-${childId}`,
12285 toolName: "agent_report",
12286 input: { reportMarkdown, title },
12287 state: "output-available",
12288 output: { success: true },
12289 },
12290 ]
12291 );
12292 expect((await partialService.writePartial(childId, childPartial)).success).toBe(true);
12293 expect((await partialService.commitPartial(childId)).success).toBe(true);
12294
12295 await handleTaskServiceStreamEndForTest(taskService, {
12296 type: "stream-end",
12297 workspaceId: childId,
12298 messageId: `assistant-${childId}-partial`,
12299 metadata: { model: "test-model" },
12300 parts: childPartial.parts as StreamEndEvent["parts"],
12301 });
12302 }
12303
12304 await finalizeChildReport(childOneId, "Report from child one", "Option one");
12305 const parentHistoryBeforeInterrupt = await collectFullHistory(historyService, parentId);

Callers 1

Calls 5

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

Tested by

no test coverage detected