* Get team context attachment for teammates in a swarm. * Only injected on the first turn to provide team coordination instructions.
(messages: Message[])
| 3773 | * Only injected on the first turn to provide team coordination instructions. |
| 3774 | */ |
| 3775 | function getTeamContextAttachment(messages: Message[]): Attachment[] { |
| 3776 | const teamName = getTeamName() |
| 3777 | const agentId = getAgentId() |
| 3778 | const agentName = getAgentName() |
| 3779 | |
| 3780 | // Only inject for teammates (not team lead or non-team sessions) |
| 3781 | if (!teamName || !agentId) { |
| 3782 | return [] |
| 3783 | } |
| 3784 | |
| 3785 | // Only inject on first turn - check if there are no assistant messages yet |
| 3786 | const hasAssistantMessage = messages.some(m => m.type === 'assistant') |
| 3787 | if (hasAssistantMessage) { |
| 3788 | return [] |
| 3789 | } |
| 3790 | |
| 3791 | const configDir = getClaudeConfigHomeDir() |
| 3792 | const teamConfigPath = `${configDir}/teams/${teamName}/config.json` |
| 3793 | const taskListPath = `${configDir}/tasks/${teamName}/` |
| 3794 | |
| 3795 | return [ |
| 3796 | { |
| 3797 | type: 'team_context', |
| 3798 | agentId, |
| 3799 | agentName: agentName || agentId, |
| 3800 | teamName, |
| 3801 | teamConfigPath, |
| 3802 | taskListPath, |
| 3803 | }, |
| 3804 | ] |
| 3805 | } |
| 3806 | |
| 3807 | function getTokenUsageAttachment( |
| 3808 | messages: Message[], |
no test coverage detected