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

Function call

src/tools/TeamDeleteTool/TeamDeleteTool.ts:71–135  ·  view source on GitHub ↗
(_input, context)

Source from the content-addressed store, hash-verified

69 },
70
71 async call(_input, context) {
72 const { setAppState, getAppState } = context
73 const appState = getAppState()
74 const teamName = appState.teamContext?.teamName
75
76 if (teamName) {
77 // Read team config to check for active members
78 const teamFile = readTeamFile(teamName)
79 if (teamFile) {
80 // Filter out the team lead - only count non-lead members
81 const nonLeadMembers = teamFile.members.filter(
82 m => m.name !== TEAM_LEAD_NAME,
83 )
84
85 // Separate truly active members from idle/dead ones
86 // Members with isActive === false are idle (finished their turn or crashed)
87 const activeMembers = nonLeadMembers.filter(m => m.isActive !== false)
88
89 if (activeMembers.length > 0) {
90 const memberNames = activeMembers.map(m => m.name).join(', ')
91 return {
92 data: {
93 success: false,
94 message: `Cannot cleanup team with ${activeMembers.length} active member(s): ${memberNames}. Use requestShutdown to gracefully terminate teammates first.`,
95 team_name: teamName,
96 },
97 }
98 }
99 }
100
101 await cleanupTeamDirectories(teamName)
102 // Already cleaned — don't try again on gracefulShutdown.
103 unregisterTeamForSessionCleanup(teamName)
104
105 // Clear color assignments so new teams start fresh
106 clearTeammateColors()
107
108 // Clear leader team name so getTaskListId() falls back to session ID
109 clearLeaderTeamName()
110
111 logEvent('tengu_team_deleted', {
112 team_name:
113 teamName as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
114 })
115 }
116
117 // Clear team context and inbox from app state
118 setAppState(prev => ({
119 ...prev,
120 teamContext: undefined,
121 inbox: {
122 messages: [], // Clear any queued messages
123 },
124 }))
125
126 return {
127 data: {
128 success: true,

Callers

nothing calls this directly

Calls 7

readTeamFileFunction · 0.85
cleanupTeamDirectoriesFunction · 0.85
clearTeammateColorsFunction · 0.85
clearLeaderTeamNameFunction · 0.85
logEventFunction · 0.85
getAppStateFunction · 0.50

Tested by

no test coverage detected