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 { Predicate } from "effect";
import type { ConnectionTarget } from "@akeru/client-runtime/connection";
import {
PORTABILITY_ARCHIVE_MAX_CHARS,
type PortabilityImportPreview,
type PortabilityProjectFolderMap,
type ProjectId,
} from "@akeru/contracts";
import { desktopLocalBackendId } from "../../connection/desktopLocal";
export function portabilityProjectPickerTarget(
target: ConnectionTarget | null,
): string | null | undefined {
if (target === null) return undefined;
if (Predicate.isTagged(target, "PrimaryConnectionTarget")) return null;
return desktopLocalBackendId(target) ?? undefined;
}
export function updatePortabilityProjectFolderMap(
current: PortabilityProjectFolderMap,
projectId: ProjectId,
destination: string,
): PortabilityProjectFolderMap {
const next = { ...current };
delete next[projectId];
const normalizedDestination = destination.trim();
return normalizedDestination ? { ...next, [projectId]: normalizedDestination } : next;
}
export function portabilityArchiveFileError(size: number): string | null {
return size > PORTABILITY_ARCHIVE_MAX_CHARS ? "Archives must be 20 MB or smaller." : null;
}
export function canApplyPortabilityPreview(preview: PortabilityImportPreview): boolean {
return preview.additions.length + preview.changes.length > 0;
}