MCPcopy Create free account
hub / github.com/Noumena-Network/code / generateUniqueTeammateName

Function generateUniqueTeammateName

src/tools/shared/spawnMultiAgent.ts:256–283  ·  view source on GitHub ↗
(
  baseName: string,
  teamName: string | undefined,
)

Source from the content-addressed store, hash-verified

254 * @internal Exported for testing
255 */
256export async function generateUniqueTeammateName(
257 baseName: string,
258 teamName: string | undefined,
259): Promise<string> {
260 if (!teamName) {
261 return baseName
262 }
263
264 const teamFile = await readTeamFileAsync(teamName)
265 if (!teamFile) {
266 return baseName
267 }
268
269 const existingNames = new Set(teamFile.members.map(m => m.name.toLowerCase()))
270
271 // If the base name doesn't exist, use it as-is
272 if (!existingNames.has(baseName.toLowerCase())) {
273 return baseName
274 }
275
276 // Find the next available suffix
277 let suffix = 2
278 while (existingNames.has(`${baseName}-${suffix}`.toLowerCase())) {
279 suffix++
280 }
281
282 return `${baseName}-${suffix}`
283}
284
285// ============================================================================
286// Spawn Handlers

Callers 3

handleSpawnSplitPaneFunction · 0.85
handleSpawnInProcessFunction · 0.85

Calls 2

readTeamFileAsyncFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected