| 1 | import { assert } from "@effect/vitest"; |
| 2 | import type { ProviderReplayTranscript } from "@t3tools/contracts"; |
| 3 | |
| 4 | import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts"; |
| 5 | import { |
| 6 | assertAssistantTextIncludes, |
| 7 | assertBaseProjection, |
| 8 | assertConversationMessageRoles, |
| 9 | assertRunOrdinals, |
| 10 | assertSemanticProjectionIntegrity, |
| 11 | assertTurnItemTypes, |
| 12 | assertUserMessagesInclude, |
| 13 | assertVisibleTurnItemsMirrorLocalTurnItems, |
| 14 | MULTI_TURN_FIRST_PROMPT, |
| 15 | MULTI_TURN_SECOND_PROMPT, |
| 16 | projectionFor, |
| 17 | } from "../shared.ts"; |
| 18 | |
| 19 | export function assertMultiTurnOutput( |
| 20 | result: OrchestratorV2ScenarioResult, |
| 21 | transcript: ProviderReplayTranscript, |
| 22 | ) { |
| 23 | assertBaseProjection({ |
| 24 | result, |
| 25 | transcript, |
| 26 | runCount: 2, |
| 27 | runStatuses: ["completed", "completed"], |
| 28 | }); |
| 29 | |
| 30 | const projection = projectionFor(result, transcript.scenario); |
| 31 | assertSemanticProjectionIntegrity(projection); |
| 32 | assertVisibleTurnItemsMirrorLocalTurnItems(projection); |
| 33 | assertRunOrdinals(projection, [1, 2]); |
| 34 | assertConversationMessageRoles(projection, ["user", "assistant", "user", "assistant"]); |
| 35 | assertTurnItemTypes(projection, ["user_message", "assistant_message"]); |
| 36 | assertUserMessagesInclude(projection, [MULTI_TURN_FIRST_PROMPT, MULTI_TURN_SECOND_PROMPT]); |
| 37 | assert.equal(projection.turnItems.filter((item) => item.type === "user_message").length, 2); |
| 38 | assertAssistantTextIncludes(projection, "first fixture turn complete"); |
| 39 | assertAssistantTextIncludes(projection, "second fixture turn complete"); |
| 40 | } |