Skip to content
169 linesCodeBlameRaw

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

Projects live: fixes from walking them end to end1import type { User, Viewer } from "./identity";
2import type { RepoPath } from "./repos";
3import type { Result } from "./result";
4
5/**
6 * Events, delivered to the addresses a repository or a workspace registers.
7 * Mirrors `crates/contracts/src/webhooks.rs`.
8 */
9
10/** Every event a webhook can be sent, in the order people are shown them. */
11export const EVENT_TYPES = [
12 "git.push",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look13 "branch.renamed",
Projects live: fixes from walking them end to end14 "repo.created",
15 "repo.forked",
Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look16 "repo.updated",
17 "repo.visibility_changed",
18 "repo.renamed",
19 "repo.transferred",
20 "repo.default_branch_changed",
21 "repo.archived",
22 "repo.unarchived",
23 "repo.deleted",
24 "repo.restored",
25 "repo.purged",
26 "repo.collaborator_added",
27 "repo.collaborator_removed",
28 "repo.collaborator_role_changed",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar29 "team.created",
30 "team.edited",
31 "team.deleted",
32 "team.member_added",
33 "team.member_role_changed",
34 "team.member_removed",
35 "team.repo_added",
36 "team.repo_role_changed",
37 "team.repo_removed",
Merge rulesets: branch and tag rules, agent-first, enforced on push and merge38 "ruleset.created",
39 "ruleset.updated",
40 "ruleset.deleted",
Projects live: fixes from walking them end to end41 "issue.opened",
42 "issue.updated",
43 "issue.assigned",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar44 "issue.labeled",
45 "issue.unlabeled",
46 "issue.milestoned",
47 "issue.demilestoned",
Projects live: fixes from walking them end to end48 "issue.closed",
49 "issue.reopened",
50 "comment.created",
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts51 "comment.edited",
52 "comment.deleted",
Projects live: fixes from walking them end to end53 "pull.opened",
54 "pull.ready",
55 "pull.updated",
56 "pull.merge_requested",
57 "pull.merged",
58 "pull.closed",
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts59 "pull.reopened",
60 "pull.converted_to_draft",
Events: review requests, assignments, stops and deployments are published61 "pull.assigned",
62 "pull.review_requested",
63 "pull.review_request_removed",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar64 "pull.labeled",
65 "pull.unlabeled",
66 "pull.milestoned",
67 "pull.demilestoned",
68 "pull.base_changed",
Events: review requests, assignments, stops and deployments are published69 "pull.stalled",
70 "pull.resumed",
Merge Actions: cross-repo workflows and actions, release and deployment triggers, step timeouts71 "release.created",
72 "release.published",
73 "release.released",
74 "release.prereleased",
75 "release.edited",
76 "release.unpublished",
77 "release.deleted",
Projects live: fixes from walking them end to end78 "agent.asked",
79 "checks.completed",
Merge checks: statuses and check runs on every commit80 "status.created",
81 "check_run.created",
82 "check_run.completed",
83 "check_run.rerequested",
84 "check_run.requested_action",
85 "check_suite.completed",
86 "check_suite.rerequested",
Projects live: fixes from walking them end to end87 "review.completed",
88 "workflow.completed",
Events: review requests, assignments, stops and deployments are published89 "deployment.succeeded",
90 "deployment.failed",
Merge branch 'main' into worktree-agent-a69aeabc4b0deeb9791 "deployment.created",
92 "deployment_status.created",
Projects live: fixes from walking them end to end93 "queue.changed",
94 "session.appended",
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member95 "package.published",
96 "package.version_deleted",
97 "package.deleted",
98 "package.visibility_changed",
Teams and CODEOWNERS, labels and milestones, dependency updates, the security suite, and a clearer top bar99 "secret_scanning_alert.created",
100 "secret_scanning_alert.fixed",
101 "secret_scanning_alert.dismissed",
102 "secret_scanning_alert.reopened",
103 "secret_scanning.bypass_requested",
104 "secret_scanning.bypass_reviewed",
105 "code_scanning_alert.created",
106 "code_scanning_alert.fixed",
107 "code_scanning_alert.dismissed",
108 "code_scanning_alert.reopened",
109 "vulnerability_alert.created",
110 "vulnerability_alert.fixed",
111 "vulnerability_alert.dismissed",
112 "vulnerability_alert.reopened",
Merge branch 'mirroring' into artifacts-mode113 "mirror.unreachable",
114 "mirror.reachable",
115 "mirror.state_changed",
116 "mirror.moved_in",
Projects live: fixes from walking them end to end117] as const;
118
119export type Hook = {
120 id: string;
121 scope: "repo" | "workspace";
122 workspace: string;
123 /** For a repository's webhook: `owner/name`. */
124 repo: string | null;
125 url: string;
126 /** Event types, or `["*"]` for all. */
127 events: string[];
128 active: boolean;
129 secretHint: string;
130 createdBy: string;
131 createdAt: string;
132 lastStatus: "delivered" | "pending" | "failed" | null;
133 lastDeliveredAt: string | null;
134};
135
136export type HookDelivery = {
137 id: string;
138 hookId: string;
139 eventId: string;
140 event: string;
141 status: "pending" | "delivered" | "failed";
142 attempts: number;
143 responseStatus: number | null;
144 responseBody: string | null;
145 error: string | null;
146 durationMs: number | null;
147 /** The JSON that was sent. */
148 payload: string;
149 createdAt: string;
150 deliveredAt: string | null;
151 nextAttemptAt: string | null;
152};
153
154/** A repository's webhooks, or with `repo` left out, the workspace's own. */
155export type HookOwner = { workspace: string; repo?: RepoPath };
156
157export interface WebhooksApi {
158 list(viewer: Viewer, owner: HookOwner): Promise<Result<Hook[]>>;
159 create(
160 actor: User,
161 owner: HookOwner,
162 input: { url: string; events?: string[]; secret?: string },
163 ): Promise<Result<{ hook: Hook; secret: string | null }>>;
164 update(actor: User, owner: HookOwner, id: string, input: { url?: string; events?: string[]; active?: boolean }): Promise<Result<Hook>>;
165 delete(actor: User, owner: HookOwner, id: string): Promise<Result<boolean>>;
166 ping(actor: User, owner: HookOwner, id: string): Promise<Result<HookDelivery>>;
167 deliveries(viewer: Viewer, owner: HookOwner, id: string): Promise<Result<HookDelivery[]>>;
168 redeliver(actor: User, owner: HookOwner, deliveryId: string): Promise<Result<HookDelivery>>;
169}

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