(
teamContext:
| {
leadAgentId: string
}
| undefined,
)
| 169 | * @returns true if this session is the team lead |
| 170 | */ |
| 171 | export function isTeamLead( |
| 172 | teamContext: |
| 173 | | { |
| 174 | leadAgentId: string |
| 175 | } |
| 176 | | undefined, |
| 177 | ): boolean { |
| 178 | if (!teamContext?.leadAgentId) { |
| 179 | return false |
| 180 | } |
| 181 | |
| 182 | // Use getAgentId() for AsyncLocalStorage support (in-process teammates) |
| 183 | const myAgentId = getAgentId() |
| 184 | const leadAgentId = teamContext.leadAgentId |
| 185 | |
| 186 | // If my agent ID matches the lead agent ID, I'm the lead |
| 187 | if (myAgentId === leadAgentId) { |
| 188 | return true |
| 189 | } |
| 190 | |
| 191 | // Backwards compat: if no agent ID is set and we have a team context, |
| 192 | // this is the original session that created the team (the lead) |
| 193 | if (!myAgentId) { |
| 194 | return true |
| 195 | } |
| 196 | |
| 197 | return false |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Checks if there are any active in-process teammates running. |
no test coverage detected