476
* semantics per CONTEXT M7 glossary.
477
*/
478
>
function readUserContent(raw: unknown): string | ReadonlyArray<UserTextBlock | UserToolResultBlock> | undefined {
claudeReplayMapper.ts
479
>
if (raw === null || typeof raw !== 'object') {
480
return undefined;
481
}
483
>
if (typeof content === 'string') {
484
return content.length > 0 ? content : undefined;
485
}
487
return undefined;
488
}
490
>
for (const block of content) {
491
>
if (block === null || typeof block !== 'object') {
492
continue;
493
}
494
>
const b = block as { type?: unknown; text?: unknown; tool_use_id?: unknown; content?: unknown; is_error?: unknown };
claudeReplayMapper.ts
495
>
if (b.type === 'text' && typeof b.text === 'string') {
496
out.push({ type: 'text', text: b.text });
498
out.push({ type: 'tool_result', tool_use_id: b.tool_use_id, content: b.content, is_error: b.is_error === true });
499
}
501
>
return out.length > 0 ? out : undefined;
502
>
}
503
504
>
function readAssistantBlocks(raw: unknown): readonly AssistantBlock[] | undefined {
claudeReplayMapper.ts
505
>
if (raw === null || typeof raw !== 'object') {
506
return undefined;
507
}
509
>
if (!Array.isArray(content)) {
510
return undefined;
511
}
513
>
for (const block of content) {
514
>
if (block === null || typeof block !== 'object') {
515
continue;
516
}
517
>
const b = block as { type?: unknown; text?: unknown; thinking?: unknown; id?: unknown; name?: unknown; input?: unknown };
claudeReplayMapper.ts
518
>
if (typeof b.type !== 'string') {
519
continue;
520
}
522
>
type: b.type,
523
>
text: typeof b.text === 'string' ? b.text : undefined,
524
>
thinking: typeof b.thinking === 'string' ? b.thinking : undefined,
525
>
id: typeof b.id === 'string' ? b.id : undefined,
526
>
name: typeof b.name === 'string' ? b.name : undefined,
527
>
input: b.input,
528
>
});
529
>
}
530
>
return out;
531
>
}
532
533
function readSystemSubtype(raw: unknown): string | undefined {