Files
lettabot/src/utils/server.ts
puffo 7f12cbdc60 Unify self-hosted URL detection with shared isLettaCloudUrl() (#60)
Docker service hostnames (e.g. http://letta:8283) were misidentified as
Letta Cloud. Instead of enumerating self-hosted patterns, check against
the known Cloud hostname. Everything else is self-hosted.
2026-02-01 20:36:39 -08:00

25 lines
632 B
TypeScript

/**
* Letta server URL utilities
*
* The heuristic is simple: Letta Cloud lives at a known URL.
* Everything else is self-hosted.
*/
import { LETTA_CLOUD_API_URL } from '../auth/oauth.js';
/**
* Check if a URL points at Letta Cloud (api.letta.com)
*
* @param url - The base URL to check. When absent, assumes cloud (the default).
*/
export function isLettaCloudUrl(url?: string): boolean {
if (!url) return true; // no URL means the default (cloud)
try {
const given = new URL(url);
const cloud = new URL(LETTA_CLOUD_API_URL);
return given.hostname === cloud.hostname;
} catch {
return false;
}
}