Skip to content

g1t/packages/contracts/src/identity.ts

757 lines31,018 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look1import type { AccessClient, BasePermission, RepoGrant } from "./access";
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API2import type { Acting, CreateRunCredentialInput, RunBinding } from "./audit";
Agents as a team: lifecycle, merge queue, billing and a new shell3import type { RepoPath } from "./repos";
Initial g1t: services, event bus, intents and attempts4import type { Result } from "./result";
Merge branch 'worktree-agent-ad7c6d88d93adc817'5import type { TeamCreation, TeamsClient } from "./teams";
Initial g1t: services, event bus, intents and attempts6
Email verification, password reset, and Git for AI scale positioning7export type User = {
8 id: string;
9 username: string;
10 /**
Agents as a team: lifecycle, merge queue, billing and a new shell11 * `workspace` when a workspace is acting through one of its own access
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily12 * tokens: `id` is then the workspace's and `username` its slug. `system`
13 * is g1t itself doing platform work, such as a security update
14 * (`username` `g1t`). Absent means `user`.
Agents as a team: lifecycle, merge queue, billing and a new shell15 */
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily16 kind?: "user" | "workspace" | "agent" | "system";
Agents as a team: lifecycle, merge queue, billing and a new shell17 /**
Email verification, password reset, and Git for AI scale positioning18 * Whether the account's email address is confirmed. Only set on users
19 * resolved from credentials; unverified accounts cannot change anything.
20 */
21 verified?: boolean;
Workspaces own repositories22 /**
23 * The workspaces this user belongs to. Set on users resolved from
24 * credentials, so any service can authorize from it.
25 */
26 workspaces?: Membership[];
Workspace names and icons, and a component kit for every control27 /**
28 * The person's uploaded avatar: the SHA-256 of its bytes, served at
29 * `/avatars/<avatar>`. Only set on the signed-in person; absent means
30 * the generated letter avatar.
31 */
32 avatar?: string;
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API33 /**
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent34 * Set on an agent resolved from its token: who it acts for ("g1t
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API35 * on behalf of syntaqx"), with which credential, and what it may do.
36 */
37 acting?: Acting;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look38 /**
39 * The repositories this user has a role on directly, whether or not they
40 * belong to its workspace. Set with `workspaces`; see `access.ts`.
41 */
42 grants?: RepoGrant[];
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step43 /**
44 * Set on a user resolved from an access token: its scopes (null for full
45 * access) and the workspaces or repositories it reaches. See scopes.ts.
46 */
47 token?: {
48 token_id: string;
49 scopes?: string[] | null;
50 legacy?: boolean;
Merge the AI Gateway: Anthropic's Messages API on a workspace's tokens51 /** The token's name, as its owner gave it. */
52 name?: string;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step53 };
Email verification, password reset, and Git for AI scale positioning54};
Initial g1t: services, event bus, intents and attempts55
Workspaces own repositories56/** What a member may do: an owner also manages the workspace's members. */
57export type Role = "owner" | "member";
58
Workspace names and icons, and a component kit for every control59export type Membership = {
60 /** The workspace's name in URLs: `g1t.sh/<slug>`. */
61 slug: string;
62 role: Role;
63 /** Its display name. Set on users resolved from credentials. */
64 name?: string;
65 /** Its uploaded icon, as `Workspace.avatar`. */
66 avatar?: string;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look67 /** The workspace's base permission: what members get on every repository. Absent means `write`. */
68 base_permission?: BasePermission;
Merge branch 'worktree-agent-ad7c6d88d93adc817'69 /** Who may create its teams. Absent means any member. */
70 team_creation?: TeamCreation;
Workspace names and icons, and a component kit for every control71};
Workspaces own repositories72
Agents and memory, checks and conflicts, profiles, slug renames, custom domains73/** How long an old workspace slug redirects, and stays reserved for it, after a rename. */
74export const SLUG_HOLD_DAYS = 90;
75
76/** How long a workspace must wait between renames. */
77export const RENAME_COOLDOWN_HOURS = 24;
78
Workspace names and icons, and a component kit for every control79/** The largest avatar that can be uploaded, in bytes. */
80export const MAX_AVATAR_BYTES = 1024 * 1024;
81
Workspaces own repositories82/**
Merge branch 'worktree-agent-a2013627e5ea4ab13'83 * Where a workspace keeps its repositories' git data: anywhere g1t stores
84 * it (the default), or in the EU only. It applies to repositories made
85 * after it is set.
86 */
87export type DataResidency = "anywhere" | "eu";
88
89/**
Workspaces own repositories90 * A workspace: the owner of repositories, and the first segment of their
91 * URLs. A person's own space and a team's are the same thing.
92 */
93export type Workspace = {
94 id: string;
95 slug: string;
96 name: string;
Agents as a team: lifecycle, merge queue, billing and a new shell97 /** One line saying what the workspace is for. */
98 description: string | null;
Workspaces own repositories99 /** RFC 3339. */
100 createdAt: string;
101 memberCount: number;
Workspace names and icons, and a component kit for every control102 /**
103 * The workspace's uploaded icon: the SHA-256 of its bytes, served at
104 * `/avatars/<avatar>`. Null means the generated letter avatar.
105 */
106 avatar: string | null;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look107 /** What every member gets on each repository; owners have Admin. */
108 basePermission?: BasePermission;
Merge branch 'worktree-agent-ad7c6d88d93adc817'109 /** Who may create its teams. Absent means any member. */
110 teamCreation?: TeamCreation;
Workspaces own repositories111};
112
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look113export type Member = {
114 username: string;
115 role: Role;
116 /** Their display name, when they set one. */
117 name?: string | null;
118 /** Their uploaded avatar's hash, served at `/avatars/<avatar>`; null for the generated letter avatar. */
119 avatar?: string | null;
120};
Workspaces own repositories121
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace122/** An owner of a workspace, as staff see them. */
123export type AdminOwner = { username: string; email: string | null };
124
125/** A workspace as staff see it. Mirrors `AdminWorkspace` in `crates/contracts/src/identity.rs`. */
126export type AdminWorkspace = {
127 slug: string;
128 name: string;
129 /** RFC 3339. */
130 createdAt: string;
131 owners: AdminOwner[];
132 memberCount: number;
133};
134
135/** A member of a workspace, as staff see them. */
136export type AdminMember = { username: string; email: string | null; role: Role; /** RFC 3339. */ joined: string };
137
138export type AdminWorkspaceDetail = {
139 slug: string;
140 name: string;
141 description: string | null;
142 /** RFC 3339. */
143 createdAt: string;
144 /** Owners first, then by username. */
145 members: AdminMember[];
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member146 /** It can never be deleted, by anyone (identity's `PROTECTED_WORKSPACES`). */
147 protected: boolean;
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace148};
149
150/** The most workspaces one `workspaces` call returns. */
151export const ADMIN_WORKSPACES_LIMIT = 500;
152
153/**
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look154 * Whether anyone may make an account, or only someone with an invite.
155 * Identity's `REGISTRATION_MODE`; unset means `invite`.
156 */
157export type RegistrationMode = "invite" | "open";
158
159/** How many invites a person may have out at once, unless identity's `INVITES_PER_USER` says otherwise. */
160export const INVITES_PER_USER = 5;
161/** How long an invite works, unless identity's `INVITE_TTL_DAYS` says otherwise. */
162export const INVITE_TTL_DAYS = 30;
163
164/** Only a pending invite can be used or revoked. Revoked and expired ones never used give the invite back. */
165export type InviteStatus = "pending" | "redeemed" | "expired" | "revoked";
166
167/** One invite. Mirrors `Invite` in `crates/contracts/src/identity.rs`. */
168export type Invite = {
169 id: string;
170 /** `g1t-k7m2-…`: returned when it is made, and to its maker while pending. */
171 code: string | null;
172 /** The code's first group, such as `g1t-k7m2`. */
173 hint: string;
174 /** Only this address can use it. */
175 email: string | null;
176 /** `account` makes an account; `workspace` joins an existing one to `workspace`. */
177 kind: "account" | "workspace";
178 /** The workspace using it joins. */
179 workspace: string | null;
180 status: InviteStatus;
181 /** Whose allowance it used. */
182 chargedTo: "user" | "workspace" | "none";
183 /** Its maker's username; null when g1t staff made it. */
184 invitedBy: string | null;
185 /** The account that used it. */
186 redeemedBy: string | null;
187 /** RFC 3339. */
188 createdAt: string;
189 /** RFC 3339. */
190 expiresAt: string;
191 redeemedAt: string | null;
192 revokedAt: string | null;
193 /** The staff member who minted it; only in staff views. */
194 staff?: string | null;
195};
196
197/** How many invites someone may have out. `limit` and `remaining` are null for no limit. */
198export type Allowance = { limit: number | null; used: number; remaining: number | null };
199
200export type InvitesOverview = {
201 mode: RegistrationMode;
202 allowance: Allowance;
203 /** Workspaces the person owns that were granted invites to share. */
204 workspaces: { slug: string; allowance: Allowance }[];
205 invites: Invite[];
206};
207
208/** What a valid code is for, before it is used. */
209export type InvitePreview = {
210 kind: "account" | "workspace";
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas211 /** Pending, unless `anyStatus` asked about a code that is spent. */
212 status: InviteStatus;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look213 /** Null when g1t staff sent it. */
214 invitedBy: { username: string; name: string | null; avatar: string | null } | null;
215 workspace: ProfileWorkspace | null;
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas216 /** The repository it accepts an invitation to, such as `{ name: "flagon-io/g1t", role: "write" }`. */
217 repository: { name: string; role: string } | null;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look218 /** Partly hidden, such as `a•••@example.com`. */
219 email: string | null;
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas220 /** The bound address in full, while the invite is pending: it fills in and locks the sign-up form. */
221 address: string | null;
222 /** Whether the bound address has a g1t account already: sign in to accept. */
223 hasAccount: boolean;
224 /** With a viewer: whether it is theirs (for one of their confirmed addresses, or used by them). */
225 forViewer: boolean | null;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look226 expiresAt: string;
227};
228
229export type WaitlistStatus = "waiting" | "invited" | "dismissed";
230
231export type WaitlistEntry = {
232 id: string;
233 email: string;
234 about: string | null;
235 status: WaitlistStatus;
236 inviteId: string | null;
237 decidedBy: string | null;
238 decidedAt: string | null;
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas239 /** What staff wrote when approving; it went in the invite email. */
240 note: string | null;
241 /** The account made with the invite, once it was used. */
242 joinedAs: string | null;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look243 /** When they first asked. */
244 createdAt: string;
245 /** When they last asked. */
246 updatedAt: string;
247};
248
249export type InviteGrant = { amount: number; note: string | null; grantedBy: string; createdAt: string };
250export type InviteTreeNode = { username: string; joinedAt: string; invited: InviteTreeNode[] };
251
252/** Where a person came from and whom they brought. For a workspace, `username` is its slug. */
253export type InviteTree = {
254 username: string;
255 /** Who invited them, then who invited that person, and so on. */
256 invitedBy: string[];
257 /** The staff member who minted their invite, when staff did. */
258 staff: string | null;
259 allowance: Allowance;
260 grants: InviteGrant[];
261 invites: Invite[];
262 /** Whom they invited, three levels down. */
263 invited: InviteTreeNode[];
264};
265
266/** The most rows one staff listing of invites or the waitlist returns. */
267export const ADMIN_INVITES_LIMIT = 500;
268
269/**
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace270 * Staff-only identity, for sudo.g1t.sh. It takes no viewer and checks no
271 * membership: only sudo calls it, over its service binding, once Cloudflare
272 * Access and its staff list have let someone in. Never call it on behalf of
273 * a customer.
274 */
275export interface IdentityAdminApi {
276 /** Every workspace, newest first, at most 500; `query` matches slug, name, or an owner's username or email. */
277 workspaces(query?: string): Promise<AdminWorkspace[]>;
278 /** One workspace with all its members, or null. */
279 workspace(slug: string): Promise<AdminWorkspaceDetail | null>;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look280
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas281 /** The waitlist, newest first; `query` matches the address or what they said. */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look282 waitlist(query?: string | null, status?: WaitlistStatus | null): Promise<WaitlistEntry[]>;
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas283 /** How many requests are waiting, for the navigation's badge. */
284 waitlistPending(): Promise<number>;
285 /**
286 * Approving mints an invite bound to the address and emails it, with
287 * `note` (up to 500 characters) if given; dismissing only marks it.
288 */
289 decideWaitlist(id: string, approve: boolean, staff: string, note?: string | null): Promise<Result<WaitlistEntry>>;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look290 /** Invites, newest first; `query` is a code's start, or part of an email, inviter or redeemer. */
291 invites(query?: string | null): Promise<Invite[]>;
292 revokeInvite(id: string, staff: string): Promise<Result<Invite>>;
293 /** An invite that uses nobody's allowance, optionally bound to (and emailed to) `email`. */
294 mintInvite(email: string | null, staff: string): Promise<Result<Invite>>;
295 /** More invites (or fewer, with a negative amount) for a person or a workspace. */
296 grantInvites(
297 target: "user" | "workspace",
298 name: string,
299 amount: number,
300 note: string,
301 staff: string,
302 ): Promise<Result<Allowance>>;
303 /** Where a person came from and whom they brought, or null. */
304 inviteTree(username: string): Promise<InviteTree | null>;
305 /** A workspace's granted invites and the invites made for it, or null. */
306 workspaceInvites(slug: string): Promise<InviteTree | null>;
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member307
308 /** Workspaces owners deleted that are not purged yet, newest first. */
309 deletedWorkspaces(): Promise<DeletedWorkspace[]>;
310 /**
311 * Brings a deleted workspace back, with its members, tokens and what went
312 * with it, while it is still restorable. Publishes `workspace.restored`.
313 */
314 restoreWorkspace(workspaceId: string, staff: string): Promise<Result<boolean>>;
315 /**
316 * Purges a deleted workspace now rather than at `purgeAfter`. `confirm` is
317 * its slug, typed out. Refused for a protected workspace. Publishes
318 * `workspace.deleted`.
319 */
320 purgeWorkspace(workspaceId: string, staff: string, confirm: string): Promise<Result<boolean>>;
Merge branch 'worktree-agent-a8385d293d42c913a'321
322 /** Every workspace alias, by name. */
323 aliases(): Promise<WorkspaceAlias[]>;
324 /**
325 * Points `alias` at the workspace whose slug is `workspace`. Refused for
326 * one of the site's routes, anyone's username, a workspace's slug (deleted
327 * or held after a rename) and an existing alias. `note` says why.
328 */
329 setAlias(alias: string, workspace: string, note: string, staff: string): Promise<Result<WorkspaceAlias>>;
330 /** Removes an alias; `reason` goes in sudo's audit log. */
331 removeAlias(alias: string, reason: string, staff: string): Promise<Result<boolean>>;
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace332}
333
Merge branch 'worktree-agent-a8385d293d42c913a'334/**
335 * A name g1t's staff point at a workspace, so its addresses lead there under
336 * the workspace's own name: `g1t`, the product, leads to `flagon-io`, Flagon,
337 * Inc. Staff-managed only; it follows the workspace through renames.
338 */
339export type WorkspaceAlias = {
340 alias: string;
341 workspaceId: string;
342 /** The workspace's slug and name now. */
343 workspace: string;
344 workspaceName: string;
345 /** Why it exists. */
346 note: string;
347 /** The staff member who set it, or `migration`. */
348 createdBy: string;
349 /** RFC 3339. */
350 createdAt: string;
351};
352
Initial g1t: services, event bus, intents and attempts353/** Who is asking. Every read and write in every service takes one. */
354export type Viewer = User | null;
355
356export type SshKey = {
357 id: string;
358 title: string;
359 fingerprint: string;
RFC 3339 timestamps in identity and repos360 /** RFC 3339. */
361 createdAt: string;
Initial g1t: services, event bus, intents and attempts362};
363
Agents as a team: lifecycle, merge queue, billing and a new shell364export type AccessToken = {
365 id: string;
366 name: string;
367 /** RFC 3339. */
368 createdAt: string;
369 /** RFC 3339, to within a few minutes. Null until it is first used. */
370 lastUsedAt: string | null;
371 /**
372 * For a workspace's token, the username of the member who made it. Null
373 * once that account is gone, and on personal tokens.
374 */
375 createdBy: string | null;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step376 /** Its scopes, as `resource:level`. Null: full access. */
377 scopes: string[] | null;
378 /** Made before tokens had scopes: full access until someone narrows it. */
379 legacy: boolean;
380 /** RFC 3339. Null: it does not expire. */
381 expiresAt: string | null;
382};
383
384/** What a new or changed token may do. */
385export type TokenGrant = {
386 /** Null: full access. */
387 scopes: string[] | null;
Agents as a team: lifecycle, merge queue, billing and a new shell388};
Initial g1t: services, event bus, intents and attempts389
Device sign-in replaces registering and minting tokens over the API390export type DeviceStart = {
391 /** Secret held by the tool and exchanged for a token once approved. */
392 deviceCode: string;
393 /** Short code shown to the person, e.g. `WDJB-MJHT`. */
394 userCode: string;
395 /** Seconds until both codes stop working. */
396 expiresIn: number;
397 /** Seconds the tool should wait between polls. */
398 interval: number;
399};
400
401export type DeviceRequest = { userCode: string; clientName: string };
402
403export type DeviceClaim =
404 | { status: "pending" | "denied" | "expired" }
405 | { status: "approved"; token: string; user: User };
406
OAuth 2.1 sign-in for MCP clients and other applications407/** What the site passes on once a person has approved an application. */
408export type OAuthApproval = {
409 clientId: string;
410 /** Shown wherever the application's access is listed. */
411 clientName: string;
412 redirectUri: string;
413 /** PKCE challenge, method S256. */
414 codeChallenge: string;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step415 /** What the person granted. Null: full access. */
416 scopes: string[] | null;
OAuth 2.1 sign-in for MCP clients and other applications417};
418
419export type OAuthTokens = {
420 accessToken: string;
421 /** Works once; using it returns the next one. */
422 refreshToken: string;
423 /** Seconds until the access token stops working. */
424 expiresIn: number;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step425 /** The scopes granted, space-separated, or `*` for full access. */
426 scope?: string | null;
OAuth 2.1 sign-in for MCP clients and other applications427};
428
429/** An application a person has signed in to. */
430export type OAuthGrant = {
431 id: string;
432 clientName: string;
433 /** RFC 3339. */
434 createdAt: string;
435 /** RFC 3339. */
436 lastUsedAt: string;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step437 /** What the person granted. Null: full access. */
438 scopes: string[] | null;
439 /** Signed in before applications had scopes: full access until narrowed. */
440 legacy: boolean;
OAuth 2.1 sign-in for MCP clients and other applications441};
442
Initial g1t: services, event bus, intents and attempts443/** Accounts, credentials and sessions. */
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member444/**
445 * What deleting a workspace takes with it, and what stands in the way:
446 * nothing does while `billing` is null and it is not `protected`.
447 */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look448export type WorkspaceDeletion = {
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member449 /** Its live repositories, deleted with it. */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look450 repositories: number;
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member451 /** Its projects, hidden with it. */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look452 projects: number;
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member453 members: number;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look454 /** Why billing cannot close it yet, in words for its owner. */
455 billing: string | null;
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member456 /** It can never be deleted, by anyone. */
457 protected: boolean;
458};
459
460/** How long a deleted workspace is kept, for g1t's staff to restore, before it is purged. */
461export const WORKSPACE_RESTORE_DAYS = 30;
462
463/**
464 * Workspaces nobody can delete, whatever identity's `PROTECTED_WORKSPACES`
465 * says: Flagon's, which runs g1t. Services that act on `workspace.deleting`
466 * check it too, so one published for it by mistake changes nothing.
467 */
468export const ALWAYS_PROTECTED_WORKSPACES: readonly string[] = ["flagon-io"];
469
470/** Whether `slug` is one of `ALWAYS_PROTECTED_WORKSPACES`, in any case. */
471export function isProtectedWorkspace(slug: string): boolean {
472 return ALWAYS_PROTECTED_WORKSPACES.includes(slug.trim().toLowerCase());
473}
474
475/** A workspace an owner deleted, kept until `purgeAfter` for staff to restore. */
476export type DeletedWorkspace = {
477 workspaceId: string;
478 slug: string;
479 name: string;
480 /** RFC 3339. */
481 deletedAt: string;
482 /** The username of the owner who deleted it. */
483 deletedBy: string;
484 /** RFC 3339: when it is purged unless restored first. */
485 purgeAfter: string;
486 /** What went with it, counted when it was deleted. */
487 went: WorkspaceDeletion;
488 /** Whether staff can still restore it. */
489 restorable: boolean;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look490};
491
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar492export interface IdentityApi extends AccessClient, TeamsClient {
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look493 /**
494 * Creates an account and signs it in. While registration is invite-only,
495 * `inviteCode` must be an unused, unexpired invite (and, when it names an
496 * email, that address); it is ignored while registration is open.
497 */
498 register(
499 username: string,
500 email: string,
501 password: string,
502 inviteCode?: string | null,
503 /** Who is asking, such as the visitor's IP address, for rate limits. */
504 client?: string | null,
505 ): Promise<Result<{ user: User; sessionToken: string }>>;
Initial g1t: services, event bus, intents and attempts506 /** Verifies a username and password for website sign-in. */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look507 /**
508 * Verifies a username, or any confirmed address of the account, and its
509 * password. Wrong passwords are counted against the account and `client`
510 * (the visitor's IP address); past a limit nothing is checked for a while.
511 */
512 signIn(username: string, password: string, client?: string | null): Promise<Result<{ user: User; sessionToken: string }>>;
Initial g1t: services, event bus, intents and attempts513 signOut(sessionToken: string): Promise<void>;
Email verification, password reset, and Git for AI scale positioning514
515 /** Sends the confirmation email again. */
516 resendVerification(user: User): Promise<Result<boolean>>;
517 /** Confirms the address the emailed token was sent to. */
518 verifyEmail(token: string): Promise<Result<User>>;
519 /** Emails a reset link if the address has an account. Always resolves. */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look520 /**
521 * Any confirmed address of an account works; the link goes to it, and the
522 * primary and backup are told. A few an hour per address and per `client`.
523 */
524 requestPasswordReset(email: string, client?: string | null): Promise<boolean>;
Email verification, password reset, and Git for AI scale positioning525 /** Sets a new password from an emailed token and ends every session. */
526 resetPassword(token: string, password: string): Promise<Result<User>>;
527
Device sign-in replaces registering and minting tokens over the API528 /**
529 * Device sign-in (RFC 8628). A tool starts a request, a person approves
530 * its short code in a browser, and the tool claims an access token.
531 */
532 deviceStart(clientName: string): Promise<DeviceStart>;
533 /** What a user code is asking for, or null if it is not valid. */
534 deviceLookup(userCode: string): Promise<DeviceRequest | null>;
535 deviceResolve(userCode: string, user: User, approve: boolean): Promise<Result<boolean>>;
536 deviceClaim(deviceCode: string): Promise<DeviceClaim>;
537
OAuth 2.1 sign-in for MCP clients and other applications538 /**
539 * OAuth 2.1 for applications that sign a person in through the browser.
540 * The caller has checked the client and its redirect address; this
541 * returns the one-time code the application exchanges for tokens.
542 */
543 oauthAuthorize(user: User, approval: OAuthApproval): Promise<{ code: string }>;
544 /** Redeems a code. It works once, for that client, with the PKCE verifier. */
545 oauthExchange(code: string, codeVerifier: string, clientId: string, redirectUri: string): Promise<Result<OAuthTokens>>;
546 /** Trades a refresh token for new tokens; the old ones stop working. */
547 oauthRefresh(refreshToken: string, clientId: string): Promise<Result<OAuthTokens>>;
548 /** Applications the user has signed in to, most recently used first. */
549 listOAuthGrants(user: User): Promise<OAuthGrant[]>;
550 /** Signs an application out. */
551 revokeOAuthGrant(user: User, id: string): Promise<void>;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step552 /** Changes what an application may do, at once and when it refreshes. */
553 updateOAuthGrant(user: User, id: string, grant: TokenGrant): Promise<Result<OAuthGrant>>;
OAuth 2.1 sign-in for MCP clients and other applications554
Workspaces own repositories555 createWorkspace(user: User, slug: string, name: string): Promise<Result<Workspace>>;
556 /** Public details of a workspace, or null. */
557 getWorkspace(slug: string): Promise<Workspace | null>;
Merge branch 'worktree-agent-a2013627e5ea4ab13'558 /** Where a workspace keeps its repositories' git data; null when there is no such workspace. */
559 workspaceResidency(slug: string): Promise<DataResidency | null>;
560 /**
561 * Owners only. Applies to repositories made from then on. Offer `eu`
562 * only when the repos service's `storageOptions()` says it is available.
563 */
564 setWorkspaceResidency(actor: User, slug: string, residency: DataResidency): Promise<Result<DataResidency>>;
Workspaces own repositories565 /** Members only. */
566 listMembers(slug: string, viewer: Viewer): Promise<Result<Member[]>>;
567 /** Owners only. */
568 addMember(actor: User, slug: string, username: string): Promise<Result<boolean>>;
569 /** Owners only. */
570 removeMember(actor: User, slug: string, username: string): Promise<Result<boolean>>;
Agents as a team: lifecycle, merge queue, billing and a new shell571 /** Owners only. An empty name falls back to the slug. */
572 updateWorkspace(actor: User, slug: string, details: { name: string; description: string }): Promise<Result<Workspace>>;
Workspace names and icons, and a component kit for every control573 /**
Agents and memory, checks and conflicts, profiles, slug renames, custom domains574 * Owners only. Changes the slug, the first segment of the workspace's
575 * URLs; the display name is untouched. The old slug redirects to the new
576 * one, and stays reserved for this workspace, for `SLUG_HOLD_DAYS`.
577 * Publishes `workspace.renamed`.
578 */
579 renameWorkspace(actor: User, slug: string, newSlug: string): Promise<Result<Workspace>>;
580 /** Whether `renameWorkspace` would be allowed, changing nothing. */
581 checkWorkspaceRename(actor: User, slug: string, newSlug: string): Promise<Result<boolean>>;
582 /**
583 * The workspace's current slug when `slug` is one it was renamed from
Merge branch 'worktree-agent-a8385d293d42c913a'584 * within `SLUG_HOLD_DAYS`, or when `slug` is an alias staff set for it
585 * (`WorkspaceAlias`); null otherwise, including for a slug in use.
Agents and memory, checks and conflicts, profiles, slug renames, custom domains586 */
587 resolveSlug(slug: string): Promise<string | null>;
588 /**
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look589 * Owners only, a person only. `confirm` is the slug, typed out. Refused
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member590 * for a protected workspace, and while billing cannot settle it. Its
591 * repositories, projects and apps go with it; it is kept for
592 * `WORKSPACE_RESTORE_DAYS`, when g1t's staff can restore it, then purged.
593 * Its slug is never given to anyone else; the person whose username it is
594 * may make it again once it is purged. Publishes `workspace.deleting`.
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look595 */
596 deleteWorkspace(actor: User, slug: string, confirm: string): Promise<Result<boolean>>;
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member597 /** What `deleteWorkspace` would take with it, and what stands in its way, changing nothing. */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look598 checkWorkspaceDeletion(actor: User, slug: string): Promise<Result<WorkspaceDeletion>>;
599 /**
Workspace names and icons, and a component kit for every control600 * Owners only. `image` is the file in base64: PNG, JPEG, WebP or GIF, at
601 * most `MAX_AVATAR_BYTES`, checked by its bytes. Null removes the icon.
602 */
603 setWorkspaceAvatar(actor: User, slug: string, image: string | null): Promise<Result<Workspace>>;
604 /** A person's own avatar, as `setWorkspaceAvatar`: the new one, or null. */
605 setUserAvatar(user: User, image: string | null): Promise<Result<string | null>>;
Workspaces own repositories606
Agents as a team: lifecycle, merge queue, billing and a new shell607 /**
608 * A workspace's own access tokens. They belong to the workspace, act as
609 * it, and keep working when the member who made one leaves. Members only.
610 */
611 listWorkspaceTokens(slug: string, viewer: Viewer): Promise<Result<AccessToken[]>>;
612 /** Owners only. The plaintext token is returned once and never stored. */
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step613 createWorkspaceToken(
614 actor: User,
615 slug: string,
616 name: string,
617 grant?: TokenGrant & { ttlSeconds?: number },
618 ): Promise<Result<{ token: string; info: AccessToken }>>;
Agents as a team: lifecycle, merge queue, billing and a new shell619 /** Owners only. */
620 removeWorkspaceToken(actor: User, slug: string, id: string): Promise<Result<boolean>>;
621
Initial g1t: services, event bus, intents and attempts622 userForSession(sessionToken: string): Promise<Viewer>;
623
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look624 /** Whether registration is invite-only. */
625 registration(): Promise<RegistrationMode>;
626 /** A person's invites and what they have left. */
627 listInvites(user: User): Promise<InvitesOverview>;
628 /**
629 * A person makes an invite, optionally for one address (emailed to it),
630 * using one of theirs or, with `workspace`, one the workspace was granted.
631 * People only: never an agent or a workspace's token.
632 */
633 createInvite(user: User, options?: { email?: string | null; workspace?: string | null }): Promise<Result<Invite>>;
634 /** Its maker, or an owner of its workspace, revokes a pending invite; the invite comes back. */
635 revokeInvite(user: User, id: string): Promise<Result<Invite>>;
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas636 /**
637 * What a code is for. Unknown, used, revoked and expired codes all get the
638 * same answer, unless `anyStatus`: then a real code that is spent is
639 * described, with its `status`. `viewer` sets `forViewer`.
640 */
641 checkInvite(
642 code: string,
643 client?: string | null,
644 options?: { viewer?: User | null; anyStatus?: boolean },
645 ): Promise<Result<InvitePreview>>;
646 /**
647 * A signed-in person uses a workspace invite sent to their address, or one
648 * sent with a repository invitation; returns the workspace's slug, or
649 * `workspace/repo`.
650 */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look651 acceptInvite(user: User, code: string): Promise<Result<string>>;
652 /** Owners only. Invites an address into a workspace, always with an invite bound to it. */
653 inviteMember(actor: User, slug: string, email: string): Promise<Result<Invite>>;
654 /** Owners only: the workspace's invites, newest first. */
655 workspaceInvites(slug: string, viewer: Viewer): Promise<Result<Invite[]>>;
656 /** Owners only. */
657 revokeWorkspaceInvite(actor: User, slug: string, id: string): Promise<Result<Invite>>;
658 /** Someone without an invite asks for one. Always the same answer for a valid address. */
659 requestAccess(email: string, about: string, client?: string | null): Promise<Result<boolean>>;
660
Initial g1t: services, event bus, intents and attempts661 /** Verifies git credentials: the account password or an access token. */
662 userForGitCredentials(username: string, secret: string): Promise<Viewer>;
API and MCP server, Rust identity service, registration, site redesign663 /** Resolves a `g1t_…` access token, as sent to the API and MCP server. */
664 userForAccessToken(token: string): Promise<Viewer>;
Initial g1t: services, event bus, intents and attempts665 userForSshKey(fingerprint: string): Promise<Viewer>;
666 userByUsername(username: string): Promise<Viewer>;
What happened across an outcome, as a feed beside its graph667 /** The names behind account and workspace ids; unknown ids are left out. */
668 usernames(ids: string[]): Promise<Record<string, string>>;
Initial g1t: services, event bus, intents and attempts669
Agents and memory, checks and conflicts, profiles, slug renames, custom domains670 /** A person's public profile, or null if there is no such account. Never an email address. */
671 profile(username: string): Promise<Profile | null>;
672 /** A person changes their own profile. Every field is replaced; an empty one is cleared. */
673 updateProfile(actor: User, fields: ProfileFields): Promise<Result<Profile>>;
674 /**
675 * The workspaces a profile shows `viewer`: those the viewer belongs to
676 * as well, and those of `publicIn` (where the person made a public
677 * project) that the person really belongs to. Nothing else.
678 */
679 profileWorkspaces(username: string, viewer: Viewer, publicIn: string[]): Promise<ProfileWorkspace[]>;
680
Initial g1t: services, event bus, intents and attempts681 listSshKeys(user: User): Promise<SshKey[]>;
682 /** Takes one line in OpenSSH public key format. */
683 addSshKey(user: User, title: string, publicKey: string): Promise<Result<SshKey>>;
684 removeSshKey(user: User, id: string): Promise<void>;
685
686 listAccessTokens(user: User): Promise<AccessToken[]>;
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)687 /**
Agents as a team: lifecycle, merge queue, billing and a new shell688 * The plaintext token is returned once and never stored. With
689 * `ttlSeconds` the token expires and is left out of token lists; that
690 * form is used for hosted agents. A token made for a workspace acting
691 * through a token of its own belongs to that workspace too.
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)692 */
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step693 createAccessToken(
694 user: User,
695 name: string,
696 ttlSeconds?: number,
697 grant?: TokenGrant & { listed?: boolean },
698 ): Promise<{ token: string; info: AccessToken }>;
699 /** Changes what one of a person's tokens may do; the token is unchanged. */
700 updateAccessToken(user: User, id: string, grant: TokenGrant): Promise<Result<AccessToken>>;
Agents as a team: lifecycle, merge queue, billing and a new shell701 /**
702 * A token for a g1t agent working for `onBehalfOf`: it acts as
g1t is one name: its agent's work, commits and comments show as @g1t, and nobody can claim g1t or g1t-agent703 * `g1t`, in `scope.repo` only, and only for `scope.operations`.
Agents as a team: lifecycle, merge queue, billing and a new shell704 */
705 createAgentToken(
706 onBehalfOf: User,
707 scope: AgentScope,
708 ttlSeconds: number,
709 ): Promise<{ token: string; info: AccessToken }>;
Initial g1t: services, event bus, intents and attempts710 removeAccessToken(user: User, id: string): Promise<void>;
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API711 /**
712 * A token for one sandbox run: it acts as the agent on behalf of
713 * `onBehalfOf`, can do only what the run's kind needs in `repo`, and
714 * expires after `ttlSeconds`. See `audit.ts`.
715 */
716 createRunCredential(input: CreateRunCredentialInput): Promise<{ token: string; info: AccessToken }>;
717 /** Ties tokens, by the SHA-256 of their text in hex, to the agent run their sandbox recorded. */
718 bindRunCredentials(tokenHashes: string[], runId: string): Promise<boolean>;
719 /** Ends a sandbox's run credentials, by hash or by run. Never touches another token. */
720 revokeRunCredentials(target: { tokenHashes?: string[]; runId?: string | null }): Promise<boolean>;
Initial g1t: services, event bus, intents and attempts721}
Agents as a team: lifecycle, merge queue, billing and a new shell722
723
724/** What an agent's token may do: these operations, in this repository. */
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API725export type AgentScope = { repo: RepoPath; operations: string[]; run?: RunBinding };
Agents and memory, checks and conflicts, profiles, slug renames, custom domains726
727/** The most characters each profile field takes. Mirrors `crates/contracts/src/identity.rs`. */
728export const PROFILE_LIMITS = { name: 80, bio: 160, location: 80, website: 200, pronouns: 40 } as const;
729
730/** What anyone may see about a person, at `g1t.sh/u/<username>`. */
731export type Profile = {
732 username: string;
733 /** The name they go by, if they gave one. */
734 name: string | null;
735 bio: string | null;
736 location: string | null;
737 /** Always an `https://` address. */
738 website: string | null;
739 pronouns: string | null;
740 /** The uploaded avatar's hash, served at `/avatars/<avatar>`. */
741 avatar: string | null;
742 /** When the account was made. RFC 3339. */
743 createdAt: string;
744};
745
746/** What a person may change on their profile. Empty clears a field. */
747export type ProfileFields = {
748 name: string;
749 bio: string;
750 location: string;
751 /** `https://…`; a bare `example.com` is taken as `https://example.com`. */
752 website: string;
753 pronouns: string;
754};
755
756/** A workspace on a person's profile. */
757export type ProfileWorkspace = { slug: string; name: string; avatar: string | null };

This file's history is long; its oldest lines are credited to the oldest commit read.