(content: unknown)
| 633 | } |
| 634 | |
| 635 | function contentShapeForHash(content: unknown): unknown { |
| 636 | if (typeof content === 'string') { |
| 637 | return { type: 'text', chars: content.length }; |
| 638 | } |
| 639 | if (Array.isArray(content)) { |
| 640 | return content.map((part) => { |
| 641 | if (!isObjectLike(part)) return { type: typeof part }; |
| 642 | const type = typeof part.type === 'string' ? part.type : 'unknown'; |
| 643 | return { |
| 644 | type, |
| 645 | ...(typeof part.toolName === 'string' ? { toolName: part.toolName } : {}), |
| 646 | ...(typeof part.toolCallId === 'string' ? { toolCallId: part.toolCallId } : {}), |
| 647 | ...(typeof part.text === 'string' ? { chars: part.text.length } : {}), |
| 648 | ...('output' in part ? { output: payloadShapeForHash(part.output) } : {}), |
| 649 | }; |
| 650 | }); |
| 651 | } |
| 652 | return { type: typeof content }; |
| 653 | } |
| 654 | |
| 655 | function payloadShapeForHash(value: unknown): unknown { |
| 656 | const serialized = stableStringify(value); |
no test coverage detected