Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
33 linesCodeBlameRaw
1import type { ProviderKind } from "@g1t/contracts";
2
3/**
4 * The workspace's integration setup pages, under `-/integrations/<section>`:
5 * one for each kind of provider connection. The directory at
6 * `-/integrations` links into them. Model providers have no page: they
7 * were for g1t's own agents, which are gone.
8 */
9export type IntegrationsSection = "alerts" | "trackers";
10
11/** The kinds of provider that have a setup page. */
12export type SectionKind = Exclude<ProviderKind, "models">;
13
14const SECTIONS: Record<SectionKind, IntegrationsSection> = {
15 alerts: "alerts",
16 tracker: "trackers",
17};
18
19/** Whether a kind of provider has a setup page. */
20export function hasSection(kind: ProviderKind): kind is SectionKind {
21 return kind in SECTIONS;
22}
23
24/** The page a kind of provider is set up on, or null when it has none. */
25export function integrationsSection(kind: ProviderKind): IntegrationsSection | null {
26 return hasSection(kind) ? SECTIONS[kind] : null;
27}
28
29/** The kind of provider a section's page is for, or null when it is no section. */
30export function sectionKind(section: string | undefined): SectionKind | null {
31 const found = (Object.keys(SECTIONS) as SectionKind[]).find((kind) => SECTIONS[kind] === section);
32 return found ?? null;
33}