UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

40 lines (39 loc) • 1.45 kB
//#region src/agents/github-host.ts const GITHUB_PUBLIC_HOST = "github.com"; const GITHUB_PUBLIC_API_BASE_URL = "https://api.github.com"; const CLEARED_GITHUB_CREDENTIALS = { GH_TOKEN: "", GH_ENTERPRISE_TOKEN: "", GITHUB_TOKEN: "", GITHUB_ENTERPRISE_TOKEN: "" }; function withGitHubToken(e, t) { return { ...e, GH_TOKEN: t, GH_ENTERPRISE_TOKEN: t, GITHUB_TOKEN: void 0, GITHUB_ENTERPRISE_TOKEN: void 0 }; } function resolveConfiguredGitHubHost(e) { const t = e?.gateway?.github?.host?.trim().toLowerCase() || "github.com"; if (!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/u.test(t) || t.includes("..")) throw new Error("gateway.github.host must be a hostname"); return t; } function resolveConfiguredGitHubApiBaseUrl(e) { const t = e?.gateway?.github?.apiBaseUrl?.trim() || GITHUB_PUBLIC_API_BASE_URL; const n = new URL(t); if (n.protocol !== "https:" || n.username || n.password || n.search || n.hash || ![ "/", "", "/api/v3", "/api/v3/" ].includes(n.pathname)) throw new Error("gateway.github.apiBaseUrl must be an HTTPS GitHub API base URL"); return n.origin + (n.pathname.startsWith("/api/v3") ? "/api/v3" : ""); } function githubRepositoryUrl(e, t = resolveConfiguredGitHubHost()) { return `https://${t}/${e}.git`; } //#endregion export { resolveConfiguredGitHubHost as a, resolveConfiguredGitHubApiBaseUrl as i, GITHUB_PUBLIC_HOST as n, withGitHubToken as o, githubRepositoryUrl as r, CLEARED_GITHUB_CREDENTIALS as t };