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.
import { CommandId, MessageId, ProjectId, ThreadId } from "@akeru/contracts";
import * as Encoding from "effect/Encoding";
import { DraftId } from "../composerDraftStore";
import type { CnFunction } from "cn";
import { createCn } from "cn/config";
import { scaleClassGroups, scaleTheme } from "./scaleTheme";
/** Class merger that knows the extra theme steps declared in styles/scale-tokens.css. */
export const cn: CnFunction = createCn({
extend: { theme: scaleTheme, classGroups: scaleClassGroups },
});
export function isMacPlatform(platform: string): boolean {
return /mac|iphone|ipad|ipod/i.test(platform);
}
export function isWindowsPlatform(platform: string): boolean {
return /^win(dows)?/i.test(platform);
}
export function isLinuxPlatform(platform: string): boolean {
return /linux/i.test(platform);
}
export function getLocalFileManagerName(platform: string): string {
if (isMacPlatform(platform)) {
return "Finder";
}
if (isWindowsPlatform(platform)) {
return "Explorer";
}
return "Files";
}
export function randomHex(byteLength: number): string {
return Encoding.encodeHex(globalThis.crypto.getRandomValues(new Uint8Array(byteLength)));
}
export function randomUUID(): string {
const bytes = globalThis.crypto.getRandomValues(new Uint8Array(16));
bytes[6] = (bytes[6]! & 0x0f) | 0x40;
bytes[8] = (bytes[8]! & 0x3f) | 0x80;
const hex = Encoding.encodeHex(bytes);
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
}
export const newCommandId = (): CommandId => CommandId.make(randomUUID());
export const newProjectId = (): ProjectId => ProjectId.make(randomUUID());
export const newThreadId = (): ThreadId => ThreadId.make(randomUUID());
export const newDraftId = (): DraftId => DraftId.make(randomUUID());
export const newMessageId = (): MessageId => MessageId.make(randomUUID());