(handoff: string)
| 12 | * Callers fall back to `Run.git.branches[]` then `s.branch`. |
| 13 | */ |
| 14 | export function parseHandoffBranch(handoff: string): string | null { |
| 15 | const match = /^##\s+Branch\s*\r?\n([^\r\n]*)/m.exec(handoff); |
| 16 | if (!match) return null; |
| 17 | const raw = match[1].trim(); |
| 18 | if (raw.length === 0) return null; |
| 19 | if (raw.startsWith("##")) return null; |
| 20 | // Worker template wraps the value in backticks (`agent/foo-abc1`); the |
| 21 | // operator-facing hint also tolerates a bare branch name. |
| 22 | const unwrapped = raw.replace(/^`([^`]+)`$/, "$1").trim(); |
| 23 | if (unwrapped.length === 0) return null; |
| 24 | if (/^\(no branch\)$/i.test(unwrapped)) return null; |
| 25 | return unwrapped; |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Precedence used by `waitAndHandoff`: `## Branch` line wins (SDK leaves |
no outgoing calls
no test coverage detected