g1t/packages/contracts/src/clients.ts

631 lines36,803 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.

GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs1import type { ActionsApi } from "./actions";
Billing accounts, terms and enterprises; g1t is no longer free2import type { BillingAdminApi, BillingApi } from "./billing";
Deployments: a preview for every pull request, production on g1t.page3import type { DeploymentsApi } from "./deployments";
Projects: what a workspace builds and runs, first on every page4import type { ProjectsApi } from "./projects";
Events service in Rust, with RFC 3339 times and accurate push events5import type { EventsApi } from "./events";
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace6import type { IdentityAdminApi, IdentityApi } from "./identity";
Integrations: your own model provider, alerts that open issues, tickets agents read7import type { IntegrationsApi } from "./integrations";
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member8import type { PackagesApi } from "./packages";
Webhooks: every event, to your own addresses, signed and retried9import type { WebhooksApi } from "./webhooks";
Rust repos service with shipping; pull requests kept in the model10import type { ReposApi } from "./repos";
Work service in Rust, with RFC 3339 timestamps11import type { WorkApi } from "./work";
Fast pages, required checks on the branch, self-hosted runners, honest incidents12import type { RunnersApi } from "./runners";
API and MCP server, Rust identity service, registration, site redesign13
14/** A service binding, as far as these clients need it. */
15export type ServiceBinding = {
16 fetch(input: string, init?: RequestInit): Promise<Response>;
17};
18
19/**
20 * Calls a method on a service that speaks the JSON protocol used by the
21 * Rust services: `POST /rpc/<method>` with the arguments as the body.
22 */
23async function rpc<T>(
24 service: ServiceBinding,
25 method: string,
26 args: object,
27): Promise<T> {
28 // The hostname is ignored; a service binding always reaches its service.
29 const response = await service.fetch(`https://service/rpc/${method}`, {
30 method: "POST",
31 headers: { "content-type": "application/json" },
32 body: JSON.stringify(args),
33 });
34 if (!response.ok) {
35 throw new Error(`${method} failed with status ${response.status}`);
36 }
Agents as a team: lifecycle, merge queue, billing and a new shell37 return (await response.json()) as T;
API and MCP server, Rust identity service, registration, site redesign38}
39
40export function identityClient(service: ServiceBinding): IdentityApi {
41 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
42 return {
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look43 register: (username, email, password, inviteCode, client) =>
44 call("register", { username, email, password, invite_code: inviteCode ?? null, client: client ?? null }),
45 signIn: (username, password, client) => call("sign_in", { username, password, client: client ?? null }),
API and MCP server, Rust identity service, registration, site redesign46 signOut: (sessionToken) => call("sign_out", { sessionToken }),
Email verification, password reset, and Git for AI scale positioning47 resendVerification: (user) => call("resend_verification", { user }),
48 verifyEmail: (token) => call("verify_email", { token }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look49 requestPasswordReset: (email, client) => call("request_password_reset", { email, client: client ?? null }),
Email verification, password reset, and Git for AI scale positioning50 resetPassword: (token, password) =>
51 call("reset_password", { token, password }),
Device sign-in replaces registering and minting tokens over the API52 deviceStart: (clientName) => call("device_start", { clientName }),
53 deviceLookup: (userCode) => call("device_lookup", { userCode }),
54 deviceResolve: (userCode, user, approve) =>
55 call("device_resolve", { userCode, user, approve }),
56 deviceClaim: (deviceCode) => call("device_claim", { deviceCode }),
OAuth 2.1 sign-in for MCP clients and other applications57 oauthAuthorize: (user, approval) => call("oauth_authorize", { user, ...approval }),
58 oauthExchange: (code, codeVerifier, clientId, redirectUri) =>
59 call("oauth_exchange", { code, codeVerifier, clientId, redirectUri }),
60 oauthRefresh: (refreshToken, clientId) =>
61 call("oauth_refresh", { refreshToken, clientId }),
62 listOAuthGrants: (user) => call("list_oauth_grants", { user }),
63 revokeOAuthGrant: (user, id) => call("revoke_oauth_grant", { user, id }),
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step64 updateOAuthGrant: (user, id, grant) =>
65 call("update_oauth_grant", { user, id, scopes: grant.scopes }),
Workspaces own repositories66 createWorkspace: (user, slug, name) => call("create_workspace", { user, slug, name }),
67 getWorkspace: (slug) => call("get_workspace", { slug }),
68 listMembers: (slug, viewer) => call("list_members", { slug, viewer }),
69 addMember: (actor, slug, username) => call("add_member", { actor, slug, username }),
70 removeMember: (actor, slug, username) =>
71 call("remove_member", { actor, slug, username }),
Agents as a team: lifecycle, merge queue, billing and a new shell72 updateWorkspace: (actor, slug, details) =>
73 call("update_workspace", { actor, slug, ...details }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains74 renameWorkspace: (actor, slug, newSlug) => call("rename_workspace", { actor, slug, newSlug }),
75 checkWorkspaceRename: (actor, slug, newSlug) =>
76 call("check_workspace_rename", { actor, slug, newSlug }),
77 resolveSlug: (slug) => call("resolve_slug", { slug }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look78 deleteWorkspace: (actor, slug, confirm) => call("delete_workspace", { actor, slug, confirm }),
79 checkWorkspaceDeletion: (actor, slug) => call("check_workspace_deletion", { actor, slug }),
Workspace names and icons, and a component kit for every control80 setWorkspaceAvatar: (actor, slug, image) => call("set_workspace_avatar", { actor, slug, image }),
81 setUserAvatar: (user, image) => call("set_user_avatar", { user, image }),
Agents as a team: lifecycle, merge queue, billing and a new shell82 listWorkspaceTokens: (slug, viewer) => call("list_workspace_tokens", { slug, viewer }),
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step83 createWorkspaceToken: (actor, slug, name, grant) =>
84 call("create_workspace_token", {
85 actor,
86 slug,
87 name,
88 scopes: grant?.scopes ?? null,
89 ttl_seconds: grant?.ttlSeconds ?? null,
90 }),
Agents as a team: lifecycle, merge queue, billing and a new shell91 removeWorkspaceToken: (actor, slug, id) =>
92 call("remove_workspace_token", { actor, slug, id }),
API and MCP server, Rust identity service, registration, site redesign93 userForSession: (sessionToken) => call("user_for_session", { sessionToken }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look94 registration: () => call("registration", {}),
95 listInvites: (user) => call("list_invites", { user }),
96 createInvite: (user, options = {}) =>
97 call("create_invite", { user, email: options.email ?? null, workspace: options.workspace ?? null }),
98 revokeInvite: (user, id) => call("revoke_invite", { user, id }),
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas99 checkInvite: (code, client, options = {}) =>
100 call("check_invite", {
101 code,
102 client: client ?? null,
103 viewer: options.viewer ?? null,
104 any_status: options.anyStatus ?? false,
105 }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look106 acceptInvite: (user, code) => call("accept_invite", { user, code }),
107 inviteMember: (actor, slug, email) => call("invite_member", { actor, slug, email }),
108 workspaceInvites: (slug, viewer) => call("workspace_invites", { slug, viewer }),
109 revokeWorkspaceInvite: (actor, slug, id) => call("revoke_workspace_invite", { actor, slug, id }),
110 requestAccess: (email, about, client) => call("request_access", { email, about, client: client ?? null }),
API and MCP server, Rust identity service, registration, site redesign111 userForGitCredentials: (username, secret) =>
112 call("user_for_git_credentials", { username, secret }),
113 userForAccessToken: (token) => call("user_for_access_token", { token }),
114 userForSshKey: (fingerprint) => call("user_for_ssh_key", { fingerprint }),
115 userByUsername: (username) => call("user_by_username", { username }),
What happened across an outcome, as a feed beside its graph116 usernames: (ids) => call("usernames", { ids }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains117 profile: (username) => call("profile", { username }),
118 updateProfile: (actor, fields) => call("update_profile", { actor, ...fields }),
119 profileWorkspaces: (username, viewer, publicIn) =>
120 call("profile_workspaces", { username, viewer, public: publicIn }),
API and MCP server, Rust identity service, registration, site redesign121 listSshKeys: (user) => call("list_ssh_keys", { user }),
122 addSshKey: (user, title, publicKey) =>
123 call("add_ssh_key", { user, title, publicKey }),
124 removeSshKey: (user, id) => call("remove_ssh_key", { user, id }),
125 listAccessTokens: (user) => call("list_access_tokens", { user }),
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step126 createAccessToken: (user, name, ttlSeconds, grant) =>
127 call("create_access_token", {
128 user,
129 name,
130 ttlSeconds,
131 scopes: grant?.scopes ?? null,
132 listed: grant?.listed ?? false,
133 }),
134 updateAccessToken: (user, id, grant) =>
135 call("update_access_token", { user, id, scopes: grant.scopes }),
Agents as a team: lifecycle, merge queue, billing and a new shell136 createAgentToken: (onBehalfOf, scope, ttlSeconds) =>
137 call("create_agent_token", { onBehalfOf, scope, ttlSeconds }),
API and MCP server, Rust identity service, registration, site redesign138 removeAccessToken: (user, id) => call("remove_access_token", { user, id }),
Agents get guardrails, run credentials, an audit log, a context hub, repository instructions and mentions; security upkeep; snake_case API139 createRunCredential: (input) => call("create_run_credential", input),
140 bindRunCredentials: (tokenHashes, runId) => call("bind_run_credentials", { tokenHashes, runId }),
141 revokeRunCredentials: (target) => call("revoke_run_credentials", target),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look142 // Who has access to a repository; see access.ts.
143 repoAccess: (owner, name, viewer) => call("repo_access", { viewer, path: { namespace: owner, name } }),
144 addCollaborator: (actor, owner, name, invitee, role) =>
145 call("add_collaborator", { actor, path: { namespace: owner, name }, invitee, role }),
146 setCollaboratorRole: (actor, owner, name, username, role) =>
147 call("set_collaborator_role", { actor, path: { namespace: owner, name }, username, role }),
148 removeCollaborator: (actor, owner, name, username) =>
149 call("remove_collaborator", { actor, path: { namespace: owner, name }, username }),
150 collaboratorPermission: (viewer, owner, name, username) =>
151 call("collaborator_permission", { viewer, path: { namespace: owner, name }, username }),
152 myRepoInvitations: (user) => call("my_repo_invitations", { user }),
153 respondRepoInvitation: (user, id, accept) => call("respond_repo_invitation", { user, id, accept }),
154 revokeRepoInvitation: (actor, owner, name, id) =>
155 call("revoke_repo_invitation", { actor, path: { namespace: owner, name }, id }),
156 setBasePermission: (actor, slug, base) => call("set_base_permission", { actor, slug, base_permission: base }),
157 outsideCollaborators: (viewer, slug) => call("outside_collaborators", { viewer, slug }),
API and MCP server, Rust identity service, registration, site redesign158 };
159}
Rust repos service with shipping; pull requests kept in the model160
Agents and memory, checks and conflicts, profiles, slug renames, custom domains161/**
162 * The slug a renamed workspace has now, for a `workspace.renamed` handler:
163 * asked of identity by the workspace's id, so that renames delivered twice
164 * or out of order converge. Falls back to the event's `to`.
165 */
166export async function currentWorkspaceSlug(
167 identity: ServiceBinding,
168 renamed: { workspaceId: string; to: string },
169): Promise<string> {
170 const names = await identityClient(identity).usernames([renamed.workspaceId]);
171 return names[renamed.workspaceId] ?? renamed.to;
172}
173
174/** The slugs whose rows move to `current`: the two a rename names, less `current`. */
175export function staleSlugs(renamed: { from: string; to: string }, current: string): string[] {
176 return [...new Set([renamed.from, renamed.to])].filter((slug) => slug !== current);
177}
178
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look179/**
180 * Where a transferred repository is now, as `namespace/name`, for a
181 * `repo.transferred` handler: asked of repos by id, so transfers delivered
182 * twice or out of order converge. Falls back to the event's destination.
183 */
184export async function currentRepoPath(
185 repos: ServiceBinding,
186 transferred: { repoId: string; name: string; to: string },
187): Promise<string> {
188 const path = await rpc<{ namespace: string; name: string } | null>(repos, "path_by_id", { id: transferred.repoId });
189 return path ? `${path.namespace}/${path.name}` : `${transferred.to}/${transferred.name}`;
190}
191
192/** The paths whose rows move to `current`: the two a transfer names, less `current`. */
193export function stalePaths(transferred: { name: string; from: string; to: string }, current: string): string[] {
194 return [...new Set([transferred.from, transferred.to].map((ns) => `${ns}/${transferred.name}`))].filter(
195 (path) => path !== current,
196 );
197}
198
199/**
200 * A repository's path change, from `repo.transferred` or `repo.renamed`,
201 * read the same way: the two paths (`namespace/name`) the event names, old
202 * then new. Null for any other event.
203 */
204export type RepoMove = { repoId: string; paths: [string, string] };
205
206export function repoMove(event: { type: string; data: unknown }): RepoMove | null {
207 const data = event.data as Record<string, string>;
208 if (event.type === "repo.transferred") {
209 return { repoId: data.repoId!, paths: [`${data.from}/${data.name}`, `${data.to}/${data.name}`] };
210 }
211 if (event.type === "repo.renamed") {
212 return { repoId: data.repoId!, paths: [`${data.namespace}/${data.from}`, `${data.namespace}/${data.to}`] };
213 }
214 return null;
215}
216
217/**
218 * Where a moved repository is now, as `namespace/name`: asked of repos by
219 * id, so moves delivered twice or out of order converge. Falls back to the
220 * event's new path.
221 */
222export async function currentMovedPath(repos: ServiceBinding, move: RepoMove): Promise<string> {
223 const path = await rpc<{ namespace: string; name: string } | null>(repos, "path_by_id", { id: move.repoId });
224 return path ? `${path.namespace}/${path.name}` : move.paths[1];
225}
226
227/** The paths whose rows move to `current`: the two a move names, less `current`. */
228export function staleMovedPaths(move: RepoMove, current: string): string[] {
229 return [...new Set(move.paths)].filter((path) => path !== current);
230}
231
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace232/** Staff-only identity. Only sudo binds to it; see `IdentityAdminApi`. */
233export function identityAdminClient(service: ServiceBinding): IdentityAdminApi {
234 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
235 return {
236 workspaces: (query) => call("admin_workspaces", { query: query ?? null }),
237 workspace: (slug) => call("admin_workspace", { slug }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look238 waitlist: (query, status) => call("admin_waitlist", { query: query ?? null, status: status ?? null }),
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas239 waitlistPending: () => call("admin_waitlist_pending", {}),
240 decideWaitlist: (id, approve, staff, note) => call("admin_decide_waitlist", { id, approve, staff, note: note ?? null }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look241 invites: (query) => call("admin_invites", { query: query ?? null }),
242 revokeInvite: (id, staff) => call("admin_revoke_invite", { id, staff }),
243 mintInvite: (email, staff) => call("admin_mint_invite", { email, staff }),
244 grantInvites: (target, name, amount, note, staff) =>
245 call("admin_grant_invites", { target, name, amount, note, staff }),
246 inviteTree: (username) => call("admin_invite_tree", { username }),
247 workspaceInvites: (slug) => call("admin_workspace_invites", { slug }),
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member248 deletedWorkspaces: () => call("admin_deleted_workspaces", {}),
249 restoreWorkspace: (workspaceId, staff) => call("admin_restore_workspace", { workspaceId, staff }),
250 purgeWorkspace: (workspaceId, staff, confirm) => call("admin_purge_workspace", { workspaceId, staff, confirm }),
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace251 };
252}
253
Rust repos service with shipping; pull requests kept in the model254export function reposClient(service: ServiceBinding): ReposApi {
255 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
256 return {
257 get: (path, viewer) => call("get", { path, viewer }),
258 getById: (id, viewer) => call("get_by_id", { id, viewer }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents259 readable: (ids, viewer) => call("readable", { ids, viewer }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains260 publicNamespaces: (ownerId) => call("public_namespaces", { ownerId }),
Rust repos service with shipping; pull requests kept in the model261 list: (viewer, options = {}) => call("list", { viewer, ...options }),
262 create: (owner, input) => call("create", { owner, ...input }),
Agents as a team: lifecycle, merge queue, billing and a new shell263 update: (actor, path, changes) => call("update", { actor, path, ...changes }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look264 transfer: (actor, path, to) => call("transfer", { actor, path, to }),
265 delete: (actor, path, confirm) => call("delete", { actor, path, confirm }),
266 deleted: (viewer, namespace) => call("deleted", { viewer, namespace }),
267 restore: (actor, path) => call("restore", { actor, path }),
268 purge: (actor, path, confirm) => call("purge", { actor, path, confirm }),
269 rename: (actor, path, name) => call("rename", { actor, path, name }),
270 archive: (actor, path, archived) => call("archive", { actor, path, archived }),
271 setVisibility: (actor, path, isPrivate, confirm) => call("set_visibility", { actor, path, isPrivate, confirm }),
272 setDefaultBranch: (actor, path, branch) => call("set_default_branch", { actor, path, branch }),
273 renameBranch: (actor, path, from, to) => call("rename_branch", { actor, path, from, to }),
274 resolveBranch: (repoId, branch) => call("resolve_branch", { repoId, branch }),
275 statusById: (id) => call("status_by_id", { id }),
276 resolvePath: (path) => call("resolve_path", { path }),
Rust repos service with shipping; pull requests kept in the model277 tree: (path, viewer, ref, treePath) =>
278 call("tree", { path, viewer, ref, treePath }),
279 blob: (path, viewer, ref, filePath) =>
280 call("blob", { path, viewer, ref, filePath }),
281 log: (path, viewer, ref, limit) => call("log", { path, viewer, ref, limit }),
Agents as a team: lifecycle, merge queue, billing and a new shell282 blame: (path, viewer, ref, filePath) => call("blame", { path, viewer, ref, filePath }),
Issues and pull requests replace intents and attempts283 forkForPull: (sourceId, pullId, actor) =>
284 call("fork_for_pull", { sourceId, pullId, actor }),
Rust repos service with shipping; pull requests kept in the model285 gitAccess: (path, viewer, service) =>
286 call("git_access", { path, viewer, service }),
Pull requests from branches287 branches: (path, viewer) => call("branches", { path, viewer }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents288 commitFile: (repo, actor, file) => call("commit_file", { repo, actor, ...file }),
Pull requests from branches289 land: (sourceId, actor, branch) => call("land", { sourceId, actor, branch }),
290 compare: (repoId, viewer, base, head) => call("compare", { repoId, viewer, base, head }),
Rust repos service with shipping; pull requests kept in the model291 };
292}
Work service in Rust, with RFC 3339 timestamps293
294export function workClient(service: ServiceBinding): WorkApi {
295 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
296 return {
Issues and pull requests replace intents and attempts297 openIssue: (actor, repo, input) => call("open_issue", { actor, repo, ...input }),
Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step298 delegateIssue: (actor, repo, input) => call("delegate_issue", { actor, repo, ...input }),
Issues and pull requests replace intents and attempts299 listIssues: (repo, viewer, filter = {}) => call("list_issues", { repo, viewer, ...filter }),
300 getIssue: (repo, number, viewer) => call("get_issue", { repo, number, viewer }),
301 updateIssue: (actor, repo, number, input) =>
302 call("update_issue", { actor, repo, number, ...input }),
303 closeIssue: (actor, repo, number, reason) =>
304 call("close_issue", { actor, repo, number, reason }),
305 reopenIssue: (actor, repo, number) => call("reopen_issue", { actor, repo, number }),
306 listLabels: (repo, viewer) => call("list_labels", { repo, viewer }),
307 counts: (repo, viewer) => call("counts", { repo, viewer }),
Acceptance checks in sandboxes, line comments and review verdicts308 addComment: (actor, repo, number, comment) =>
309 call("add_comment", { actor, repo, number, ...comment }),
310 startChecks: (pullId) => call("start_checks", { pullId }),
311 reportChecks: (runId, token, report) =>
312 call("report_checks", { runId, token, ...report }),
Agents as a team: lifecycle, merge queue, billing and a new shell313 startReview: (pullId) => call("start_review", { pullId }),
314 failReview: (runId, token, error) => call("report_review", { runId, token, error }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains315 startMergecheck: (pullId) => call("start_mergecheck", { pullId }),
316 failMergecheck: (pullId, token, error) => call("report_mergecheck", { pullId, token, error }),
Agents as a team: lifecycle, merge queue, billing and a new shell317 advance: (pullId) => call("advance", { pullId }),
318 stall: (pullId, reason) => call("stall", { pullId, reason }),
319 managedPulls: (repoId) => call("managed_pulls", { repoId }),
320 queue: (repo, viewer) => call("queue", { repo, viewer }),
321 queueBuild: (repoId) => call("queue_build", { repoId }),
322 failQueue: (entryId, token, error) => call("report_queue", { entryId, token, error }),
323 removeFromQueue: (actor, repo, number) => call("remove_from_queue", { actor, repo, number }),
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request324 messageAgent: (actor, repo, number, body) => call("message_agent", { actor, repo, number, body }),
Agents as a team: lifecycle, merge queue, billing and a new shell325 catchUpJob: (pullId) => call("catch_up_job", { pullId }),
Agents asked while not at work are woken to answer326 wakeForMessages: (pullId) => call("wake_for_messages", { pullId }),
Agents as a team: lifecycle, merge queue, billing and a new shell327 getSettings: (repo, viewer) => call("get_settings", { repo, viewer }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents328 seenChecks: (repo, viewer) => call("seen_checks", { repo, viewer }),
Agents as a team: lifecycle, merge queue, billing and a new shell329 updateSettings: (actor, repo, settings) =>
330 call("update_settings", { actor, repo, settings }),
Issues and pull requests replace intents and attempts331 openPull: (actor, repo, input) => call("open_pull", { actor, repo, ...input }),
332 listPulls: (repo, viewer, state) => call("list_pulls", { repo, viewer, state }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents333 pullsForRepos: (repoIds, viewer, limit) => call("pulls_for_repos", { repoIds, viewer, limit }),
Issues and pull requests replace intents and attempts334 getPull: (repo, number, viewer) => call("get_pull", { repo, number, viewer }),
Agents as a team: lifecycle, merge queue, billing and a new shell335 updatePull: (actor, repo, number, changes) =>
336 call("update_pull", { actor, repo, number, ...changes }),
Catching up with main takes seconds when the two sides touched different files337 catchUpPull: (actor, repo, number) => call("catch_up_pull", { actor, repo, number }),
Issues and pull requests replace intents and attempts338 readyPull: (actor, repo, number, summary) =>
339 call("ready_pull", { actor, repo, number, summary }),
340 closePull: (actor, repo, number) => call("close_pull", { actor, repo, number }),
Acceptance checks in sandboxes, line comments and review verdicts341 mergePull: (actor, repo, number, options = {}) =>
342 call("merge_pull", { actor, repo, number, ...options }),
Issues and pull requests replace intents and attempts343 listActivePulls: (viewer) => call("list_active_pulls", { viewer }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains344 byAuthor: (username, viewer, filter = {}) => call("by_author", { username, viewer, ...filter }),
Agents as a team: lifecycle, merge queue, billing and a new shell345 startPlan: (actor, repo, brief) => call("start_plan", { actor, repo, brief }),
346 failPlan: (planId, token, error) => call("report_plan", { planId, token, error }),
347 getPlan: (repo, viewer, id) => call("get_plan", { repo, viewer, id }),
348 listPlans: (repo, viewer) => call("list_plans", { repo, viewer }),
349 applyPlan: (actor, repo, id, options = {}) =>
350 call("apply_plan", { actor, repo, id, ...options }),
351 queueIssue: (actor, repo, number, queued) =>
352 call("queue_issue", { actor, repo, number, queued }),
353 readyIssues: (repoId) => call("ready_issues", { repoId }),
354 listAssignedIssues: (viewer) => call("list_assigned_issues", { viewer }),
Issues and pull requests replace intents and attempts355 appendSession: (actor, repo, number, entries) =>
356 call("append_session", { actor, repo, number, entries }),
357 readSession: (repo, number, viewer, afterSeq = 0) =>
358 call("read_session", { repo, number, viewer, afterSeq }),
Work service in Rust, with RFC 3339 timestamps359 };
360}
Events service in Rust, with RFC 3339 times and accurate push events361
Agents as a team: lifecycle, merge queue, billing and a new shell362export function billingClient(service: ServiceBinding): BillingApi {
363 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
364 return {
365 status: () => call("status", {}),
366 account: (workspace, viewer) => call("account", { workspace, viewer }),
367 ledger: (workspace, viewer) => call("ledger", { workspace, viewer }),
The statement is a month at a time, a line per kind of charge368 statement: (workspace, viewer, month = null, group = "day") => call("statement", { workspace, viewer, month, group }),
369 statementEntries: (workspace, viewer, filter) =>
370 call("statement_entries", {
371 workspace,
372 viewer,
373 month: filter.month,
374 kind: filter.kind,
375 day: filter.day ?? null,
376 project: filter.project ?? null,
377 before: filter.before ?? null,
378 }),
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request379 usage: (workspace, viewer, since) => call("usage", { workspace, viewer, since }),
Mission control shows model usage, yours and the workspace's: tokens, cost, active days, cache share, each day, and the mix380 tokenUsage: (workspace, viewer, options = {}) =>
381 call("token_usage", { workspace, viewer, person: options.person ?? null, days: options.days ?? null }),
382 recordTokens: (usage) => call("record_tokens", usage),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look383 checkout: (actor, workspace, amountCents, returnUrl, method = "card") =>
384 call("checkout", { actor, workspace, amountCents, returnUrl, method }),
Agents as a team: lifecycle, merge queue, billing and a new shell385 confirm: (workspace, viewer, session) => call("confirm", { workspace, viewer, session }),
386 canStart: (workspace) => call("can_start", { workspace }),
A free allowance on g1t's models, so anyone can try its agents387 trial: (workspace, exempt) => call("trial", { workspace, exempt }),
Agents as a team: lifecycle, merge queue, billing and a new shell388 startRun: (run) => call("start_run", run),
Paid features: a workspace turns on Deployments with a monthly plan389 features: (workspace, viewer) => call("features", { workspace, viewer }),
390 subscribe: (actor, workspace, feature, returnUrl) =>
391 call("subscribe", { actor, workspace, feature, returnUrl }),
392 confirmSubscription: (workspace, viewer, session) =>
393 call("confirm_subscription", { workspace, viewer, session }),
394 cancelSubscription: (actor, workspace, feature, resume = false) =>
395 call("cancel_subscription", { actor, workspace, feature, resume }),
396 hasFeature: (workspace, feature) => call("has_feature", { workspace, feature }),
397 chargeFeature: (charge) => call("charge_feature", charge),
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace398 billingPortal: (actor, workspace, returnUrl) => call("billing_portal", { actor, workspace, return_url: returnUrl }),
Every sandbox is metered by the second399 recordSandbox: (usage) => call("record_sandbox", usage),
Usage limits: unpaid usage can only go so far400 limit: (workspace, viewer) => call("limit", { workspace, viewer }),
401 checkLimit: (workspace) => call("check_limit", { workspace }),
Prices keep themselves current with what g1t pays402 prices: () => call("prices", {}),
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas403 notePending: (workspace, source, costMicros, detail = null) => call("note_pending", { workspace, source, costMicros, detail }),
404 usageMeters: (workspace, viewer) => call("usage_meters", { workspace, viewer }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look405 setSpendLimit: (actor, workspace, spendLimitMicros, useFullLimit = false, raiseOnce = false) =>
406 call("set_spend_limit", { actor, workspace, spendLimitMicros, use_full_limit: useFullLimit, raise_once: raiseOnce }),
Two limits, real invoices, trust that grows by itself, sales signals407 invoices: (workspace, viewer) => call("invoices", { workspace, viewer }),
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put408 entitlements: (workspace) => call("entitlements", { workspace }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look409 reserve: (reservation) => call("reserve", reservation),
410 settle: (reservationId, actualMicros) => call("settle", { reservationId, actualMicros }),
411 cardCheck: (actor, workspace, returnUrl) => call("card_check", { actor, workspace, returnUrl }),
412 confirmCardCheck: (workspace, viewer, session) => call("confirm_card_check", { workspace, viewer, session }),
413 requestLimit: (actor, workspace, request) => call("request_limit", { actor, workspace, ...request }),
414 limitRequests: (workspace, viewer) => call("limit_requests", { workspace, viewer }),
415 confirmSpike: (actor, workspace, keepGoing) => call("confirm_spike", { actor, workspace, keepGoing }),
416 setCaps: (actor, workspace, caps) => call("set_caps", { actor, workspace, ...caps }),
Agents as a team: lifecycle, merge queue, billing and a new shell417 };
418}
419
Billing accounts, terms and enterprises; g1t is no longer free420export function billingAdminClient(service: ServiceBinding): BillingAdminApi {
421 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
422 return {
423 accounts: (query) => call("admin_accounts", { query: query ?? null }),
424 account: (id) => call("admin_account", { id }),
425 setTerms: (id, terms, by) => call("admin_set_terms", { id, terms, by }),
Team plan, an open-source pool, monthly trials and honest metering; the sidebar for everyone; a workspace that stays put426 setAllowances: (id, allowances, note, by) => call("admin_set_allowances", { id, allowances, note, by }),
Billing accounts, terms and enterprises; g1t is no longer free427 createEnterprise: (name, workspaces, by) => call("admin_create_enterprise", { name, workspaces, by }),
428 attach: (workspace, account, by) => call("admin_attach", { workspace, account, by }),
429 credit: (workspace, amountMicros, note, by) => call("admin_credit", { workspace, amount_micros: amountMicros, note, by }),
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace430 billingLink: (workspace, by) => call("admin_billing_link", { workspace, by }),
Stripe's webhook secret is a Worker secret, STRIPE_WEBHOOK_SECRET, from a destination made in Stripe's dashboard431 stripe: (fix = false, by) => call("admin_stripe", { fix, by: by ?? null }),
Stripe webhooks, enterprise invoices, and sudo for both432 enterpriseBilling: (id, email, by) => call("admin_enterprise_billing", { id, email, by }),
433 invoiceEnterprise: (id, by) => call("admin_invoice_enterprise", { id, by }),
434 accountsFor: (workspaces) => call("admin_accounts", { query: null, workspaces }),
Two limits, real invoices, trust that grows by itself, sales signals435 signals: () => call("admin_signals", {}),
436 overview: () => call("admin_overview", {}),
437 sales: (workspace) => call("admin_sales", { workspace }),
438 setSales: (workspace, record, by) =>
439 call("admin_set_sales", {
440 workspace,
441 stage: record.stage,
442 owner: record.owner ?? null,
443 next_step: record.nextStep ?? null,
444 next_at: record.nextAt ?? null,
445 by,
446 }),
447 addNote: (workspace, text, by) => call("admin_add_note", { workspace, text, by }),
448 workspaceInvoices: (workspace) => call("admin_workspace_invoices", { workspace }),
Billing lists every invoice and every staff change; signals carry follow-ups449 allInvoices: (filter = {}) => call("admin_invoices", { status: filter.status ?? null, month: filter.month ?? null }),
450 audit: (filter = {}) =>
451 call("admin_audit", { by: filter.by ?? null, action: filter.action ?? null, before: filter.before ?? null }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look452 limitRequests: (status = "open") => call("admin_limit_requests", { status }),
453 decideLimitRequest: (id, decision, amountMicros, note, by) =>
454 call("admin_decide_limit_request", { id, decision, amount_micros: amountMicros, note, by }),
455 overages: () => call("admin_overages", {}),
456 goodwill: (workspace, amountMicros, reason, by, day = null) =>
457 call("admin_goodwill", { workspace, amount_micros: amountMicros, reason, by, day }),
458 velocity: () => call("admin_velocity", {}),
459 recordPayment: (workspace, amountMicros, reference, note, by) =>
460 call("admin_record_payment", { workspace, amount_micros: amountMicros, reference, note, by }),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily461 costs: (days) => call("admin_costs", { days: days ?? null }),
462 costAlerts: () => call("admin_cost_alerts", {}),
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays463 spendCaps: () => call("admin_spend_caps", {}),
464 liftBreaker: (note, by) => call("admin_lift_breaker", { note, by }),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily465 decideProposal: (id, decision, note, by) => call("admin_decide_proposal", { id, decision, note, by }),
466 setCostSettings: (settings, by) => call("admin_set_cost_settings", { settings, by }),
467 setCostMapping: (mapping, by) =>
468 call("admin_set_cost_mapping", {
469 product: mapping.product,
470 meter: mapping.meter,
471 bucket: mapping.bucket ?? "",
472 price_meter: mapping.priceMeter ?? null,
473 own_meter: mapping.ownMeter ?? null,
474 scale_to_own: mapping.scaleToOwn ?? false,
475 drift_percent: mapping.driftPercent ?? null,
476 note: mapping.note ?? "",
477 remove: mapping.remove ?? false,
478 by,
479 }),
480 runCosts: (by) => call("admin_run_costs", { by }),
Billing accounts, terms and enterprises; g1t is no longer free481 };
482}
483
Events service in Rust, with RFC 3339 times and accurate push events484export function eventsClient(service: ServiceBinding): EventsApi {
485 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
486 return {
487 publish: (events) => call("publish", { events }),
488 list: (query) => call("list", query),
489 };
490}
Integrations: your own model provider, alerts that open issues, tickets agents read491
492export function integrationsClient(service: ServiceBinding): IntegrationsApi {
493 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
494 return {
495 list: (workspace, viewer) => call("list", { workspace, viewer }),
496 connect: (actor, workspace, input) => call("connect", { actor, workspace, ...input }),
497 update: (actor, workspace, id, input) => call("update", { actor, workspace, id, ...input }),
498 disconnect: (actor, workspace, id) => call("disconnect", { actor, workspace, id }),
499 test: (actor, workspace, id) => call("test", { actor, workspace, id }),
500 deliveries: (workspace, viewer, id) => call("deliveries", { workspace, viewer, id }),
501 resolve: (workspace, viewer, reference) => call("resolve", { workspace, viewer, reference }),
502 references: (workspace, text, limit) => call("references", { workspace, text, limit }),
503 import: (actor, repo, reference, assign) => call("import", { actor, repo, reference, assign }),
504 links: (repo, number) => call("links", { repo, number }),
505 modelProvider: (workspace) => call("model_provider", { workspace }),
506 openModelSession: (run) => call("open_model_session", run),
507 modelUpstream: (token) => call("model_upstream", { token }),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily508 closeModelSessions: (tokenHashes) => call("close_model_sessions", { token_hashes: tokenHashes }),
Models per workspace: several providers, routed by kind of work509 routes: (workspace, viewer) => call("routes", { workspace, viewer }),
510 setRoutes: (actor, workspace, routes) => call("set_routes", { actor, workspace, routes }),
Integrations: your own model provider, alerts that open issues, tickets agents read511 };
512}
Webhooks: every event, to your own addresses, signed and retried513
514export function webhooksClient(service: ServiceBinding): WebhooksApi {
515 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
516 return {
517 list: (viewer, owner) => call("list", { viewer, ...owner }),
518 create: (actor, owner, input) => call("create", { actor, ...owner, ...input }),
519 update: (actor, owner, id, input) => call("update", { actor, ...owner, id, ...input }),
520 delete: (actor, owner, id) => call("delete", { actor, ...owner, id }),
521 ping: (actor, owner, id) => call("ping", { actor, ...owner, id }),
522 deliveries: (viewer, owner, id) => call("deliveries", { viewer, ...owner, id }),
523 redeliver: (actor, owner, deliveryId) => call("redeliver", { actor, ...owner, deliveryId }),
524 };
525}
Automations: rules in .g1t/automations that act when something happens526
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs527export function actionsClient(service: ServiceBinding): ActionsApi {
528 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
529 return {
530 workflows: (repo, viewer) => call("workflows", { repo, viewer }),
531 runs: (repo, viewer, filter = {}) => call("runs", { repo, viewer, ...filter }),
532 run: (repo, viewer, id) => call("run", { repo, viewer, id }),
533 logs: (repo, viewer, job, after = 0) => call("logs", { repo, viewer, job, after }),
534 dispatch: (actor, repo, workflow, ref, inputs) => call("dispatch", { actor, repo, workflow, ref, inputs }),
535 cancel: (actor, repo, id) => call("cancel", { actor, repo, id }),
536 rerun: (actor, repo, id, failedOnly = false) => call("rerun", { actor, repo, id, failed_only: failedOnly }),
537 setWorkflowEnabled: (actor, repo, workflow, enabled) =>
538 call("set_workflow_enabled", { actor, repo, workflow, enabled }),
539 settings: (actor, owner, kind) => call("settings", { actor, ...owner, kind }),
Secrets and variables: one list, rows per environment, for workflows and deployments540 setSetting: (actor, owner, kind, name, value, options = {}) =>
541 call("set_setting", { actor, ...owner, kind, name, value, ...options }),
542 deleteSetting: (actor, owner, kind, name, id) => call("delete_setting", { actor, ...owner, kind, name, id }),
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs543 };
544}
545
Deployments: a preview for every pull request, production on g1t.page546
Fast pages, required checks on the branch, self-hosted runners, honest incidents547/** Self-hosted runners, kept by the actions service. */
548export function runnersClient(service: ServiceBinding): RunnersApi {
549 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
550 return {
551 stuck: (viewer) => call("stuck_jobs", { viewer }),
552 list: (actor, owner) => call("runners", { actor, ...owner }),
553 createToken: (actor, owner, group) => call("create_registration_token", { actor, ...owner, group }),
554 remove: (actor, owner, id) => call("remove_runner", { actor, ...owner, id }),
555 groups: (actor, workspace) => call("runner_groups", { actor, workspace }),
556 setGroup: (actor, workspace, group) => call("set_runner_group", { actor, workspace, ...group }),
557 deleteGroup: (actor, workspace, id) => call("delete_runner_group", { actor, workspace, id }),
558 settings: (actor, owner) => call("runner_settings", { actor, ...owner }),
559 setSettings: (actor, owner, change) => call("set_runner_settings", { actor, ...owner, ...change }),
560 };
561}
562
Deployments: a preview for every pull request, production on g1t.page563export function deploymentsClient(service: ServiceBinding): DeploymentsApi {
564 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
565 return {
Projects: what a workspace builds and runs, first on every page566 settings: (project, viewer) => call("settings", { project, viewer }),
567 updateSettings: (actor, project, changes) => call("update_settings", { actor, project, changes }),
568 list: (project, viewer) => call("list", { project, viewer }),
569 get: (project, id, viewer) => call("get", { project, id, viewer }),
570 redeploy: (actor, project, branch) => call("redeploy", { actor, project, branch }),
571 takeDown: (actor, project, branch) => call("take_down", { actor, project, branch }),
Project dependencies: addresses, preview stacks, Affects, and agents who know572 stack: (actor, project, branch) => call("stack", { actor, project, branch }),
Projects: what a workspace builds and runs, first on every page573 overview: (workspace, viewer) => call("overview", { workspace, viewer }),
Deployments: a preview for every pull request, production on g1t.page574 usage: (workspace, viewer) => call("usage", { workspace, viewer }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains575 domains: (project, viewer) => call("domains", { project, viewer }),
576 addDomain: (actor, project, hostname, options = {}) =>
577 call("add_domain", { actor, project, hostname, twin: !!options.twin }),
578 removeDomain: (actor, project, id) => call("remove_domain", { actor, project, id }),
579 refreshDomain: (actor, project, id) => call("refresh_domain", { actor, project, id }),
Deployments: a preview for every pull request, production on g1t.page580 };
581}
Projects: what a workspace builds and runs, first on every page582
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member583/** Packages: the registries beside the code (services/packages). */
584export function packagesClient(service: ServiceBinding): PackagesApi {
585 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
586 return {
587 list: (workspace, viewer, filter = {}) =>
588 call("list_packages", {
589 workspace,
590 viewer,
591 ecosystem: filter.ecosystem ?? null,
592 repo_id: filter.repoId ?? null,
593 query: filter.query ?? null,
594 }),
595 get: (workspace, ecosystem, name, viewer) => call("get_package", { workspace, ecosystem, name, viewer }),
596 deleteVersion: (actor, workspace, ecosystem, name, version, surface) =>
597 call("delete_version", { actor, workspace, ecosystem, name, version, surface: surface ?? null }),
598 deletePackage: (actor, workspace, ecosystem, name, surface) =>
599 call("delete_package", { actor, workspace, ecosystem, name, surface: surface ?? null }),
600 set: (actor, workspace, ecosystem, name, change, surface) =>
601 call("set_package", {
602 actor,
603 workspace,
604 ecosystem,
605 name,
606 visibility: change.visibility ?? null,
607 link: change.link ?? null,
608 unlink: change.unlink ?? false,
609 surface: surface ?? null,
610 }),
611 storage: (workspace) => call("storage", { workspace }),
612 storageAll: () => call("storage_all", {}),
Composer from the workspace's own repositories, and go get from g1t.sh613 syncComposer: (repoId) => call("sync_composer", { repo_id: repoId }),
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member614 };
615}
616
Projects: what a workspace builds and runs, first on every page617export function projectsClient(service: ServiceBinding): ProjectsApi {
618 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
619 return {
620 list: (workspace, viewer) => call("list", { workspace, viewer }),
621 get: (workspace, slug, viewer) => call("get", { workspace, slug, viewer }),
622 byRepo: (repoId) => call("by_repo", { repoId }),
623 create: (actor, workspace, input) => call("create", { actor, workspace, input }),
624 update: (actor, workspace, slug, changes) => call("update", { actor, workspace, slug, changes }),
A project is an app or a library: libraries show their package and how to ship a release, not production625 deploymentsChanged: (projectId, enabled) => call("deployments_changed", { projectId, enabled }),
Project dependencies: addresses, preview stacks, Affects, and agents who know626 dependencies: (workspace, slug, viewer) => call("dependencies", { workspace, slug, viewer }),
627 addDependency: (actor, workspace, slug, on, as) => call("add_dependency", { actor, workspace, slug, on, as }),
628 removeDependency: (actor, workspace, slug, on) => call("remove_dependency", { actor, workspace, slug, on }),
629 graph: (projectId) => call("graph", { projectId }),
Projects: what a workspace builds and runs, first on every page630 };
631}