Files
AgentCompany/landing/lib/platform-support.ts
T
ZacharyZhang-NY 208ba8b38d Ship Windows 1.0.0 and drop Linux from the download page
- release-links: bump to 1.0.0; Windows now points at AgentCompany-1.0.0-x64.exe
  (signed x64 NSIS, uploaded to R2); remove the Linux platform. macOS stays on
  0.4.182 until the 1.0.0 mac build is ready.
- platform-support / product-narrative / footer / layout / faq: remove Linux
  from availability copy, the FAQ, JSON-LD, and footer download links
- e2e: adjust the tracked-download-link count (macOS x2 + Windows = 3)
2026-07-08 01:00:50 -04:00

106 lines
3.6 KiB
TypeScript

import {
platformDownloads,
type PlatformDownload,
type PlatformDownloadAsset,
type ReleaseArchitecture,
} from "../components/release-links.generated";
const ARCHITECTURE_ORDER: ReleaseArchitecture[] = ["arm64", "x64", "x86"];
export type PlatformSupportSummary = {
downloadAnswer: string;
platformAnswer: string;
};
export const platformSupportSummary = buildPlatformSupportSummary(platformDownloads);
export function buildPlatformSupportSummary(downloads: PlatformDownload[]): PlatformSupportSummary {
const macos = requirePlatform(downloads, "macos");
const windows = requirePlatform(downloads, "windows");
return {
downloadAnswer:
`Use the download section on this page to choose the build that matches your architecture and package format. ` +
`${formatDownloadSentence(macos)} ${formatDownloadSentence(windows)}`,
platformAnswer:
`AgentCompany is available on ${formatAvailability(macos)} and ${formatAvailability(windows)}. ` +
`It is built with Electron and the desktop feature set stays aligned across all supported targets.`,
};
}
function requirePlatform(downloads: PlatformDownload[], id: PlatformDownload["id"]): PlatformDownload {
const platform = downloads.find((download) => download.id === id);
if (!platform) {
throw new Error(`Missing ${id} release download metadata.`);
}
return platform;
}
function formatDownloadSentence(download: PlatformDownload): string {
const architectures = formatArchitectureList(collectArchitectures(download));
if (!download.packageDescription.trim()) {
throw new Error(`Release platform ${download.id} must include package format copy.`);
}
return `${download.title} ships as ${download.packageDescription} for ${architectures}.`;
}
function formatAvailability(download: PlatformDownload): string {
return `${download.title} (${formatArchitectureList(collectArchitectures(download), "comma")})`;
}
function collectArchitectures(download: PlatformDownload): ReleaseArchitecture[] {
const architectures = new Set<ReleaseArchitecture>();
for (const asset of download.assets) {
collectAssetArchitectures(download.id, asset).forEach((architecture) => architectures.add(architecture));
}
return [...architectures].sort((left, right) => architectureRank(left) - architectureRank(right));
}
function collectAssetArchitectures(
platformId: PlatformDownload["id"],
asset: PlatformDownloadAsset,
): ReleaseArchitecture[] {
if (asset.architectures.length === 0) {
throw new Error(`Release asset ${platformId}/${asset.id} must declare at least one architecture.`);
}
for (const architecture of asset.architectures) {
if (!isReleaseArchitecture(architecture)) {
throw new Error(`Release asset ${platformId}/${asset.id} declares unsupported architecture: ${architecture}`);
}
}
return asset.architectures;
}
function isReleaseArchitecture(value: string): value is ReleaseArchitecture {
return ARCHITECTURE_ORDER.includes(value as ReleaseArchitecture);
}
function architectureRank(architecture: ReleaseArchitecture): number {
return ARCHITECTURE_ORDER.indexOf(architecture);
}
function formatArchitectureList(
architectures: ReleaseArchitecture[],
style: "and" | "comma" = "and",
): string {
if (architectures.length === 0) {
throw new Error("Release download metadata must include at least one architecture.");
}
if (style === "comma") {
return architectures.join(", ");
}
if (architectures.length === 1) {
return architectures[0];
}
if (architectures.length === 2) {
return `${architectures[0]} and ${architectures[1]}`;
}
return `${architectures.slice(0, -1).join(", ")}, and ${architectures.at(-1)}`;
}