Skip to content
720 linesCodeBlameRaw

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";
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar5import type { 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;
51 };
Email verification, password reset, and Git for AI scale positioning52};
Initial g1t: services, event bus, intents and attempts53
Workspaces own repositories54/** What a member may do: an owner also manages the workspace's members. */
55export type Role = "owner" | "member";
56
Workspace names and icons, and a component kit for every control57export type Membership = {
58 /** The workspace's name in URLs: `g1t.sh/<slug>`. */
59 slug: string;
60 role: Role;
61 /** Its display name. Set on users resolved from credentials. */
62 name?: string;
63 /** Its uploaded icon, as `Workspace.avatar`. */
64 avatar?: string;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look65 /** The workspace's base permission: what members get on every repository. Absent means `write`. */
66 base_permission?: BasePermission;
Workspace names and icons, and a component kit for every control67};
Workspaces own repositories68
Agents and memory, checks and conflicts, profiles, slug renames, custom domains69/** How long an old workspace slug redirects, and stays reserved for it, after a rename. */
70export const SLUG_HOLD_DAYS = 90;
71
72/** How long a workspace must wait between renames. */
73export const RENAME_COOLDOWN_HOURS = 24;
74
Workspace names and icons, and a component kit for every control75/** The largest avatar that can be uploaded, in bytes. */
76export const MAX_AVATAR_BYTES = 1024 * 1024;
77
Workspaces own repositories78/**
Merge branch 'worktree-agent-a2013627e5ea4ab13'79 * Where a workspace keeps its repositories' git data: anywhere g1t stores
80 * it (the default), or in the EU only. It applies to repositories made
81 * after it is set.
82 */
83export type DataResidency = "anywhere" | "eu";
84
85/**
Workspaces own repositories86 * A workspace: the owner of repositories, and the first segment of their
87 * URLs. A person's own space and a team's are the same thing.
88 */
89export type Workspace = {
90 id: string;
91 slug: string;
92 name: string;
Agents as a team: lifecycle, merge queue, billing and a new shell93 /** One line saying what the workspace is for. */
94 description: string | null;
Workspaces own repositories95 /** RFC 3339. */
96 createdAt: string;
97 memberCount: number;
Workspace names and icons, and a component kit for every control98 /**
99 * The workspace's uploaded icon: the SHA-256 of its bytes, served at
100 * `/avatars/<avatar>`. Null means the generated letter avatar.
101 */
102 avatar: string | null;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look103 /** What every member gets on each repository; owners have Admin. */
104 basePermission?: BasePermission;
Workspaces own repositories105};
106
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look107export type Member = {
108 username: string;
109 role: Role;
110 /** Their display name, when they set one. */
111 name?: string | null;
112 /** Their uploaded avatar's hash, served at `/avatars/<avatar>`; null for the generated letter avatar. */
113 avatar?: string | null;
114};
Workspaces own repositories115
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace116/** An owner of a workspace, as staff see them. */
117export type AdminOwner = { username: string; email: string | null };
118
119/** A workspace as staff see it. Mirrors `AdminWorkspace` in `crates/contracts/src/identity.rs`. */
120export type AdminWorkspace = {
121 slug: string;
122 name: string;
123 /** RFC 3339. */
124 createdAt: string;
125 owners: AdminOwner[];
126 memberCount: number;
127};
128
129/** A member of a workspace, as staff see them. */
130export type AdminMember = { username: string; email: string | null; role: Role; /** RFC 3339. */ joined: string };
131
132export type AdminWorkspaceDetail = {
133 slug: string;
134 name: string;
135 description: string | null;
136 /** RFC 3339. */
137 createdAt: string;
138 /** Owners first, then by username. */
139 members: AdminMember[];
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member140 /** It can never be deleted, by anyone (identity's `PROTECTED_WORKSPACES`). */
141 protected: boolean;
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace142};
143
144/** The most workspaces one `workspaces` call returns. */
145export const ADMIN_WORKSPACES_LIMIT = 500;
146
147/**
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look148 * Whether anyone may make an account, or only someone with an invite.
149 * Identity's `REGISTRATION_MODE`; unset means `invite`.
150 */
151export type RegistrationMode = "invite" | "open";
152
153/** How many invites a person may have out at once, unless identity's `INVITES_PER_USER` says otherwise. */
154export const INVITES_PER_USER = 5;
155/** How long an invite works, unless identity's `INVITE_TTL_DAYS` says otherwise. */
156export const INVITE_TTL_DAYS = 30;
157
158/** Only a pending invite can be used or revoked. Revoked and expired ones never used give the invite back. */
159export type InviteStatus = "pending" | "redeemed" | "expired" | "revoked";
160
161/** One invite. Mirrors `Invite` in `crates/contracts/src/identity.rs`. */
162export type Invite = {
163 id: string;
164 /** `g1t-k7m2-…`: returned when it is made, and to its maker while pending. */
165 code: string | null;
166 /** The code's first group, such as `g1t-k7m2`. */
167 hint: string;
168 /** Only this address can use it. */
169 email: string | null;
170 /** `account` makes an account; `workspace` joins an existing one to `workspace`. */
171 kind: "account" | "workspace";
172 /** The workspace using it joins. */
173 workspace: string | null;
174 status: InviteStatus;
175 /** Whose allowance it used. */
176 chargedTo: "user" | "workspace" | "none";
177 /** Its maker's username; null when g1t staff made it. */
178 invitedBy: string | null;
179 /** The account that used it. */
180 redeemedBy: string | null;
181 /** RFC 3339. */
182 createdAt: string;
183 /** RFC 3339. */
184 expiresAt: string;
185 redeemedAt: string | null;
186 revokedAt: string | null;
187 /** The staff member who minted it; only in staff views. */
188 staff?: string | null;
189};
190
191/** How many invites someone may have out. `limit` and `remaining` are null for no limit. */
192export type Allowance = { limit: number | null; used: number; remaining: number | null };
193
194export type InvitesOverview = {
195 mode: RegistrationMode;
196 allowance: Allowance;
197 /** Workspaces the person owns that were granted invites to share. */
198 workspaces: { slug: string; allowance: Allowance }[];
199 invites: Invite[];
200};
201
202/** What a valid code is for, before it is used. */
203export type InvitePreview = {
204 kind: "account" | "workspace";
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas205 /** Pending, unless `anyStatus` asked about a code that is spent. */
206 status: InviteStatus;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look207 /** Null when g1t staff sent it. */
208 invitedBy: { username: string; name: string | null; avatar: string | null } | null;
209 workspace: ProfileWorkspace | null;
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas210 /** The repository it accepts an invitation to, such as `{ name: "flagon-io/g1t", role: "write" }`. */
211 repository: { name: string; role: string } | null;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look212 /** Partly hidden, such as `a•••@example.com`. */
213 email: string | null;
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas214 /** The bound address in full, while the invite is pending: it fills in and locks the sign-up form. */
215 address: string | null;
216 /** Whether the bound address has a g1t account already: sign in to accept. */
217 hasAccount: boolean;
218 /** With a viewer: whether it is theirs (for one of their confirmed addresses, or used by them). */
219 forViewer: boolean | null;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look220 expiresAt: string;
221};
222
223export type WaitlistStatus = "waiting" | "invited" | "dismissed";
224
225export type WaitlistEntry = {
226 id: string;
227 email: string;
228 about: string | null;
229 status: WaitlistStatus;
230 inviteId: string | null;
231 decidedBy: string | null;
232 decidedAt: string | null;
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas233 /** What staff wrote when approving; it went in the invite email. */
234 note: string | null;
235 /** The account made with the invite, once it was used. */
236 joinedAs: string | null;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look237 /** When they first asked. */
238 createdAt: string;
239 /** When they last asked. */
240 updatedAt: string;
241};
242
243export type InviteGrant = { amount: number; note: string | null; grantedBy: string; createdAt: string };
244export type InviteTreeNode = { username: string; joinedAt: string; invited: InviteTreeNode[] };
245
246/** Where a person came from and whom they brought. For a workspace, `username` is its slug. */
247export type InviteTree = {
248 username: string;
249 /** Who invited them, then who invited that person, and so on. */
250 invitedBy: string[];
251 /** The staff member who minted their invite, when staff did. */
252 staff: string | null;
253 allowance: Allowance;
254 grants: InviteGrant[];
255 invites: Invite[];
256 /** Whom they invited, three levels down. */
257 invited: InviteTreeNode[];
258};
259
260/** The most rows one staff listing of invites or the waitlist returns. */
261export const ADMIN_INVITES_LIMIT = 500;
262
263/**
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace264 * Staff-only identity, for sudo.g1t.sh. It takes no viewer and checks no
265 * membership: only sudo calls it, over its service binding, once Cloudflare
266 * Access and its staff list have let someone in. Never call it on behalf of
267 * a customer.
268 */
269export interface IdentityAdminApi {
270 /** Every workspace, newest first, at most 500; `query` matches slug, name, or an owner's username or email. */
271 workspaces(query?: string): Promise<AdminWorkspace[]>;
272 /** One workspace with all its members, or null. */
273 workspace(slug: string): Promise<AdminWorkspaceDetail | null>;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look274
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas275 /** 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 look276 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 quotas277 /** How many requests are waiting, for the navigation's badge. */
278 waitlistPending(): Promise<number>;
279 /**
280 * Approving mints an invite bound to the address and emails it, with
281 * `note` (up to 500 characters) if given; dismissing only marks it.
282 */
283 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 look284 /** Invites, newest first; `query` is a code's start, or part of an email, inviter or redeemer. */
285 invites(query?: string | null): Promise<Invite[]>;
286 revokeInvite(id: string, staff: string): Promise<Result<Invite>>;
287 /** An invite that uses nobody's allowance, optionally bound to (and emailed to) `email`. */
288 mintInvite(email: string | null, staff: string): Promise<Result<Invite>>;
289 /** More invites (or fewer, with a negative amount) for a person or a workspace. */
290 grantInvites(
291 target: "user" | "workspace",
292 name: string,
293 amount: number,
294 note: string,
295 staff: string,
296 ): Promise<Result<Allowance>>;
297 /** Where a person came from and whom they brought, or null. */
298 inviteTree(username: string): Promise<InviteTree | null>;
299 /** A workspace's granted invites and the invites made for it, or null. */
300 workspaceInvites(slug: string): Promise<InviteTree | null>;
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member301
302 /** Workspaces owners deleted that are not purged yet, newest first. */
303 deletedWorkspaces(): Promise<DeletedWorkspace[]>;
304 /**
305 * Brings a deleted workspace back, with its members, tokens and what went
306 * with it, while it is still restorable. Publishes `workspace.restored`.
307 */
308 restoreWorkspace(workspaceId: string, staff: string): Promise<Result<boolean>>;
309 /**
310 * Purges a deleted workspace now rather than at `purgeAfter`. `confirm` is
311 * its slug, typed out. Refused for a protected workspace. Publishes
312 * `workspace.deleted`.
313 */
314 purgeWorkspace(workspaceId: string, staff: string, confirm: string): Promise<Result<boolean>>;
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace315}
316
Initial g1t: services, event bus, intents and attempts317/** Who is asking. Every read and write in every service takes one. */
318export type Viewer = User | null;
319
320export type SshKey = {
321 id: string;
322 title: string;
323 fingerprint: string;
RFC 3339 timestamps in identity and repos324 /** RFC 3339. */
325 createdAt: string;
Initial g1t: services, event bus, intents and attempts326};
327
Agents as a team: lifecycle, merge queue, billing and a new shell328export type AccessToken = {
329 id: string;
330 name: string;
331 /** RFC 3339. */
332 createdAt: string;
333 /** RFC 3339, to within a few minutes. Null until it is first used. */
334 lastUsedAt: string | null;
335 /**
336 * For a workspace's token, the username of the member who made it. Null
337 * once that account is gone, and on personal tokens.
338 */
339 createdBy: string | null;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step340 /** Its scopes, as `resource:level`. Null: full access. */
341 scopes: string[] | null;
342 /** Made before tokens had scopes: full access until someone narrows it. */
343 legacy: boolean;
344 /** RFC 3339. Null: it does not expire. */
345 expiresAt: string | null;
346};
347
348/** What a new or changed token may do. */
349export type TokenGrant = {
350 /** Null: full access. */
351 scopes: string[] | null;
Agents as a team: lifecycle, merge queue, billing and a new shell352};
Initial g1t: services, event bus, intents and attempts353
Device sign-in replaces registering and minting tokens over the API354export type DeviceStart = {
355 /** Secret held by the tool and exchanged for a token once approved. */
356 deviceCode: string;
357 /** Short code shown to the person, e.g. `WDJB-MJHT`. */
358 userCode: string;
359 /** Seconds until both codes stop working. */
360 expiresIn: number;
361 /** Seconds the tool should wait between polls. */
362 interval: number;
363};
364
365export type DeviceRequest = { userCode: string; clientName: string };
366
367export type DeviceClaim =
368 | { status: "pending" | "denied" | "expired" }
369 | { status: "approved"; token: string; user: User };
370
OAuth 2.1 sign-in for MCP clients and other applications371/** What the site passes on once a person has approved an application. */
372export type OAuthApproval = {
373 clientId: string;
374 /** Shown wherever the application's access is listed. */
375 clientName: string;
376 redirectUri: string;
377 /** PKCE challenge, method S256. */
378 codeChallenge: string;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step379 /** What the person granted. Null: full access. */
380 scopes: string[] | null;
OAuth 2.1 sign-in for MCP clients and other applications381};
382
383export type OAuthTokens = {
384 accessToken: string;
385 /** Works once; using it returns the next one. */
386 refreshToken: string;
387 /** Seconds until the access token stops working. */
388 expiresIn: number;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step389 /** The scopes granted, space-separated, or `*` for full access. */
390 scope?: string | null;
OAuth 2.1 sign-in for MCP clients and other applications391};
392
393/** An application a person has signed in to. */
394export type OAuthGrant = {
395 id: string;
396 clientName: string;
397 /** RFC 3339. */
398 createdAt: string;
399 /** RFC 3339. */
400 lastUsedAt: string;
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step401 /** What the person granted. Null: full access. */
402 scopes: string[] | null;
403 /** Signed in before applications had scopes: full access until narrowed. */
404 legacy: boolean;
OAuth 2.1 sign-in for MCP clients and other applications405};
406
Initial g1t: services, event bus, intents and attempts407/** Accounts, credentials and sessions. */
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member408/**
409 * What deleting a workspace takes with it, and what stands in the way:
410 * nothing does while `billing` is null and it is not `protected`.
411 */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look412export type WorkspaceDeletion = {
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member413 /** Its live repositories, deleted with it. */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look414 repositories: number;
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member415 /** Its projects, hidden with it. */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look416 projects: number;
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member417 members: number;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look418 /** Why billing cannot close it yet, in words for its owner. */
419 billing: string | null;
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member420 /** It can never be deleted, by anyone. */
421 protected: boolean;
422};
423
424/** How long a deleted workspace is kept, for g1t's staff to restore, before it is purged. */
425export const WORKSPACE_RESTORE_DAYS = 30;
426
427/**
428 * Workspaces nobody can delete, whatever identity's `PROTECTED_WORKSPACES`
429 * says: Flagon's, which runs g1t. Services that act on `workspace.deleting`
430 * check it too, so one published for it by mistake changes nothing.
431 */
432export const ALWAYS_PROTECTED_WORKSPACES: readonly string[] = ["flagon-io"];
433
434/** Whether `slug` is one of `ALWAYS_PROTECTED_WORKSPACES`, in any case. */
435export function isProtectedWorkspace(slug: string): boolean {
436 return ALWAYS_PROTECTED_WORKSPACES.includes(slug.trim().toLowerCase());
437}
438
439/** A workspace an owner deleted, kept until `purgeAfter` for staff to restore. */
440export type DeletedWorkspace = {
441 workspaceId: string;
442 slug: string;
443 name: string;
444 /** RFC 3339. */
445 deletedAt: string;
446 /** The username of the owner who deleted it. */
447 deletedBy: string;
448 /** RFC 3339: when it is purged unless restored first. */
449 purgeAfter: string;
450 /** What went with it, counted when it was deleted. */
451 went: WorkspaceDeletion;
452 /** Whether staff can still restore it. */
453 restorable: boolean;
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look454};
455
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar456export interface IdentityApi extends AccessClient, TeamsClient {
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look457 /**
458 * Creates an account and signs it in. While registration is invite-only,
459 * `inviteCode` must be an unused, unexpired invite (and, when it names an
460 * email, that address); it is ignored while registration is open.
461 */
462 register(
463 username: string,
464 email: string,
465 password: string,
466 inviteCode?: string | null,
467 /** Who is asking, such as the visitor's IP address, for rate limits. */
468 client?: string | null,
469 ): Promise<Result<{ user: User; sessionToken: string }>>;
Initial g1t: services, event bus, intents and attempts470 /** Verifies a username and password for website sign-in. */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look471 /**
472 * Verifies a username, or any confirmed address of the account, and its
473 * password. Wrong passwords are counted against the account and `client`
474 * (the visitor's IP address); past a limit nothing is checked for a while.
475 */
476 signIn(username: string, password: string, client?: string | null): Promise<Result<{ user: User; sessionToken: string }>>;
Initial g1t: services, event bus, intents and attempts477 signOut(sessionToken: string): Promise<void>;
Email verification, password reset, and Git for AI scale positioning478
479 /** Sends the confirmation email again. */
480 resendVerification(user: User): Promise<Result<boolean>>;
481 /** Confirms the address the emailed token was sent to. */
482 verifyEmail(token: string): Promise<Result<User>>;
483 /** 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 look484 /**
485 * Any confirmed address of an account works; the link goes to it, and the
486 * primary and backup are told. A few an hour per address and per `client`.
487 */
488 requestPasswordReset(email: string, client?: string | null): Promise<boolean>;
Email verification, password reset, and Git for AI scale positioning489 /** Sets a new password from an emailed token and ends every session. */
490 resetPassword(token: string, password: string): Promise<Result<User>>;
491
Device sign-in replaces registering and minting tokens over the API492 /**
493 * Device sign-in (RFC 8628). A tool starts a request, a person approves
494 * its short code in a browser, and the tool claims an access token.
495 */
496 deviceStart(clientName: string): Promise<DeviceStart>;
497 /** What a user code is asking for, or null if it is not valid. */
498 deviceLookup(userCode: string): Promise<DeviceRequest | null>;
499 deviceResolve(userCode: string, user: User, approve: boolean): Promise<Result<boolean>>;
500 deviceClaim(deviceCode: string): Promise<DeviceClaim>;
501
OAuth 2.1 sign-in for MCP clients and other applications502 /**
503 * OAuth 2.1 for applications that sign a person in through the browser.
504 * The caller has checked the client and its redirect address; this
505 * returns the one-time code the application exchanges for tokens.
506 */
507 oauthAuthorize(user: User, approval: OAuthApproval): Promise<{ code: string }>;
508 /** Redeems a code. It works once, for that client, with the PKCE verifier. */
509 oauthExchange(code: string, codeVerifier: string, clientId: string, redirectUri: string): Promise<Result<OAuthTokens>>;
510 /** Trades a refresh token for new tokens; the old ones stop working. */
511 oauthRefresh(refreshToken: string, clientId: string): Promise<Result<OAuthTokens>>;
512 /** Applications the user has signed in to, most recently used first. */
513 listOAuthGrants(user: User): Promise<OAuthGrant[]>;
514 /** Signs an application out. */
515 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 step516 /** Changes what an application may do, at once and when it refreshes. */
517 updateOAuthGrant(user: User, id: string, grant: TokenGrant): Promise<Result<OAuthGrant>>;
OAuth 2.1 sign-in for MCP clients and other applications518
Workspaces own repositories519 createWorkspace(user: User, slug: string, name: string): Promise<Result<Workspace>>;
520 /** Public details of a workspace, or null. */
521 getWorkspace(slug: string): Promise<Workspace | null>;
Merge branch 'worktree-agent-a2013627e5ea4ab13'522 /** Where a workspace keeps its repositories' git data; null when there is no such workspace. */
523 workspaceResidency(slug: string): Promise<DataResidency | null>;
524 /**
525 * Owners only. Applies to repositories made from then on. Offer `eu`
526 * only when the repos service's `storageOptions()` says it is available.
527 */
528 setWorkspaceResidency(actor: User, slug: string, residency: DataResidency): Promise<Result<DataResidency>>;
Workspaces own repositories529 /** Members only. */
530 listMembers(slug: string, viewer: Viewer): Promise<Result<Member[]>>;
531 /** Owners only. */
532 addMember(actor: User, slug: string, username: string): Promise<Result<boolean>>;
533 /** Owners only. */
534 removeMember(actor: User, slug: string, username: string): Promise<Result<boolean>>;
Agents as a team: lifecycle, merge queue, billing and a new shell535 /** Owners only. An empty name falls back to the slug. */
536 updateWorkspace(actor: User, slug: string, details: { name: string; description: string }): Promise<Result<Workspace>>;
Workspace names and icons, and a component kit for every control537 /**
Agents and memory, checks and conflicts, profiles, slug renames, custom domains538 * Owners only. Changes the slug, the first segment of the workspace's
539 * URLs; the display name is untouched. The old slug redirects to the new
540 * one, and stays reserved for this workspace, for `SLUG_HOLD_DAYS`.
541 * Publishes `workspace.renamed`.
542 */
543 renameWorkspace(actor: User, slug: string, newSlug: string): Promise<Result<Workspace>>;
544 /** Whether `renameWorkspace` would be allowed, changing nothing. */
545 checkWorkspaceRename(actor: User, slug: string, newSlug: string): Promise<Result<boolean>>;
546 /**
547 * The workspace's current slug when `slug` is one it was renamed from
548 * within `SLUG_HOLD_DAYS`; null otherwise, including for a slug in use.
549 */
550 resolveSlug(slug: string): Promise<string | null>;
551 /**
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look552 * 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 member553 * for a protected workspace, and while billing cannot settle it. Its
554 * repositories, projects and apps go with it; it is kept for
555 * `WORKSPACE_RESTORE_DAYS`, when g1t's staff can restore it, then purged.
556 * Its slug is never given to anyone else; the person whose username it is
557 * 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 look558 */
559 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 member560 /** 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 look561 checkWorkspaceDeletion(actor: User, slug: string): Promise<Result<WorkspaceDeletion>>;
562 /**
Workspace names and icons, and a component kit for every control563 * Owners only. `image` is the file in base64: PNG, JPEG, WebP or GIF, at
564 * most `MAX_AVATAR_BYTES`, checked by its bytes. Null removes the icon.
565 */
566 setWorkspaceAvatar(actor: User, slug: string, image: string | null): Promise<Result<Workspace>>;
567 /** A person's own avatar, as `setWorkspaceAvatar`: the new one, or null. */
568 setUserAvatar(user: User, image: string | null): Promise<Result<string | null>>;
Workspaces own repositories569
Agents as a team: lifecycle, merge queue, billing and a new shell570 /**
571 * A workspace's own access tokens. They belong to the workspace, act as
572 * it, and keep working when the member who made one leaves. Members only.
573 */
574 listWorkspaceTokens(slug: string, viewer: Viewer): Promise<Result<AccessToken[]>>;
575 /** 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 step576 createWorkspaceToken(
577 actor: User,
578 slug: string,
579 name: string,
580 grant?: TokenGrant & { ttlSeconds?: number },
581 ): Promise<Result<{ token: string; info: AccessToken }>>;
Agents as a team: lifecycle, merge queue, billing and a new shell582 /** Owners only. */
583 removeWorkspaceToken(actor: User, slug: string, id: string): Promise<Result<boolean>>;
584
Initial g1t: services, event bus, intents and attempts585 userForSession(sessionToken: string): Promise<Viewer>;
586
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look587 /** Whether registration is invite-only. */
588 registration(): Promise<RegistrationMode>;
589 /** A person's invites and what they have left. */
590 listInvites(user: User): Promise<InvitesOverview>;
591 /**
592 * A person makes an invite, optionally for one address (emailed to it),
593 * using one of theirs or, with `workspace`, one the workspace was granted.
594 * People only: never an agent or a workspace's token.
595 */
596 createInvite(user: User, options?: { email?: string | null; workspace?: string | null }): Promise<Result<Invite>>;
597 /** Its maker, or an owner of its workspace, revokes a pending invite; the invite comes back. */
598 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 quotas599 /**
600 * What a code is for. Unknown, used, revoked and expired codes all get the
601 * same answer, unless `anyStatus`: then a real code that is spent is
602 * described, with its `status`. `viewer` sets `forViewer`.
603 */
604 checkInvite(
605 code: string,
606 client?: string | null,
607 options?: { viewer?: User | null; anyStatus?: boolean },
608 ): Promise<Result<InvitePreview>>;
609 /**
610 * A signed-in person uses a workspace invite sent to their address, or one
611 * sent with a repository invitation; returns the workspace's slug, or
612 * `workspace/repo`.
613 */
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look614 acceptInvite(user: User, code: string): Promise<Result<string>>;
615 /** Owners only. Invites an address into a workspace, always with an invite bound to it. */
616 inviteMember(actor: User, slug: string, email: string): Promise<Result<Invite>>;
617 /** Owners only: the workspace's invites, newest first. */
618 workspaceInvites(slug: string, viewer: Viewer): Promise<Result<Invite[]>>;
619 /** Owners only. */
620 revokeWorkspaceInvite(actor: User, slug: string, id: string): Promise<Result<Invite>>;
621 /** Someone without an invite asks for one. Always the same answer for a valid address. */
622 requestAccess(email: string, about: string, client?: string | null): Promise<Result<boolean>>;
623
Initial g1t: services, event bus, intents and attempts624 /** Verifies git credentials: the account password or an access token. */
625 userForGitCredentials(username: string, secret: string): Promise<Viewer>;
API and MCP server, Rust identity service, registration, site redesign626 /** Resolves a `g1t_…` access token, as sent to the API and MCP server. */
627 userForAccessToken(token: string): Promise<Viewer>;
Initial g1t: services, event bus, intents and attempts628 userForSshKey(fingerprint: string): Promise<Viewer>;
629 userByUsername(username: string): Promise<Viewer>;
What happened across an outcome, as a feed beside its graph630 /** The names behind account and workspace ids; unknown ids are left out. */
631 usernames(ids: string[]): Promise<Record<string, string>>;
Initial g1t: services, event bus, intents and attempts632
Agents and memory, checks and conflicts, profiles, slug renames, custom domains633 /** A person's public profile, or null if there is no such account. Never an email address. */
634 profile(username: string): Promise<Profile | null>;
635 /** A person changes their own profile. Every field is replaced; an empty one is cleared. */
636 updateProfile(actor: User, fields: ProfileFields): Promise<Result<Profile>>;
637 /**
638 * The workspaces a profile shows `viewer`: those the viewer belongs to
639 * as well, and those of `publicIn` (where the person made a public
640 * project) that the person really belongs to. Nothing else.
641 */
642 profileWorkspaces(username: string, viewer: Viewer, publicIn: string[]): Promise<ProfileWorkspace[]>;
643
Initial g1t: services, event bus, intents and attempts644 listSshKeys(user: User): Promise<SshKey[]>;
645 /** Takes one line in OpenSSH public key format. */
646 addSshKey(user: User, title: string, publicKey: string): Promise<Result<SshKey>>;
647 removeSshKey(user: User, id: string): Promise<void>;
648
649 listAccessTokens(user: User): Promise<AccessToken[]>;
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)650 /**
Agents as a team: lifecycle, merge queue, billing and a new shell651 * The plaintext token is returned once and never stored. With
652 * `ttlSeconds` the token expires and is left out of token lists; that
653 * form is used for hosted agents. A token made for a workspace acting
654 * through a token of its own belongs to that workspace too.
Account dropdown, llms.txt onboarding, hosted agent runner (not yet deployed)655 */
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step656 createAccessToken(
657 user: User,
658 name: string,
659 ttlSeconds?: number,
660 grant?: TokenGrant & { listed?: boolean },
661 ): Promise<{ token: string; info: AccessToken }>;
662 /** Changes what one of a person's tokens may do; the token is unchanged. */
663 updateAccessToken(user: User, id: string, grant: TokenGrant): Promise<Result<AccessToken>>;
Agents as a team: lifecycle, merge queue, billing and a new shell664 /**
665 * 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-agent666 * `g1t`, in `scope.repo` only, and only for `scope.operations`.
Agents as a team: lifecycle, merge queue, billing and a new shell667 */
668 createAgentToken(
669 onBehalfOf: User,
670 scope: AgentScope,
671 ttlSeconds: number,
672 ): Promise<{ token: string; info: AccessToken }>;
Initial g1t: services, event bus, intents and attempts673 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 API674 /**
675 * A token for one sandbox run: it acts as the agent on behalf of
676 * `onBehalfOf`, can do only what the run's kind needs in `repo`, and
677 * expires after `ttlSeconds`. See `audit.ts`.
678 */
679 createRunCredential(input: CreateRunCredentialInput): Promise<{ token: string; info: AccessToken }>;
680 /** Ties tokens, by the SHA-256 of their text in hex, to the agent run their sandbox recorded. */
681 bindRunCredentials(tokenHashes: string[], runId: string): Promise<boolean>;
682 /** Ends a sandbox's run credentials, by hash or by run. Never touches another token. */
683 revokeRunCredentials(target: { tokenHashes?: string[]; runId?: string | null }): Promise<boolean>;
Initial g1t: services, event bus, intents and attempts684}
Agents as a team: lifecycle, merge queue, billing and a new shell685
686
687/** 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 API688export type AgentScope = { repo: RepoPath; operations: string[]; run?: RunBinding };
Agents and memory, checks and conflicts, profiles, slug renames, custom domains689
690/** The most characters each profile field takes. Mirrors `crates/contracts/src/identity.rs`. */
691export const PROFILE_LIMITS = { name: 80, bio: 160, location: 80, website: 200, pronouns: 40 } as const;
692
693/** What anyone may see about a person, at `g1t.sh/u/<username>`. */
694export type Profile = {
695 username: string;
696 /** The name they go by, if they gave one. */
697 name: string | null;
698 bio: string | null;
699 location: string | null;
700 /** Always an `https://` address. */
701 website: string | null;
702 pronouns: string | null;
703 /** The uploaded avatar's hash, served at `/avatars/<avatar>`. */
704 avatar: string | null;
705 /** When the account was made. RFC 3339. */
706 createdAt: string;
707};
708
709/** What a person may change on their profile. Empty clears a field. */
710export type ProfileFields = {
711 name: string;
712 bio: string;
713 location: string;
714 /** `https://…`; a bare `example.com` is taken as `https://example.com`. */
715 website: string;
716 pronouns: string;
717};
718
719/** A workspace on a person's profile. */
720export 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.