Skip to content

g1t/packages/contracts/src/clients.ts

741 lines43,893 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";
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar11import type { PullDetail, WorkApi } from "./work";
12import type { Result } from "./result";
Fast pages, required checks on the branch, self-hosted runners, honest incidents13import type { RunnersApi } from "./runners";
API and MCP server, Rust identity service, registration, site redesign14
15/** A service binding, as far as these clients need it. */
16export type ServiceBinding = {
17 fetch(input: string, init?: RequestInit): Promise<Response>;
18};
19
20/**
21 * Calls a method on a service that speaks the JSON protocol used by the
22 * Rust services: `POST /rpc/<method>` with the arguments as the body.
23 */
24async function rpc<T>(
25 service: ServiceBinding,
26 method: string,
27 args: object,
28): Promise<T> {
29 // The hostname is ignored; a service binding always reaches its service.
30 const response = await service.fetch(`https://service/rpc/${method}`, {
31 method: "POST",
32 headers: { "content-type": "application/json" },
33 body: JSON.stringify(args),
34 });
35 if (!response.ok) {
36 throw new Error(`${method} failed with status ${response.status}`);
37 }
Agents as a team: lifecycle, merge queue, billing and a new shell38 return (await response.json()) as T;
API and MCP server, Rust identity service, registration, site redesign39}
40
41export function identityClient(service: ServiceBinding): IdentityApi {
42 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
43 return {
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look44 register: (username, email, password, inviteCode, client) =>
45 call("register", { username, email, password, invite_code: inviteCode ?? null, client: client ?? null }),
46 signIn: (username, password, client) => call("sign_in", { username, password, client: client ?? null }),
API and MCP server, Rust identity service, registration, site redesign47 signOut: (sessionToken) => call("sign_out", { sessionToken }),
Email verification, password reset, and Git for AI scale positioning48 resendVerification: (user) => call("resend_verification", { user }),
49 verifyEmail: (token) => call("verify_email", { token }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look50 requestPasswordReset: (email, client) => call("request_password_reset", { email, client: client ?? null }),
Email verification, password reset, and Git for AI scale positioning51 resetPassword: (token, password) =>
52 call("reset_password", { token, password }),
Device sign-in replaces registering and minting tokens over the API53 deviceStart: (clientName) => call("device_start", { clientName }),
54 deviceLookup: (userCode) => call("device_lookup", { userCode }),
55 deviceResolve: (userCode, user, approve) =>
56 call("device_resolve", { userCode, user, approve }),
57 deviceClaim: (deviceCode) => call("device_claim", { deviceCode }),
OAuth 2.1 sign-in for MCP clients and other applications58 oauthAuthorize: (user, approval) => call("oauth_authorize", { user, ...approval }),
59 oauthExchange: (code, codeVerifier, clientId, redirectUri) =>
60 call("oauth_exchange", { code, codeVerifier, clientId, redirectUri }),
61 oauthRefresh: (refreshToken, clientId) =>
62 call("oauth_refresh", { refreshToken, clientId }),
63 listOAuthGrants: (user) => call("list_oauth_grants", { user }),
64 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 step65 updateOAuthGrant: (user, id, grant) =>
66 call("update_oauth_grant", { user, id, scopes: grant.scopes }),
Workspaces own repositories67 createWorkspace: (user, slug, name) => call("create_workspace", { user, slug, name }),
68 getWorkspace: (slug) => call("get_workspace", { slug }),
Merge branch 'worktree-agent-a2013627e5ea4ab13'69 workspaceResidency: (slug) => call("workspace_residency", { slug }),
70 setWorkspaceResidency: (actor, slug, residency) => call("set_workspace_residency", { actor, slug, residency }),
Workspaces own repositories71 listMembers: (slug, viewer) => call("list_members", { slug, viewer }),
72 addMember: (actor, slug, username) => call("add_member", { actor, slug, username }),
73 removeMember: (actor, slug, username) =>
74 call("remove_member", { actor, slug, username }),
Agents as a team: lifecycle, merge queue, billing and a new shell75 updateWorkspace: (actor, slug, details) =>
76 call("update_workspace", { actor, slug, ...details }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains77 renameWorkspace: (actor, slug, newSlug) => call("rename_workspace", { actor, slug, newSlug }),
78 checkWorkspaceRename: (actor, slug, newSlug) =>
79 call("check_workspace_rename", { actor, slug, newSlug }),
80 resolveSlug: (slug) => call("resolve_slug", { slug }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look81 deleteWorkspace: (actor, slug, confirm) => call("delete_workspace", { actor, slug, confirm }),
82 checkWorkspaceDeletion: (actor, slug) => call("check_workspace_deletion", { actor, slug }),
Workspace names and icons, and a component kit for every control83 setWorkspaceAvatar: (actor, slug, image) => call("set_workspace_avatar", { actor, slug, image }),
84 setUserAvatar: (user, image) => call("set_user_avatar", { user, image }),
Agents as a team: lifecycle, merge queue, billing and a new shell85 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 step86 createWorkspaceToken: (actor, slug, name, grant) =>
87 call("create_workspace_token", {
88 actor,
89 slug,
90 name,
91 scopes: grant?.scopes ?? null,
92 ttl_seconds: grant?.ttlSeconds ?? null,
93 }),
Agents as a team: lifecycle, merge queue, billing and a new shell94 removeWorkspaceToken: (actor, slug, id) =>
95 call("remove_workspace_token", { actor, slug, id }),
API and MCP server, Rust identity service, registration, site redesign96 userForSession: (sessionToken) => call("user_for_session", { sessionToken }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look97 registration: () => call("registration", {}),
98 listInvites: (user) => call("list_invites", { user }),
99 createInvite: (user, options = {}) =>
100 call("create_invite", { user, email: options.email ?? null, workspace: options.workspace ?? null }),
101 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 quotas102 checkInvite: (code, client, options = {}) =>
103 call("check_invite", {
104 code,
105 client: client ?? null,
106 viewer: options.viewer ?? null,
107 any_status: options.anyStatus ?? false,
108 }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look109 acceptInvite: (user, code) => call("accept_invite", { user, code }),
110 inviteMember: (actor, slug, email) => call("invite_member", { actor, slug, email }),
111 workspaceInvites: (slug, viewer) => call("workspace_invites", { slug, viewer }),
112 revokeWorkspaceInvite: (actor, slug, id) => call("revoke_workspace_invite", { actor, slug, id }),
113 requestAccess: (email, about, client) => call("request_access", { email, about, client: client ?? null }),
API and MCP server, Rust identity service, registration, site redesign114 userForGitCredentials: (username, secret) =>
115 call("user_for_git_credentials", { username, secret }),
116 userForAccessToken: (token) => call("user_for_access_token", { token }),
117 userForSshKey: (fingerprint) => call("user_for_ssh_key", { fingerprint }),
118 userByUsername: (username) => call("user_by_username", { username }),
What happened across an outcome, as a feed beside its graph119 usernames: (ids) => call("usernames", { ids }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains120 profile: (username) => call("profile", { username }),
121 updateProfile: (actor, fields) => call("update_profile", { actor, ...fields }),
122 profileWorkspaces: (username, viewer, publicIn) =>
123 call("profile_workspaces", { username, viewer, public: publicIn }),
API and MCP server, Rust identity service, registration, site redesign124 listSshKeys: (user) => call("list_ssh_keys", { user }),
125 addSshKey: (user, title, publicKey) =>
126 call("add_ssh_key", { user, title, publicKey }),
127 removeSshKey: (user, id) => call("remove_ssh_key", { user, id }),
128 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 step129 createAccessToken: (user, name, ttlSeconds, grant) =>
130 call("create_access_token", {
131 user,
132 name,
133 ttlSeconds,
134 scopes: grant?.scopes ?? null,
135 listed: grant?.listed ?? false,
136 }),
137 updateAccessToken: (user, id, grant) =>
138 call("update_access_token", { user, id, scopes: grant.scopes }),
Agents as a team: lifecycle, merge queue, billing and a new shell139 createAgentToken: (onBehalfOf, scope, ttlSeconds) =>
140 call("create_agent_token", { onBehalfOf, scope, ttlSeconds }),
API and MCP server, Rust identity service, registration, site redesign141 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 API142 createRunCredential: (input) => call("create_run_credential", input),
143 bindRunCredentials: (tokenHashes, runId) => call("bind_run_credentials", { tokenHashes, runId }),
144 revokeRunCredentials: (target) => call("revoke_run_credentials", target),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look145 // Who has access to a repository; see access.ts.
146 repoAccess: (owner, name, viewer) => call("repo_access", { viewer, path: { namespace: owner, name } }),
147 addCollaborator: (actor, owner, name, invitee, role) =>
148 call("add_collaborator", { actor, path: { namespace: owner, name }, invitee, role }),
149 setCollaboratorRole: (actor, owner, name, username, role) =>
150 call("set_collaborator_role", { actor, path: { namespace: owner, name }, username, role }),
151 removeCollaborator: (actor, owner, name, username) =>
152 call("remove_collaborator", { actor, path: { namespace: owner, name }, username }),
153 collaboratorPermission: (viewer, owner, name, username) =>
154 call("collaborator_permission", { viewer, path: { namespace: owner, name }, username }),
155 myRepoInvitations: (user) => call("my_repo_invitations", { user }),
156 respondRepoInvitation: (user, id, accept) => call("respond_repo_invitation", { user, id, accept }),
157 revokeRepoInvitation: (actor, owner, name, id) =>
158 call("revoke_repo_invitation", { actor, path: { namespace: owner, name }, id }),
159 setBasePermission: (actor, slug, base) => call("set_base_permission", { actor, slug, base_permission: base }),
160 outsideCollaborators: (viewer, slug) => call("outside_collaborators", { viewer, slug }),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar161 // Teams; see teams.ts.
162 listTeams: (viewer, workspace, query) => call("list_teams", { viewer, workspace, query: query ?? null }),
163 getTeam: (viewer, workspace, team) => call("get_team", { viewer, workspace, team }),
164 createTeam: (actor, workspace, team) => call("create_team", { actor, workspace, ...team }),
Merge branch 'worktree-agent-ad7c6d88d93adc817'165 setTeamCreation: (actor, slug, setting) => call("set_team_creation", { actor, slug, team_creation: setting }),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar166 updateTeam: (actor, workspace, team, changes) => call("update_team", { actor, workspace, team, ...changes }),
167 deleteTeam: (actor, workspace, team) => call("delete_team", { actor, workspace, team }),
168 teamMembers: (viewer, workspace, team, includeChildTeams) =>
169 call("team_members", { viewer, workspace, team, include_child_teams: includeChildTeams ?? false }),
170 setTeamMember: (actor, workspace, team, username, role) =>
171 call("set_team_member", { actor, workspace, team, username, role }),
172 removeTeamMember: (actor, workspace, team, username) =>
173 call("remove_team_member", { actor, workspace, team, username }),
174 childTeams: (viewer, workspace, team) => call("child_teams", { viewer, workspace, team }),
175 teamRepos: (viewer, workspace, team) => call("team_repos", { viewer, workspace, team }),
176 setTeamRepo: (actor, workspace, team, owner, name, role) =>
177 call("set_team_repo", { actor, workspace, team, repo: { namespace: owner, name }, role }),
178 removeTeamRepo: (actor, workspace, team, owner, name) =>
179 call("remove_team_repo", { actor, workspace, team, repo: { namespace: owner, name } }),
180 userTeams: (viewer, workspace, username) => call("user_teams", { viewer, workspace, username }),
181 teamMemberships: (viewer, workspace) => call("team_memberships", { viewer, workspace }),
API and MCP server, Rust identity service, registration, site redesign182 };
183}
Rust repos service with shipping; pull requests kept in the model184
Agents and memory, checks and conflicts, profiles, slug renames, custom domains185/**
186 * The slug a renamed workspace has now, for a `workspace.renamed` handler:
187 * asked of identity by the workspace's id, so that renames delivered twice
188 * or out of order converge. Falls back to the event's `to`.
189 */
190export async function currentWorkspaceSlug(
191 identity: ServiceBinding,
192 renamed: { workspaceId: string; to: string },
193): Promise<string> {
194 const names = await identityClient(identity).usernames([renamed.workspaceId]);
195 return names[renamed.workspaceId] ?? renamed.to;
196}
197
198/** The slugs whose rows move to `current`: the two a rename names, less `current`. */
199export function staleSlugs(renamed: { from: string; to: string }, current: string): string[] {
200 return [...new Set([renamed.from, renamed.to])].filter((slug) => slug !== current);
201}
202
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look203/**
204 * Where a transferred repository is now, as `namespace/name`, for a
205 * `repo.transferred` handler: asked of repos by id, so transfers delivered
206 * twice or out of order converge. Falls back to the event's destination.
207 */
208export async function currentRepoPath(
209 repos: ServiceBinding,
210 transferred: { repoId: string; name: string; to: string },
211): Promise<string> {
212 const path = await rpc<{ namespace: string; name: string } | null>(repos, "path_by_id", { id: transferred.repoId });
213 return path ? `${path.namespace}/${path.name}` : `${transferred.to}/${transferred.name}`;
214}
215
216/** The paths whose rows move to `current`: the two a transfer names, less `current`. */
217export function stalePaths(transferred: { name: string; from: string; to: string }, current: string): string[] {
218 return [...new Set([transferred.from, transferred.to].map((ns) => `${ns}/${transferred.name}`))].filter(
219 (path) => path !== current,
220 );
221}
222
223/**
224 * A repository's path change, from `repo.transferred` or `repo.renamed`,
225 * read the same way: the two paths (`namespace/name`) the event names, old
226 * then new. Null for any other event.
227 */
228export type RepoMove = { repoId: string; paths: [string, string] };
229
230export function repoMove(event: { type: string; data: unknown }): RepoMove | null {
231 const data = event.data as Record<string, string>;
232 if (event.type === "repo.transferred") {
233 return { repoId: data.repoId!, paths: [`${data.from}/${data.name}`, `${data.to}/${data.name}`] };
234 }
235 if (event.type === "repo.renamed") {
236 return { repoId: data.repoId!, paths: [`${data.namespace}/${data.from}`, `${data.namespace}/${data.to}`] };
237 }
238 return null;
239}
240
241/**
242 * Where a moved repository is now, as `namespace/name`: asked of repos by
243 * id, so moves delivered twice or out of order converge. Falls back to the
244 * event's new path.
245 */
246export async function currentMovedPath(repos: ServiceBinding, move: RepoMove): Promise<string> {
247 const path = await rpc<{ namespace: string; name: string } | null>(repos, "path_by_id", { id: move.repoId });
248 return path ? `${path.namespace}/${path.name}` : move.paths[1];
249}
250
251/** The paths whose rows move to `current`: the two a move names, less `current`. */
252export function staleMovedPaths(move: RepoMove, current: string): string[] {
253 return [...new Set(move.paths)].filter((path) => path !== current);
254}
255
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace256/** Staff-only identity. Only sudo binds to it; see `IdentityAdminApi`. */
257export function identityAdminClient(service: ServiceBinding): IdentityAdminApi {
258 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
259 return {
260 workspaces: (query) => call("admin_workspaces", { query: query ?? null }),
261 workspace: (slug) => call("admin_workspace", { slug }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look262 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 quotas263 waitlistPending: () => call("admin_waitlist_pending", {}),
264 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 look265 invites: (query) => call("admin_invites", { query: query ?? null }),
266 revokeInvite: (id, staff) => call("admin_revoke_invite", { id, staff }),
267 mintInvite: (email, staff) => call("admin_mint_invite", { email, staff }),
268 grantInvites: (target, name, amount, note, staff) =>
269 call("admin_grant_invites", { target, name, amount, note, staff }),
270 inviteTree: (username) => call("admin_invite_tree", { username }),
271 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 member272 deletedWorkspaces: () => call("admin_deleted_workspaces", {}),
273 restoreWorkspace: (workspaceId, staff) => call("admin_restore_workspace", { workspaceId, staff }),
274 purgeWorkspace: (workspaceId, staff, confirm) => call("admin_purge_workspace", { workspaceId, staff, confirm }),
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace275 };
276}
277
Rust repos service with shipping; pull requests kept in the model278export function reposClient(service: ServiceBinding): ReposApi {
279 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
280 return {
281 get: (path, viewer) => call("get", { path, viewer }),
282 getById: (id, viewer) => call("get_by_id", { id, viewer }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents283 readable: (ids, viewer) => call("readable", { ids, viewer }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains284 publicNamespaces: (ownerId) => call("public_namespaces", { ownerId }),
Rust repos service with shipping; pull requests kept in the model285 list: (viewer, options = {}) => call("list", { viewer, ...options }),
286 create: (owner, input) => call("create", { owner, ...input }),
Agents as a team: lifecycle, merge queue, billing and a new shell287 update: (actor, path, changes) => call("update", { actor, path, ...changes }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look288 transfer: (actor, path, to) => call("transfer", { actor, path, to }),
289 delete: (actor, path, confirm) => call("delete", { actor, path, confirm }),
290 deleted: (viewer, namespace) => call("deleted", { viewer, namespace }),
291 restore: (actor, path) => call("restore", { actor, path }),
292 purge: (actor, path, confirm) => call("purge", { actor, path, confirm }),
293 rename: (actor, path, name) => call("rename", { actor, path, name }),
294 archive: (actor, path, archived) => call("archive", { actor, path, archived }),
295 setVisibility: (actor, path, isPrivate, confirm) => call("set_visibility", { actor, path, isPrivate, confirm }),
296 setDefaultBranch: (actor, path, branch) => call("set_default_branch", { actor, path, branch }),
297 renameBranch: (actor, path, from, to) => call("rename_branch", { actor, path, from, to }),
298 resolveBranch: (repoId, branch) => call("resolve_branch", { repoId, branch }),
299 statusById: (id) => call("status_by_id", { id }),
Merge branch 'worktree-agent-a2013627e5ea4ab13'300 storageOptions: () => call("storage_options", {}),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look301 resolvePath: (path) => call("resolve_path", { path }),
Rust repos service with shipping; pull requests kept in the model302 tree: (path, viewer, ref, treePath) =>
303 call("tree", { path, viewer, ref, treePath }),
304 blob: (path, viewer, ref, filePath) =>
305 call("blob", { path, viewer, ref, filePath }),
306 log: (path, viewer, ref, limit) => call("log", { path, viewer, ref, limit }),
Agents as a team: lifecycle, merge queue, billing and a new shell307 blame: (path, viewer, ref, filePath) => call("blame", { path, viewer, ref, filePath }),
Issues and pull requests replace intents and attempts308 forkForPull: (sourceId, pullId, actor) =>
309 call("fork_for_pull", { sourceId, pullId, actor }),
Rust repos service with shipping; pull requests kept in the model310 gitAccess: (path, viewer, service) =>
311 call("git_access", { path, viewer, service }),
Pull requests from branches312 branches: (path, viewer) => call("branches", { path, viewer }),
Branches and Tags pages, each file's last commit, and the branch menu on files313 lastCommits: (path, viewer, ref, treePath) => call("last_commits", { path, viewer, ref, treePath }),
314 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 paths315 listFiles: (repoId, ref, limit) => call("list_files", { repoId, ref, skipDirs: [], limit }),
316 rawBlobs: (repoId, hashes, maxBytes) => call("raw_blobs", { repoId, hashes, maxBytes }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents317 commitFile: (repo, actor, file) => call("commit_file", { repo, actor, ...file }),
Pull requests from branches318 land: (sourceId, actor, branch) => call("land", { sourceId, actor, branch }),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar319 compare: (repoId, viewer, base, head, baseBranch) => call("compare", { repoId, viewer, base, head, baseBranch }),
Merge branch 'worktree-agent-ac5b181a013e54348'320 claimBackups: (limit, maxRunning) => call("claim_backups", { limit, maxRunning }),
321 // The sandbox's own calls are snake_case (they come through the API).
322 failBackup: (jobId, token, error) => call("backup_fail", { job_id: jobId, token, error }),
Rust repos service with shipping; pull requests kept in the model323 };
324}
Work service in Rust, with RFC 3339 timestamps325
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar326/**
327 * `PullDetail`'s own fields that the work service writes in snake_case:
328 * `g1t_contracts::work::PullDetail` has no camelCase renaming, though what
329 * it holds (`Pull`, `CheckRun` and the rest) does. Each with its name here.
330 */
331const PULL_DETAIL_FIELDS = [
332 ["review_pending", "reviewPending"],
333 ["earlier_checks", "earlierChecks"],
334 ["required_checks", "requiredChecks"],
335 ["code_owners", "codeOwners"],
336] as const;
337
338/**
339 * A pull request's detail as the work service sent it, with its own fields
340 * in the camelCase this package uses: read at the edge, by `workClient`'s
341 * `getPull`. Either spelling is taken, so a service that already sends
342 * camelCase reads the same.
343 */
344export function pullDetailFromWire(raw: Record<string, unknown>): PullDetail {
345 const detail: Record<string, unknown> = { ...raw };
346 for (const [snake, camel] of PULL_DETAIL_FIELDS) {
347 if (snake in detail) {
348 if (!(camel in detail)) detail[camel] = detail[snake];
349 delete detail[snake];
350 }
351 }
352 if (typeof detail.reviewPending !== "boolean") detail.reviewPending = false;
353 return detail as PullDetail;
354}
355
Work service in Rust, with RFC 3339 timestamps356export function workClient(service: ServiceBinding): WorkApi {
357 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
358 return {
Issues and pull requests replace intents and attempts359 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 step360 delegateIssue: (actor, repo, input) => call("delegate_issue", { actor, repo, ...input }),
Issues and pull requests replace intents and attempts361 listIssues: (repo, viewer, filter = {}) => call("list_issues", { repo, viewer, ...filter }),
362 getIssue: (repo, number, viewer) => call("get_issue", { repo, number, viewer }),
363 updateIssue: (actor, repo, number, input) =>
364 call("update_issue", { actor, repo, number, ...input }),
365 closeIssue: (actor, repo, number, reason) =>
366 call("close_issue", { actor, repo, number, reason }),
367 reopenIssue: (actor, repo, number) => call("reopen_issue", { actor, repo, number }),
368 listLabels: (repo, viewer) => call("list_labels", { repo, viewer }),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar369 saveLabel: (actor, repo, label) => call("save_label", { actor, repo, ...label }),
370 deleteLabel: (actor, repo, name) => call("delete_label", { actor, repo, name }),
371 addDefaultLabels: (actor, repo) => call("add_default_labels", { actor, repo }),
372 setLabels: (actor, repo, number, labels, change = "set") =>
373 call("set_labels", { actor, repo, number, labels, change }),
374 listMilestones: (repo, viewer, state) => call("list_milestones", { repo, viewer, state }),
375 getMilestone: (repo, number, viewer) => call("get_milestone", { repo, number, viewer }),
376 saveMilestone: (actor, repo, milestone) => call("save_milestone", { actor, repo, ...milestone }),
377 deleteMilestone: (actor, repo, number) => call("delete_milestone", { actor, repo, number }),
Issues and pull requests replace intents and attempts378 counts: (repo, viewer) => call("counts", { repo, viewer }),
Acceptance checks in sandboxes, line comments and review verdicts379 addComment: (actor, repo, number, comment) =>
380 call("add_comment", { actor, repo, number, ...comment }),
381 startChecks: (pullId) => call("start_checks", { pullId }),
382 reportChecks: (runId, token, report) =>
383 call("report_checks", { runId, token, ...report }),
Agents as a team: lifecycle, merge queue, billing and a new shell384 startReview: (pullId) => call("start_review", { pullId }),
385 failReview: (runId, token, error) => call("report_review", { runId, token, error }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains386 startMergecheck: (pullId) => call("start_mergecheck", { pullId }),
387 failMergecheck: (pullId, token, error) => call("report_mergecheck", { pullId, token, error }),
Agents as a team: lifecycle, merge queue, billing and a new shell388 advance: (pullId) => call("advance", { pullId }),
389 stall: (pullId, reason) => call("stall", { pullId, reason }),
390 managedPulls: (repoId) => call("managed_pulls", { repoId }),
391 queue: (repo, viewer) => call("queue", { repo, viewer }),
392 queueBuild: (repoId) => call("queue_build", { repoId }),
393 failQueue: (entryId, token, error) => call("report_queue", { entryId, token, error }),
394 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 request395 messageAgent: (actor, repo, number, body) => call("message_agent", { actor, repo, number, body }),
Agents as a team: lifecycle, merge queue, billing and a new shell396 catchUpJob: (pullId) => call("catch_up_job", { pullId }),
Agents asked while not at work are woken to answer397 wakeForMessages: (pullId) => call("wake_for_messages", { pullId }),
Agents as a team: lifecycle, merge queue, billing and a new shell398 getSettings: (repo, viewer) => call("get_settings", { repo, viewer }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents399 seenChecks: (repo, viewer) => call("seen_checks", { repo, viewer }),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar400 codeownersErrors: (repo, viewer, ref) => call("codeowners_errors", { repo, viewer, ref: ref ?? null }),
Agents as a team: lifecycle, merge queue, billing and a new shell401 updateSettings: (actor, repo, settings) =>
402 call("update_settings", { actor, repo, settings }),
Issues and pull requests replace intents and attempts403 openPull: (actor, repo, input) => call("open_pull", { actor, repo, ...input }),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar404 listPulls: (repo, viewer, state, filter = {}) => call("list_pulls", { repo, viewer, state, ...filter }),
Fast pages, required checks on the branch, self-hosted runners, honest incidents405 pullsForRepos: (repoIds, viewer, limit) => call("pulls_for_repos", { repoIds, viewer, limit }),
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar406 // Its own fields arrive in snake_case: read into camelCase here.
407 getPull: (repo, number, viewer) =>
408 call<Result<Record<string, unknown>>>("get_pull", { repo, number, viewer }).then(
409 (found): Result<PullDetail> => (found.ok ? { ok: true, value: pullDetailFromWire(found.value) } : found),
410 ),
Agents as a team: lifecycle, merge queue, billing and a new shell411 updatePull: (actor, repo, number, changes) =>
412 call("update_pull", { actor, repo, number, ...changes }),
Catching up with main takes seconds when the two sides touched different files413 catchUpPull: (actor, repo, number) => call("catch_up_pull", { actor, repo, number }),
Issues and pull requests replace intents and attempts414 readyPull: (actor, repo, number, summary) =>
415 call("ready_pull", { actor, repo, number, summary }),
416 closePull: (actor, repo, number) => call("close_pull", { actor, repo, number }),
Acceptance checks in sandboxes, line comments and review verdicts417 mergePull: (actor, repo, number, options = {}) =>
418 call("merge_pull", { actor, repo, number, ...options }),
Issues and pull requests replace intents and attempts419 listActivePulls: (viewer) => call("list_active_pulls", { viewer }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains420 byAuthor: (username, viewer, filter = {}) => call("by_author", { username, viewer, ...filter }),
Agents as a team: lifecycle, merge queue, billing and a new shell421 startPlan: (actor, repo, brief) => call("start_plan", { actor, repo, brief }),
422 failPlan: (planId, token, error) => call("report_plan", { planId, token, error }),
423 getPlan: (repo, viewer, id) => call("get_plan", { repo, viewer, id }),
424 listPlans: (repo, viewer) => call("list_plans", { repo, viewer }),
425 applyPlan: (actor, repo, id, options = {}) =>
426 call("apply_plan", { actor, repo, id, ...options }),
427 queueIssue: (actor, repo, number, queued) =>
428 call("queue_issue", { actor, repo, number, queued }),
429 readyIssues: (repoId) => call("ready_issues", { repoId }),
430 listAssignedIssues: (viewer) => call("list_assigned_issues", { viewer }),
Issues and pull requests replace intents and attempts431 appendSession: (actor, repo, number, entries) =>
432 call("append_session", { actor, repo, number, entries }),
433 readSession: (repo, number, viewer, afterSeq = 0) =>
434 call("read_session", { repo, number, viewer, afterSeq }),
Work service in Rust, with RFC 3339 timestamps435 };
436}
Events service in Rust, with RFC 3339 times and accurate push events437
Agents as a team: lifecycle, merge queue, billing and a new shell438export function billingClient(service: ServiceBinding): BillingApi {
439 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
440 return {
441 status: () => call("status", {}),
442 account: (workspace, viewer) => call("account", { workspace, viewer }),
443 ledger: (workspace, viewer) => call("ledger", { workspace, viewer }),
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging444 credits: (workspace, viewer) => call("credits", { workspace, viewer }),
The statement is a month at a time, a line per kind of charge445 statement: (workspace, viewer, month = null, group = "day") => call("statement", { workspace, viewer, month, group }),
446 statementEntries: (workspace, viewer, filter) =>
447 call("statement_entries", {
448 workspace,
449 viewer,
450 month: filter.month,
451 kind: filter.kind,
452 day: filter.day ?? null,
453 project: filter.project ?? null,
454 before: filter.before ?? null,
455 }),
Usage, like a hosting provider's: what agents cost, per day, task, repository and pull request456 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 mix457 tokenUsage: (workspace, viewer, options = {}) =>
458 call("token_usage", { workspace, viewer, person: options.person ?? null, days: options.days ?? null }),
459 recordTokens: (usage) => call("record_tokens", usage),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look460 checkout: (actor, workspace, amountCents, returnUrl, method = "card") =>
461 call("checkout", { actor, workspace, amountCents, returnUrl, method }),
Agents as a team: lifecycle, merge queue, billing and a new shell462 confirm: (workspace, viewer, session) => call("confirm", { workspace, viewer, session }),
463 canStart: (workspace) => call("can_start", { workspace }),
A free allowance on g1t's models, so anyone can try its agents464 trial: (workspace, exempt) => call("trial", { workspace, exempt }),
Agents as a team: lifecycle, merge queue, billing and a new shell465 startRun: (run) => call("start_run", run),
Paid features: a workspace turns on Deployments with a monthly plan466 features: (workspace, viewer) => call("features", { workspace, viewer }),
467 subscribe: (actor, workspace, feature, returnUrl) =>
468 call("subscribe", { actor, workspace, feature, returnUrl }),
469 confirmSubscription: (workspace, viewer, session) =>
470 call("confirm_subscription", { workspace, viewer, session }),
471 cancelSubscription: (actor, workspace, feature, resume = false) =>
472 call("cancel_subscription", { actor, workspace, feature, resume }),
473 hasFeature: (workspace, feature) => call("has_feature", { workspace, feature }),
474 chargeFeature: (charge) => call("charge_feature", charge),
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace475 billingPortal: (actor, workspace, returnUrl) => call("billing_portal", { actor, workspace, return_url: returnUrl }),
Every sandbox is metered by the second476 recordSandbox: (usage) => call("record_sandbox", usage),
Usage limits: unpaid usage can only go so far477 limit: (workspace, viewer) => call("limit", { workspace, viewer }),
478 checkLimit: (workspace) => call("check_limit", { workspace }),
Prices keep themselves current with what g1t pays479 prices: () => call("prices", {}),
status.g1t.sh with incident management, invites that land you in the workspace, settings as pages, usage without quotas480 notePending: (workspace, source, costMicros, detail = null) => call("note_pending", { workspace, source, costMicros, detail }),
481 usageMeters: (workspace, viewer) => call("usage_meters", { workspace, viewer }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look482 setSpendLimit: (actor, workspace, spendLimitMicros, useFullLimit = false, raiseOnce = false) =>
483 call("set_spend_limit", { actor, workspace, spendLimitMicros, use_full_limit: useFullLimit, raise_once: raiseOnce }),
Two limits, real invoices, trust that grows by itself, sales signals484 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 put485 entitlements: (workspace) => call("entitlements", { workspace }),
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look486 reserve: (reservation) => call("reserve", reservation),
487 settle: (reservationId, actualMicros) => call("settle", { reservationId, actualMicros }),
488 cardCheck: (actor, workspace, returnUrl) => call("card_check", { actor, workspace, returnUrl }),
489 confirmCardCheck: (workspace, viewer, session) => call("confirm_card_check", { workspace, viewer, session }),
490 requestLimit: (actor, workspace, request) => call("request_limit", { actor, workspace, ...request }),
491 limitRequests: (workspace, viewer) => call("limit_requests", { workspace, viewer }),
492 confirmSpike: (actor, workspace, keepGoing) => call("confirm_spike", { actor, workspace, keepGoing }),
493 setCaps: (actor, workspace, caps) => call("set_caps", { actor, workspace, ...caps }),
Usage, Billing settings and prepaid AI credit; fixes from the UX audit494 usageReport: (workspace, viewer, range) =>
495 call("usage_report", { workspace, viewer, from: range.from, until: range.until, products: range.products ?? [], projects: range.projects ?? [] }),
496 aiCredit: (workspace, viewer) => call("ai_credit", { workspace, viewer }),
497 buyAiCredit: (actor, workspace, amountCents, returnUrl) => call("buy_ai_credit", { actor, workspace, amountCents, returnUrl }),
498 confirmAiCredit: (workspace, viewer, session) => call("confirm_ai_credit", { workspace, viewer, session }),
499 setAiReload: (actor, workspace, reload) => call("set_ai_reload", { actor, workspace, ...reload }),
500 setBudget: (actor, workspace, budget) => call("set_budget", { actor, workspace, ...budget }),
501 billingDetails: (workspace, viewer) => call("billing_details", { workspace, viewer }),
502 setBillingDetails: (actor, workspace, details) => call("set_billing_details", { actor, workspace, ...details }),
Agents as a team: lifecycle, merge queue, billing and a new shell503 };
504}
505
Billing accounts, terms and enterprises; g1t is no longer free506export function billingAdminClient(service: ServiceBinding): BillingAdminApi {
507 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
508 return {
509 accounts: (query) => call("admin_accounts", { query: query ?? null }),
510 account: (id) => call("admin_account", { id }),
511 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 put512 setAllowances: (id, allowances, note, by) => call("admin_set_allowances", { id, allowances, note, by }),
Billing accounts, terms and enterprises; g1t is no longer free513 createEnterprise: (name, workspaces, by) => call("admin_create_enterprise", { name, workspaces, by }),
514 attach: (workspace, account, by) => call("admin_attach", { workspace, account, by }),
Billing: credits with a kind and expiry, discounts instead of comped, and safer charging515 credit: (workspace, amountMicros, note, by, options = { kind: "goodwill" }) =>
516 call("admin_credit", {
517 workspace,
518 amount_micros: amountMicros,
519 note,
520 by,
521 kind: options.kind,
522 expires_at: options.expiresAt ?? null,
523 refund_for: options.refundFor ?? null,
524 refund_day: options.refundDay ?? null,
525 }),
526 credits: (filter = {}) =>
527 call("admin_credits", {
528 workspace: filter.workspace ?? null,
529 kind: filter.kind ?? null,
530 month: filter.month ?? null,
531 by: filter.by ?? null,
532 }),
533 revokeCredit: (id, note, by) => call("admin_revoke_credit", { id, 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's534 resetBilling: (workspace, confirm, note, by) => call("admin_reset_billing", { workspace, confirm, note, by }),
Billing on Stripe's pages, month-end charges, warnings; sudo by workspace535 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 dashboard536 stripe: (fix = false, by) => call("admin_stripe", { fix, by: by ?? null }),
Stripe webhooks, enterprise invoices, and sudo for both537 enterpriseBilling: (id, email, by) => call("admin_enterprise_billing", { id, email, by }),
538 invoiceEnterprise: (id, by) => call("admin_invoice_enterprise", { id, by }),
539 accountsFor: (workspaces) => call("admin_accounts", { query: null, workspaces }),
Two limits, real invoices, trust that grows by itself, sales signals540 signals: () => call("admin_signals", {}),
541 overview: () => call("admin_overview", {}),
542 sales: (workspace) => call("admin_sales", { workspace }),
543 setSales: (workspace, record, by) =>
544 call("admin_set_sales", {
545 workspace,
546 stage: record.stage,
547 owner: record.owner ?? null,
548 next_step: record.nextStep ?? null,
549 next_at: record.nextAt ?? null,
550 by,
551 }),
552 addNote: (workspace, text, by) => call("admin_add_note", { workspace, text, by }),
553 workspaceInvoices: (workspace) => call("admin_workspace_invoices", { workspace }),
Billing lists every invoice and every staff change; signals carry follow-ups554 allInvoices: (filter = {}) => call("admin_invoices", { status: filter.status ?? null, month: filter.month ?? null }),
555 audit: (filter = {}) =>
556 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 look557 limitRequests: (status = "open") => call("admin_limit_requests", { status }),
558 decideLimitRequest: (id, decision, amountMicros, note, by) =>
559 call("admin_decide_limit_request", { id, decision, amount_micros: amountMicros, note, by }),
560 overages: () => call("admin_overages", {}),
561 goodwill: (workspace, amountMicros, reason, by, day = null) =>
562 call("admin_goodwill", { workspace, amount_micros: amountMicros, reason, by, day }),
563 velocity: () => call("admin_velocity", {}),
564 recordPayment: (workspace, amountMicros, reference, note, by) =>
565 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 daily566 costs: (days) => call("admin_costs", { days: days ?? null }),
567 costAlerts: () => call("admin_cost_alerts", {}),
Spend caps: a monthly budget for comped workspaces and a daily breaker on what g1t pays568 spendCaps: () => call("admin_spend_caps", {}),
569 liftBreaker: (note, by) => call("admin_lift_breaker", { note, by }),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily570 decideProposal: (id, decision, note, by) => call("admin_decide_proposal", { id, decision, note, by }),
571 setCostSettings: (settings, by) => call("admin_set_cost_settings", { settings, by }),
572 setCostMapping: (mapping, by) =>
573 call("admin_set_cost_mapping", {
574 product: mapping.product,
575 meter: mapping.meter,
576 bucket: mapping.bucket ?? "",
577 price_meter: mapping.priceMeter ?? null,
578 own_meter: mapping.ownMeter ?? null,
579 scale_to_own: mapping.scaleToOwn ?? false,
580 drift_percent: mapping.driftPercent ?? null,
581 note: mapping.note ?? "",
582 remove: mapping.remove ?? false,
583 by,
584 }),
585 runCosts: (by) => call("admin_run_costs", { by }),
Billing accounts, terms and enterprises; g1t is no longer free586 };
587}
588
Events service in Rust, with RFC 3339 times and accurate push events589export function eventsClient(service: ServiceBinding): EventsApi {
590 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
591 return {
592 publish: (events) => call("publish", { events }),
593 list: (query) => call("list", query),
594 };
595}
Integrations: your own model provider, alerts that open issues, tickets agents read596
597export function integrationsClient(service: ServiceBinding): IntegrationsApi {
598 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
599 return {
600 list: (workspace, viewer) => call("list", { workspace, viewer }),
601 connect: (actor, workspace, input) => call("connect", { actor, workspace, ...input }),
602 update: (actor, workspace, id, input) => call("update", { actor, workspace, id, ...input }),
603 disconnect: (actor, workspace, id) => call("disconnect", { actor, workspace, id }),
604 test: (actor, workspace, id) => call("test", { actor, workspace, id }),
605 deliveries: (workspace, viewer, id) => call("deliveries", { workspace, viewer, id }),
606 resolve: (workspace, viewer, reference) => call("resolve", { workspace, viewer, reference }),
607 references: (workspace, text, limit) => call("references", { workspace, text, limit }),
608 import: (actor, repo, reference, assign) => call("import", { actor, repo, reference, assign }),
609 links: (repo, number) => call("links", { repo, number }),
610 modelProvider: (workspace) => call("model_provider", { workspace }),
611 openModelSession: (run) => call("open_model_session", run),
612 modelUpstream: (token) => call("model_upstream", { token }),
Git storage hardened, pages in tens of milliseconds, honest security alerts, and costs reconciled daily613 closeModelSessions: (tokenHashes) => call("close_model_sessions", { token_hashes: tokenHashes }),
Models per workspace: several providers, routed by kind of work614 routes: (workspace, viewer) => call("routes", { workspace, viewer }),
615 setRoutes: (actor, workspace, routes) => call("set_routes", { actor, workspace, routes }),
Integrations: your own model provider, alerts that open issues, tickets agents read616 };
617}
Webhooks: every event, to your own addresses, signed and retried618
619export function webhooksClient(service: ServiceBinding): WebhooksApi {
620 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
621 return {
622 list: (viewer, owner) => call("list", { viewer, ...owner }),
623 create: (actor, owner, input) => call("create", { actor, ...owner, ...input }),
624 update: (actor, owner, id, input) => call("update", { actor, ...owner, id, ...input }),
625 delete: (actor, owner, id) => call("delete", { actor, ...owner, id }),
626 ping: (actor, owner, id) => call("ping", { actor, ...owner, id }),
627 deliveries: (viewer, owner, id) => call("deliveries", { viewer, ...owner, id }),
628 redeliver: (actor, owner, deliveryId) => call("redeliver", { actor, ...owner, deliveryId }),
629 };
630}
Automations: rules in .g1t/automations that act when something happens631
GitHub Actions on g1t, part three: .g1t/workflows, the pages, the docs632export function actionsClient(service: ServiceBinding): ActionsApi {
633 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
634 return {
635 workflows: (repo, viewer) => call("workflows", { repo, viewer }),
636 runs: (repo, viewer, filter = {}) => call("runs", { repo, viewer, ...filter }),
637 run: (repo, viewer, id) => call("run", { repo, viewer, id }),
638 logs: (repo, viewer, job, after = 0) => call("logs", { repo, viewer, job, after }),
639 dispatch: (actor, repo, workflow, ref, inputs) => call("dispatch", { actor, repo, workflow, ref, inputs }),
640 cancel: (actor, repo, id) => call("cancel", { actor, repo, id }),
641 rerun: (actor, repo, id, failedOnly = false) => call("rerun", { actor, repo, id, failed_only: failedOnly }),
642 setWorkflowEnabled: (actor, repo, workflow, enabled) =>
643 call("set_workflow_enabled", { actor, repo, workflow, enabled }),
644 settings: (actor, owner, kind) => call("settings", { actor, ...owner, kind }),
Secrets and variables: one list, rows per environment, for workflows and deployments645 setSetting: (actor, owner, kind, name, value, options = {}) =>
646 call("set_setting", { actor, ...owner, kind, name, value, ...options }),
647 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 docs648 };
649}
650
Deployments: a preview for every pull request, production on g1t.page651
Fast pages, required checks on the branch, self-hosted runners, honest incidents652/** Self-hosted runners, kept by the actions service. */
653export function runnersClient(service: ServiceBinding): RunnersApi {
654 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
655 return {
656 stuck: (viewer) => call("stuck_jobs", { viewer }),
657 list: (actor, owner) => call("runners", { actor, ...owner }),
658 createToken: (actor, owner, group) => call("create_registration_token", { actor, ...owner, group }),
659 remove: (actor, owner, id) => call("remove_runner", { actor, ...owner, id }),
660 groups: (actor, workspace) => call("runner_groups", { actor, workspace }),
661 setGroup: (actor, workspace, group) => call("set_runner_group", { actor, workspace, ...group }),
662 deleteGroup: (actor, workspace, id) => call("delete_runner_group", { actor, workspace, id }),
663 settings: (actor, owner) => call("runner_settings", { actor, ...owner }),
664 setSettings: (actor, owner, change) => call("set_runner_settings", { actor, ...owner, ...change }),
665 };
666}
667
Deployments: a preview for every pull request, production on g1t.page668export function deploymentsClient(service: ServiceBinding): DeploymentsApi {
669 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
670 return {
Projects: what a workspace builds and runs, first on every page671 settings: (project, viewer) => call("settings", { project, viewer }),
672 updateSettings: (actor, project, changes) => call("update_settings", { actor, project, changes }),
673 list: (project, viewer) => call("list", { project, viewer }),
674 get: (project, id, viewer) => call("get", { project, id, viewer }),
675 redeploy: (actor, project, branch) => call("redeploy", { actor, project, branch }),
676 takeDown: (actor, project, branch) => call("take_down", { actor, project, branch }),
Project dependencies: addresses, preview stacks, Affects, and agents who know677 stack: (actor, project, branch) => call("stack", { actor, project, branch }),
Projects: what a workspace builds and runs, first on every page678 overview: (workspace, viewer) => call("overview", { workspace, viewer }),
Deployments: a preview for every pull request, production on g1t.page679 usage: (workspace, viewer) => call("usage", { workspace, viewer }),
Agents and memory, checks and conflicts, profiles, slug renames, custom domains680 domains: (project, viewer) => call("domains", { project, viewer }),
681 addDomain: (actor, project, hostname, options = {}) =>
682 call("add_domain", { actor, project, hostname, twin: !!options.twin }),
683 removeDomain: (actor, project, id) => call("remove_domain", { actor, project, id }),
684 refreshDomain: (actor, project, id) => call("refresh_domain", { actor, project, id }),
Deployments: a preview for every pull request, production on g1t.page685 };
686}
Projects: what a workspace builds and runs, first on every page687
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member688/** Packages: the registries beside the code (services/packages). */
689export function packagesClient(service: ServiceBinding): PackagesApi {
690 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
691 return {
692 list: (workspace, viewer, filter = {}) =>
693 call("list_packages", {
694 workspace,
695 viewer,
696 ecosystem: filter.ecosystem ?? null,
697 repo_id: filter.repoId ?? null,
698 query: filter.query ?? null,
699 }),
700 get: (workspace, ecosystem, name, viewer) => call("get_package", { workspace, ecosystem, name, viewer }),
701 deleteVersion: (actor, workspace, ecosystem, name, version, surface) =>
702 call("delete_version", { actor, workspace, ecosystem, name, version, surface: surface ?? null }),
703 deletePackage: (actor, workspace, ecosystem, name, surface) =>
704 call("delete_package", { actor, workspace, ecosystem, name, surface: surface ?? null }),
705 set: (actor, workspace, ecosystem, name, change, surface) =>
706 call("set_package", {
707 actor,
708 workspace,
709 ecosystem,
710 name,
711 visibility: change.visibility ?? null,
712 link: change.link ?? null,
713 unlink: change.unlink ?? false,
714 surface: surface ?? null,
715 }),
716 storage: (workspace) => call("storage", { workspace }),
717 storageAll: () => call("storage_all", {}),
Composer from the workspace's own repositories, and go get from g1t.sh718 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 member719 };
720}
721
Projects: what a workspace builds and runs, first on every page722export function projectsClient(service: ServiceBinding): ProjectsApi {
723 const call = <T>(method: string, args: object) => rpc<T>(service, method, args);
724 return {
725 list: (workspace, viewer) => call("list", { workspace, viewer }),
726 get: (workspace, slug, viewer) => call("get", { workspace, slug, viewer }),
727 byRepo: (repoId) => call("by_repo", { repoId }),
728 create: (actor, workspace, input) => call("create", { actor, workspace, input }),
729 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 production730 deploymentsChanged: (projectId, enabled) => call("deployments_changed", { projectId, enabled }),
Project dependencies: addresses, preview stacks, Affects, and agents who know731 dependencies: (workspace, slug, viewer) => call("dependencies", { workspace, slug, viewer }),
732 addDependency: (actor, workspace, slug, on, as) => call("add_dependency", { actor, workspace, slug, on, as }),
733 removeDependency: (actor, workspace, slug, on) => call("remove_dependency", { actor, workspace, slug, on }),
734 graph: (projectId) => call("graph", { projectId }),
Projects: pinned and recent projects, per person per workspace735 shortcuts: (workspace, viewer) => call("shortcuts", { workspace, viewer }),
736 pin: (actor, workspace, slug, position) => call("pin", { actor, workspace, slug, position: position ?? null }),
737 unpin: (actor, workspace, slug) => call("unpin", { actor, workspace, slug }),
738 reorderPins: (actor, workspace, slugs) => call("reorder_pins", { actor, workspace, slugs }),
739 visited: (actor, projectId) => call("visited", { actor, projectId }),
Projects: what a workspace builds and runs, first on every page740 };
741}

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