MCPcopy
hub / github.com/codeaashu/claude-code / removeTeammateFromTeamFile

Function removeTeammateFromTeamFile

src/utils/swarm/teamHelpers.ts:188–227  ·  view source on GitHub ↗
(
  teamName: string,
  identifier: { agentId?: string; name?: string },
)

Source from the content-addressed store, hash-verified

186 * Used by the leader when processing shutdown approvals.
187 */
188export function removeTeammateFromTeamFile(
189 teamName: string,
190 identifier: { agentId?: string; name?: string },
191): boolean {
192 const identifierStr = identifier.agentId || identifier.name
193 if (!identifierStr) {
194 logForDebugging(
195 '[TeammateTool] removeTeammateFromTeamFile called with no identifier',
196 )
197 return false
198 }
199
200 const teamFile = readTeamFile(teamName)
201 if (!teamFile) {
202 logForDebugging(
203 `[TeammateTool] Cannot remove teammate ${identifierStr}: failed to read team file for "${teamName}"`,
204 )
205 return false
206 }
207
208 const originalLength = teamFile.members.length
209 teamFile.members = teamFile.members.filter(m => {
210 if (identifier.agentId && m.agentId === identifier.agentId) return false
211 if (identifier.name && m.name === identifier.name) return false
212 return true
213 })
214
215 if (teamFile.members.length === originalLength) {
216 logForDebugging(
217 `[TeammateTool] Teammate ${identifierStr} not found in team file for "${teamName}"`,
218 )
219 return false
220 }
221
222 writeTeamFile(teamName, teamFile)
223 logForDebugging(
224 `[TeammateTool] Removed teammate from team file: ${identifierStr}`,
225 )
226 return true
227}
228
229/**
230 * Adds a pane ID to the hidden panes list in the team file.

Callers 3

runFunction · 0.85
useInboxPollerFunction · 0.85

Calls 3

logForDebuggingFunction · 0.85
readTeamFileFunction · 0.85
writeTeamFileFunction · 0.85

Tested by

no test coverage detected