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
54 linesCodeBlameRaw
1import { env } from "cloudflare:workers";
2
3import {
4 type ModelDiscoveryApi,
5 type StatusAdminApi,
6 accountsAdminClient,
7 billingAdminClient,
8 billingClient,
9 eventsClient,
10 identityAdminClient,
11 projectsClient,
12 runnersAdminClient,
13 telemetryClient,
14 type User,
15} from "@g1t/contracts";
16
17/** Staff-only billing, on the billing service. */
18export const admin = billingAdminClient(env.BILLING);
19
20/** The public price book, read-only, from the same service. */
21export const priceBook = () => billingClient(env.BILLING).prices();
22
23/** Staff-only identity: every workspace, its owners and members. */
24export const identity = identityAdminClient(env.IDENTITY);
25
26/** Staff-only accounts: a person's email addresses and security log. */
27export const accountsAdmin = accountsAdminClient(env.IDENTITY);
28
29/** The workspace's plan, caps and pause, as billing gives them to every service. */
30export const entitlements = (workspace: string) => billingClient(env.BILLING).entitlements(workspace);
31
32/** The event log, read-only: sudo lists `abuse.flagged`. */
33export const events = eventsClient(env.EVENTS);
34
35/** The status page's incidents (apps/status's `StatusAdmin` entrypoint). */
36export const statusAdmin = env.STATUS as unknown as StatusAdminApi;
37
38/** "Check for new models": the model proxy's `Discovery` entrypoint (services/models). */
39export const modelDiscovery = env.MODELS as unknown as ModelDiscoveryApi;
40
41/** A workspace's self-hosted runners, and removing them (actions' admin_* methods). */
42export const runnersAdmin = runnersAdminClient(env.ACTIONS);
43
44/** A workspace's projects, read as the workspace itself, which sees them all. */
45export const workspaceProjects = (slug: string) => {
46 const workspace: User = { id: `staff:${slug}`, username: slug, kind: "workspace", verified: true, workspaces: [{ slug, role: "member" }] };
47 return projectsClient(env.PROJECTS).list(slug, workspace);
48};
49
50/** Projects' telemetry: their ingest tokens, to see and revoke. */
51export const telemetry = telemetryClient(env.TELEMETRY);
52
53/** STAFF_EMAILS, for suggesting staff in the incident roles. */
54export const staffEmails = (): string => env.STAFF_EMAILS ?? "";