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