| 319 | // Returns null when the sentinel is absent — callers treat null as a normal |
| 320 | // user rejection (scanner falls through to { kind: 'rejected' }). |
| 321 | function extractTeleportPlan( |
| 322 | content: ToolResultBlockParam['content'], |
| 323 | ): string | null { |
| 324 | const text = contentToText(content) |
| 325 | const marker = `${ULTRAPLAN_TELEPORT_SENTINEL}\n` |
| 326 | const idx = text.indexOf(marker) |
| 327 | if (idx === -1) return null |
| 328 | return text.slice(idx + marker.length).trimEnd() |
| 329 | } |
| 330 | |
| 331 | // Plan is echoed in tool_result content as "## Approved Plan:\n<text>" or |
| 332 | // "## Approved Plan (edited by user):\n<text>" (ExitPlanModeV2Tool). |