MCPcopy Index your code
hub / github.com/codeaashu/claude-code / handleBroadcast

Function handleBroadcast

src/tools/SendMessageTool/SendMessageTool.ts:191–266  ·  view source on GitHub ↗
(
  content: string,
  summary: string | undefined,
  context: ToolUseContext,
)

Source from the content-addressed store, hash-verified

189}
190
191async function handleBroadcast(
192 content: string,
193 summary: string | undefined,
194 context: ToolUseContext,
195): Promise<{ data: BroadcastOutput }> {
196 const appState = context.getAppState()
197 const teamName = getTeamName(appState.teamContext)
198
199 if (!teamName) {
200 throw new Error(
201 'Not in a team context. Create a team with Teammate spawnTeam first, or set CLAUDE_CODE_TEAM_NAME.',
202 )
203 }
204
205 const teamFile = await readTeamFileAsync(teamName)
206 if (!teamFile) {
207 throw new Error(`Team "${teamName}" does not exist`)
208 }
209
210 const senderName =
211 getAgentName() || (isTeammate() ? 'teammate' : TEAM_LEAD_NAME)
212 if (!senderName) {
213 throw new Error(
214 'Cannot broadcast: sender name is required. Set CLAUDE_CODE_AGENT_NAME.',
215 )
216 }
217
218 const senderColor = getTeammateColor()
219
220 const recipients: string[] = []
221 for (const member of teamFile.members) {
222 if (member.name.toLowerCase() === senderName.toLowerCase()) {
223 continue
224 }
225 recipients.push(member.name)
226 }
227
228 if (recipients.length === 0) {
229 return {
230 data: {
231 success: true,
232 message: 'No teammates to broadcast to (you are the only team member)',
233 recipients: [],
234 },
235 }
236 }
237
238 for (const recipientName of recipients) {
239 await writeToMailbox(
240 recipientName,
241 {
242 from: senderName,
243 text: content,
244 summary,
245 timestamp: new Date().toISOString(),
246 color: senderColor,
247 },
248 teamName,

Callers 1

callFunction · 0.85

Calls 7

getTeamNameFunction · 0.85
readTeamFileAsyncFunction · 0.85
getAgentNameFunction · 0.85
isTeammateFunction · 0.85
writeToMailboxFunction · 0.85
getTeammateColorFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected