124
125
const finalizeTurn = (turn: NonNullable<typeof currentTurn>, state: TurnState): void => {
127
>
id: turn.id,
128
>
message: turn.message,
129
>
responseParts: turn.responseParts,
130
>
usage: undefined,
131
>
state,
132
>
});
133
>
};
134
135
const startTurn = (id: string, text: string): NonNullable<typeof currentTurn> => ({
137
>
message: { text, origin: { kind: MessageKind.User } },
138
>
responseParts: [],
139
>
pendingTools: new Map(),
140
>
});
141
142
for (const msg of messages) {
144
>
if (currentTurn) {
145
finalizeTurn(currentTurn, TurnState.Cancelled);
146
}
148
>
} else if (msg.type === 'message' && msg.role === 'assistant') {
149
if (msg.parentToolCallId) {
150
continue;