```ts
/**
 * Builds weight codes for tokens based on the given entries.
 * @param entries - A list of entries, each containing a token and its tally.
 * @returns An object with "codes", "bits", and "tallest" keys.
 */
export function buildWeightCode(entries: any[]): any {
    if (!Array.isArray(entries) || entries.length === 0) {
        throw new Error("Invalid input");
    }

    const tokens = entries.map((entry, index) => {
        if (!Array.isArray(entry) || entry.length !== 2) {
            throw new Error(`Entry at index ${index} is invalid`);
        }
        const [token, tally] = entry;
        if (typeof token !== 'string' || !/^[a-z]+$/.test(token)) {
            throw new Error(`Token at index ${index} is invalid`);
        }
        if (!Number.isInteger(tally) || tally < 1) {
            throw new Error(`Tally at index ${index} is invalid`);
        }
        return { token, tally };
    });

    if (new Set(tokens.map(token => token.token)).size !== tokens.length) {
        throw new Error("Duplicate token found");
    }

    tokens.sort((a, b) => a.token.localeCompare(b.token));

    interface Bud {
        number: number;
        load: number;
        near?: Bud;
        far?: Bud;
    }

    const buds: Bud[] = tokens.map((token, index) => ({
        number: index,
        load: token.tally
    }));

    while (buds.length > 1) {
        buds.sort((a, b) => a.load !== b.load ? a.load - b.load : a.number - b.number);
        const nearBud = buds.shift()!;
        const farBud = buds.shift()!;
        const newBud: Bud = {
            number: buds.length,
            load: nearBud.load + farBud.load,
            near: nearBud,
            far: farBud
        };
        buds.push(newBud);
    }

    const crown = buds[0];
    const codes: { [key: string]: string } = {};

    function buildBits(bud: Bud, path: string): void {
        if (bud.near) {
            buildBits(bud.near, path + '0');
        }
        if (bud.far) {
            buildBits(bud.far, path + '1');
        }
        if (!bud.near && !bud.far) {
            for (const token of tokens) {
                if (token.tally === bud.load) {
                    codes[token.token] = path;
                    break;
                }
            }
        }
    }

    buildBits(crown, '');

    let totalBits = 0;
    let tallestBits = 0;

    for (const token of tokens) {
        const bits = codes[token.token];
        totalBits += token.tally * bits.length;
        if (bits.length > tallestBits) {
            tallestBits = bits.length;
        }
    }

    return {
        codes,
        bits: totalBits,
        tallest: tallestBits
    };
}
```