Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
export function toTitleCaseWords(value: string): string {
const parts: Array<string> = [];
for (const part of value.split(/[\s_-]+/g)) {
if (part.length > 0) {
parts.push(part[0]!.toUpperCase() + part.slice(1).toLowerCase());
}
}
return parts.join(" ");
}
export function claudeSubscriptionLabel(subscriptionType: string | undefined): string | undefined {
const normalized = subscriptionType?.toLowerCase().replace(/[\s_-]+/g, "");
if (!normalized) return undefined;
switch (normalized) {
case "claudemaxsubscription":
return "Max";
case "claudemax5xsubscription":
return "Max 5x";
case "claudemax20xsubscription":
return "Max 20x";
case "claudeenterprisesubscription":
return "Enterprise";
case "claudeteamsubscription":
return "Team";
case "claudeprosubscription":
return "Pro";
case "claudefreesubscription":
return "Free";
case "max":
case "maxplan":
return "Max";
case "max5":
return "Max 5x";
case "max20":
return "Max 20x";
case "enterprise":
return "Enterprise";
case "team":
return "Team";
case "pro":
return "Pro";
case "free":
return "Free";
default:
return toTitleCaseWords(subscriptionType!);
}
}
export function normalizeClaudeAuthMethod(authMethod: string | undefined): string | undefined {
const normalized = authMethod?.toLowerCase().replace(/[\s_-]+/g, "");
if (!normalized) return undefined;
if (
normalized === "apikey" ||
normalized === "anthropicapikey" ||
normalized === "anthropicauthtoken"
) {
return "apiKey";
}
return undefined;
}
export function formatClaudeSubscriptionAuthLabel(subscriptionType: string): string {
const subscriptionLabel =
claudeSubscriptionLabel(subscriptionType) ?? toTitleCaseWords(subscriptionType);
const normalized = subscriptionLabel.toLowerCase().replace(/[\s_-]+/g, "");
if (normalized.startsWith("claude") && normalized.endsWith("subscription")) {
return subscriptionLabel;
}
if (normalized.startsWith("claude")) {
return `${subscriptionLabel} Subscription`;
}
if (normalized.endsWith("subscription")) {
return `Claude ${subscriptionLabel}`;
}
return `Claude ${subscriptionLabel} Subscription`;
}
export function claudeAuthMetadata(input: {
readonly subscriptionType: string | undefined;
readonly authMethod: string | undefined;
}): { readonly type: string; readonly label: string } | undefined {
if (normalizeClaudeAuthMethod(input.authMethod) === "apiKey") {
return {
type: "apiKey",
label: "Claude API Key",
};
}
if (input.subscriptionType) {
return {
type: input.subscriptionType,
label: formatClaudeSubscriptionAuthLabel(input.subscriptionType),
};
}
return undefined;
}
export function apiProviderAuthMetadata(
apiProvider: string | undefined,
): { readonly type: string; readonly label: string } | undefined {
return apiProvider === "bedrock" ? { type: "bedrock", label: "Amazon Bedrock" } : undefined;
}