* Extract the selection reason from multi-prompt agent's set_output block. * set_output wraps data in a 'data' property, so we need to access input.data.reason
( blocks: ContentBlock[] | undefined, )
| 709 | * set_output wraps data in a 'data' property, so we need to access input.data.reason |
| 710 | */ |
| 711 | function extractSelectionReason( |
| 712 | blocks: ContentBlock[] | undefined, |
| 713 | ): string | null { |
| 714 | if (!blocks || blocks.length === 0) return null |
| 715 | |
| 716 | const setOutputBlock = blocks.find( |
| 717 | (block): block is ToolContentBlock => |
| 718 | block.type === 'tool' && |
| 719 | block.toolName === 'set_output' && |
| 720 | hasSetOutputData(block.input) && |
| 721 | typeof block.input.data?.reason === 'string', |
| 722 | ) |
| 723 | |
| 724 | if (!setOutputBlock || !hasSetOutputData(setOutputBlock.input)) { |
| 725 | return null |
| 726 | } |
| 727 | |
| 728 | return setOutputBlock.input.data?.reason ?? null |
| 729 | } |
| 730 | |
| 731 | /** |
| 732 | * Generate a progress-focused preview string for multi-prompt editor. |
no test coverage detected