g1t/packages/contracts/src/clients.ts

642 lines37,774 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 }),
Merge branch 'worktree-agent-a2013627e5ea4ab13'68 workspaceResidency: (slug) => call("workspace_residency", { slug }),
69 setWorkspaceResidency: (actor, slug, residency) => call("set_workspace_residency", { actor, slug, residency }),
Workspaces own repositories70 listMembers: (slug, viewer) => call("list_members", { slug, viewer }),
71 addMember: (actor, slug, username) => call("add_member", { actor, slug, username }),
72 removeMember: (actor, slug, username) =>
73 call("remove_member", { actor, slug, username }),
Agents as a team: lifecycle, merge queue, billing and a new shell74 updateWorkspace: (actor, slug, details) =>
75 call("update_workspace", { actor, slug, ...details }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains76 renameWorkspace: (actor, slug, newSlug) => call("rename_workspace", { actor, slug, newSlug }),
77 checkWorkspaceRename: (actor, slug, newSlug) =>
78 call("check_workspace_rename", { actor, slug, newSlug }),
79 resolveSlug: (slug) => call("resolve_slug", { slug }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look80 deleteWorkspace: (actor, slug, confirm) => call("delete_workspace", { actor, slug, confirm }),
81 checkWorkspaceDeletion: (actor, slug) => call("check_workspace_deletion", { actor, slug }),
Workspace names and icons, and a component kit for every control82 setWorkspaceAvatar: (actor, slug, image) => call("set_workspace_avatar", { actor, slug, image }),
83 setUserAvatar: (user, image) => call("set_user_avatar", { user, image }),
Agents as a team: lifecycle, merge queue, billing and a new shell84 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 step85 createWorkspaceToken: (actor, slug, name, grant) =>
86 call("create_workspace_token", {
87 actor,
88 slug,
89 name,
90 scopes: grant?.scopes ?? null,
91 ttl_seconds: grant?.ttlSeconds ?? null,
92 }),
Agents as a team: lifecycle, merge queue, billing and a new shell93 removeWorkspaceToken: (actor, slug, id) =>
94 call("remove_workspace_token", { actor, slug, id }),
API and MCP server, Rust identity service, registration, site redesign95 userForSession: (sessionToken) => call("user_for_session", { sessionToken }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look96 registration: () => call("registration", {}),
97 listInvites: (user) => call("list_invites", { user }),
98 createInvite: (user, options = {}) =>
99 call("create_invite", { user, email: options.email ?? null, workspace: options.workspace ?? null }),
100 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 quotas101 checkInvite: (code, client, options = {}) =>
102 call("check_invite", {
103 code,
104 client: client ?? null,
105 viewer: options.viewer ?? null,
106 any_status: options.anyStatus ?? false,
107 }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look108 acceptInvite: (user, code) => call("accept_invite", { user, code }),
109 inviteMember: (actor, slug, email) => call("invite_member", { actor, slug, email }),
110 workspaceInvites: (slug, viewer) => call("workspace_invites", { slug, viewer }),
111 revokeWorkspaceInvite: (actor, slug, id) => call("revoke_workspace_invite", { actor, slug, id }),
112 requestAccess: (email, about, client) => call("request_access", { email, about, client: client ?? null }),
API and MCP server, Rust identity service, registration, site redesign113 userForGitCredentials: (username, secret) =>
114 call("user_for_git_credentials", { username, secret }),
115 userForAccessToken: (token) => call("user_for_access_token", { token }),
116 userForSshKey: (fingerprint) => call("user_for_ssh_key", { fingerprint }),
117 userByUsername: (username) => call("user_by_username", { username }),
What happened across an outcome, as a feed beside its graph118 usernames: (ids) => call("usernames", { ids }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains119 profile: (username) => call("profile", { username }),
120 updateProfile: (actor, fields) => call("update_profile", { actor, ...fields }),
121 profileWorkspaces: (username, viewer, publicIn) =>
122 call("profile_workspaces", { username, viewer, public: publicIn }),
API and MCP server, Rust identity service, registration, site redesign123 listSshKeys: (user) => call("list_ssh_keys", { user }),
124 addSshKey: (user, title, publicKey) =>
125 call("add_ssh_key", { user, title, publicKey }),
126 removeSshKey: (user, id) => call("remove_ssh_key", { user, id }),
127 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 step128 createAccessToken: (user, name, ttlSeconds, grant) =>
129 call("create_access_token", {
130 user,
131 name,
132 ttlSeconds,
133 scopes: grant?.scopes ?? null,
134 listed: grant?.listed ?? false,
135 }),
136 updateAccessToken: (user, id, grant) =>
137 call("update_access_token", { user, id, scopes: grant.scopes }),
Agents as a team: lifecycle, merge queue, billing and a new shell138 createAgentToken: (onBehalfOf, scope, ttlSeconds) =>
139 call("create_agent_token", { onBehalfOf, scope, ttlSeconds }),
API and MCP server, Rust identity service, registration, site redesign140 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 API141 createRunCredential: (input) => call("create_run_credential", input),
142 bindRunCredentials: (tokenHashes, runId) => call("bind_run_credentials", { tokenHashes, runId }),
143 revokeRunCredentials: (target) => call("revoke_run_credentials", target),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look144 // Who has access to a repository; see access.ts.
145 repoAccess: (owner, name, viewer) => call("repo_access", { viewer, path: { namespace: owner, name } }),
146 addCollaborator: (actor, owner, name, invitee, role) =>
147 call("add_collaborator", { actor, path: { namespace: owner, name }, invitee, role }),
148 setCollaboratorRole: (actor, owner, name, username, role) =>
149 call("set_collaborator_role", { actor, path: { namespace: owner, name }, username, role }),
150 removeCollaborator: (actor, owner, name, username) =>
151 call("remove_collaborator", { actor, path: { namespace: owner, name }, username }),
152 collaboratorPermission: (viewer, owner, name, username) =>
153 call("collaborator_permission", { viewer, path: { namespace: owner, name }, username }),
154 myRepoInvitations: (user) => call("my_repo_invitations", { user }),
155 respondRepoInvitation: (user, id, accept) => call("respond_repo_invitation", { user, id, accept }),
156 revokeRepoInvitation: (actor, owner, name, id) =>
157 call("revoke_repo_invitation", { actor, path: { namespace: owner, name }, id }),
158 setBasePermission: (actor, slug, base) => call("set_base_permission", { actor, slug, base_permission: base }),
159 outsideCollaborators: (viewer, slug) => call("outside_collaborators", { viewer, slug }),
API and MCP server, Rust identity service, registration, site redesign160 };
161}
Rust repos service with shipping; pull requests kept in the model162
Agents and memory, checks and conflicts, profiles, slug renames, custom domains163/**
164 * The slug a renamed workspace has now, for a `workspace.renamed` handler:
165 * asked of identity by the workspace's id, so that renames delivered twice
166 * or out of order converge. Falls back to the event's `to`.
167 */
168export async function currentWorkspaceSlug(
169 identity: ServiceBinding,
170 renamed: { workspaceId: string; to: string },
171): Promise<string> {
172 const names = await identityClient(identity).usernames([renamed.workspaceId]);
173 return names[renamed.workspaceId] ?? renamed.to;
174}
175
176/** The slugs whose rows move to `current`: the two a rename names, less `current`. */
177export function staleSlugs(renamed: { from: string; to: string }, current: string): string[] {
178 return [...new Set([renamed.from, renamed.to])].filter((slug) => slug !== current);
179}
180
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look181/**
182 * Where a transferred repository is now, as `namespace/name`, for a
183 * `repo.transferred` handler: asked of repos by id, so transfers delivered
184 * twice or out of order converge. Falls back to the event's destination.
185 */
186export async function currentRepoPath(
187 repos: ServiceBinding,
188 transferred: { repoId: string; name: string; to: string },
189): Promise<string> {
190 const path = await rpc<{ namespace: string; name: string } | null>(repos, "path_by_id", { id: transferred.repoId });
191 return path ? `${path.namespace}/${path.name}` : `${transferred.to}/${transferred.name}`;
192}
193
194/** The paths whose rows move to `current`: the two a transfer names, less `current`. */
195export function stalePaths(transferred: { name: string; from: string; to: string }, current: string): string[] {
196 return [...new Set([transferred.from, transferred.to].map((ns) => `${ns}/${transferred.name}`))].filter(
197 (path) => path !== current,
198 );
199}
200
201/**
202 * A repository's path change, from `repo.transferred` or `repo.renamed`,
203 * read the same way: the two paths (`namespace/name`) the event names, old
204 * then new. Null for any other event.
205 */
206export type RepoMove = { repoId: string; paths: [string, string] };
207
208export function repoMove(event: { type: string; data: unknown }): RepoMove | null {
209 const data = event.data as Record<string, string>;
210 if (event.type === "repo.transferred") {
211 return { repoId: data.repoId!, paths: [`${data.from}/${data.name}`, `${data.to}/${data.name}`] };
212 }
213 if (event.type === "repo.renamed") {
214 return { repoId: data.repoId!, paths: [`${data.namespace}/${data.from}`, `${data.namespace}/${data.to}`] };
215 }
216 return null;
217}
218
219/**
220 * Where a moved repository is now, as `namespace/name`: asked of repos by
221 * id, so moves delivered twice or out of order converge. Falls back to the
222 * event's new path.
223 */
224export async function currentMovedPath(repos: ServiceBinding, move: RepoMove): Promise<string> {
225 const path = await rpc<{ namespace: string; name: string } | null>(repos, "path_by_id", { id: move.repoId });
226 return path ? `${path.namespace}/${path.name}` : move.paths[1];
227}
228
229/** The paths whose rows move to `current`: the two a move names, less `current`. */
230export function staleMovedPaths(move: RepoMove, current: string): string[] {
231 return [...new Set(move.paths)].filter((path) => path !== current);
232}
233
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace234/** Staff-only identity. Only sudo binds to it; see `IdentityAdminApi`. */
235export function identityAdminClient(service: ServiceBinding): IdentityAdminApi {
236 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
237 return {
238 workspaces: (query) => call("admin_workspaces", { query: query ?? null }),
239 workspace: (slug) => call("admin_workspace", { slug }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look240 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 quotas241 waitlistPending: () => call("admin_waitlist_pending", {}),
242 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 look243 invites: (query) => call("admin_invites", { query: query ?? null }),
244 revokeInvite: (id, staff) => call("admin_revoke_invite", { id, staff }),
245 mintInvite: (email, staff) => call("admin_mint_invite", { email, staff }),
246 grantInvites: (target, name, amount, note, staff) =>
247 call("admin_grant_invites", { target, name, amount, note, staff }),
248 inviteTree: (username) => call("admin_invite_tree", { username }),
249 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 member250 deletedWorkspaces: () => call("admin_deleted_workspaces", {}),
251 restoreWorkspace: (workspaceId, staff) => call("admin_restore_workspace", { workspaceId, staff }),
252 purgeWorkspace: (workspaceId, staff, confirm) => call("admin_purge_workspace", { workspaceId, staff, confirm }),
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace253 };
254}
255
Rust repos service with shipping; pull requests kept in the model256export function reposClient(service: ServiceBinding): ReposApi {
257 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
258 return {
259 get: (path, viewer) => call("get", { path, viewer }),
260 getById: (id, viewer) => call("get_by_id", { id, viewer }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents261 readable: (ids, viewer) => call("readable", { ids, viewer }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains262 publicNamespaces: (ownerId) => call("public_namespaces", { ownerId }),
Rust repos service with shipping; pull requests kept in the model263 list: (viewer, options = {}) => call("list", { viewer, ...options }),
264 create: (owner, input) => call("create", { owner, ...input }),
Agents as a team: lifecycle, merge queue, billing and a new shell265 update: (actor, path, changes) => call("update", { actor, path, ...changes }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look266 transfer: (actor, path, to) => call("transfer", { actor, path, to }),
267 delete: (actor, path, confirm) => call("delete", { actor, path, confirm }),
268 deleted: (viewer, namespace) => call("deleted", { viewer, namespace }),
269 restore: (actor, path) => call("restore", { actor, path }),
270 purge: (actor, path, confirm) => call("purge", { actor, path, confirm }),
271 rename: (actor, path, name) => call("rename", { actor, path, name }),
272 archive: (actor, path, archived) => call("archive", { actor, path, archived }),
273 setVisibility: (actor, path, isPrivate, confirm) => call("set_visibility", { actor, path, isPrivate, confirm }),
274 setDefaultBranch: (actor, path, branch) => call("set_default_branch", { actor, path, branch }),
275 renameBranch: (actor, path, from, to) => call("rename_branch", { actor, path, from, to }),
276 resolveBranch: (repoId, branch) => call("resolve_branch", { repoId, branch }),
277 statusById: (id) => call("status_by_id", { id }),
Merge branch 'worktree-agent-a2013627e5ea4ab13'278 storageOptions: () => call("storage_options", {}),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look279 resolvePath: (path) => call("resolve_path", { path }),
Rust repos service with shipping; pull requests kept in the model280 tree: (path, viewer, ref, treePath) =>
281 call("tree", { path, viewer, ref, treePath }),
282 blob: (path, viewer, ref, filePath) =>
283 call("blob", { path, viewer, ref, filePath }),
284 log: (path, viewer, ref, limit) => call("log", { path, viewer, ref, limit }),
Agents as a team: lifecycle, merge queue, billing and a new shell285 blame: (path, viewer, ref, filePath) => call("blame", { path, viewer, ref, filePath }),
Issues and pull requests replace intents and attempts286 forkForPull: (sourceId, pullId, actor) =>
287 call("fork_for_pull", { sourceId, pullId, actor }),
Rust repos service with shipping; pull requests kept in the model288 gitAccess: (path, viewer, service) =>
289 call("git_access", { path, viewer, service }),
Pull requests from branches290 branches: (path, viewer) => call("branches", { path, viewer }),
Branches and Tags pages, each file's last commit, and the branch menu on files291 lastCommits: (path, viewer, ref, treePath) => call("last_commits", { path, viewer, ref, treePath }),
292 tags: (path, viewer) => call("tags", { path, viewer }),
Download ZIP from the Code button; a slimmer lifecycle panel; agent steps say what was done, not sandbox paths293 listFiles: (repoId, ref, limit) => call("list_files", { repoId, ref, skipDirs: [], limit }),
294 rawBlobs: (repoId, hashes, maxBytes) => call("raw_blobs", { repoId, hashes, maxBytes }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents295 commitFile: (repo, actor, file) => call("commit_file", { repo, actor, ...file }),
Pull requests from branches296 land: (sourceId, actor, branch) => call("land", { sourceId, actor, branch }),
297 compare: (repoId, viewer, base, head) => call("compare", { repoId, viewer, base, head }),
Merge branch 'worktree-agent-ac5b181a013e54348'298 claimBackups: (limit, maxRunning) => call("claim_backups", { limit, maxRunning }),
299 // The sandbox's own calls are snake_case (they come through the API).
300 failBackup: (jobId, token, error) => call("backup_fail", { job_id: jobId, token, error }),
Rust repos service with shipping; pull requests kept in the model301 };
302}
Work service in Rust, with RFC 3339 timestamps303
304export function workClient(service: ServiceBinding): WorkApi {
305 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
306 return {
Issues and pull requests replace intents and attempts307 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 step308 delegateIssue: (actor, repo, input) => call("delegate_issue", { actor, repo, ...input }),
Issues and pull requests replace intents and attempts309 listIssues: (repo, viewer, filter = {}) => call("list_issues", { repo, viewer, ...filter }),
310 getIssue: (repo, number, viewer) => call("get_issue", { repo, number, viewer }),
311 updateIssue: (actor, repo, number, input) =>
312 call("update_issue", { actor, repo, number, ...input }),
313 closeIssue: (actor, repo, number, reason) =>
314 call("close_issue", { actor, repo, number, reason }),
315 reopenIssue: (actor, repo, number) => call("reopen_issue", { actor, repo, number }),
316 listLabels: (repo, viewer) => call("list_labels", { repo, viewer }),
317 counts: (repo, viewer) => call("counts", { repo, viewer }),
Acceptance checks in sandboxes, line comments and review verdicts318 addComment: (actor, repo, number, comment) =>
319 call("add_comment", { actor, repo, number, ...comment }),
320 startChecks: (pullId) => call("start_checks", { pullId }),
321 reportChecks: (runId, token, report) =>
322 call("report_checks", { runId, token, ...report }),
Agents as a team: lifecycle, merge queue, billing and a new shell323 startReview: (pullId) => call("start_review", { pullId }),
324 failReview: (runId, token, error) => call("report_review", { runId, token, error }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains325 startMergecheck: (pullId) => call("start_mergecheck", { pullId }),
326 failMergecheck: (pullId, token, error) => call("report_mergecheck", { pullId, token, error }),
Agents as a team: lifecycle, merge queue, billing and a new shell327 advance: (pullId) => call("advance", { pullId }),
328 stall: (pullId, reason) => call("stall", { pullId, reason }),
329 managedPulls: (repoId) => call("managed_pulls", { repoId }),
330 queue: (repo, viewer) => call("queue", { repo, viewer }),
331 queueBuild: (repoId) => call("queue_build", { repoId }),
332 failQueue: (entryId, token, error) => call("report_queue", { entryId, token, error }),
333 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 request334 messageAgent: (actor, repo, number, body) => call("message_agent", { actor, repo, number, body }),
Agents as a team: lifecycle, merge queue, billing and a new shell335 catchUpJob: (pullId) => call("catch_up_job", { pullId }),
Agents asked while not at work are woken to answer336 wakeForMessages: (pullId) => call("wake_for_messages", { pullId }),
Agents as a team: lifecycle, merge queue, billing and a new shell337 getSettings: (repo, viewer) => call("get_settings", { repo, viewer }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents338 seenChecks: (repo, viewer) => call("seen_checks", { repo, viewer }),
Agents as a team: lifecycle, merge queue, billing and a new shell339 updateSettings: (actor, repo, settings) =>
340 call("update_settings", { actor, repo, settings }),
Issues and pull requests replace intents and attempts341 openPull: (actor, repo, input) => call("open_pull", { actor, repo, ...input }),
342 listPulls: (repo, viewer, state) => call("list_pulls", { repo, viewer, state }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents343 pullsForRepos: (repoIds, viewer, limit) => call("pulls_for_repos", { repoIds, viewer, limit }),
Issues and pull requests replace intents and attempts344 getPull: (repo, number, viewer) => call("get_pull", { repo, number, viewer }),
Agents as a team: lifecycle, merge queue, billing and a new shell345 updatePull: (actor, repo, number, changes) =>
346 call("update_pull", { actor, repo, number, ...changes }),
Catching up with main takes seconds when the two sides touched different files347 catchUpPull: (actor, repo, number) => call("catch_up_pull", { actor, repo, number }),
Issues and pull requests replace intents and attempts348 readyPull: (actor, repo, number, summary) =>
349 call("ready_pull", { actor, repo, number, summary }),
350 closePull: (actor, repo, number) => call("close_pull", { actor, repo, number }),
Acceptance checks in sandboxes, line comments and review verdicts351 mergePull: (actor, repo, number, options = {}) =>
352 call("merge_pull", { actor, repo, number, ...options }),
Issues and pull requests replace intents and attempts353 listActivePulls: (viewer) => call("list_active_pulls", { viewer }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains354 byAuthor: (username, viewer, filter = {}) => call("by_author", { username, viewer, ...filter }),
Agents as a team: lifecycle, merge queue, billing and a new shell355 startPlan: (actor, repo, brief) => call("start_plan", { actor, repo, brief }),
356 failPlan: (planId, token, error) => call("report_plan", { planId, token, error }),
357 getPlan: (repo, viewer, id) => call("get_plan", { repo, viewer, id }),
358 listPlans: (repo, viewer) => call("list_plans", { repo, viewer }),
359 applyPlan: (actor, repo, id, options = {}) =>
360 call("apply_plan", { actor, repo, id, ...options }),
361 queueIssue: (actor, repo, number, queued) =>
362 call("queue_issue", { actor, repo, number, queued }),
363 readyIssues: (repoId) => call("ready_issues", { repoId }),
364 listAssignedIssues: (viewer) => call("list_assigned_issues", { viewer }),
Issues and pull requests replace intents and attempts365 appendSession: (actor, repo, number, entries) =>
366 call("append_session", { actor, repo, number, entries }),
367 readSession: (repo, number, viewer, afterSeq = 0) =>
368 call("read_session", { repo, number, viewer, afterSeq }),
Work service in Rust, with RFC 3339 timestamps369 };
370}
Events service in Rust, with RFC 3339 times and accurate push events371
Agents as a team: lifecycle, merge queue, billing and a new shell372export function billingClient(service: ServiceBinding): BillingApi {
373 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
374 return {
375 status: () => call("status", {}),
376 account: (workspace, viewer) => call("account", { workspace, viewer }),
377 ledger: (workspace, viewer) => call("ledger", { workspace, viewer }),
The statement is a month at a time, a line per kind of charge378 statement: (workspace, viewer, month = null, group = "day") => call("statement", { workspace, viewer, month, group }),
379 statementEntries: (workspace, viewer, filter) =>
380 call("statement_entries", {
381 workspace,
382 viewer,
383 month: filter.month,
384 kind: filter.kind,
385 day: filter.day ?? null,
386 project: filter.project ?? null,
387 before: filter.before ?? null,
388 }),
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request389 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 mix390 tokenUsage: (workspace, viewer, options = {}) =>
391 call("token_usage", { workspace, viewer, person: options.person ?? null, days: options.days ?? null }),
392 recordTokens: (usage) => call("record_tokens", usage),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look393 checkout: (actor, workspace, amountCents, returnUrl, method = "card") =>
394 call("checkout", { actor, workspace, amountCents, returnUrl, method }),
Agents as a team: lifecycle, merge queue, billing and a new shell395 confirm: (workspace, viewer, session) => call("confirm", { workspace, viewer, session }),
396 canStart: (workspace) => call("can_start", { workspace }),
A free allowance on g1t's models, so anyone can try its agents397 trial: (workspace, exempt) => call("trial", { workspace, exempt }),
Agents as a team: lifecycle, merge queue, billing and a new shell398 startRun: (run) => call("start_run", run),
Paid features: a workspace turns on Deployments with a monthly plan399 features: (workspace, viewer) => call("features", { workspace, viewer }),
400 subscribe: (actor, workspace, feature, returnUrl) =>
401 call("subscribe", { actor, workspace, feature, returnUrl }),
402 confirmSubscription: (workspace, viewer, session) =>
403 call("confirm_subscription", { workspace, viewer, session }),
404 cancelSubscription: (actor, workspace, feature, resume = false) =>
405 call("cancel_subscription", { actor, workspace, feature, resume }),
406 hasFeature: (workspace, feature) => call("has_feature", { workspace, feature }),
407 chargeFeature: (charge) => call("charge_feature", charge),
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace408 billingPortal: (actor, workspace, returnUrl) => call("billing_portal", { actor, workspace, return_url: returnUrl }),
Every sandbox is metered by the second409 recordSandbox: (usage) => call("record_sandbox", usage),
Usage limits: unpaid usage can only go so far410 limit: (workspace, viewer) => call("limit", { workspace, viewer }),
411 checkLimit: (workspace) => call("check_limit", { workspace }),
Prices keep themselves current with what g1t pays412 prices: () => call("prices", {}),
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas413 notePending: (workspace, source, costMicros, detail = null) => call("note_pending", { workspace, source, costMicros, detail }),
414 usageMeters: (workspace, viewer) => call("usage_meters", { workspace, viewer }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look415 setSpendLimit: (actor, workspace, spendLimitMicros, useFullLimit = false, raiseOnce = false) =>
416 call("set_spend_limit", { actor, workspace, spendLimitMicros, use_full_limit: useFullLimit, raise_once: raiseOnce }),
Two limits, real invoices, trust that grows by itself, sales signals417 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 put418 entitlements: (workspace) => call("entitlements", { workspace }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look419 reserve: (reservation) => call("reserve", reservation),
420 settle: (reservationId, actualMicros) => call("settle", { reservationId, actualMicros }),
421 cardCheck: (actor, workspace, returnUrl) => call("card_check", { actor, workspace, returnUrl }),
422 confirmCardCheck: (workspace, viewer, session) => call("confirm_card_check", { workspace, viewer, session }),
423 requestLimit: (actor, workspace, request) => call("request_limit", { actor, workspace, ...request }),
424 limitRequests: (workspace, viewer) => call("limit_requests", { workspace, viewer }),
425 confirmSpike: (actor, workspace, keepGoing) => call("confirm_spike", { actor, workspace, keepGoing }),
426 setCaps: (actor, workspace, caps) => call("set_caps", { actor, workspace, ...caps }),
Agents as a team: lifecycle, merge queue, billing and a new shell427 };
428}
429
Billing accounts, terms and enterprises; g1t is no longer free430export function billingAdminClient(service: ServiceBinding): BillingAdminApi {
431 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
432 return {
433 accounts: (query) => call("admin_accounts", { query: query ?? null }),
434 account: (id) => call("admin_account", { id }),
435 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 put436 setAllowances: (id, allowances, note, by) => call("admin_set_allowances", { id, allowances, note, by }),
Billing accounts, terms and enterprises; g1t is no longer free437 createEnterprise: (name, workspaces, by) => call("admin_create_enterprise", { name, workspaces, by }),
438 attach: (workspace, account, by) => call("admin_attach", { workspace, account, by }),
439 credit: (workspace, amountMicros, note, by) => call("admin_credit", { workspace, amount_micros: amountMicros, note, by }),
sudo: reset a test workspace's billing so it starts again as a new customer; refused on a live Stripe key, for comped workspaces and for an enterprise's440 resetBilling: (workspace, confirm, note, by) => call("admin_reset_billing", { workspace, confirm, note, by }),
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace441 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 dashboard442 stripe: (fix = false, by) => call("admin_stripe", { fix, by: by ?? null }),
Stripe webhooks, enterprise invoices, and sudo for both443 enterpriseBilling: (id, email, by) => call("admin_enterprise_billing", { id, email, by }),
444 invoiceEnterprise: (id, by) => call("admin_invoice_enterprise", { id, by }),
445 accountsFor: (workspaces) => call("admin_accounts", { query: null, workspaces }),
Two limits, real invoices, trust that grows by itself, sales signals446 signals: () => call("admin_signals", {}),
447 overview: () => call("admin_overview", {}),
448 sales: (workspace) => call("admin_sales", { workspace }),
449 setSales: (workspace, record, by) =>
450 call("admin_set_sales", {
451 workspace,
452 stage: record.stage,
453 owner: record.owner ?? null,
454 next_step: record.nextStep ?? null,
455 next_at: record.nextAt ?? null,
456 by,
457 }),
458 addNote: (workspace, text, by) => call("admin_add_note", { workspace, text, by }),
459 workspaceInvoices: (workspace) => call("admin_workspace_invoices", { workspace }),
Billing lists every invoice and every staff change; signals carry follow-ups460 allInvoices: (filter = {}) => call("admin_invoices", { status: filter.status ?? null, month: filter.month ?? null }),
461 audit: (filter = {}) =>
462 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 look463 limitRequests: (status = "open") => call("admin_limit_requests", { status }),
464 decideLimitRequest: (id, decision, amountMicros, note, by) =>
465 call("admin_decide_limit_request", { id, decision, amount_micros: amountMicros, note, by }),
466 overages: () => call("admin_overages", {}),
467 goodwill: (workspace, amountMicros, reason, by, day = null) =>
468 call("admin_goodwill", { workspace, amount_micros: amountMicros, reason, by, day }),
469 velocity: () => call("admin_velocity", {}),
470 recordPayment: (workspace, amountMicros, reference, note, by) =>
471 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 daily472 costs: (days) => call("admin_costs", { days: days ?? null }),
473 costAlerts: () => call("admin_cost_alerts", {}),
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays474 spendCaps: () => call("admin_spend_caps", {}),
475 liftBreaker: (note, by) => call("admin_lift_breaker", { note, by }),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily476 decideProposal: (id, decision, note, by) => call("admin_decide_proposal", { id, decision, note, by }),
477 setCostSettings: (settings, by) => call("admin_set_cost_settings", { settings, by }),
478 setCostMapping: (mapping, by) =>
479 call("admin_set_cost_mapping", {
480 product: mapping.product,
481 meter: mapping.meter,
482 bucket: mapping.bucket ?? "",
483 price_meter: mapping.priceMeter ?? null,
484 own_meter: mapping.ownMeter ?? null,
485 scale_to_own: mapping.scaleToOwn ?? false,
486 drift_percent: mapping.driftPercent ?? null,
487 note: mapping.note ?? "",
488 remove: mapping.remove ?? false,
489 by,
490 }),
491 runCosts: (by) => call("admin_run_costs", { by }),
Billing accounts, terms and enterprises; g1t is no longer free492 };
493}
494
Events service in Rust, with RFC 3339 times and accurate push events495export function eventsClient(service: ServiceBinding): EventsApi {
496 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
497 return {
498 publish: (events) => call("publish", { events }),
499 list: (query) => call("list", query),
500 };
501}
Integrations: your own model provider, alerts that open issues, tickets agents read502
503export function integrationsClient(service: ServiceBinding): IntegrationsApi {
504 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
505 return {
506 list: (workspace, viewer) => call("list", { workspace, viewer }),
507 connect: (actor, workspace, input) => call("connect", { actor, workspace, ...input }),
508 update: (actor, workspace, id, input) => call("update", { actor, workspace, id, ...input }),
509 disconnect: (actor, workspace, id) => call("disconnect", { actor, workspace, id }),
510 test: (actor, workspace, id) => call("test", { actor, workspace, id }),
511 deliveries: (workspace, viewer, id) => call("deliveries", { workspace, viewer, id }),
512 resolve: (workspace, viewer, reference) => call("resolve", { workspace, viewer, reference }),
513 references: (workspace, text, limit) => call("references", { workspace, text, limit }),
514 import: (actor, repo, reference, assign) => call("import", { actor, repo, reference, assign }),
515 links: (repo, number) => call("links", { repo, number }),
516 modelProvider: (workspace) => call("model_provider", { workspace }),
517 openModelSession: (run) => call("open_model_session", run),
518 modelUpstream: (token) => call("model_upstream", { token }),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily519 closeModelSessions: (tokenHashes) => call("close_model_sessions", { token_hashes: tokenHashes }),
Models per workspace: several providers, routed by kind of work520 routes: (workspace, viewer) => call("routes", { workspace, viewer }),
521 setRoutes: (actor, workspace, routes) => call("set_routes", { actor, workspace, routes }),
Integrations: your own model provider, alerts that open issues, tickets agents read522 };
523}
Webhooks: every event, to your own addresses, signed and retried524
525export function webhooksClient(service: ServiceBinding): WebhooksApi {
526 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
527 return {
528 list: (viewer, owner) => call("list", { viewer, ...owner }),
529 create: (actor, owner, input) => call("create", { actor, ...owner, ...input }),
530 update: (actor, owner, id, input) => call("update", { actor, ...owner, id, ...input }),
531 delete: (actor, owner, id) => call("delete", { actor, ...owner, id }),
532 ping: (actor, owner, id) => call("ping", { actor, ...owner, id }),
533 deliveries: (viewer, owner, id) => call("deliveries", { viewer, ...owner, id }),
534 redeliver: (actor, owner, deliveryId) => call("redeliver", { actor, ...owner, deliveryId }),
535 };
536}
Automations: rules in .g1t/automations that act when something happens537
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs538export function actionsClient(service: ServiceBinding): ActionsApi {
539 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
540 return {
541 workflows: (repo, viewer) => call("workflows", { repo, viewer }),
542 runs: (repo, viewer, filter = {}) => call("runs", { repo, viewer, ...filter }),
543 run: (repo, viewer, id) => call("run", { repo, viewer, id }),
544 logs: (repo, viewer, job, after = 0) => call("logs", { repo, viewer, job, after }),
545 dispatch: (actor, repo, workflow, ref, inputs) => call("dispatch", { actor, repo, workflow, ref, inputs }),
546 cancel: (actor, repo, id) => call("cancel", { actor, repo, id }),
547 rerun: (actor, repo, id, failedOnly = false) => call("rerun", { actor, repo, id, failed_only: failedOnly }),
548 setWorkflowEnabled: (actor, repo, workflow, enabled) =>
549 call("set_workflow_enabled", { actor, repo, workflow, enabled }),
550 settings: (actor, owner, kind) => call("settings", { actor, ...owner, kind }),
Secrets and variables: one list, rows per environment, for workflows and deployments551 setSetting: (actor, owner, kind, name, value, options = {}) =>
552 call("set_setting", { actor, ...owner, kind, name, value, ...options }),
553 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 docs554 };
555}
556
Deployments: a preview for every pull request, production on g1t.page557
Fast pages, required checks on the branch, self-hosted runners, honest incidents558/** Self-hosted runners, kept by the actions service. */
559export function runnersClient(service: ServiceBinding): RunnersApi {
560 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
561 return {
562 stuck: (viewer) => call("stuck_jobs", { viewer }),
563 list: (actor, owner) => call("runners", { actor, ...owner }),
564 createToken: (actor, owner, group) => call("create_registration_token", { actor, ...owner, group }),
565 remove: (actor, owner, id) => call("remove_runner", { actor, ...owner, id }),
566 groups: (actor, workspace) => call("runner_groups", { actor, workspace }),
567 setGroup: (actor, workspace, group) => call("set_runner_group", { actor, workspace, ...group }),
568 deleteGroup: (actor, workspace, id) => call("delete_runner_group", { actor, workspace, id }),
569 settings: (actor, owner) => call("runner_settings", { actor, ...owner }),
570 setSettings: (actor, owner, change) => call("set_runner_settings", { actor, ...owner, ...change }),
571 };
572}
573
Deployments: a preview for every pull request, production on g1t.page574export function deploymentsClient(service: ServiceBinding): DeploymentsApi {
575 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
576 return {
Projects: what a workspace builds and runs, first on every page577 settings: (project, viewer) => call("settings", { project, viewer }),
578 updateSettings: (actor, project, changes) => call("update_settings", { actor, project, changes }),
579 list: (project, viewer) => call("list", { project, viewer }),
580 get: (project, id, viewer) => call("get", { project, id, viewer }),
581 redeploy: (actor, project, branch) => call("redeploy", { actor, project, branch }),
582 takeDown: (actor, project, branch) => call("take_down", { actor, project, branch }),
Project dependencies: addresses, preview stacks, Affects, and agents who know583 stack: (actor, project, branch) => call("stack", { actor, project, branch }),
Projects: what a workspace builds and runs, first on every page584 overview: (workspace, viewer) => call("overview", { workspace, viewer }),
Deployments: a preview for every pull request, production on g1t.page585 usage: (workspace, viewer) => call("usage", { workspace, viewer }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains586 domains: (project, viewer) => call("domains", { project, viewer }),
587 addDomain: (actor, project, hostname, options = {}) =>
588 call("add_domain", { actor, project, hostname, twin: !!options.twin }),
589 removeDomain: (actor, project, id) => call("remove_domain", { actor, project, id }),
590 refreshDomain: (actor, project, id) => call("refresh_domain", { actor, project, id }),
Deployments: a preview for every pull request, production on g1t.page591 };
592}
Projects: what a workspace builds and runs, first on every page593
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member594/** Packages: the registries beside the code (services/packages). */
595export function packagesClient(service: ServiceBinding): PackagesApi {
596 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
597 return {
598 list: (workspace, viewer, filter = {}) =>
599 call("list_packages", {
600 workspace,
601 viewer,
602 ecosystem: filter.ecosystem ?? null,
603 repo_id: filter.repoId ?? null,
604 query: filter.query ?? null,
605 }),
606 get: (workspace, ecosystem, name, viewer) => call("get_package", { workspace, ecosystem, name, viewer }),
607 deleteVersion: (actor, workspace, ecosystem, name, version, surface) =>
608 call("delete_version", { actor, workspace, ecosystem, name, version, surface: surface ?? null }),
609 deletePackage: (actor, workspace, ecosystem, name, surface) =>
610 call("delete_package", { actor, workspace, ecosystem, name, surface: surface ?? null }),
611 set: (actor, workspace, ecosystem, name, change, surface) =>
612 call("set_package", {
613 actor,
614 workspace,
615 ecosystem,
616 name,
617 visibility: change.visibility ?? null,
618 link: change.link ?? null,
619 unlink: change.unlink ?? false,
620 surface: surface ?? null,
621 }),
622 storage: (workspace) => call("storage", { workspace }),
623 storageAll: () => call("storage_all", {}),
Composer from the workspace's own repositories, and go get from g1t.sh624 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 member625 };
626}
627
Projects: what a workspace builds and runs, first on every page628export function projectsClient(service: ServiceBinding): ProjectsApi {
629 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
630 return {
631 list: (workspace, viewer) => call("list", { workspace, viewer }),
632 get: (workspace, slug, viewer) => call("get", { workspace, slug, viewer }),
633 byRepo: (repoId) => call("by_repo", { repoId }),
634 create: (actor, workspace, input) => call("create", { actor, workspace, input }),
635 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 production636 deploymentsChanged: (projectId, enabled) => call("deployments_changed", { projectId, enabled }),
Project dependencies: addresses, preview stacks, Affects, and agents who know637 dependencies: (workspace, slug, viewer) => call("dependencies", { workspace, slug, viewer }),
638 addDependency: (actor, workspace, slug, on, as) => call("add_dependency", { actor, workspace, slug, on, as }),
639 removeDependency: (actor, workspace, slug, on) => call("remove_dependency", { actor, workspace, slug, on }),
640 graph: (projectId) => call("graph", { projectId }),
Projects: what a workspace builds and runs, first on every page641 };
642}

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