INNER CODE UNIT · TypeScript
stripSwarmPrefix
ZaxbyHub/opencode-swarm · src/agents/index.ts:134
export function stripSwarmPrefix(
agentName: string,
swarmPrefix?: string,
): string {
if (!swarmPrefix || !agentName) return agentName;
const prefixWithUnderscore = `${swarmPrefix}_`;
if (agentName.startsWith(prefixWithUnderscore)) {
return agentName.substring(prefixWithUnderscore.length);
}
return agentName;
}
/**
* Extract the swarm ID from a prefixed agent name.
* For multi-swarm configurations, agent names are prefixed: "swarmId_agentName"
* For the default swarm, agent names have no prefix.
*
* Example: "local_coder" -> "local", "coder" -> undefined (default swarm)