144
});
145
};
147
>
push({
148
>
id: generateUuid(),
149
>
parentId,
150
>
timestamp: nextTimestamp(),
151
>
type: 'session.start',
152
>
data: {
153
>
sessionId: options.sessionId,
154
>
copilotVersion: options.copilotVersion ?? '0.0.0',
155
>
producer: MIGRATION_PRODUCER,
156
>
startTime: nextTimestamp(),
157
>
version: options.schemaVersion ?? DEFAULT_SESSION_EVENT_SCHEMA_VERSION,
158
>
...(options.model ? { selectedModel: options.model } : {}),
159
>
...(options.workingDirectory ? { context: { cwd: options.workingDirectory } } : {}),
160
>
},
161
>
});
162
>
163
>
for (const turn of turns) {
164
>
// Reuse the turn id as the user-message envelope id when it is already a
165
>
// UUID (the runtime rejects non-UUID event ids) so the reconstructed turn
166
>
// keeps the id the SDK's fork/truncate RPCs address and a caller can seed
167
>
// a matching protocol turn; otherwise mint a fresh UUID.
168
>
push({
169
>
id: isUUID(turn.id) ? turn.id : generateUuid(),
170
>
parentId,
171
>
timestamp: nextTimestamp(),
172
>
type: 'user.message',
173
>
data: {
174
>
content: turn.message.text,
175
>
source: 'user',
176
>
},
177
>
});
178
>
179
>
let markdown = '';
180
>
let reasoning = '';
181
>
const flushAssistantMessage = (): void => {
182
>
if (!markdown && !reasoning) {
183
return;
184
}